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