Commit a9c03371 authored by Cyril Rossi's avatar Cyril Rossi

KCM KWinTouchEdges disable edge if is immutable

Summary:
Disable touch screen edge modification, but allow the user to open an edge context menu and see the settings.

To set an edge immutable, just add `[$i]` right after the entry in `TouchEdges` group, although the edges settings are shared between some `[Effect-something]` group under the key `TouchBorderActivateSomething`.

Since one entry like `TouchBorderActivateSomething` lists all edges that use this effect, it doesn't make sense to set it immutable.

Test Plan:
In `kwinrc`, set the `TouchEdges` group immutable or any entry.

```
[TouchEdges]
Bottom=None
Left=None
Right=None
Top[$i]=None
```

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

Reviewed By: ervin, zzag, #kwin, mart

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D28507
parent 128eb13c
......@@ -42,6 +42,12 @@ void KWinScreenEdge::monitorHideEdge(ElectricBorder border, bool hidden)
monitor()->setEdgeHidden(edge, hidden);
}
void KWinScreenEdge::monitorEnableEdge(ElectricBorder border, bool enabled)
{
const int edge = KWinScreenEdge::electricBorderToMonitorEdge(border);
monitor()->setEdgeEnabled(edge, enabled);
}
void KWinScreenEdge::monitorAddItem(const QString &item)
{
for (int i = 0; i < 8; i++) {
......
......@@ -40,6 +40,7 @@ public:
~KWinScreenEdge() override;
void monitorHideEdge(ElectricBorder border, bool hidden);
void monitorEnableEdge(ElectricBorder border, bool enabled);
void monitorAddItem(const QString &item);
void monitorItemSetEnabled(int index, bool enabled);
......
......@@ -138,6 +138,13 @@ bool Monitor::edge(int edge) const
return items[ edge ]->brush() == Qt::green;
}
void Monitor::setEdgeEnabled(int edge, bool enabled)
{
for (QAction *action : qAsConst(popup_actions[edge])) {
action->setEnabled(enabled);
}
}
void Monitor::setEdgeHidden(int edge, bool set)
{
hidden[ edge ] = set;
......
......@@ -49,6 +49,7 @@ public:
explicit Monitor(QWidget* parent);
void setEdge(int edge, bool set);
bool edge(int edge) const;
void setEdgeEnabled(int edge, bool enabled);
void setEdgeHidden(int edge, bool set);
bool edgeHidden(int edge) const;
void clear();
......
......@@ -299,6 +299,12 @@ void KWinScreenEdgesConfig::monitorShowEvent()
bool reasonable = focusPolicy != "FocusStrictlyUnderMouse" && focusPolicy != "FocusUnderMouse";
m_form->monitorItemSetEnabled(TabBox, reasonable);
m_form->monitorItemSetEnabled(TabBoxAlternative, reasonable);
// Disable Edge if TouchEdges group entries are immutable
m_form->monitorEnableEdge(ElectricTop, !m_settings->isTopImmutable());
m_form->monitorEnableEdge(ElectricRight, !m_settings->isRightImmutable());
m_form->monitorEnableEdge(ElectricBottom, !m_settings->isBottomImmutable());
m_form->monitorEnableEdge(ElectricLeft, !m_settings->isLeftImmutable());
}
ElectricBorderAction KWinScreenEdgesConfig::electricBorderActionFromString(const QString &string)
......
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