MauiKit Controls

controls.h
1#pragma once
2
3#include <QObject>
4#include <QQmlEngine>
5
6/**
7 * @brief The Controls class.
8 *
9 * This object exposes a series of attached properties useful for the MauiKit controls as a sort of common set metadata.
10 *
11 * @note This is mean to be used as an attached property. It can be consumed as `Maui.Controls`, for example, `Maui.Controls.showCSD`
12 */
13class Controls : public QObject
14{
16 QML_ELEMENT
17 QML_ATTACHED(Controls)
18 QML_UNCREATABLE("Cannot be created. Controls object is a set of metadata information to be attached")
19
20 /**
21 * A title text that can be attached to any control.
22 */
23 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
24
25 /**
26 * The icon name to be used in the AppViews button port
27 */
28 Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
29
30
31 /**
32 * The text to be used as a badge for notification purposes.
33 * If this is left empty, then not badge will be shown.
34 */
35 Q_PROPERTY(QString badgeText READ badgeText WRITE setBadgeText NOTIFY badgeTextChanged)
36
37 /**
38 * The color to be used as an indicator in the supported widgets.
39 * Supported widgets include:
40 * TabButton
41 * Button
42 * Page
43 * Badge
44 */
45 Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
46
47 /**
48 * The text to be shown in the tool-tip when hovering over the tab button representing the view.
49 */
50 Q_PROPERTY(QString toolTipText READ toolTipText WRITE setToolTipText NOTIFY toolTipTextChanged)
51
52 /**
53 * Whether a supported MauiKit controls should display the window control buttons when using CSD.
54 */
55 Q_PROPERTY(bool showCSD READ showCSD WRITE setShowCSD NOTIFY showCSDChanged)
56
57 /**
58 * Set a UI element hierarchy level. For example, in a page with two toolbars one could be Level::Primary, and the other one Level::Secunday, this will allow to better style the toolbars for differentiation.
59 * By default `Level::Primary` is assumed.
60 * @see Level
61 */
62 Q_PROPERTY(Level level READ level WRITE setLevel NOTIFY levelChanged)
63
64 /**
65 * A property hint for UI elements to be styled as a flat surface, for example, without a background.
66 * By default this is set to false.
67 */
68 Q_PROPERTY(bool flat READ flat WRITE setFlat NOTIFY flatChanged)
69
70 /**
71 * Mark the supported widgets in one of the given status, which will alterate its look.
72 * @see Status
73 **/
74 Q_PROPERTY(Status status READ status WRITE setStatus NOTIFY statusChanged)
75
76public:
77
78 enum Level
79 {
80 Undefined,
81 Primary,
82 Secondary
83 }; Q_ENUM(Level)
84
85 enum Status
86 {
87 Normal,
88 Positive,
89 Negative,
90 Neutral
91 }; Q_ENUM(Status)
92
93 explicit Controls(QObject *parent = nullptr);
94
95 static Controls *qmlAttachedProperties(QObject *object);
96
97 bool showCSD() const;
98 void setShowCSD(bool newShowCSD);
99
100 QString title() const;
101 void setTitle(const QString &title);
102
103 QString iconName() const;
104 void setIconName(const QString &newIconName);
105
106 QString badgeText() const;
107 void setBadgeText(const QString &newBadgeText);
108
109 QString toolTipText() const;
110 void setToolTipText(const QString &newToolTipText);
111
112 QString color() const;
113 void setColor(const QString &newColor);
114
115 Controls::Level level() const;
116 void setLevel(Level level);
117
118 bool flat() const;
119 void setFlat(bool value);
120
121 Controls::Status status() const;
122 void setStatus(Controls::Status status);
123
125 void titleChanged();
126 void showCSDChanged();
127 void iconNameChanged();
128 void badgeTextChanged();
129 void toolTipTextChanged();
130 void colorChanged();
131 void levelChanged();
132 void flatChanged();
133 void statusChanged();
134
135private:
136 bool m_showCSD;
137 QString m_title;
138 QString m_iconName;
139 QString m_badgeText;
140 QString m_toolTipText;
141 QString m_color;
142 Controls::Level m_level = Controls::Level::Undefined;
143 bool m_flat;
144 Controls::Status m_status = Controls::Status::Normal;
145};
146
147QML_DECLARE_TYPEINFO(Controls, QML_HAS_ATTACHED_PROPERTIES)
The Controls class.
Definition controls.h:14
QString toolTipText
The text to be shown in the tool-tip when hovering over the tab button representing the view.
Definition controls.h:50
QML_ELEMENTQString title
A title text that can be attached to any control.
Definition controls.h:23
QString iconName
The icon name to be used in the AppViews button port.
Definition controls.h:28
QString badgeText
The text to be used as a badge for notification purposes.
Definition controls.h:35
Status status
Mark the supported widgets in one of the given status, which will alterate its look.
Definition controls.h:74
QString color
The color to be used as an indicator in the supported widgets.
Definition controls.h:45
bool showCSD
Whether a supported MauiKit controls should display the window control buttons when using CSD.
Definition controls.h:55
Level level
Set a UI element hierarchy level.
Definition controls.h:62
bool flat
A property hint for UI elements to be styled as a flat surface, for example, without a background.
Definition controls.h:68
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Sep 6 2024 12:09:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.