Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 01314f8e authored by Cyril Rossi's avatar Cyril Rossi

KCM KWinTouchScreen port to KConfigXT

Summary:
Also manage KCModule states (isSaveNeeded and isDefaults)

BUG: 405573

Test Plan:
* exec kcmshell5 kwintouchscreen
* In an edge, select action Present windows - All desktops, then apply
* close and reopen
* Should display action Present windows - All desktops in the previously selected edge.

* Do same test with Present windows - current desktop

Reviewers: #kwin, ervin, bport, meven, zzag

Reviewed By: #kwin, ervin, meven, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27862
parent b8b71dae
......@@ -5,6 +5,7 @@ include_directories(${KWin_SOURCE_DIR}/effects)
set(kcm_screenedges_SRCS
monitor.cpp
screenpreviewwidget.cpp
kwinscreenedge.cpp
)
qt5_add_dbus_interface(kcm_screenedges_SRCS ${KWin_SOURCE_DIR}/org.kde.kwin.Effects.xml kwin_effects_interface)
......@@ -26,8 +27,9 @@ set(kcm_screenedges_LIBS
)
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 kwintouchscreenedgeconfigform.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})
......
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
Copyright (C) 2020 Cyril Rossi <cyril.rossi@enioka.com>
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 <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "kwinscreenedge.h"
#include "monitor.h"
namespace KWin
{
KWinScreenEdge::KWinScreenEdge(QWidget *parent)
: QWidget(parent)
{
QMetaObject::invokeMethod(this, "createConnection", Qt::QueuedConnection);
}
KWinScreenEdge::~KWinScreenEdge()
{
}
void KWinScreenEdge::monitorHideEdge(ElectricBorder border, bool hidden)
{
const int edge = KWinScreenEdge::electricBorderToMonitorEdge(border);
monitor()->setEdgeHidden(edge, hidden);
}
void KWinScreenEdge::monitorAddItem(const QString &item)
{
for (int i = 0; i < 8; i++) {
monitor()->addEdgeItem(i, item);
}
}
void KWinScreenEdge::monitorItemSetEnabled(int index, bool enabled)
{
for (int i = 0; i < 8; i++) {
monitor()->setEdgeItemEnabled(i, index, enabled);
}
}
void KWinScreenEdge::monitorChangeEdge(const QList<int> &borderList, int index)
{
for (int border : borderList) {
monitorChangeEdge(static_cast<ElectricBorder>(border), index);
}
}
void KWinScreenEdge::monitorChangeEdge(ElectricBorder border, int index)
{
if (ELECTRIC_COUNT == border || ElectricNone == border) {
return;
}
m_reference[border] = index;
monitor()->selectEdgeItem(KWinScreenEdge::electricBorderToMonitorEdge(border), index);
}
QList<int> KWinScreenEdge::monitorCheckEffectHasEdge(int index) const
{
QList<int> list;
if (monitor()->selectedEdgeItem(Monitor::Top) == index) {
list.append(ElectricTop);
}
if (monitor()->selectedEdgeItem(Monitor::TopRight) == index) {
list.append(ElectricTopRight);
}
if (monitor()->selectedEdgeItem(Monitor::Right) == index) {
list.append(ElectricRight);
}
if (monitor()->selectedEdgeItem(Monitor::BottomRight) == index) {
list.append(ElectricBottomRight);
}
if (monitor()->selectedEdgeItem(Monitor::Bottom) == index) {
list.append(ElectricBottom);
}
if (monitor()->selectedEdgeItem(Monitor::BottomLeft) == index) {
list.append(ElectricBottomLeft);
}
if (monitor()->selectedEdgeItem(Monitor::Left) == index) {
list.append(ElectricLeft);
}
if (monitor()->selectedEdgeItem(Monitor::TopLeft) == index) {
list.append(ElectricTopLeft);
}
if (list.isEmpty()) {
list.append(ElectricNone);
}
return list;
}
int KWinScreenEdge::selectedEdgeItem(ElectricBorder border) const
{
return monitor()->selectedEdgeItem(KWinScreenEdge::electricBorderToMonitorEdge(border));
}
void KWinScreenEdge::monitorChangeDefaultEdge(ElectricBorder border, int index)
{
if (ELECTRIC_COUNT == border || ElectricNone == border) {
return;
}
m_default[border] = index;
}
void KWinScreenEdge::monitorChangeDefaultEdge(const QList<int> &borderList, int index)
{
for (int border : borderList) {
monitorChangeDefaultEdge(static_cast<ElectricBorder>(border), index);
}
}
void KWinScreenEdge::reload()
{
for (auto it = m_reference.begin(); it != m_reference.cend(); ++it) {
monitor()->selectEdgeItem(KWinScreenEdge::electricBorderToMonitorEdge(it.key()), it.value());
}
onChanged();
}
void KWinScreenEdge::setDefaults()
{
for (auto it = m_default.begin(); it != m_default.cend(); ++it) {
monitor()->selectEdgeItem(KWinScreenEdge::electricBorderToMonitorEdge(it.key()), it.value());
}
onChanged();
}
int KWinScreenEdge::electricBorderToMonitorEdge(ElectricBorder border)
{
switch(border) {
case ElectricTop:
return Monitor::Top;
case ElectricTopRight:
return Monitor::TopRight;
case ElectricRight:
return Monitor::Right;
case ElectricBottomRight:
return Monitor::BottomRight;
case ElectricBottom:
return Monitor::Bottom;
case ElectricBottomLeft:
return Monitor::BottomLeft;
case ElectricLeft:
return Monitor::Left;
case ElectricTopLeft:
return Monitor::TopLeft;
default: // ELECTRIC_COUNT and ElectricNone
Q_ASSERT(false);
}
}
ElectricBorder KWinScreenEdge::monitorEdgeToElectricBorder(int edge)
{
const Monitor::Edges monitorEdge = static_cast<Monitor::Edges>(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 KWinScreenEdge::onChanged()
{
bool needSave = false;
for (auto it = m_reference.begin(); it != m_reference.cend(); ++it) {
needSave |= it.value() != monitor()->selectedEdgeItem(KWinScreenEdge::electricBorderToMonitorEdge(it.key()));
}
emit saveNeededChanged(needSave);
bool isDefault = true;
for (auto it = m_default.begin(); it != m_default.cend(); ++it) {
isDefault &= it.value() == monitor()->selectedEdgeItem(KWinScreenEdge::electricBorderToMonitorEdge(it.key()));
}
emit defaultChanged(isDefault);
}
void KWinScreenEdge::createConnection()
{
connect(monitor(),
&Monitor::changed,
this,
&KWinScreenEdge::onChanged);
}
} // namespace
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
Copyright (C) 2020 Cyril Rossi <cyril.rossi@enioka.com>
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 <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef __KWINSCREENEDGE_H__
#define __KWINSCREENEDGE_H__
#include <QWidget>
#include "kwinglobals.h"
namespace KWin
{
class Monitor;
class KWinScreenEdge : public QWidget
{
Q_OBJECT
public:
explicit KWinScreenEdge(QWidget *parent = nullptr);
~KWinScreenEdge() override;
void monitorHideEdge(ElectricBorder border, bool hidden);
void monitorAddItem(const QString &item);
void monitorItemSetEnabled(int index, bool enabled);
QList<int> monitorCheckEffectHasEdge(int index) const;
int selectedEdgeItem(ElectricBorder border) const;
void monitorChangeEdge(ElectricBorder border, int index);
void monitorChangeEdge(const QList<int> &borderList, int index);
void monitorChangeDefaultEdge(ElectricBorder border, int index);
void monitorChangeDefaultEdge(const QList<int> &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();
void createConnection();
Q_SIGNALS:
void saveNeededChanged(bool isNeeded);
void defaultChanged(bool isDefault);
private:
virtual Monitor *monitor() const = 0;
// internal use, assert if border equals ELECTRIC_COUNT or ElectricNone
static int electricBorderToMonitorEdge(ElectricBorder border);
static ElectricBorder monitorEdgeToElectricBorder(int edge);
private:
QHash<ElectricBorder, int> m_reference; // reference settings
QHash<ElectricBorder, int> m_default; // default settings
};
} // namespace
#endif
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
Copyright (C) 2020 Cyril Rossi <cyril.rossi@enioka.com>
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 <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "kwintouchscreenedgeconfigform.h"
#include "ui_touch.h"
namespace KWin
{
KWinTouchScreenEdgeConfigForm::KWinTouchScreenEdgeConfigForm(QWidget *parent)
: KWinScreenEdge(parent)
, ui(new Ui::KWinTouchScreenConfigUi)
{
ui->setupUi(this);
}
KWinTouchScreenEdgeConfigForm::~KWinTouchScreenEdgeConfigForm()
{
delete ui;
}
Monitor *KWinTouchScreenEdgeConfigForm::monitor() const
{
return ui->monitor;
}
} // namespace
/********************************************************************
KWin - the KDE window manager
This file is part of the KDE project.
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
Copyright (C) 2020 Cyril Rossi <cyril.rossi@enioka.com>
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 <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef __KWINTOUCHSCREENEDGECONFIGFORM_H__
#define __KWINTOUCHSCREENEDGECONFIGFORM_H__
#include "kwinscreenedge.h"
namespace Ui
{
class KWinTouchScreenConfigUi;
}
namespace KWin
{
class KWinTouchScreenEdgeConfigForm : public KWinScreenEdge
{
Q_OBJECT
public:
KWinTouchScreenEdgeConfigForm(QWidget *parent = nullptr);
~KWinTouchScreenEdgeConfigForm() override;
protected:
Monitor *monitor() const override;
private:
Ui::KWinTouchScreenConfigUi *ui;
};
} // namespace
#endif
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc">
<parameter name="ScriptName"/>
</kcfgfile>
<group name="Script-$(ScriptName)">
<entry key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
</kcfg>
File=kwintouchscreenscriptsettings.kcfg
NameSpace=KWin
ClassName=KWinTouchScreenScriptSettings
IncludeFiles=kwinglobals.h
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true
<?xml version="1.0" encoding="UTF-8"?>
<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0
http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" >
<kcfgfile name="kwinrc"/>
<group name="TouchEdges">
<entry key="Top" type="String">
<default>None</default>
</entry>
<entry key="Right" type="String">
<default>None</default>
</entry>
<entry key="Bottom" type="String">
<default>None</default>
</entry>
<entry key="Left" type="String">
<default>None</default>
</entry>
</group>
<group name="Effect-PresentWindows">
<entry key="TouchBorderActivateAll" type="IntList">
<default>ElectricNone</default>
</entry>
<entry name="TouchBorderActivatePresentWindows" key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
<entry key="TouchBorderActivateClass" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
<group name="Effect-DesktopGrid">
<entry name="TouchBorderActivateDesktopGrid" key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
<group name="Effect-Cube">
<entry name="TouchBorderActivateCube" key="TouchBorderActivate" type="IntList">
<default>ElectricNone</default>
</entry>
<entry key="TouchBorderActivateCylinder" type="IntList">
<default>ElectricNone</default>
</entry>
<entry key="TouchBorderActivateSphere" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
<group name="TabBox">
<entry name="TouchBorderActivateTabBox" key="TouchBorderActivate" type="IntList">
<default>ElectricLeft</default>
</entry>
<entry key="TouchBorderAlternativeActivate" type="IntList">
<default>ElectricNone</default>
</entry>
</group>
</kcfg>
File=kwintouchscreensettings.kcfg
NameSpace=KWin
ClassName=KWinTouchScreenSettings
IncludeFiles=kwinglobals.h
Mutators=true
DefaultValueGetters=true
ParentInConstructor=true
This diff is collapsed.
......@@ -3,6 +3,7 @@
This file is part of the KDE project.
Copyright (C) 2009 Lucas Murray <lmurray@undefinedfire.com>
Copyright (C) 2020 Cyril Rossi <cyril.rossi@enioka.com>
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,37 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "kwinglobals.h"
#include "ui_touch.h"
class QShowEvent;
namespace KWin
{
class KWinTouchScreenEdgeConfigForm;
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;
KWinTouchScreenEdgeConfigForm *m_form;
KSharedConfigPtr m_config;
QStringList m_scripts; //list of script IDs ordered in the list they are presented in the menu
QHash<QString, KWinTouchScreenScriptSettings*> m_scriptSettings;
KWinTouchScreenSettings *m_settings;
enum EffectActions {
PresentWindowsAll = ELECTRIC_ACTION_COUNT, // Start at the end of built in actions
......@@ -74,20 +72,16 @@ private:
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<int> monitorCheckEffectHasEdge(int index) const;
static ElectricBorderAction electricBorderActionFromString(const QString &string);
static QString electricBorderActionToString(int action);
};
} // namespace
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>KWinScreenEdgesConfigForm</class>
<widget class="QWidget" name="KWinScreenEdgesConfigForm">
<class>KWinTouchScreenConfigUi</class>
<widget class="QWidget" name="KWinTouchScreenConfigUi">
<property name="geometry">
<rect>
<x>0</x>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment