main.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3. #include <QProcess>
  4. #include <QSettings>
  5. int main(int argc, char *argv[])
  6. {
  7. QCoreApplication::setOrganizationName("openPilotLog");
  8. QCoreApplication::setOrganizationDomain("https://github.com/fiffty-50/openpilotlog");
  9. QCoreApplication::setApplicationName("openPilotLog");
  10. if(!QDir("data").exists()){
  11. QDir().mkdir("data");
  12. }
  13. QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,"data");
  14. QSettings::setDefaultFormat(QSettings::IniFormat);
  15. QSettings settings;
  16. QApplication openPilotLog(argc, argv);
  17. //Theming
  18. int selectedtheme = settings.value("main/theme").toInt();
  19. QDir::setCurrent("/themes");
  20. switch (selectedtheme) {
  21. case 1:
  22. {
  23. qDebug() << "main :: Loading light theme";
  24. QFile file(":light.qss");
  25. file.open(QFile::ReadOnly | QFile::Text);
  26. QTextStream stream(&file);
  27. openPilotLog.setStyleSheet(stream.readAll());
  28. break;
  29. }
  30. case 2:
  31. qDebug() << "Loading dark theme";
  32. QFile file(":dark.qss");
  33. file.open(QFile::ReadOnly | QFile::Text);
  34. QTextStream stream(&file);
  35. openPilotLog.setStyleSheet(stream.readAll());
  36. break;
  37. }
  38. MainWindow w;
  39. w.show();
  40. return openPilotLog.exec();
  41. }