2
0

main.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <QCoreApplication>
  20. #include <QApplication>
  21. #include <QFile>
  22. #include <QTextStream>
  23. #include <QDir>
  24. #include <QPalette>
  25. #include <QColor>
  26. #include "dbman.cpp"
  27. #include <QDebug>
  28. int selectedtheme = 1; //Variable to store theming information
  29. int main(int argc, char *argv[])
  30. {
  31. QCoreApplication::setOrganizationName("Fiffty50");
  32. QCoreApplication::setOrganizationDomain("f-cloud.ch");
  33. QCoreApplication::setApplicationName("openLog");
  34. QApplication openLog(argc, argv);
  35. db::connect(); //connect to the database
  36. //Theming with CSS inlcues QFile,QTextStream, QDir, themes folder and TARGET = flog, RESOURCES = themes/breeze.qrc in pro
  37. // credit: https://github.com/Alexhuszagh/BreezeStyleSheets
  38. selectedtheme = db::retreiveSetting("10").toInt();
  39. QDir::setCurrent("/themes");
  40. if (selectedtheme == 1){
  41. qDebug() << "Loading light theme";
  42. QFile file(":light.qss");
  43. file.open(QFile::ReadOnly | QFile::Text);
  44. QTextStream stream(&file);
  45. openLog.setStyleSheet(stream.readAll());
  46. }else if (selectedtheme == 2){
  47. qDebug() << "Loading dark theme";
  48. QFile file(":dark.qss");
  49. file.open(QFile::ReadOnly | QFile::Text);
  50. QTextStream stream(&file);
  51. openLog.setStyleSheet(stream.readAll());
  52. }
  53. MainWindow w;
  54. w.show();
  55. return openLog.exec();
  56. }