12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "mainwindow.h"
- #include "src/gui/dialogues/firstrundialog.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;
- 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;
- }
- MainWindow w;
-
- w.show();
- return openPilotLog.exec();
- }
|