CuteHMI - Graphical User Interface (CuteHMI.GUI.1)
Theme.hpp
1 #ifndef H_EXTENSIONS_CUTEHMI_GUI_1_INCLUDE_CUTEHMI_GUI_THEME_HPP
2 #define H_EXTENSIONS_CUTEHMI_GUI_1_INCLUDE_CUTEHMI_GUI_THEME_HPP
3 
4 #include "internal/common.hpp"
5 #include "Palette.hpp"
6 #include "Units.hpp"
7 #include "Fonts.hpp"
8 
9 #include <cutehmi/Singleton.hpp>
10 
11 #include <QObject>
12 
13 namespace cutehmi {
14 namespace gui {
15 
21 class CUTEHMI_GUI_API Theme:
22  public QObject,
23  public Singleton<Theme>
24 {
25  Q_OBJECT
26 
27  friend class Singleton<Theme>;
28 
29  public:
30  Q_PROPERTY(Palette * palette READ palette WRITE setPalette NOTIFY paletteChanged RESET resetPalette)
31 
32  Q_PROPERTY(Units * units READ units WRITE setUnits NOTIFY unitsChanged RESET resetUnits)
33 
34  Q_PROPERTY(Fonts * fonts READ fonts WRITE setFonts NOTIFY fontsChanged RESET resetFonts)
35 
36  Palette * palette() const;
37 
38  void setPalette(Palette * palette);
39 
40  void resetPalette();
41 
42  Units * units() const;
43 
44  void setUnits(Units * units);
45 
46  void resetUnits();
47 
48  Fonts * fonts() const;
49 
50  void setFonts(Fonts * fonts);
51 
52  void resetFonts();
53 
54  signals:
55  void paletteChanged();
56 
57  void unitsChanged();
58 
59  void fontsChanged();
60 
61  protected:
62  Theme(QObject * parent = nullptr);
63 
64  static Palette & DefaultPalette();
65 
66  static Units & DefaultUnits();
67 
68  static Fonts & DefaultFonts();
69 
70  private:
71  void establishFontBindings();
72 
73  struct Members
74  {
75  Palette * palette;
76  Units * units;
77  Fonts * fonts;
78 
79  Members():
80  palette(& DefaultPalette()),
81  units(& DefaultUnits()),
82  fonts(& DefaultFonts())
83  {
84  }
85  };
86 
87  MPtr<Members> m;
88 };
89 
90 }
91 }
92 
93 #endif
94 
95 //(c)C: Copyright © 2020, Michał Policht <michal@policht.pl>. All rights reserved.
96 //(c)C: This file is a part of CuteHMI.
97 //(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.
98 //(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.
99 //(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/>.
cutehmi::gui::Fonts
Definition: Fonts.hpp:12
cutehmi::gui::Units
Unit.
Definition: Units.hpp:14
cutehmi::MPtr< Members >
QObject
cutehmi
cutehmi::gui::Theme
Theme.
Definition: Theme.hpp:21
cutehmi::gui::Palette
Palette.
Definition: Palette.hpp:19
cutehmi::Singleton