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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
|
import QtQuick 2.0
import Sailfish.Silica 1.0
Page {
id: root
property var pebble: null
SilicaFlickable {
id: flickable
anchors.fill: parent
contentHeight: column.height
VerticalScrollDecorator { flickable: flickable }
PullDownMenu {
MenuItem {
text: qsTr("About")
onClicked: {
pageStack.push(Qt.resolvedUrl("InfoPage.qml"))
}
}
MenuItem {
text: qsTr("Developer tools")
onClicked: {
pageStack.push(Qt.resolvedUrl("DeveloperToolsPage.qml"), {pebble: root.pebble})
}
}
}
Column {
id: column
width: root.width
spacing: Theme.paddingLarge
PageHeader {
title: qsTr("RockPool")
}
ListView {
model: mainMenuModel
}
//Creating the menu list this way to allow the text field to be translatable (http://askubuntu.com/a/476331)
ListModel {
id: mainMenuModel
dynamicRoles: true
}
Component.onCompleted: {
populateMainMenu();
}
Connections {
target: root.pebble
onFirmwareUpgradeAvailableChanged: {
populateMainMenu();
}
}
function populateMainMenu() {
mainMenuModel.clear();
mainMenuModel.append({
icon: "stock_notification",
text: qsTr("Manage notifications"),
page: "NotificationsPage.qml",
color: "blue"
});
mainMenuModel.append({
icon: "stock_application",
text: qsTr("Manage Apps"),
page: "InstalledAppsPage.qml",
showWatchApps: true,
color: "green"
});
mainMenuModel.append({
icon: "clock-app-symbolic",
text: qsTr("Manage Watchfaces"),
page: "InstalledAppsPage.qml",
showWatchFaces: true,
color: "black"
});
mainMenuModel.append({
icon: "settings",
text: qsTr("Settings"),
page: "SettingsPage.qml",
showWatchFaces: true,
color: "gold"
});
if (root.pebble.firmwareUpgradeAvailable) {
mainMenuModel.append({
icon: "preferences-system-updates-symbolic",
text: qsTr("Firmware upgrade"),
page: "FirmwareUpgradePage.qml",
color: "red"
});
}
}
PebbleModels {
id: modelModel
}
Column {
anchors.fill: parent
Item {
//Layout.alignment: Qt.AlignHCenter
width: root.width
Image {
id: watchImage
width: implicitWidth * height / implicitHeight
height: parent.height
anchors.horizontalCenter: parent.horizontalCenter
source: Qt.resolvedUrl("qrc:///"+modelModel.get(root.pebble.model).image)
fillMode: Image.PreserveAspectFit
}
Item {
id: watchFace
height: parent.height * (modelModel.get(root.pebble.model - 1).shape === "rectangle" ? .5 : .515)
width: height * (modelModel.get(root.pebble.model - 1).shape === "rectangle" ? .85 : 1)
anchors.centerIn: parent
anchors.horizontalCenterOffset: units.dp(1)
anchors.verticalCenterOffset: units.dp(modelModel.get(root.pebble.model - 1).shape === "rectangle" ? 0 : 1)
Image {
id: image
anchors.fill: parent
source: "file://" + root.pebble.screenshots.latestScreenshot
visible: false
}
Component.onCompleted: {
if (!root.pebble.screenshots.latestScreenshot) {
root.pebble.requestScreenshot();
}
}
Rectangle {
id: textItem
anchors.fill: parent
layer.enabled: true
radius: modelModel.get(root.pebble.model - 1).shape === "rectangle" ? units.gu(.5) : height / 2
// This item should be used as the 'mask'
layer.samplerName: "maskSource"
layer.effect: ShaderEffect {
property var colorSource: image;
fragmentShader: "
uniform lowp sampler2D colorSource;
uniform lowp sampler2D maskSource;
uniform lowp float qt_Opacity;
varying highp vec2 qt_TexCoord0;
void main() {
gl_FragColor =
texture2D(colorSource, qt_TexCoord0)
* texture2D(maskSource, qt_TexCoord0).a
* qt_Opacity;
}
"
}
}
}
}
Column {
width: root.width
spacing: units.gu(2)
Rectangle {
height: units.gu(10)
width: height
radius: height / 2
color: root.pebble.connected ? "green" : "red"
IconButton {
anchors.fill: parent
anchors.margins: units.gu(2)
icon.source: root.pebble.connected ? "image://theme/icon-m-acknowledge" : "image://theme/icon-m-reset"
}
}
Label {
text: root.pebble.connected ? qsTr("Connected") : qsTr("Disconnected")
width: root.width
}
}
}
Column {
width: root.width
//Layout.preferredHeight: childrenRect.height
spacing: menuRepeater.count > 0 ? 0 : units.gu(2)
Label {
text: qsTr("Your Pebble smartwatch is disconnected. Please make sure it is powered on, within range and it is paired properly in the Bluetooth System Settings.")
width: parent.width - units.gu(4)
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WordWrap
visible: !root.pebble.connected
font.pixelSize: Theme.fontSizeLarge
horizontalAlignment: Text.AlignHCenter
}
Label {
text: qsTr("Your Pebble smartwatch is in factory mode and needs to be initialized.")
width: parent.width - units.gu(4)
anchors.horizontalCenter: parent.horizontalCenter
wrapMode: Text.WordWrap
visible: root.pebble.connected && root.pebble.recovery && !root.pebble.upgradingFirmware
font.pixelSize: Theme.fontSizeLarge
horizontalAlignment: Text.AlignHCenter
}
Button {
text: qsTr("Initialize Pebble")
onClicked: root.pebble.performFirmwareUpgrade();
visible: root.pebble.connected && root.pebble.recovery && !root.pebble.upgradingFirmware
color: "orange"
anchors.horizontalCenter: parent.horizontalCenter
}
Rectangle {
id: upgradeIcon
height: units.gu(10)
width: height
radius: width / 2
color: Theme.highlightColor
anchors.horizontalCenter: parent.horizontalCenter
BusyIndicator {
anchors.horizontalCenter: parent.horizontalCenter
running: upgradeInProgress
size: BusyIndicatorSize.Large
}
visible: root.pebble.connected && root.pebble.upgradingFirmware
}
Label {
text: qsTr("Upgrading...")
font.pixelSize: Theme.fontSizeLarge
anchors.horizontalCenter: parent.horizontalCenter
visible: root.pebble.connected && root.pebble.upgradingFirmware
}
Repeater {
id: menuRepeater
model: root.pebble.connected && !root.pebble.recovery && !root.pebble.upgradingFirmware ? mainMenuModel : null
delegate: ListItem {
Row {
anchors.fill: parent
anchors.margins: units.gu(1)
Rectangle {
//Layout.fillHeight: true
//Layout.preferredWidth: height
//backgroundColor: model.color
Image {
anchors.fill: parent
anchors.margins: units.gu(.5)
source: model.icon
}
}
Label {
text: model.text
width: page.width
}
}
onClicked: {
var options = {};
options["pebble"] = root.pebble
var modelItem = mainMenuModel.get(index)
options["showWatchApps"] = modelItem.showWatchApps
options["showWatchFaces"] = modelItem.showWatchFaces
pageStack.push(Qt.resolvedUrl(model.page), options)
}
}
}
}
}
}
Connections {
target: pebble
onOpenURL: {
if (url) {
pageStack.push(Qt.resolvedUrl("AppSettingsPage.qml"), {uuid: uuid, url: url, pebble: pebble})
}
}
}
}
|