From f722ebc09a6d0336bd3bc86ef7e621932adb5064 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 17 Apr 2018 11:48:22 +0200 Subject: Slider, RangeSlider: document pressed slightly more thoroughly Change-Id: I16d6ece7ae0e4278c7bc02a6db294863116e84c7 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickrangeslider.cpp | 6 ++++-- src/quicktemplates2/qquickslider.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 9bd39d62..4da1df82 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -690,7 +690,8 @@ void QQuickRangeSlider::setTo(qreal to) \l {first.visualPosition}{visualPosition} should be used instead. \row \li pressed - \li This property holds whether the first handle is pressed. + \li This property holds whether the first handle is pressed by either touch, + mouse, or keys. \row \li hovered \li This property holds whether the first handle is hovered. @@ -747,7 +748,8 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const \l {second.visualPosition}{visualPosition} should be used instead. \row \li pressed - \li This property holds whether the second handle is pressed. + \li This property holds whether the second handle is pressed by either touch, + mouse, or keys. \row \li hovered \li This property holds whether the second handle is hovered. diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 2143e536..0729b5d4 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -459,7 +459,8 @@ void QQuickSlider::setSnapMode(SnapMode mode) /*! \qmlproperty bool QtQuick.Controls::Slider::pressed - This property holds whether the slider is pressed. + This property holds whether the slider is pressed by either touch, mouse, + or keys. */ bool QQuickSlider::isPressed() const { -- cgit v1.2.3 From 9b8338c20236f705d1472c0a7c7244646369d58f Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 17 Apr 2018 14:51:53 +0200 Subject: Slider, RangeSlider: document stepSize's relation to snapMode Task-number: QTBUG-67478 Change-Id: Idb2a24fe6397b8c86d94e250968bc4e175bfa554 Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickrangeslider.cpp | 3 +++ src/quicktemplates2/qquickslider.cpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 4da1df82..35797203 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -792,6 +792,9 @@ void QQuickRangeSlider::setStepSize(qreal step) This property holds the snap mode. + The snap mode determines how the slider handles behave with + regards to the \l stepSize. + Possible values: \value RangeSlider.NoSnap The slider does not snap (default). \value RangeSlider.SnapAlways The slider snaps while the handle is dragged. diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 0729b5d4..e9717368 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -421,6 +421,9 @@ void QQuickSlider::setStepSize(qreal step) This property holds the snap mode. + The snap mode determines how the slider handle behaves with + regards to the \l stepSize. + Possible values: \value Slider.NoSnap The slider does not snap (default). \value Slider.SnapAlways The slider snaps while the handle is dragged. -- cgit v1.2.3 From e23beb63cc0dbbe69d193e3445f6ca9d4f586ad4 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 20 Apr 2018 09:34:00 +0200 Subject: Ensure that CheckIndicator works with MenuItem This was broken in 99b2fbbc90466c79837c7e68ac5d7a15b2f91699. MenuItem doesn't have a checkState property, so we need to check its checked property instead. Change-Id: I3c2f9b27a1fe81c1de3500fad7e7bbe17ce6e02e Reviewed-by: J-P Nurmi --- src/imports/controls/material/CheckIndicator.qml | 13 +++++++------ src/imports/controls/material/MenuItem.qml | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/imports/controls/material/CheckIndicator.qml b/src/imports/controls/material/CheckIndicator.qml index 71962150..dbba4ca4 100644 --- a/src/imports/controls/material/CheckIndicator.qml +++ b/src/imports/controls/material/CheckIndicator.qml @@ -44,11 +44,12 @@ Rectangle { implicitHeight: 18 color: "transparent" border.color: !control.enabled ? control.Material.hintTextColor - : control.checkState !== Qt.Unchecked ? control.Material.accentColor : control.Material.secondaryTextColor - border.width: control.checkState !== Qt.Unchecked ? width / 2 : 2 + : checkState !== Qt.Unchecked ? control.Material.accentColor : control.Material.secondaryTextColor + border.width: checkState !== Qt.Unchecked ? width / 2 : 2 radius: 2 property Item control + property int checkState: control.checkState Behavior on border.width { NumberAnimation { @@ -74,7 +75,7 @@ Rectangle { source: "qrc:/qt-project.org/imports/QtQuick/Controls.2/Material/images/check.png" fillMode: Image.PreserveAspectFit - scale: control.checkState === Qt.Checked ? 1 : 0 + scale: checkState === Qt.Checked ? 1 : 0 Behavior on scale { NumberAnimation { duration: 100 } } } @@ -84,18 +85,18 @@ Rectangle { width: 12 height: 3 - scale: control.checkState === Qt.PartiallyChecked ? 1 : 0 + scale: checkState === Qt.PartiallyChecked ? 1 : 0 Behavior on scale { NumberAnimation { duration: 100 } } } states: [ State { name: "checked" - when: control.checkState === Qt.Checked + when: checkState === Qt.Checked }, State { name: "partiallychecked" - when: control.checkState === Qt.PartiallyChecked + when: checkState === Qt.PartiallyChecked } ] diff --git a/src/imports/controls/material/MenuItem.qml b/src/imports/controls/material/MenuItem.qml index 13d4694c..54d13f8e 100644 --- a/src/imports/controls/material/MenuItem.qml +++ b/src/imports/controls/material/MenuItem.qml @@ -65,6 +65,7 @@ T.MenuItem { y: control.topPadding + (control.availableHeight - height) / 2 visible: control.checkable control: control + checkState: control.checked ? Qt.Checked : Qt.Unchecked } arrow: ColorImage { -- cgit v1.2.3 From ec0ad4ca9207acbc524a109ffbacb6cbb0fa18a8 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 23 Apr 2018 12:45:24 +0200 Subject: ComboBox: reset when hidden Close the popup and reset the pressed state. Same as in focusOutEvent(). Task-number: QTBUG-67684 Change-Id: I51143175b0f90f3edd116723481faed6ac6e7988 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcombobox.cpp | 10 ++++++++++ src/quicktemplates2/qquickcombobox_p.h | 1 + 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index d992c649..d3226baf 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1666,6 +1666,16 @@ void QQuickComboBox::componentComplete() } } +void QQuickComboBox::itemChange(QQuickItem::ItemChange change, const QQuickItem::ItemChangeData &value) +{ + Q_D(QQuickComboBox); + QQuickControl::itemChange(change, value); + if (change == ItemVisibleHasChanged && !value.boolValue) { + d->hidePopup(false); + setPressed(false); + } +} + void QQuickComboBox::contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) { Q_D(QQuickComboBox); diff --git a/src/quicktemplates2/qquickcombobox_p.h b/src/quicktemplates2/qquickcombobox_p.h index ee926daf..2faff745 100644 --- a/src/quicktemplates2/qquickcombobox_p.h +++ b/src/quicktemplates2/qquickcombobox_p.h @@ -194,6 +194,7 @@ protected: #endif void componentComplete() override; + void itemChange(ItemChange change, const ItemChangeData &value) override; void contentItemChange(QQuickItem *newItem, QQuickItem *oldItem) override; void localeChange(const QLocale &newLocale, const QLocale &oldLocale) override; -- cgit v1.2.3 From def92f7b657ee9247beffffcb0cadd1eca8be3c6 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 23 Apr 2018 14:05:25 +0200 Subject: ComboBox: don't block the escape/back key Accept Key_Escape or Key_Back only if it actually close the popup. If the popup is not visible, the key is not handled, and the event should therefore propagate (and potentially close the app on Android). Change-Id: Ibdb0cab8e0ac47005c5112f7ca4882288f1f5a17 Task-number: QTBUG-67684 Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcombobox.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index d3226baf..4d5efece 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1624,9 +1624,11 @@ void QQuickComboBox::keyReleaseEvent(QKeyEvent *event) break; case Qt::Key_Escape: case Qt::Key_Back: - d->hidePopup(false); - setPressed(false); - event->accept(); + if (d->isPopupVisible()) { + d->hidePopup(false); + setPressed(false); + event->accept(); + } break; default: break; -- cgit v1.2.3 From 110b7187cef4a920423e860ef0e10f819c283fa2 Mon Sep 17 00:00:00 2001 From: Liang Qi Date: Tue, 24 Apr 2018 22:24:14 +0200 Subject: Revert "ComboBox: don't block the escape/back key" This change got integrated by sick COIN. This reverts commit def92f7b657ee9247beffffcb0cadd1eca8be3c6. Task-number: QTBUG-67930 Change-Id: I541579d7112ba386b227b7892d4e0aa8e2bd4edf Reviewed-by: J-P Nurmi --- src/quicktemplates2/qquickcombobox.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index 4d5efece..d3226baf 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1624,11 +1624,9 @@ void QQuickComboBox::keyReleaseEvent(QKeyEvent *event) break; case Qt::Key_Escape: case Qt::Key_Back: - if (d->isPopupVisible()) { - d->hidePopup(false); - setPressed(false); - event->accept(); - } + d->hidePopup(false); + setPressed(false); + event->accept(); break; default: break; -- cgit v1.2.3 From bc93333958e469e2bd79319befb23328a9de38a9 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Mon, 23 Apr 2018 14:05:25 +0200 Subject: ComboBox: don't block the escape/back key (with fixed test) Accept Key_Escape or Key_Back only if it actually close the popup. If the popup is not visible, the key is not handled, and the event should therefore propagate (and potentially close the app on Android). Note: def92f7 had a broken test (didn't take the popup exit transition into account) and thus, blocked the CI and got rejected in 110b718. Task-number: QTBUG-67684 Change-Id: I46b4731b3006721f3737cf909fbd97331ac6d8ed Reviewed-by: Liang Qi Reviewed-by: Mitch Curtis --- src/quicktemplates2/qquickcombobox.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/quicktemplates2/qquickcombobox.cpp b/src/quicktemplates2/qquickcombobox.cpp index d3226baf..4d5efece 100644 --- a/src/quicktemplates2/qquickcombobox.cpp +++ b/src/quicktemplates2/qquickcombobox.cpp @@ -1624,9 +1624,11 @@ void QQuickComboBox::keyReleaseEvent(QKeyEvent *event) break; case Qt::Key_Escape: case Qt::Key_Back: - d->hidePopup(false); - setPressed(false); - event->accept(); + if (d->isPopupVisible()) { + d->hidePopup(false); + setPressed(false); + event->accept(); + } break; default: break; -- cgit v1.2.3