@@ -17,7 +17,10 @@
1717import QtQuick 2.4
1818import QtQuick.Layouts 1.1
1919import Ubuntu.Components 1.3
20+import Qt.labs.settings 1.0
21+import Unity.Screens 0.1
2022import UInput 0.1
23+import "../Components"
2124
2225Item {
2326 id: root
@@ -29,13 +32,26 @@ Item {
2932 function runTutorial() {
3033 tutorial.start()
3134 }
32− signal tutorialDone();
3335
3436 readonly property bool pressed: point1.pressed || point2.pressed || leftButton.pressed || rightButton.pressed
3537
38+ Settings {
39+ id: inputMethodState
40+ objectName: "inputMethodState"
41+ property bool touchpadTutorialHasRun: false
42+ property bool oskEnabled: true
43+ }
44+
45+ Component.onCompleted: {
46+ if (!inputMethodState.touchpadTutorialHasRun) {
47+ tutorial.start();
48+ }
49+ }
50+
3651 MultiPointTouchArea {
3752 objectName: "touchPadArea"
3853 anchors.fill: parent
54+ enabled: !tutorial.running || tutorial.paused
3955
4056 // FIXME: Once we have Qt DPR support, this should be Qt.styleHints.startDragDistance
4157 readonly property int clickThreshold: internalGu * 1.5
@@ -44,6 +60,12 @@ Item {
4460 property bool isDrag: false
4561
4662 onPressed: {
63+ print("pressed, tutorial state", tutorial.paused, tutorial.running)
64+ if (tutorial.paused) {
65+ tutorial.resume();
66+ return;
67+ }
68+
4769 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
4870 // Make sure we check for both combos, only point1 or only point2
4971 if (((point1.pressed && !point2.pressed) || (!point1.pressed && point2.pressed))
@@ -177,6 +199,41 @@ Item {
177199 }
178200 }
179201
202+ AbstractButton {
203+ id: oskButton
204+ anchors { right: parent.right; top: parent.top; margins: internalGu * 2 }
205+ height: internalGu * 6
206+ width: height
207+
208+ onClicked: {
209+ inputMethodState.oskEnabled = !inputMethodState.oskEnabled
210+ }
211+
212+ Rectangle {
213+ anchors.fill: parent
214+ radius: width / 2
215+ color: UbuntuColors.inkstone
216+ }
217+
218+ Icon {
219+ anchors.fill: parent
220+ anchors.margins: internalGu * 1.5
221+ name: "input-keyboard-symbolic"
222+ }
223+ }
224+
225+ Screens {
226+ id: screens
227+ }
228+
229+ InputMethod {
230+ id: inputMethod
231+ // Don't resize when there is only one screen to avoid resize clashing with the InputMethod in the Shell.
232+ enabled: screens.count > 1 && inputMethodState.oskEnabled
233+ objectName: "inputMethod"
234+ anchors.fill: parent
235+ }
236+
180237 Label {
181238 id: tutorialLabel
182239 anchors { left: parent.left; top: parent.top; right: parent.right; margins: internalGu * 4; topMargin: internalGu * 10 }
@@ -186,6 +243,16 @@ Item {
186243 wrapMode: Text.WordWrap
187244 }
188245
246+ Icon {
247+ id: tutorialImage
248+ height: internalGu * 8
249+ width: height
250+ name: "input-touchpad-symbolic"
251+ color: "white"
252+ opacity: 0
253+ anchors { top: tutorialLabel.bottom; horizontalCenter: parent.horizontalCenter; margins: internalGu * 2 }
254+ }
255+
189256 Item {
190257 id: tutorialFinger1
191258 width: internalGu * 5
@@ -218,6 +285,19 @@ Item {
218285
219286 SequentialAnimation {
220287 id: tutorial
288+
289+ PropertyAction { targets: [leftButton, rightButton, oskButton]; property: "enabled"; value: false }
290+ PropertyAction { targets: [leftButton, rightButton, oskButton]; property: "opacity"; value: 0 }
291+ PropertyAction { target: tutorialLabel; property: "text"; value: i18n.tr("Your device is now connected to an external display. Use this screen as a touch pad to interact with the pointer.") }
292+ UbuntuNumberAnimation { targets: [tutorialLabel, tutorialImage]; property: "opacity"; to: 1; duration: UbuntuAnimation.FastDuration }
293+ PropertyAction { target: tutorial; property: "paused"; value: true }
294+ PauseAnimation { duration: 100 } // it takes a bit until pausing actually takes effect
295+ UbuntuNumberAnimation { targets: [tutorialLabel, tutorialImage]; property: "opacity"; to: 0; duration: UbuntuAnimation.FastDuration }
296+
297+ PauseAnimation { duration: UbuntuAnimation.SleepyDuration }
298+ UbuntuNumberAnimation { target: leftButton; property: "opacity"; to: 1 }
299+ UbuntuNumberAnimation { target: rightButton; property: "opacity"; to: 1 }
300+
221301 PauseAnimation { duration: UbuntuAnimation.SleepyDuration }
222302 PropertyAction { target: tutorialLabel; property: "text"; value: i18n.tr("Tap left button to click.") }
223303 UbuntuNumberAnimation { target: tutorialLabel; property: "opacity"; to: 1; duration: UbuntuAnimation.FastDuration }
@@ -292,6 +372,10 @@ Item {
292372 UbuntuNumberAnimation { target: tutorialLabel; property: "opacity"; to: 1; duration: UbuntuAnimation.FastDuration }
293373 PauseAnimation { duration: 2000 }
294374 UbuntuNumberAnimation { target: tutorialLabel; property: "opacity"; to: 0; duration: UbuntuAnimation.FastDuration }
295− ScriptAction { script: root.tutorialDone(); }
375+
376+ UbuntuNumberAnimation { target: oskButton; property: "opacity"; to: 1 }
377+ PropertyAction { targets: [leftButton, rightButton, oskButton]; property: "enabled"; value: true }
378+
379+ PropertyAction { target: inputMethodState; property: "touchpadTutorialHasRun"; value: true }
296380 }
297381}