summaryrefslogtreecommitdiff
path: root/gui/components/Splash.qml
blob: cf75108a43150337a96b38105286088426c248d9 (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
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0

Page {
    id: splash
    property int timeoutInterval: qmlDebug ? 200 : 1600
    property alias errors: splashErrorBox

    Column {
        width: parent.width * 0.8
        anchors.horizontalCenter: parent.horizontalCenter
        anchors.topMargin: 24

        VerticalSpacer {
            visible: true
            height: root.height * 0.25
        }

        Image {
            id: connectionImage
            height: 180
            anchors.horizontalCenter: parent.horizontalCenter
            source: "../resources/icon-noshield.svg"
            fillMode: Image.PreserveAspectFit
        }

        VerticalSpacer {
            visible: true
            height: root.height * 0.05
        }

        ProgressBar {
            id: splashProgress
            width: appWidth * 0.8 - 60
            indeterminate: true
            anchors.horizontalCenter: parent.horizontalCenter
        }

        InitErrors {
            id: splashErrorBox
        }
    }

    Timer {
        id: splashTimer
    }

    function delay(delayTime, cb) {
        splashTimer.interval = delayTime
        splashTimer.repeat = true
        splashTimer.triggered.connect(cb)
        splashTimer.start()
    }

    function loadMainViewWhenReady() {
        if (root.error != "") {
            return
        }
        if (ctx && ctx.isReady || qmlDebug) {
            splashTimer.stop()
            loader.source = "MainView.qml"
        } else {
            if (!splashTimer.running) {
              console.debug('delay...')
              delay(500, loadMainViewWhenReady)
            }
        }
    }

    Timer {
        interval: timeoutInterval
        running: true
        repeat: false
        onTriggered: {
            loadMainViewWhenReady()
        }
    }

    Component.onCompleted: {}
}