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 
35 class HomeWidget : public QWidget
36 {
37  Q_OBJECT
38 
39 public:
40  explicit HomeWidget(QWidget *parent = nullptr);
41  ~HomeWidget();
42 
43 private:
44  Ui::HomeWidget *ui;
45 
46  QList<QLabel*> limitationDisplayLabels;
47  QDate today;
48  int currWarningThreshold;
49  double ftlWarningThreshold;
50 
51  void fillTotals();
52  void fillSelectedCurrencies();
53  void fillCurrencyTakeOffLanding();
54  void fillCurrency(ACurrencyEntry::CurrencyName currency_name, QLabel *display_label);
55  void fillLimitations();
56 
57  enum class Colour {Red, Orange, None};
58  inline void setLabelColour(QLabel* label, Colour colour)
59  {
60  switch (colour) {
61  case Colour::None:
62  label->setStyleSheet(QString());
63  break;
64  case Colour::Red:
65  label->setStyleSheet(QStringLiteral("color: red"));
66  break;
67  case Colour::Orange:
68  label->setStyleSheet(QStringLiteral("color: orange"));
69  break;
70  default:
71  label->setStyleSheet(QString());
72  break;
73  }
74  }
75 
76  inline void hideLabels(QLabel* label1, QLabel* label2) {
77  label1->hide();
78  label2->hide();
79  }
80 
84  const QString userName();
85  void checkAllCurrencies();
86 public slots:
87  void refresh();
88 };
89 
90 #endif // HOMEWIDGET_H
HomeWidget
Definition: homewidget.h:36