From e418e5025928cf0335eece9b1045023a0cd148a7 Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Fri, 27 Oct 2017 21:29:15 +0200 Subject: [PATCH] Add desktop notification when -p is invalid --- src/main.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 30d5e1a8..154f01a4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -21,6 +21,7 @@ #include "src/utils/filenamehandler.h" #include "src/utils/confighandler.h" #include "src/cli/commandlineparser.h" +#include "src/utils/systemnotification.h" #include #include #include @@ -116,21 +117,25 @@ int main(int argc, char *argv[]) { "- Named colors like 'blue' or 'red'\n" "You may need to escape the '#' sign as in '\\#FFF'"; + const QString delayErr = "Ivalid delay, it must be higher than 0"; auto delayChecker = [&parser](const QString &delayValue) -> bool { int value = delayValue.toInt(); return value >= 0; }; - QString delayErr = "Ivalid delay, it must be higher than 0"; - auto pathChecker = [&parser](const QString &pathValue) -> bool { - return QDir(pathValue).exists(); + const QString pathErr = "Ivalid path, it must be a real path in the system"; + auto pathChecker = [&parser, pathErr](const QString &pathValue) -> bool { + bool res = QDir(pathValue).exists(); + if (!res) { + SystemNotification().sendMessage(QObject::tr(pathErr.toLatin1().data())); + } + return res; }; - QString pathErr = "Ivalid path, it must be a real path in the system"; + const QString booleanErr = "Ivalid value, it must be defined as 'true' or 'false'"; auto booleanChecker = [&parser](const QString &value) -> bool { return value == "true" || value == "false"; }; - QString booleanErr = "Ivalid value, it must be defined as 'true' or 'false'"; contrastColorOption.addChecker(colorChecker, colorErr); mainColorOption.addChecker(colorChecker, colorErr);