MauiKit Controls

appview.h
1/*
2 * <one line to give the program's name and a brief idea of what it does.>
3 * Copyright (C) 2019 camilo <chiguitar@unal.edu.co>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19#pragma once
20#include <QObject>
21#include <QQmlEngine>
22
23/**
24 * @brief The AppView class.
25 * Represents the possible attachable properties to be use with the MauiKit AppViews control.
26 *
27 * With this properties information can be attached to the AppViews children views, so the AppViews can - for example - place the view port buttons with the indicated icon and text title.
28 * @see AppViews
29 * @see AppViewLoader
30 *
31 * @note This class is exposed as AppView to QML, and is meant to be used as n attached property in the AppViews children views.
32 *
33 * @code
34 * Item
35 * {
36 * Maui.AppView.title: "View1"
37 * Maui.AppView.iconName: "folder"
38 * }
39 * @endcode
40 */
41class AppView : public QObject
42{
44 QML_ELEMENT
45 QML_ATTACHED(AppView)
46 QML_UNCREATABLE("Cannot be created Controls")
47 /**
48 * The title of the view
49 */
50 Q_PROPERTY(QString title READ title WRITE setTitle NOTIFY titleChanged)
51
52 /**
53 * The icon name to be used in the AppViews button port
54 */
55 Q_PROPERTY(QString iconName READ iconName WRITE setIconName NOTIFY iconNameChanged)
56
57 /**
58 * The text to be used as a badge in the AppViews button port.
59 * If this is left empty, then not badge will be shown.
60 */
61 Q_PROPERTY(QString badgeText READ badgeText WRITE setBadgeText NOTIFY badgeTextChanged)
62
63public:
64 /**
65 * @private
66 */
67 static AppView *qmlAttachedProperties(QObject *object)
68 {
69 Q_UNUSED(object)
70 return new AppView(object);
71 }
72
73 inline void setTitle(const QString &title)
74 {
75 if (title == m_title)
76 return;
77
78 m_title = title;
79 Q_EMIT titleChanged();
80 }
81
82 inline void setIconName(const QString &iconName)
83 {
84 if (iconName == m_iconName)
85 return;
86
87 m_iconName = iconName;
88 Q_EMIT iconNameChanged();
89 }
90
91 inline void setBadgeText(const QString &text)
92 {
93 if (text == m_badgeText)
94 return;
95
96 m_badgeText = text;
97 Q_EMIT badgeTextChanged();
98 }
99
100 inline const QString title() const
101 {
102 return m_title;
103 }
104
105 inline const QString iconName() const
106 {
107 return m_iconName;
108 }
109
110 inline const QString badgeText() const
111 {
112 return m_badgeText;
113 }
114
115private:
116 using QObject::QObject;
117
118 QString m_title;
119 QString m_iconName;
120 QString m_badgeText;
121
123 void titleChanged();
124 void iconNameChanged();
125 void badgeTextChanged();
126};
127
The AppView class.
Definition appview.h:42
QML_ELEMENTQString title
The title of the view.
Definition appview.h:50
QString iconName
The icon name to be used in the AppViews button port.
Definition appview.h:55
QString badgeText
The text to be used as a badge in the AppViews button port.
Definition appview.h:61
QObject(QObject *parent)
Q_EMITQ_EMIT
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:56:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.