diff options
author | Simon Rettberg | 2015-10-05 18:39:39 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-10-05 18:39:39 +0200 |
commit | 5fb0a90ae26b4c23b1bf5c959d153b0a82e04b6d (patch) | |
tree | 96aec9766d4f9980ddc157130938352ae703b606 | |
parent | Man man man, Manuel... (diff) | |
download | printergui-5fb0a90ae26b4c23b1bf5c959d153b0a82e04b6d.tar.gz printergui-5fb0a90ae26b4c23b1bf5c959d153b0a82e04b6d.tar.xz printergui-5fb0a90ae26b4c23b1bf5c959d153b0a82e04b6d.zip |
[printergui] Add simple error-message displaying command line option
-rw-r--r-- | src/maingui/main.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/maingui/main.cpp b/src/maingui/main.cpp index 53aa68f..c22ad7b 100644 --- a/src/maingui/main.cpp +++ b/src/maingui/main.cpp @@ -1,4 +1,5 @@ #include <QApplication> +#include <QMessageBox> #include <fstream> #include "printergui.h" #include <fcntl.h> @@ -11,16 +12,23 @@ int main(int argc, char *argv[]) return 2; } - // Check if file exists - int fh = open(argv[2], O_RDONLY); - if (fh < 0) { - fprintf(stderr, "ERROR: Could not open %s for reading..\n", argv[2]); - return 2; - } - close(fh); - QApplication a(argc, argv); - PrinterGui w(argv); - w.show(); + + if (strcmp(argv[1], "--error") == 0) { + QMessageBox::critical(NULL, "Verarbeitungsfehler", argv[2]); + return 0; + } else { + // Check if file exists + int fh = open(argv[2], O_RDONLY); + if (fh < 0) { + fprintf(stderr, "ERROR: Could not open %s for reading..\n", argv[2]); + return 2; + } + close(fh); + + PrinterGui *w = new PrinterGui(argv); + w->show(); + } return a.exec(); } + |