2
0

mainwindow.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. MainWindow::MainWindow(QWidget *parent)
  21. : QMainWindow(parent)
  22. , ui(new Ui::MainWindow)
  23. {
  24. ui->setupUi(this);
  25. db::connect();
  26. // Set up Toolbar
  27. ui->toolBar->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
  28. ui->toolBar->setIconSize(QSize(64,64));
  29. ui->actionLogbook->setIcon(QIcon(":/icons/ionicon-icons/book-outline.png"));
  30. ui->actionHome->setIcon(QIcon(":/icons/ionicon-icons/home-outline.png"));
  31. ui->actionSettings->setIcon(QIcon(":/icons/ionicon-icons/settings-outline.png"));
  32. ui->actionQuit->setIcon(QIcon(":/icons/ionicon-icons/power-outline.png"));
  33. ui->actionNewFlight->setIcon(QIcon(":/icons/ionicon-icons/airplane-outline.png"));
  34. ui->actionAircraft->setIcon(QIcon(":/icons/ionicon-icons/airplane-outline.png"));
  35. ui->actionNewAircraft->setIcon(QIcon(":/icons/ionicon-icons/airplane-outline.png"));
  36. ui->actionPilots->setIcon(QIcon(":/icons/ionicon-icons/settings-outline.png"));
  37. ui->actionNewPilot->setIcon(QIcon(":/icons/ionicon-icons/settings-outline.png"));
  38. // Adds space between toolbar items
  39. auto *spacer = new QWidget();
  40. spacer->setMinimumWidth(10);
  41. spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
  42. ui->toolBar->insertWidget(ui->actionNewFlight,spacer);
  43. // create and show homeWidget
  44. auto hw = new homeWidget(this);
  45. ui->stackedWidget->addWidget(hw);
  46. ui->stackedWidget->setCurrentWidget(hw);
  47. }
  48. MainWindow::~MainWindow()
  49. {
  50. delete ui;
  51. }
  52. void MainWindow::nope()
  53. {
  54. QMessageBox nope(this); //error box
  55. nope.setText("This feature is not yet available!");
  56. nope.exec();
  57. }
  58. /*
  59. * Slots
  60. */
  61. void MainWindow::on_actionQuit_triggered()
  62. {
  63. QApplication::quit();
  64. }
  65. void MainWindow::on_actionHome_triggered()
  66. {
  67. auto hw = new homeWidget(this);
  68. ui->stackedWidget->addWidget(hw);
  69. ui->stackedWidget->setCurrentWidget(hw);
  70. }
  71. void MainWindow::on_actionLogbook_triggered()
  72. {
  73. auto lw = new logbookWidget(this);
  74. ui->stackedWidget->addWidget(lw);
  75. ui->stackedWidget->setCurrentWidget(lw);
  76. }
  77. void MainWindow::on_actionSettings_triggered()
  78. {
  79. //nope();
  80. auto sw = new settingsWidget(this);
  81. ui->stackedWidget->addWidget(sw);
  82. ui->stackedWidget->setCurrentWidget(sw);
  83. }
  84. void MainWindow::on_actionNewFlight_triggered()
  85. {/*
  86. QVector<QStringList> lineEdit_completionLists = {
  87. QStringList(),//empty dummy list for TimeLineEdits
  88. dbAirport::retreiveIataIcaoList(),
  89. dbAircraft::retreiveRegistrationList(),
  90. dbPilots::retreivePilotList()
  91. };
  92. NewFlight nf(this, lineEdit_completionLists);
  93. nf.exec();
  94. */
  95. }
  96. void MainWindow::on_actionAircraft_triggered()
  97. {
  98. auto aw = new aircraftWidget(this);
  99. ui->stackedWidget->addWidget(aw);
  100. ui->stackedWidget->setCurrentWidget(aw);
  101. }
  102. void MainWindow::on_actionNewAircraft_triggered()
  103. {
  104. auto nt = new NewTail(QString(), sql::createNew,this);
  105. nt->show();
  106. }
  107. void MainWindow::on_actionPilots_triggered()
  108. {
  109. nope();
  110. }
  111. void MainWindow::on_actionNewPilot_triggered()
  112. {
  113. nope();
  114. }