-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathAppToolBar.qml
436 lines (365 loc) · 14.9 KB
/
AppToolBar.qml
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
/* Copyright 2021 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import QtGraphicalEffects 1.12
//------------------------------------------------------------------------------
import ArcGIS.AppFramework 1.0
//------------------------------------------------------------------------------
import "Portal"
import "AboutDialog"
import "AppMetrics"
import "singletons" as Singletons
//------------------------------------------------------------------------------
Item {
// PROPERTIES //////////////////////////////////////////////////////////////
id: appToolBar
property StackView stackView
property Portal portal
property UpdatesDialog updates
property string toolBarBackground: "#222"
property string toolBarFontColor: "#fff"
property double toolBarFontPointSize: sf(15)
property string toolBarBorderColor: "#fff"
property string toolBarButtonColor: "#fff"
property string toolBarButtonBackgroundColor: "transparent"
property string toolBarButtonHoverColor: "gold"
property string toolBarButtonPressedColor: "orange"
property string toolBarButtonDisabledColor: "#aaa"
property int toolBarHeight: sf(50)
property int toolBarWidth
property int iconHeight: toolBarHeight - sf(25)
property int updateCount: 0
// -------------------------------------------------------------------------
property alias toolBarTitleLabel: toolbarTitle.text
property alias backButtonVisible: backButton.visible
property alias backButtonEnabled: backButton.enabled
property alias updatesButtonVisible: updatesButton.visible
property alias updatesButtonEnabled: updatesButton.enabled
property alias updateIndicatorVisible: numberOfUpdatesIndicator.visible
property alias updateIndicatorCount: numberOfUpdatesIndicatorCount.text
property alias feedbackButtonVisible: feedbackButton.visible
property alias feedbackButtonEnabled: feedbackButton.enabled
property alias historyButtonVisible: historyButton.visible
property alias historyButtonEnabled: historyButton.enabled
property alias aboutButtonVisible: aboutButton.visible
property alias aboutButtonEnabled: aboutButton.enabled
property alias userButtonVisible: userButton.visible
property alias userButtonEnabled: userButton.enabled
property alias settingsButtonVisible: settingsButton.visible
property alias settingsButtonEnabled: settingsButton.enabled
// UI //////////////////////////////////////////////////////////////////////
Rectangle{
anchors.fill: parent
color: toolBarBorderColor
Accessible.role: Accessible.Pane
RowLayout {
anchors.fill: parent
spacing: sf(1)
//------------------------------------------------------------------
Button{
id: backButton
Layout.preferredWidth: toolBarHeight
Layout.fillHeight: true
ToolTip.visible: hovered
ToolTip.text: Singletons.Strings.back
background: Rectangle{
color: toolBarBackground
anchors.fill: parent
}
IconFont {
anchors.centerIn: parent
icon: _icons.chevron_left
iconSizeMultiplier: 1
color: _returnButtonColor(backButton)
Accessible.ignored: true
}
onClicked: {
stackView.pop();
}
Accessible.role: Accessible.Button
Accessible.name: Singletons.Strings.goBackToPreviousView
Accessible.description: Singletons.Strings.goBackToPreviousViewDesc
Accessible.onPressAction: {
if (enabled && visible) {
clicked();
}
}
}
//------------------------------------------------------------------
Rectangle {
color: toolBarBackground
Layout.fillWidth: true
Layout.fillHeight: true
Accessible.role: Accessible.Pane
Text {
id: toolbarTitle
anchors.centerIn: parent
verticalAlignment: Text.AlignVCenter
leftPadding: sf(20)
font.family: defaultFontFamily
font.pointSize: toolBarFontPointSize
color: toolBarFontColor
textFormat: Text.RichText
text: ""
Accessible.role: Accessible.Heading
Accessible.name: text
}
}
//------------------------------------------------------------------
Button{
id: updatesButton
Layout.preferredWidth: toolBarHeight
Layout.fillHeight: true
ToolTip.visible: hovered
ToolTip.text: Singletons.Strings.updatesAvailable
enabled: false
visible: false
background: Rectangle{
color: toolBarBackground
anchors.fill: parent
}
IconFont {
anchors.centerIn: parent
icon: _icons.download_circle
iconSizeMultiplier: 1.1
color: _returnButtonColor(updatesButton)
Accessible.ignored: true
}
Rectangle {
id: numberOfUpdatesIndicator
visible: false
color: "orange"
width: parent.width/2.4
height: parent.width/2.4
radius: (parent.width/2.4) / 2
anchors.top: updatesButton.top
anchors.right: updatesButton.right
anchors.topMargin: 4 * AppFramework.displayScaleFactor
anchors.rightMargin: 4 * AppFramework.displayScaleFactor
Text {
id: numberOfUpdatesIndicatorCount
anchors.centerIn: parent
text: "0"
color:"white"
}
Accessible.ignored: true
}
onClicked: {
updates.open();
}
Accessible.role: Accessible.Button
Accessible.name: Singletons.Strings.xUpdatesAvaliable.arg(numberOfUpdatesIndicatorCount.text)
Accessible.description: Singletons.Strings.xUpdatesAvaliableDesc
Accessible.onPressAction: {
if (enabled && visible) {
clicked();
}
}
}
//------------------------------------------------------------------
Button {
id: feedbackButton
Layout.preferredWidth: toolBarHeight
Layout.fillHeight: true
ToolTip.visible: hovered
ToolTip.text: Singletons.Strings.feedback
enabled: true
background: Rectangle {
color: toolBarBackground
anchors.fill: parent
}
IconFont {
anchors.centerIn: parent
icon: _icons.chat_bubble
iconSizeMultiplier: 1.1
color: _returnButtonColor(feedbackButton)
Accessible.ignored: true
}
onClicked: {
feedbackDialog.open();
}
Accessible.role: Accessible.Button
Accessible.name: Singletons.Strings.feedback
Accessible.description: Singletons.Strings.feedbackDesc
Accessible.onPressAction: {
if (enabled && visible) {
clicked();
}
}
}
//------------------------------------------------------------------
Button {
id: aboutButton
Layout.preferredWidth: toolBarHeight
Layout.fillHeight: true
ToolTip.visible: hovered
ToolTip.text: Singletons.Strings.aboutAndHelp
background: Rectangle{
color: toolBarBackground
anchors.fill: parent
}
IconFont {
anchors.centerIn: parent
icon: _icons.info
iconSizeMultiplier: 1.1
color: _returnButtonColor(aboutButton)
Accessible.ignored: true
}
onClicked: {
aboutDialog.open()
}
Accessible.role: Accessible.Button
Accessible.name: Singletons.Strings.aboutTheApp
Accessible.description: Singletons.Strings.aboutTheAppDesc
Accessible.onPressAction: {
if (enabled && visible) {
clicked();
}
}
}
//------------------------------------------------------------------
Button {
id: settingsButton
Layout.preferredWidth: toolBarHeight
Layout.fillHeight: true
ToolTip.visible: hovered
ToolTip.text: Singletons.Strings.settings
background: Rectangle {
color: toolBarBackground
anchors.fill: parent
}
IconFont {
anchors.centerIn: parent
icon: _icons.settings
iconSizeMultiplier: 1.1
color: _returnButtonColor(settingsButton)
Accessible.ignored: true
}
onClicked: {
stackView.push(sv);
}
Accessible.role: Accessible.Button
Accessible.name: Singletons.Strings.settings
Accessible.description: Singletons.Strings.settingsDesc
Accessible.onPressAction: {
if (enabled && visible) {
clicked();
}
}
}
//------------------------------------------------------------------
Button {
id: historyButton
Layout.preferredWidth: toolBarHeight
Layout.fillHeight: true
ToolTip.visible: hovered
ToolTip.text: Singletons.Strings.history
background: Rectangle {
color: toolBarBackground
anchors.fill: parent
}
IconFont {
anchors.centerIn: parent
icon: _icons.history
iconSizeMultiplier: 1.1
color: _returnButtonColor(historyButton)
Accessible.ignored: true
}
onClicked: {
stackView.push(hv);
}
Accessible.role: Accessible.Button
Accessible.name: Singletons.Strings.exportAndUploadHistory
Accessible.description: Singletons.Strings.exportAndUploadHistoryDesc
Accessible.onPressAction: {
if (enabled && visible) {
clicked();
}
}
}
//------------------------------------------------------------------
Button {
id: userButton
Layout.preferredWidth: toolBarHeight
Layout.fillHeight: true
ToolTip.visible: hovered
ToolTip.text: (portal.user !== null && portal.user !== "" && portal.user !== undefined) ? Singletons.Strings.signOut + ": " + portal.user.fullName : "User Unknown"
enabled: true
background: Rectangle {
color: toolBarBackground
anchors.fill: parent
}
IconFont {
anchors.centerIn: parent
icon: _icons.sign_out
iconSizeMultiplier: 1.1
color: _returnButtonColor(userButton)
Accessible.ignored: true
}
onClicked: {
portal.signOut();
stackView.replace(null,startView);
//stackView.push({item: startView, replace: true});
}
Accessible.role: Accessible.Button
Accessible.name: Singletons.Strings.signOut
Accessible.description: Singletons.Strings.signOutDesc
Accessible.onPressAction: {
if (enabled && visible) {
clicked();
}
}
}
//------------------------------------------------------------------
}
}
// SIGNAL IMPLEMENTATIONS //////////////////////////////////////////////////
onUpdateCountChanged: {
if (updateCount > 0) {
updatesButtonEnabled = true;
updatesButtonVisible = true;
updateIndicatorVisible = true;
updateIndicatorCount = updateCount.toString();
}
}
// COMPONENTS //////////////////////////////////////////////////////////////
AboutDialog {
id: aboutDialog
}
//--------------------------------------------------------------------------
FeedbackDialog {
id: feedbackDialog
metrics: mainView.appMetrics
}
// METHODS /////////////////////////////////////////////////////////////////
function _returnButtonColor(cntrl) {
if (cntrl.enabled === false) {
return toolBarButtonDisabledColor;
}
else if(cntrl.hovered){
return toolBarButtonHoverColor;
}
else if(cntrl.pressed){
return toolBarButtonPressedColor;
}
else {
return toolBarButtonColor;
}
}
// END /////////////////////////////////////////////////////////////////////
}