00001 #ifndef THEME_MANAGER_H
00002 #define THEME_MANAGER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <QObject>
00025 #include <QSvgRenderer>
00026 #include <QHash>
00027
00028
00029 #include <kconfig.h>
00030
00031
00032 class ThemeManager;
00033
00039 class Themable
00040 {
00041 public:
00044 Themable();
00045
00052 Themable(QString id, ThemeManager* thememanager);
00053
00056 virtual ~Themable();
00057
00061 QString id() {return mId;}
00062
00066 ThemeManager* thememanager() {return mThemeManager;}
00067
00071 double getScale() {return mScale;}
00072
00076 void setScale(double scale) {mScale = scale;}
00077
00082 virtual void changeTheme() = 0;
00083
00084 private:
00085
00086 QString mId;
00087
00088
00089 ThemeManager* mThemeManager;
00090
00091
00092 double mScale;
00093 };
00094
00095
00096
00105 class ThemeManager : public QObject
00106 {
00107
00108 public:
00114 ThemeManager(QString themefile, QObject* parent, int initialSize = 1);
00115
00123 const QPixmap getPixmap(QString svgid, QSize size);
00124
00133 const QPixmap getPixmap(QString svgid, double width);
00134
00144 const QPixmap getPixmap(QString svgid, QString svgref, double refwidth);
00145
00149 double getScale();
00150
00154 KConfigGroup config(QString id);
00155
00159 void registerTheme(Themable* ob);
00160
00164 void unregisterTheme(Themable* ob);
00165
00170 void updateTheme(Themable* ob);
00171
00178 void updateTheme(QString themefile);
00179
00185 void rescale(int scale);
00186
00187
00188 private:
00189
00190 QSvgRenderer* mRenderer;
00191
00192
00193 QHash<Themable*,int> mObjects;
00194
00195
00196 QHash<QString,QPixmap> mPixmapCache;
00197
00198
00199 KConfig* mConfig;
00200
00201
00202 int mScale;
00203
00204 };
00205
00206
00207 #endif