Simplify plasma theme startup

Don't emit themeChanged when constructing Plasma::Theme instances

Reviewed by David Edmundson
This commit is contained in:
Aleix Pol 2014-05-26 19:03:46 +02:00
parent 12811f1fc4
commit 9d9c72630c
3 changed files with 12 additions and 11 deletions

View File

@ -451,18 +451,18 @@ void ThemePrivate::settingsFileChanged(const QString &file)
} }
} else if (file.endsWith(themeRcFile)) { } else if (file.endsWith(themeRcFile)) {
config().config()->reparseConfiguration(); config().config()->reparseConfiguration();
settingsChanged(); settingsChanged(true);
} }
} }
void ThemePrivate::settingsChanged() void ThemePrivate::settingsChanged(bool emitChanges)
{ {
if (fixedName) { if (fixedName) {
return; return;
} }
//qDebug() << "Settings Changed!"; //qDebug() << "Settings Changed!";
KConfigGroup cg = config(); KConfigGroup cg = config();
setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false); setThemeName(cg.readEntry("name", ThemePrivate::defaultTheme), false, emitChanges);
} }
QColor ThemePrivate::color(Theme::ColorRole role) const QColor ThemePrivate::color(Theme::ColorRole role) const
@ -563,7 +563,7 @@ void ThemePrivate::processContrastSettings(KConfigBase *metadata)
} }
} }
void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings) void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings, bool emitChanged)
{ {
QString theme = tempThemeName; QString theme = tempThemeName;
if (theme.isEmpty() || theme == themeName) { if (theme.isEmpty() || theme == themeName) {
@ -668,7 +668,8 @@ void ThemePrivate::setThemeName(const QString &tempThemeName, bool writeSettings
cg.sync(); cg.sync();
} }
scheduleThemeChangeNotification(SvgElementsCache); if(emitChanged)
scheduleThemeChangeNotification(SvgElementsCache);
} }
bool ThemePrivate::eventFilter(QObject *watched, QEvent *event) bool ThemePrivate::eventFilter(QObject *watched, QEvent *event)

View File

@ -77,7 +77,7 @@ public:
void discardCache(CacheTypes caches); void discardCache(CacheTypes caches);
void scheduleThemeChangeNotification(CacheTypes caches); void scheduleThemeChangeNotification(CacheTypes caches);
bool useCache(); bool useCache();
void setThemeName(const QString &themeName, bool writeSettings); void setThemeName(const QString &themeName, bool writeSettings, bool emitChanged);
void processWallpaperSettings(KConfigBase *metadata); void processWallpaperSettings(KConfigBase *metadata);
void processContrastSettings(KConfigBase *metadata); void processContrastSettings(KConfigBase *metadata);
@ -93,7 +93,7 @@ public Q_SLOTS:
void scheduledCacheUpdate(); void scheduledCacheUpdate();
void onAppExitCleanup(); void onAppExitCleanup();
void notifyOfChanged(); void notifyOfChanged();
void settingsChanged(); void settingsChanged(bool emitChanges);
Q_SIGNALS: Q_SIGNALS:
void themeChanged(); void themeChanged();

View File

@ -55,7 +55,7 @@ Theme::Theme(QObject *parent)
ThemePrivate::globalThemeRefCount.ref(); ThemePrivate::globalThemeRefCount.ref();
d = ThemePrivate::globalTheme; d = ThemePrivate::globalTheme;
d->settingsChanged(); d->settingsChanged(false);
if (QCoreApplication::instance()) { if (QCoreApplication::instance()) {
connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()), connect(QCoreApplication::instance(), SIGNAL(aboutToQuit()),
d, SLOT(onAppExitCleanup())); d, SLOT(onAppExitCleanup()));
@ -79,7 +79,7 @@ Theme::Theme(const QString &themeName, QObject *parent)
// turn off caching so we don't accidently trigger unnecessary disk activity at this point // turn off caching so we don't accidently trigger unnecessary disk activity at this point
bool useCache = d->cacheTheme; bool useCache = d->cacheTheme;
d->cacheTheme = false; d->cacheTheme = false;
d->setThemeName(themeName, false); d->setThemeName(themeName, false, false);
d->cacheTheme = useCache; d->cacheTheme = useCache;
d->fixedName = true; d->fixedName = true;
if (QCoreApplication::instance()) { if (QCoreApplication::instance()) {
@ -144,7 +144,7 @@ void Theme::setThemeName(const QString &themeName)
connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged); connect(d, &ThemePrivate::themeChanged, this, &Theme::themeChanged);
} }
d->setThemeName(themeName, true); d->setThemeName(themeName, true, true);
} }
QString Theme::themeName() const QString Theme::themeName() const
@ -293,7 +293,7 @@ void Theme::setUseGlobalSettings(bool useGlobal)
d->useGlobal = useGlobal; d->useGlobal = useGlobal;
d->cfg = KConfigGroup(); d->cfg = KConfigGroup();
d->themeName.clear(); d->themeName.clear();
d->settingsChanged(); d->settingsChanged(true);
} }
bool Theme::useGlobalSettings() const bool Theme::useGlobalSettings() const