CuteHMI - Graphical User Interface (CuteHMI.GUI.1)
CuteApplication.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_GUI_1_INCLUDE_CUTEHMI_GUI_CUTEAPPLICATION_HPP
2 #define H_EXTENSIONS_CUTEHMI_GUI_1_INCLUDE_CUTEHMI_GUI_CUTEAPPLICATION_HPP
3 
4 #include "internal/common.hpp"
5 
6 #include <QApplication>
7 #include <QElapsedTimer>
8 #include <QTimer>
9 
10 namespace cutehmi {
11 namespace gui {
12 
18 class CUTEHMI_GUI_API CuteApplication:
19 //<CuteHMI.GUI-1.workaround target="Qt" cause="bug">
20  public QApplication
21 // Instead of:
22 // public QGuiApplication
23 //</CuteHMI.GUI-1.workaround>
24 {
25  typedef QApplication Parent;
26 
27  Q_OBJECT
28 
29  public:
30  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
31  static constexpr int IDLE_MEASURE_INTERVAL = 1000;
32  //</CuteHMI.LockScreen-1.workaround>
33 
34  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
35  Q_PROPERTY(double idle READ idle NOTIFY idleChanged)
36 
37  Q_PROPERTY(bool idleMeasureEnabled READ idleMeasureEnabled WRITE setIdleMeasureEnabled NOTIFY idleMeasureEnabledChanged)
38  //</CuteHMI.LockScreen-1.workaround>
39 
40  CuteApplication(int & argc, char ** argv);
41 
42  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
43  double idle() const;
44 
45  bool idleMeasureEnabled() const;
46 
47  void setIdleMeasureEnabled(bool idleMeasureEnabled);
48 
49  bool notify(QObject * receiver, QEvent * event) override;
50  //</CuteHMI.LockScreen-1.workaround>
51 
52  signals:
53  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
54  void idleChanged();
55 
56  void idleMeasureEnabledChanged();
57  //</CuteHMI.LockScreen-1.workaround>
58 
59  private slots:
60  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
61  void updateIdleTime();
62  //</CuteHMI.LockScreen-1.workaround>
63 
64  private:
65  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
66  void setIdle(double idle);
67  //</CuteHMI.LockScreen-1.workaround>
68 
69  private:
70  struct Members
71  {
72  //<CuteHMI.LockScreen-1.workaround target="Qt" cause="design">
73  int notifyEventCtr;
74  double idle;
75  bool idleMeasureEnabled;
76  QTimer updateTimer;
77  QElapsedTimer idleTime;
78  //</CuteHMI.LockScreen-1.workaround>
79 
80  Members():
81  notifyEventCtr(0),
82  idle(0.0),
83  idleMeasureEnabled(false)
84  {
85  }
86  };
87 
88  MPtr<Members> m;
89 };
90 
91 }
92 }
93 
94 #endif
95 
96 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
97 //(c)C: This file is a part of CuteHMI.
98 //(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.
99 //(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.
100 //(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:18
QApplication
QObject
cutehmi
QElapsedTimer
QEvent