summaryrefslogtreecommitdiff
path: root/src/tutorials/tutorials.js
blob: eb23eab7990286ff72fd5d9d60eba8654871b3a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var tutorialSteps = []
var waitingForClick = false


function highlightItem(widgetName, click) {
    var rect = tutorialControl.getRect(widgetName)
    highlight.x = rect.x - 1
    highlight.y = rect.y - 1
    highlight.width = rect.width + 2
    highlight.height = rect.height + 2
    if (click) {
        highlight.border.color = "green"
    } else {
        highlight.border.color = "blue"
    }
    highlight.visible = true
}

function highlightAction(actionName, click) {
    var rect = tutorialControl.getActionRect(actionName)
    highlight.x = rect.x - 1
    highlight.y = rect.y - 1
    highlight.width = rect.width + 2
    highlight.height = rect.height + 2
    if (click) {
        highlight.border.color = "green"
    } else {
        highlight.border.color = "blue"
    }
    highlight.visible = true
}

function unhighlight()
{
    highlight.visible = false
}

function waitForClick()
{
    waitingForClick = true;
    description.continueVisible = true
    // ui needs to be locked, otherwise the tutorial-view does not receive mouse-events!
    tutorialControl.lockUI(true)
}

function clickNext()
{
    if (waitingForClick) {
        nextStep()
    }
}

function nextStep()
{
  waitingForClick = false;
  description.continueVisible = false
  if (step < tutorialSteps.length) {
    tutorialControl.lockUI(false)
    step++
    tutorialSteps[step - 1]()
  } else {
    tutorialControl.finish()
  }
}

function sameStep()
{
  tutorialSteps[step - 1]()
}

function onTabChanged(func)
{
  tutToplevel.tabChanged.connect(func)
}

function init()
{
    var res = Qt.include("file:///" + scriptName)
    if (res.status !== 0) {
        console.log("failed to load " + scriptName + ": " + res.status)
        return
    }

    tutorialSteps = getTutorialSteps()
}