diff --git a/shell/osd.h b/shell/osd.h --- a/shell/osd.h +++ b/shell/osd.h @@ -22,6 +22,8 @@ #include #include +#include + namespace KDeclarative { class QmlObject; } @@ -35,7 +37,7 @@ Q_OBJECT Q_CLASSINFO("D-Bus Interface", "org.kde.osdService") public: - Osd(ShellCorona *corona); + Osd(KSharedConfig::Ptr config, ShellCorona *corona); ~Osd() override; public Q_SLOTS: @@ -70,6 +72,8 @@ KDeclarative::QmlObject *m_osdObject = nullptr; QTimer *m_osdTimer = nullptr; int m_timeout = 0; + + KSharedConfig::Ptr m_config; }; #endif // OSD_H diff --git a/shell/osd.cpp b/shell/osd.cpp --- a/shell/osd.cpp +++ b/shell/osd.cpp @@ -29,9 +29,10 @@ #include #include -Osd::Osd(ShellCorona *corona) +Osd::Osd(KSharedConfig::Ptr config, ShellCorona *corona) : QObject(corona) , m_osdPath(corona->lookAndFeelPackage().filePath("osdmainscript")) + , m_config(config) { QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/osdService"), this, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals); } @@ -153,6 +154,10 @@ bool Osd::init() { + if (m_config && !KConfigGroup(m_config, QStringLiteral("OSD")).readEntry(QStringLiteral("Enabled"), true)) { + return false; + } + if (m_osdObject && m_osdObject->rootObject()) { return true; } diff --git a/shell/shellcorona.h b/shell/shellcorona.h --- a/shell/shellcorona.h +++ b/shell/shellcorona.h @@ -210,6 +210,7 @@ private: void updateStruts(); + void configurationChanged(const QString &path); bool isOutputRedundant(QScreen* screen) const; void reconsiderOutputs(); QList panelsForScreen(QScreen *screen) const; @@ -223,6 +224,9 @@ void insertContainment(const QString &activity, int screenNum, Plasma::Containment *containment); + KSharedConfig::Ptr m_config; + QString m_configPath; + ScreenPool *m_screenPool; QString m_shell; KActivities::Controller *m_activityController; diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp --- a/shell/shellcorona.cpp +++ b/shell/shellcorona.cpp @@ -86,6 +86,7 @@ ShellCorona::ShellCorona(QObject *parent) : Plasma::Corona(parent), + m_config(KSharedConfig::openConfig(QStringLiteral("plasmarc"))), m_screenPool(new ScreenPool(KSharedConfig::openConfig(), this)), m_activityController(new KActivities::Controller(this)), m_addPanelAction(nullptr), @@ -216,7 +217,13 @@ }); } - new Osd(this); + new Osd(m_config, this); + + // catch when plasmarc changes, so we e.g. enable/disable the OSd + m_configPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + m_config->name(); + KDirWatch::self()->addFile(m_configPath); + connect(KDirWatch::self(), &KDirWatch::dirty, this, &ShellCorona::configurationChanged); + connect(KDirWatch::self(), &KDirWatch::created, this, &ShellCorona::configurationChanged); } ShellCorona::~ShellCorona() @@ -254,7 +261,7 @@ QString themeName; - KConfigGroup plasmarc(KSharedConfig::openConfig(QStringLiteral("plasmarc")), themeGroupKey); + KConfigGroup plasmarc(m_config, themeGroupKey); themeName = plasmarc.readEntry(themeNameKey, themeName); if (themeName.isEmpty()) { @@ -2013,6 +2020,12 @@ } } +void ShellCorona::configurationChanged(const QString &path) +{ + if (path == m_configPath) { + m_config->reparseConfiguration(); + } +} void ShellCorona::activateLauncherMenu() {