1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #include "mainwindow.h"
- #include "src/gui/dialogues/firstrundialog.h"
- #include "src/classes/runguard.h"
- #include <QApplication>
- #include <QProcess>
- #include <QSettings>
- #include <QFileInfo>
- const auto DATA_DIR = QLatin1String("data");
- bool setup()
- {
- if (!QDir(DATA_DIR).exists())
- QDir().mkdir(DATA_DIR);
- QDir settingspath(DATA_DIR + QLatin1Char('/') + QCoreApplication::organizationName());
- QString settingsfile = QCoreApplication::applicationName() + QLatin1String(".ini");
- QFileInfo check_file(settingspath,settingsfile);
- return check_file.exists() && check_file.isFile();
- };
- int main(int argc, char *argv[])
- {
- QCoreApplication::setOrganizationName("openPilotLog");
- QCoreApplication::setOrganizationDomain("https://github.com/fiffty-50/openpilotlog");
- QCoreApplication::setApplicationName("openPilotLog");
- QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, DATA_DIR);
- QSettings::setDefaultFormat(QSettings::IniFormat);
- QSettings settings;
- Db::connect();
- QApplication openPilotLog(argc, argv);
- if(!setup()){
- FirstRunDialog dialog;
- dialog.exec();
- }
-
- int selectedtheme = settings.value("main/theme").toInt();
- QDir::setCurrent("/themes");
- switch (selectedtheme) {
- case 1:{
- qDebug() << "main :: Loading light theme";
- QFile file(":light.qss");
- file.open(QFile::ReadOnly | QFile::Text);
- QTextStream stream(&file);
- openPilotLog.setStyleSheet(stream.readAll());
- break;
- }
- case 2:{
- qDebug() << "Loading dark theme";
- QFile file(":dark.qss");
- file.open(QFile::ReadOnly | QFile::Text);
- QTextStream stream(&file);
- openPilotLog.setStyleSheet(stream.readAll());
- break;
- }
- default:
- break;
- }
-
- RunGuard guard("opl_single_key");
- if ( !guard.tryToRun() ){
- qDebug() << "Another Instance is already running. Exiting.";
- return 0;
- }
- MainWindow w;
-
- w.show();
- return openPilotLog.exec();
- }
|