diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-05-20 18:19:11 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-05-23 06:59:15 +0000 |
commit | 83a91bc0738dd9336a36a230ebd8c5cacbff65bc (patch) | |
tree | d76745c5dc25b9786be8ac287e0b99b002654457 /src | |
parent | aefb24193809b473d8d3d137b678bcdc87dd52f6 (diff) |
StackView::clear() allow specifying a transition
This turns out to be a useful feature wanted for the Coffee Machine
demo, which is being cleaned up.
[ChangeLog][Controls][StackView] Allowed specifying a transition
when clearing the stack view.
Change-Id: I12ed18ca24c247980bab1fe93e1810c0d25d85e7
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quicktemplates2/qquickstackview.cpp | 24 | ||||
-rw-r--r-- | src/quicktemplates2/qquickstackview_p.h | 2 |
2 files changed, 22 insertions, 4 deletions
diff --git a/src/quicktemplates2/qquickstackview.cpp b/src/quicktemplates2/qquickstackview.cpp index 155f5f4d..e1740273 100644 --- a/src/quicktemplates2/qquickstackview.cpp +++ b/src/quicktemplates2/qquickstackview.cpp @@ -780,13 +780,31 @@ void QQuickStackView::replace(QQmlV4Function *args) } /*! - \qmlmethod void QtQuick.Controls::StackView::clear() + \qmlmethod void QtQuick.Controls::StackView::clear(transition) - Removes all items from the stack. No animations are applied. + Removes all items from the stack. + + Since QtQuick.Controls 2.3, a \a transition can be optionally specified. Supported transitions: + + \value StackView.Immediate Clear the stack immediately without any transition (default). + \value StackView.PushTransition Clear the stack with a push transition. + \value StackView.ReplaceTransition Clear the stack with a replace transition. + \value StackView.PopTransition Clear the stack with a pop transition. */ -void QQuickStackView::clear() +void QQuickStackView::clear(Operation operation) { Q_D(QQuickStackView); + if (d->elements.isEmpty()) + return; + + if (operation != Immediate) { + QQuickStackElement *exit = d->elements.pop(); + exit->removal = true; + d->removing.insert(exit); + d->startTransition(QQuickStackTransition::popExit(operation, exit, this), + QQuickStackTransition::popEnter(operation, nullptr, this), false); + } + d->setCurrentItem(nullptr); qDeleteAll(d->elements); d->elements.clear(); diff --git a/src/quicktemplates2/qquickstackview_p.h b/src/quicktemplates2/qquickstackview_p.h index b74a162d..22392698 100644 --- a/src/quicktemplates2/qquickstackview_p.h +++ b/src/quicktemplates2/qquickstackview_p.h @@ -135,7 +135,7 @@ public: Q_INVOKABLE void replace(QQmlV4Function *args); public Q_SLOTS: - void clear(); + void clear(Operation operation = Immediate); Q_SIGNALS: void busyChanged(); |