CuteHMI - Graphical User Interface (CuteHMI.GUI.0)
CuteApplication.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_GUI_0_INCLUDE_CUTEHMI_GUI_CUTEAPPLICATION_HPP
2 #define H_EXTENSIONS_CUTEHMI_GUI_0_INCLUDE_CUTEHMI_GUI_CUTEAPPLICATION_HPP
3 
4 #include "internal/common.hpp"
5 #include "Theme.hpp"
6 
7 #include <QApplication>
8 #include <QElapsedTimer>
9 #include <QTimer>
10 
11 namespace cutehmi {
12 namespace gui {
13 
19 class CUTEHMI_GUI_API CuteApplication:
20 //<CuteHMI.GUI-1.workaround target="Qt" cause="bug">
21  public QApplication
22 // Instead of:
23 // public QGuiApplication
24 //</CuteHMI.GUI-1.workaround>
25 {
26  typedef QApplication Parent;
27 
28  Q_OBJECT
29 
30  public:
31  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
32  static constexpr int IDLE_MEASURE_INTERVAL = 1000;
33  //</CuteHMI.LockScreen-1.workaround>
34 
35  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
36  Q_PROPERTY(double idle READ idle NOTIFY idleChanged)
37 
38  Q_PROPERTY(bool idleMeasureEnabled READ idleMeasureEnabled WRITE setIdleMeasureEnabled NOTIFY idleMeasureEnabledChanged)
39  //</CuteHMI.LockScreen-1.workaround>
40 
44  Q_PROPERTY(Theme * defaultTheme READ defaultTheme CONSTANT)
45 
49  Q_PROPERTY(Theme * theme READ theme WRITE setTheme NOTIFY themeChanged)
50 
51  CuteApplication(int & argc, char ** argv);
52 
53  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
54  double idle() const;
55 
56  bool idleMeasureEnabled() const;
57 
58  void setIdleMeasureEnabled(bool idleMeasureEnabled);
59 
60  Theme * defaultTheme() const;
61 
62  Theme * theme() const;
63 
64  void setTheme(Theme * theme);
65 
66  bool notify(QObject * receiver, QEvent * event) override;
67  //</CuteHMI.LockScreen-1.workaround>
68 
69  signals:
70  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
71  void idleChanged();
72 
73  void idleMeasureEnabledChanged();
74  //</CuteHMI.LockScreen-1.workaround>
75 
76  void themeChanged();
77 
78  private slots:
79  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
80  void updateIdleTime();
81  //</CuteHMI.LockScreen-1.workaround>
82 
83  private:
84  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
85  void setIdle(double idle);
86  //</CuteHMI.LockScreen-1.workaround>
87 
88  private:
89  struct Members
90  {
91  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
92  int notifyEventCtr;
93  double idle;
94  bool idleMeasureEnabled;
95  QTimer updateTimer;
96  QElapsedTimer idleTime;
97  //</CuteHMI.LockScreen-1.workaround>
98  Theme * defaultTheme;
99  Theme * theme;
100 
101  Members(QObject * parent):
102  notifyEventCtr(0),
103  idle(0.0),
104  idleMeasureEnabled(false),
105  defaultTheme(new Theme(parent)),
106  theme(defaultTheme)
107  {
108  }
109  };
110 
111  MPtr<Members> m;
112 };
113 
114 }
115 }
116 
117 #endif
118 
119 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
120 //(c)C: This file is a part of CuteHMI.
121 //(c)C: CuteHMI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
122 //(c)C: CuteHMI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
123 //(c)C: You should have received a copy of the GNU Lesser General Public License along with CuteHMI. If not, see <https://www.gnu.org/licenses/>.
QTimer
cutehmi::MPtr< Members >
cutehmi::gui::CuteApplication
Application.
Definition: CuteApplication.hpp:19
QApplication
QObject
cutehmi
QElapsedTimer
QEvent
cutehmi::gui::Theme
Theme.
Definition: Theme.hpp:19