2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2020-03-05 17:03:00 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2009 Lucas Murray <lmurray@undefinedfire.com>
|
|
|
|
SPDX-FileCopyrightText: 2020 Cyril Rossi <cyril.rossi@enioka.com>
|
2020-03-05 17:03:00 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2020-03-05 17:03:00 +00:00
|
|
|
|
|
|
|
#include "kwinscreenedgeconfigform.h"
|
|
|
|
#include "ui_main.h"
|
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
KWinScreenEdgesConfigForm::KWinScreenEdgesConfigForm(QWidget *parent)
|
|
|
|
: KWinScreenEdge(parent)
|
|
|
|
, ui(new Ui::KWinScreenEdgesConfigUI)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
|
2020-09-23 18:39:59 +00:00
|
|
|
connect(ui->kcfg_ElectricBorderDelay, qOverload<int>(&QSpinBox::valueChanged), this, &KWinScreenEdgesConfigForm::sanitizeCooldown);
|
2020-03-05 17:03:00 +00:00
|
|
|
|
|
|
|
// Visual feedback of action group conflicts
|
2020-09-23 18:39:59 +00:00
|
|
|
connect(ui->kcfg_ElectricBorders, qOverload<int>(&QComboBox::currentIndexChanged), this, &KWinScreenEdgesConfigForm::groupChanged);
|
|
|
|
connect(ui->kcfg_ElectricBorderMaximize, &QCheckBox::stateChanged, this, &KWinScreenEdgesConfigForm::groupChanged);
|
|
|
|
connect(ui->kcfg_ElectricBorderTiling, &QCheckBox::stateChanged, this, &KWinScreenEdgesConfigForm::groupChanged);
|
2020-03-05 17:03:00 +00:00
|
|
|
|
2020-09-23 18:39:59 +00:00
|
|
|
connect(ui->electricBorderCornerRatioSpin, qOverload<int>(&QSpinBox::valueChanged), this, &KWinScreenEdgesConfigForm::onChanged);
|
2020-08-04 08:11:27 +00:00
|
|
|
connect(ui->electricBorderCornerRatioSpin, qOverload<int>(&QSpinBox::valueChanged), this, &KWinScreenEdgesConfigForm::updateDefaultIndicators);
|
2020-03-05 17:03:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
KWinScreenEdgesConfigForm::~KWinScreenEdgesConfigForm()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinScreenEdgesConfigForm::setElectricBorderCornerRatio(double value)
|
|
|
|
{
|
|
|
|
m_referenceCornerRatio = value;
|
|
|
|
ui->electricBorderCornerRatioSpin->setValue(m_referenceCornerRatio * 100.);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinScreenEdgesConfigForm::setDefaultElectricBorderCornerRatio(double value)
|
|
|
|
{
|
|
|
|
m_defaultCornerRatio = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
double KWinScreenEdgesConfigForm::electricBorderCornerRatio() const
|
|
|
|
{
|
|
|
|
return ui->electricBorderCornerRatioSpin->value() / 100.;
|
|
|
|
}
|
|
|
|
|
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
2020-04-02 09:28:14 +00:00
|
|
|
void KWinScreenEdgesConfigForm::setElectricBorderCornerRatioEnabled(bool enable)
|
|
|
|
{
|
2020-08-04 08:11:27 +00:00
|
|
|
ui->electricBorderCornerRatioSpin->setEnabled(enable);
|
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
2020-04-02 09:28:14 +00:00
|
|
|
}
|
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
void KWinScreenEdgesConfigForm::reload()
|
|
|
|
{
|
|
|
|
ui->electricBorderCornerRatioSpin->setValue(m_referenceCornerRatio * 100.);
|
|
|
|
KWinScreenEdge::reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinScreenEdgesConfigForm::setDefaults()
|
|
|
|
{
|
|
|
|
ui->electricBorderCornerRatioSpin->setValue(m_defaultCornerRatio * 100.);
|
|
|
|
KWinScreenEdge::setDefaults();
|
|
|
|
}
|
|
|
|
|
2020-08-04 08:11:27 +00:00
|
|
|
void KWinScreenEdgesConfigForm::setDefaultsIndicatorsVisible(bool visible)
|
|
|
|
{
|
|
|
|
if (m_defaultIndicatorVisible != visible) {
|
|
|
|
m_defaultIndicatorVisible = visible;
|
|
|
|
updateDefaultIndicators();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
Monitor *KWinScreenEdgesConfigForm::monitor() const
|
|
|
|
{
|
|
|
|
return ui->monitor;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KWinScreenEdgesConfigForm::isSaveNeeded() const
|
|
|
|
{
|
|
|
|
return m_referenceCornerRatio != electricBorderCornerRatio();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool KWinScreenEdgesConfigForm::isDefault() const
|
|
|
|
{
|
|
|
|
return m_defaultCornerRatio == electricBorderCornerRatio();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinScreenEdgesConfigForm::sanitizeCooldown()
|
|
|
|
{
|
|
|
|
ui->kcfg_ElectricBorderCooldown->setMinimum(ui->kcfg_ElectricBorderDelay->value() + 50);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWinScreenEdgesConfigForm::groupChanged()
|
|
|
|
{
|
|
|
|
// Monitor conflicts
|
|
|
|
bool hide = false;
|
|
|
|
if (ui->kcfg_ElectricBorders->currentIndex() == 2) {
|
|
|
|
hide = true;
|
|
|
|
}
|
|
|
|
monitorHideEdge(ElectricTop, hide);
|
|
|
|
monitorHideEdge(ElectricRight, hide);
|
|
|
|
monitorHideEdge(ElectricBottom, hide);
|
|
|
|
monitorHideEdge(ElectricLeft, hide);
|
|
|
|
}
|
|
|
|
|
2020-08-04 08:11:27 +00:00
|
|
|
void KWinScreenEdgesConfigForm::updateDefaultIndicators()
|
|
|
|
{
|
|
|
|
ui->electricBorderCornerRatioSpin->setProperty("_kde_highlight_neutral", m_defaultIndicatorVisible && (electricBorderCornerRatio() != m_defaultCornerRatio));
|
|
|
|
ui->electricBorderCornerRatioSpin->update();
|
|
|
|
}
|
|
|
|
|
2020-03-05 17:03:00 +00:00
|
|
|
} // namespace
|