[kwinrules] Allow negative numbers in position

This was limited by the range of the edition spinbox, not by the
rules mechanism which already allowed it.

BUG: 428083
This commit is contained in:
Ismael Asensio 2020-10-22 14:35:14 +02:00
parent 0ad4901687
commit 3d80665c0a
2 changed files with 12 additions and 9 deletions

View file

@ -142,8 +142,9 @@ Loader {
id: coordItem
spacing: Kirigami.Units.smallSpacing
readonly property var coord: (controlType == RuleItem.Size) ? Qt.size(coordX.value, coordY.value)
: Qt.point(coordX.value, coordY.value)
readonly property bool isSize: controlType == RuleItem.Size
readonly property var coord: (isSize) ? Qt.size(coordX.value, coordY.value)
: Qt.point(coordX.value, coordY.value)
onCoordChanged: valueEditor.valueEdited(coord)
QQC2.SpinBox {
@ -151,9 +152,9 @@ Loader {
editable: true
Layout.preferredWidth: 50 // 50%
Layout.fillWidth: true
from: 0
from: (isSize) ? 0 : -32767
to: 32767
value: (controlType == RuleItem.Size) ? ruleValue.width : ruleValue.x
value: (isSize) ? ruleValue.width : ruleValue.x
}
QQC2.Label {
id: coordSeparator
@ -164,11 +165,11 @@ Loader {
QQC2.SpinBox {
id: coordY
editable: true
from: 0
to: 32767
from: coordX.from
to: coordX.to
Layout.preferredWidth: 50 // 50%
Layout.fillWidth: true
value: (controlType == RuleItem.Size) ? ruleValue.height : ruleValue.y
value: (isSize) ? ruleValue.height : ruleValue.y
}
}
}

View file

@ -208,8 +208,10 @@ QVariant RuleItem::typedValue(const QVariant &value) const
}
return typesMask;
}
case Point:
return value.toPoint();
case Point: {
const QPoint point = value.toPoint();
return (point == invalidPoint) ? QPoint(0, 0) : point;
}
case Size:
return value.toSize();
case String: