123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- #ifndef MAINWINDOW_H
- #define MAINWINDOW_H
- #include <QMainWindow>
- #include <QTime>
- #include <QSqlTableModel>
- #include <QTableView>
- #include <chrono>
- #include <QMessageBox>
- #include <QDir>
- #include <QFile>
- #include <QKeyEvent>
- #include <QToolBar>
- #include <src/gui/widgets/logbooktableeditwidget.h>
- #include "src/gui/widgets/homewidget.h"
- #include "src/gui/widgets/settingswidget.h"
- #include "src/gui/widgets/tableeditwidget.h"
- #include "src/gui/widgets/debugwidget.h"
- #include "src/classes/style.h"
- QT_BEGIN_NAMESPACE
- namespace Ui {
- class MainWindow;
- }
- QT_END_NAMESPACE
- class MainWindow : public QMainWindow
- {
- Q_OBJECT
- public:
- MainWindow(QWidget *parent = nullptr);
- ~MainWindow();
- public slots:
- void onStyleChanged(SettingsWidget::SettingSignal signal){
- if (signal == SettingsWidget::MainWindow)
- setActionIcons(OPL::Style::getStyleType());
- }
- private slots:
- void on_actionHome_triggered();
- void on_actionNewFlight_triggered();
- void on_actionLogbook_triggered();
- void on_actionAircraft_triggered();
- void on_actionPilots_triggered();
- void on_actionAirports_triggered();
- void on_actionSettings_triggered();
- void on_actionQuit_triggered();
- void on_actionDebug_triggered();
- void on_actionNewSim_triggered();
- private:
- Ui::MainWindow *ui;
- HomeWidget* homeWidget;
- LogbookTableEditWidget* logbookWidget;
-
- TableEditWidget* tailsWidget;
- TableEditWidget* pilotsWidget;
- TableEditWidget* airportWidget;
- SettingsWidget* settingsWidget;
- DebugWidget* debugWidget;
- bool airportDbIsDirty = false;
- void init();
- void setupToolbar();
- void initialiseWidgets();
- void connectDatabase();
- void setActionIcons(OPL::Style::StyleType style = OPL::Style::StyleType::Light);
- void nope();
- void connectWidgets();
-
- void onDatabaseInvalid();
-
- void doDebugStuff();
- protected:
-
- void keyPressEvent(QKeyEvent* keyEvent) override
- {
- if(keyEvent->type() == QKeyEvent::KeyPress) {
- if(keyEvent->matches(QKeySequence::AddTab)) {
- on_actionDebug_triggered();
- } else if (keyEvent->matches(QKeySequence::InsertLineSeparator)) {
- doDebugStuff();
- }
- }
- }
-
- void resizeEvent(QResizeEvent *event) override
- {
- const auto icon_size = this->height() / 16;
- const auto toolBar = this->findChild<QToolBar*>();
- toolBar->setIconSize(QSize(icon_size, icon_size));
- event->accept();
- }
- signals:
- void addFlightEntryRequested();
- void addSimulatorEntryRequested();
-
- };
- #endif
|