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/quicktemplates2/qquickstackview.cpp | |
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/quicktemplates2/qquickstackview.cpp')
-rw-r--r-- | src/quicktemplates2/qquickstackview.cpp | 24 |
1 files changed, 21 insertions, 3 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(); |