Warning, file /office/calligra/gemini/Theme.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * This file is part of the KDE project 0003 * SPDX-FileCopyrightText: 2014 Arjen Hiemstra <ahiemstra@heimr.nl> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef THEME_H 0009 #define THEME_H 0010 0011 #include <QObject> 0012 #include <QVariantMap> 0013 #include <QIcon> 0014 0015 class Theme : public QObject 0016 { 0017 Q_OBJECT 0018 /** 0019 * \property id 0020 * \brief 0021 * 0022 * \get id() const 0023 * \set setId() 0024 * \notify idChanged() 0025 */ 0026 Q_PROPERTY(QString id READ id WRITE setId NOTIFY idChanged) 0027 /** 0028 * \property name 0029 * \brief The user-visible name of this theme. 0030 * 0031 * \get name() const 0032 * \set setName() 0033 * \notify nameChanged() 0034 */ 0035 Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) 0036 /** 0037 * \property inherits 0038 * \brief The id of the theme this theme inherits. 0039 * 0040 * If a certain property can not be found, the theme will try to get that property 0041 * from the inherited theme. 0042 * 0043 * \default None 0044 * \get inherits() const 0045 * \set setInherits() 0046 * \notify inheritsChanged() 0047 */ 0048 Q_PROPERTY(QString inherits READ inherits WRITE setInherits NOTIFY inheritsChanged) 0049 /** 0050 * \property colors 0051 * \brief A JavaScript object describing the colors to be used by this theme. 0052 * 0053 * \get colors() const 0054 * \set setColors() 0055 * \notify colorsChanged() 0056 */ 0057 Q_PROPERTY(QVariantMap colors READ colors WRITE setColors NOTIFY colorsChanged) 0058 /** 0059 * \property sizes 0060 * \brief A JavaScript object describing a number of sizes to be used by this theme. 0061 * 0062 * \get sizes() const 0063 * \set setSizes() 0064 * \notify sizesChanged() 0065 */ 0066 Q_PROPERTY(QVariantMap sizes READ sizes WRITE setSizes NOTIFY sizesChanged) 0067 /** 0068 * \property fonts 0069 * \brief A JavaScript object describing the fonts to be used by this theme. 0070 * 0071 * \get fonts() const 0072 * \set setFonts() 0073 * \notify fontsChanged() 0074 */ 0075 Q_PROPERTY(QVariantMap fonts READ fonts WRITE setFonts NOTIFY fontsChanged) 0076 /** 0077 * \property iconPath 0078 * \brief The path used to look up icons from the theme. 0079 * 0080 * Relative paths are relative to the theme directory. 0081 * 0082 * \default "icons/" 0083 * \get iconPath() const 0084 * \set setIconPath() 0085 * \notify iconPathChanged() 0086 */ 0087 Q_PROPERTY(QString iconPath READ iconPath WRITE setIconPath NOTIFY iconPathChanged) 0088 /** 0089 * \property imagePath 0090 * \brief The path used to look up images from the theme. 0091 * 0092 * Relative paths are relative to the theme directory. 0093 * 0094 * \default "images/" 0095 * \get imagePath() const 0096 * \set setImagePath() 0097 * \notify imagePathChanged() 0098 */ 0099 Q_PROPERTY(QString imagePath READ imagePath WRITE setImagePath NOTIFY imagePathChanged) 0100 /** 0101 * \property fontPath 0102 * \brief A path containing additional fonts to load. 0103 * 0104 * The fontPath specifies a directory that will be searched for font files. These 0105 * font files will then be made available for use in the theme. 0106 * 0107 * \default "fonts/" 0108 * \get fontPath() const 0109 * \set setFontPath() 0110 * \notify fontPathChanged() 0111 */ 0112 Q_PROPERTY(QString fontPath READ fontPath WRITE setFontPath NOTIFY fontPathChanged) 0113 public: 0114 explicit Theme(QObject* parent = 0); 0115 ~Theme() override; 0116 0117 /** 0118 * Getter for property #id. 0119 */ 0120 QString id() const; 0121 /** 0122 * Setter for property #id. 0123 */ 0124 void setId(const QString& newValue); 0125 0126 /** 0127 * Getter for property #name. 0128 */ 0129 QString name() const; 0130 /** 0131 * Setter for property #name. 0132 */ 0133 void setName(const QString& newValue); 0134 0135 /** 0136 * Getter for property #inherits. 0137 */ 0138 QString inherits() const; 0139 /** 0140 * Setter for property #inherits. 0141 */ 0142 void setInherits(const QString& newValue); 0143 0144 /** 0145 * Getter for property #colors. 0146 */ 0147 QVariantMap colors() const; 0148 /** 0149 * Setter for property #colors. 0150 */ 0151 void setColors(const QVariantMap& newValue); 0152 0153 /** 0154 * Getter for property #sizes. 0155 */ 0156 QVariantMap sizes() const; 0157 /** 0158 * Setter for property #sizes. 0159 */ 0160 void setSizes(const QVariantMap& newValue); 0161 0162 /** 0163 * Getter for property #fonts. 0164 */ 0165 QVariantMap fonts() const; 0166 /** 0167 * Setter for property #fonts. 0168 */ 0169 void setFonts(const QVariantMap& newValue); 0170 0171 /** 0172 * Getter for property #iconPath. 0173 */ 0174 QString iconPath() const; 0175 /** 0176 * Setter for property #iconPath. 0177 */ 0178 void setIconPath(const QString& newValue); 0179 0180 /** 0181 * Getter for property #imagePath. 0182 */ 0183 QString imagePath() const; 0184 /** 0185 * Setter for property #imagePath. 0186 */ 0187 void setImagePath(const QString& newValue); 0188 0189 /** 0190 * Getter for property #fontPath. 0191 */ 0192 QString fontPath() const; 0193 /** 0194 * Setter for property #fontPath. 0195 */ 0196 void setFontPath(const QString& newValue); 0197 0198 /** 0199 * Get a single color from the theme. 0200 * 0201 * \param name The color to get. 0202 * \return The color asked for, or a default color if it is not defined in the theme. 0203 */ 0204 Q_INVOKABLE QColor color(const QString& name); 0205 /** 0206 * Get a single size value from the theme. 0207 */ 0208 Q_INVOKABLE float size(const QString& name); 0209 /** 0210 * Get an icon from the theme. 0211 */ 0212 Q_INVOKABLE QUrl icon(const QString& name, bool useSystemFallback = false); 0213 /** 0214 * Get an icon from the theme. 0215 */ 0216 Q_INVOKABLE QIcon iconActual(const QString& name); 0217 /** 0218 * Get a font from the theme. 0219 */ 0220 Q_INVOKABLE QFont font(const QString& name); 0221 /** 0222 * Get an image from the theme. 0223 */ 0224 Q_INVOKABLE QUrl image(const QString& name); 0225 /** 0226 * Adjust a pixel size according to what it would be given that is what the pixel would 0227 * be on a 1080p monitor 0228 */ 0229 Q_INVOKABLE int adjustedPixel(const int& pixel) const; 0230 0231 static Theme* load(const QString& id, QObject* parent = 0); 0232 0233 Q_SIGNALS: 0234 void idChanged(); 0235 void nameChanged(); 0236 void inheritsChanged(); 0237 void colorsChanged(); 0238 void sizesChanged(); 0239 void fontsChanged(); 0240 void iconPathChanged(); 0241 void imagePathChanged(); 0242 void fontPathChanged(); 0243 void fontCacheRebuilt(); 0244 0245 protected: 0246 bool eventFilter(QObject*, QEvent*) override; 0247 0248 private: 0249 class Private; 0250 Private * const d; 0251 }; 0252 0253 #endif // THEME_H