-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.qml
368 lines (327 loc) · 12.7 KB
/
main.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
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.3
import QtQml 2.15
import "./ScreensComponents"
import "./GameScreens"
import "./ScreensComponents/LeftSideDrawer"
import "./ScreensComponents/RightSideDrawer"
import "./Settings"
import "./AddItemScreen"
import FontStyle 1.0
import AppStyle 1.0
ApplicationWindow {
id:root
width: 1280
height: 750
visible: true
color: AppStyle.background
property color homeColor: "#313a41"
property color borderColor: "#444b51"
property color backgroundColor : "#373e44"
property bool isLandscape: width > height
property bool backKeyBlocked: false
property var activationPolicy: {
"NONE":0, "IMMEDIATELY":1, "LAZY":2, "WHILE_CURRENT":3
}
property color transparentColor: "transparent"
// primary and accent properties:
property variant primaryPalette: AppTheme.defaultPrimaryPalette()
property color primaryLightColor: primaryPalette[0]
property color primaryColor: primaryPalette[1]
property color primaryDarkColor: primaryPalette[2]
property color textOnPrimaryLight: primaryPalette[3]
property color textOnPrimary: primaryPalette[4]
property color textOnPrimaryDark: primaryPalette[5]
property string iconOnPrimaryLightFolder: primaryPalette[6]
property string iconOnPrimaryFolder: primaryPalette[7]
property string iconOnPrimaryDarkFolder: primaryPalette[8]
property variant accentPalette: AppTheme.defaultAccentPalette()
property color accentColor: accentPalette[0]
property color textOnAccent: accentPalette[1]
property string iconOnAccentFolder: accentPalette[2]
Material.primary: primaryColor
Material.accent: accentColor
// theme Dark vs Light properties:
property variant themePalette: AppTheme.defaultThemePalette()
property color dividerColor: themePalette[0]
property color cardAndDialogBackground: themePalette[1]
property real primaryTextOpacity: themePalette[2]
property real secondaryTextOpacity: themePalette[3]
property real dividerOpacity: themePalette[4]
property real iconActiveOpacity: themePalette[5]
property real iconInactiveOpacity: themePalette[6]
property string iconFolder: themePalette[7]
property int isDarkTheme: themePalette[8]
property color flatButtonTextColor: themePalette[9]
property color popupTextColor: themePalette[10]
property real toolBarActiveOpacity: themePalette[11]
property real toolBarInactiveOpacity: themePalette[12]
property color toastColor: themePalette[13]
property real toastOpacity: themePalette[14]
// Material.dropShadowColor OK for Light, but too dark for dark theme
property color dropShadow: isDarkTheme? "#E4E4E4" : Material.dropShadowColor
onIsDarkThemeChanged: {
if(isDarkTheme == 1) {
Material.theme = Material.Dark
root.background = AppStyle.backgroundColor
} else {
root.background = AppStyle.background
Material.theme = Material.Light
}
}
// font sizes - defaults from Google Material Design Guide
property int fontSizeDisplay4: 112
property int fontSizeDisplay3: 56
property int fontSizeDisplay2: 45
property int fontSizeDisplay1: 34
property int fontSizeHeadline: 24
property int fontSizeTitle: 20
property int fontSizeSubheading: 16
property int fontSizeBodyAndButton: 14 // is Default
property int fontSizeCaption: 12
property int fontSizeActiveNavigationButton: 14
property int fontSizeInactiveNavigationButton: 12
property real opacityDisplay4: secondaryTextOpacity
property real opacityDisplay3: secondaryTextOpacity
property real opacityDisplay2: secondaryTextOpacity
property real opacityDisplay1: secondaryTextOpacity
property real opacityHeadline: primaryTextOpacity
property real opacityTitle: primaryTextOpacity
property real opacitySubheading: primaryTextOpacity
// body can be both: primary or secondary text
property real opacityBodyAndButton: primaryTextOpacity
property real opacityBodySecondary: secondaryTextOpacity
property real opacityCaption: secondaryTextOpacity
property var navigationModel: [
{"type": "qrc:/ScreensComponents/RightSideDrawer/navigation/DrawerNavigationButton.qml", "name": "General", "icon": "home.png", "source": "qrc:/ScreensComponents/RightSideDrawer/navigation/HomeNavigation.qml", "showCounter":false, "showMarker":false, "a_p":1},
{"type": "qrc:/ScreensComponents/RightSideDrawer/navigation/DrawerNavigationButton.qml", "name": "Security", "icon": "car.png", "source": "qrc:/ScreensComponents/RightSideDrawer/pages/PageOne.qml", "showCounter":true, "showMarker":false, "a_p":2},
{"type": "qrc:/ScreensComponents/RightSideDrawer/navigation/DrawerNavigationButton.qml", "name": "Privacy", "icon": "bus.png", "source": "qrc:/ScreensComponents/RightSideDrawer/pages/PageTwo.qml", "showCounter":false, "showMarker":false, "a_p":2},
{"type": "qrc:/ScreensComponents/RightSideDrawer/navigation/DrawerNavigationButton.qml", "name": "Advanced", "icon": "subway.png", "source": "qrc:/ScreensComponents/RightSideDrawer/pages/PageThree.qml", "showCounter":false, "showMarker":true, "a_p":3},
]
property var navigationData: [
{"counter":0, "marker":""},
{"counter":0, "marker":""},
{"counter":0, "marker":""},
{"counter":0, "marker":""}
]
property var favoritesModel: [0,1,2,3]
property int navigationIndex: 0
onNavigationIndexChanged: {
rightDrawerLoader.source = navigationModel[navigationIndex]["source"]
}
property bool hideTitleBar: false
property bool showFavorites: true
property bool highlightActiveNavigationButton : true
// Chance to ignore the checkbox
property bool ignoreCheck: false
/* With help Connections object
* set connections with System tray class
* */
Connections {
target: systemTray
function onSignalShow() {
root.show();
}
// The signal - close the application by ignoring the check-box
function onSignalQuit() {
ignoreCheck = true
close();
}
// Minimize / maximize the window by clicking on the default system tray
function onSignalIconActivated() {
if(root.visibility === Window.Hidden) {
root.show()
} else {
root.hide()
}
}
}
// Handler window closing event
onClosing: {
/* If the check box should not be ignored and it is active,
* then hide the application. Otherwise, close the application
* */
if(ignoreCheck === false){
close.accepted = false
root.hide()
} else {
Qt.quit()
}
}
header: TitleBar{
id:titlebar
onMenuClicked: {
drawer.open()
}
onHomeClicked: {
//AppTheme.swapThemePalette()
var component = Qt.createComponent("qrc:/Settings/Settings.qml");
var win = component.createObject(root);
win.show();
}
onHelpCliked: {
var component = Qt.createComponent("qrc:/AddItemScreen/AddItemDialog.qml");//Qt.createComponent("qrc:/Settings/Settings.qml");
var win = component.createObject(root);
win.show();
}
onSettingsCliked: {
// var component = Qt.createComponent("qrc:/Settings/Settings.qml");
// var win = component.createObject(root);
// win.show();
settingsDrawer.open()
}
Component{
id:settings
Settings{
}
}
}
Loader{
id:mainLoader
anchors.fill: parent
StackView{
id:mainStack
anchors.fill: parent
initialItem: HomeScreen{
anchors.fill: parent
}
}
}
//LeftSide Drawer
PageDrawer {
id: drawer
iconTitle: "Qt Drawer App"
iconSource: "qrc:/Img/Icons/hire-a-helper.svg"
iconSubtitle: qsTr ("Version 1.0 Beta")
actions: {
0: function() { console.log ("Item 1 clicked!") },
1: function() { console.log ("Item 2 clicked!") },
2: function() { console.log ("Item 3 clicked!") },
3: function() { console.log ("Item 4 clicked!") },
4: function() { console.log ("Item 5 clicked!") },
5: function() { console.log ("Item 6 clicked!") },
7: function() { console.log ("Item 7 clicked!") },
8: function() { console.log ("Item 8 clicked!") },
}
items: ListModel {
id: pagesModel
ListElement {
pageTitle: qsTr ("Home")
pageIcon: "qrc:/Img/Icons/house-user-solid.svg"
}
ListElement {
pageTitle: qsTr ("Settings")
pageIcon: "qrc:/Img/Icons/gear-solid.svg"
}
ListElement {
pageTitle: qsTr ("Configuration")
pageIcon: "qrc:/Img/Icons/gear-solid.svg"
}
ListElement {
pageTitle: qsTr ("Docs")
pageIcon: "qrc:/Img/Icons/globe-solid.svg"
}
ListElement {
pageTitle: qsTr ("Help")
pageIcon: "qrc:/Img/Icons/hire-a-helper.svg"
}
ListElement {
pageTitle: qsTr ("About")
pageIcon: "qrc:/Img/Icons/house-user-solid.svg"
}
ListElement {
separator: true
}
ListElement {
pageTitle: qsTr ("Our Blog")
pageIcon: "qrc:/Img/Icons/globe-solid.svg"
}
ListElement {
pageTitle: qsTr ("Follows us")
pageIcon: "qrc:/Img/Icons/globe-solid.svg"
}
}
}
//RightSide Drawer
Drawer{
id:settingsDrawer
width: parent.width*0.40
height: root.height
edge: Qt.RightEdge
background: Rectangle{
anchors.fill: parent
color: AppStyle.background
}
contentItem:Page{
padding: 0
anchors.fill: parent
background: settingsDrawer.background
header:Rectangle{
width: parent.width
height: 40
color: AppStyle.titleBarColor
Column{
width: parent.width
height: parent.height
Row{
spacing: 10
MainButton{
id:crossButton
sourceIcon:"qrc:/ScreensComponents/RightSideDrawer/Images/"+iconFolder+"/"+ "arrow_back.png"
width: 40
height: 40
buttonText: "";
color: "transparent"
hoverColor: "transparent"
pressColor: "transparent"
borderColor: "transparent"
fontSize: 10
borderWidth: 1
borderRadius: height/2
onClicked: {
console.log("Button Clicked !")
settingsDrawer.close()
}
}
Label {
font.weight: Font.Medium
font.pixelSize: 18
opacity: 0.8
anchors.verticalCenter: crossButton.verticalCenter
text: navigationModel[navigationIndex]["name"]
color: AppStyle.textColor
}
}
Rectangle{
color: "grey"
width: parent.width
height: 1
}
}
}
Loader {
id: rightDrawerLoader
anchors.fill: parent
clip: true
sourceComponent: homePageComponent
}
Component {
id: homePageComponent
HomeNavigation{
}
}
footer: Rectangle{
width: parent.width
height: 56
color: AppStyle.background
DrawerFavoritesNavigationBar{
width: parent.width
anchors.centerIn: parent
}
}
}
}
}