diff options
author | Mitch Curtis <mitch.curtis@theqtcompany.com> | 2016-04-12 16:19:58 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-04-15 14:45:47 +0000 |
commit | eae24fccc57437170e2ba01b894fa24fe65292be (patch) | |
tree | dfbd1450c237df8c2cd08838d2f054ef029ceea8 /tests | |
parent | 0fe0283308199a6bf4a155627cddd524638c7063 (diff) |
Add QQuickAbstractButton::down
This property will determine whether or not the button is visually
pressed. Having such a distinction allows users more control over their
controls.
The patch also fixes the problem with ComboBox where pressing on the
ComboBox when it's open would cause a delegate in the popup to show as
being pressed.
Unless explicitly set, this property follows the value of the pressed
property. To return to the default value, set it to undefined.
Change-Id: I29ecf325ed2ede125613f0c878b0427937599866
Task-number: QTBUG-51005
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/controls/data/tst_button.qml | 23 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_combobox.qml | 2 | ||||
-rw-r--r-- | tests/auto/controls/data/tst_toolbutton.qml | 24 | ||||
-rw-r--r-- | tests/manual/testbench/main.qml | 26 |
4 files changed, 57 insertions, 18 deletions
diff --git a/tests/auto/controls/data/tst_button.qml b/tests/auto/controls/data/tst_button.qml index 06038994..4831bdd6 100644 --- a/tests/auto/controls/data/tst_button.qml +++ b/tests/auto/controls/data/tst_button.qml @@ -57,7 +57,7 @@ TestCase { property SignalSequenceSpy spy: SignalSequenceSpy { target: control - signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "checkedChanged"] + signals: ["pressed", "released", "canceled", "clicked", "doubleClicked", "pressedChanged", "downChanged", "checkedChanged"] } } } @@ -80,12 +80,15 @@ TestCase { verify(control) // click - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"] + control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + ["downChanged", { "down": true }], + "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) verify(control.spy.success) control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], + ["downChanged", { "down": false }], "released", "clicked"] mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) @@ -93,12 +96,15 @@ TestCase { verify(control.spy.success) // release outside - control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"] + control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + ["downChanged", { "down": true }], + "pressed"] mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(control.pressed, true) verify(control.spy.success) - control.spy.expectedSequence = [["pressedChanged", { "pressed": false }]] + control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], + ["downChanged", { "down": false }]] mouseMove(control, control.width * 2, control.height * 2, 0, Qt.LeftButton) compare(control.pressed, false) verify(control.spy.success) @@ -119,14 +125,18 @@ TestCase { // double click control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + ["downChanged", { "down": true }], "pressed", ["pressedChanged", { "pressed": false }], + ["downChanged", { "down": false }], "released", "clicked", ["pressedChanged", { "pressed": true }], + ["downChanged", { "down": true }], "pressed", "doubleClicked", ["pressedChanged", { "pressed": false }], + ["downChanged", { "down": false }], "released", "clicked"] mouseDoubleClickSequence(control, control.width / 2, control.height / 2, Qt.LeftButton) @@ -144,8 +154,10 @@ TestCase { // click control.spy.expectedSequence = [["pressedChanged", { "pressed": true }], + ["downChanged", { "down": true }], "pressed", ["pressedChanged", { "pressed": false }], + ["downChanged", { "down": false }], "released", "clicked"] keyClick(Qt.Key_Space) @@ -185,6 +197,7 @@ TestCase { var repeatCount = 2 var repeatSequence = [["pressedChanged", { "pressed": true }], + ["downChanged", { "down": true }], "pressed", "released", "clicked", @@ -201,6 +214,7 @@ TestCase { verify(control.spy.success) control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], + ["downChanged", { "down": false }], "released", "clicked"] mouseRelease(control) @@ -216,6 +230,7 @@ TestCase { verify(control.spy.success) control.spy.expectedSequence = [["pressedChanged", { "pressed": false }], + ["downChanged", { "down": false }], "released", "clicked"] keyRelease(Qt.Key_Space) diff --git a/tests/auto/controls/data/tst_combobox.qml b/tests/auto/controls/data/tst_combobox.qml index 24df675e..6af82dc5 100644 --- a/tests/auto/controls/data/tst_combobox.qml +++ b/tests/auto/controls/data/tst_combobox.qml @@ -644,7 +644,7 @@ TestCase { autoExclusive: true checked: _combobox.currentIndex === index highlighted: _combobox.highlightedIndex === index - pressed: highlighted && _combobox.pressed + down: highlighted && _combobox.pressed } } } diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml index 6c03f18c..ddabb0fc 100644 --- a/tests/auto/controls/data/tst_toolbutton.qml +++ b/tests/auto/controls/data/tst_toolbutton.qml @@ -56,6 +56,11 @@ TestCase { } SignalSpy { + id: downSpy + signalName: "downChanged" + } + + SignalSpy { id: clickedSpy signalName: "clicked" } @@ -97,47 +102,66 @@ TestCase { verify(control) pressedSpy.target = control + downSpy.target = control clickedSpy.target = control verify(pressedSpy.valid) + verify(downSpy.valid) verify(clickedSpy.valid) // check mousePress(control, control.width / 2, control.height / 2, Qt.LeftToolButton) compare(pressedSpy.count, 1) + compare(downSpy.count, 1) compare(control.pressed, true) + compare(control.down, true) mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftToolButton) compare(clickedSpy.count, 1) compare(pressedSpy.count, 2) + compare(downSpy.count, 2) compare(control.pressed, false) + compare(control.down, false) // uncheck mousePress(control, control.width / 2, control.height / 2, Qt.LeftToolButton) compare(pressedSpy.count, 3) + compare(downSpy.count, 3) compare(control.pressed, true) + compare(control.down, true) mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftToolButton) compare(clickedSpy.count, 2) compare(pressedSpy.count, 4) + compare(downSpy.count, 4) compare(control.pressed, false) + compare(control.down, false) // release outside mousePress(control, control.width / 2, control.height / 2, Qt.LeftToolButton) compare(pressedSpy.count, 5) + compare(downSpy.count, 5) compare(control.pressed, true) + compare(control.down, true) mouseMove(control, control.width * 2, control.height * 2, 0, Qt.LeftToolButton) compare(control.pressed, false) + compare(control.down, false) mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftToolButton) compare(clickedSpy.count, 2) compare(pressedSpy.count, 6) + compare(downSpy.count, 6) compare(control.pressed, false) + compare(control.down, false) // right button mousePress(control, control.width / 2, control.height / 2, Qt.RightButton) compare(pressedSpy.count, 6) + compare(downSpy.count, 6) compare(control.pressed, false) + compare(control.down, false) mouseRelease(control, control.width / 2, control.height / 2, Qt.RightButton) compare(clickedSpy.count, 2) compare(pressedSpy.count, 6) + compare(downSpy.count, 6) compare(control.pressed, false) + compare(control.down, false) control.destroy() } diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml index 76d945ba..8d0fe7a7 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/main.qml @@ -96,7 +96,7 @@ ApplicationWindow { } ToolButton { text: "Pressed" - pressed: true + down: true hoverEnabled: true ToolTip.text: text ToolTip.delay: 1000 @@ -141,7 +141,7 @@ ApplicationWindow { } TabButton { text: "Pressed" - pressed: true + down: true } TabButton { text: "Disabled" @@ -169,7 +169,7 @@ ApplicationWindow { } Button { text: "Pressed" - pressed: true + down: true } Button { text: "Checked" @@ -178,7 +178,7 @@ ApplicationWindow { Button { text: "CH + PR" checked: true - pressed: true + down: true } Button { text: "Disabled" @@ -201,7 +201,7 @@ ApplicationWindow { Button { text: "HI + PR" highlighted: true - pressed: true + down: true } Button { text: "HI + CH" @@ -211,7 +211,7 @@ ApplicationWindow { Button { text: "HI+CH+PR" highlighted: true - pressed: true + down: true checked: true } Button { @@ -233,7 +233,7 @@ ApplicationWindow { } CheckBox { text: "Pressed" - pressed: true + down: true } CheckBox { text: "Checked" @@ -242,7 +242,7 @@ ApplicationWindow { CheckBox { text: "CH + PR" checked: true - pressed: true + down: true } CheckBox { text: "Disabled" @@ -261,7 +261,7 @@ ApplicationWindow { } RadioButton { text: "Pressed" - pressed: true + down: true } RadioButton { text: "Checked" @@ -270,7 +270,7 @@ ApplicationWindow { RadioButton { text: "CH + PR" checked: true - pressed: true + down: true } RadioButton { text: "Disabled" @@ -289,7 +289,7 @@ ApplicationWindow { } Switch { text: "Pressed" - pressed: true + down: true } Switch { text: "Checked" @@ -298,7 +298,7 @@ ApplicationWindow { Switch { text: "CH + PR" checked: true - pressed: true + down: true } Switch { text: "Disabled" @@ -452,7 +452,7 @@ ApplicationWindow { implicitHeight: normalComboBox.implicitHeight ComboBox { - pressed: true + down: true model: ListModel { ListElement { text: "Pressed" } } |