Plasma
theme.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef PLASMA_THEME_H
00021 #define PLASMA_THEME_H
00022
00023 #include <QtCore/QObject>
00024 #include <QtGui/QFont>
00025 #include <QtGui/QFontMetrics>
00026
00027 #include <ksharedconfig.h>
00028
00029 #include <plasma/plasma_export.h>
00030 #include <plasma/packagestructure.h>
00031
00032 namespace Plasma
00033 {
00034
00035 class ThemePrivate;
00036
00055 class PLASMA_EXPORT Theme : public QObject
00056 {
00057 Q_OBJECT
00058 Q_PROPERTY(QString themeName READ themeName)
00059
00060 public:
00061 enum ColorRole {
00062 TextColor = 0,
00063 HighlightColor = 1,
00065 BackgroundColor = 2,
00066 ButtonTextColor = 4,
00067 ButtonBackgroundColor = 8
00068 };
00069
00070 enum FontRole {
00071 DefaultFont = 0,
00072 DesktopFont
00073 };
00074
00078 static Theme *defaultTheme();
00079
00083 explicit Theme(QObject *parent = 0);
00084 ~Theme();
00085
00089 static PackageStructure::Ptr packageStructure();
00090
00094 void setThemeName(const QString &themeName);
00095
00099 QString themeName() const;
00100
00108 Q_INVOKABLE QString imagePath(const QString &name) const;
00109
00117 Q_INVOKABLE QString wallpaperPath(const QSize &size = QSize()) const;
00118
00126 Q_INVOKABLE bool currentThemeHasImage(const QString &name) const;
00127
00133 Q_INVOKABLE KSharedConfigPtr colorScheme() const;
00134
00140 Q_INVOKABLE QColor color(ColorRole role) const;
00141
00149 Q_INVOKABLE void setFont(const QFont &font, FontRole role = DefaultFont);
00150
00156 Q_INVOKABLE QFont font(FontRole role) const;
00157
00161 Q_INVOKABLE QFontMetrics fontMetrics() const;
00162
00166 Q_INVOKABLE bool windowTranslucencyEnabled() const;
00167
00174 void setUseGlobalSettings(bool useGlobal);
00175
00180 bool useGlobalSettings() const;
00181
00186 bool findInCache(const QString &key, QPixmap &pix);
00187
00193 void insertIntoCache(const QString& key, const QPixmap& pix);
00194
00203 void setCacheLimit(int kbytes);
00204
00214 bool findInRectsCache(const QString &image, const QString &element, QRectF &rect) const;
00215
00223 void insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect);
00224
00230 void invalidateRectsCache(const QString &image);
00231
00239 void releaseRectsCache(const QString &image);
00240
00241 Q_SIGNALS:
00246 void themeChanged();
00247
00248 public Q_SLOTS:
00253 void settingsChanged();
00254
00255 private:
00256 friend class ThemeSingleton;
00257 friend class ThemePrivate;
00258 ThemePrivate *const d;
00259
00260 Q_PRIVATE_SLOT(d, void compositingChanged())
00261 Q_PRIVATE_SLOT(d, void discardCache())
00262 Q_PRIVATE_SLOT(d, void colorsChanged())
00263 };
00264
00265 }
00266
00267 #endif // multiple inclusion guard
00268