-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathBrowserPage.qml
438 lines (380 loc) · 17.6 KB
/
BrowserPage.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
437
438
/*****************************************************************************
* Copyright: 2011-2013 Michael Zanetti <[email protected]> *
* 2014 Robert Meijers <[email protected]> *
* *
* This file is part of Kodimote *
* *
* Kodimote 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. *
* *
* Kodimote 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 Sailfish.Silica 1.0
import harbour.kodimote 1.0
import "../components/"
Page {
id: browserPage
property variant model
property bool showSearch: !model.busy && browserPage.model && browserPage.model.allowSearch
signal home();
Component.onCompleted: {
var setting = model.watchedFilterSetting;
if (setting) {
settings[setting + 'Changed'].connect(function() {
filterModel.hideWatched = !settings[setting];
});
}
}
Component.onDestruction: {
if (model) {
model.exit();
}
}
KodiFilterModel {
id: filterModel
model: browserPage.model
filterCaseSensitivity: Qt.CaseInsensitive
hideWatched: model.watchedFilterSetting ? !settings[model.watchedFilterSetting] : false
onHideWatchedChanged: {
var setting = model.watchedFilterSetting;
if (setting) {
settings[setting] = !hideWatched;
}
}
}
SilicaFlickable {
id: flickable
interactive: !listView.flicking
pressDelay: 0
anchors.fill: parent
PullDownMenu {
ControlsMenuItem {
}
MenuItem {
text: qsTr("Home")
onClicked: {
browserPage.home();
}
}
MenuItem {
text: qsTr("Keypad")
onClicked: {
pageStack.push("Keypad.qml")
}
}
MenuItem {
text: qsTr("Now Playing")
enabled: kodi.activePlayer !== null
onClicked: {
pageStack.push("NowPlayingPage.qml")
}
}
}
PageHeader {
id: header
title: model ? model.title : ""
width: parent.width
}
BusyIndicator {
id: busyIndicator
anchors.centerIn: parent
running: model && model.busy
visible: model && model.busy
size: BusyIndicatorSize.Large
}
SilicaListView {
id: listView
highlightFollowsCurrentItem: true
model: filterModel
anchors.top: header.bottom
anchors.bottom: controlBar.top
width: parent.width
clip: true
pressDelay: 0
cacheBuffer: itemHeight * 3
property bool useThumbnails: settings.useThumbnails
property int itemHeight: browserPage.model && browserPage.model.thumbnailFormat === KodiModel.ThumbnailFormatPortrait ? 122 : 88
delegate: Drawer {
id: drawer
width: parent.width
height: opened && listView.height * drawer._progress > contentItem.height ? listView.height * drawer._progress : contentItem.height
dock: Dock.Bottom
function playItem() {
if (resume === 0) {
browserPage.model.playItem(filterModel.mapToSourceIndex(index));
} else {
var dialog = pageStack.push("ResumeDialog.qml", {item: model});
dialog.onAccepted.connect(function() {
browserPage.model.playItem(filterModel.mapToSourceIndex(index), true);
});
dialog.onRejected.connect(function() {
browserPage.model.playItem(filterModel.mapToSourceIndex(index));
});
}
}
background: Item {
anchors.fill: parent
width: drawer.width - 20
Loader {
id: contentLoader
anchors.fill: parent
onLoaded: {
item.item = browserPage.model.getItem(index);
}
Connections {
target: contentLoader.item
onPlayItem: {
drawer.playItem();
}
onAddToPlaylist: {
browserPage.model.addToPlaylist(filterModel.mapToSourceIndex(index))
}
}
}
}
backgroundSize: drawer.height - contentItem.height
ListItem {
id: contentItem
contentHeight: listView.itemHeight
width: parent.width
anchors.topMargin: Theme.paddingSmall
anchors.rightMargin: Theme.paddingSmall
showMenuOnPressAndHold: playable && !browserPage.model.hasDetails()
onPressed: {
listView.currentIndex = index
}
onPressAndHold: {
if (browserPage.model.hasDetails()) {
browserPage.model.fetchItemDetails(filterModel.mapToSourceIndex(listView.currentIndex));
drawer.open = true;
}
}
onClicked: {
if (drawer.open) {
drawer.open = false;
} else {
if (filetype === "directory") {
var newModel = browserPage.model.enterItem(filterModel.mapToSourceIndex(index));
newModel.ignoreArticle = settings.ignoreArticle;
var browser = pageStack.push("BrowserPage.qml", {model: newModel});
browser.home.connect(function() {
browserPage.home();
});
} else {
drawer.playItem();
}
}
}
Rectangle {
id: highlightBar
color: resume <= 0 ? Theme.highlightColor : Theme.secondaryHighlightColor
width: 8
anchors.top: thumbnailImage.top
anchors.bottom: thumbnailImage.bottom
anchors.right: thumbnailImage.left
anchors.rightMargin: 2
visible: playcount === 0 || resume > 0
}
menu: Component {
ContextMenu {
MenuItem {
text: qsTr("Play")
onClicked: drawer.playItem()
}
MenuItem {
text: qsTr("Add to playlist")
onClicked: browserPage.model.addToPlaylist(filterModel.mapToSourceIndex(index))
}
}
}
Thumbnail {
id: thumbnailImage
height: browserPage.model.thumbnailFormat === KodiModel.ThumbnailFormatPortrait ? 120 : (browserPage.model.thumbnailFormat === KodiModel.ThumbnailFormatNone ? 0 : 86 )
width: browserPage.model.thumbnailFormat === KodiModel.ThumbnailFormatPortrait ? 80 : (browserPage.model.thumbnailFormat === KodiModel.ThumbnailFormatLandscape ? 152 : height)
anchors.left: parent.left
anchors.leftMargin: Theme.paddingLarge
anchors.top: parent.top
visible: listView.useThumbnails && browserPage.model.thumbnailFormat !== KodiModel.ThumbnailFormatNone
artworkSource: thumbnail
defaultText: title
IconButton {
id: playingOverlay
icon.source: playingState === "playing" ? "image://theme/icon-m-play" : "image://theme/icon-m-pause"
visible: playingState === "playing" || playingState == "paused"
z: 2
anchors.centerIn: thumbnailImage
SequentialAnimation on opacity {
loops: Animation.Infinite
running: playingOverlay.visible
NumberAnimation {target: playingOverlay; properties: "opacity"; from: 1; to: 0.5; duration: 1000; easing.type: Easing.InOutQuad}
NumberAnimation {target: playingOverlay; properties: "opacity"; from: 0.5; to: 1; duration: 1000; easing.type: Easing.InOutQuad}
}
}
}
Row {
id: itemRow
anchors {
left: (thumbnailImage.visible ? thumbnailImage.right : parent.left);
leftMargin: (thumbnailImage.visible ? Theme.paddingMedium : Theme.paddingLarge);
top: parent.top;
right: parent.right;
rightMargin: Theme.paddingSmall
}
height: listView.itemHeight
Column {
anchors.verticalCenter: parent.verticalCenter
Text {
id: mainText
text: title
font.weight: Font.Bold
font.pixelSize: Theme.fontSizeMedium
width: itemRow.width
elide: Text.ElideRight
color: Theme.primaryColor
states: [
State {
name: "highlighted"; when: playingState === "playing" || playingState === "paused"
PropertyChanges { target: mainText; color: Theme.highlightColor }
}
]
}
Label {
id: subText
text: subtitle
font.weight: Font.Light
font.pixelSize: Theme.fontSizeSmall
color: Theme.secondaryColor
width: mainText.width
elide: Text.ElideRight
visible: text != ""
}
Label {
id: subSubText
text: year
font.weight: Font.Light
font.pixelSize: Theme.fontSizeSmall
color: Theme.secondaryColor
width: mainText.width
elide: Text.ElideRight
visible: text != ""
}
}
}
ProgressBar {
minimumValue: 0
maximumValue: 100
value: model.progressPercentage != undefined ? progressPercentage : 0
visible: index >= 0 && browserPage.model.getItem(filterModel.mapToSourceIndex(index)).type === "channel"
leftMargin: 10
rightMargin: 10
height: 20
anchors {
left: (thumbnailImage.visible ? thumbnailImage.right : parent.left);
leftMargin: (thumbnailImage.visible ? Theme.paddingSmall : Theme.paddingLarge);
right: parent.right
rightMargin: Theme.paddingLarge
verticalCenter: parent.bottom
verticalCenterOffset: 25
}
}
}
states: [
State {
when: open
PropertyChanges { target: listView; interactive: false; contentY: listView.itemHeight * listView.currentIndex }
PropertyChanges { target: flickable; interactive: false }
PropertyChanges { target: contentLoader; source: browserPage.model.getItem(filterModel.mapToSourceIndex(index)).type == "channel" ? "../components/ChannelDetails.qml" : "../components/ItemDetails.qml" }
PropertyChanges { target: dockedControls; hideTemporary: true }
PropertyChanges { target: controlBar; height: 0 }
},
State {
when: opened
PropertyChanges { target: listView; interactive: false }
PropertyChanges { target: flickable; interactive: false }
PropertyChanges { target: dockedControls; hideTemporary: true }
}
]
}
Behavior on contentY {
NumberAnimation {
easing.type: Easing.OutQuad
duration: 300
}
}
VerticalScrollDecorator { }
}
Column {
id: controlBar
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.leftMargin: Theme.paddingLarge
anchors.right: parent.right
anchors.rightMargin: Theme.paddingSmall
SearchField {
id: searchField
width: parent.width
visible: browserPage.showSearch && searchSwitch.checked
Binding {
target: filterModel
property: "filter"
value: searchField.text
}
}
Row {
Switch {
id: searchSwitch
icon.source: "image://theme/icon-m-search"
icon.height: 32
icon.width: 32
visible: browserPage.showSearch
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: -14
onCheckedChanged: {
if (searchSwitch.checked) {
searchField.forceActiveFocus();
}
}
}
Switch {
icon.source: "image://theme/icon-s-installed"
visible: model.allowWatchedFilter
anchors.verticalCenter: parent.verticalCenter
anchors.verticalCenterOffset: -14
checked: !filterModel.hideWatched
automaticCheck: false
onClicked: {
filterModel.hideWatched = !filterModel.hideWatched
}
}
IconButton {
icon.source: "image://theme/icon-direction-forward"
rotation: filterModel.sortOrder == Qt.AscendingOrder ? 180 : 0
height: 70
width: 70
icon.height: 70
icon.width: 70
onClicked: {
filterModel.sortOrder = filterModel.sortOrder == Qt.AscendingOrder ? Qt.DescendingOrder : Qt.AscendingOrder
}
anchors.verticalCenter: parent.verticalCenter
}
}
Behavior on height {
NumberAnimation {
easing.type: Easing.OutQuad
duration: 300
}
}
}
}
}