From 9636922827d4e9f198c2010a4eeca5549517e91c Mon Sep 17 00:00:00 2001 From: Mika Allan Rauhala Date: Wed, 22 Apr 2015 12:31:05 +0200 Subject: [PATCH] Fix DecorationPalette loading when kdeglobals doesn't exist When kdeglobals doesn't exist, QStandardPaths::locate() for it returns an empty string, so the check in previous fix doesn't work in this case. This change sets m_colorScheme properly in this case and also creates an empty kdeglobals(needed because QFileSystemWatcher can't monitor non-existing files) so kdeglobals can be reloaded if it is later populated. REVIEW: 123399 --- decorations/decorationpalette.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/decorations/decorationpalette.cpp b/decorations/decorationpalette.cpp index d086de9817..7552c79ccb 100644 --- a/decorations/decorationpalette.cpp +++ b/decorations/decorationpalette.cpp @@ -41,6 +41,15 @@ DecorationPalette::DecorationPalette(const QString &colorScheme) ? colorScheme : QStandardPaths::locate(QStandardPaths::GenericConfigLocation, colorScheme)) { + if (m_colorScheme.isEmpty() && colorScheme == QStringLiteral("kdeglobals")) { + // kdeglobals doesn't exist so create it. This is needed to monitor it using QFileSystemWatcher. + auto config = KSharedConfig::openConfig(colorScheme, KConfig::SimpleConfig); + KConfigGroup wmConfig(config, QStringLiteral("WM")); + wmConfig.writeEntry("FakeEntryToKeepThisGroup", true); + config->sync(); + + m_colorScheme = QStandardPaths::locate(QStandardPaths::GenericConfigLocation, colorScheme); + } m_watcher.addPath(m_colorScheme); connect(&m_watcher, &QFileSystemWatcher::fileChanged, [this]() { m_watcher.addPath(m_colorScheme);