KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
/*
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Ismael Asensio <isma.af@gmail.com>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
|
|
|
*/
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
|
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Layouts 1.14
|
|
|
|
import QtQuick.Controls 2.14 as QQC2
|
|
|
|
|
|
|
|
import org.kde.kirigami 2.10 as Kirigami
|
|
|
|
import org.kde.kquickcontrols 2.0 as KQC
|
|
|
|
import org.kde.kcms.kwinrules 1.0
|
|
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: valueEditor
|
|
|
|
focus: true
|
|
|
|
|
|
|
|
property var ruleValue
|
|
|
|
property var ruleOptions
|
|
|
|
property int controlType
|
|
|
|
|
|
|
|
signal valueEdited(var value)
|
|
|
|
|
|
|
|
sourceComponent: {
|
|
|
|
switch (controlType) {
|
|
|
|
case RuleItem.Boolean: return booleanEditor
|
|
|
|
case RuleItem.String: return stringEditor
|
|
|
|
case RuleItem.Integer: return integerEditor
|
|
|
|
case RuleItem.Option: return optionEditor
|
2020-06-19 18:56:12 +00:00
|
|
|
case RuleItem.NetTypes: return netTypesEditor
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
case RuleItem.Percentage: return percentageEditor
|
[kcm/kwinrules] Fix size properties not being stored
Summary:
Use `QSize`/`QPoint` to handle and store coordinate values (size and position)
Previously, the rules model stored the "coordinate" type properties as a
`QString` with format `x, y`.
This fails when setting the properties to the config schema, as it requires
a proper `QPoint` or `QSize` value, specially the latter which can't be
convert from such a string.
BUG: 421055
FIXED-IN: 5.19.0
Test Plan:
- Add a new rule and set its position and size properties
- Hitting apply stores the right values in `~\.config\kwinrulesrc`
- Close the kcm and reopen, the values are loaded
- Property detection still works for size and position
Please note that there is a pre-existing bug of some position/sizes not being
applied to the windows in some cases, when using `Apply Initially`.
Better try using the `Force` policy.
Reviewers: ngraham, #kwin, #plasma, zzag
Reviewed By: #kwin, #plasma, zzag
Subscribers: zzag, ltoscano, yurchor, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D29764
2020-05-14 20:46:15 +00:00
|
|
|
case RuleItem.Point: return coordinateEditor
|
|
|
|
case RuleItem.Size: return coordinateEditor
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
case RuleItem.Shortcut: return shortcutEditor
|
|
|
|
default: return emptyEditor
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: emptyEditor
|
|
|
|
Item {}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: booleanEditor
|
|
|
|
RowLayout {
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
QQC2.RadioButton {
|
|
|
|
text: i18n("Yes")
|
|
|
|
checked: ruleValue
|
|
|
|
Layout.margins: Kirigami.Units.smallSpacing
|
|
|
|
onToggled: valueEditor.valueEdited(checked)
|
|
|
|
}
|
|
|
|
QQC2.RadioButton {
|
|
|
|
text: i18n("No")
|
|
|
|
checked: !ruleValue
|
|
|
|
Layout.margins: Kirigami.Units.smallSpacing
|
|
|
|
onToggled: valueEditor.valueEdited(!checked)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: stringEditor
|
|
|
|
QQC2.TextField {
|
|
|
|
property bool isTextEdited: false
|
|
|
|
text: ruleValue
|
|
|
|
horizontalAlignment: Text.AlignLeft
|
|
|
|
onTextEdited: { isTextEdited = true; }
|
|
|
|
onEditingFinished: {
|
|
|
|
if (isTextEdited) { valueEditor.valueEdited(text); }
|
|
|
|
isTextEdited = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: integerEditor
|
|
|
|
QQC2.SpinBox {
|
|
|
|
editable: true
|
|
|
|
value: ruleValue
|
|
|
|
onValueModified: valueEditor.valueEdited(value)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: optionEditor
|
|
|
|
OptionsComboBox {
|
|
|
|
flat: true
|
|
|
|
model: ruleOptions
|
|
|
|
onActivated: (index) => {
|
|
|
|
valueEditor.valueEdited(currentValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
2020-06-19 18:56:12 +00:00
|
|
|
id: netTypesEditor
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
OptionsComboBox {
|
|
|
|
flat: true
|
|
|
|
model: ruleOptions
|
|
|
|
multipleChoice: true
|
2020-06-24 17:38:30 +00:00
|
|
|
// Filter the provided value with the options mask
|
|
|
|
selectionMask: ruleValue & optionsMask
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
onActivated: {
|
|
|
|
valueEditor.valueEdited(selectionMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: percentageEditor
|
|
|
|
RowLayout {
|
|
|
|
QQC2.Slider {
|
|
|
|
id: slider
|
|
|
|
Layout.fillWidth: true
|
|
|
|
from: 0
|
|
|
|
to: 100
|
|
|
|
value: ruleValue
|
|
|
|
onMoved: valueEditor.valueEdited(Math.round(slider.value))
|
|
|
|
}
|
|
|
|
QQC2.Label {
|
|
|
|
text: i18n("%1 %", Math.round(slider.value))
|
|
|
|
horizontalAlignment: Qt.AlignRight
|
|
|
|
Layout.minimumWidth: maxPercentage.width + Kirigami.Units.smallSpacing
|
|
|
|
Layout.margins: Kirigami.Units.smallSpacing
|
|
|
|
}
|
|
|
|
TextMetrics {
|
|
|
|
id: maxPercentage
|
|
|
|
text: i18n("%1 %", 100)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: coordinateEditor
|
|
|
|
RowLayout {
|
|
|
|
id: coordItem
|
|
|
|
spacing: Kirigami.Units.smallSpacing
|
|
|
|
|
[kcm/kwinrules] Fix size properties not being stored
Summary:
Use `QSize`/`QPoint` to handle and store coordinate values (size and position)
Previously, the rules model stored the "coordinate" type properties as a
`QString` with format `x, y`.
This fails when setting the properties to the config schema, as it requires
a proper `QPoint` or `QSize` value, specially the latter which can't be
convert from such a string.
BUG: 421055
FIXED-IN: 5.19.0
Test Plan:
- Add a new rule and set its position and size properties
- Hitting apply stores the right values in `~\.config\kwinrulesrc`
- Close the kcm and reopen, the values are loaded
- Property detection still works for size and position
Please note that there is a pre-existing bug of some position/sizes not being
applied to the windows in some cases, when using `Apply Initially`.
Better try using the `Force` policy.
Reviewers: ngraham, #kwin, #plasma, zzag
Reviewed By: #kwin, #plasma, zzag
Subscribers: zzag, ltoscano, yurchor, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D29764
2020-05-14 20:46:15 +00:00
|
|
|
readonly property var coord: (controlType == RuleItem.Size) ? Qt.size(coordX.value, coordY.value)
|
|
|
|
: Qt.point(coordX.value, coordY.value)
|
|
|
|
onCoordChanged: valueEditor.valueEdited(coord)
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
|
|
|
|
QQC2.SpinBox {
|
|
|
|
id: coordX
|
|
|
|
editable: true
|
|
|
|
Layout.preferredWidth: 50 // 50%
|
|
|
|
Layout.fillWidth: true
|
|
|
|
from: 0
|
2020-05-22 13:50:35 +00:00
|
|
|
to: 32767
|
[kcm/kwinrules] Fix size properties not being stored
Summary:
Use `QSize`/`QPoint` to handle and store coordinate values (size and position)
Previously, the rules model stored the "coordinate" type properties as a
`QString` with format `x, y`.
This fails when setting the properties to the config schema, as it requires
a proper `QPoint` or `QSize` value, specially the latter which can't be
convert from such a string.
BUG: 421055
FIXED-IN: 5.19.0
Test Plan:
- Add a new rule and set its position and size properties
- Hitting apply stores the right values in `~\.config\kwinrulesrc`
- Close the kcm and reopen, the values are loaded
- Property detection still works for size and position
Please note that there is a pre-existing bug of some position/sizes not being
applied to the windows in some cases, when using `Apply Initially`.
Better try using the `Force` policy.
Reviewers: ngraham, #kwin, #plasma, zzag
Reviewed By: #kwin, #plasma, zzag
Subscribers: zzag, ltoscano, yurchor, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D29764
2020-05-14 20:46:15 +00:00
|
|
|
value: (controlType == RuleItem.Size) ? ruleValue.width : ruleValue.x
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
QQC2.Label {
|
|
|
|
id: coordSeparator
|
|
|
|
Layout.preferredWidth: implicitWidth
|
|
|
|
text: i18nc("(x, y) coordinates separator in size/position","x")
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
}
|
|
|
|
QQC2.SpinBox {
|
|
|
|
id: coordY
|
|
|
|
editable: true
|
|
|
|
from: 0
|
2020-05-22 13:50:35 +00:00
|
|
|
to: 32767
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
Layout.preferredWidth: 50 // 50%
|
|
|
|
Layout.fillWidth: true
|
[kcm/kwinrules] Fix size properties not being stored
Summary:
Use `QSize`/`QPoint` to handle and store coordinate values (size and position)
Previously, the rules model stored the "coordinate" type properties as a
`QString` with format `x, y`.
This fails when setting the properties to the config schema, as it requires
a proper `QPoint` or `QSize` value, specially the latter which can't be
convert from such a string.
BUG: 421055
FIXED-IN: 5.19.0
Test Plan:
- Add a new rule and set its position and size properties
- Hitting apply stores the right values in `~\.config\kwinrulesrc`
- Close the kcm and reopen, the values are loaded
- Property detection still works for size and position
Please note that there is a pre-existing bug of some position/sizes not being
applied to the windows in some cases, when using `Apply Initially`.
Better try using the `Force` policy.
Reviewers: ngraham, #kwin, #plasma, zzag
Reviewed By: #kwin, #plasma, zzag
Subscribers: zzag, ltoscano, yurchor, kwin
Tags: #kwin
Differential Revision: https://phabricator.kde.org/D29764
2020-05-14 20:46:15 +00:00
|
|
|
value: (controlType == RuleItem.Size) ? ruleValue.height : ruleValue.y
|
KWinRules KCM Redesign
Summary:
Replacement KCM to configure kwin rules, using a QML-based UI.
After some work on the task T12729, it is almost feature-par with the previous module, and adapted to the recent move to KConfigXT.
Test Plan:
{F8208046}
{F8208047}
Reviewers: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Reviewed By: #plasma, #kwin, #vdg, ngraham, davidedmundson, zzag
Subscribers: ngraham, davidedmundson, hchain, broulik, zzag, kwin
Tags: #kwin, #vdg
Differential Revision: https://phabricator.kde.org/D28152
2020-04-20 20:01:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: shortcutEditor
|
|
|
|
RowLayout {
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
KQC.KeySequenceItem {
|
|
|
|
keySequence: ruleValue
|
|
|
|
onCaptureFinished: valueEditor.valueEdited(keySequence)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|