mainwindow.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 "ui_mainwindow.h"
  20. #include "newflight.h"
  21. #include "editflight.h"
  22. #include "newacft.h"
  23. #include "easaview.h"
  24. #include "dbman.cpp"
  25. #include "calc.h"
  26. #include "homewidget.h"
  27. #include "logbookwidget.h"
  28. #include "settingswidget.h"
  29. #include <QTime>
  30. #include <QSqlDatabase>
  31. #include <QSqlDriver>
  32. #include <QSqlError>
  33. #include <QSqlQuery>
  34. #include <QSqlTableModel>
  35. #include <QTableView>
  36. #include <chrono>
  37. #include <QMessageBox>
  38. #include <QDir>
  39. #include <QFile>
  40. qlonglong SelectedFlightold = -1;
  41. MainWindow::MainWindow(QWidget *parent)
  42. : QMainWindow(parent)
  43. , ui(new Ui::MainWindow)
  44. {
  45. ui->setupUi(this);
  46. // Set up Toolbar
  47. ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  48. ui->toolBar->setIconSize(QSize(64,64));
  49. ui->actionLogbook->setIcon(QIcon(":/logbook_icon.png"));
  50. ui->actionHome->setIcon(QIcon(":/home_icon.svg"));
  51. ui->actionSettings->setIcon(QIcon(":/settings_icon.svg"));
  52. ui->actionQuit->setIcon(QIcon(":/quit_icon.svg"));
  53. // Adds space between toolbar items and actionSetting item
  54. auto *spacer = new QWidget();
  55. spacer->setMinimumWidth(10);
  56. spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
  57. ui->toolBar->insertWidget(ui->actionSettings,spacer);
  58. // create and show homeWidget
  59. auto hw = new homeWidget(this);
  60. ui->stackedWidget->addWidget(hw);
  61. ui->stackedWidget->setCurrentWidget(hw);
  62. }
  63. MainWindow::~MainWindow()
  64. {
  65. delete ui;
  66. }
  67. /*
  68. * Functions
  69. */
  70. void MainWindow::nope()
  71. {
  72. QMessageBox nope; //error box
  73. nope.setText("This feature is not yet available!");
  74. nope.exec();
  75. }
  76. /*
  77. * Slots
  78. */
  79. void MainWindow::on_actionNew_Flight_triggered()
  80. {
  81. NewFlight nf(this);
  82. nf.exec();
  83. }
  84. void MainWindow::on_actionQuit_triggered()
  85. {
  86. QApplication::quit();
  87. }
  88. void MainWindow::on_quitButton_clicked()
  89. {
  90. QApplication::quit();
  91. }
  92. void MainWindow::on_actionHome_triggered()
  93. {
  94. auto hw = new homeWidget(this);
  95. ui->stackedWidget->addWidget(hw);
  96. ui->stackedWidget->setCurrentWidget(hw);
  97. }
  98. void MainWindow::on_actionLogbook_triggered()
  99. {
  100. auto lw = new logbookWidget(this);
  101. ui->stackedWidget->addWidget(lw);
  102. ui->stackedWidget->setCurrentWidget(lw);
  103. }
  104. void MainWindow::on_actionSettings_triggered()
  105. {
  106. auto sw = new settingsWidget(this);
  107. ui->stackedWidget->addWidget(sw);
  108. ui->stackedWidget->setCurrentWidget(sw);
  109. }