diff --git a/kcmkwin/kwinscreenedges/CMakeLists.txt b/kcmkwin/kwinscreenedges/CMakeLists.txt
--- a/kcmkwin/kwinscreenedges/CMakeLists.txt
+++ b/kcmkwin/kwinscreenedges/CMakeLists.txt
@@ -26,8 +26,9 @@
)
target_link_libraries(kcm_kwinscreenedges ${X11_LIBRARIES} ${kcm_screenedges_LIBS})
-set(kcm_kwintouchscreenedges_PART_SRCS touch.cpp ${kcm_screenedges_SRCS})
+set(kcm_kwintouchscreenedges_PART_SRCS touch.cpp kwnscreenedgeconfigform.cpp ${kcm_screenedges_SRCS})
ki18n_wrap_ui(kcm_kwintouchscreenedges_PART_SRCS touch.ui)
+kconfig_add_kcfg_files(kcm_kwintouchscreenedges_PART_SRCS kwintouchscreensettings.kcfgc kwintouchscreenscriptsettings.kcfgc)
add_library(kcm_kwintouchscreen MODULE ${kcm_kwintouchscreenedges_PART_SRCS})
target_link_libraries(kcm_kwintouchscreen ${X11_LIBRARIES} ${kcm_screenedges_LIBS})
diff --git a/kcmkwin/kwinscreenedges/kwintouchscreenscriptsettings.kcfg b/kcmkwin/kwinscreenedges/kwintouchscreenscriptsettings.kcfg
new file mode 100644
--- /dev/null
+++ b/kcmkwin/kwinscreenedges/kwintouchscreenscriptsettings.kcfg
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+ ElectricNone
+
+
+
diff --git a/kcmkwin/kwinscreenedges/kwintouchscreenscriptsettings.kcfgc b/kcmkwin/kwinscreenedges/kwintouchscreenscriptsettings.kcfgc
new file mode 100644
--- /dev/null
+++ b/kcmkwin/kwinscreenedges/kwintouchscreenscriptsettings.kcfgc
@@ -0,0 +1,7 @@
+File=kwintouchscreenscriptsettings.kcfg
+NameSpace=KWin
+ClassName=KWinTouchScreenScriptSettings
+IncludeFiles=kwinglobals.h
+Mutators=true
+DefaultValueGetters=true
+ParentInConstructor=true
diff --git a/kcmkwin/kwinscreenedges/kwintouchscreensettings.kcfg b/kcmkwin/kwinscreenedges/kwintouchscreensettings.kcfg
new file mode 100644
--- /dev/null
+++ b/kcmkwin/kwinscreenedges/kwintouchscreensettings.kcfg
@@ -0,0 +1,56 @@
+
+
+
+
+
+ None
+
+
+ None
+
+
+ None
+
+
+ None
+
+
+
+
+ ElectricNone
+
+
+ ElectricNone
+
+
+ ElectricNone
+
+
+
+
+ ElectricNone
+
+
+
+
+ ElectricNone
+
+
+ ElectricNone
+
+
+ ElectricNone
+
+
+
+
+ ElectricLeft
+
+
+ ElectricNone
+
+
+
diff --git a/kcmkwin/kwinscreenedges/kwintouchscreensettings.kcfgc b/kcmkwin/kwinscreenedges/kwintouchscreensettings.kcfgc
new file mode 100644
--- /dev/null
+++ b/kcmkwin/kwinscreenedges/kwintouchscreensettings.kcfgc
@@ -0,0 +1,7 @@
+File=kwintouchscreensettings.kcfg
+NameSpace=KWin
+ClassName=KWinTouchScreenSettings
+IncludeFiles=kwinglobals.h
+Mutators=true
+DefaultValueGetters=true
+ParentInConstructor=true
diff --git a/kcmkwin/kwinscreenedges/kwnscreenedgeconfigform.h b/kcmkwin/kwinscreenedges/kwnscreenedgeconfigform.h
new file mode 100644
--- /dev/null
+++ b/kcmkwin/kwinscreenedges/kwnscreenedgeconfigform.h
@@ -0,0 +1,84 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2009 Lucas Murray
+Copyright (C) 2020 Cyril Rossi
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*********************************************************************/
+
+#ifndef __KWINSCREENEDGECONFIGFORM_H__
+#define __KWINSCREENEDGECONFIGFORM_H__
+
+#include
+
+#include "kwinglobals.h"
+
+namespace Ui
+{
+class KWinTouchScreenConfigUi;
+}
+
+namespace KWin
+{
+
+class KWinScreenEdgeConfigForm : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit KWinScreenEdgeConfigForm(QWidget *parent);
+
+ void monitorHideEdge(ElectricBorder border, bool hidden);
+
+ void monitorAddItem(const QString &item);
+ void monitorItemSetEnabled(int index, bool enabled);
+
+ QList monitorCheckEffectHasEdge(int index) const;
+ int selectedEdgeItem(ElectricBorder border) const;
+
+ void monitorChangeEdge(ElectricBorder border, int index);
+ void monitorChangeEdge(const QList &borderList, int index);
+
+ void monitorChangeDefaultEdge(ElectricBorder border, int index);
+ void monitorChangeDefaultEdge(const QList &borderList, int index);
+
+ // revert to reference settings and assess for saveNeeded and default changed
+ void reload();
+ // reset to default settings and assess for saveNeeded and default changed
+ void setDefaults();
+
+private Q_SLOTS:
+ void onChanged();
+
+Q_SIGNALS:
+ void saveNeededChanged(bool isNeeded);
+ void defaultChanged(bool isDefault);
+
+private:
+ // internal use, assert if border equals ELECTRIC_COUNT or ElectricNone
+ static int electricBorderToMonitorEdge(ElectricBorder border);
+ static ElectricBorder monitorEdgeToElectricBorder(int edge);
+
+private:
+ QHash m_reference; // reference settings
+ QHash m_default; // default settings
+
+ Ui::KWinTouchScreenConfigUi *ui;
+};
+
+} // namespace
+
+#endif
diff --git a/kcmkwin/kwinscreenedges/kwnscreenedgeconfigform.cpp b/kcmkwin/kwinscreenedges/kwnscreenedgeconfigform.cpp
new file mode 100644
--- /dev/null
+++ b/kcmkwin/kwinscreenedges/kwnscreenedgeconfigform.cpp
@@ -0,0 +1,214 @@
+/********************************************************************
+ KWin - the KDE window manager
+ This file is part of the KDE project.
+
+Copyright (C) 2009 Lucas Murray
+Copyright (C) 2020 Cyril Rossi
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see .
+*********************************************************************/
+
+#include "kwnscreenedgeconfigform.h"
+
+#include
+
+#include "monitor.h"
+#include "ui_touch.h"
+
+namespace KWin
+{
+
+KWinScreenEdgeConfigForm::KWinScreenEdgeConfigForm(QWidget *parent)
+ : QWidget(parent)
+ , ui(new Ui::KWinTouchScreenConfigUi)
+{
+ ui->setupUi(this);
+
+ connect(ui->monitor,
+ &Monitor::changed,
+ this,
+ &KWinScreenEdgeConfigForm::onChanged);
+}
+
+void KWinScreenEdgeConfigForm::monitorHideEdge(ElectricBorder border, bool hidden)
+{
+ const int edge = KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(border);
+ ui->monitor->setEdgeHidden(edge, hidden);
+}
+
+void KWinScreenEdgeConfigForm::monitorAddItem(const QString &item)
+{
+ for (int i = 0; i < 8; i++) {
+ ui->monitor->addEdgeItem(i, item);
+ }
+}
+
+void KWinScreenEdgeConfigForm::monitorItemSetEnabled(int index, bool enabled)
+{
+ for (int i = 0; i < 8; i++) {
+ ui->monitor->setEdgeItemEnabled(i, index, enabled);
+ }
+}
+
+void KWinScreenEdgeConfigForm::monitorChangeEdge(const QList &borderList, int index)
+{
+ for (int border : borderList) {
+ monitorChangeEdge(static_cast(border), index);
+ }
+}
+
+void KWinScreenEdgeConfigForm::monitorChangeEdge(ElectricBorder border, int index)
+{
+ if (ELECTRIC_COUNT == border || ElectricNone == border) {
+ return;
+ }
+ m_reference[border] = index;
+ ui->monitor->selectEdgeItem(KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(border), index);
+}
+
+QList KWinScreenEdgeConfigForm::monitorCheckEffectHasEdge(int index) const
+{
+ QList list = QList();
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::Top)) == index) {
+ list.append(static_cast(ElectricTop));
+ }
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::TopRight)) == index) {
+ list.append(static_cast(ElectricTopRight));
+ }
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::Right)) == index) {
+ list.append(static_cast(ElectricRight));
+ }
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::BottomRight)) == index) {
+ list.append(static_cast(ElectricBottomRight));
+ }
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::Bottom)) == index) {
+ list.append(static_cast(ElectricBottom));
+ }
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::BottomLeft)) == index) {
+ list.append(static_cast(ElectricBottomLeft));
+ }
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::Left)) == index) {
+ list.append(static_cast(ElectricLeft));
+ }
+ if (ui->monitor->selectedEdgeItem(static_cast(Monitor::TopLeft)) == index) {
+ list.append(static_cast(ElectricTopLeft));
+ }
+
+ if (list.isEmpty()) {
+ list.append(static_cast(ElectricNone));
+ }
+ return list;
+}
+
+int KWinScreenEdgeConfigForm::selectedEdgeItem(ElectricBorder border) const
+{
+ return ui->monitor->selectedEdgeItem(KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(border));
+}
+
+void KWinScreenEdgeConfigForm::monitorChangeDefaultEdge(ElectricBorder border, int index)
+{
+ if (ELECTRIC_COUNT == border || ElectricNone == border) {
+ return;
+ }
+ m_default[border] = index;
+}
+
+void KWinScreenEdgeConfigForm::monitorChangeDefaultEdge(const QList &borderList, int index)
+{
+ for (int border : borderList) {
+ monitorChangeDefaultEdge(static_cast(border), index);
+ }
+}
+
+void KWinScreenEdgeConfigForm::reload()
+{
+ for (auto it = m_reference.begin(); it != m_reference.cend(); ++it) {
+ ui->monitor->selectEdgeItem(KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(it.key()), it.value());
+ }
+ onChanged();
+}
+
+void KWinScreenEdgeConfigForm::setDefaults()
+{
+ for (auto it = m_default.begin(); it != m_default.cend(); ++it) {
+ ui->monitor->selectEdgeItem(KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(it.key()), it.value());
+ }
+ onChanged();
+}
+
+int KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(ElectricBorder border)
+{
+ switch(border) {
+ case ElectricTop:
+ return static_cast(Monitor::Top);
+ case ElectricTopRight:
+ return static_cast(Monitor::TopRight);
+ case ElectricRight:
+ return static_cast(Monitor::Right);
+ case ElectricBottomRight:
+ return static_cast(Monitor::BottomRight);
+ case ElectricBottom:
+ return static_cast(Monitor::Bottom);
+ case ElectricBottomLeft:
+ return static_cast(Monitor::BottomLeft);
+ case ElectricLeft:
+ return static_cast(Monitor::Left);
+ case ElectricTopLeft:
+ return static_cast(Monitor::TopLeft);
+ default: // ELECTRIC_COUNT and ElectricNone
+ Q_ASSERT(false);
+ }
+}
+
+ElectricBorder KWinScreenEdgeConfigForm::monitorEdgeToElectricBorder(int edge)
+{
+ const Monitor::Edges monitorEdge = static_cast(edge);
+ switch (monitorEdge) {
+ case Monitor::Left:
+ return ElectricLeft;
+ case Monitor::Right:
+ return ElectricRight;
+ case Monitor::Top:
+ return ElectricTop;
+ case Monitor::Bottom:
+ return ElectricBottom;
+ case Monitor::TopLeft:
+ return ElectricTopLeft;
+ case Monitor::TopRight:
+ return ElectricTopRight;
+ case Monitor::BottomLeft:
+ return ElectricBottomLeft;
+ case Monitor::BottomRight:
+ return ElectricBottomRight;
+ default:
+ return ElectricNone;
+ }
+}
+
+void KWinScreenEdgeConfigForm::onChanged()
+{
+ bool needSave = false;
+ for (auto it = m_reference.begin(); it != m_reference.cend(); ++it) {
+ needSave |= it.value() != ui->monitor->selectedEdgeItem(KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(it.key()));
+ }
+ emit saveNeededChanged(needSave);
+
+ bool isDefault = true;
+ for (auto it = m_default.begin(); it != m_default.cend(); ++it) {
+ isDefault &= it.value() == ui->monitor->selectedEdgeItem(KWinScreenEdgeConfigForm::electricBorderToMonitorEdge(it.key()));
+ }
+ emit defaultChanged(isDefault);
+}
+
+} // namespace
diff --git a/kcmkwin/kwinscreenedges/touch.h b/kcmkwin/kwinscreenedges/touch.h
--- a/kcmkwin/kwinscreenedges/touch.h
+++ b/kcmkwin/kwinscreenedges/touch.h
@@ -3,6 +3,7 @@
This file is part of the KDE project.
Copyright (C) 2009 Lucas Murray
+Copyright (C) 2020 Cyril Rossi
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,40 +27,38 @@
#include "kwinglobals.h"
-#include "ui_touch.h"
class QShowEvent;
namespace KWin
{
+class KWinScreenEdgeConfigForm;
+class KWinTouchScreenSettings;
+class KWinTouchScreenScriptSettings;
enum class BuiltInEffect;
-class KWinScreenEdgesConfigForm : public QWidget, public Ui::KWinScreenEdgesConfigForm
-{
- Q_OBJECT
-
-public:
- explicit KWinScreenEdgesConfigForm(QWidget* parent);
-};
-
class KWinScreenEdgesConfig : public KCModule
{
Q_OBJECT
public:
- explicit KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args);
+ explicit KWinScreenEdgesConfig(QWidget *parent, const QVariantList &args);
~KWinScreenEdgesConfig() override;
public Q_SLOTS:
void save() override;
void load() override;
void defaults() override;
+
protected:
- void showEvent(QShowEvent* e) override;
+ void showEvent(QShowEvent *e) override;
+
private:
- KWinScreenEdgesConfigForm* m_ui;
+ KWinScreenEdgeConfigForm *m_ui;
KSharedConfigPtr m_config;
QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu
+ QHash m_scriptSettings;
+ KWinTouchScreenSettings *m_settings;
enum EffectActions {
PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions
@@ -74,20 +73,16 @@
EffectCount
};
- bool effectEnabled(const BuiltInEffect& effect, const KConfigGroup& cfg) const;
+ bool effectEnabled(const BuiltInEffect &effect, const KConfigGroup &cfg) const;
- void monitorAddItem(const QString& item);
- void monitorItemSetEnabled(int index, bool enabled);
void monitorInit();
- void monitorLoadAction(ElectricBorder edge, const QString& configName);
- void monitorLoad();
- void monitorSaveAction(int edge, const QString& configName);
- void monitorSave();
- void monitorDefaults();
+ void monitorLoadSettings();
+ void monitorLoadDefaultSettings();
+ void monitorSaveSettings();
void monitorShowEvent();
- void monitorChangeEdge(ElectricBorder border, int index);
- void monitorHideEdge(ElectricBorder border, bool hidden);
- QList monitorCheckEffectHasEdge(int index) const;
+
+ static ElectricBorderAction electricBorderActionFromString(const QString &string);
+ static QString electricBorderActionToString(int action);
};
} // namespace
diff --git a/kcmkwin/kwinscreenedges/touch.cpp b/kcmkwin/kwinscreenedges/touch.cpp
--- a/kcmkwin/kwinscreenedges/touch.cpp
+++ b/kcmkwin/kwinscreenedges/touch.cpp
@@ -4,6 +4,7 @@
Copyright (C) 2008 Martin Gräßlin
Copyright (C) 2009 Lucas Murray
+Copyright (C) 2020 Cyril Rossi
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -30,31 +31,30 @@
#include
#include
#include
+#include
+
+#include "kwnscreenedgeconfigform.h"
+#include "kwintouchscreensettings.h"
+#include "kwintouchscreenscriptsettings.h"
K_PLUGIN_FACTORY(KWinScreenEdgesConfigFactory, registerPlugin();)
namespace KWin
{
-KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm(QWidget* parent)
- : QWidget(parent)
-{
- setupUi(this);
-}
-
KWinScreenEdgesConfig::KWinScreenEdgesConfig(QWidget* parent, const QVariantList& args)
: KCModule(parent, args)
, m_config(KSharedConfig::openConfig("kwinrc"))
+ , m_settings(new KWinTouchScreenSettings(this))
{
- m_ui = new KWinScreenEdgesConfigForm(this);
+ m_ui = new KWinScreenEdgeConfigForm(this);
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_ui);
monitorInit();
- connect(m_ui->monitor, SIGNAL(changed()), this, SLOT(changed()));
-
- load();
+ connect(m_ui, &KWinScreenEdgeConfigForm::saveNeededChanged, this, &KWinScreenEdgesConfig::unmanagedWidgetChangeState);
+ connect(m_ui, &KWinScreenEdgeConfigForm::defaultChanged, this, &KWinScreenEdgesConfig::unmanagedWidgetDefaultState);
}
KWinScreenEdgesConfig::~KWinScreenEdgesConfig()
@@ -64,17 +64,27 @@
void KWinScreenEdgesConfig::load()
{
KCModule::load();
+ m_settings->load();
+ for (KWinTouchScreenScriptSettings *setting : qAsConst(m_scriptSettings)) {
+ setting->load();
+ }
- monitorLoad();
-
- emit changed(false);
+ monitorLoadSettings();
+ monitorLoadDefaultSettings();
+ m_ui->reload();
}
void KWinScreenEdgesConfig::save()
{
- KCModule::save();
+ monitorSaveSettings();
+ m_settings->save();
+ for (KWinTouchScreenScriptSettings *setting : qAsConst(m_scriptSettings)) {
+ setting->save();
+ }
- monitorSave();
+ // Reload saved settings to ScreenEdge UI
+ monitorLoadSettings();
+ m_ui->reload();
// Reload KWin.
QDBusMessage message = QDBusMessage::createSignal("/KWin", "org.kde.KWin", "reloadConfig");
@@ -87,14 +97,14 @@
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::DesktopGrid));
interface.reconfigureEffect(BuiltInEffects::nameForEffect(BuiltInEffect::Cube));
- emit changed(false);
+ KCModule::save();
}
void KWinScreenEdgesConfig::defaults()
{
- monitorDefaults();
+ m_ui->setDefaults();
- emit changed(true);
+ KCModule::defaults();
}
void KWinScreenEdgesConfig::showEvent(QShowEvent* e)
@@ -113,40 +123,33 @@
//-----------------------------------------------------------------------------
// Monitor
-void KWinScreenEdgesConfig::monitorAddItem(const QString& item)
-{
- for (int i = 0; i < 8; i++)
- m_ui->monitor->addEdgeItem(i, item);
-}
-
-void KWinScreenEdgesConfig::monitorItemSetEnabled(int index, bool enabled)
-{
- for (int i = 0; i < 8; i++)
- m_ui->monitor->setEdgeItemEnabled(i, index, enabled);
-}
-
void KWinScreenEdgesConfig::monitorInit()
{
- monitorAddItem(i18n("No Action"));
- monitorAddItem(i18n("Show Desktop"));
- monitorAddItem(i18n("Lock Screen"));
- monitorAddItem(i18n("Show KRunner"));
- monitorAddItem(i18n("Activity Manager"));
- monitorAddItem(i18n("Application Launcher"));
+ m_ui->monitorHideEdge(ElectricTopLeft, true);
+ m_ui->monitorHideEdge(ElectricTopRight, true);
+ m_ui->monitorHideEdge(ElectricBottomRight, true);
+ m_ui->monitorHideEdge(ElectricBottomLeft, true);
+
+ m_ui->monitorAddItem(i18n("No Action"));
+ m_ui->monitorAddItem(i18n("Show Desktop"));
+ m_ui->monitorAddItem(i18n("Lock Screen"));
+ m_ui->monitorAddItem(i18n("Show KRunner"));
+ m_ui->monitorAddItem(i18n("Activity Manager"));
+ m_ui->monitorAddItem(i18n("Application Launcher"));
// Add the effects
const QString presentWindowsName = BuiltInEffects::effectData(BuiltInEffect::PresentWindows).displayName;
- monitorAddItem(i18n("%1 - All Desktops", presentWindowsName));
- monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName));
- monitorAddItem(i18n("%1 - Current Application", presentWindowsName));
- monitorAddItem(BuiltInEffects::effectData(BuiltInEffect::DesktopGrid).displayName);
+ m_ui->monitorAddItem(i18n("%1 - All Desktops", presentWindowsName));
+ m_ui->monitorAddItem(i18n("%1 - Current Desktop", presentWindowsName));
+ m_ui->monitorAddItem(i18n("%1 - Current Application", presentWindowsName));
+ m_ui->monitorAddItem(BuiltInEffects::effectData(BuiltInEffect::DesktopGrid).displayName);
const QString cubeName = BuiltInEffects::effectData(BuiltInEffect::Cube).displayName;
- monitorAddItem(i18n("%1 - Cube", cubeName));
- monitorAddItem(i18n("%1 - Cylinder", cubeName));
- monitorAddItem(i18n("%1 - Sphere", cubeName));
+ m_ui->monitorAddItem(i18n("%1 - Cube", cubeName));
+ m_ui->monitorAddItem(i18n("%1 - Cylinder", cubeName));
+ m_ui->monitorAddItem(i18n("%1 - Sphere", cubeName));
- monitorAddItem(i18n("Toggle window switching"));
- monitorAddItem(i18n("Toggle alternative window switching"));
+ m_ui->monitorAddItem(i18n("Toggle window switching"));
+ m_ui->monitorAddItem(i18n("Toggle alternative window switching"));
const QString scriptFolder = QStringLiteral("kwin/scripts/");
const auto scripts = KPackage::PackageLoader::self()->listPackages(QStringLiteral("KWin/Script"), scriptFolder);
@@ -161,309 +164,180 @@
continue;
}
m_scripts << script.pluginId();
- monitorAddItem(script.name());
+ m_ui->monitorAddItem(script.name());
+ m_scriptSettings[script.pluginId()] = new KWinTouchScreenScriptSettings(script.pluginId(), this);
}
- monitorHideEdge(ElectricTopLeft, true);
- monitorHideEdge(ElectricTopRight, true);
- monitorHideEdge(ElectricBottomRight, true);
- monitorHideEdge(ElectricBottomLeft, true);
-
monitorShowEvent();
}
-void KWinScreenEdgesConfig::monitorLoadAction(ElectricBorder edge, const QString& configName)
-{
- KConfigGroup config(m_config, "TouchEdges");
- QString lowerName = config.readEntry(configName, "None").toLower();
- if (lowerName == "showdesktop") monitorChangeEdge(edge, int(ElectricActionShowDesktop));
- else if (lowerName == "lockscreen") monitorChangeEdge(edge, int(ElectricActionLockScreen));
- else if (lowerName == "krunner") monitorChangeEdge(edge, int(ElectricActionKRunner));
- else if (lowerName == "activitymanager") monitorChangeEdge(edge, int(ElectricActionActivityManager));
- else if (lowerName == "applicationlauncher") monitorChangeEdge(edge, int(ElectricActionApplicationLauncher));
-}
-
-void KWinScreenEdgesConfig::monitorLoad()
+void KWinScreenEdgesConfig::monitorLoadSettings()
{
// Load ElectricBorderActions
- monitorLoadAction(ElectricTop, "Top");
- monitorLoadAction(ElectricRight, "Right");
- monitorLoadAction(ElectricBottom, "Bottom");
- monitorLoadAction(ElectricLeft, "Left");
+ m_ui->monitorChangeEdge(ElectricTop, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->top()));
+ m_ui->monitorChangeEdge(ElectricRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->right()));
+ m_ui->monitorChangeEdge(ElectricBottom, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->bottom()));
+ m_ui->monitorChangeEdge(ElectricLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->left()));
// Load effect-specific actions:
- // Present Windows
- KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows");
- QList list = QList();
- // PresentWindows BorderActivateAll
- list.append(int(ElectricTopLeft));
- list = presentWindowsConfig.readEntry("TouchBorderActivateAll", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(PresentWindowsAll));
- }
+ // Present Windows BorderActivateAll
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivateAll(), int(PresentWindowsAll));
// PresentWindows BorderActivate
- list.clear();
- list.append(int(ElectricNone));
- list = presentWindowsConfig.readEntry("TouchBorderActivate", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(PresentWindowsCurrent));
- }
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivatePresentWindows(), int(PresentWindowsCurrent));
// PresentWindows BorderActivateClass
- list.clear();
- list.append(int(ElectricNone));
- list = presentWindowsConfig.readEntry("TouchBorderActivateClass", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(PresentWindowsClass));
- }
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivateClass(), int(PresentWindowsClass));
- // Desktop Grid
- KConfigGroup gridConfig(m_config, "Effect-DesktopGrid");
- list.clear();
- list.append(int(ElectricNone));
- list = gridConfig.readEntry("TouchBorderActivate", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(DesktopGrid));
- }
+ // Desktop Grid BorderActivate
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivateDesktopGrid(), int(DesktopGrid));
- // Desktop Cube
- KConfigGroup cubeConfig(m_config, "Effect-Cube");
- list.clear();
- list.append(int(ElectricNone));
- list = cubeConfig.readEntry("TouchBorderActivate", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(Cube));
- }
- list.clear();
- list.append(int(ElectricNone));
- list = cubeConfig.readEntry("TouchBorderActivateCylinder", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(Cylinder));
- }
- list.clear();
- list.append(int(ElectricNone));
- list = cubeConfig.readEntry("TouchBorderActivateSphere", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(Sphere));
- }
+ // Desktop Cube BorderActivate
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivateCube(), int(Cube));
+ // Desktop Cube BorderActivateCylinder
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivateCylinder(), int(Cylinder));
+ // Desktop Cube BorderActivateSphere
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivateSphere(), int(Sphere));
- // TabBox
- KConfigGroup tabBoxConfig(m_config, "TabBox");
- list.clear();
- // TabBox
- list.append(int(ElectricLeft));
- list = tabBoxConfig.readEntry("TouchBorderActivate", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(TabBox));
- }
+ // TabBox BorderActivate
+ m_ui->monitorChangeEdge(m_settings->touchBorderActivateTabBox(), int(TabBox));
// Alternative TabBox
- list.clear();
- list.append(int(ElectricNone));
- list = tabBoxConfig.readEntry("TouchBorderAlternativeActivate", list);
- foreach (int i, list) {
- monitorChangeEdge(ElectricBorder(i), int(TabBoxAlternative));
- }
+ m_ui->monitorChangeEdge(m_settings->touchBorderAlternativeActivate(), int(TabBoxAlternative));
+ // Scripts
for (int i=0; i < m_scripts.size(); i++) {
int index = EffectCount + i;
- KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]);
- list.append(int(ElectricNone));
- list = scriptConfig.readEntry("TouchBorderActivate", list);
- for (int i: list) {
- monitorChangeEdge(ElectricBorder(i), index);
- }
+ m_ui->monitorChangeEdge(m_scriptSettings[m_scripts[i]]->touchBorderActivate(), index);
}
}
-void KWinScreenEdgesConfig::monitorSaveAction(int edge, const QString& configName)
+void KWinScreenEdgesConfig::monitorLoadDefaultSettings()
{
- KConfigGroup config(m_config, "TouchEdges");
- int item = m_ui->monitor->selectedEdgeItem(edge);
- if (item == 1)
- config.writeEntry(configName, "ShowDesktop");
- else if (item == 2)
- config.writeEntry(configName, "LockScreen");
- else if (item == 3)
- config.writeEntry(configName, "KRunner");
- else if (item == 4)
- config.writeEntry(configName, "ActivityManager");
- else if (item == 5)
- config.writeEntry(configName, "ApplicationLauncher");
- else // Anything else
- config.writeEntry(configName, "None");
+ m_ui->monitorChangeDefaultEdge(ElectricTop, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultTopValue()));
+ m_ui->monitorChangeDefaultEdge(ElectricRight, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultRightValue()));
+ m_ui->monitorChangeDefaultEdge(ElectricBottom, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultBottomValue()));
+ m_ui->monitorChangeDefaultEdge(ElectricLeft, KWinScreenEdgesConfig::electricBorderActionFromString(m_settings->defaultLeftValue()));
+
+ // Present Windows BorderActivateAll
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivateAllValue(), int(PresentWindowsAll));
+ // PresentWindows BorderActivate
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivatePresentWindowsValue(), int(PresentWindowsCurrent));
+ // PresentWindows BorderActivateClass
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivateClassValue(), int(PresentWindowsClass));
+
+ // Desktop Grid BorderActivate
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivateDesktopGridValue(), int(DesktopGrid));
+
+ // Desktop Cube BorderActivate
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivateCubeValue(), int(Cube));
+ // Desktop Cube BorderActivateCylinder
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivateCylinderValue(), int(Cylinder));
+ // Desktop Cube BorderActivateSphere
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivateSphereValue(), int(Sphere));
+
+ // TabBox BorderActivate
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderActivateTabBoxValue(), int(TabBox));
+ // Alternative TabBox
+ m_ui->monitorChangeDefaultEdge(m_settings->defaultTouchBorderAlternativeActivateValue(), int(TabBoxAlternative));
}
-void KWinScreenEdgesConfig::monitorSave()
+void KWinScreenEdgesConfig::monitorSaveSettings()
{
// Save ElectricBorderActions
- monitorSaveAction(int(Monitor::Top), "Top");
- monitorSaveAction(int(Monitor::Right), "Right");
- monitorSaveAction(int(Monitor::Bottom), "Bottom");
- monitorSaveAction(int(Monitor::Left), "Left");
+ m_settings->setTop(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->selectedEdgeItem(ElectricTop)));
+ m_settings->setRight(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->selectedEdgeItem(ElectricRight)));
+ m_settings->setBottom(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->selectedEdgeItem(ElectricBottom)));
+ m_settings->setLeft(KWinScreenEdgesConfig::electricBorderActionToString(m_ui->selectedEdgeItem(ElectricLeft)));
// Save effect-specific actions:
// Present Windows
- KConfigGroup presentWindowsConfig(m_config, "Effect-PresentWindows");
- presentWindowsConfig.writeEntry("TouchBorderActivate",
- monitorCheckEffectHasEdge(int(PresentWindowsAll)));
- presentWindowsConfig.writeEntry("TouchBorderActivateAll",
- monitorCheckEffectHasEdge(int(PresentWindowsCurrent)));
- presentWindowsConfig.writeEntry("TouchBorderActivateClass",
- monitorCheckEffectHasEdge(int(PresentWindowsClass)));
+ m_settings->setTouchBorderActivatePresentWindows(m_ui->monitorCheckEffectHasEdge(static_cast(PresentWindowsAll)));
+ m_settings->setTouchBorderActivateAll(m_ui->monitorCheckEffectHasEdge(static_cast(PresentWindowsCurrent)));
+ m_settings->setTouchBorderActivateClass(m_ui->monitorCheckEffectHasEdge(static_cast(PresentWindowsClass)));
// Desktop Grid
- KConfigGroup gridConfig(m_config, "Effect-DesktopGrid");
- gridConfig.writeEntry("TouchBorderActivate",
- monitorCheckEffectHasEdge(int(DesktopGrid)));
+ m_settings->setTouchBorderActivateDesktopGrid(m_ui->monitorCheckEffectHasEdge(static_cast(DesktopGrid)));
// Desktop Cube
- KConfigGroup cubeConfig(m_config, "Effect-Cube");
- cubeConfig.writeEntry("TouchBorderActivate",
- monitorCheckEffectHasEdge(int(Cube)));
- cubeConfig.writeEntry("TouchBorderActivateCylinder",
- monitorCheckEffectHasEdge(int(Cylinder)));
- cubeConfig.writeEntry("TouchBorderActivateSphere",
- monitorCheckEffectHasEdge(int(Sphere)));
+ m_settings->setTouchBorderActivateCube(m_ui->monitorCheckEffectHasEdge(static_cast(Cube)));
+ m_settings->setTouchBorderActivateCylinder(m_ui->monitorCheckEffectHasEdge(static_cast(Cylinder)));
+ m_settings->setTouchBorderActivateSphere(m_ui->monitorCheckEffectHasEdge(static_cast(Sphere)));
// TabBox
- KConfigGroup tabBoxConfig(m_config, "TabBox");
- tabBoxConfig.writeEntry("TouchBorderActivate",
- monitorCheckEffectHasEdge(int(TabBox)));
- tabBoxConfig.writeEntry("TouchBorderAlternativeActivate",
- monitorCheckEffectHasEdge(int(TabBoxAlternative)));
+ m_settings->setTouchBorderActivateTabBox(m_ui->monitorCheckEffectHasEdge(static_cast(TabBox)));
+ m_settings->setTouchBorderAlternativeActivate(m_ui->monitorCheckEffectHasEdge(static_cast(TabBoxAlternative)));
- for (int i=0; i < m_scripts.size(); i++) {
+ // Scripts
+ for (int i = 0; i < m_scripts.size(); i++) {
int index = EffectCount + i;
- KConfigGroup scriptConfig(m_config, "Script-"+m_scripts[i]);
- scriptConfig.writeEntry("TouchBorderActivate",
- monitorCheckEffectHasEdge(index));
+ m_scriptSettings[m_scripts[i]]->setTouchBorderActivate(m_ui->monitorCheckEffectHasEdge(index));
}
}
-void KWinScreenEdgesConfig::monitorDefaults()
-{
- // Clear all edges
- for (int i = 0; i < 8; i++)
- m_ui->monitor->selectEdgeItem(i, 0);
- // select TabBox
- m_ui->monitor->selectEdgeItem(int(Monitor::Left), int(TabBox));
-}
-
void KWinScreenEdgesConfig::monitorShowEvent()
{
// Check if they are enabled
KConfigGroup config(m_config, "Plugins");
// Present Windows
bool enabled = effectEnabled(BuiltInEffect::PresentWindows, config);
- monitorItemSetEnabled(int(PresentWindowsCurrent), enabled);
- monitorItemSetEnabled(int(PresentWindowsAll), enabled);
+ m_ui->monitorItemSetEnabled(int(PresentWindowsCurrent), enabled);
+ m_ui->monitorItemSetEnabled(int(PresentWindowsAll), enabled);
// Desktop Grid
enabled = effectEnabled(BuiltInEffect::DesktopGrid, config);
- monitorItemSetEnabled(int(DesktopGrid), enabled);
+ m_ui->monitorItemSetEnabled(int(DesktopGrid), enabled);
// Desktop Cube
enabled = effectEnabled(BuiltInEffect::Cube, config);
- monitorItemSetEnabled(int(Cube), enabled);
- monitorItemSetEnabled(int(Cylinder), enabled);
- monitorItemSetEnabled(int(Sphere), enabled);
+ m_ui->monitorItemSetEnabled(int(Cube), enabled);
+ m_ui->monitorItemSetEnabled(int(Cylinder), enabled);
+ m_ui->monitorItemSetEnabled(int(Sphere), enabled);
// tabbox, depends on reasonable focus policy.
KConfigGroup config2(m_config, "Windows");
QString focusPolicy = config2.readEntry("FocusPolicy", QString());
bool reasonable = focusPolicy != "FocusStrictlyUnderMouse" && focusPolicy != "FocusUnderMouse";
- monitorItemSetEnabled(int(TabBox), reasonable);
- monitorItemSetEnabled(int(TabBoxAlternative), reasonable);
+ m_ui->monitorItemSetEnabled(int(TabBox), reasonable);
+ m_ui->monitorItemSetEnabled(int(TabBoxAlternative), reasonable);
}
-void KWinScreenEdgesConfig::monitorChangeEdge(ElectricBorder border, int index)
+ElectricBorderAction KWinScreenEdgesConfig::electricBorderActionFromString(const QString &string)
{
- switch(border) {
- case ElectricTop:
- m_ui->monitor->selectEdgeItem(int(Monitor::Top), index);
- break;
- case ElectricTopRight:
- m_ui->monitor->selectEdgeItem(int(Monitor::TopRight), index);
- break;
- case ElectricRight:
- m_ui->monitor->selectEdgeItem(int(Monitor::Right), index);
- break;
- case ElectricBottomRight:
- m_ui->monitor->selectEdgeItem(int(Monitor::BottomRight), index);
- break;
- case ElectricBottom:
- m_ui->monitor->selectEdgeItem(int(Monitor::Bottom), index);
- break;
- case ElectricBottomLeft:
- m_ui->monitor->selectEdgeItem(int(Monitor::BottomLeft), index);
- break;
- case ElectricLeft:
- m_ui->monitor->selectEdgeItem(int(Monitor::Left), index);
- break;
- case ElectricTopLeft:
- m_ui->monitor->selectEdgeItem(int(Monitor::TopLeft), index);
- break;
- default: // Nothing
- break;
+ QString lowerName = string.toLower();
+ if (lowerName == QStringLiteral("showdesktop")) {
+ return ElectricActionShowDesktop;
}
-}
-
-void KWinScreenEdgesConfig::monitorHideEdge(ElectricBorder border, bool hidden)
-{
- switch(border) {
- case ElectricTop:
- m_ui->monitor->setEdgeHidden(int(Monitor::Top), hidden);
- break;
- case ElectricTopRight:
- m_ui->monitor->setEdgeHidden(int(Monitor::TopRight), hidden);
- break;
- case ElectricRight:
- m_ui->monitor->setEdgeHidden(int(Monitor::Right), hidden);
- break;
- case ElectricBottomRight:
- m_ui->monitor->setEdgeHidden(int(Monitor::BottomRight), hidden);
- break;
- case ElectricBottom:
- m_ui->monitor->setEdgeHidden(int(Monitor::Bottom), hidden);
- break;
- case ElectricBottomLeft:
- m_ui->monitor->setEdgeHidden(int(Monitor::BottomLeft), hidden);
- break;
- case ElectricLeft:
- m_ui->monitor->setEdgeHidden(int(Monitor::Left), hidden);
- break;
- case ElectricTopLeft:
- m_ui->monitor->setEdgeHidden(int(Monitor::TopLeft), hidden);
- break;
- default: // Nothing
- break;
+ if (lowerName == QStringLiteral("lockscreen")) {
+ return ElectricActionLockScreen;
+ }
+ if (lowerName == QStringLiteral("krunner")) {
+ return ElectricActionKRunner;
}
+ if (lowerName == QStringLiteral("activitymanager")) {
+ return ElectricActionActivityManager;
+ }
+ if (lowerName == QStringLiteral("applicationlauncher")) {
+ return ElectricActionApplicationLauncher;
+ }
+ return ElectricActionNone;
}
-QList KWinScreenEdgesConfig::monitorCheckEffectHasEdge(int index) const
+QString KWinScreenEdgesConfig::electricBorderActionToString(int action)
{
- QList list = QList();
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::Top)) == index)
- list.append(int(ElectricTop));
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopRight)) == index)
- list.append(int(ElectricTopRight));
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::Right)) == index)
- list.append(int(ElectricRight));
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::BottomRight)) == index)
- list.append(int(ElectricBottomRight));
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::Bottom)) == index)
- list.append(int(ElectricBottom));
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::BottomLeft)) == index)
- list.append(int(ElectricBottomLeft));
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::Left)) == index)
- list.append(int(ElectricLeft));
- if (m_ui->monitor->selectedEdgeItem(int(Monitor::TopLeft)) == index)
- list.append(int(ElectricTopLeft));
-
- if (list.isEmpty())
- list.append(int(ElectricNone));
- return list;
+ switch (action) {
+ case 1:
+ return QStringLiteral("ShowDesktop");
+ case 2:
+ return QStringLiteral("LockScreen");
+ case 3:
+ return QStringLiteral("KRunner");
+ case 4:
+ return QStringLiteral("ActivityManager");
+ case 5:
+ return QStringLiteral("ApplicationLauncher");
+ default:
+ return QStringLiteral("None");
+ }
}
} // namespace
diff --git a/kcmkwin/kwinscreenedges/touch.ui b/kcmkwin/kwinscreenedges/touch.ui
--- a/kcmkwin/kwinscreenedges/touch.ui
+++ b/kcmkwin/kwinscreenedges/touch.ui
@@ -1,7 +1,7 @@
- KWinScreenEdgesConfigForm
-
+ KWinTouchScreenConfigUi
+
0