Changeset View
Changeset View
Standalone View
Standalone View
kcmkwin/kwinscreenedges/touch.cpp
1 | /******************************************************************** | 1 | /******************************************************************** | ||
---|---|---|---|---|---|
2 | KWin - the KDE window manager | 2 | KWin - the KDE window manager | ||
3 | This file is part of the KDE project. | 3 | This file is part of the KDE project. | ||
4 | 4 | | |||
5 | Copyright (C) 2008 Martin Gräßlin <mgraesslin@kde.org> | 5 | Copyright (C) 2008 Martin Gräßlin <mgraesslin@kde.org> | ||
6 | Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com> | 6 | Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com> | ||
7 | Copyright (C) 2020 Cyril Rossi <cyril.rossi@enioka.com> | ||||
7 | 8 | | |||
8 | This program is free software; you can redistribute it and/or modify | 9 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | 10 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | 11 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | 12 | (at your option) any later version. | ||
12 | 13 | | |||
13 | This program is distributed in the hope that it will be useful, | 14 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
Show All 11 Lines | |||||
26 | #include <KAboutData> | 27 | #include <KAboutData> | ||
27 | #include <KConfigGroup> | 28 | #include <KConfigGroup> | ||
28 | #include <KLocalizedString> | 29 | #include <KLocalizedString> | ||
29 | #include <KPluginFactory> | 30 | #include <KPluginFactory> | ||
30 | #include <KPackage/Package> | 31 | #include <KPackage/Package> | ||
31 | #include <KPackage/PackageLoader> | 32 | #include <KPackage/PackageLoader> | ||
32 | #include <QtDBus> | 33 | #include <QtDBus> | ||
33 | 34 | | |||
35 | #include "kwintouchscreensettings.h" | ||||
36 | #include "kwintouchscreenscriptsettings.h" | ||||
37 | | ||||
34 | K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin<KWin::KWinScreenEdgesConfig>();) | 38 | K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin<KWin::KWinScreenEdgesConfig>();) | ||
35 | 39 | | |||
36 | namespace KWin | 40 | namespace KWin | ||
37 | { | 41 | { | ||
38 | 42 | | |||
39 | KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm(QWidget* parent) | 43 | KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm(QWidget* parent) | ||
40 | : QWidget(parent) | 44 | : QWidget(parent) | ||
41 | { | 45 | { | ||
42 | setupUi(this); | 46 | setupUi(this); | ||
43 | } | 47 | } | ||
44 | 48 | | |||
45 | KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args) | 49 | KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args) | ||
46 | : KCModule(parent, args) | 50 | : KCModule(parent, args) | ||
47 | , m_config(KSharedConfig::openConfig("kwinrc")) | 51 | , m_config(KSharedConfig::openConfig("kwinrc")) | ||
52 | , m_settings(new KWinTouchScreenSettings(this)) | ||||
48 | { | 53 | { | ||
49 | m_ui = new KWinScreenEdgesConfigForm(this); | 54 | m_ui = new KWinScreenEdgesConfigForm(this); | ||
ervin: This would be better in the initialization list. Also this is leaked. | |||||
Agree, much better to put in initialization list. crossi: Agree, much better to put in initialization list.
It's not leaked, I renamed it to m_form since… | |||||
ervin: Ah indeed, stupid me. | |||||
50 | QVBoxLayout* layout = new QVBoxLayout(this); | 55 | QVBoxLayout* layout = new QVBoxLayout(this); | ||
51 | layout->addWidget(m_ui); | 56 | layout->addWidget(m_ui); | ||
52 | 57 | | |||
53 | monitorInit(); | 58 | monitorInit(); | ||
54 | 59 | | |||
55 | connect(m_ui->monitor, SIGNAL(changed()), this, SLOT(changed())); | 60 | connect(m_ui->monitor, &Monitor::changed, this, [this]() { | ||
56 | 61 | monitorSaveSettings(); | |||
57 | load(); | 62 | updateUnmanagedState(); | ||
63 | }); | ||||
58 | } | 64 | } | ||
59 | 65 | | |||
60 | KWinScreenEdgesConfig::~KWinScreenEdgesConfig() | 66 | KWinScreenEdgesConfig::~KWinScreenEdgesConfig() | ||
61 | { | 67 | { | ||
62 | } | 68 | } | ||
63 | 69 | | |||
64 | void KWinScreenEdgesConfig::load() | 70 | void KWinScreenEdgesConfig::load() | ||
65 | { | 71 | { | ||
66 | KCModule::load(); | 72 | KCModule::load(); | ||
73 | m_settings->load(); | ||||
74 | for (auto setting : m_scriptSettings) { | ||||
Could you please use an explicit type here? It's not obvious what type setting has. https://community.kde.org/Policies/Library_Code_Policy#auto_Keyword zzag: Could you please use an explicit type here? It's not obvious what type `setting` has.
https… | |||||
If I had my way this policy would get an update. This is "obviously" a setting object so it can be loaded. ;-) More seriously, and more importantly (to me) this lacks a qAsConst for m_scriptSettings ervin: If I had my way this policy would get an update. This is "obviously" a setting object so it can… | |||||
75 | setting->load(); | ||||
76 | } | ||||
67 | 77 | | |||
68 | monitorLoad(); | 78 | monitorLoadSettings(); | ||
69 | 79 | updateUnmanagedState(); | |||
70 | emit changed(false); | | |||
71 | } | 80 | } | ||
72 | 81 | | |||
73 | void KWinScreenEdgesConfig::save() | 82 | void KWinScreenEdgesConfig::save() | ||
74 | { | 83 | { | ||
75 | KCModule::save(); | 84 | monitorSaveSettings(); | ||
76 | 85 | m_settings->save(); | |||
77 | monitorSave(); | 86 | for (auto setting : m_scriptSettings) { | ||
ervin: qAsConst missing | |||||
87 | setting->save(); | ||||
88 | } | ||||
78 | 89 | | |||
79 | // Reload KWin. | 90 | // Reload KWin. | ||
80 | QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | 91 | QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig"); | ||
81 | QDBusConnection::sessionBus().send(message); | 92 | QDBusConnection::sessionBus().send(message); | ||
82 | // and reconfigure the effects | 93 | // and reconfigure the effects | ||
83 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | 94 | OrgKdeKwinEffectsInterface interface(QStringLiteral("org.kde.KWin"), | ||
84 | QStringLiteral("/Effects"), | 95 | QStringLiteral("/Effects"), | ||
85 | QDBusConnection::sessionBus()); | 96 | QDBusConnection::sessionBus()); | ||
86 | interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::PresentWindows)); | 97 | interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::PresentWindows)); | ||
87 | interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::DesktopGrid)); | 98 | interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::DesktopGrid)); | ||
88 | interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::Cube)); | 99 | interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::Cube)); | ||
89 | 100 | | |||
90 | emit changed(false); | 101 | KCModule::save(); | ||
91 | } | 102 | } | ||
92 | 103 | | |||
93 | void KWinScreenEdgesConfig::defaults() | 104 | void KWinScreenEdgesConfig::defaults() | ||
94 | { | 105 | { | ||
95 | monitorDefaults(); | 106 | m_settings->setDefaults(); | ||
96 | 107 | for (auto setting : m_scriptSettings) { | |||
ervin: qAsConst missing | |||||
97 | emit changed(true); | 108 | setting->setDefaults(); | ||
109 | } | ||||
110 | monitorLoadSettings(); | ||||
111 | KCModule::defaults(); | ||||
112 | updateUnmanagedState(); | ||||
98 | } | 113 | } | ||
99 | 114 | | |||
100 | void KWinScreenEdgesConfig::showEvent(QShowEvent* e) | 115 | void KWinScreenEdgesConfig::showEvent(QShowEvent* e) | ||
101 | { | 116 | { | ||
102 | KCModule::showEvent(e); | 117 | KCModule::showEvent(e); | ||
103 | 118 | | |||
104 | monitorShowEvent(); | 119 | monitorShowEvent(); | ||
105 | } | 120 | } | ||
106 | 121 | | |||
122 | void KWinScreenEdgesConfig::updateUnmanagedState() | ||||
123 | { | ||||
124 | bool isScriptSaveNeeded = std::any_of(m_scriptSettings.cbegin(), | ||||
125 | m_scriptSettings.cend(), | ||||
126 | [](const KWinTouchScreenScriptSettings *setting) { | ||||
127 | return setting->isSaveNeeded(); | ||||
128 | }); | ||||
129 | unmanagedWidgetChangeState(m_settings->isSaveNeeded() || isScriptSaveNeeded); | ||||
130 | | ||||
131 | bool isScriptNotDefault = std::any_of(m_scriptSettings.cbegin(), | ||||
132 | m_scriptSettings.cend(), | ||||
133 | [](const KWinTouchScreenScriptSettings *setting) { | ||||
134 | return !setting->isDefaults(); | ||||
135 | }); | ||||
136 | unmanagedWidgetDefaultState(m_settings->isDefaults() && !isScriptNotDefault ); | ||||
137 | } | ||||
138 | | ||||
107 | // Copied from kcmkwin/kwincompositing/main.cpp | 139 | // Copied from kcmkwin/kwincompositing/main.cpp | ||
108 | bool KWinScreenEdgesConfig::effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const | 140 | bool KWinScreenEdgesConfig::effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const | ||
109 | { | 141 | { | ||
110 | return cfg.readEntry(BuiltInEffects::nameForEffect(effect) + "Enabled", BuiltInEffects::enabledByDefault(effect)); | 142 | return cfg.readEntry(BuiltInEffects::nameForEffect(effect) + "Enabled", BuiltInEffects::enabledByDefault(effect)); | ||
111 | } | 143 | } | ||
112 | 144 | | |||
113 | //----------------------------------------------------------------------------- | 145 | //----------------------------------------------------------------------------- | ||
114 | // Monitor | 146 | // Monitor | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 188 | if (script.value(QStringLiteral("X-KWin-Border-Activate")) != QLatin1String("true")) { | |||
157 | continue; | 189 | continue; | ||
158 | } | 190 | } | ||
159 | 191 | | |||
160 | if (!config.readEntry(script.pluginId() + QStringLiteral("Enabled"), script.isEnabledByDefault())) { | 192 | if (!config.readEntry(script.pluginId() + QStringLiteral("Enabled"), script.isEnabledByDefault())) { | ||
161 | continue; | 193 | continue; | ||
162 | } | 194 | } | ||
163 | m_scripts << script.pluginId(); | 195 | m_scripts << script.pluginId(); | ||
164 | monitorAddItem(script.name()); | 196 | monitorAddItem(script.name()); | ||
197 | m_scriptSettings[script.pluginId()] = new KWinTouchScreenScriptSettings(script.pluginId(), this); | ||||
165 | } | 198 | } | ||
166 | 199 | | |||
167 | monitorHideEdge(ElectricTopLeft, true); | 200 | monitorHideEdge(ElectricTopLeft, true); | ||
168 | monitorHideEdge(ElectricTopRight, true); | 201 | monitorHideEdge(ElectricTopRight, true); | ||
169 | monitorHideEdge(ElectricBottomRight, true); | 202 | monitorHideEdge(ElectricBottomRight, true); | ||
170 | monitorHideEdge(ElectricBottomLeft, true); | 203 | monitorHideEdge(ElectricBottomLeft, true); | ||
171 | 204 | | |||
172 | monitorShowEvent(); | 205 | monitorShowEvent(); | ||
173 | } | 206 | } | ||
174 | 207 | | |||
175 | void KWinScreenEdgesConfig::monitorLoadAction(ElectricBorder edge, const QString& configName) | 208 | void KWinScreenEdgesConfig::monitorLoadSettings() | ||
176 | { | | |||
177 | KConfigGroup config(m_config, "TouchEdges"); | | |||
178 | QString lowerName = config.readEntry(configName, "None").toLower(); | | |||
179 | if (lowerName == "showdesktop") monitorChangeEdge(edge, int(ElectricActionShowDesktop)); | | |||
180 | else if (lowerName == "lockscreen") monitorChangeEdge(edge, int(ElectricActionLockScreen)); | | |||
181 | else if (lowerName == "krunner") monitorChangeEdge(edge, int(ElectricActionKRunner)); | | |||
182 | else if (lowerName == "activitymanager") monitorChangeEdge(edge, int(ElectricActionActivityManager)); | | |||
183 | else if (lowerName == "applicationlauncher") monitorChangeEdge(edge, int(ElectricActionApplicationLauncher)); | | |||
184 | } | | |||
185 | | ||||
186 | void KWinScreenEdgesConfig::monitorLoad() | | |||
187 | { | 209 | { | ||
188 | // Load ElectricBorderActions | 210 | // Load ElectricBorderActions | ||
189 | monitorLoadAction(ElectricTop, "Top"); | 211 | monitorChangeEdge(ElectricTop, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->top())); | ||
190 | monitorLoadAction(ElectricRight, "Right"); | 212 | monitorChangeEdge(ElectricRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->right())); | ||
191 | monitorLoadAction(ElectricBottom, "Bottom"); | 213 | monitorChangeEdge(ElectricBottom, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->bottom())); | ||
192 | monitorLoadAction(ElectricLeft, "Left"); | 214 | monitorChangeEdge(ElectricLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->left())); | ||
193 | 215 | | |||
194 | // Load effect-specific actions: | 216 | // Load effect-specific actions: | ||
195 | 217 | | |||
196 | // Present Windows | | |||
197 | KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows"); | | |||
198 | QList<int> list = QList<int>(); | | |||
199 | // PresentWindows BorderActivateAll | 218 | // Present Windows BorderActivateAll | ||
200 | list.append(int(ElectricTopLeft)); | 219 | QList<int> list = m_settings->touchBorderActivateAll(); | ||
201 | list = presentWindowsConfig.readEntry("TouchBorderActivateAll", list); | | |||
202 | foreach (int i, list) { | 220 | foreach (int i, list) { | ||
203 | monitorChangeEdge(ElectricBorder(i), int(PresentWindowsAll)); | 221 | monitorChangeEdge(ElectricBorder(i), int(PresentWindowsAll)); | ||
204 | } | 222 | } | ||
205 | // PresentWindows BorderActivate | 223 | // PresentWindows BorderActivate | ||
ervin: Since you're touching those lines anyway, please clean up the c-casts to int | |||||
206 | list.clear(); | 224 | list = m_settings->touchBorderActivatePresentWindows(); | ||
207 | list.append(int(ElectricNone)); | | |||
208 | list = presentWindowsConfig.readEntry("TouchBorderActivate", list); | | |||
209 | foreach (int i, list) { | 225 | foreach (int i, list) { | ||
210 | monitorChangeEdge(ElectricBorder(i), int(PresentWindowsCurrent)); | 226 | monitorChangeEdge(ElectricBorder(i), int(PresentWindowsCurrent)); | ||
211 | } | 227 | } | ||
212 | // PresentWindows BorderActivateClass | 228 | // PresentWindows BorderActivateClass | ||
213 | list.clear(); | 229 | list = m_settings->touchBorderActivateClass(); | ||
214 | list.append(int(ElectricNone)); | | |||
215 | list = presentWindowsConfig.readEntry("TouchBorderActivateClass", list); | | |||
216 | foreach (int i, list) { | 230 | foreach (int i, list) { | ||
217 | monitorChangeEdge(ElectricBorder(i), int(PresentWindowsClass)); | 231 | monitorChangeEdge(ElectricBorder(i), int(PresentWindowsClass)); | ||
218 | } | 232 | } | ||
219 | 233 | | |||
220 | // Desktop Grid | 234 | // Desktop Grid BorderActivate | ||
221 | KConfigGroup gridConfig(m_config, "Effect-DesktopGrid"); | 235 | list = m_settings->touchBorderActivateDesktopGrid(); | ||
222 | list.clear(); | | |||
223 | list.append(int(ElectricNone)); | | |||
224 | list = gridConfig.readEntry("TouchBorderActivate", list); | | |||
225 | foreach (int i, list) { | 236 | foreach (int i, list) { | ||
226 | monitorChangeEdge(ElectricBorder(i), int(DesktopGrid)); | 237 | monitorChangeEdge(ElectricBorder(i), int(DesktopGrid)); | ||
227 | } | 238 | } | ||
228 | 239 | | |||
229 | // Desktop Cube | 240 | // Desktop Cube BorderActivate | ||
230 | KConfigGroup cubeConfig(m_config, "Effect-Cube"); | 241 | list = m_settings->touchBorderActivateCube(); | ||
231 | list.clear(); | | |||
232 | list.append(int(ElectricNone)); | | |||
233 | list = cubeConfig.readEntry("TouchBorderActivate", list); | | |||
234 | foreach (int i, list) { | 242 | foreach (int i, list) { | ||
235 | monitorChangeEdge(ElectricBorder(i), int(Cube)); | 243 | monitorChangeEdge(ElectricBorder(i), int(Cube)); | ||
236 | } | 244 | } | ||
237 | list.clear(); | 245 | // Desktop Cube BorderActivateCylinder | ||
238 | list.append(int(ElectricNone)); | 246 | list = m_settings->touchBorderActivateCylinder(); | ||
239 | list = cubeConfig.readEntry("TouchBorderActivateCylinder", list); | | |||
240 | foreach (int i, list) { | 247 | foreach (int i, list) { | ||
241 | monitorChangeEdge(ElectricBorder(i), int(Cylinder)); | 248 | monitorChangeEdge(ElectricBorder(i), int(Cylinder)); | ||
242 | } | 249 | } | ||
243 | list.clear(); | 250 | // Desktop Cube BorderActivateSphere | ||
244 | list.append(int(ElectricNone)); | 251 | list = m_settings->touchBorderActivateSphere(); | ||
245 | list = cubeConfig.readEntry("TouchBorderActivateSphere", list); | | |||
246 | foreach (int i, list) { | 252 | foreach (int i, list) { | ||
247 | monitorChangeEdge(ElectricBorder(i), int(Sphere)); | 253 | monitorChangeEdge(ElectricBorder(i), int(Sphere)); | ||
248 | } | 254 | } | ||
249 | 255 | | |||
250 | // TabBox | 256 | // TabBox BorderActivate | ||
251 | KConfigGroup tabBoxConfig(m_config, "TabBox"); | 257 | list = m_settings->touchBorderActivateTabBox(); | ||
252 | list.clear(); | | |||
253 | // TabBox | | |||
254 | list.append(int(ElectricLeft)); | | |||
255 | list = tabBoxConfig.readEntry("TouchBorderActivate", list); | | |||
256 | foreach (int i, list) { | 258 | foreach (int i, list) { | ||
257 | monitorChangeEdge(ElectricBorder(i), int(TabBox)); | 259 | monitorChangeEdge(ElectricBorder(i), int(TabBox)); | ||
258 | } | 260 | } | ||
259 | // Alternative TabBox | 261 | // Alternative TabBox | ||
260 | list.clear(); | 262 | list = m_settings->touchBorderAlternativeActivate(); | ||
261 | list.append(int(ElectricNone)); | | |||
262 | list = tabBoxConfig.readEntry("TouchBorderAlternativeActivate", list); | | |||
263 | foreach (int i, list) { | 263 | foreach (int i, list) { | ||
264 | monitorChangeEdge(ElectricBorder(i), int(TabBoxAlternative)); | 264 | monitorChangeEdge(ElectricBorder(i), int(TabBoxAlternative)); | ||
265 | } | 265 | } | ||
266 | 266 | | |||
267 | // Scripts | ||||
267 | for (int i=0; i < m_scripts.size(); i++) { | 268 | for (int i=0; i < m_scripts.size(); i++) { | ||
268 | int index = EffectCount + i; | 269 | int index = EffectCount + i; | ||
269 | KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]); | 270 | list = m_scriptSettings[m_scripts[i]]->touchBorderActivate(); | ||
270 | list.append(int(ElectricNone)); | | |||
271 | list = scriptConfig.readEntry("TouchBorderActivate", list); | | |||
272 | for (int i: list) { | 271 | for (int i: list) { | ||
273 | monitorChangeEdge(ElectricBorder(i), index); | 272 | monitorChangeEdge(ElectricBorder(i), index); | ||
274 | } | 273 | } | ||
275 | } | 274 | } | ||
276 | } | 275 | } | ||
277 | 276 | | |||
278 | void KWinScreenEdgesConfig::monitorSaveAction(int edge, const QString& configName) | 277 | void KWinScreenEdgesConfig::monitorSaveSettings() | ||
279 | { | | |||
280 | KConfigGroup config(m_config, "TouchEdges"); | | |||
281 | int item = m_ui->monitor->selectedEdgeItem(edge); | | |||
282 | if (item == 1) | | |||
283 | config.writeEntry(configName, "ShowDesktop"); | | |||
284 | else if (item == 2) | | |||
285 | config.writeEntry(configName, "LockScreen"); | | |||
286 | else if (item == 3) | | |||
287 | config.writeEntry(configName, "KRunner"); | | |||
288 | else if (item == 4) | | |||
289 | config.writeEntry(configName, "ActivityManager"); | | |||
290 | else if (item == 5) | | |||
291 | config.writeEntry(configName, "ApplicationLauncher"); | | |||
292 | else // Anything else | | |||
293 | config.writeEntry(configName, "None"); | | |||
294 | } | | |||
295 | | ||||
296 | void KWinScreenEdgesConfig::monitorSave() | | |||
297 | { | 278 | { | ||
298 | // Save ElectricBorderActions | 279 | // Save ElectricBorderActions | ||
299 | monitorSaveAction(int(Monitor::Top), "Top"); | 280 | m_settings->setTop(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->monitor->selectedEdgeItem(static_cast<int>(Monitor::Top)))); | ||
300 | monitorSaveAction(int(Monitor::Right), "Right"); | 281 | m_settings->setRight(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->monitor->selectedEdgeItem(static_cast<int>(Monitor::Right)))); | ||
301 | monitorSaveAction(int(Monitor::Bottom), "Bottom"); | 282 | m_settings->setBottom(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->monitor->selectedEdgeItem(static_cast<int>(Monitor::Bottom)))); | ||
302 | monitorSaveAction(int(Monitor::Left), "Left"); | 283 | m_settings->setLeft(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->monitor->selectedEdgeItem(static_cast<int>(Monitor::Left)))); | ||
303 | 284 | | |||
304 | // Save effect-specific actions: | 285 | // Save effect-specific actions: | ||
305 | 286 | | |||
306 | // Present Windows | 287 | // Present Windows | ||
307 | KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows"); | 288 | m_settings->setTouchBorderActivatePresentWindows(monitorCheckEffectHasEdge(static_cast<int>(PresentWindowsAll))); | ||
308 | presentWindowsConfig.writeEntry("TouchBorderActivate", | 289 | m_settings->setTouchBorderActivateAll(monitorCheckEffectHasEdge(static_cast<int>(PresentWindowsCurrent))); | ||
309 | monitorCheckEffectHasEdge(int(PresentWindowsAll))); | 290 | m_settings->setTouchBorderActivateClass(monitorCheckEffectHasEdge(static_cast<int>(PresentWindowsClass))); | ||
310 | presentWindowsConfig.writeEntry("TouchBorderActivateAll", | | |||
311 | monitorCheckEffectHasEdge(int(PresentWindowsCurrent))); | | |||
312 | presentWindowsConfig.writeEntry("TouchBorderActivateClass", | | |||
313 | monitorCheckEffectHasEdge(int(PresentWindowsClass))); | | |||
314 | 291 | | |||
315 | // Desktop Grid | 292 | // Desktop Grid | ||
316 | KConfigGroup gridConfig(m_config, "Effect-DesktopGrid"); | 293 | m_settings->setTouchBorderActivateDesktopGrid(monitorCheckEffectHasEdge(static_cast<int>(DesktopGrid))); | ||
317 | gridConfig.writeEntry("TouchBorderActivate", | | |||
318 | monitorCheckEffectHasEdge(int(DesktopGrid))); | | |||
319 | 294 | | |||
320 | // Desktop Cube | 295 | // Desktop Cube | ||
321 | KConfigGroup cubeConfig(m_config, "Effect-Cube"); | 296 | m_settings->setTouchBorderActivateCube(monitorCheckEffectHasEdge(static_cast<int>(Cube))); | ||
322 | cubeConfig.writeEntry("TouchBorderActivate", | 297 | m_settings->setTouchBorderActivateCylinder(monitorCheckEffectHasEdge(static_cast<int>(Cylinder))); | ||
323 | monitorCheckEffectHasEdge(int(Cube))); | 298 | m_settings->setTouchBorderActivateSphere(monitorCheckEffectHasEdge(static_cast<int>(Sphere))); | ||
324 | cubeConfig.writeEntry("TouchBorderActivateCylinder", | | |||
325 | monitorCheckEffectHasEdge(int(Cylinder))); | | |||
326 | cubeConfig.writeEntry("TouchBorderActivateSphere", | | |||
327 | monitorCheckEffectHasEdge(int(Sphere))); | | |||
328 | 299 | | |||
329 | // TabBox | 300 | // TabBox | ||
330 | KConfigGroup tabBoxConfig(m_config, "TabBox"); | 301 | m_settings->setTouchBorderActivateTabBox(monitorCheckEffectHasEdge(static_cast<int>(TabBox))); | ||
331 | tabBoxConfig.writeEntry("TouchBorderActivate", | 302 | m_settings->setTouchBorderAlternativeActivate(monitorCheckEffectHasEdge(static_cast<int>(TabBoxAlternative))); | ||
332 | monitorCheckEffectHasEdge(int(TabBox))); | | |||
333 | tabBoxConfig.writeEntry("TouchBorderAlternativeActivate", | | |||
334 | monitorCheckEffectHasEdge(int(TabBoxAlternative))); | | |||
335 | 303 | | |||
304 | // Scripts | ||||
336 | for (int i=0; i < m_scripts.size(); i++) { | 305 | for (int i = 0; i < m_scripts.size(); i++) { | ||
337 | int index = EffectCount + i; | 306 | int index = EffectCount + i; | ||
338 | KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]); | 307 | m_scriptSettings[m_scripts[i]]->setTouchBorderActivate(monitorCheckEffectHasEdge(index)); | ||
339 | scriptConfig.writeEntry("TouchBorderActivate", | | |||
340 | monitorCheckEffectHasEdge(index)); | | |||
341 | } | | |||
342 | } | 308 | } | ||
343 | | ||||
344 | void KWinScreenEdgesConfig::monitorDefaults() | | |||
345 | { | | |||
346 | // Clear all edges | | |||
347 | for (int i = 0; i < 8; i++) | | |||
348 | m_ui->monitor->selectEdgeItem(i, 0); | | |||
349 | // select TabBox | | |||
350 | m_ui->monitor->selectEdgeItem(int(Monitor::Left), int(TabBox)); | | |||
351 | } | 309 | } | ||
352 | 310 | | |||
353 | void KWinScreenEdgesConfig::monitorShowEvent() | 311 | void KWinScreenEdgesConfig::monitorShowEvent() | ||
354 | { | 312 | { | ||
355 | // Check if they are enabled | 313 | // Check if they are enabled | ||
356 | KConfigGroup config(m_config, "Plugins"); | 314 | KConfigGroup config(m_config, "Plugins"); | ||
357 | 315 | | |||
358 | // Present Windows | 316 | // Present Windows | ||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Line(s) | 403 | { | |||
461 | if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopLeft)) == index) | 419 | if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopLeft)) == index) | ||
462 | list.append(int(ElectricTopLeft)); | 420 | list.append(int(ElectricTopLeft)); | ||
463 | 421 | | |||
464 | if (list.isEmpty()) | 422 | if (list.isEmpty()) | ||
465 | list.append(int(ElectricNone)); | 423 | list.append(int(ElectricNone)); | ||
466 | return list; | 424 | return list; | ||
467 | } | 425 | } | ||
468 | 426 | | |||
427 | ElectricBorderAction KWinScreenEdgesConfig::electricBorderActionFromString(const QString &s) | ||||
428 | { | ||||
429 | QString lowerName = s.toLower(); | ||||
430 | if (lowerName == QStringLiteral("showdesktop")) { | ||||
431 | return ElectricActionShowDesktop; | ||||
432 | } | ||||
433 | if (lowerName == QStringLiteral("lockscreen")) { | ||||
434 | return ElectricActionLockScreen; | ||||
435 | } | ||||
436 | if (lowerName == QStringLiteral("krunner")) { | ||||
437 | return ElectricActionKRunner; | ||||
438 | } | ||||
439 | if (lowerName == QStringLiteral("activitymanager")) { | ||||
440 | return ElectricActionActivityManager; | ||||
441 | } | ||||
442 | if (lowerName == QStringLiteral("applicationlauncher")) { | ||||
443 | return ElectricActionApplicationLauncher; | ||||
444 | } | ||||
445 | return ElectricActionNone; | ||||
446 | } | ||||
447 | | ||||
448 | QString KWinScreenEdgesConfig::electricBorderActionToString(int a) | ||||
zzag: No short names
int a -> int action | |||||
449 | { | ||||
450 | switch (a) { | ||||
451 | case 1: | ||||
452 | return QStringLiteral("ShowDesktop"); | ||||
453 | case 2: | ||||
454 | return QStringLiteral("LockScreen"); | ||||
455 | case 3: | ||||
456 | return QStringLiteral("KRunner"); | ||||
457 | case 4: | ||||
458 | return QStringLiteral("ActivityManager"); | ||||
459 | case 5: | ||||
460 | return QStringLiteral("ApplicationLauncher"); | ||||
461 | default: | ||||
462 | return QStringLiteral("None"); | ||||
463 | } | ||||
464 | } | ||||
465 | | ||||
469 | } // namespace | 466 | } // namespace | ||
470 | 467 | | |||
471 | #include "touch.moc" | 468 | #include "touch.moc" |
This would be better in the initialization list. Also this is leaked.