123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include "mainwindow.h"
- #include "src/gui/dialogues/firstrundialog.h"
- #include "src/classes/runguard.h"
- #include <QApplication>
- #include <QProcess>
- #include <QSettings>
- #include <QFileInfo>
- #include "src/experimental/DataBase.h"
- 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;
- experimental::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();
- }
|