Add all view
This commit is contained in:
1 parent
186cff1d73
commit
49d8524597
18 files changed
+1007
-98
No files matched your search
@@ -0,0 +1,73 @@
|
||||
import QtQuick 2.5
|
||||
import "../Components"
|
||||
|
||||
// Pile de navigation entre les écrans de Views/.
|
||||
// push("ServerAdd") charge Views/ServerAddView.qml ; la touche Retour dépile.
|
||||
// Chaque écran reçoit `navigator` et `session`, plus les propriétés passées à push().
|
||||
FocusScope {
|
||||
id: root
|
||||
|
||||
property var session: null
|
||||
property int depth: 0
|
||||
property var _stack: []
|
||||
|
||||
function push(name, props) {
|
||||
_stack.push({ name: name, props: props || {} });
|
||||
_load();
|
||||
}
|
||||
|
||||
function replace(name, props) {
|
||||
if (_stack.length > 0)
|
||||
_stack.pop();
|
||||
push(name, props);
|
||||
}
|
||||
|
||||
function pop() {
|
||||
if (_stack.length <= 1)
|
||||
return false;
|
||||
_stack.pop();
|
||||
_load();
|
||||
return true;
|
||||
}
|
||||
|
||||
function reset(name, props) {
|
||||
_stack = [];
|
||||
push(name, props);
|
||||
}
|
||||
|
||||
function _load() {
|
||||
var entry = _stack[_stack.length - 1];
|
||||
var props = { navigator: root, session: root.session };
|
||||
for (var key in entry.props)
|
||||
props[key] = entry.props[key];
|
||||
depth = _stack.length;
|
||||
loader.setSource(Qt.resolvedUrl("../Views/" + entry.name + "View.qml"), props);
|
||||
}
|
||||
|
||||
Loader {
|
||||
id: loader
|
||||
anchors.fill: parent
|
||||
focus: true
|
||||
|
||||
onLoaded: {
|
||||
fadeIn.restart();
|
||||
var target = item.initialFocus ? item.initialFocus : item;
|
||||
target.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: fadeIn
|
||||
target: loader.item
|
||||
property: "opacity"
|
||||
from: 0
|
||||
to: 1
|
||||
duration: 180
|
||||
}
|
||||
|
||||
// Retour : on dépile ; à la racine, la touche remonte (fermeture de l'app).
|
||||
Keys.onPressed: {
|
||||
if (Remote.isBack(event.key) && pop())
|
||||
event.accepted = true;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user