mainwindow.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 "calc.h"
  25. #include "homewidget.h"
  26. #include "logbookwidget.h"
  27. #include "settingswidget.h"
  28. #include "dbsetup.h"
  29. MainWindow::MainWindow(QWidget *parent)
  30. : QMainWindow(parent)
  31. , ui(new Ui::MainWindow)
  32. {
  33. ui->setupUi(this);
  34. // Set up Toolbar
  35. ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  36. ui->toolBar->setIconSize(QSize(64,64));
  37. ui->actionLogbook->setIcon(QIcon(":/logbook_icon.png"));
  38. ui->actionHome->setIcon(QIcon(":/home_icon.svg"));
  39. ui->actionSettings->setIcon(QIcon(":/settings_icon.svg"));
  40. ui->actionQuit->setIcon(QIcon(":/quit_icon.svg"));
  41. ui->actionNewFlight->setIcon(QIcon(":/new_flight_icon.jpg"));
  42. // Adds space between toolbar items and actionSetting item
  43. auto *spacer = new QWidget();
  44. spacer->setMinimumWidth(10);
  45. spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
  46. ui->toolBar->insertWidget(ui->actionSettings,spacer);
  47. // create and show homeWidget
  48. auto hw = new homeWidget(this);
  49. ui->stackedWidget->addWidget(hw);
  50. ui->stackedWidget->setCurrentWidget(hw);
  51. }
  52. MainWindow::~MainWindow()
  53. {
  54. delete ui;
  55. }
  56. /*
  57. * Functions
  58. */
  59. void MainWindow::nope()
  60. {
  61. QMessageBox nope(this); //error box
  62. nope.setText("This feature is not yet available!");
  63. nope.exec();
  64. }
  65. /*
  66. * Slots
  67. */
  68. void MainWindow::on_actionQuit_triggered()
  69. {
  70. QApplication::quit();
  71. }
  72. void MainWindow::on_actionHome_triggered()
  73. {
  74. auto hw = new homeWidget(this);
  75. ui->stackedWidget->addWidget(hw);
  76. ui->stackedWidget->setCurrentWidget(hw);
  77. }
  78. void MainWindow::on_actionLogbook_triggered()
  79. {
  80. auto lw = new logbookWidget(this);
  81. ui->stackedWidget->addWidget(lw);
  82. ui->stackedWidget->setCurrentWidget(lw);
  83. }
  84. void MainWindow::on_actionSettings_triggered()
  85. {
  86. //nope();
  87. auto sw = new settingsWidget(this);
  88. ui->stackedWidget->addWidget(sw);
  89. ui->stackedWidget->setCurrentWidget(sw);
  90. }
  91. void MainWindow::on_actionNewFlight_triggered()
  92. {
  93. QVector<QStringList> lineEdit_completionLists = {
  94. QStringList(),//empty dummy list for TimeLineEdits
  95. dbAirport::retreiveIataIcaoList(),
  96. dbAircraft::retreiveRegistrationList(),
  97. dbPilots::retreivePilotList()
  98. };
  99. NewFlight nf(this, lineEdit_completionLists);
  100. nf.exec();
  101. }