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 <kplugininfo.h>
00028 #include <ksharedconfig.h>
00029
00030 #include <plasma/plasma_export.h>
00031 #include <plasma/packagestructure.h>
00032
00033 namespace Plasma
00034 {
00035
00036 class ThemePrivate;
00037
00056 class PLASMA_EXPORT Theme : public QObject
00057 {
00058 Q_OBJECT
00059 Q_PROPERTY(QString themeName READ themeName)
00060
00061 public:
00062 enum ColorRole {
00063 TextColor = 0,
00064 HighlightColor = 1,
00066 BackgroundColor = 2,
00067 ButtonTextColor = 4,
00068 ButtonBackgroundColor = 8
00069 };
00070
00071 enum FontRole {
00072 DefaultFont = 0,
00073 DesktopFont
00074 };
00075
00079 static Theme *defaultTheme();
00080
00086 explicit Theme(QObject *parent = 0);
00087
00095 explicit Theme(const QString &themeName, QObject *parent = 0);
00096
00097 ~Theme();
00098
00102 static PackageStructure::Ptr packageStructure();
00103
00108 static KPluginInfo::List listThemeInfo();
00109
00113 void setThemeName(const QString &themeName);
00114
00118 QString themeName() const;
00119
00127 Q_INVOKABLE QString imagePath(const QString &name) const;
00128
00136 Q_INVOKABLE QString wallpaperPath(const QSize &size = QSize()) const;
00137
00145 Q_INVOKABLE bool currentThemeHasImage(const QString &name) const;
00146
00152 Q_INVOKABLE KSharedConfigPtr colorScheme() const;
00153
00159 Q_INVOKABLE QColor color(ColorRole role) const;
00160
00168 Q_INVOKABLE void setFont(const QFont &font, FontRole role = DefaultFont);
00169
00175 Q_INVOKABLE QFont font(FontRole role) const;
00176
00180 Q_INVOKABLE QFontMetrics fontMetrics() const;
00181
00185 Q_INVOKABLE bool windowTranslucencyEnabled() const;
00186
00193 void setUseGlobalSettings(bool useGlobal);
00194
00199 bool useGlobalSettings() const;
00200
00205 bool useNativeWidgetStyle() const;
00206
00215 bool findInCache(const QString &key, QPixmap &pix);
00216
00229 bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified);
00230
00239 void insertIntoCache(const QString& key, const QPixmap& pix);
00240
00256 void insertIntoCache(const QString& key, const QPixmap& pix, const QString& id);
00257
00266 void setCacheLimit(int kbytes);
00267
00277 bool findInRectsCache(const QString &image, const QString &element, QRectF &rect) const;
00278
00286 void insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect);
00287
00293 void invalidateRectsCache(const QString &image);
00294
00302 void releaseRectsCache(const QString &image);
00303
00304 Q_SIGNALS:
00309 void themeChanged();
00310
00311 public Q_SLOTS:
00316 void settingsChanged();
00317
00318 private:
00319 friend class ThemeSingleton;
00320 friend class ThemePrivate;
00321 ThemePrivate *const d;
00322
00323 Q_PRIVATE_SLOT(d, void compositingChanged())
00324 Q_PRIVATE_SLOT(d, void colorsChanged())
00325 Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &))
00326 Q_PRIVATE_SLOT(d, void scheduledCacheUpdate())
00327 };
00328
00329 }
00330
00331 #endif // multiple inclusion guard
00332