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 tab button representing the view.
39 */
40 Q_PROPERTY(QString color READ color WRITE setColor NOTIFY colorChanged)
41
42 /**
43 * The text to be shown in the tool-tip when hovering over the tab button representing the view.
44 */
45 Q_PROPERTY(QString toolTipText READ toolTipText WRITE setToolTipText NOTIFY toolTipTextChanged)
46
47 /**
48 * Whether a supported MauiKit controls should display the window control buttons when using CSD.
49 */
50 Q_PROPERTY(bool showCSD READ showCSD WRITE setShowCSD NOTIFY showCSDChanged)
51
52 /**
53 * 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.
54 * By default `Level::Primary` is set.
55 */
56 Q_PROPERTY(Level level READ level WRITE setLevel NOTIFY levelChanged)
57
58 /**
59 * A property hint for UI elements to be styled as a flat surface, for example, without a background.
60 * By default this is set to false.
61 */
62 // Q_PROPERTY(bool flat READ flat WRITE setFlat NOTIFY flatChanged)
63
64public:
65
66 enum Level
67 {
68 Undefined,
69 Primary,
70 Secondary
71 }; Q_ENUM(Level)
72
73 explicit Controls(QObject *parent = nullptr);
74
75 static Controls *qmlAttachedProperties(QObject *object);
76
77 bool showCSD() const;
78 void setShowCSD(bool newShowCSD);
79
80 QString title() const;
81 void setTitle(const QString &title);
82
83 QString iconName() const;
84 void setIconName(const QString &newIconName);
85
86 QString badgeText() const;
87 void setBadgeText(const QString &newBadgeText);
88
89 QString toolTipText() const;
90 void setToolTipText(const QString &newToolTipText);
91
92 QString color() const;
93 void setColor(const QString &newColor);
94
95 Controls::Level level() const;
96 void setLevel(Level level);
97
99 void titleChanged();
100 void showCSDChanged();
101 void iconNameChanged();
102 void badgeTextChanged();
103 void toolTipTextChanged();
104 void colorChanged();
105 void levelChanged();
106
107private:
108 bool m_showCSD;
109 QString m_title;
110 QString m_iconName;
111 QString m_badgeText;
112 QString m_toolTipText;
113 QString m_color;
114 Controls::Level m_level = Controls::Level::Undefined;
115};
116
117QML_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:45
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
Level
A property hint for UI elements to be styled as a flat surface, for example, without a background.
Definition controls.h:67
QString color
The color to be used as an indicator in the tab button representing the view.
Definition controls.h:40
bool showCSD
Whether a supported MauiKit controls should display the window control buttons when using CSD.
Definition controls.h:50
Level level
Set a UI element hierarchy level.
Definition controls.h:56
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 Jul 26 2024 11:50:53 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.