Changeset View
Changeset View
Standalone View
Standalone View
shell/osd.cpp
Show All 23 Lines | |||||
24 | #include <QWindow> | 24 | #include <QWindow> | ||
25 | #include <QDebug> | 25 | #include <QDebug> | ||
26 | #include <QUrl> | 26 | #include <QUrl> | ||
27 | 27 | | |||
28 | #include <Plasma/Package> | 28 | #include <Plasma/Package> | ||
29 | #include <KDeclarative/QmlObject> | 29 | #include <KDeclarative/QmlObject> | ||
30 | #include <klocalizedstring.h> | 30 | #include <klocalizedstring.h> | ||
31 | 31 | | |||
32 | Osd::Osd(ShellCorona *corona) | 32 | Osd::Osd(KSharedConfig::Ptr config, ShellCorona *corona) | ||
33 | : QObject(corona) | 33 | : QObject(corona) | ||
34 | , m_osdPath(corona->lookAndFeelPackage().filePath("osdmainscript")) | 34 | , m_osdPath(corona->lookAndFeelPackage().filePath("osdmainscript")) | ||
35 | , m_config(config) | ||||
35 | { | 36 | { | ||
graesslin: sharing a lesson learned from KWin: if you dependency inject the KSharedConfig you get two… | |||||
36 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/osdService"), this, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals); | 37 | QDBusConnection::sessionBus().registerObject(QStringLiteral("/org/kde/osdService"), this, QDBusConnection::ExportAllSlots | QDBusConnection::ExportAllSignals); | ||
37 | } | 38 | } | ||
38 | 39 | | |||
39 | Osd::~Osd() | 40 | Osd::~Osd() | ||
40 | { | 41 | { | ||
41 | } | 42 | } | ||
42 | 43 | | |||
43 | void Osd::brightnessChanged(int percent) | 44 | void Osd::brightnessChanged(int percent) | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 148 | if (virtualKeyboardEnabled) { | |||
148 | showText(QStringLiteral("input-keyboard-virtual-on"), i18nc("on screen keyboard was enabled because physical keyboard got unplugged, keep short", "On-Screen Keyboard Activated")); | 149 | showText(QStringLiteral("input-keyboard-virtual-on"), i18nc("on screen keyboard was enabled because physical keyboard got unplugged, keep short", "On-Screen Keyboard Activated")); | ||
149 | } else { | 150 | } else { | ||
150 | showText(QStringLiteral("input-keyboard-virtual-off"), i18nc("on screen keyboard was disabled because physical keyboard was plugged in, keep short", "On-Screen Keyboard Deactivated")); | 151 | showText(QStringLiteral("input-keyboard-virtual-off"), i18nc("on screen keyboard was disabled because physical keyboard was plugged in, keep short", "On-Screen Keyboard Deactivated")); | ||
151 | } | 152 | } | ||
152 | } | 153 | } | ||
153 | 154 | | |||
154 | bool Osd::init() | 155 | bool Osd::init() | ||
155 | { | 156 | { | ||
157 | if (m_config && !KConfigGroup(m_config, QStringLiteral("OSD")).readEntry(QStringLiteral("Enabled"), true)) { | ||||
158 | return false; | ||||
159 | } | ||||
160 | | ||||
156 | if (m_osdObject && m_osdObject->rootObject()) { | 161 | if (m_osdObject && m_osdObject->rootObject()) { | ||
157 | return true; | 162 | return true; | ||
158 | } | 163 | } | ||
159 | 164 | | |||
160 | if (m_osdPath.isEmpty()) { | 165 | if (m_osdPath.isEmpty()) { | ||
161 | return false; | 166 | return false; | ||
162 | } | 167 | } | ||
163 | 168 | | |||
▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines |
sharing a lesson learned from KWin: if you dependency inject the KSharedConfig you get two advantages: