summaryrefslogtreecommitdiff
path: root/app/qml/pages/AppConfigDialog.qml
blob: 304bced68e610d8b881c32ee198629e2cdb6880c (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
import QtQuick 2.0
import QtQml 2.1
import QtWebKit 3.0
import Sailfish.Silica 1.0

Dialog {
    id: appConfigPage

    property alias url: webview.url
    property string uuid
    property string name

    SilicaWebView {
        id: webview
        visible: url != ""
        anchors.fill: parent

        header: DialogHeader {
            title: "Configuring " + name
        }

        VerticalScrollDecorator { flickable: webview }

        onNavigationRequested: {
            console.log("appconfig navigation requested to " + request.url);
            var url = request.url.toString();
            if (/^pebblejs:\/\/close/.exec(url)) {
                var data = decodeURIComponent(url.substring(17));
                console.log("appconfig requesting close; data: " + data);
                pebbled.setAppConfiguration(uuid, data);
                appConfigPage.canAccept = true;
                appConfigPage.accept();
                request.action = WebView.IgnoreRequest;
            } else {
                request.action = WebView.AcceptRequest;
            }
        }

        experimental.itemSelector: Component {
            Item {
                Component.onCompleted: {
                    var dialog = pageStack.push(Qt.resolvedUrl("WebItemSelDialog.qml"), {
                                                       model: model.items
                                                });
                    dialog.onRejected.connect(function() {
                        model.reject();
                    });
                    dialog.onAccepted.connect(function() {
                        model.accept(dialog.selectedIndex);
                    });
                }
            }
        }
    }

    ProgressBar {
        anchors {
            left: parent.left
            right: parent.right
            bottom: parent.bottom
        }

        visible: webview.visible && webview.loading
        minimumValue: 0
        maximumValue: 100
        indeterminate: webview.loadProgress === 0
        value: webview.loadProgress
    }

    Text {
        anchors.centerIn: parent
        visible: url == ""
        text: qsTr("No configuration settings available")
        width: parent.width - 2*Theme.paddingLarge
        horizontalAlignment: Text.AlignHCenter
        wrapMode: Text.Wrap
        font {
            pixelSize: Theme.fontSizeLarge
            family: Theme.fontFamilyHeading
        }
        color: Theme.highlightColor
    }

    canAccept: false
}