summaryrefslogblamecommitdiffstats
path: root/src/maingui/main.cpp
blob: 58ace07e0079b1e06f41d7540246840b066ddb18 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                       
                      
                  
                       
                        

                     
 

                                      

                                



                                      
 
                                   












                                                                                             



                                                            

                          
                        
 
 









                                     
#include <QApplication>
#include <QMessageBox>
#include <fstream>
#include "printergui.h"
#include "../backdrop.h"
#include <fcntl.h>
#include <sys/stat.h>

static Backdrop* showGrayBackground();

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

		Backdrop* bgWin = showGrayBackground();

		PrinterGui *w = new PrinterGui(argv, bgWin);
		bgWin->setMainWindow(w);
		w->show();
	}
	return a.exec();
}


static Backdrop* showGrayBackground()
{
	Backdrop *bg = new Backdrop;
	bg->show();
	bg->raise();
	bg->activateWindow();
	bg->move(0, 0);
	return bg;
}