summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-01-14 21:58:48 +0100
committerLiang Qi <liang.qi@qt.io>2017-01-14 21:58:48 +0100
commit537eced61381f0ce1eabdc797bb0dacd11e11d39 (patch)
tree13ccb774329ca0214e89675e5f1d1ffa638f8ef6
parent698cffce2171bed322aa9d0df1fda316c379efda (diff)
parent6f7852a307c7ebbdb3b6efa00cbf7626b072bbc1 (diff)
Merge remote-tracking branch 'origin/5.8.0' into 5.8
-rw-r--r--src/imports/controls/material/ComboBox.qml2
-rw-r--r--src/quicktemplates2/qquickdialogbuttonbox.cpp12
-rw-r--r--src/quicktemplates2/qquickswitch.cpp8
-rw-r--r--src/quicktemplates2/qquickswitchdelegate.cpp8
-rw-r--r--tests/auto/controls/data/tst_dialogbuttonbox.qml4
-rw-r--r--tests/auto/controls/data/tst_switch.qml17
-rw-r--r--tests/auto/controls/data/tst_switchdelegate.qml17
7 files changed, 63 insertions, 5 deletions
diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml
index fbddb32c..c38c2b01 100644
--- a/src/imports/controls/material/ComboBox.qml
+++ b/src/imports/controls/material/ComboBox.qml
@@ -74,6 +74,8 @@ T.ComboBox {
x: control.mirrored ? control.leftPadding : control.width - width - control.rightPadding
y: control.topPadding + (control.availableHeight - height) / 2
source: "image://material/drop-indicator/" + (control.enabled ? control.Material.foreground : control.Material.hintTextColor)
+ sourceSize.width: width
+ sourceSize.height: height
}
contentItem: Text {
diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp
index 0f362fcc..40b1e2c7 100644
--- a/src/quicktemplates2/qquickdialogbuttonbox.cpp
+++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp
@@ -500,7 +500,17 @@ void QQuickDialogButtonBox::setStandardButtons(QPlatformDialogHelper::StandardBu
*/
QQuickAbstractButton *QQuickDialogButtonBox::standardButton(QPlatformDialogHelper::StandardButton button) const
{
- Q_UNUSED(button);
+ Q_D(const QQuickDialogButtonBox);
+ if (Q_UNLIKELY(!(d->standardButtons & button)))
+ return nullptr;
+ for (int i = 0, n = count(); i < n; ++i) {
+ QQuickAbstractButton *btn = qobject_cast<QQuickAbstractButton *>(d->itemAt(i));
+ if (Q_LIKELY(btn)) {
+ QQuickDialogButtonBoxAttached *attached = qobject_cast<QQuickDialogButtonBoxAttached *>(qmlAttachedPropertiesObject<QQuickDialogButtonBox>(btn, false));
+ if (attached && QQuickDialogButtonBoxAttachedPrivate::get(attached)->standardButton == button)
+ return btn;
+ }
+ }
return nullptr;
}
diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp
index fa1b5463..c1a7d34a 100644
--- a/src/quicktemplates2/qquickswitch.cpp
+++ b/src/quicktemplates2/qquickswitch.cpp
@@ -186,10 +186,14 @@ void QQuickSwitch::mirrorChange()
void QQuickSwitch::nextCheckState()
{
Q_D(QQuickSwitch);
- if (keepMouseGrab())
+ if (keepMouseGrab()) {
setChecked(d->position > 0.5);
- else
+ // the checked state might not change => force a position update to
+ // avoid that the handle is left somewhere in the middle (QTBUG-57944)
+ checkStateSet();
+ } else {
QQuickAbstractButton::nextCheckState();
+ }
}
void QQuickSwitch::checkStateSet()
diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp
index 72b4803d..d0d14ae5 100644
--- a/src/quicktemplates2/qquickswitchdelegate.cpp
+++ b/src/quicktemplates2/qquickswitchdelegate.cpp
@@ -191,10 +191,14 @@ void QQuickSwitchDelegate::mirrorChange()
void QQuickSwitchDelegate::nextCheckState()
{
Q_D(QQuickSwitchDelegate);
- if (keepMouseGrab())
+ if (keepMouseGrab()) {
setChecked(d->position > 0.5);
- else
+ // the checked state might not change => force a position update to
+ // avoid that the handle is left somewhere in the middle (QTBUG-57944)
+ checkStateSet();
+ } else {
QQuickItemDelegate::nextCheckState();
+ }
}
void QQuickSwitchDelegate::checkStateSet()
diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml
index 880d44c7..74a17c6d 100644
--- a/tests/auto/controls/data/tst_dialogbuttonbox.qml
+++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml
@@ -104,9 +104,13 @@ TestCase {
verify(cancelButton)
compare(okButton.text.toUpperCase(), "OK")
compare(cancelButton.text.toUpperCase(), "CANCEL")
+ compare(control.standardButton(DialogButtonBox.Ok), okButton)
+ compare(control.standardButton(DialogButtonBox.Cancel), cancelButton)
control.standardButtons = 0
compare(control.count, 0)
+ compare(control.standardButton(DialogButtonBox.Ok), null)
+ compare(control.standardButton(DialogButtonBox.Cancel), null)
control.destroy()
}
diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml
index 314848c8..4a229ff0 100644
--- a/tests/auto/controls/data/tst_switch.qml
+++ b/tests/auto/controls/data/tst_switch.qml
@@ -187,6 +187,23 @@ TestCase {
compare(control.pressed, false)
verify(spy.success)
+ // release in the middle
+ spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }],
+ "pressed"]
+ mousePress(control, 0, 0, Qt.LeftButton)
+ compare(control.pressed, true)
+ verify(spy.success)
+ mouseMove(control, control.width / 4, control.height / 4, 0, Qt.LeftButton)
+ compare(control.pressed, true)
+ spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false }],
+ "released",
+ "clicked"]
+ mouseRelease(control, control.width / 4, control.height / 4, Qt.LeftButton)
+ compare(control.checked, false)
+ compare(control.pressed, false)
+ tryCompare(control, "position", 0) // QTBUG-57944
+ verify(spy.success)
+
// right button
spy.expectedSequence = []
mousePress(control, control.width / 2, control.height / 2, Qt.RightButton)
diff --git a/tests/auto/controls/data/tst_switchdelegate.qml b/tests/auto/controls/data/tst_switchdelegate.qml
index 23117ce7..ff8dbbc9 100644
--- a/tests/auto/controls/data/tst_switchdelegate.qml
+++ b/tests/auto/controls/data/tst_switchdelegate.qml
@@ -183,6 +183,23 @@ TestCase {
compare(control.pressed, false)
verify(spy.success)
+ // release in the middle
+ spy.expectedSequence = [["pressedChanged", { "pressed": true, "checked": false }],
+ "pressed"]
+ mousePress(control.indicator, 0, 0, Qt.LeftButton)
+ compare(control.pressed, true)
+ verify(spy.success)
+ mouseMove(control.indicator, control.indicator.width / 2 - 1, 0)
+ compare(control.pressed, true)
+ spy.expectedSequence = [["pressedChanged", { "pressed": false, "checked": false }],
+ "released",
+ "clicked"]
+ mouseRelease(control.indicator, control.indicator.width / 2 - 1, 0, Qt.LeftButton)
+ compare(control.checked, false)
+ compare(control.pressed, false)
+ tryCompare(control, "position", 0) // QTBUG-57944
+ verify(spy.success)
+
// right button
spy.expectedSequence = []
mousePress(control, control.width / 2, control.height / 2, Qt.RightButton)