aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <[email protected]>2021-11-19 10:53:16 +0100
committerMitch Curtis <[email protected]>2021-11-26 21:23:08 +0100
commit3bb8ef28a73a1469c1bbc4384d134deb466a4030 (patch)
tree838e3fa644d9e91302d8ac89c0275be231175e5f
parent5d656b31eb371c9e0bb97c558f9193b08471f1d7 (diff)
SpinBox: use control instead of parent in indicators
This avoids errors when users give an id to a customized indicator. Fixes: QTBUG-97782 Pick-to: 6.2 Change-Id: I3af8139abf992152f27826dd34d499608c6558b9 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Mitch Curtis <[email protected]>
-rw-r--r--src/quickcontrols2/basic/SpinBox.qml6
-rw-r--r--src/quickcontrols2/fusion/SpinBox.qml10
-rw-r--r--src/quickcontrols2/imagine/SpinBox.qml8
-rw-r--r--src/quickcontrols2/material/SpinBox.qml8
-rw-r--r--src/quickcontrols2/universal/SpinBox.qml8
-rw-r--r--tests/auto/quickcontrols2/controls/data/tst_spinbox.qml25
6 files changed, 45 insertions, 20 deletions
diff --git a/src/quickcontrols2/basic/SpinBox.qml b/src/quickcontrols2/basic/SpinBox.qml
index 772cc583dc..f992e7c9ba 100644
--- a/src/quickcontrols2/basic/SpinBox.qml
+++ b/src/quickcontrols2/basic/SpinBox.qml
@@ -88,8 +88,8 @@ T.SpinBox {
}
up.indicator: Rectangle {
- x: control.mirrored ? 0 : parent.width - width
- height: parent.height
+ x: control.mirrored ? 0 : control.width - width
+ height: control.height
implicitWidth: 40
implicitHeight: 40
color: control.up.pressed ? control.palette.mid : control.palette.button
@@ -112,7 +112,7 @@ T.SpinBox {
down.indicator: Rectangle {
x: control.mirrored ? parent.width - width : 0
- height: parent.height
+ height: control.height
implicitWidth: 40
implicitHeight: 40
color: control.down.pressed ? control.palette.mid : control.palette.button
diff --git a/src/quickcontrols2/fusion/SpinBox.qml b/src/quickcontrols2/fusion/SpinBox.qml
index e71aa42895..4ed18f39d6 100644
--- a/src/quickcontrols2/fusion/SpinBox.qml
+++ b/src/quickcontrols2/fusion/SpinBox.qml
@@ -79,9 +79,9 @@ T.SpinBox {
}
up.indicator: PaddedRectangle {
- x: control.mirrored ? 1 : parent.width - width - 1
+ x: control.mirrored ? 1 : control.width - width - 1
y: 1
- height: parent.height / 2 - 1
+ height: control.height / 2 - 1
implicitWidth: 16
implicitHeight: 10
@@ -103,9 +103,9 @@ T.SpinBox {
}
down.indicator: PaddedRectangle {
- x: control.mirrored ? 1 : parent.width - width - 1
- y: parent.height - height - 1
- height: parent.height / 2 - 1
+ x: control.mirrored ? 1 : control.width - width - 1
+ y: control.height - height - 1
+ height: control.height / 2 - 1
implicitWidth: 16
implicitHeight: 10
diff --git a/src/quickcontrols2/imagine/SpinBox.qml b/src/quickcontrols2/imagine/SpinBox.qml
index 6d1bdababb..0ed9d451f7 100644
--- a/src/quickcontrols2/imagine/SpinBox.qml
+++ b/src/quickcontrols2/imagine/SpinBox.qml
@@ -102,8 +102,8 @@ T.SpinBox {
}
up.indicator: NinePatchImage {
- x: control.mirrored ? 0 : parent.width - width
- height: parent.height
+ x: control.mirrored ? 0 : control.width - width
+ height: control.height
source: Imagine.url + "spinbox-indicator"
NinePatchImageSelector on source {
@@ -120,8 +120,8 @@ T.SpinBox {
}
down.indicator: NinePatchImage {
- x: control.mirrored ? parent.width - width : 0
- height: parent.height
+ x: control.mirrored ? control.width - width : 0
+ height: control.height
source: Imagine.url + "spinbox-indicator"
NinePatchImageSelector on source {
diff --git a/src/quickcontrols2/material/SpinBox.qml b/src/quickcontrols2/material/SpinBox.qml
index 4f69dd2512..9ea6fd9260 100644
--- a/src/quickcontrols2/material/SpinBox.qml
+++ b/src/quickcontrols2/material/SpinBox.qml
@@ -81,10 +81,10 @@ T.SpinBox {
}
up.indicator: Item {
- x: control.mirrored ? 0 : parent.width - width
+ x: control.mirrored ? 0 : control.width - width
implicitWidth: control.Material.touchTarget
implicitHeight: control.Material.touchTarget
- height: parent.height
+ height: control.height
width: height
Ripple {
@@ -115,10 +115,10 @@ T.SpinBox {
}
down.indicator: Item {
- x: control.mirrored ? parent.width - width : 0
+ x: control.mirrored ? control.width - width : 0
implicitWidth: control.Material.touchTarget
implicitHeight: control.Material.touchTarget
- height: parent.height
+ height: control.height
width: height
Ripple {
diff --git a/src/quickcontrols2/universal/SpinBox.qml b/src/quickcontrols2/universal/SpinBox.qml
index 10c12589de..0bb5e4b19b 100644
--- a/src/quickcontrols2/universal/SpinBox.qml
+++ b/src/quickcontrols2/universal/SpinBox.qml
@@ -84,9 +84,9 @@ T.SpinBox {
up.indicator: Item {
implicitWidth: 28
- height: parent.height + 4
+ height: control.height + 4
y: -2
- x: control.mirrored ? 0 : parent.width - width
+ x: control.mirrored ? 0 : control.width - width
Rectangle {
x: 2; y: 4
@@ -110,9 +110,9 @@ T.SpinBox {
down.indicator: Item {
implicitWidth: 28
- height: parent.height + 4
+ height: control.height + 4
y: -2
- x: control.mirrored ? parent.width - width : 0
+ x: control.mirrored ? control.width - width : 0
Rectangle {
x: 2; y: 4
diff --git a/tests/auto/quickcontrols2/controls/data/tst_spinbox.qml b/tests/auto/quickcontrols2/controls/data/tst_spinbox.qml
index 6220a857b3..a3d6b265e7 100644
--- a/tests/auto/quickcontrols2/controls/data/tst_spinbox.qml
+++ b/tests/auto/quickcontrols2/controls/data/tst_spinbox.qml
@@ -688,6 +688,31 @@ TestCase {
compare(control.up.indicator.s, "this is the one");
}
+ Component {
+ id: overriddenSpinBoxWithIds
+ SpinBox {
+ value: 50
+ up.indicator: Rectangle {
+ id: uhOh1
+ property string s: "up"
+ }
+ down.indicator: Rectangle {
+ id: uhOh2
+ property string s: "down"
+ }
+ }
+ }
+
+ function test_indicatorOverriddenWithIds() {
+ var control = createTemporaryObject(overriddenSpinBoxWithIds, testCase)
+ verify(control)
+ // TODO: Use failOnWarning() here when it has been implemented
+ // Specifying an id will result in both the default indicator implementations
+ // and the custom ones being created, but it shouldn't result in any TypeErrors.
+ compare(control.up.indicator.s, "up");
+ compare(control.down.indicator.s, "down");
+ }
+
function test_valueEnterFromOutsideRange() {
// Check that changing from 2 to 99 goes to 98 then changing to 99 puts it back to 98
var control = createTemporaryObject(spinBox, testCase, {from: 2, to: 98, value: 2, editable: true})