summaryrefslogtreecommitdiffstats
path: root/src/maingui/main.cpp
blob: c22ad7b7d26d673af66059fd4fff2b84f76fa590 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <QApplication>
#include <QMessageBox>
#include <fstream>
#include "printergui.h"
#include <fcntl.h>
#include <sys/stat.h>

int main(int argc, char *argv[])
{
	// First check parameter count
	if (argc != 3) {
		return 2;
	}

	QApplication a(argc, argv);

	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();
}