From cf7762eaa874163944d298feb0cfd4dcb44a1b22 Mon Sep 17 00:00:00 2001 From: Cyril Rossi Date: Thu, 2 Apr 2020 11:28:14 +0200 Subject: [PATCH] KCM KWinScreenEdges disable widgets if is immutable Summary: Same as D28507 Disable 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 `ElectricBorders` group, although the edges settings are shared between some `[Effect-something]` group under the key `BorderActivateSomething`. Since one entry like `BorderActivateSomething` lists all edges that use this effect, it doesn't make sense to set it immutable. Test Plan: In `kwinrc`, set the `ElectricBorders` and/or `Windows` group immutable or any entry. ``` [ElectricBorders] BottomLeft[$i]=None Left=None Right=None Top[$i]=None [Windows][$i] ElectricBorderCornerRatio=0.29 ElectricBorderDelay=300 ElectricBorderMaximize=false ElectricBorderTiling=true ElectricBorders=2 ``` Reviewers: ervin, bport, meven, zzag, #kwin, mart Reviewed By: ervin, zzag, #kwin, mart Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D28508 --- .../kwinscreenedges/kwinscreenedgeconfigform.cpp | 5 +++++ kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.h | 2 ++ kcmkwin/kwinscreenedges/main.cpp | 13 +++++++++++++ 3 files changed, 20 insertions(+) diff --git a/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.cpp b/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.cpp index f5ca68d545..86e465d207 100644 --- a/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.cpp +++ b/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.cpp @@ -62,6 +62,11 @@ double KWinScreenEdgesConfigForm::electricBorderCornerRatio() const return ui->electricBorderCornerRatioSpin->value() / 100.; } +void KWinScreenEdgesConfigForm::setElectricBorderCornerRatioEnabled(bool enable) +{ + return ui->electricBorderCornerRatioSpin->setEnabled(enable); +} + void KWinScreenEdgesConfigForm::reload() { ui->electricBorderCornerRatioSpin->setValue(m_referenceCornerRatio * 100.); diff --git a/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.h b/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.h index 5ee85337ee..b8fcbede5c 100644 --- a/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.h +++ b/kcmkwin/kwinscreenedges/kwinscreenedgeconfigform.h @@ -47,6 +47,8 @@ public: // return value between 0. and 1. double electricBorderCornerRatio() const; + void setElectricBorderCornerRatioEnabled(bool enable); + void reload() override; void setDefaults() override; diff --git a/kcmkwin/kwinscreenedges/main.cpp b/kcmkwin/kwinscreenedges/main.cpp index 141405e90e..d0ea594a1a 100644 --- a/kcmkwin/kwinscreenedges/main.cpp +++ b/kcmkwin/kwinscreenedges/main.cpp @@ -315,6 +315,19 @@ void KWinScreenEdgesConfig::monitorShowEvent() bool reasonable = focusPolicy != "FocusStrictlyUnderMouse" && focusPolicy != "FocusUnderMouse"; m_form->monitorItemSetEnabled(TabBox, reasonable); m_form->monitorItemSetEnabled(TabBoxAlternative, reasonable); + + // Disable Edge if ElectricBorders group entries are immutable + m_form->monitorEnableEdge(ElectricTop, !m_settings->isTopImmutable()); + m_form->monitorEnableEdge(ElectricTopRight, !m_settings->isTopRightImmutable()); + m_form->monitorEnableEdge(ElectricRight, !m_settings->isRightImmutable()); + m_form->monitorEnableEdge(ElectricBottomRight, !m_settings->isBottomRightImmutable()); + m_form->monitorEnableEdge(ElectricBottom, !m_settings->isBottomImmutable()); + m_form->monitorEnableEdge(ElectricBottomLeft, !m_settings->isBottomLeftImmutable()); + m_form->monitorEnableEdge(ElectricLeft, !m_settings->isLeftImmutable()); + m_form->monitorEnableEdge(ElectricTopLeft, !m_settings->isTopLeftImmutable()); + + // Disable ElectricBorderCornerRatio if entry is immutable + m_form->setElectricBorderCornerRatioEnabled(!m_settings->isElectricBorderCornerRatioImmutable()); } ElectricBorderAction KWinScreenEdgesConfig::electricBorderActionFromString(const QString &string)