-
Notifications
You must be signed in to change notification settings - Fork 0
/
theme.qml
220 lines (188 loc) · 5.78 KB
/
theme.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
// Pegasus Frontend
// Copyright (C) 2017-2020 Mátyás Mustoha
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.0
import SortFilterProxyModel 0.2
import "layer_filter"
import "layer_gameinfo"
import "layer_grid"
import "layer_platform"
FocusScope {
Keys.onPressed:
{
if (event.isAutoRepeat)
return;
if (api.keys.isPrevPage(event))
{
event.accepted = true;
topbar.prev();
return;
}
if (api.keys.isNextPage(event))
{
event.accepted = true;
topbar.next();
return;
}
if (api.keys.isDetails(event))
{
event.accepted = true;
gamepreview.focus = true;
return;
}
if (api.keys.isFilters(event))
{
event.accepted = true;
filter.focus = true;
return;
}
}
PlatformBar
{
id: topbar
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
z: 300
model: api.collections
onCurrentIndexChanged: onPlatformChanged();
}
//***********************ON_PLATORM_CHANGED***********************
function onPlatformChanged()
{
console.log("onPlatformChanged()");
gamegrid.cells_need_recalc();
initFolders();
}
//***********************INIT_FOLDERS********************************
function initFolders()
{
//console.log("initFolders()");
filter.init_genre_model();
}
BackgroundImage
{
anchors.top: topbar.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
game: gamegrid.currentGame
}
GameGrid
{
id: gamegrid
focus: true
gridWidth: (parent.width * 0.6) - vpx(32)
gridMarginTop: vpx(32)
gridMarginRight: vpx(6)
anchors.top: topbar.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
baseCollection: topbar.currentCollection
originalModel: topbar.currentCollection.games
filteredModel: filteredGames
onDetailsRequested: gamepreview.focus = true
onLaunchRequested: launchGame()
}
GamePreview
{
id: gamepreview
panelWidth: parent.width * 0.7 + vpx(72)
anchors {
top: topbar.bottom; bottom: parent.bottom
left: parent.left; right: parent.right
}
game: gamegrid.currentGame
onOpenRequested: gamepreview.focus = true
onCloseRequested: gamegrid.focus = true
onFiltersRequested: filter.focus = true
onLaunchRequested: launchGame()
}
FilterLayer
{
id: filter
//anchors.fill: parent
onCloseRequested: gamegrid.focus = true
anchors.top: topbar.bottom;
anchors.bottom: parent.bottom;
anchors.topMargin: vpx(40);
anchors.bottomMargin: vpx(40);
property int gf_fontsize : 24
property int gf_fontsizeSel : 48
}//end of FilterLayer
SortFilterProxyModel
{
id: filteredGames
sourceModel: topbar.currentCollection.games
filters: [
RegExpFilter {
roleName: "genre" //topbar.currentCollection.games[0].Field name to filter by
pattern: filter.withFolder
caseSensitivity: Qt.CaseInsensitive
enabled: filter.withFolder == "ALL" ? false : true
}
]
}//end of SortFilterProxyModel
Component.onCompleted:
{
console.log("Component.onCompleted()");
var genre_filter_font_size = api.memory.get('genrefilter.fontsize');
if (!genre_filter_font_size)
{
console.log("Writing Font Size");
genre_filter_font_size=32;
api.memory.set('genrefilter.fontsize', genre_filter_font_size);
}
filter.gf_fontsize=genre_filter_font_size;
filter.gf_fontsizeSel=genre_filter_font_size*2;
const last_collection = api.memory.get('collection');
if (!last_collection)
{
initFolders();
return;
}
const last_coll_idx = api
.collections
.toVarArray()
.findIndex(c => c.name === last_collection);
if (last_coll_idx < 0)
{
initFolders();
return;
}
topbar.currentIndex = last_coll_idx;
initFolders();
const last_game = api.memory.get('game');
if (!last_game)
return;
const last_game_idx = api
.collections
.get(last_coll_idx)
.games
.toVarArray()
.findIndex(g => g.title === last_game);
if (last_game_idx < 0)
return;
gamegrid.currentIndex = last_game_idx;
gamegrid.memoryLoaded = true;
}
function launchGame()
{
api.memory.set('collection', topbar.currentCollection.name);
api.memory.set('game', gamegrid.currentGame.title);
gamegrid.currentGame.launch();
}
}//end of FocusScope {