summaryrefslogtreecommitdiff
path: root/rockwork/qml/Main.qml
blob: aae852b6cd5fdb06f158afbf208987f1902c6aab (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
import QtQuick 2.0
import Sailfish.Silica 1.0
import RockPool 1.0

/*!
    \brief MainView with a Label and Button elements.
*/

ApplicationWindow {
    id: app

    ServiceController {
        id: serviceController
        Component.onCompleted: {
            if (!serviceController.serviceRunning) {
                print("Service not running. Starting now.")
                serviceController.startService();
            }
            if (pebbles.version !== version) {
                print("Service file version (", version, ") is not equal running service version (", pebbles.version, "). Restarting service.")
                serviceController.restartService();
            }
        }
    }

    Pebbles {
        id: pebbles
        onCountChanged: loadStack()
    }

    function loadStack() {
        pageStack.clear()
        if (pebbles.count == 1) {
            pageStack.push(Qt.resolvedUrl("MainMenuPage.qml"), {pebble: pebbles.get(0)})
            app.cover.replace(Qt.resolvedUrl("CoverPage.qml"), {pebble: pebbles.get(0)})
        } else {
            pageStack.push(Qt.resolvedUrl("PebblesPage.qml"))
        }
    }

    PageStack {
        id: pageStack
        Component.onCompleted: loadStack();
    }
}