Plasma
theme.h
Go to the documentation of this file.
00001 /* 00002 * Copyright 2006-2007 Aaron Seigo <aseigo@kde.org> 00003 * 00004 * This program is free software; you can redistribute it and/or modify 00005 * it under the terms of the GNU Library General Public License as 00006 * published by the Free Software Foundation; either version 2, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details 00013 * 00014 * You should have received a copy of the GNU Library General Public 00015 * License along with this program; if not, write to the 00016 * Free Software Foundation, Inc., 00017 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 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 LinkColor = 16, 00070 VisitedLinkColor = 32, 00071 ButtonHoverColor = 64, 00072 ButtonFocusColor = 128, 00073 ViewTextColor = 256, 00074 ViewBackgroundColor = 512, 00075 ViewHoverColor = 1024, 00076 ViewFocusColor = 2048 00077 }; 00078 00079 enum FontRole { 00080 DefaultFont = 0, 00081 DesktopFont 00082 }; 00083 00087 static Theme *defaultTheme(); 00088 00094 explicit Theme(QObject *parent = 0); 00095 00103 explicit Theme(const QString &themeName, QObject *parent = 0); 00104 00105 ~Theme(); 00106 00110 static PackageStructure::Ptr packageStructure(); 00111 00116 static KPluginInfo::List listThemeInfo(); 00117 00121 void setThemeName(const QString &themeName); 00122 00126 QString themeName() const; 00127 00135 Q_INVOKABLE QString imagePath(const QString &name) const; 00136 00144 Q_INVOKABLE QString animationPath(const QString &name) const; 00145 00153 Q_INVOKABLE QString wallpaperPath(const QSize &size = QSize()) const; 00154 00162 Q_INVOKABLE bool currentThemeHasImage(const QString &name) const; 00163 00169 Q_INVOKABLE KSharedConfigPtr colorScheme() const; 00170 00176 Q_INVOKABLE QColor color(ColorRole role) const; 00177 00185 Q_INVOKABLE void setFont(const QFont &font, FontRole role = DefaultFont); 00186 00192 Q_INVOKABLE QFont font(FontRole role) const; 00193 00197 Q_INVOKABLE QFontMetrics fontMetrics() const; 00198 00202 Q_INVOKABLE bool windowTranslucencyEnabled() const; 00203 00210 void setUseGlobalSettings(bool useGlobal); 00211 00216 bool useGlobalSettings() const; 00217 00222 bool useNativeWidgetStyle() const; 00223 00261 Q_INVOKABLE QString styleSheet(const QString &css = QString()) const; 00262 00263 00272 bool findInCache(const QString &key, QPixmap &pix); 00273 00286 bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified); 00287 00296 void insertIntoCache(const QString& key, const QPixmap& pix); 00297 00316 void insertIntoCache(const QString& key, const QPixmap& pix, const QString& id); 00317 00326 void setCacheLimit(int kbytes); 00327 00337 bool findInRectsCache(const QString &image, const QString &element, QRectF &rect) const; 00338 00348 QStringList listCachedRectKeys(const QString &image) const; 00349 00357 void insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect); 00358 00364 void invalidateRectsCache(const QString &image); 00365 00373 void releaseRectsCache(const QString &image); 00374 00375 Q_SIGNALS: 00380 void themeChanged(); 00381 00382 public Q_SLOTS: 00387 void settingsChanged(); 00388 00389 private: 00390 friend class ThemeSingleton; 00391 friend class ThemePrivate; 00392 ThemePrivate *const d; 00393 00394 Q_PRIVATE_SLOT(d, void compositingChanged()) 00395 Q_PRIVATE_SLOT(d, void colorsChanged()) 00396 Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &)) 00397 Q_PRIVATE_SLOT(d, void scheduledCacheUpdate()) 00398 Q_PRIVATE_SLOT(d, void onAppExitCleanup()) 00399 }; 00400 00401 } // Plasma namespace 00402 00403 #endif // multiple inclusion guard 00404
KDE 4.6 API Reference