summaryrefslogtreecommitdiff
path: root/tests/manual/testbench
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-03-02 09:00:03 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-02 09:17:56 +0100
commitd8df1613b61e9b3309fb5b02763bd2f46b430f27 (patch)
tree290078ae380c53727a5b014a938ef6888e422f1c /tests/manual/testbench
parent8ef3923e9233c2d87a27dd83c1290aa1f6c18db7 (diff)
downloadqtquickcontrols-d8df1613b61e9b3309fb5b02763bd2f46b430f27.tar.gz
Improve resize behavior in testbench
- I now update width and height properties dynamically - I automatically reset the size when properties are changed Change-Id: I7edf717e52cd746f9921a8027c43617b54117a0f Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'tests/manual/testbench')
-rw-r--r--tests/manual/testbench/content/PropertyLayouts.qml46
-rw-r--r--tests/manual/testbench/main.qml27
2 files changed, 61 insertions, 12 deletions
diff --git a/tests/manual/testbench/content/PropertyLayouts.qml b/tests/manual/testbench/content/PropertyLayouts.qml
index 768c02fb..7a105978 100644
--- a/tests/manual/testbench/content/PropertyLayouts.qml
+++ b/tests/manual/testbench/content/PropertyLayouts.qml
@@ -45,7 +45,12 @@ QtObject {
property Component boolLayout: CheckBox {
checked: visible ? (result == "true") : false
text: name
- onCheckedChanged: loader.item[name] = checked
+ onCheckedChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = checked
+ propertyChanged()
+ }
+ }
}
property Component intLayout: RowLayout {
@@ -59,7 +64,12 @@ QtObject {
maximumValue: 9999
minimumValue: -9999
Layout.horizontalSizePolicy: Layout.Expanding
- onValueChanged: loader.item[name] = value
+ onValueChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = value
+ propertyChanged()
+ }
+ }
}
}
@@ -70,13 +80,27 @@ QtObject {
Layout.minimumWidth: 100
}
SpinBox {
+ id: spinbox
value: result
decimals: 1
stepSize: 0.5
maximumValue: 9999
minimumValue: -9999
Layout.horizontalSizePolicy: Layout.Expanding
- onValueChanged: loader.item[name] = value
+ onValueChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = value
+ if (name != "width" && name != "height") // We dont want to reset size when size changes
+ propertyChanged()
+ }
+ }
+
+ Component.onCompleted: {
+ if (name == "width")
+ widthControl = spinbox
+ else if (name == "height")
+ heightControl = spinbox
+ }
}
}
@@ -89,8 +113,13 @@ QtObject {
TextField {
id: tf
text: result
- onTextChanged: loader.item[name] = tf.text
Layout.horizontalSizePolicy: Layout.Expanding
+ onTextChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = tf.text
+ propertyChanged()
+ }
+ }
}
}
@@ -104,8 +133,8 @@ QtObject {
Text {
height: 20
anchors.right: parent.right
- text: loader.item[name] ? loader.item[name] : ""
Layout.horizontalSizePolicy: Layout.Expanding
+ text: loader.item[name] ? loader.item[name] : ""
}
}
@@ -122,7 +151,12 @@ QtObject {
height: 20
model: enumModel
Layout.horizontalSizePolicy: Layout.Expanding
- onSelectedIndexChanged: loader.item[name] = model.get(selectedIndex).value
+ onSelectedIndexChanged: {
+ if (!ignoreUpdate) {
+ loader.item[name] = model.get(selectedIndex).value
+ propertyChanged()
+ }
+ }
Component.onCompleted: selectedIndex = getDefaultIndex()
diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml
index ecfa64f0..c4195961 100644
--- a/tests/manual/testbench/main.qml
+++ b/tests/manual/testbench/main.qml
@@ -46,7 +46,15 @@ ApplicationWindow {
width: 950
height: 600
+ signal propertyChanged
+ property bool ignoreUpdate: false
+ onPropertyChanged: container.resetSize()
+
property var propertyMap: []
+
+ property SpinBox widthControl
+ property SpinBox heightControl
+
Components{ id: components }
SystemPalette { id: syspal }
@@ -67,11 +75,6 @@ ApplicationWindow {
checked: true
text: "Background"
}
- ToolButton {
- id: resetButton
- text: "Reset size"
- onClicked: container.resetSize()
- }
}
CheckBox {
@@ -129,6 +132,18 @@ ApplicationWindow {
bottomRightHandle.y = topLeftHandle.y + loader.item.implicitHeight;
}
+ function updateSize() {
+ ignoreUpdate = true
+ if (widthControl)
+ widthControl.value = loader.item.width
+ if (heightControl)
+ heightControl.value = loader.item.height
+ ignoreUpdate = false
+ }
+
+ onHeightChanged: updateSize()
+ onWidthChanged: updateSize()
+
y: Math.floor(topLeftHandle.y + topLeftHandle.height - topLeftHandle.width/2)
x: Math.floor(topLeftHandle.x + topLeftHandle.width - topLeftHandle.height/2)
width: Math.floor(bottomRightHandle.x - topLeftHandle.x )
@@ -370,7 +385,7 @@ ApplicationWindow {
Rectangle {
id: sidebar
color : syspal.window
- width: 300
+ width: 200
ScrollView {
id: scrollView
anchors.fill: parent