File: Theme.h

package info (click to toggle)
calligra 1%3A25.04.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 309,164 kB
  • sloc: cpp: 667,890; xml: 126,105; perl: 2,724; python: 2,497; yacc: 1,817; ansic: 1,326; sh: 1,223; lex: 1,107; javascript: 495; makefile: 24
file content (253 lines) | stat: -rw-r--r-- 6,453 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
/*
 * This file is part of the KDE project
 * SPDX-FileCopyrightText: 2014 Arjen Hiemstra <ahiemstra@heimr.nl>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#ifndef THEME_H
#define THEME_H

#include <QIcon>
#include <QObject>
#include <QVariantMap>

class Theme : public QObject
{
    Q_OBJECT
    /**
     * \property id
     * \brief
     *
     * \get id() const
     * \set setId()
     * \notify idChanged()
     */
    Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged)
    /**
     * \property name
     * \brief The user-visible name of this theme.
     *
     * \get name() const
     * \set setName()
     * \notify nameChanged()
     */
    Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged)
    /**
     * \property inherits
     * \brief The id of the theme this theme inherits.
     *
     * If a certain property can not be found, the theme will try to get that property
     * from the inherited theme.
     *
     * \default None
     * \get inherits() const
     * \set setInherits()
     * \notify inheritsChanged()
     */
    Q_PROPERTY(QString inherits READ inherits WRITE setInherits NOTIFY inheritsChanged)
    /**
     * \property colors
     * \brief A JavaScript object describing the colors to be used by this theme.
     *
     * \get colors() const
     * \set setColors()
     * \notify colorsChanged()
     */
    Q_PROPERTY(QVariantMap colors READ colors WRITE setColors NOTIFY colorsChanged)
    /**
     * \property sizes
     * \brief A JavaScript object describing a number of sizes to be used by this theme.
     *
     * \get sizes() const
     * \set setSizes()
     * \notify sizesChanged()
     */
    Q_PROPERTY(QVariantMap sizes READ sizes WRITE setSizes NOTIFY sizesChanged)
    /**
     * \property fonts
     * \brief A JavaScript object describing the fonts to be used by this theme.
     *
     * \get fonts() const
     * \set setFonts()
     * \notify fontsChanged()
     */
    Q_PROPERTY(QVariantMap fonts READ fonts WRITE setFonts NOTIFY fontsChanged)
    /**
     * \property iconPath
     * \brief The path used to look up icons from the theme.
     *
     * Relative paths are relative to the theme directory.
     *
     * \default "icons/"
     * \get iconPath() const
     * \set setIconPath()
     * \notify iconPathChanged()
     */
    Q_PROPERTY(QString iconPath READ iconPath WRITE setIconPath NOTIFY iconPathChanged)
    /**
     * \property imagePath
     * \brief The path used to look up images from the theme.
     *
     * Relative paths are relative to the theme directory.
     *
     * \default "images/"
     * \get imagePath() const
     * \set setImagePath()
     * \notify imagePathChanged()
     */
    Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged)
    /**
     * \property fontPath
     * \brief A path containing additional fonts to load.
     *
     * The fontPath specifies a directory that will be searched for font files. These
     * font files will then be made available for use in the theme.
     *
     * \default "fonts/"
     * \get fontPath() const
     * \set setFontPath()
     * \notify fontPathChanged()
     */
    Q_PROPERTY(QString fontPath READ fontPath WRITE setFontPath NOTIFY fontPathChanged)
public:
    explicit Theme(QObject *parent = nullptr);
    ~Theme() override;

    /**
     * Getter for property #id.
     */
    QString id() const;
    /**
     * Setter for property #id.
     */
    void setId(const QString &newValue);

    /**
     * Getter for property #name.
     */
    QString name() const;
    /**
     * Setter for property #name.
     */
    void setName(const QString &newValue);

    /**
     * Getter for property #inherits.
     */
    QString inherits() const;
    /**
     * Setter for property #inherits.
     */
    void setInherits(const QString &newValue);

    /**
     * Getter for property #colors.
     */
    QVariantMap colors() const;
    /**
     * Setter for property #colors.
     */
    void setColors(const QVariantMap &newValue);

    /**
     * Getter for property #sizes.
     */
    QVariantMap sizes() const;
    /**
     * Setter for property #sizes.
     */
    void setSizes(const QVariantMap &newValue);

    /**
     * Getter for property #fonts.
     */
    QVariantMap fonts() const;
    /**
     * Setter for property #fonts.
     */
    void setFonts(const QVariantMap &newValue);

    /**
     * Getter for property #iconPath.
     */
    QString iconPath() const;
    /**
     * Setter for property #iconPath.
     */
    void setIconPath(const QString &newValue);

    /**
     * Getter for property #imagePath.
     */
    QString imagePath() const;
    /**
     * Setter for property #imagePath.
     */
    void setImagePath(const QString &newValue);

    /**
     * Getter for property #fontPath.
     */
    QString fontPath() const;
    /**
     * Setter for property #fontPath.
     */
    void setFontPath(const QString &newValue);

    /**
     * Get a single color from the theme.
     *
     * \param name The color to get.
     * \return The color asked for, or a default color if it is not defined in the theme.
     */
    Q_INVOKABLE QColor color(const QString &name);
    /**
     * Get a single size value from the theme.
     */
    Q_INVOKABLE float size(const QString &name);
    /**
     * Get an icon from the theme.
     */
    Q_INVOKABLE QUrl icon(const QString &name, bool useSystemFallback = false);
    /**
     * Get an icon from the theme.
     */
    Q_INVOKABLE QIcon iconActual(const QString &name);
    /**
     * Get a font from the theme.
     */
    Q_INVOKABLE QFont font(const QString &name);
    /**
     * Get an image from the theme.
     */
    Q_INVOKABLE QUrl image(const QString &name);
    /**
     * Adjust a pixel size according to what it would be given that is what the pixel would
     * be on a 1080p monitor
     */
    Q_INVOKABLE int adjustedPixel(const int &pixel) const;

    static Theme *load(const QString &id, QObject *parent = nullptr);

Q_SIGNALS:
    void idChanged();
    void nameChanged();
    void inheritsChanged();
    void colorsChanged();
    void sizesChanged();
    void fontsChanged();
    void iconPathChanged();
    void imagePathChanged();
    void fontPathChanged();
    void fontCacheRebuilt();

protected:
    bool eventFilter(QObject *, QEvent *) override;

private:
    class Private;
    Private *const d;
};

#endif // THEME_H