summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Uwe Broulik <kde@privat.broulik.de>2017-01-11 19:06:48 (GMT)
committerMarco Martin <notmart@gmail.com>2017-03-24 11:56:41 (GMT)
commit37ac27c59d97db3bb173ae1786a639cce0c6feb6 (patch)
tree79894b0424a73ffc3d45dffbee150fcc38cad803
parent7f2dceb95c5812207c87f4b61d5a90e0306603d6 (diff)
[OSD] Allow disabling OSD through config file
Differential Revision: https://phabricator.kde.org/D1770
-rw-r--r--shell/osd.cpp7
-rw-r--r--shell/osd.h6
-rw-r--r--shell/shellcorona.cpp17
-rw-r--r--shell/shellcorona.h4
4 files changed, 30 insertions, 4 deletions
diff --git a/shell/osd.cpp b/shell/osd.cpp
index 48ff27c..2dc8cd6 100644
--- a/shell/osd.cpp
+++ b/shell/osd.cpp
@@ -29,9 +29,10 @@
#include <KDeclarative/QmlObject>
#include <klocalizedstring.h>
-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 @@ void Osd::virtualKeyboardEnabledChanged(bool virtualKeyboardEnabled)
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/osd.h b/shell/osd.h
index 76c4749..ca6a548 100644
--- a/shell/osd.h
+++ b/shell/osd.h
@@ -22,6 +22,8 @@
#include <QObject>
#include <QString>
+#include <KSharedConfig>
+
namespace KDeclarative {
class QmlObject;
}
@@ -35,7 +37,7 @@ class Osd : public QObject {
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 @@ private:
KDeclarative::QmlObject *m_osdObject = nullptr;
QTimer *m_osdTimer = nullptr;
int m_timeout = 0;
+
+ KSharedConfig::Ptr m_config;
};
#endif // OSD_H
diff --git a/shell/shellcorona.cpp b/shell/shellcorona.cpp
index 14fa7fc..6c98931 100644
--- a/shell/shellcorona.cpp
+++ b/shell/shellcorona.cpp
@@ -88,6 +88,7 @@ static const int s_configSyncDelay = 10000; // 10 seconds
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),
@@ -207,7 +208,13 @@ ShellCorona::ShellCorona(QObject *parent)
connect(m_activityController, &KActivities::Controller::activityAdded, this, &ShellCorona::activityAdded);
connect(m_activityController, &KActivities::Controller::activityRemoved, this, &ShellCorona::activityRemoved);
- 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);
qApp->installEventFilter(this);
}
@@ -262,7 +269,7 @@ void ShellCorona::setShell(const QString &shell)
QString themeName;
- KConfigGroup plasmarc(KSharedConfig::openConfig(QStringLiteral("plasmarc")), themeGroupKey);
+ KConfigGroup plasmarc(m_config, themeGroupKey);
themeName = plasmarc.readEntry(themeNameKey, themeName);
if (themeName.isEmpty()) {
@@ -2044,6 +2051,12 @@ void ShellCorona::updateStruts()
}
}
+void ShellCorona::configurationChanged(const QString &path)
+{
+ if (path == m_configPath) {
+ m_config->reparseConfiguration();
+ }
+}
void ShellCorona::activateLauncherMenu()
{
diff --git a/shell/shellcorona.h b/shell/shellcorona.h
index b4eb49d..b028e99 100644
--- a/shell/shellcorona.h
+++ b/shell/shellcorona.h
@@ -212,6 +212,7 @@ private Q_SLOTS:
private:
void updateStruts();
+ void configurationChanged(const QString &path);
bool isOutputRedundant(QScreen* screen) const;
void reconsiderOutputs();
QList<PanelView *> panelsForScreen(QScreen *screen) const;
@@ -225,6 +226,9 @@ private:
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;