| openPilotLog

homewidget.h
1 /*
2 *openPilotLog - A FOSS Pilot Logbook Application
3 *Copyright (C) 2020-2021 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 #ifndef HOMEWIDGET_H
19 #define HOMEWIDGET_H
20
21 #include <QWidget>
22 #include <QStackedLayout>
23 #include <QLabel>
24 #include <QLineEdit>
25 #include <QSettings>
26 #include "src/functions/astat.h"
27 #include "src/database/adatabase.h"
28 #include "src/classes/asettings.h"
29 #include "src/classes/acurrencyentry.h"
30
31 namespace Ui {
32 class HomeWidget;
33 }
34
43 class HomeWidget : public QWidget
44 {
45 Q_OBJECT
46
47 public:
48 explicit HomeWidget(QWidget *parent = nullptr);
49 ~HomeWidget();
50
51 private:
52 Ui::HomeWidget *ui;
53
54 QList<QLabel*> limitationDisplayLabels;
55 QDate today;
60 int currWarningThreshold;
65 double ftlWarningThreshold;
66
67 void fillTotals();
68 void fillSelectedCurrencies();
69 void fillCurrencyTakeOffLanding();
70 void fillCurrency(ACurrencyEntry::CurrencyName currency_name, QLabel *display_label);
71 void fillLimitations();
72
73 enum class Colour {Red, Orange, None};
74 inline void setLabelColour(QLabel* label, Colour colour)
75 {
76 switch (colour) {
77 case Colour::None:
78 label->setStyleSheet(QString());
79 break;
80 case Colour::Red:
81 label->setStyleSheet(QStringLiteral("color: red"));
82 break;
83 case Colour::Orange:
84 label->setStyleSheet(QStringLiteral("color: orange"));
85 break;
86 default:
87 label->setStyleSheet(QString());
88 break;
89 }
90 }
91
92 inline void hideLabels(QLabel* label1, QLabel* label2) {
93 label1->hide();
94 label2->hide();
95 }
96
100 const QString userName();
101
102 public slots:
103 void refresh();
104
105 protected:
109 void changeEvent(QEvent* event) override;
110 };
111
112 #endif // HOMEWIDGET_H
HomeWidget
The HomeWidget is the welcome screen of the application.
Definition: homewidget.h:44
HomeWidget::changeEvent
void changeEvent(QEvent *event) override
Handles change events, like updating the UI to new localisation.
Definition: homewidget.cpp:78