2
0

mainwindow.cpp 2.9 KB

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