diff options
19 files changed, 170 insertions, 30 deletions
diff --git a/src/imports/controls/designer/images/roundbutton-icon.png b/src/imports/controls/designer/images/roundbutton-icon.png Binary files differnew file mode 100644 index 00000000..35d28fab --- /dev/null +++ b/src/imports/controls/designer/images/roundbutton-icon.png diff --git a/src/imports/controls/designer/images/roundbutton-icon16.png b/src/imports/controls/designer/images/roundbutton-icon16.png Binary files differnew file mode 100644 index 00000000..5dc3a895 --- /dev/null +++ b/src/imports/controls/designer/images/roundbutton-icon16.png diff --git a/src/imports/controls/designer/images/roundbutton-icon16@2x.png b/src/imports/controls/designer/images/roundbutton-icon16@2x.png Binary files differnew file mode 100644 index 00000000..10c13149 --- /dev/null +++ b/src/imports/controls/designer/images/roundbutton-icon16@2x.png diff --git a/src/imports/controls/designer/images/roundbutton-icon@2x.png b/src/imports/controls/designer/images/roundbutton-icon@2x.png Binary files differnew file mode 100644 index 00000000..81150e3d --- /dev/null +++ b/src/imports/controls/designer/images/roundbutton-icon@2x.png diff --git a/src/imports/controls/designer/images/stackview-icon.png b/src/imports/controls/designer/images/stackview-icon.png Binary files differnew file mode 100644 index 00000000..bbd6783c --- /dev/null +++ b/src/imports/controls/designer/images/stackview-icon.png diff --git a/src/imports/controls/designer/images/stackview-icon16.png b/src/imports/controls/designer/images/stackview-icon16.png Binary files differnew file mode 100644 index 00000000..3f7ab00c --- /dev/null +++ b/src/imports/controls/designer/images/stackview-icon16.png diff --git a/src/imports/controls/designer/images/swipeview-icon.png b/src/imports/controls/designer/images/swipeview-icon.png Binary files differnew file mode 100644 index 00000000..bbd6783c --- /dev/null +++ b/src/imports/controls/designer/images/swipeview-icon.png diff --git a/src/imports/controls/designer/images/swipeview-icon16.png b/src/imports/controls/designer/images/swipeview-icon16.png Binary files differnew file mode 100644 index 00000000..3f7ab00c --- /dev/null +++ b/src/imports/controls/designer/images/swipeview-icon16.png diff --git a/src/imports/controls/designer/qtquickcontrols2.metainfo b/src/imports/controls/designer/qtquickcontrols2.metainfo index c697b3c2..35cfa0f2 100644 --- a/src/imports/controls/designer/qtquickcontrols2.metainfo +++ b/src/imports/controls/designer/qtquickcontrols2.metainfo @@ -440,4 +440,50 @@ MetaInfo { Property { name: "text"; type: "binding"; value: "qsTr(\"Tab Button\")" } } } + + Type { + name: "QtQuick.Controls.RoundButton" + icon: "images/roundbutton-icon16.png" + + ItemLibraryEntry { + name: "Round Button" + category: "Qt Quick - Controls 2" + libraryIcon: "images/roundbutton-icon.png" + version: "2.1" + requiredImport: "QtQuick.Controls" + Property { name: "text"; type: "string"; value: "+" } + } + } + + Type { + name: "QtQuick.Controls.StackView" + icon: "images/stackview-icon16.png" + + ItemLibraryEntry { + name: "stack View" + category: "Qt Quick - Views" + libraryIcon: "images/stackview-icon.png" + version: "2.1" + requiredImport: "QtQuick.Controls" + + Property { name: "width"; type: "int"; value: 200 } + Property { name: "height"; type: "int"; value: 200 } + } + } + + Type { + name: "QtQuick.Controls.SwipeView" + icon: "images/swipeview-icon16.png" + + ItemLibraryEntry { + name: "Swipe View" + category: "Qt Quick - Views" + libraryIcon: "images/swipeview-icon.png" + version: "2.0" + requiredImport: "QtQuick.Controls" + + Property { name: "width"; type: "int"; value: 200 } + Property { name: "height"; type: "int"; value: 200 } + } + } } diff --git a/src/imports/controls/material/ComboBox.qml b/src/imports/controls/material/ComboBox.qml index 2bdf9afa..0721e8f3 100644 --- a/src/imports/controls/material/ComboBox.qml +++ b/src/imports/controls/material/ComboBox.qml @@ -71,6 +71,8 @@ T.ComboBox { x: control.mirrored ? control.padding : control.width - width - control.padding 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: T.TextField { diff --git a/src/quicktemplates2/qquickdialogbuttonbox.cpp b/src/quicktemplates2/qquickdialogbuttonbox.cpp index 7606f26a..d125de91 100644 --- a/src/quicktemplates2/qquickdialogbuttonbox.cpp +++ b/src/quicktemplates2/qquickdialogbuttonbox.cpp @@ -499,7 +499,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/qquickspinbox.cpp b/src/quicktemplates2/qquickspinbox.cpp index 4dd7518c..d8d34d28 100644 --- a/src/quicktemplates2/qquickspinbox.cpp +++ b/src/quicktemplates2/qquickspinbox.cpp @@ -123,6 +123,7 @@ public: int boundValue(int value) const; void updateValue(); + bool setValue(int value); int effectiveStepSize() const; @@ -181,6 +182,24 @@ void QQuickSpinBoxPrivate::updateValue() } } +bool QQuickSpinBoxPrivate::setValue(int newValue) +{ + Q_Q(QQuickSpinBox); + if (q->isComponentComplete()) + newValue = boundValue(newValue); + + if (value == newValue) + return false; + + value = newValue; + + updateUpEnabled(); + updateDownEnabled(); + + emit q->valueChanged(); + return true; +} + int QQuickSpinBoxPrivate::effectiveStepSize() const { return from > to ? -1 * stepSize : stepSize; @@ -351,8 +370,12 @@ void QQuickSpinBox::setFrom(int from) d->from = from; emit fromChanged(); - if (isComponentComplete()) - setValue(d->value); + if (isComponentComplete()) { + if (!d->setValue(d->value)) { + d->updateUpEnabled(); + d->updateDownEnabled(); + } + } } /*! @@ -376,8 +399,12 @@ void QQuickSpinBox::setTo(int to) d->to = to; emit toChanged(); - if (isComponentComplete()) - setValue(d->value); + if (isComponentComplete()) { + if (!d->setValue(d->value)) { + d->updateUpEnabled(); + d->updateDownEnabled(); + } + } } /*! @@ -394,18 +421,7 @@ int QQuickSpinBox::value() const void QQuickSpinBox::setValue(int value) { Q_D(QQuickSpinBox); - if (isComponentComplete()) - value = d->boundValue(value); - - if (d->value == value) - return; - - d->value = value; - - d->updateUpEnabled(); - d->updateDownEnabled(); - - emit valueChanged(); + d->setValue(value); } /*! diff --git a/src/quicktemplates2/qquickswitch.cpp b/src/quicktemplates2/qquickswitch.cpp index 217b305d..f96fa391 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()) { d->toggle(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) + setPosition(d->checked ? 1.0 : 0.0); + } else { QQuickAbstractButton::nextCheckState(); + } } void QQuickSwitch::buttonChange(ButtonChange change) diff --git a/src/quicktemplates2/qquickswitchdelegate.cpp b/src/quicktemplates2/qquickswitchdelegate.cpp index 0523e332..82c9594c 100644 --- a/src/quicktemplates2/qquickswitchdelegate.cpp +++ b/src/quicktemplates2/qquickswitchdelegate.cpp @@ -188,10 +188,14 @@ void QQuickSwitchDelegate::mirrorChange() void QQuickSwitchDelegate::nextCheckState() { Q_D(QQuickSwitchDelegate); - if (keepMouseGrab()) + if (keepMouseGrab()) { d->toggle(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) + setPosition(d->checked ? 1.0 : 0.0); + } else { QQuickItemDelegate::nextCheckState(); + } } void QQuickSwitchDelegate::buttonChange(ButtonChange change) diff --git a/tests/auto/controls/data/tst_dialogbuttonbox.qml b/tests/auto/controls/data/tst_dialogbuttonbox.qml index a851c435..17bc31f2 100644 --- a/tests/auto/controls/data/tst_dialogbuttonbox.qml +++ b/tests/auto/controls/data/tst_dialogbuttonbox.qml @@ -103,9 +103,14 @@ 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) } function test_attached() { diff --git a/tests/auto/controls/data/tst_spinbox.qml b/tests/auto/controls/data/tst_spinbox.qml index 73a122bc..ab6068eb 100644 --- a/tests/auto/controls/data/tst_spinbox.qml +++ b/tests/auto/controls/data/tst_spinbox.qml @@ -116,9 +116,21 @@ TestCase { compare(control.up.indicator.enabled, true) compare(control.down.indicator.enabled, false) + control.value = 30 + compare(control.from, 25) + compare(control.value, 30) + compare(control.up.indicator.enabled, true) + compare(control.down.indicator.enabled, true) + + control.from = 30 + compare(control.from, 30) + compare(control.value, 30) + compare(control.up.indicator.enabled, true) + compare(control.down.indicator.enabled, false) + control.to = 75 compare(control.to, 75) - compare(control.value, 25) + compare(control.value, 30) compare(control.up.indicator.enabled, true) compare(control.down.indicator.enabled, false) @@ -127,7 +139,14 @@ TestCase { compare(control.up.indicator.enabled, true) compare(control.down.indicator.enabled, true) - control.to = 40; + control.to = 50 + compare(control.to, 50) + compare(control.value, 50) + compare(control.up.indicator.enabled, false) + compare(control.down.indicator.enabled, true) + + control.to = 40 + compare(control.to, 40) compare(control.value, 40) compare(control.up.indicator.enabled, false) compare(control.down.indicator.enabled, true) diff --git a/tests/auto/controls/data/tst_switch.qml b/tests/auto/controls/data/tst_switch.qml index 2b050d14..6e424609 100644 --- a/tests/auto/controls/data/tst_switch.qml +++ b/tests/auto/controls/data/tst_switch.qml @@ -185,6 +185,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 3f591602..490afd51 100644 --- a/tests/auto/controls/data/tst_switchdelegate.qml +++ b/tests/auto/controls/data/tst_switchdelegate.qml @@ -181,6 +181,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) diff --git a/tests/auto/controls/data/tst_toolbutton.qml b/tests/auto/controls/data/tst_toolbutton.qml index 88afeeb3..be9ce95f 100644 --- a/tests/auto/controls/data/tst_toolbutton.qml +++ b/tests/auto/controls/data/tst_toolbutton.qml @@ -85,12 +85,12 @@ TestCase { verify(clickedSpy.valid) // check - mousePress(control, control.width / 2, control.height / 2, Qt.LeftToolButton) + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) 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) + mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(clickedSpy.count, 1) compare(pressedSpy.count, 2) compare(downSpy.count, 2) @@ -98,12 +98,12 @@ TestCase { compare(control.down, false) // uncheck - mousePress(control, control.width / 2, control.height / 2, Qt.LeftToolButton) + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) 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) + mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton) compare(clickedSpy.count, 2) compare(pressedSpy.count, 4) compare(downSpy.count, 4) @@ -111,15 +111,15 @@ TestCase { compare(control.down, false) // release outside - mousePress(control, control.width / 2, control.height / 2, Qt.LeftToolButton) + mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton) 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) + mouseMove(control, control.width * 2, control.height * 2) compare(control.pressed, false) compare(control.down, false) - mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftToolButton) + mouseRelease(control, control.width * 2, control.height * 2, Qt.LeftButton) compare(clickedSpy.count, 2) compare(pressedSpy.count, 6) compare(downSpy.count, 6) |