on 75b8c19 help sign in
unity8/qml/Tutorial/TutorialPage.qml
120 lines 3.0 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.4
18import Ubuntu.Components 1.3
19import "../Components"
21Showable {
22 id: root
24 property alias arrow: arrow
25 property alias label: label
26 property alias background: background
27 property alias mouseArea: mouseArea
28 property real opacityOverride: 1
29 property bool paused
30 property bool isReady
32 signal finished()
34 ////
36 QtObject {
37 id: d
38 property bool showOnUnpause
39 }
41 visible: false
42 shown: false
44 opacity: Math.max(Math.min(_showOpacity, opacityOverride), 0)
45 onOpacityOverrideChanged: {
46 if (opacityOverride <= 0) {
47 d.showOnUnpause = false;
48 hide();
49 }
50 }
51 property real _showOpacity: 0
53 onPausedChanged: {
54 if (paused && shown) {
55 d.showOnUnpause = true;
56 hide();
57 } else if (!paused && d.showOnUnpause) {
58 if (isReady) {
59 show();
60 } else if (hideAnimation.running) {
61 hideAnimation.stop();
62 }
63 d.showOnUnpause = false;
64 }
65 }
67 showAnimation: StandardAnimation {
68 property: "_showOpacity"
69 from: 0
70 to: 1
71 duration: UbuntuAnimation.SleepyDuration
72 onStarted: root.visible = true
73 }
75 hideAnimation: StandardAnimation {
76 property: "_showOpacity"
77 to: 0
78 duration: UbuntuAnimation.BriskDuration
79 onStopped: {
80 root.visible = false;
81 if (!d.showOnUnpause) {
82 root.finished();
83 }
84 }
85 }
87 MouseArea { // eat any errant presses
88 id: mouseArea
89 anchors.fill: parent
90 }
92 Image {
93 id: background
94 // Use x/y/height/width instead of anchors so that we don't adjust
95 // the image if the OSK appears.
96 x: 0
97 y: 0
98 height: root.height
99 width: root.width
100 fillMode: Image.PreserveAspectCrop
101 }
103 Image {
104 id: arrow
105 width: units.gu(1.5)
106 source: Qt.resolvedUrl("graphics/arrow.svg")
107 fillMode: Image.PreserveAspectFit
108 mipmap: true
109 }
111 Label {
112 id: label
113 objectName: "tutorialLabel"
114 fontSize: "large"
115 font.weight: Font.Light
116 color: "#333333"
117 wrapMode: Text.Wrap
118 lineHeight: 1.2
119 }