forked from papyros/qml-material
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPageStack.qml
More file actions
47 lines (39 loc) · 1.24 KB
/
Copy pathPageStack.qml
File metadata and controls
47 lines (39 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* QML Material - An application framework implementing Material Design.
*
* Copyright (C) 2014-2016 Michael Spencer <sonrisesoftware@gmail.com>
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import QtQuick 2.4
import QtQuick.Controls 1.3 as Controls
import Material 0.3
/*!
\qmltype PageStack
\inqmlmodule Material
\brief Manages the page stack used for navigation.
*/
Controls.StackView {
id: stackView
signal pushed(Item page)
signal popped(Item page)
signal replaced(Item page)
property int __lastDepth: 0
property Item __oldItem: null
onCurrentItemChanged: {
if (stackView.currentItem) {
stackView.currentItem.canGoBack = stackView.depth > 1;
stackView.currentItem.forceActiveFocus()
if (__lastDepth > stackView.depth) {
popped(stackView.currentItem);
} else if (__lastDepth < stackView.depth) {
pushed(stackView.currentItem);
} else {
replaced(stackView.currentItem);
}
}
__lastDepth = stackView.depth;
}
}