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
13namespace cutehmi {
14namespace gui {
15
21class CUTEHMI_GUI_API Theme:
22 public QObject,
23 public Singleton<Theme>
24{
25 Q_OBJECT
26 //<CuteHMI.Workarounds.Qt5Compatibility-4.workaround target="Qt" cause="Qt5.15-QML_SINGLETON">
27#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
28 QML_NAMED_ELEMENT(Theme)
29 QML_UNCREATABLE("Theme is a singleton")
30 QML_SINGLETON
31#endif
32 //</CuteHMI.Workarounds.Qt5Compatibility-4.workaround>
33
34 friend class Singleton<Theme>;
35
36 public:
37 Q_PROPERTY(cutehmi::gui::Palette * palette READ palette WRITE setPalette NOTIFY paletteChanged RESET resetPalette)
38
39 Q_PROPERTY(cutehmi::gui::Units * units READ units WRITE setUnits NOTIFY unitsChanged RESET resetUnits)
40
41 Q_PROPERTY(cutehmi::gui::Fonts * fonts READ fonts WRITE setFonts NOTIFY fontsChanged RESET resetFonts)
42
43
51 static Theme * create(QQmlEngine * qmlEngine, QJSEngine * jsEngine);
52
53 Palette * palette() const;
54
55 void setPalette(Palette * palette);
56
57 void resetPalette();
58
59 Units * units() const;
60
61 void setUnits(Units * units);
62
63 void resetUnits();
64
65 Fonts * fonts() const;
66
67 void setFonts(Fonts * fonts);
68
69 void resetFonts();
70
71 signals:
73
75
77
78 protected:
79 Theme(QObject * parent = nullptr);
80
81 static Palette & DefaultPalette();
82
83 static Units & DefaultUnits();
84
85 static Fonts & DefaultFonts();
86
87 private:
88 void establishFontBindings();
89
90 struct Members
91 {
92 Palette * palette;
93 Units * units;
94 Fonts * fonts;
95
96 Members():
97 palette(& DefaultPalette()),
98 units(& DefaultUnits()),
99 fonts(& DefaultFonts())
100 {
101 }
102 };
103
105};
106
107}
108}
109
110#endif
111
112//(c)C: Copyright © 2020-2022, Michał Policht <michal@policht.pl>. All rights reserved.
113//(c)C: SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
114//(c)C: This file is a part of CuteHMI.
115//(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.
116//(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.
117//(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/>.
118//(c)C: Additionally, this file is licensed under terms of MIT license as expressed below.
119//(c)C: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
120//(c)C: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
121//(c)C: THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Definition: Fonts.hpp:15
Palette.
Definition: Palette.hpp:22
Theme.
Definition: Theme.hpp:24
Unit.
Definition: Units.hpp:17