make it possible to set the theme per-application, allowing krunner to share plasma's theme by default but amarok to have their own Fun(tm) too
svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=689180
This commit is contained in:
parent
cf889b289b
commit
9789d8b57f
45
theme.cpp
45
theme.cpp
@ -27,19 +27,20 @@ namespace Plasma
|
||||
|
||||
class Theme::Private
|
||||
{
|
||||
public:
|
||||
Private()
|
||||
: themeName( "default" )
|
||||
{
|
||||
}
|
||||
public:
|
||||
Private()
|
||||
: themeName( "default" )
|
||||
{
|
||||
}
|
||||
|
||||
QString themeName;
|
||||
QString themeName;
|
||||
QString app;
|
||||
};
|
||||
|
||||
class ThemeSingleton
|
||||
{
|
||||
public:
|
||||
Theme self;
|
||||
public:
|
||||
Theme self;
|
||||
};
|
||||
|
||||
K_GLOBAL_STATIC( ThemeSingleton, privateSelf )
|
||||
@ -53,9 +54,7 @@ Theme::Theme(QObject* parent)
|
||||
: QObject(parent),
|
||||
d(new Private)
|
||||
{
|
||||
KConfig config( "plasmarc" );
|
||||
KConfigGroup group( &config, "Theme" );
|
||||
d->themeName = group.readEntry( "name", d->themeName );
|
||||
settingsChanged();
|
||||
}
|
||||
|
||||
Theme::~Theme()
|
||||
@ -63,6 +62,30 @@ Theme::~Theme()
|
||||
delete d;
|
||||
}
|
||||
|
||||
void Theme::setApplication(const QString &appname)
|
||||
{
|
||||
if (d->app != appname) {
|
||||
d->app = appname;
|
||||
settingsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void Theme::settingsChanged()
|
||||
{
|
||||
QString groupName = "Theme";
|
||||
if (!d->app.isEmpty() && d->app != "plasma") {
|
||||
groupName.append("-").append(d->app);
|
||||
}
|
||||
|
||||
KSharedConfig::Ptr config = KSharedConfig::openConfig("plasmarc");
|
||||
KConfigGroup group(config, groupName);
|
||||
QString themeName = group.readEntry("name", d->themeName);
|
||||
if (themeName != d->themeName) {
|
||||
d->themeName = themeName;
|
||||
emit changed();
|
||||
}
|
||||
}
|
||||
|
||||
QString Theme::themeName() const
|
||||
{
|
||||
return d->themeName;
|
||||
|
16
theme.h
16
theme.h
@ -57,6 +57,15 @@ class PLASMA_EXPORT Theme : public QObject
|
||||
explicit Theme( QObject* parent = 0 );
|
||||
~Theme();
|
||||
|
||||
/**
|
||||
* Sets the application the theme setting is associated with. This
|
||||
* allows for individual applications that use libplasma to have the
|
||||
* theme set independantly.
|
||||
*
|
||||
* @param appname name of the application
|
||||
**/
|
||||
void setApplication(const QString &appname);
|
||||
|
||||
/**
|
||||
* @return the name of the theme. "default" is none set.
|
||||
*/
|
||||
@ -78,6 +87,13 @@ class PLASMA_EXPORT Theme : public QObject
|
||||
*/
|
||||
void changed();
|
||||
|
||||
public Q_SLOTS:
|
||||
/**
|
||||
* Notifies the Theme object that the theme settings have changed
|
||||
* and should be read from the config file
|
||||
**/
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
class Private;
|
||||
Private* const d;
|
||||
|
Loading…
Reference in New Issue
Block a user