diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-05-03 16:54:16 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-05-04 09:04:11 +0000 |
commit | ff9d924d98aac8248ce99aef992920aeb99fda7e (patch) | |
tree | 111f0559bac140df5f245172a38d13921577705e /src/quicktemplates2/qquickswitch.cpp | |
parent | d3371de42f5262a2f0794a2d5e972ed50001028e (diff) |
QQuickSwitch: fix the order of checkedChanged() vs. clicked()
And emit clicked() also when the switch was dragged to make it possible
to use clicked() reliably to detect user interaction.
Change-Id: Iefbd95b90ed40f04d84e03e247a8ac12c7f0e9ca
Task-number: QTBUG-52558
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickswitch.cpp')
-rw-r--r-- | src/quicktemplates2/qquickswitch.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp index e6f8cce0..380c37ec 100644 --- a/src/quicktemplates2/qquickswitch.cpp +++ b/src/quicktemplates2/qquickswitch.cpp @@ -142,14 +142,17 @@ bool QQuickSwitchPrivate::handleMouseReleaseEvent(QQuickItem *child, QMouseEvent pressPoint = QPoint(); q->setPressed(false); if (child->keepMouseGrab()) { + bool wasChecked = checked; q->setChecked(position > 0.5); q->setPosition(checked ? 1.0 : 0.0); child->setKeepMouseGrab(false); + if (wasChecked != checked) + emit q->clicked(); event->accept(); } else { + q->toggle(); emit q->clicked(); event->accept(); - q->toggle(); } return true; } |