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
icc-effect-master
Cyril Rossi 2020-04-02 11:28:14 +02:00
parent a9c0337113
commit cf7762eaa8
3 changed files with 20 additions and 0 deletions

View File

@ -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.);

View File

@ -47,6 +47,8 @@ public:
// return value between 0. and 1.
double electricBorderCornerRatio() const;
void setElectricBorderCornerRatioEnabled(bool enable);
void reload() override;
void setDefaults() override;

View File

@ -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)