on 539b375 help sign in
unity8/qml/Tutorial/TutorialContent.qml
130 lines 3.2 kB history raw
1/*
2 * Copyright (C) 2013,2014 Canonical, Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
17import QtQuick 2.3
18import Ubuntu.Components 1.1
20Item {
21 id: root
23 property Item launcher
24 property Item panel
25 property Item stages
26 property Item overlay
28 readonly property bool launcherEnabled: !running ||
29 (!paused && loader.target === leftComponent)
30 readonly property bool stagesEnabled: !running
31 readonly property bool panelEnabled: !running
32 readonly property bool panelContentEnabled: !running
33 readonly property bool running: loader.sourceComponent !== null
35 property bool paused: false
37 signal finished()
39 function finish() {
40 d.stop();
41 finished();
42 }
44 ////
46 Component.onCompleted: {
47 d.start();
48 }
50 QtObject {
51 id: d
53 function stop() {
54 loader.sourceComponent = null;
55 }
57 function start() {
58 loader.load(leftComponent);
59 }
60 }
62 Loader {
63 id: loader
64 objectName: "tutorialLoader"
66 property Component target: {
67 if (next) {
68 return next;
69 } else if (loader.item && loader.item.shown) {
70 return sourceComponent;
71 } else {
72 return null;
73 }
74 }
76 property Component next: null
78 function load(comp) {
79 if (loader.item) {
80 next = comp;
81 loader.item.hide();
82 } else {
83 loader.sourceComponent = comp;
84 }
85 }
87 Connections {
88 target: loader.item
89 onFinished: {
90 loader.sourceComponent = loader.next;
91 if (loader.next != null) {
92 loader.next = null;
93 } else {
94 root.finished();
95 }
96 }
97 }
99 Binding {
100 target: loader.item
101 property: "paused"
102 value: root.paused
103 }
104 }
106 Component {
107 id: leftComponent
108 TutorialLeft {
109 objectName: "tutorialLeft"
110 parent: root.stages
111 anchors.fill: parent
112 launcher: root.launcher
114 onFinished: loader.load(leftFinishComponent)
115 }
116 }
118 Component {
119 id: leftFinishComponent
120 TutorialLeftFinish {
121 objectName: "tutorialLeftFinish"
122 parent: root.stages
123 anchors.fill: parent
124 textXOffset: root.launcher.panelWidth
125 backgroundFadesOut: true
127 onFinished: root.launcher.hide()
128 }
129 }