mainwindow.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. // Adds space between toolbar items and actionSetting item
  37. auto *spacer = new QWidget();
  38. spacer->setMinimumWidth(10);
  39. spacer->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
  40. ui->toolBar->insertWidget(ui->actionSettings,spacer);
  41. // create and show homeWidget
  42. auto hw = new homeWidget(this);
  43. ui->stackedWidget->addWidget(hw);
  44. ui->stackedWidget->setCurrentWidget(hw);
  45. }
  46. MainWindow::~MainWindow()
  47. {
  48. delete ui;
  49. }
  50. void MainWindow::nope()
  51. {
  52. QMessageBox nope(this); //error box
  53. nope.setText("This feature is not yet available!");
  54. nope.exec();
  55. }
  56. /*
  57. * Slots
  58. */
  59. void MainWindow::on_actionQuit_triggered()
  60. {
  61. QApplication::quit();
  62. }
  63. void MainWindow::on_actionHome_triggered()
  64. {
  65. auto hw = new homeWidget(this);
  66. ui->stackedWidget->addWidget(hw);
  67. ui->stackedWidget->setCurrentWidget(hw);
  68. }
  69. void MainWindow::on_actionLogbook_triggered()
  70. {
  71. auto lw = new logbookWidget(this);
  72. ui->stackedWidget->addWidget(lw);
  73. ui->stackedWidget->setCurrentWidget(lw);
  74. }
  75. void MainWindow::on_actionSettings_triggered()
  76. {
  77. //nope();
  78. auto sw = new settingsWidget(this);
  79. ui->stackedWidget->addWidget(sw);
  80. ui->stackedWidget->setCurrentWidget(sw);
  81. }
  82. void MainWindow::on_actionNewFlight_triggered()
  83. {/*
  84. QVector<QStringList> lineEdit_completionLists = {
  85. QStringList(),//empty dummy list for TimeLineEdits
  86. dbAirport::retreiveIataIcaoList(),
  87. dbAircraft::retreiveRegistrationList(),
  88. dbPilots::retreivePilotList()
  89. };
  90. NewFlight nf(this, lineEdit_completionLists);
  91. nf.exec();
  92. */
  93. }
  94. void MainWindow::on_actionAircraft_triggered()
  95. {
  96. auto aw = new aircraftWidget(this);
  97. ui->stackedWidget->addWidget(aw);
  98. ui->stackedWidget->setCurrentWidget(aw);
  99. }
  100. void MainWindow::on_actionNewAircraft_triggered()
  101. {
  102. auto nt = new NewTail(QString(), sql::createNew,this);
  103. nt->show();
  104. }