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 SmallestFont 00083 }; 00084 00088 static Theme *defaultTheme(); 00089 00095 explicit Theme(QObject *parent = 0); 00096 00104 explicit Theme(const QString &themeName, QObject *parent = 0); 00105 00106 ~Theme(); 00107 00111 static PackageStructure::Ptr packageStructure(); 00112 00117 static KPluginInfo::List listThemeInfo(); 00118 00122 void setThemeName(const QString &themeName); 00123 00127 QString themeName() const; 00128 00136 Q_INVOKABLE QString imagePath(const QString &name) const; 00137 00145 Q_INVOKABLE QString animationPath(const QString &name) const; 00146 00154 Q_INVOKABLE QString wallpaperPath(const QSize &size = QSize()) const; 00155 00163 Q_INVOKABLE bool currentThemeHasImage(const QString &name) const; 00164 00170 Q_INVOKABLE KSharedConfigPtr colorScheme() const; 00171 00177 Q_INVOKABLE QColor color(ColorRole role) const; 00178 00186 Q_INVOKABLE void setFont(const QFont &font, FontRole role = DefaultFont); 00187 00193 Q_INVOKABLE QFont font(FontRole role) const; 00194 00198 Q_INVOKABLE QFontMetrics fontMetrics() const; 00199 00203 Q_INVOKABLE bool windowTranslucencyEnabled() const; 00204 00211 void setUseGlobalSettings(bool useGlobal); 00212 00217 bool useGlobalSettings() const; 00218 00223 bool useNativeWidgetStyle() const; 00224 00262 Q_INVOKABLE QString styleSheet(const QString &css = QString()) const; 00263 00264 00273 bool findInCache(const QString &key, QPixmap &pix); 00274 00287 bool findInCache(const QString &key, QPixmap &pix, unsigned int lastModified); 00288 00297 void insertIntoCache(const QString& key, const QPixmap& pix); 00298 00317 void insertIntoCache(const QString& key, const QPixmap& pix, const QString& id); 00318 00327 void setCacheLimit(int kbytes); 00328 00338 bool findInRectsCache(const QString &image, const QString &element, QRectF &rect) const; 00339 00349 QStringList listCachedRectKeys(const QString &image) const; 00350 00358 void insertIntoRectsCache(const QString& image, const QString &element, const QRectF &rect); 00359 00365 void invalidateRectsCache(const QString &image); 00366 00374 void releaseRectsCache(const QString &image); 00375 00380 KUrl homepage() const; 00381 00382 Q_SIGNALS: 00387 void themeChanged(); 00388 00389 public Q_SLOTS: 00394 void settingsChanged(); 00395 00396 private: 00397 friend class ThemeSingleton; 00398 friend class ThemePrivate; 00399 ThemePrivate *const d; 00400 00401 Q_PRIVATE_SLOT(d, void compositingChanged(bool)) 00402 Q_PRIVATE_SLOT(d, void colorsChanged()) 00403 Q_PRIVATE_SLOT(d, void blurBehindChanged(bool blur)) 00404 Q_PRIVATE_SLOT(d, void settingsFileChanged(const QString &)) 00405 Q_PRIVATE_SLOT(d, void scheduledCacheUpdate()) 00406 Q_PRIVATE_SLOT(d, void onAppExitCleanup()) 00407 }; 00408 00409 } // Plasma namespace 00410 00411 #endif // multiple inclusion guard 00412
KDE 4.7 API Reference