summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-11 21:44:47 +0200
committerJ-P Nurmi <jpnurmi@theqtcompany.com>2016-04-12 09:07:57 +0000
commit571f4be253386cb30a55060bed7d81ef356124eb (patch)
tree4b1b3638ad3886ad7c92d38c1a03d62e31435cc3
parent8615db11a61178c5be5c2ef9e373ad0d245888d6 (diff)
QQuickAbstractButton: fix the order of nextCheckState() vs. clicked()
Task-number: QTBUG-52448 Change-Id: I4ee2c16f3dccc61e07268f9e8ced530a06d2adf3 Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
-rw-r--r--src/templates/qquickabstractbutton.cpp8
-rw-r--r--tests/auto/controls/data/tst_checkbox.qml56
-rw-r--r--tests/auto/controls/data/tst_radiobutton.qml8
3 files changed, 36 insertions, 36 deletions
diff --git a/src/templates/qquickabstractbutton.cpp b/src/templates/qquickabstractbutton.cpp
index 44fa30b1..071b4964 100644
--- a/src/templates/qquickabstractbutton.cpp
+++ b/src/templates/qquickabstractbutton.cpp
@@ -478,9 +478,9 @@ void QQuickAbstractButton::keyReleaseEvent(QKeyEvent *event)
if (event->key() == Qt::Key_Space) {
setPressed(false);
+ nextCheckState();
emit released();
emit clicked();
- nextCheckState();
if (d->autoRepeat)
d->stopPressRepeat();
@@ -525,6 +525,9 @@ void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event)
bool wasPressed = d->pressed;
setPressed(false);
+ if (contains(event->pos()))
+ nextCheckState();
+
if (wasPressed) {
emit released();
if (!d->wasHeld)
@@ -533,9 +536,6 @@ void QQuickAbstractButton::mouseReleaseEvent(QMouseEvent *event)
emit canceled();
}
- if (contains(event->pos()))
- nextCheckState();
-
if (d->autoRepeat)
d->stopPressRepeat();
else
diff --git a/tests/auto/controls/data/tst_checkbox.qml b/tests/auto/controls/data/tst_checkbox.qml
index 7e0c88e4..6b3718e2 100644
--- a/tests/auto/controls/data/tst_checkbox.qml
+++ b/tests/auto/controls/data/tst_checkbox.qml
@@ -139,10 +139,10 @@ TestCase {
verify(control.spy.success)
control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
- ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }]]
+ ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
+ "released",
+ "clicked"]
mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(control.checked, true)
compare(control.checkState, Qt.Checked)
@@ -156,10 +156,10 @@ TestCase {
compare(control.pressed, true)
verify(control.spy.success)
control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]]
+ ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
+ "released",
+ "clicked"]
mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(control.checked, false)
compare(control.checkState, Qt.Unchecked)
@@ -209,10 +209,10 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
- ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }]]
+ ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
+ "released",
+ "clicked"]
keyClick(Qt.Key_Space)
compare(control.checked, true)
compare(control.checkState, Qt.Checked)
@@ -222,10 +222,10 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]]
+ ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
+ "released",
+ "clicked"]
keyClick(Qt.Key_Space)
compare(control.checked, false)
compare(control.checkState, Qt.Unchecked)
@@ -343,9 +343,9 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }],
+ ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
"released",
- "clicked",
- ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }]]
+ "clicked"]
keyClick(Qt.Key_Space)
compare(control.checked, true)
compare(control.checkState, Qt.Checked)
@@ -355,10 +355,10 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]]
+ ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
+ "released",
+ "clicked"]
keyClick(Qt.Key_Space)
compare(control.checked, false)
compare(control.checkState, Qt.Unchecked)
@@ -368,10 +368,10 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }],
- ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }]]
+ ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }],
+ "released",
+ "clicked"]
keyClick(Qt.Key_Space)
compare(control.checked, true)
compare(control.checkState, Qt.PartiallyChecked)
@@ -381,9 +381,9 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.PartiallyChecked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }],
+ ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
"released",
- "clicked",
- ["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }]]
+ "clicked"]
mouseClick(control)
compare(control.checked, true)
compare(control.checkState, Qt.Checked)
@@ -393,10 +393,10 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": true, "checkState": Qt.Checked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": true, "checkState": Qt.Checked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }]]
+ ["checkedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
+ "released",
+ "clicked"]
mouseClick(control)
compare(control.checked, false)
compare(control.checkState, Qt.Unchecked)
@@ -406,10 +406,10 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false, "checkState": Qt.Unchecked }],
"pressed",
["pressedChanged", { "pressed": false, "checked": false, "checkState": Qt.Unchecked }],
- "released",
- "clicked",
["checkStateChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }],
- ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }]]
+ ["checkedChanged", { "pressed": false, "checked": true, "checkState": Qt.PartiallyChecked }],
+ "released",
+ "clicked"]
mouseClick(control)
compare(control.checked, true)
compare(control.checkState, Qt.PartiallyChecked)
diff --git a/tests/auto/controls/data/tst_radiobutton.qml b/tests/auto/controls/data/tst_radiobutton.qml
index 1b105f08..17e3355d 100644
--- a/tests/auto/controls/data/tst_radiobutton.qml
+++ b/tests/auto/controls/data/tst_radiobutton.qml
@@ -107,9 +107,9 @@ TestCase {
compare(control.pressed, true)
verify(control.spy.success)
control.spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false }],
+ ["checkedChanged", { "pressed": false, "checked": true }],
"released",
- "clicked",
- ["checkedChanged", { "pressed": false, "checked": true }]]
+ "clicked"]
mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton)
compare(control.checked, true)
compare(control.pressed, false)
@@ -170,9 +170,9 @@ TestCase {
control.spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }],
"pressed",
["pressedChanged", { "pressed": false, "checked": false }],
+ ["checkedChanged", { "pressed": false, "checked": true }],
"released",
- "clicked",
- ["checkedChanged", { "pressed": false, "checked": true }]]
+ "clicked"]
keyClick(Qt.Key_Space)
compare(control.checked, true)
verify(control.spy.success)