main.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. *openPilot Log - A FOSS Pilot Logbook Application
  3. *Copyright (C) 2020 Felix Turowsky
  4. *
  5. *This program is free software: you can redistribute it and/or modify
  6. *it under the terms of the GNU General Public License as published by
  7. *the Free Software Foundation, either version 3 of the License, or
  8. *(at your option) any later version.
  9. *
  10. *This program is distributed in the hope that it will be useful,
  11. *but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. *MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. *GNU General Public License for more details.
  14. *
  15. *You should have received a copy of the GNU General Public License
  16. *along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. #include "mainwindow.h"
  19. #include <QApplication>
  20. #include <QProcess>
  21. #include <QSettings>
  22. int main(int argc, char *argv[])
  23. {
  24. QCoreApplication::setOrganizationName("openPilotLog");
  25. QCoreApplication::setOrganizationDomain("https://github.com/fiffty-50/openpilotlog");
  26. QCoreApplication::setApplicationName("openPilotLog");
  27. if(!QDir("data").exists()){
  28. QDir().mkdir("data");
  29. }
  30. QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,"data");
  31. QSettings::setDefaultFormat(QSettings::IniFormat);
  32. QSettings settings;
  33. QApplication openPilotLog(argc, argv);
  34. //Theming
  35. int selectedtheme = settings.value("main/theme").toInt();
  36. QDir::setCurrent("/themes");
  37. switch (selectedtheme) {
  38. case 1:
  39. {
  40. qDebug() << "main :: Loading light theme";
  41. QFile file(":light.qss");
  42. file.open(QFile::ReadOnly | QFile::Text);
  43. QTextStream stream(&file);
  44. openPilotLog.setStyleSheet(stream.readAll());
  45. break;
  46. }
  47. case 2:
  48. qDebug() << "Loading dark theme";
  49. QFile file(":dark.qss");
  50. file.open(QFile::ReadOnly | QFile::Text);
  51. QTextStream stream(&file);
  52. openPilotLog.setStyleSheet(stream.readAll());
  53. break;
  54. }
  55. MainWindow w;
  56. w.show();
  57. return openPilotLog.exec();
  58. }