diff options
27 files changed, 246 insertions, 61 deletions
diff --git a/.qmake.conf b/.qmake.conf index 0104dac8..8114dfd7 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -4,4 +4,4 @@ DEFINES += QT_NO_FOREACH QQC2_SOURCE_TREE = $$PWD -MODULE_VERSION = 5.8.0 +MODULE_VERSION = 5.9.0 diff --git a/src/imports/controls/Dial.qml b/src/imports/controls/Dial.qml index f19fcc2b..e4579ca9 100644 --- a/src/imports/controls/Dial.qml +++ b/src/imports/controls/Dial.qml @@ -35,9 +35,9 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.1 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T T.Dial { id: control diff --git a/src/imports/controls/RangeSlider.qml b/src/imports/controls/RangeSlider.qml index 6b892fd1..005fa99c 100644 --- a/src/imports/controls/RangeSlider.qml +++ b/src/imports/controls/RangeSlider.qml @@ -35,9 +35,9 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.1 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T T.RangeSlider { id: control diff --git a/src/imports/controls/Slider.qml b/src/imports/controls/Slider.qml index f7e95db9..d2aba229 100644 --- a/src/imports/controls/Slider.qml +++ b/src/imports/controls/Slider.qml @@ -35,9 +35,9 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.1 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T T.Slider { id: control diff --git a/src/imports/controls/Tumbler.qml b/src/imports/controls/Tumbler.qml index 6c89b86d..0be6c074 100644 --- a/src/imports/controls/Tumbler.qml +++ b/src/imports/controls/Tumbler.qml @@ -35,9 +35,9 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.1 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T T.Tumbler { id: control diff --git a/src/imports/controls/material/Dial.qml b/src/imports/controls/material/Dial.qml index 9f5d88c3..dce68e93 100644 --- a/src/imports/controls/material/Dial.qml +++ b/src/imports/controls/material/Dial.qml @@ -35,7 +35,7 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Material 2.1 import QtQuick.Controls.Material.impl 2.1 diff --git a/src/imports/controls/material/RangeSlider.qml b/src/imports/controls/material/RangeSlider.qml index 641c00f1..90a68f04 100644 --- a/src/imports/controls/material/RangeSlider.qml +++ b/src/imports/controls/material/RangeSlider.qml @@ -35,7 +35,7 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Material 2.1 import QtQuick.Controls.Material.impl 2.1 diff --git a/src/imports/controls/material/Slider.qml b/src/imports/controls/material/Slider.qml index 1c915b32..bd2cc57b 100644 --- a/src/imports/controls/material/Slider.qml +++ b/src/imports/controls/material/Slider.qml @@ -35,7 +35,7 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Material 2.1 import QtQuick.Controls.Material.impl 2.1 diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml index 88750855..06a012f6 100644 --- a/src/imports/controls/material/Tumbler.qml +++ b/src/imports/controls/material/Tumbler.qml @@ -35,9 +35,9 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.1 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Material 2.1 T.Tumbler { diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index 5b8868fe..1bbeefd6 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -41,6 +41,10 @@ #include <QtQuickControls2/private/qquickstyleselector_p.h> #include <QtQuickControls2/private/qquickcolorimageprovider_p.h> #include <QtQuickTemplates2/private/qquickbuttongroup_p.h> +#include <QtQuickTemplates2/private/qquickdial_p.h> +#include <QtQuickTemplates2/private/qquickrangeslider_p.h> +#include <QtQuickTemplates2/private/qquickslider_p.h> +#include <QtQuickTemplates2/private/qquicktumbler_p.h> #include <QtQuickControls2/private/qquicktumblerview_p.h> #include "qquickbusyindicatorring_p.h" @@ -137,6 +141,12 @@ void QtQuickControls2Plugin::registerTypes(const char *uri) qmlRegisterType(selector.select(QStringLiteral("MenuSeparator.qml")), uri, 2, 1, "MenuSeparator"); qmlRegisterType(selector.select(QStringLiteral("RoundButton.qml")), uri, 2, 1, "RoundButton"); qmlRegisterType(selector.select(QStringLiteral("ToolSeparator.qml")), uri, 2, 1, "ToolSeparator"); + + // QtQuick.Controls 2.2 (Qt 5.9) + qmlRegisterRevision<QQuickDial, 2>(uri, 2, 2); + qmlRegisterRevision<QQuickRangeSlider, 2>(uri, 2, 2); + qmlRegisterRevision<QQuickSlider, 2>(uri, 2, 2); + qmlRegisterRevision<QQuickTumbler, 2>(uri, 2, 2); } static QObject *styleSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) diff --git a/src/imports/controls/universal/Dial.qml b/src/imports/controls/universal/Dial.qml index d50b066b..b6531ed6 100644 --- a/src/imports/controls/universal/Dial.qml +++ b/src/imports/controls/universal/Dial.qml @@ -35,7 +35,7 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Universal 2.1 T.Dial { diff --git a/src/imports/controls/universal/RangeSlider.qml b/src/imports/controls/universal/RangeSlider.qml index 0b78962e..e7a315dd 100644 --- a/src/imports/controls/universal/RangeSlider.qml +++ b/src/imports/controls/universal/RangeSlider.qml @@ -35,7 +35,7 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Universal 2.1 T.RangeSlider { diff --git a/src/imports/controls/universal/Slider.qml b/src/imports/controls/universal/Slider.qml index b059a9c5..9fad8f9c 100644 --- a/src/imports/controls/universal/Slider.qml +++ b/src/imports/controls/universal/Slider.qml @@ -35,7 +35,7 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Universal 2.1 T.Slider { diff --git a/src/imports/controls/universal/Tumbler.qml b/src/imports/controls/universal/Tumbler.qml index e7093d0a..a8033551 100644 --- a/src/imports/controls/universal/Tumbler.qml +++ b/src/imports/controls/universal/Tumbler.qml @@ -35,9 +35,9 @@ ****************************************************************************/ import QtQuick 2.8 -import QtQuick.Templates 2.1 as T +import QtQuick.Templates 2.2 as T import QtQuick.Controls.Universal 2.1 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 import QtQuick.Controls.impl 2.1 T.Tumbler { diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index cc344a80..88ee9b58 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -197,6 +197,12 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) qmlRegisterType<QQuickTextField, 1>(uri, 2, 1, "TextField"); qmlRegisterType<QQuickToolSeparator>(uri, 2, 1, "ToolSeparator"); qmlRegisterType<QQuickTumbler, 1>(uri, 2, 1, "Tumbler"); + + // QtQuick.Templates 2.2 (Qt 5.9) + qmlRegisterRevision<QQuickDial, 2>(uri, 2, 2); + qmlRegisterRevision<QQuickRangeSlider, 2>(uri, 2, 2); + qmlRegisterRevision<QQuickSlider, 2>(uri, 2, 2); + qmlRegisterRevision<QQuickTumbler, 2>(uri, 2, 2); } QT_END_NAMESPACE diff --git a/src/quicktemplates2/qquickdial.cpp b/src/quicktemplates2/qquickdial.cpp index 48d02faa..eb60c93c 100644 --- a/src/quicktemplates2/qquickdial.cpp +++ b/src/quicktemplates2/qquickdial.cpp @@ -95,6 +95,7 @@ public: pressed(false), snapMode(QQuickDial::NoSnap), wrap(false), + live(false), handle(nullptr) { } @@ -116,6 +117,7 @@ public: QPoint pressPoint; QQuickDial::SnapMode snapMode; bool wrap; + bool live; QQuickItem *handle; }; @@ -246,11 +248,12 @@ void QQuickDial::setTo(qreal to) This property holds the value in the range \c from - \c to. The default value is \c 0.0. - Unlike the \l position property, the \c value is not updated while the - handle is dragged. The value is updated after the value has been chosen - and the dial has been released. + Unlike the \l position property, the \c value is not updated by default + while the handle is dragged. The value is updated after the value has + been chosen and the dial has been released. The \l live property can be + used to make the dial provide live updates for the \c value property. - \sa position + \sa position, live */ qreal QQuickDial::value() const { @@ -445,6 +448,33 @@ void QQuickDial::setPressed(bool pressed) } /*! + \since QtQuick.Controls 2.2 + \qmlproperty bool QtQuick.Controls::Dial::live + + This property holds whether the dial provides live updates for the \l value + property while the handle is dragged. + + The default value is \c false. + + \sa value +*/ +bool QQuickDial::live() const +{ + Q_D(const QQuickDial); + return d->live; +} + +void QQuickDial::setLive(bool live) +{ + Q_D(QQuickDial); + if (d->live == live) + return; + + d->live = live; + emit liveChanged(); +} + +/*! \qmlmethod void QtQuick.Controls::Dial::increase() Increases the value by \l stepSize, or \c 0.1 if stepSize is not defined. @@ -571,8 +601,12 @@ void QQuickDial::mouseMoveEvent(QMouseEvent *event) if (d->snapMode == SnapAlways) pos = d->snapPosition(pos); - if (d->wrap || (!d->wrap && !d->isLargeChange(event->pos(), pos))) - d->setPosition(pos); + if (d->wrap || (!d->wrap && !d->isLargeChange(event->pos(), pos))) { + if (d->live) + setValue(d->valueAt(pos)); + else + d->setPosition(pos); + } } } diff --git a/src/quicktemplates2/qquickdial_p.h b/src/quicktemplates2/qquickdial_p.h index 2d87d6d9..17a44b7a 100644 --- a/src/quicktemplates2/qquickdial_p.h +++ b/src/quicktemplates2/qquickdial_p.h @@ -69,6 +69,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickDial : public QQuickControl Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapChanged FINAL) Q_PROPERTY(bool pressed READ isPressed NOTIFY pressedChanged FINAL) + Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION 2) Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) public: @@ -106,6 +107,9 @@ public: bool isPressed() const; void setPressed(bool pressed); + bool live() const; + void setLive(bool live); + QQuickItem *handle() const; void setHandle(QQuickItem *handle); @@ -123,6 +127,7 @@ Q_SIGNALS: void snapModeChanged(); void wrapChanged(); void pressedChanged(); + Q_REVISION(2) void liveChanged(); void handleChanged(); protected: diff --git a/src/quicktemplates2/qquickrangeslider.cpp b/src/quicktemplates2/qquickrangeslider.cpp index 34654fe1..fb518b69 100644 --- a/src/quicktemplates2/qquickrangeslider.cpp +++ b/src/quicktemplates2/qquickrangeslider.cpp @@ -313,6 +313,7 @@ class QQuickRangeSliderPrivate : public QQuickControlPrivate public: QQuickRangeSliderPrivate() : + live(false), from(defaultFrom), to(defaultTo), stepSize(0), @@ -325,6 +326,7 @@ public: void updateHover(const QPointF &pos); + bool live; qreal from; qreal to; qreal stepSize; @@ -471,8 +473,10 @@ void QQuickRangeSlider::setTo(qreal to) If \l to is greater than \l from, the value of the first handle must be greater than the second, and vice versa. - Unlike \l {first.position}{position}, value is not updated while the - handle is dragged, but rather when it has been released. + Unlike \l {first.position}{position}, value is not updated by default + while the handle is dragged, but rather when it has been released. The + \l live property can be used to make the slider provide live updates + for value. The default value is \c 0.0. \row @@ -533,8 +537,10 @@ QQuickRangeSliderNode *QQuickRangeSlider::first() const If \l to is greater than \l from, the value of the first handle must be greater than the second, and vice versa. - Unlike \l {second.position}{position}, value is not updated while the - handle is dragged, but rather when it has been released. + Unlike \l {second.position}{position}, value is not updated by default + while the handle is dragged, but rather when it has been released. The + \l live property can be used to make the slider provide live updates + for value. The default value is \c 0.0. \row @@ -651,6 +657,33 @@ void QQuickRangeSlider::setOrientation(Qt::Orientation orientation) } /*! + \since QtQuick.Controls 2.2 + \qmlproperty bool QtQuick.Controls::RangeSlider::live + + This property holds whether the slider provides live updates for the \l first.value + and \l second.value properties while the respective handles are dragged. + + The default value is \c false. + + \sa first.value, second.value +*/ +bool QQuickRangeSlider::live() const +{ + Q_D(const QQuickRangeSlider); + return d->live; +} + +void QQuickRangeSlider::setLive(bool live) +{ + Q_D(QQuickRangeSlider); + if (d->live == live) + return; + + d->live = live; + emit liveChanged(); +} + +/*! \qmlmethod void QtQuick.Controls::RangeSlider::setValues(real firstValue, real secondValue) Sets \l first.value and \l second.value with the given arguments. @@ -868,7 +901,10 @@ void QQuickRangeSlider::mouseMoveEvent(QMouseEvent *event) qreal pos = positionAt(this, pressedNode->handle(), event->pos()); if (d->snapMode == SnapAlways) pos = snapPosition(this, pos); - QQuickRangeSliderNodePrivate::get(pressedNode)->setPosition(pos); + if (d->live) + pressedNode->setValue(valueAt(this, pos)); + else + QQuickRangeSliderNodePrivate::get(pressedNode)->setPosition(pos); } } } diff --git a/src/quicktemplates2/qquickrangeslider_p.h b/src/quicktemplates2/qquickrangeslider_p.h index 1b102e87..08e68b0e 100644 --- a/src/quicktemplates2/qquickrangeslider_p.h +++ b/src/quicktemplates2/qquickrangeslider_p.h @@ -65,6 +65,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickRangeSlider : public QQuickControl Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL) Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) + Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION 2) public: explicit QQuickRangeSlider(QQuickItem *parent = nullptr); @@ -94,6 +95,9 @@ public: Qt::Orientation orientation() const; void setOrientation(Qt::Orientation orientation); + bool live() const; + void setLive(bool live); + Q_INVOKABLE void setValues(qreal firstValue, qreal secondValue); Q_SIGNALS: @@ -102,6 +106,7 @@ Q_SIGNALS: void stepSizeChanged(); void snapModeChanged(); void orientationChanged(); + Q_REVISION(2) void liveChanged(); protected: void focusInEvent(QFocusEvent *event) override; diff --git a/src/quicktemplates2/qquickslider.cpp b/src/quicktemplates2/qquickslider.cpp index 43754260..3eb186be 100644 --- a/src/quicktemplates2/qquickslider.cpp +++ b/src/quicktemplates2/qquickslider.cpp @@ -77,7 +77,7 @@ class QQuickSliderPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickSlider) public: - QQuickSliderPrivate() : from(0), to(1), value(0), position(0), stepSize(0), pressed(false), + QQuickSliderPrivate() : from(0), to(1), value(0), position(0), stepSize(0), live(false), pressed(false), orientation(Qt::Horizontal), snapMode(QQuickSlider::NoSnap), handle(nullptr) { @@ -93,6 +93,7 @@ public: qreal value; qreal position; qreal stepSize; + bool live; bool pressed; QPoint pressPoint; Qt::Orientation orientation; @@ -222,12 +223,12 @@ void QQuickSlider::setTo(qreal to) This property holds the value in the range \c from - \c to. The default value is \c 0.0. - Unlike the \l position property, the \c value is not updated while the - handle is dragged, but only after the value has been chosen and the slider - has been released. The \l valueAt() method can be used to get continuous - updates. + Unlike the \l position property, the \c value is not updated by default + while the handle is dragged, but only after the value has been chosen and + the slider has been released. The \l live property can be used to make the + slider provide live updates for the \c value property. - \sa position, valueAt() + \sa position, live, valueAt() */ qreal QQuickSlider::value() const { @@ -256,9 +257,9 @@ void QQuickSlider::setValue(qreal value) This property holds the logical position of the handle. The position is defined as a percentage of the control's size, scaled - to \c {0.0 - 1.0}. Unlike the \l value property, the \c position is - continuously updated while the handle is dragged. For visualizing a - slider, the right-to-left aware \l visualPosition should be used instead. + to \c {0.0 - 1.0}. The \c position is continuously updated while the + handle is dragged. For visualizing a slider, the right-to-left aware + \l visualPosition should be used instead. \sa value, visualPosition, valueAt() */ @@ -341,6 +342,33 @@ void QQuickSlider::setSnapMode(SnapMode mode) } /*! + \since QtQuick.Controls 2.2 + \qmlproperty bool QtQuick.Controls::Slider::live + + This property holds whether the slider provides live updates for the \l value + property while the handle is dragged. + + The default value is \c false. + + \sa value +*/ +bool QQuickSlider::live() const +{ + Q_D(const QQuickSlider); + return d->live; +} + +void QQuickSlider::setLive(bool live) +{ + Q_D(QQuickSlider); + if (d->live == live) + return; + + d->live = live; + emit liveChanged(); +} + +/*! \qmlproperty bool QtQuick.Controls::Slider::pressed This property holds whether the slider is pressed. @@ -521,7 +549,10 @@ void QQuickSlider::mouseMoveEvent(QMouseEvent *event) qreal pos = d->positionAt(event->pos()); if (d->snapMode == SnapAlways) pos = d->snapPosition(pos); - d->setPosition(pos); + if (d->live) + setValue(valueAt(pos)); + else + d->setPosition(pos); } } diff --git a/src/quicktemplates2/qquickslider_p.h b/src/quicktemplates2/qquickslider_p.h index d17af5c4..7ddffc7e 100644 --- a/src/quicktemplates2/qquickslider_p.h +++ b/src/quicktemplates2/qquickslider_p.h @@ -64,6 +64,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSlider : public QQuickControl Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) Q_PROPERTY(qreal stepSize READ stepSize WRITE setStepSize NOTIFY stepSizeChanged FINAL) Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) + Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged FINAL REVISION 2) Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) @@ -96,6 +97,9 @@ public: SnapMode snapMode() const; void setSnapMode(SnapMode mode); + bool live() const; + void setLive(bool live); + bool isPressed() const; void setPressed(bool pressed); @@ -119,6 +123,7 @@ Q_SIGNALS: void visualPositionChanged(); void stepSizeChanged(); void snapModeChanged(); + Q_REVISION(2) void liveChanged(); void pressedChanged(); void orientationChanged(); void handleChanged(); diff --git a/src/quicktemplates2/qquicktumbler.cpp b/src/quicktemplates2/qquicktumbler.cpp index b7e47ec8..8d0aa4d4 100644 --- a/src/quicktemplates2/qquicktumbler.cpp +++ b/src/quicktemplates2/qquicktumbler.cpp @@ -439,6 +439,19 @@ void QQuickTumbler::resetWrap() d->setWrapBasedOnCount(); } +/*! + \qmlproperty bool QtQuick.Controls::Tumbler::moving + \since QtQuick.Controls 2.2 + + This property describes whether the tumbler is currently moving, due to + the user either dragging or flicking it. +*/ +bool QQuickTumbler::isMoving() const +{ + Q_D(const QQuickTumbler); + return d->view && d->view->property("moving").toBool(); +} + QQuickTumblerAttached *QQuickTumbler::qmlAttachedProperties(QObject *object) { return new QQuickTumblerAttached(object); @@ -505,6 +518,7 @@ void QQuickTumblerPrivate::disconnectFromView() QObject::disconnect(view, SIGNAL(currentIndexChanged()), q, SLOT(_q_onViewCurrentIndexChanged())); QObject::disconnect(view, SIGNAL(currentItemChanged()), q, SIGNAL(currentItemChanged())); QObject::disconnect(view, SIGNAL(countChanged()), q, SLOT(_q_onViewCountChanged())); + QObject::disconnect(view, SIGNAL(movingChanged()), q, SIGNAL(movingChanged())); QQuickItemPrivate *oldViewContentItemPrivate = QQuickItemPrivate::get(viewContentItem); oldViewContentItemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Children); @@ -529,6 +543,7 @@ void QQuickTumblerPrivate::setupViewData(QQuickItem *newControlContentItem) QObject::connect(view, SIGNAL(currentIndexChanged()), q, SLOT(_q_onViewCurrentIndexChanged())); QObject::connect(view, SIGNAL(currentItemChanged()), q, SIGNAL(currentItemChanged())); QObject::connect(view, SIGNAL(countChanged()), q, SLOT(_q_onViewCountChanged())); + QObject::connect(view, SIGNAL(movingChanged()), q, SIGNAL(movingChanged())); QQuickItemPrivate *viewContentItemPrivate = QQuickItemPrivate::get(viewContentItem); viewContentItemPrivate->addItemChangeListener(this, QQuickItemPrivate::Children); diff --git a/src/quicktemplates2/qquicktumbler_p.h b/src/quicktemplates2/qquicktumbler_p.h index 1c8cfa18..3ec4044c 100644 --- a/src/quicktemplates2/qquicktumbler_p.h +++ b/src/quicktemplates2/qquicktumbler_p.h @@ -67,6 +67,7 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickTumbler : public QQuickControl Q_PROPERTY(QQmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged FINAL) Q_PROPERTY(int visibleItemCount READ visibleItemCount WRITE setVisibleItemCount NOTIFY visibleItemCountChanged FINAL) Q_PROPERTY(bool wrap READ wrap WRITE setWrap RESET resetWrap NOTIFY wrapChanged FINAL REVISION 1) + Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged FINAL REVISION 2) public: explicit QQuickTumbler(QQuickItem *parent = nullptr); @@ -91,6 +92,8 @@ public: void setWrap(bool wrap); void resetWrap(); + bool isMoving() const; + static QQuickTumblerAttached *qmlAttachedProperties(QObject *object); Q_SIGNALS: @@ -101,6 +104,7 @@ Q_SIGNALS: void delegateChanged(); void visibleItemCountChanged(); Q_REVISION(1) void wrapChanged(); + Q_REVISION(2) void movingChanged(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override; diff --git a/tests/auto/controls/data/tst_dial.qml b/tests/auto/controls/data/tst_dial.qml index e6446d3e..6dd65593 100644 --- a/tests/auto/controls/data/tst_dial.qml +++ b/tests/auto/controls/data/tst_dial.qml @@ -172,9 +172,10 @@ TestCase { function test_dragging_data() { return [ - { tag: "default", from: 0, to: 1, leftValue: 0.20, topValue: 0.5, rightValue: 0.8, bottomValue: 1.0 }, - { tag: "scaled2", from: 0, to: 2, leftValue: 0.4, topValue: 1.0, rightValue: 1.6, bottomValue: 2.0 }, - { tag: "scaled1", from: -1, to: 0, leftValue: -0.8, topValue: -0.5, rightValue: -0.2, bottomValue: 0.0 } + { tag: "default", from: 0, to: 1, leftValue: 0.20, topValue: 0.5, rightValue: 0.8, bottomValue: 1.0, live: false }, + { tag: "scaled2", from: 0, to: 2, leftValue: 0.4, topValue: 1.0, rightValue: 1.6, bottomValue: 2.0, live: false }, + { tag: "scaled1", from: -1, to: 0, leftValue: -0.8, topValue: -0.5, rightValue: -0.2, bottomValue: 0.0, live: false }, + { tag: "live", from: 0, to: 1, leftValue: 0.20, topValue: 0.5, rightValue: 0.8, bottomValue: 1.0, live: true } ] } @@ -183,32 +184,35 @@ TestCase { verify(dial.wrap); dial.from = data.from; dial.to = data.to; + dial.live = data.live; valueSpy.target = dial; verify(valueSpy.valid); + var minimumExpectedValueCount = data.live ? 2 : 1; + // drag to the left mouseDrag(dial, dial.width / 2, dial.height / 2, -dial.width / 2, 0, Qt.LeftButton); fuzzyCompare(dial.value, data.leftValue, 0.1); - verify(valueSpy.count > 0); + verify(valueSpy.count >= minimumExpectedValueCount); valueSpy.clear(); // drag to the top mouseDrag(dial, dial.width / 2, dial.height / 2, 0, -dial.height / 2, Qt.LeftButton); fuzzyCompare(dial.value, data.topValue, 0.1); - verify(valueSpy.count > 0); + verify(valueSpy.count >= minimumExpectedValueCount); valueSpy.clear(); // drag to the right mouseDrag(dial, dial.width / 2, dial.height / 2, dial.width / 2, 0, Qt.LeftButton); fuzzyCompare(dial.value, data.rightValue, 0.1); - verify(valueSpy.count > 0); + verify(valueSpy.count >= minimumExpectedValueCount); valueSpy.clear(); // drag to the bottom (* 0.6 to ensure we don't go over to the minimum position) mouseDrag(dial, dial.width / 2, dial.height / 2, 10, dial.height / 2, Qt.LeftButton); fuzzyCompare(dial.value, data.bottomValue, 0.1); - verify(valueSpy.count > 0); + verify(valueSpy.count >= minimumExpectedValueCount); valueSpy.clear(); } diff --git a/tests/auto/controls/data/tst_rangeslider.qml b/tests/auto/controls/data/tst_rangeslider.qml index 392be018..f9e027d4 100644 --- a/tests/auto/controls/data/tst_rangeslider.qml +++ b/tests/auto/controls/data/tst_rangeslider.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 TestCase { id: testCase @@ -294,13 +294,15 @@ TestCase { function test_mouse_data() { return [ - { tag: "horizontal", orientation: Qt.Horizontal }, - { tag: "vertical", orientation: Qt.Vertical } + { tag: "horizontal", orientation: Qt.Horizontal, live: false }, + { tag: "vertical", orientation: Qt.Vertical, live: false }, + { tag: "horizontal:live", orientation: Qt.Horizontal, live: true }, + { tag: "vertical:live", orientation: Qt.Vertical, live: true } ] } function test_mouse(data) { - var control = sliderComponent.createObject(testCase, { orientation: data.orientation }) + var control = sliderComponent.createObject(testCase, { orientation: data.orientation, live: data.live }) verify(control) firstPressedSpy.target = control.first @@ -386,7 +388,7 @@ TestCase { compare(firstPressedSpy.count, 5) compare(secondPressedSpy.count, 2) compare(control.first.pressed, true) - compare(control.first.value, 0.0) + compare(control.first.value, data.live ? 0.5 : 0.0) compare(control.first.position, 0.5) compare(control.first.visualPosition, 0.5) compare(control.second.pressed, false) diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml index f91760e4..2c20f26c 100644 --- a/tests/auto/controls/data/tst_slider.qml +++ b/tests/auto/controls/data/tst_slider.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 TestCase { id: testCase @@ -223,13 +223,15 @@ TestCase { function test_mouse_data() { return [ - { tag: "horizontal", orientation: Qt.Horizontal }, - { tag: "vertical", orientation: Qt.Vertical } + { tag: "horizontal", orientation: Qt.Horizontal, live: false }, + { tag: "vertical", orientation: Qt.Vertical, live: false }, + { tag: "horizontal:live", orientation: Qt.Horizontal, live: true }, + { tag: "vertical:live", orientation: Qt.Vertical, live: true } ] } function test_mouse(data) { - var control = slider.createObject(testCase, {orientation: data.orientation}) + var control = slider.createObject(testCase, {orientation: data.orientation, live: data.live}) verify(control) pressedSpy.target = control @@ -251,8 +253,8 @@ TestCase { mouseMove(control, control.width * 0.5, control.height * 0.5, 0, Qt.LeftButton) compare(pressedSpy.count, 1) compare(control.pressed, true) - compare(control.value, 0.0) - verify(control.position, 0.5) + compare(control.value, data.live ? 0.5 : 0.0) + compare(control.position, 0.5) mouseRelease(control, control.width * 0.5, control.height * 0.5, Qt.LeftButton) compare(pressedSpy.count, 2) @@ -270,13 +272,13 @@ TestCase { mouseMove(control, control.width * 2, -control.height, 0, Qt.LeftButton) compare(pressedSpy.count, 3) compare(control.pressed, true) - compare(control.value, 0.5) + compare(control.value, data.live ? 1.0 : 0.5) compare(control.position, 1.0) mouseMove(control, control.width * 0.75, control.height * 0.25, 0, Qt.LeftButton) compare(pressedSpy.count, 3) compare(control.pressed, true) - compare(control.value, 0.5) + compare(control.value, data.live ? control.position : 0.5) verify(control.position >= 0.75) mouseRelease(control, control.width * 0.25, control.height * 0.75, Qt.LeftButton) diff --git a/tests/auto/controls/data/tst_tumbler.qml b/tests/auto/controls/data/tst_tumbler.qml index b3230ca4..bca2e976 100644 --- a/tests/auto/controls/data/tst_tumbler.qml +++ b/tests/auto/controls/data/tst_tumbler.qml @@ -40,7 +40,7 @@ import QtQuick 2.2 import QtTest 1.0 -import QtQuick.Controls 2.1 +import QtQuick.Controls 2.2 TestCase { id: testCase @@ -1045,4 +1045,30 @@ TestCase { ++tumbler.currentIndex; tryCompare(tumblerView, "offset", 4, tumblerView.highlightMoveDuration * 2); } + + function test_moving_data() { + return [ + { tag: "wrap:true", wrap: true }, + { tag: "wrap:false", wrap: false } + ] + } + + function test_moving(data) { + createTumbler({wrap: data.wrap, model: 5}) + compare(tumbler.wrap, data.wrap) + compare(tumbler.moving, false) + + waitForRendering(tumbler) + + mousePress(tumbler, tumbler.width / 2, tumbler.height / 2, Qt.LeftButton) + compare(tumbler.moving, false) + + for (var y = tumbler.height / 2; y >= tumbler.height / 4; y -= 10) + mouseMove(tumbler, tumbler.width / 2, y, 1) + compare(tumbler.moving, true) + + mouseRelease(tumbler, tumbler.width / 2, tumbler.height / 4, Qt.LeftButton) + compare(tumbler.moving, true) + tryCompare(tumbler, "moving", false) + } } |