summaryrefslogblamecommitdiffstats
path: root/src/server/main.cpp
blob: 8729af5d05c4f1918a32015186bb2b80d6a564f0 (plain) (tree)
1
2
3
4
5
6
7
8

                   

                                  
                               


                               










                                                 







                                                                  



















                                                                                        
                 

                                                                                                                                              
                 
         
 
 



                                                         
 

                                     
 
#include <iostream>
#include <stdlib.h>
#include "mainwindow/mainwindow.h"
#include "util/util.h"
#include "../shared/settings.h"

int main(int argc, char** argv)
{
	QString ipListUrl;
	if (argc != 2)
	{
		ipListUrl = "";
	} else {
		ipListUrl = argv[1];
	}
	QApplication app(argc, argv);
	app.setOrganizationName("openslx");
	app.setOrganizationDomain("openslx.org");
	app.setApplicationName("pvsmgr");
	QStringList supportedStyles = QStyleFactory::keys();
	for (QString style : PREFERRED_STYLES) {
		if (supportedStyles.contains(style)) {
			qDebug() << "Setting style to: " << style;
			app.setStyle(style);
			break;
		}
	}
	qsrand((uint)QDateTime::currentMSecsSinceEpoch());


	// Set the global path of the settings
	QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope, "/opt/");

	// Make sure settings directory exists
	USER_SETTINGS(settings);
	QFileInfo fi(settings.fileName());
	QDir path(fi.path());
	qDebug() << "User settings are in:" << settings.fileName();
	if (!path.exists())
		path.mkpath(path.absolutePath());
	// Now check if settings file exists. If not, copy system default (if available)
	if (!fi.exists())
	{
		SYSTEM_SETTINGS(sys);
		qDebug() << "System settings are in:" << sys.fileName();
		QFileInfo sysfi(sys.fileName());
		if (sysfi.exists())
		{
			if (!QFile::copy(sys.fileName(), settings.fileName()))
				qDebug() << "Copying default settings from " << sys.fileName() << " to " << settings.fileName() << " failed.";
		}
	}


	// use system locale as language to translate gui
	QTranslator translator;
	translator.load(":pvsmgr");
	app.installTranslator(&translator);

	MainWindow pvsmgr(ipListUrl);
	return app.exec();
}