forked from PlayingKarrde/clearOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGameList.qml
109 lines (93 loc) · 3.13 KB
/
GameList.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
import QtQuick 2.3
import QtQuick.Layouts 1.11
import "Lists"
FocusScope {
id: root
property var collectionData: api.collections.get(0).games
property int itemWidth: vpx(250)
property int itemHeight: itemWidth*0.6
property alias currentIndex: collectionList.currentIndex
property alias savedIndex: collectionList.savedIndex
property alias title: collectiontitle.text
property alias model: collectionList.model
property alias delegate: collectionList.delegate
property alias collectionList: collectionList
property var search
signal activate(int activeIndex)
signal activateSelected
signal listHighlighted
Text {
id: collectiontitle
text: collectionData.name
font.family: titleFont.name
font.pixelSize: vpx(26)
font.bold: true
color: theme.text
//opacity: root.focus ? 1 : 0.2
anchors { left: parent.left; top: parent.top; topMargin: vpx(5) }
height: vpx(50)
}
ListView {
id: collectionList
focus: root.focus
anchors {
top: collectiontitle.bottom; topMargin: vpx(10)
left: parent.left;
right: parent.right;
bottom: parent.bottom
}
spacing: vpx(40)
orientation: ListView.Horizontal
preferredHighlightBegin: vpx(0)
preferredHighlightEnd: parent.width
highlightRangeMode: ListView.ApplyRange
snapMode: ListView.SnapOneItem
highlightMoveDuration: 100
displayMarginEnd: itemWidth*2
property int savedIndex: 0
onFocusChanged: {
if (focus)
currentIndex = savedIndex;
else {
savedIndex = currentIndex;
currentIndex = -1;
}
}
currentIndex: focus ? savedIndex : -1
Component.onCompleted: positionViewAtIndex(savedIndex, ListView.Visible)
model: collectionData
delegate: GridItem {
selected: ListView.isCurrentItem && collectionList.focus
gameData: modelData
// List specific input
Keys.onPressed: {
// Back
if (api.keys.isCancel(event) && !event.isAutoRepeat) {
event.accepted = true;
sfxBack.play();
navigationMenu();
}
// Favorites
if (api.keys.isDetails(event) && !event.isAutoRepeat) {
event.accepted = true;
sfxToggle.play();
modelData.favorite = !modelData.favorite;
}
}
}
Keys.onLeftPressed: {
sfxNav.play();
if (currentIndex == 0) {
navigationMenu();
} else {
collectionList.decrementCurrentIndex();
}
}
Keys.onRightPressed: { sfxNav.play(); collectionList.incrementCurrentIndex() }
}
GridItem {
selected: root.focus
visible: collectionList.count == 0
anchors { top: collectiontitle.bottom; topMargin: vpx(10) }
}
}