summaryrefslogtreecommitdiff
path: root/rockwork/qml/DeveloperToolsPage.qml
blob: 2f77254479ea91a7638213f193d42875e36c494d (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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
import QtQuick 2.4
import QtQuick.Layouts 1.1
import Ubuntu.Components 1.3
import Ubuntu.Components.Popups 1.3
import Ubuntu.Content 1.3

Page {
    id: root
    title: i18n.tr("Developer Tools")

    property var pebble: null

    //Creating the menu list this way to allow the text field to be translatable (http://askubuntu.com/a/476331)
    ListModel {
        id: devMenuModel
        dynamicRoles: true
    }

    Component.onCompleted: {
        populateDevMenu();
    }

    function populateDevMenu() {
        devMenuModel.clear();

        devMenuModel.append({
            icon: "camera-app-symbolic",
            text: i18n.tr("Screenshots"),
            page: "ScreenshotsPage.qml",
            dialog: "",
            color: "gold"
        });
        devMenuModel.append({
            icon: "dialog-warning-symbolic",
            text: i18n.tr("Report problem"),
            page: "",
            dialog: sendLogsComponent,
            color: UbuntuColors.red
        });
        devMenuModel.append({
            icon: "stock_application",
            text: i18n.tr("Install app or watchface from file"),
            page: "ImportPackagePage.qml",
            dialog: null,
            color: UbuntuColors.blue
        });

    }

    ColumnLayout {
        anchors.fill: parent

        Repeater {
            id: menuRepeater
            model: devMenuModel
            delegate: ListItem {

                RowLayout {
                    anchors.fill: parent
                    anchors.margins: units.gu(1)

                    UbuntuShape {
                        Layout.fillHeight: true
                        Layout.preferredWidth: height
                        backgroundColor: model.color
                        Icon {
                            anchors.fill: parent
                            anchors.margins: units.gu(.5)
                            name: model.icon
                            color: "white"
                        }
                    }


                    Label {
                        text: model.text
                        Layout.fillWidth: true
                    }
                }

                onClicked: {
                    if (model.page) {
                        pageStack.push(Qt.resolvedUrl(model.page), {pebble: root.pebble})
                    }
                    if (model.dialog) {
                        PopupUtils.open(model.dialog)
                    }
                }
            }
        }

        Item {
            Layout.fillHeight: true
            Layout.fillWidth: true
        }
    }

    Component {
        id: sendLogsComponent
        Dialog {
            id: sendLogsDialog
            title: i18n.tr("Report problem")
            ActivityIndicator {
                id: busyIndicator
                visible: false
                running: visible
            }
            Label {
                text: i18n.tr("Preparing logs package...")
                visible: busyIndicator.visible
                horizontalAlignment: Text.AlignHCenter
                fontSize: "large"
            }

            Connections {
                target: root.pebble
                onLogsDumped: {
                    if (success) {
                        var filename = "/tmp/pebble.log"
                        pageStack.push(Qt.resolvedUrl("ContentPeerPickerPage.qml"), {itemName: i18n.tr("pebble.log"),handler: ContentHandler.Share, contentType: ContentType.All, filename: filename })
                    }
                    PopupUtils.close(sendLogsDialog)
                }
            }

            Button {
                text: i18n.tr("Send rockworkd.log")
                color: UbuntuColors.blue
                visible: !busyIndicator.visible
                onClicked: {
                    var filename = homePath + "/.cache/upstart/rockworkd.log"
                    pageStack.push(Qt.resolvedUrl("ContentPeerPickerPage.qml"), {itemName: i18n.tr("rockworkd.log"),handler: ContentHandler.Share, contentType: ContentType.All, filename: filename })
                    PopupUtils.close(sendLogsDialog)
                }
            }
            Button {
                text: i18n.tr("Send watch logs")
                color: UbuntuColors.blue
                visible: !busyIndicator.visible
                onClicked: {
                    busyIndicator.visible = true
                    root.pebble.dumpLogs("/tmp/pebble.log")
                }
            }
            Button {
                text: i18n.tr("Cancel")
                color: UbuntuColors.red
                visible: !busyIndicator.visible
                onClicked: {
                    PopupUtils.close(sendLogsDialog)
                }
            }
        }
    }

}