forked from PlayingKarrde/clearOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavigation.qml
176 lines (160 loc) · 4.79 KB
/
Navigation.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
import QtQuick 2.12
import QtGraphicalEffects 1.0
import QtQml.Models 2.10
import "utils.js" as Utils
FocusScope {
id: root
property var collectionData
property alias menu: navView
function activated(name) {
collections.focus = true;
switch (name) {
case "Home":
homeScreen();
break;
case "All Games":
allGamesScreen();
break;
case "Top Rated":
topGamesScreen();
break;
case "Search":
searchScreen();
break;
}
}
Keys.onRightPressed: {
sfxNav.play();
currentView.focus = true;
}
// Logo
Image {
id: logo
anchors {
left: parent.left;
right: parent.right;
top: parent.top;
margins: vpx(15)
}
height: width
source: "assets/images/logo.png"
sourceSize { width: vpx(100); height: vpx(100) }
fillMode: Image.PreserveAspectFit
smooth: true
}
Rectangle {
id: separator
anchors {
right: parent.right;
top: parent.top;
bottom: parent.bottom
}
width: 2
opacity: 0.05
color: "black"
}
function setIndex(idx) {
root.focus = true;
navView.currentIndex = idx;
}
ObjectModel {
id: navModel
NavigationButton {
selected: PathView.isCurrentItem
icon: "assets/images/navigation/Platforms.png"
label: (currentCollection != -1) ? api.collections.get(currentCollection).name : "All Games"
showLabel: selected && root.focus
width: vpx(46)
anchors { top: parent.top; }
onActivated: {
setIndex(ObjectModel.index);
if (!collectionMenuOpen)
openCollectionsMenu(root);
else
closeCollectionsMenu(true);
}
}
NavigationButton {
selected: PathView.isCurrentItem
icon: "assets/images/navigation/Home.png"
label: "Home"
showLabel: selected && root.focus
width: vpx(46)
onActivated: {
setIndex(ObjectModel.index);
closeCollectionsMenu();
homeScreen();
}
}
NavigationButton {
selected: PathView.isCurrentItem
icon: "assets/images/navigation/All Games.png"
label: "All Games"
showLabel: selected && root.focus
width: vpx(46)
onActivated: {
setIndex(ObjectModel.index);
closeCollectionsMenu();
allGamesScreen();
}
}
NavigationButton {
selected: PathView.isCurrentItem
icon: "assets/images/navigation/Top Rated.png"
label: "Top Rated Games"
showLabel: selected && root.focus
width: vpx(46)
onActivated: {
setIndex(ObjectModel.index);
closeCollectionsMenu();
topGamesScreen();
}
}
NavigationButton {
selected: PathView.isCurrentItem
icon: "assets/images/navigation/Search.png"
label: "Search"
showLabel: selected && root.focus
width: vpx(46)
onActivated: {
setIndex(ObjectModel.index);
closeCollectionsMenu();
searchScreen();
}
}
NavigationButton {
selected: PathView.isCurrentItem
icon: "assets/images/navigation/DarkMode.png"
label: "Toggle Dark Mode"
showLabel: selected && root.focus
anchors { bottom: parent.bottom; bottomMargin: vpx(25)}
width: vpx(46)
onActivated: {
setIndex(ObjectModel.index);
closeCollectionsMenu();
darkMode = !darkMode;
//mainMenu.focus = true;
}
}
}
PathView {
id: navView
anchors {
top: logo.bottom;
left: parent.left;
right: parent.right
bottom: parent.bottom
}
focus: true
interactive: false
highlightRangeMode: PathView.NoHighlightRange
Component.onCompleted: currentIndex = 1 // Set "Home" to be default selected
model: navModel
path: Path {
startX: vpx(50); startY: vpx(100)
PathLine { x: vpx(50); y: vpx(540); }
}
Keys.onUpPressed: { sfxNav.play(); decrementCurrentIndex(); }
Keys.onDownPressed: { sfxNav.play(); incrementCurrentIndex(); }
}
}