From 5fb0a90ae26b4c23b1bf5c959d153b0a82e04b6d Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 5 Oct 2015 18:39:39 +0200 Subject: [printergui] Add simple error-message displaying command line option --- src/maingui/main.cpp | 28 ++++++++++++++++++---------- 1 file 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 +#include #include #include "printergui.h" #include @@ -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(); } + -- cgit v1.2.3-55-g7522