diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2016-05-23 09:54:56 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-05-23 09:49:04 +0000 |
commit | 11d5a011e87b9137b33626032eed336b999395a0 (patch) | |
tree | 9aaeaa1046223bb357a5f1d2f55710cf95a5c0f6 | |
parent | d5dd0409f3d2e84289207a7b191ddc0cf1e79771 (diff) |
SwipeDelegate: rename exposure to swipe, active to complete
"swipe" is both shorter and easier to understand.
"complete" is easier to understand.
Task-number: QTBUG-53519
Change-Id: I87ecba4ac878f033111ee56fa618b80b227858a7
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
10 files changed, 364 insertions, 364 deletions
diff --git a/examples/quickcontrols2/gallery/pages/DelegatePage.qml b/examples/quickcontrols2/gallery/pages/DelegatePage.qml index c3fa06c5..3d175fd8 100644 --- a/examples/quickcontrols2/gallery/pages/DelegatePage.qml +++ b/examples/quickcontrols2/gallery/pages/DelegatePage.qml @@ -70,13 +70,13 @@ Pane { text: labelText width: parent.width - onClicked: if (exposure.active) view.model.remove(ourIndex) + onClicked: if (swipe.complete) view.model.remove(ourIndex) Component { id: removeComponent Rectangle { - color: swipeDelegate.exposed && swipeDelegate.pressed ? "#333" : "#444" + color: swipeDelegate.swipe.complete && swipeDelegate.pressed ? "#333" : "#444" width: parent.width height: parent.height clip: true @@ -90,8 +90,8 @@ Pane { } } - exposure.left: removeComponent - exposure.right: removeComponent + swipe.left: removeComponent + swipe.right: removeComponent } } diff --git a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml index bd58de8b..ae63efed 100644 --- a/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml +++ b/src/imports/controls/doc/snippets/qtquickcontrols2-swipedelegate-custom.qml @@ -37,7 +37,7 @@ SwipeDelegate { id: component Rectangle { - color: control.exposure.active && control.down ? "#333" : "#444" + color: control.swipe.complete && control.down ? "#333" : "#444" width: parent.width height: parent.height clip: true @@ -50,8 +50,8 @@ SwipeDelegate { } } - exposure.left: component - exposure.right: component + swipe.left: component + swipe.right: component contentItem: Text { text: control.text diff --git a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc index 19f1889e..559c89f0 100644 --- a/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc +++ b/src/imports/controls/doc/src/qtquickcontrols2-customize.qdoc @@ -585,7 +585,7 @@ SwipeDelegate consists of six visual items: \l {Control::background}{background}, \l {Control::contentItem}{content item}, \l {AbstractButton::indicator}{indicator}, - \c exposure.left, \c exposure.right, and \c exposure.behind. + \c swipe.left, \c swipe.right, and \c swipe.behind. \image qtquickcontrols2-swipedelegate-custom.png diff --git a/src/imports/templates/qtquicktemplates2plugin.cpp b/src/imports/templates/qtquicktemplates2plugin.cpp index 3f05d31e..7efddb3c 100644 --- a/src/imports/templates/qtquicktemplates2plugin.cpp +++ b/src/imports/templates/qtquicktemplates2plugin.cpp @@ -141,7 +141,7 @@ void QtQuickTemplates2Plugin::registerTypes(const char *uri) qmlRegisterType<QQuickSpinButton>(); qmlRegisterType<QQuickStackView>(uri, 2, 0, "StackView"); qmlRegisterType<QQuickSwipeDelegate>(uri, 2, 0, "SwipeDelegate"); - qmlRegisterType<QQuickSwipeExposure>(); + qmlRegisterType<QQuickSwipe>(); qmlRegisterType<QQuickSwipeViewAttached>(); qmlRegisterType<QQuickSwipeView>(uri, 2, 0, "SwipeView"); qmlRegisterType<QQuickSwitch>(uri, 2, 0, "Switch"); diff --git a/src/quicktemplates2/qquickswipedelegate.cpp b/src/quicktemplates2/qquickswipedelegate.cpp index 683e6790..bdc211f2 100644 --- a/src/quicktemplates2/qquickswipedelegate.cpp +++ b/src/quicktemplates2/qquickswipedelegate.cpp @@ -63,27 +63,27 @@ QT_BEGIN_NAMESPACE Information regarding the progress of a swipe, as well as the components that should be shown upon swiping, are both available through the - \l {SwipeDelegate::}{exposure} grouped property object. For example, - \c exposure.position holds the position of the - swipe within the range \c -1.0 to \c 1.0. The \c exposure.left + \l {SwipeDelegate::}{swipe} grouped property object. For example, + \c swipe.position holds the position of the + swipe within the range \c -1.0 to \c 1.0. The \c swipe.left property determines which item will be displayed when the control is swiped - to the right, and vice versa for \c exposure.right. The positioning of these + to the right, and vice versa for \c swipe.right. The positioning of these components is left to applications to decide. For example, without specifying - any position for \c exposure.left or \c exposure.right, the following will + any position for \c swipe.left or \c swipe.right, the following will occur: \image qtquickcontrols2-swipedelegate.gif - If \c exposure.left and \c exposure.right are anchored to the left and + If \c swipe.left and \c swipe.right are anchored to the left and right of the \l background item (respectively), they'll behave like this: \image qtquickcontrols2-swipedelegate-leading-trailing.gif - When using \c exposure.left and \c exposure.right, the control cannot be + When using \c swipe.left and \c swipe.right, the control cannot be swiped past the left and right edges. To achieve this type of "wrapping" - behavior, set \c exposure.behind instead. This will result in the same + behavior, set \c swipe.behind instead. This will result in the same item being shown regardless of which direction the control is swiped. For - example, in the image below, we set \c exposure.behind and then swipe the + example, in the image below, we set \c swipe.behind and then swipe the control repeatedly in both directions: \image qtquickcontrols2-swipedelegate-behind.gif @@ -91,17 +91,17 @@ QT_BEGIN_NAMESPACE \sa {Customizing SwipeDelegate} */ -class QQuickSwipeExposurePrivate : public QObjectPrivate +class QQuickSwipePrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QQuickSwipeExposure) + Q_DECLARE_PUBLIC(QQuickSwipe) public: - QQuickSwipeExposurePrivate(QQuickSwipeDelegate *control) : + QQuickSwipePrivate(QQuickSwipeDelegate *control) : control(control), positionBeforePress(0), position(0), - wasActive(false), - active(false), + wasComplete(false), + complete(false), left(nullptr), behind(nullptr), right(nullptr), @@ -111,7 +111,7 @@ public: { } - static QQuickSwipeExposurePrivate *get(QQuickSwipeExposure *exposure); + static QQuickSwipePrivate *get(QQuickSwipe *swipe); QQuickItem *createDelegateItem(QQmlComponent *component); QQuickItem *showRelevantItemForPosition(qreal position); @@ -131,10 +131,10 @@ public: // keep track of which direction the user must swipe when using left and right delegates. qreal positionBeforePress; qreal position; - // A "less strict" version of active that is true if active was true + // A "less strict" version of complete that is true if complete was true // before the last press event. - bool wasActive; - bool active; + bool wasComplete; + bool complete; QQuickVelocityCalculator velocityCalculator; QQmlComponent *left; QQmlComponent *behind; @@ -144,12 +144,12 @@ public: QQuickItem *rightItem; }; -QQuickSwipeExposurePrivate *QQuickSwipeExposurePrivate::get(QQuickSwipeExposure *exposure) +QQuickSwipePrivate *QQuickSwipePrivate::get(QQuickSwipe *swipe) { - return exposure->d_func(); + return swipe->d_func(); } -QQuickItem *QQuickSwipeExposurePrivate::createDelegateItem(QQmlComponent *component) +QQuickItem *QQuickSwipePrivate::createDelegateItem(QQmlComponent *component) { // If we don't use the correct context, it won't be possible to refer to // the control's id from within the delegates. @@ -168,7 +168,7 @@ QQuickItem *QQuickSwipeExposurePrivate::createDelegateItem(QQmlComponent *compon return item; } -QQuickItem *QQuickSwipeExposurePrivate::showRelevantItemForPosition(qreal position) +QQuickItem *QQuickSwipePrivate::showRelevantItemForPosition(qreal position) { if (qFuzzyIsNull(position)) return nullptr; @@ -191,7 +191,7 @@ QQuickItem *QQuickSwipeExposurePrivate::showRelevantItemForPosition(qreal positi return nullptr; } -QQuickItem *QQuickSwipeExposurePrivate::createRelevantItemForDistance(qreal distance) +QQuickItem *QQuickSwipePrivate::createRelevantItemForDistance(qreal distance) { if (qFuzzyIsNull(distance)) return nullptr; @@ -233,37 +233,37 @@ QQuickItem *QQuickSwipeExposurePrivate::createRelevantItemForDistance(qreal dist return nullptr; } -void QQuickSwipeExposurePrivate::createLeftItem() +void QQuickSwipePrivate::createLeftItem() { if (!leftItem) { - Q_Q(QQuickSwipeExposure); + Q_Q(QQuickSwipe); q->setLeftItem(createDelegateItem(left)); if (!leftItem) qmlInfo(control) << "Failed to create left item:" << left->errors(); } } -void QQuickSwipeExposurePrivate::createBehindItem() +void QQuickSwipePrivate::createBehindItem() { if (!behindItem) { - Q_Q(QQuickSwipeExposure); + Q_Q(QQuickSwipe); q->setBehindItem(createDelegateItem(behind)); if (!behindItem) qmlInfo(control) << "Failed to create behind item:" << behind->errors(); } } -void QQuickSwipeExposurePrivate::createRightItem() +void QQuickSwipePrivate::createRightItem() { if (!rightItem) { - Q_Q(QQuickSwipeExposure); + Q_Q(QQuickSwipe); q->setRightItem(createDelegateItem(right)); if (!rightItem) qmlInfo(control) << "Failed to create right item:" << right->errors(); } } -void QQuickSwipeExposurePrivate::createAndShowLeftItem() +void QQuickSwipePrivate::createAndShowLeftItem() { createLeftItem(); @@ -274,7 +274,7 @@ void QQuickSwipeExposurePrivate::createAndShowLeftItem() rightItem->setVisible(false); } -void QQuickSwipeExposurePrivate::createAndShowBehindItem() +void QQuickSwipePrivate::createAndShowBehindItem() { createBehindItem(); @@ -282,7 +282,7 @@ void QQuickSwipeExposurePrivate::createAndShowBehindItem() behindItem->setVisible(true); } -void QQuickSwipeExposurePrivate::createAndShowRightItem() +void QQuickSwipePrivate::createAndShowRightItem() { createRightItem(); @@ -295,30 +295,30 @@ void QQuickSwipeExposurePrivate::createAndShowRightItem() leftItem->setVisible(false); } -void QQuickSwipeExposurePrivate::warnAboutMixingDelegates() +void QQuickSwipePrivate::warnAboutMixingDelegates() { qmlInfo(control) << "cannot set both behind and left/right properties"; } -void QQuickSwipeExposurePrivate::warnAboutSettingDelegatesWhileVisible() +void QQuickSwipePrivate::warnAboutSettingDelegatesWhileVisible() { - qmlInfo(control) << "left/right/behind properties may only be set when exposure.position is 0"; + qmlInfo(control) << "left/right/behind properties may only be set when swipe.position is 0"; } -QQuickSwipeExposure::QQuickSwipeExposure(QQuickSwipeDelegate *control) : - QObject(*(new QQuickSwipeExposurePrivate(control))) +QQuickSwipe::QQuickSwipe(QQuickSwipeDelegate *control) : + QObject(*(new QQuickSwipePrivate(control))) { } -QQmlComponent *QQuickSwipeExposure::left() const +QQmlComponent *QQuickSwipe::left() const { - Q_D(const QQuickSwipeExposure); + Q_D(const QQuickSwipe); return d->left; } -void QQuickSwipeExposure::setLeft(QQmlComponent *left) +void QQuickSwipe::setLeft(QQmlComponent *left) { - Q_D(QQuickSwipeExposure); + Q_D(QQuickSwipe); if (left == d->left) return; @@ -342,15 +342,15 @@ void QQuickSwipeExposure::setLeft(QQmlComponent *left) emit leftChanged(); } -QQmlComponent *QQuickSwipeExposure::behind() const +QQmlComponent *QQuickSwipe::behind() const { - Q_D(const QQuickSwipeExposure); + Q_D(const QQuickSwipe); return d->behind; } -void QQuickSwipeExposure::setBehind(QQmlComponent *behind) +void QQuickSwipe::setBehind(QQmlComponent *behind) { - Q_D(QQuickSwipeExposure); + Q_D(QQuickSwipe); if (behind == d->behind) return; @@ -374,15 +374,15 @@ void QQuickSwipeExposure::setBehind(QQmlComponent *behind) emit behindChanged(); } -QQmlComponent *QQuickSwipeExposure::right() const +QQmlComponent *QQuickSwipe::right() const { - Q_D(const QQuickSwipeExposure); + Q_D(const QQuickSwipe); return d->right; } -void QQuickSwipeExposure::setRight(QQmlComponent *right) +void QQuickSwipe::setRight(QQmlComponent *right) { - Q_D(QQuickSwipeExposure); + Q_D(QQuickSwipe); if (right == d->right) return; @@ -406,15 +406,15 @@ void QQuickSwipeExposure::setRight(QQmlComponent *right) emit rightChanged(); } -QQuickItem *QQuickSwipeExposure::leftItem() const +QQuickItem *QQuickSwipe::leftItem() const { - Q_D(const QQuickSwipeExposure); + Q_D(const QQuickSwipe); return d->leftItem; } -void QQuickSwipeExposure::setLeftItem(QQuickItem *item) +void QQuickSwipe::setLeftItem(QQuickItem *item) { - Q_D(QQuickSwipeExposure); + Q_D(QQuickSwipe); if (item == d->leftItem) return; @@ -431,15 +431,15 @@ void QQuickSwipeExposure::setLeftItem(QQuickItem *item) emit leftItemChanged(); } -QQuickItem *QQuickSwipeExposure::behindItem() const +QQuickItem *QQuickSwipe::behindItem() const { - Q_D(const QQuickSwipeExposure); + Q_D(const QQuickSwipe); return d->behindItem; } -void QQuickSwipeExposure::setBehindItem(QQuickItem *item) +void QQuickSwipe::setBehindItem(QQuickItem *item) { - Q_D(QQuickSwipeExposure); + Q_D(QQuickSwipe); if (item == d->behindItem) return; @@ -456,15 +456,15 @@ void QQuickSwipeExposure::setBehindItem(QQuickItem *item) emit behindItemChanged(); } -QQuickItem *QQuickSwipeExposure::rightItem() const +QQuickItem *QQuickSwipe::rightItem() const { - Q_D(const QQuickSwipeExposure); + Q_D(const QQuickSwipe); return d->rightItem; } -void QQuickSwipeExposure::setRightItem(QQuickItem *item) +void QQuickSwipe::setRightItem(QQuickItem *item) { - Q_D(QQuickSwipeExposure); + Q_D(QQuickSwipe); if (item == d->rightItem) return; @@ -481,15 +481,15 @@ void QQuickSwipeExposure::setRightItem(QQuickItem *item) emit rightItemChanged(); } -qreal QQuickSwipeExposure::position() const +qreal QQuickSwipe::position() const { - Q_D(const QQuickSwipeExposure); + Q_D(const QQuickSwipe); return d->position; } -void QQuickSwipeExposure::setPosition(qreal position) +void QQuickSwipe::setPosition(qreal position) { - Q_D(QQuickSwipeExposure); + Q_D(QQuickSwipe); const qreal adjustedPosition = qBound<qreal>(-1.0, position, 1.0); if (adjustedPosition == d->position) return; @@ -505,20 +505,20 @@ void QQuickSwipeExposure::setPosition(qreal position) emit positionChanged(); } -bool QQuickSwipeExposure::isActive() const +bool QQuickSwipe::isComplete() const { - Q_D(const QQuickSwipeExposure); - return d->active; + Q_D(const QQuickSwipe); + return d->complete; } -void QQuickSwipeExposure::setActive(bool active) +void QQuickSwipe::setComplete(bool complete) { - Q_D(QQuickSwipeExposure); - if (active == d->active) + Q_D(QQuickSwipe); + if (complete == d->complete) return; - d->active = active; - emit activeChanged(); + d->complete = complete; + emit completeChanged(); } class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate @@ -527,7 +527,7 @@ class QQuickSwipeDelegatePrivate : public QQuickItemDelegatePrivate public: QQuickSwipeDelegatePrivate(QQuickSwipeDelegate *control) : - exposure(control) + swipe(control) { } @@ -537,23 +537,23 @@ public: void resizeContent() override; - QQuickSwipeExposure exposure; + QQuickSwipe swipe; }; bool QQuickSwipeDelegatePrivate::handleMousePressEvent(QQuickItem *item, QMouseEvent *event) { Q_Q(QQuickSwipeDelegate); - QQuickSwipeExposurePrivate *exposurePrivate = QQuickSwipeExposurePrivate::get(&exposure); + QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe); // If the position is 0, we want to handle events ourself - we don't want child items to steal them. // This code will only get called when a child item has been created; // events will go through the regular channels (mousePressEvent()) until then. - if (qFuzzyIsNull(exposurePrivate->position)) { + if (qFuzzyIsNull(swipePrivate->position)) { q->mousePressEvent(event); return true; } - exposurePrivate->positionBeforePress = exposurePrivate->position; - exposurePrivate->velocityCalculator.startMeasuring(event->pos(), event->timestamp()); + swipePrivate->positionBeforePress = swipePrivate->position; + swipePrivate->velocityCalculator.startMeasuring(event->pos(), event->timestamp()); pressPoint = item->mapToItem(q, event->pos()); return false; } @@ -572,8 +572,8 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv return false; // Don't bother reacting to events if we don't have any delegates. - QQuickSwipeExposurePrivate *exposurePrivate = QQuickSwipeExposurePrivate::get(&exposure); - if (!exposurePrivate->left && !exposurePrivate->right && !exposurePrivate->behind) + QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe); + if (!swipePrivate->left && !swipePrivate->right && !swipePrivate->behind) return false; // Don't handle move events for the control if it wasn't pressed. @@ -591,7 +591,7 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv q->grabMouse(); q->setKeepMouseGrab(overThreshold); q->setPressed(true); - exposure.setActive(false); + swipe.setComplete(false); } } } @@ -601,15 +601,15 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv // to the left when the left item is already exposed, and vice versa. // The code below assumes that the drag is valid, so if we don't have this check, // the wrong items are visible and the swiping wraps. - if (exposurePrivate->behind - || ((exposurePrivate->left || exposurePrivate->right) - && (qFuzzyIsNull(exposurePrivate->positionBeforePress) - || (exposurePrivate->positionBeforePress == -1.0 && distance >= 0.0) - || (exposurePrivate->positionBeforePress == 1.0 && distance <= 0.0)))) { + if (swipePrivate->behind + || ((swipePrivate->left || swipePrivate->right) + && (qFuzzyIsNull(swipePrivate->positionBeforePress) + || (swipePrivate->positionBeforePress == -1.0 && distance >= 0.0) + || (swipePrivate->positionBeforePress == 1.0 && distance <= 0.0)))) { // We must instantiate the items here so that we can calculate the // position against the width of the relevant item. - QQuickItem *relevantItem = exposurePrivate->createRelevantItemForDistance(distance); + QQuickItem *relevantItem = swipePrivate->createRelevantItemForDistance(distance); // If there isn't any relevant item, the user may have swiped back to the 0 position, // or they swiped back to a position that is equal to positionBeforePress. const qreal normalizedDistance = relevantItem ? distance / relevantItem->width() : 0.0; @@ -633,14 +633,14 @@ bool QQuickSwipeDelegatePrivate::handleMouseMoveEvent(QQuickItem *item, QMouseEv // to the left by the exact width of the left item, there won't be any relevant item // (because the swipe's position would be at 0.0). In turn, the normalizedDistance // would be 0 (because of the lack of a relevant item), but the distance will be non-zero. - position = qFuzzyIsNull(distance) ? exposurePrivate->positionBeforePress : 0; - } else if (!exposurePrivate->wasActive) { + position = qFuzzyIsNull(distance) ? swipePrivate->positionBeforePress : 0; + } else if (!swipePrivate->wasComplete) { position = normalizedDistance; } else { position = distance > 0 ? normalizedDistance - 1.0 : normalizedDistance + 1.0; } - exposure.setPosition(position); + swipe.setPosition(position); } } @@ -654,25 +654,25 @@ static const qreal exposeVelocityThreshold = 300.0; bool QQuickSwipeDelegatePrivate::handleMouseReleaseEvent(QQuickItem *, QMouseEvent *event) { Q_Q(QQuickSwipeDelegate); - QQuickSwipeExposurePrivate *exposurePrivate = QQuickSwipeExposurePrivate::get(&exposure); - exposurePrivate->velocityCalculator.stopMeasuring(event->pos(), event->timestamp()); + QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe); + swipePrivate->velocityCalculator.stopMeasuring(event->pos(), event->timestamp()); // The control can be exposed by either swiping past the halfway mark, or swiping fast enough. - const qreal swipeVelocity = exposurePrivate->velocityCalculator.velocity().x(); - if (exposurePrivate->position > 0.5 || - (exposurePrivate->position > 0.0 && swipeVelocity > exposeVelocityThreshold)) { - exposure.setPosition(1.0); - exposure.setActive(true); - exposurePrivate->wasActive = true; - } else if (exposurePrivate->position < -0.5 || - (exposurePrivate->position < 0.0 && swipeVelocity < -exposeVelocityThreshold)) { - exposure.setPosition(-1.0); - exposure.setActive(true); - exposurePrivate->wasActive = true; + const qreal swipeVelocity = swipePrivate->velocityCalculator.velocity().x(); + if (swipePrivate->position > 0.5 || + (swipePrivate->position > 0.0 && swipeVelocity > exposeVelocityThreshold)) { + swipe.setPosition(1.0); + swipe.setComplete(true); + swipePrivate->wasComplete = true; + } else if (swipePrivate->position < -0.5 || + (swipePrivate->position < 0.0 && swipeVelocity < -exposeVelocityThreshold)) { + swipe.setPosition(-1.0); + swipe.setComplete(true); + swipePrivate->wasComplete = true; } else { - exposure.setPosition(0.0); - exposure.setActive(false); - exposurePrivate->wasActive = false; + swipe.setPosition(0.0); + swipe.setComplete(false); + swipePrivate->wasComplete = false; } q->setKeepMouseGrab(false); @@ -686,8 +686,8 @@ void QQuickSwipeDelegatePrivate::resizeContent() // of the control (we clip anything outside the bounds), we don't want // to call QQuickControlPrivate's implementation of this function, // as it repositions the contentItem to be visible. - QQuickSwipeExposurePrivate *exposurePrivate = QQuickSwipeExposurePrivate::get(&exposure); - if (!exposurePrivate->active) { + QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&swipe); + if (!swipePrivate->complete) { QQuickAbstractButtonPrivate::resizeContent(); } } @@ -699,15 +699,15 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) : } /*! - \qmlpropertygroup QtQuick.Controls::SwipeDelegate::exposure - \qmlproperty real QtQuick.Controls::SwipeDelegate::exposure.position - \qmlproperty bool QtQuick.Controls::SwipeDelegate::exposure.active - \qmlproperty Component QtQuick.Controls::SwipeDelegate::exposure.left - \qmlproperty Component QtQuick.Controls::SwipeDelegate::exposure.behind - \qmlproperty Component QtQuick.Controls::SwipeDelegate::exposure.right - \qmlproperty Item QtQuick.Controls::SwipeDelegate::exposure.leftItem - \qmlproperty Item QtQuick.Controls::SwipeDelegate::exposure.behindItem - \qmlproperty Item QtQuick.Controls::SwipeDelegate::exposure.rightItem + \qmlpropertygroup QtQuick.Controls::SwipeDelegate::swipe + \qmlproperty real QtQuick.Controls::SwipeDelegate::swipe.position + \qmlproperty bool QtQuick.Controls::SwipeDelegate::swipe.complete + \qmlproperty Component QtQuick.Controls::SwipeDelegate::swipe.left + \qmlproperty Component QtQuick.Controls::SwipeDelegate::swipe.behind + \qmlproperty Component QtQuick.Controls::SwipeDelegate::swipe.right + \qmlproperty Item QtQuick.Controls::SwipeDelegate::swipe.leftItem + \qmlproperty Item QtQuick.Controls::SwipeDelegate::swipe.behindItem + \qmlproperty Item QtQuick.Controls::SwipeDelegate::swipe.rightItem \table \header @@ -718,14 +718,14 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) : \li This property holds the position of the swipe relative to either side of the control. When this value reaches either \c -1.0 (left side) or \c 1.0 (right side) and the mouse button is - released, \c active will be \c true. + released, \c complete will be \c true. \row - \li active - \li This property holds whether the control is fully exposed. It is - equivalent to \c {!pressed && (position == -1.0 || position == 1.0)}. + \li complete + \li This property holds whether the control is fully exposed after + having been swiped to the left or right. - When active is \c true, any interactive items declared in \l left - or \l right will receive mouse events. + When complete is \c true, any interactive items declared in \l left, + \l right, or \l behind will receive mouse events. \row \li left \li This property holds the left delegate. @@ -771,10 +771,10 @@ QQuickSwipeDelegate::QQuickSwipeDelegate(QQuickItem *parent) : \sa {Control::}{contentItem}, {Control::}{background} */ -QQuickSwipeExposure *QQuickSwipeDelegate::exposure() const +QQuickSwipe *QQuickSwipeDelegate::swipe() const { Q_D(const QQuickSwipeDelegate); - return const_cast<QQuickSwipeExposure*>(&d->exposure); + return const_cast<QQuickSwipe*>(&d->swipe); } static bool isChildOrGrandchildOf(QQuickItem *child, QQuickItem *item) @@ -790,9 +790,9 @@ bool QQuickSwipeDelegate::childMouseEventFilter(QQuickItem *child, QEvent *event // items before these items won't allow us to get mouse events when the control is not currently exposed // but has been previously. Therefore, we instead call setFiltersChildMouseEvents(true) in the constructor // and filter out child events only when the child is the left/right/behind item. - const QQuickSwipeExposurePrivate *exposurePrivate = QQuickSwipeExposurePrivate::get(&d->exposure); - if (!isChildOrGrandchildOf(child, exposurePrivate->leftItem) && !isChildOrGrandchildOf(child, exposurePrivate->behindItem) - && !isChildOrGrandchildOf(child, exposurePrivate->rightItem)) { + const QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&d->swipe); + if (!isChildOrGrandchildOf(child, swipePrivate->leftItem) && !isChildOrGrandchildOf(child, swipePrivate->behindItem) + && !isChildOrGrandchildOf(child, swipePrivate->rightItem)) { return false; } @@ -818,9 +818,9 @@ void QQuickSwipeDelegate::mousePressEvent(QMouseEvent *event) { Q_D(QQuickSwipeDelegate); QQuickItemDelegate::mousePressEvent(event); - QQuickSwipeExposurePrivate *exposurePrivate = QQuickSwipeExposurePrivate::get(&d->exposure); - exposurePrivate->positionBeforePress = exposurePrivate->position; - exposurePrivate->velocityCalculator.startMeasuring(event->pos(), event->timestamp()); + QQuickSwipePrivate *swipePrivate = QQuickSwipePrivate::get(&d->swipe); + swipePrivate->positionBeforePress = swipePrivate->position; + swipePrivate->velocityCalculator.startMeasuring(event->pos(), event->timestamp()); } void QQuickSwipeDelegate::mouseMoveEvent(QMouseEvent *event) diff --git a/src/quicktemplates2/qquickswipedelegate_p.h b/src/quicktemplates2/qquickswipedelegate_p.h index fe4fd05d..b2bea3eb 100644 --- a/src/quicktemplates2/qquickswipedelegate_p.h +++ b/src/quicktemplates2/qquickswipedelegate_p.h @@ -53,17 +53,17 @@ QT_BEGIN_NAMESPACE class QQuickSwipeDelegatePrivate; -class QQuickSwipeExposure; +class QQuickSwipe; class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeDelegate : public QQuickItemDelegate { Q_OBJECT - Q_PROPERTY(QQuickSwipeExposure *exposure READ exposure CONSTANT) + Q_PROPERTY(QQuickSwipe *swipe READ swipe CONSTANT) public: explicit QQuickSwipeDelegate(QQuickItem *parent = nullptr); - QQuickSwipeExposure *exposure() const; + QQuickSwipe *swipe() const; protected: bool childMouseEventFilter(QQuickItem *child, QEvent *event) override; @@ -82,13 +82,13 @@ private: Q_DECLARE_PRIVATE(QQuickSwipeDelegate) }; -class QQuickSwipeExposurePrivate; +class QQuickSwipePrivate; -class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeExposure : public QObject +class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipe : public QObject { Q_OBJECT Q_PROPERTY(qreal position READ position NOTIFY positionChanged FINAL) - Q_PROPERTY(bool active READ isActive NOTIFY activeChanged FINAL) + Q_PROPERTY(bool complete READ isComplete NOTIFY completeChanged FINAL) Q_PROPERTY(QQmlComponent *left READ left WRITE setLeft NOTIFY leftChanged FINAL) Q_PROPERTY(QQmlComponent *behind READ behind WRITE setBehind NOTIFY behindChanged FINAL) Q_PROPERTY(QQmlComponent *right READ right WRITE setRight NOTIFY rightChanged FINAL) @@ -97,13 +97,13 @@ class Q_QUICKTEMPLATES2_PRIVATE_EXPORT QQuickSwipeExposure : public QObject Q_PROPERTY(QQuickItem *rightItem READ rightItem NOTIFY rightItemChanged FINAL) public: - explicit QQuickSwipeExposure(QQuickSwipeDelegate *control); + explicit QQuickSwipe(QQuickSwipeDelegate *control); qreal position() const; void setPosition(qreal position); - bool isActive() const; - void setActive(bool active); + bool isComplete() const; + void setComplete(bool complete); QQmlComponent *left() const; void setLeft(QQmlComponent *left); @@ -125,7 +125,7 @@ public: Q_SIGNALS: void positionChanged(); - void activeChanged(); + void completeChanged(); void leftChanged(); void behindChanged(); void rightChanged(); @@ -134,8 +134,8 @@ Q_SIGNALS: void rightItemChanged(); private: - Q_DISABLE_COPY(QQuickSwipeExposure) - Q_DECLARE_PRIVATE(QQuickSwipeExposure) + Q_DISABLE_COPY(QQuickSwipe) + Q_DECLARE_PRIVATE(QQuickSwipe) }; QT_END_NAMESPACE diff --git a/tests/auto/controls/data/tst_swipedelegate.qml b/tests/auto/controls/data/tst_swipedelegate.qml index 59b37e8d..6666589f 100644 --- a/tests/auto/controls/data/tst_swipedelegate.qml +++ b/tests/auto/controls/data/tst_swipedelegate.qml @@ -79,8 +79,8 @@ TestCase { id: swipeDelegate text: "SwipeDelegate" width: 150 - exposure.left: greenLeftComponent - exposure.right: redRightComponent + swipe.left: greenLeftComponent + swipe.right: redRightComponent } } @@ -89,9 +89,9 @@ TestCase { verify(control); compare(control.baselineOffset, control.contentItem.y + control.contentItem.baselineOffset); - compare(control.exposure.position, 0); + compare(control.swipe.position, 0); verify(!control.pressed); - verify(!control.exposure.active); + verify(!control.swipe.complete); control.destroy(); } @@ -105,25 +105,25 @@ TestCase { // Assumes that the delegate is smaller than the width of the control. function swipe(control, from, to) { // Sanity check. - compare(control.exposure.position, from); + compare(control.swipe.position, from); var distance = (to - from) * control.width; mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); mouseMove(control, control.width / 2 + distance, control.height / 2, Qt.LeftButton); mouseRelease(control, control.width / 2 + distance, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, to); - - if (control.exposure.position === -1.0) { - if (control.exposure.right) - verify(control.exposure.rightItem); - else if (control.exposure.behind) - verify(control.exposure.behindItem); - } else if (control.exposure.position === 1.0) { - if (control.exposure.left) - verify(control.exposure.leftItem); - else if (control.exposure.behind) - verify(control.exposure.behindItem); + compare(control.swipe.position, to); + + if (control.swipe.position === -1.0) { + if (control.swipe.right) + verify(control.swipe.rightItem); + else if (control.swipe.behind) + verify(control.swipe.behindItem); + } else if (control.swipe.position === 1.0) { + if (control.swipe.left) + verify(control.swipe.leftItem); + else if (control.swipe.behind) + verify(control.swipe.behindItem); } } @@ -133,57 +133,57 @@ TestCase { ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") - control.exposure.behind = itemComponent; + control.swipe.behind = itemComponent; // Shouldn't be any warnings when unsetting delegates. - control.exposure.left = null; - compare(control.exposure.leftItem, null); + control.swipe.left = null; + compare(control.swipe.leftItem, null); // right is still set. ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") - control.exposure.behind = itemComponent; + control.swipe.behind = itemComponent; - control.exposure.right = null; - compare(control.exposure.rightItem, null); + control.swipe.right = null; + compare(control.swipe.rightItem, null); - control.exposure.behind = itemComponent; + control.swipe.behind = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") - control.exposure.left = itemComponent; + control.swipe.left = itemComponent; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + ":78:9: QML SwipeDelegate: cannot set both behind and left/right properties") - control.exposure.right = itemComponent; + control.swipe.right = itemComponent; - control.exposure.behind = null; - control.exposure.left = greenLeftComponent; - control.exposure.right = redRightComponent; + control.swipe.behind = null; + control.swipe.left = greenLeftComponent; + control.swipe.right = redRightComponent; // Test that the user is warned when attempting to set or unset left or // right item while they're exposed. // First, try the left item. swipe(control, 0.0, 1.0); - var oldLeft = control.exposure.left; - var oldLeftItem = control.exposure.leftItem; + var oldLeft = control.swipe.left; + var oldLeftItem = control.swipe.leftItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when exposure.position is 0") - control.exposure.left = null; - compare(control.exposure.left, oldLeft); - compare(control.exposure.leftItem, oldLeftItem); + ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + control.swipe.left = null; + compare(control.swipe.left, oldLeft); + compare(control.swipe.leftItem, oldLeftItem); // Try the same thing with the right item. swipe(control, 1.0, -1.0); - var oldRight = control.exposure.right; - var oldRightItem = control.exposure.rightItem; + var oldRight = control.swipe.right; + var oldRightItem = control.swipe.rightItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when exposure.position is 0") - control.exposure.right = null; - compare(control.exposure.right, oldRight); - compare(control.exposure.rightItem, oldRightItem); + ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + control.swipe.right = null; + compare(control.swipe.right, oldRight); + compare(control.swipe.rightItem, oldRightItem); // Return to the default position. swipe(control, -1.0, 0.0); @@ -191,25 +191,25 @@ TestCase { tryCompare(control.background, "x", 0, 1000); // Try the same thing with the behind item. - control.exposure.left = null; - verify(!control.exposure.left); - verify(!control.exposure.leftItem); - control.exposure.right = null; - verify(!control.exposure.right); - verify(!control.exposure.rightItem); - control.exposure.behind = greenLeftComponent; - verify(control.exposure.behind); - verify(!control.exposure.behindItem); + control.swipe.left = null; + verify(!control.swipe.left); + verify(!control.swipe.leftItem); + control.swipe.right = null; + verify(!control.swipe.right); + verify(!control.swipe.rightItem); + control.swipe.behind = greenLeftComponent; + verify(control.swipe.behind); + verify(!control.swipe.behindItem); swipe(control, 0.0, 1.0); - var oldBehind = control.exposure.behind; - var oldBehindItem = control.exposure.behindItem; + var oldBehind = control.swipe.behind; + var oldBehindItem = control.swipe.behindItem; ignoreWarning(Qt.resolvedUrl("tst_swipedelegate.qml") + - ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when exposure.position is 0") - control.exposure.behind = null; - compare(control.exposure.behind, oldBehind); - compare(control.exposure.behindItem, oldBehindItem); + ":78:9: QML SwipeDelegate: left/right/behind properties may only be set when swipe.position is 0") + control.swipe.behind = null; + compare(control.swipe.behind, oldBehind); + compare(control.swipe.behindItem, oldBehindItem); control.destroy(); } @@ -229,89 +229,89 @@ TestCase { mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); - compare(control.exposure.position, 0.0); - verify(!control.exposure.active); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); verify(mouseSignalSequenceSpy.success); - verify(!control.exposure.leftItem); - verify(!control.exposure.rightItem); + verify(!control.swipe.leftItem); + verify(!control.swipe.rightItem); // Drag to the right so that leftItem is created and visible. mouseMove(control, control.width / 2 + overDragDistance, control.height / 2); verify(control.pressed); - compare(control.exposure.position, overDragDistance / control.width); - verify(!control.exposure.active); - verify(control.exposure.leftItem); - verify(control.exposure.leftItem.visible); - compare(control.exposure.leftItem.parent, control); - compare(control.exposure.leftItem.objectName, "leftItem"); - verify(!control.exposure.rightItem); + compare(control.swipe.position, overDragDistance / control.width); + verify(!control.swipe.complete); + verify(control.swipe.leftItem); + verify(control.swipe.leftItem.visible); + compare(control.swipe.leftItem.parent, control); + compare(control.swipe.leftItem.objectName, "leftItem"); + verify(!control.swipe.rightItem); // Go back to 0. mouseMove(control, control.width / 2, control.height / 2); verify(control.pressed); - compare(control.exposure.position, 0.0); - verify(!control.exposure.active); - verify(control.exposure.leftItem); - verify(control.exposure.leftItem.visible); - compare(control.exposure.leftItem.parent, control); - compare(control.exposure.leftItem.objectName, "leftItem"); - verify(!control.exposure.rightItem); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); + verify(control.swipe.leftItem); + verify(control.swipe.leftItem.visible); + compare(control.swipe.leftItem.parent, control); + compare(control.swipe.leftItem.objectName, "leftItem"); + verify(!control.swipe.rightItem); // Try the other direction. The right item should be created and visible, // and the left item should be hidden. mouseMove(control, control.width / 2 - overDragDistance, control.height / 2); verify(control.pressed); - compare(control.exposure.position, -overDragDistance / control.width); - verify(!control.exposure.active); - verify(control.exposure.leftItem); - verify(!control.exposure.leftItem.visible); - verify(control.exposure.rightItem); - verify(control.exposure.rightItem.visible); - compare(control.exposure.rightItem.parent, control); - compare(control.exposure.rightItem.objectName, "rightItem"); + compare(control.swipe.position, -overDragDistance / control.width); + verify(!control.swipe.complete); + verify(control.swipe.leftItem); + verify(!control.swipe.leftItem.visible); + verify(control.swipe.rightItem); + verify(control.swipe.rightItem.visible); + compare(control.swipe.rightItem.parent, control); + compare(control.swipe.rightItem.objectName, "rightItem"); // Now release outside the right edge of the control. mouseMove(control, control.width * 1.1, control.height / 2); verify(control.pressed); - compare(control.exposure.position, 0.6); - verify(!control.exposure.active); - verify(control.exposure.leftItem); - verify(control.exposure.leftItem.visible); - verify(control.exposure.rightItem); - verify(!control.exposure.rightItem.visible); + compare(control.swipe.position, 0.6); + verify(!control.swipe.complete); + verify(control.swipe.leftItem); + verify(control.swipe.leftItem.visible); + verify(control.swipe.rightItem); + verify(!control.swipe.rightItem.visible); mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; mouseRelease(control, control.width / 2, control.height / 2); verify(!control.pressed); - compare(control.exposure.position, 1.0); - verify(control.exposure.active); + compare(control.swipe.position, 1.0); + verify(control.swipe.complete); verify(mouseSignalSequenceSpy.success); - verify(control.exposure.leftItem); - verify(control.exposure.leftItem.visible); - verify(control.exposure.rightItem); - verify(!control.exposure.rightItem.visible); + verify(control.swipe.leftItem); + verify(control.swipe.leftItem.visible); + verify(control.swipe.rightItem); + verify(!control.swipe.rightItem.visible); tryCompare(control.contentItem, "x", control.width + control.leftPadding); // Swiping from the right and releasing early should return position to 1.0. mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); - compare(control.exposure.position, 1.0); - // exposed should still be true, because we haven't moved yet, and hence + compare(control.swipe.position, 1.0); + // complete should still be true, because we haven't moved yet, and hence // haven't started grabbing behind's mouse events. - verify(control.exposure.active); + verify(control.swipe.complete); verify(mouseSignalSequenceSpy.success); mouseMove(control, control.width / 2 - overDragDistance, control.height / 2); verify(control.pressed); - verify(!control.exposure.active); - compare(control.exposure.position, 1.0 - overDragDistance / control.width); + verify(!control.swipe.complete); + compare(control.swipe.position, 1.0 - overDragDistance / control.width); mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; mouseRelease(control, control.width * 0.4, control.height / 2); verify(!control.pressed); - compare(control.exposure.position, 1.0); - verify(control.exposure.active); + compare(control.swipe.position, 1.0); + verify(control.swipe.complete); verify(mouseSignalSequenceSpy.success); tryCompare(control.contentItem, "x", control.width + control.leftPadding); @@ -319,20 +319,20 @@ TestCase { mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); - compare(control.exposure.position, 1.0); - verify(control.exposure.active); + compare(control.swipe.position, 1.0); + verify(control.swipe.complete); verify(mouseSignalSequenceSpy.success); mouseMove(control, control.width * -0.1, control.height / 2); verify(control.pressed); - verify(!control.exposure.active); - compare(control.exposure.position, 0.4); + verify(!control.swipe.complete); + compare(control.swipe.position, 0.4); mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": false }], "released", "clicked"]; mouseRelease(control, control.width * -0.1, control.height / 2); verify(!control.pressed); - compare(control.exposure.position, 0.0); - verify(!control.exposure.active); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); verify(mouseSignalSequenceSpy.success); tryCompare(control.contentItem, "x", control.leftPadding); @@ -362,19 +362,19 @@ TestCase { mouseSignalSequenceSpy.expectedSequence = [["pressedChanged", { "pressed": true }], "pressed"]; mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); - compare(control.exposure.position, 0.0); - verify(!control.exposure.active); + compare(control.swipe.position, 0.0); + verify(!control.swipe.complete); verify(mouseSignalSequenceSpy.success); - verify(!control.exposure.leftItem); - verify(!control.exposure.rightItem); + verify(!control.swipe.leftItem); + verify(!control.swipe.rightItem); // Swipe quickly to the side over a distance that is longer than the drag threshold, // quicker than the expose velocity threshold, but shorter than the halfway mark. mouseMove(control, control.width / 2 + distance, control.height / 2); verify(control.pressed); - compare(control.exposure.position, distance / control.width); - verify(control.exposure.position < 0.5); - verify(!control.exposure.active); + compare(control.swipe.position, distance / control.width); + verify(control.swipe.position < 0.5); + verify(!control.swipe.complete); var expectedVisibleItem; var expectedVisibleObjectName; @@ -382,13 +382,13 @@ TestCase { var expectedContentItemX; if (distance > 0) { expectedVisibleObjectName = "leftItem"; - expectedVisibleItem = control.exposure.leftItem; - expectedHiddenItem = control.exposure.rightItem; + expectedVisibleItem = control.swipe.leftItem; + expectedHiddenItem = control.swipe.rightItem; expectedContentItemX = control.width + control.leftPadding; } else { expectedVisibleObjectName = "rightItem"; - expectedVisibleItem = control.exposure.rightItem; - expectedHiddenItem = control.exposure.leftItem; + expectedVisibleItem = control.swipe.rightItem; + expectedHiddenItem = control.swipe.leftItem; expectedContentItemX = -control.width + control.leftPadding; } verify(expectedVisibleItem); @@ -402,8 +402,8 @@ TestCase { // and hence that the second timestamp isn't zero (can happen with e.g. release builds). mouseRelease(control, control.width / 2 + distance, control.height / 2, Qt.LeftButton, Qt.NoModifier, 30); verify(!control.pressed); - compare(control.exposure.position, data.direction); - verify(control.exposure.active); + compare(control.swipe.position, data.direction); + verify(control.swipe.complete); verify(mouseSignalSequenceSpy.success); verify(expectedVisibleItem); verify(expectedVisibleItem.visible); @@ -418,7 +418,7 @@ TestCase { SwipeDelegate { text: "SwipeDelegate" width: 150 - exposure.right: Button { + swipe.right: Button { width: parent.width height: parent.height text: "Boo!" @@ -433,14 +433,14 @@ TestCase { // The button should be pressed instead of the SwipeDelegate. mouseDrag(control, control.width / 2, control.height / 2, -control.width, 0); verify(!control.pressed); - compare(control.exposure.position, -1.0); - verify(control.exposure.rightItem); - verify(control.exposure.rightItem.visible); - compare(control.exposure.rightItem.parent, control); + compare(control.swipe.position, -1.0); + verify(control.swipe.rightItem); + verify(control.swipe.rightItem.visible); + compare(control.swipe.rightItem.parent, control); mousePress(control, control.width / 2, control.height / 2); verify(!control.pressed); - var button = control.exposure.rightItem; + var button = control.swipe.rightItem; verify(button.pressed); mouseRelease(control, control.width / 2, control.height / 2); @@ -449,7 +449,7 @@ TestCase { // Returning back to a position of 0 and pressing on the control should // result in the control being pressed. mouseDrag(control, control.width / 2, control.height / 2, control.width * 0.6, 0); - compare(control.exposure.position, 0); + compare(control.swipe.position, 0); mousePress(control, control.width / 2, control.height / 2); verify(control.pressed); verify(!button.pressed); @@ -524,7 +524,7 @@ TestCase { text: modelData width: listView.width - onClicked: if (exposure.active) ListView.view.model.remove(index) + onClicked: if (swipe.complete) ListView.view.model.remove(index) property alias removeAnimation: onRemoveAnimation @@ -549,8 +549,8 @@ TestCase { } } - exposure.left: Rectangle { - color: rootDelegate.exposure.active && rootDelegate.pressed ? "#333" : "#444" + swipe.left: Rectangle { + color: rootDelegate.swipe.complete && rootDelegate.pressed ? "#333" : "#444" anchors.fill: parent Label { @@ -573,18 +573,18 @@ TestCase { var firstItem = listView.itemAt(0, 0); mousePress(listView, firstItem.width / 2, firstItem.height / 2); verify(firstItem.pressed); - compare(firstItem.exposure.position, 0.0); - verify(!firstItem.exposure.active); + compare(firstItem.swipe.position, 0.0); + verify(!firstItem.swipe.complete); mouseMove(listView, firstItem.width * 1.1, firstItem.height / 2); verify(firstItem.pressed); - compare(firstItem.exposure.position, 0.6); - verify(!firstItem.exposure.active); + compare(firstItem.swipe.position, 0.6); + verify(!firstItem.swipe.complete); mouseRelease(listView, firstItem.width / 2, firstItem.height / 2); verify(!firstItem.pressed); - compare(firstItem.exposure.position, 1.0); - verify(firstItem.exposure.active); + compare(firstItem.swipe.position, 1.0); + verify(firstItem.swipe.complete); compare(listView.count, 3); // Wait for it to settle down. @@ -617,14 +617,14 @@ TestCase { width: 150 text: "SwipeDelegate" - exposure.left: Rectangle { + swipe.left: Rectangle { x: delegate.background.x - width width: delegate.width height: delegate.height color: "green" } - exposure.right: Rectangle { + swipe.right: Rectangle { x: delegate.background.x + delegate.background.width width: delegate.width height: delegate.height @@ -640,14 +640,14 @@ TestCase { width: 150 text: "SwipeDelegate" - exposure.left: Rectangle { + swipe.left: Rectangle { anchors.right: delegate.background.left width: delegate.width height: delegate.height color: "green" } - exposure.right: Rectangle { + swipe.right: Rectangle { anchors.left: delegate.background.right width: delegate.width height: delegate.height @@ -669,8 +669,8 @@ TestCase { mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); mouseMove(control, control.width, control.height / 2, Qt.LeftButton); - verify(control.exposure.leftItem); - compare(control.exposure.leftItem.x, -control.width / 2); + verify(control.swipe.leftItem); + compare(control.swipe.leftItem.x, -control.width / 2); mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton); control.destroy(); @@ -683,11 +683,11 @@ TestCase { // Should be limited within the range -1.0 to 1.0. mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); mouseMove(control, control.width * 1.5, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 1.0); + compare(control.swipe.position, 1.0); mouseMove(control, control.width * 1.6, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 1.0); + compare(control.swipe.position, 1.0); mouseMove(control, control.width * -1.6, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, -1.0); + compare(control.swipe.position, -1.0); mouseRelease(control, control.width / 2, control.height / 2, Qt.LeftButton); control.destroy(); @@ -712,34 +712,34 @@ TestCase { } } - // exposure.position should be scaled to the width of the relevant delegate, + // swipe.position should be scaled to the width of the relevant delegate, // and it shouldn't be possible to drag past the delegate (so that content behind the control is visible). function test_delegateWidth() { var control = emptySwipeDelegateComponent.createObject(testCase); verify(control); - control.exposure.left = smallLeftComponent; + control.swipe.left = smallLeftComponent; // Ensure that the position is scaled to the width of the currently visible delegate. var overDragDistance = dragDistance * 1.1; mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); mouseMove(control, control.width / 2 + overDragDistance, control.height / 2, Qt.LeftButton); - verify(control.exposure.leftItem); - compare(control.exposure.position, overDragDistance / control.exposure.leftItem.width); + verify(control.swipe.leftItem); + compare(control.swipe.position, overDragDistance / control.swipe.leftItem.width); - mouseMove(control, control.width / 2 + control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 1.0); + mouseMove(control, control.width / 2 + control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, 1.0); // Ensure that it's not possible to drag past the (left) delegate. - mouseMove(control, control.width / 2 + control.exposure.leftItem.width + 1, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 1.0); + mouseMove(control, control.width / 2 + control.swipe.leftItem.width + 1, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, 1.0); // Now release over the right side; the position should be 1.0 and the background // should be "anchored" to the right side of the left delegate item. - mouseMove(control, control.width / 2 + control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); - mouseRelease(control, control.width / 2 + control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 1.0); - tryCompare(control.background, "x", control.exposure.leftItem.width, 1000); + mouseMove(control, control.width / 2 + control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); + mouseRelease(control, control.width / 2 + control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, 1.0); + tryCompare(control.background, "x", control.swipe.leftItem.width, 1000); control.destroy(); } @@ -754,51 +754,51 @@ TestCase { signalName: "visibleChanged" } - function test_positionAfterExposureMadeActive() { + function test_positionAfterSwipeCompleted() { var control = swipeDelegateComponent.createObject(testCase); verify(control); // Ensure that both delegates are constructed. mousePress(control, 0, control.height / 2, Qt.LeftButton); mouseMove(control, control.width * 1.1, control.height / 2, Qt.LeftButton); - verify(control.exposure.leftItem); + verify(control.swipe.leftItem); mouseMove(control, control.width * -0.1, control.height / 2, Qt.LeftButton); - verify(control.exposure.rightItem); + verify(control.swipe.rightItem); // Expose the left delegate. - mouseMove(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); - mouseRelease(control, control.exposure.leftItem.width, control.height / 2); - verify(control.exposure.active); - compare(control.exposure.position, 1.0); + mouseMove(control, control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); + mouseRelease(control, control.swipe.leftItem.width, control.height / 2); + verify(control.swipe.complete); + compare(control.swipe.position, 1.0); - leftVisibleSpy.target = control.exposure.leftItem; - rightVisibleSpy.target = control.exposure.rightItem; + leftVisibleSpy.target = control.swipe.leftItem; + rightVisibleSpy.target = control.swipe.rightItem; // Swipe from right to left without exposing the right item, // and make sure that the right item never becomes visible // (and hence that the left item never loses visibility). - mousePress(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + mousePress(control, control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); compare(leftVisibleSpy.count, 0); compare(rightVisibleSpy.count, 0); - var newX = control.exposure.leftItem.width - dragDistance * 1.1; + var newX = control.swipe.leftItem.width - dragDistance * 1.1; mouseMove(control, newX, control.height / 2, Qt.LeftButton, Qt.LeftButton); compare(leftVisibleSpy.count, 0); compare(rightVisibleSpy.count, 0); - compare(control.exposure.position, newX / control.exposure.leftItem.width); + compare(control.swipe.position, newX / control.swipe.leftItem.width); mouseMove(control, 0, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 0); + compare(control.swipe.position, 0); // Test swiping over a distance that is greater than the width of the left item. mouseMove(control, -1, control.height / 2, Qt.LeftButton); - verify(control.exposure.rightItem); - compare(control.exposure.position, -1 / control.exposure.rightItem.width); + verify(control.swipe.rightItem); + compare(control.swipe.position, -1 / control.swipe.rightItem.width); // Now go back to 1.0. - mouseMove(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 1.0); - tryCompare(control.background, "x", control.exposure.leftItem.width, 1000); - mouseRelease(control, control.exposure.leftItem.width, control.height / 2, Qt.LeftButton); + mouseMove(control, control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, 1.0); + tryCompare(control.background, "x", control.swipe.leftItem.width, 1000); + mouseRelease(control, control.swipe.leftItem.width, control.height / 2, Qt.LeftButton); control.destroy(); } @@ -808,22 +808,22 @@ TestCase { // id: behindSwipeDelegateComponent // SwipeDelegate { // anchors.centerIn: parent -// exposure.behind: Rectangle { +// swipe.behind: Rectangle { // onXChanged: print("x changed", x) // anchors.left: { -// print("anchors.left expression", exposure.position) -// exposure.position < 0 ? parent.background.right : undefined +// print("anchors.left expression", swipe.position) +// swipe.position < 0 ? parent.background.right : undefined // } // anchors.right: { -// print("anchors.right expression", exposure.position) -// exposure.position > 0 ? parent.background.left : undefined +// print("anchors.right expression", swipe.position) +// swipe.position > 0 ? parent.background.left : undefined // } // width: parent.width // height: parent.height // color: "green" // } -// exposure.left: null -// exposure.right: null +// swipe.left: null +// swipe.right: null // Rectangle { // anchors.fill: parent // color: "transparent" @@ -838,15 +838,15 @@ TestCase { text: "SwipeDelegate" width: 150 anchors.centerIn: parent - exposure.behind: Rectangle { - x: exposure.position < 0 ? parent.background.x + parent.background.width - : (exposure.position > 0 ? parent.background.x - width : 0) + swipe.behind: Rectangle { + x: swipe.position < 0 ? parent.background.x + parent.background.width + : (swipe.position > 0 ? parent.background.x - width : 0) width: parent.width height: parent.height color: "green" } - exposure.left: null - exposure.right: null + swipe.left: null + swipe.right: null } } @@ -855,34 +855,34 @@ TestCase { verify(control); swipe(control, 0.0, 1.0); - verify(control.exposure.behindItem.visible); - compare(control.exposure.behindItem.x, control.background.x - control.background.width); + verify(control.swipe.behindItem.visible); + compare(control.swipe.behindItem.x, control.background.x - control.background.width); swipe(control, 1.0, -1.0); - verify(control.exposure.behindItem.visible); - compare(control.exposure.behindItem.x, control.background.x + control.background.width); + verify(control.swipe.behindItem.visible); + compare(control.swipe.behindItem.x, control.background.x + control.background.width); swipe(control, -1.0, 1.0); - verify(control.exposure.behindItem.visible); - compare(control.exposure.behindItem.x, control.background.x - control.background.width); + verify(control.swipe.behindItem.visible); + compare(control.swipe.behindItem.x, control.background.x - control.background.width); // Should be possible to "wrap" with a behind delegate specified. mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); - mouseMove(control, control.width / 2 + control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, -0.2); - mouseRelease(control, control.width / 2 + control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 0.0); + mouseMove(control, control.width / 2 + control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, -0.2); + mouseRelease(control, control.width / 2 + control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, 0.0); // Try wrapping the other way. swipe(control, 0.0, -1.0); - verify(control.exposure.behindItem.visible); - compare(control.exposure.behindItem.x, control.background.x + control.background.width); + verify(control.swipe.behindItem.visible); + compare(control.swipe.behindItem.x, control.background.x + control.background.width); mousePress(control, control.width / 2, control.height / 2, Qt.LeftButton); - mouseMove(control, control.width / 2 - control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 0.2); - mouseRelease(control, control.width / 2 - control.exposure.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); - compare(control.exposure.position, 0.0); + mouseMove(control, control.width / 2 - control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, 0.2); + mouseRelease(control, control.width / 2 - control.swipe.behindItem.width * 0.8, control.height / 2, Qt.LeftButton); + compare(control.swipe.position, 0.0); control.destroy(); } diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml index 37241d25..d019368e 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-behind.qml @@ -54,9 +54,9 @@ Window { text: "SwipeDelegate" anchors.centerIn: parent - exposure.left: null - exposure.right: null - exposure.behind: Rectangle { + swipe.left: null + swipe.right: null + swipe.behind: Rectangle { width: swipeDelegate.width height: swipeDelegate.height color: swipeDelegate.pressed ? "#333" : "#444" diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml index fd56db9d..ecc7924e 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate-leading-trailing.qml @@ -54,7 +54,7 @@ Window { text: "SwipeDelegate" anchors.centerIn: parent - exposure.left: Rectangle { + swipe.left: Rectangle { width: swipeDelegate.width height: swipeDelegate.height color: swipeDelegate.pressed ? "#333" : "#444" @@ -67,7 +67,7 @@ Window { } } - exposure.right: Rectangle { + swipe.right: Rectangle { width: swipeDelegate.width height: swipeDelegate.height color: swipeDelegate.pressed ? "#333" : "#444" diff --git a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml index a7f73580..9dfee7f5 100644 --- a/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml +++ b/tests/manual/gifs/data/qtquickcontrols2-swipedelegate.qml @@ -54,7 +54,7 @@ Window { text: "SwipeDelegate" anchors.centerIn: parent - exposure.left: Rectangle { + swipe.left: Rectangle { width: swipeDelegate.width height: swipeDelegate.height color: swipeDelegate.pressed ? "#333" : "#444" @@ -66,7 +66,7 @@ Window { } } - exposure.right: Rectangle { + swipe.right: Rectangle { anchors.fill: parent width: swipeDelegate.width height: swipeDelegate.height |