mainwindow.cpp 3.1 KB

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