/
Main.qml
721 lines (590 loc) · 21 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
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
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
import Qt 4.7
import com.nokia.meego 1.0
import 'config.js' as Config
Image {
id: main
focus: true
function _(x) {
return controller.translate(x)
}
function n_(x, y, z) {
return controller.ntranslate(x, y, z)
}
property alias podcastModel: podcastList.model
property alias episodeModel: episodeList.model
property alias currentEpisode: mediaPlayer.episode
property variant currentPodcast: undefined
property bool hasPodcasts: podcastList.hasItems
property alias currentFilterText: episodeList.currentFilterText
property bool playing: mediaPlayer.playing
property bool canGoBack: (closeButton.isRequired || mediaPlayer.visible) && !progressIndicator.opacity && !myGpoSheetVisible
property bool hasPlayButton: nowPlayingThrobber.shouldAppear && !progressIndicator.opacity && !myGpoSheetVisible
property bool hasSearchButton: searchButton.visible && !mediaPlayer.visible && !progressIndicator.opacity && !myGpoSheetVisible
property bool myGpoSheetVisible: false
property bool hasFilterButton: state == 'episodes' && !mediaPlayer.visible
function openMyGpo() {
myGpoEnableSwitch.checked = controller.myGpoEnabled
myGpoUsernameField.text = controller.myGpoUsername
myGpoPasswordField.text = controller.myGpoPassword
myGpoDeviceCaptionField.text = controller.myGpoDeviceCaption
myGpoSheet.open()
myGpoSheetVisible = true
}
function goBack() {
if (nowPlayingThrobber.opened) {
nowPlayingThrobber.opened = false
} else {
closeButton.clicked()
}
}
function showFilterDialog() {
episodeList.showFilterDialog()
}
function clickPlayButton() {
nowPlayingThrobber.clicked()
}
function clickSearchButton() {
searchButton.clicked()
}
Keys.onPressed: {
console.log(event.key)
if (event.key == Qt.Key_Escape) {
goBack()
}
if (event.key == Qt.Key_F && event.modifiers & Qt.ControlModifier) {
searchButton.clicked()
}
}
width: 800
height: 480
source: 'artwork/background-harmattan.png'
state: 'podcasts'
function togglePlayback(episode) {
if (episode !== undefined && episode.qfiletype == 'video') {
controller.playVideo(episode)
} else {
controller.currentEpisodeChanging()
mediaPlayer.togglePlayback(episode)
}
}
function openShowNotes(episode) {
showNotes.episode = episode
main.state = 'shownotes'
}
function openContextMenu(items) {
hrmtnContextMenu.items = items
hrmtnContextMenu.open()
}
function startProgress(text) {
progressIndicator.text = text
progressIndicator.opacity = 1
}
function endProgress() {
progressIndicator.opacity = 0
}
states: [
State {
name: 'podcasts'
PropertyChanges {
target: podcastList
opacity: 1
}
PropertyChanges {
target: episodeList
anchors.leftMargin: 100
opacity: 0
}
PropertyChanges {
target: showNotes
opacity: 0
}
StateChangeScript {
script: episodeList.resetSelection()
}
},
State {
name: 'episodes'
PropertyChanges {
target: episodeList
opacity: 1
}
PropertyChanges {
target: podcastList
opacity: 0
anchors.leftMargin: -100
}
PropertyChanges {
target: showNotes
opacity: 0
anchors.leftMargin: main.width
}
},
State {
name: 'shownotes'
PropertyChanges {
target: listContainer
opacity: 0
}
PropertyChanges {
target: showNotes
opacity: 1
anchors.leftMargin: 0
}
}
]
Item {
id: listContainer
anchors.fill: parent
PodcastList {
id: podcastList
opacity: 0
anchors.fill: parent
onPodcastSelected: {
controller.podcastSelected(podcast)
main.currentPodcast = podcast
}
onPodcastContextMenu: controller.podcastContextMenu(podcast)
onSubscribe: contextMenu.showSubscribe()
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
Behavior on anchors.leftMargin { NumberAnimation { duration: Config.slowTransition } }
}
EpisodeList {
id: episodeList
opacity: 0
anchors.fill: parent
onEpisodeContextMenu: controller.episodeContextMenu(episode)
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
Behavior on anchors.leftMargin { NumberAnimation { duration: Config.slowTransition } }
}
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
Behavior on scale { NumberAnimation { duration: Config.fadeTransition } }
}
ShowNotes {
id: showNotes
anchors {
left: parent.left
top: titleBar.bottom
bottom: parent.bottom
}
width: parent.width
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
Behavior on anchors.leftMargin { NumberAnimation { duration: Config.slowTransition } }
}
Item {
id: overlayInteractionBlockWall
anchors.fill: parent
anchors.topMargin: (nowPlayingThrobber.opened || messageDialog.opacity > 0 || inputDialog.opacity > 0 || progressIndicator.opacity > 0)?0:titleBar.height
z: (contextMenu.state != 'opened')?2:0
opacity: (nowPlayingThrobber.opened || contextMenu.state == 'opened' || messageDialog.opacity || inputDialog.opacity || progressIndicator.opacity)?1:0
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
MouseArea {
anchors.fill: parent
onClicked: {
if (contextMenu.state == 'opened') {
// do nothing
} else if (progressIndicator.opacity) {
// do nothing
} else if (inputDialog.opacity) {
inputDialog.close()
} else if (messageDialog.opacity) {
messageDialog.opacity = 0
} else {
nowPlayingThrobber.opened = false
}
}
}
Rectangle {
anchors.fill: parent
color: 'black'
opacity: .7
}
Image {
anchors.fill: parent
source: 'artwork/mask.png'
}
}
CornerButton {
id: extraCloseButton
visible: false
z: (contextMenu.state == 'opened')?2:0
tab: 'artwork/back-tab.png'
icon: 'artwork/back.png'
isLeftCorner: true
anchors.bottom: parent.bottom
anchors.left: parent.left
onClicked: closeButton.clicked()
opened: !(!Config.hasCloseButton && closeButton.isRequired)
}
CornerButton {
z: 3
property bool shouldAppear: ((contextMenu.state != 'opened') && (mediaPlayer.episode !== undefined))
id: nowPlayingThrobber
visible: false
anchors.bottom: parent.bottom
anchors.right: parent.right
opacity: shouldAppear
caption: (mediaPlayer.episode!=undefined)?mediaPlayer.episode.qtitle:''
opened: false
onClicked: { opened = !opened }
}
MediaPlayer {
id: mediaPlayer
visible: nowPlayingThrobber.opened
z: 3
anchors.top: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.topMargin: nowPlayingThrobber.opened?-(height+(parent.height-height)/2):0
Behavior on anchors.topMargin { PropertyAnimation { duration: Config.quickTransition; easing.type: Easing.OutCirc } }
}
ContextMenu {
id: hrmtnContextMenu
property variant items: []
MenuLayout {
Repeater {
model: hrmtnContextMenu.items
MenuItem {
text: modelData.caption
onClicked: {
hrmtnContextMenu.close()
controller.contextMenuResponse(index)
}
}
}
}
}
ContextMenuArea {
id: contextMenu
width: parent.width
opacity: 0
anchors {
top: parent.top
bottom: parent.bottom
}
onClose: contextMenu.state = 'closed'
onResponse: controller.contextMenuResponse(index)
state: 'closed'
Behavior on opacity { NumberAnimation { duration: Config.fadeTransition } }
states: [
State {
name: 'opened'
PropertyChanges {
target: contextMenu
opacity: 1
}
AnchorChanges {
target: contextMenu
anchors.right: main.right
}
},
State {
name: 'closed'
PropertyChanges {
target: contextMenu
opacity: 0
}
AnchorChanges {
target: contextMenu
anchors.right: main.left
}
StateChangeScript {
script: controller.contextMenuClosed()
}
}
]
transitions: Transition {
AnchorAnimation { duration: Config.slowTransition }
}
}
Item {
id: titleBar
height: taskSwitcher.height*.8
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
//anchors.topMargin: mediaPlayer.fullscreen?-height:0
//opacity: mediaPlayer.fullscreen?0:1
Behavior on opacity { PropertyAnimation { } }
Behavior on anchors.topMargin { PropertyAnimation { } }
Rectangle {
anchors.fill: parent
color: "black"
opacity: .9
MouseArea {
// clicks should not fall through!
anchors.fill: parent
}
}
Item {
id: taskSwitcher
visible: contextMenu.state != 'opened' && Config.hasTaskSwitcher
anchors.left: parent.left
anchors.top: parent.top
width: Config.switcherWidth
height: Config.headerHeight
MouseArea {
anchors.fill: parent
onClicked: controller.switcher()
}
ScaledIcon {
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: (parent.width * .8 - width) / 2
}
source: 'artwork/switch.png'
}
}
Label {
id: titleBarText
anchors.verticalCenter: parent.verticalCenter
anchors.left: taskSwitcher.visible?taskSwitcher.right:taskSwitcher.left
anchors.leftMargin: (contextMenu.state == 'opened')?(Config.largeSpacing):(Config.hasTaskSwitcher?0:Config.largeSpacing)
anchors.right: searchButton.visible?searchButton.left:searchButton.right
wrapMode: Text.NoWrap
clip: true
text: (contextMenu.state == 'opened')?(contextMenu.subscribeMode?_('Add a new podcast'):_('Context menu')):((main.state == 'episodes' || main.state == 'shownotes')?(controller.episodeListTitle + ' (' + episodeList.count + ')'):"gPodder")
color: 'white'
font.pixelSize: parent.height * .5
font.bold: false
}
Binding {
target: controller
property: 'windowTitle'
value: titleBarText.text
}
TitlebarButton {
id: searchButton
anchors.right: closeButton.visible?closeButton.left:closeButton.right
source: 'artwork/subscriptions.png'
onClicked: contextMenu.showSubscribe()
visible: (contextMenu.state == 'closed' && main.state == 'podcasts')
opacity: 0
}
TitlebarButton {
id: closeButton
anchors.right: parent.right
property bool isRequired: main.state != 'podcasts' || contextMenu.state != 'closed'
visible: extraCloseButton.opened && (Config.hasCloseButton || isRequired)
source: (main.state == 'podcasts' && contextMenu.state == 'closed')?'artwork/close.png':'artwork/back.png'
rotation: 0
onClicked: {
if (contextMenu.state == 'opened') {
contextMenu.state = 'closed'
} else if (main.state == 'podcasts') {
mediaPlayer.stop()
controller.quit()
} else if (main.state == 'episodes') {
main.state = 'podcasts'
main.currentPodcast = undefined
} else if (main.state == 'shownotes') {
main.state = 'episodes'
}
}
}
}
function showMessage(message) {
messageDialogText.text = message
messageDialog.opacity = 1
}
Item {
id: messageDialog
anchors.fill: parent
opacity: 0
z: 20
Behavior on opacity { PropertyAnimation { } }
Label {
id: messageDialogText
anchors.centerIn: parent
color: 'white'
font.pixelSize: 20
font.bold: true
}
}
function showInputDialog(message, value, accept, reject, textInput) {
inputDialogText.text = message
inputDialogField.text = value
inputDialogAccept.text = accept
inputDialogReject.text = reject
inputDialogField.visible = textInput
if (textInput) {
inputSheet.open()
} else {
queryDialog.open()
}
}
QueryDialog {
id: queryDialog
acceptButtonText: inputDialogAccept.text
rejectButtonText: inputDialogReject.text
message: inputDialogText.text
onAccepted: inputDialog.accept()
onRejected: inputDialog.close()
}
Sheet {
id: inputSheet
acceptButtonText: inputDialogAccept.text
rejectButtonText: inputDialogReject.text
content: Item {
anchors.fill: parent
MouseArea {
anchors.fill: parent
onClicked: console.log('caught')
}
Column {
anchors.fill: parent
anchors.margins: Config.smallSpacing
spacing: Config.smallSpacing
Item {
height: 1
width: parent.width
}
Label {
id: inputDialogText
anchors.margins: Config.smallSpacing
width: parent.width
}
Item {
height: 1
width: parent.width
}
InputField {
id: inputDialogField
width: parent.width
onAccepted: {
inputDialog.accept()
inputSheet.close()
}
actionName: inputDialogAccept.text
}
}
}
onAccepted: inputDialog.accept()
onRejected: inputDialog.close()
}
Item {
id: inputDialog
anchors.fill: parent
opacity: 0
function accept() {
opacity = 0
scale = .5
controller.inputDialogResponse(true, inputDialogField.text,
inputDialogField.visible)
}
function close() {
opacity = 0
scale = .5
controller.inputDialogResponse(false, inputDialogField.text,
inputDialogField.visible)
}
SimpleButton {
id: inputDialogReject
width: parent.width / 2
onClicked: inputDialog.close()
}
SimpleButton {
id: inputDialogAccept
width: parent.width / 2
onClicked: inputDialog.accept()
}
}
Column {
id: progressIndicator
property string text: '...'
anchors.centerIn: parent
opacity: 0
spacing: Config.largeSpacing * 2
z: 40
Behavior on opacity { NumberAnimation { duration: Config.slowTransition } }
Label {
text: parent.text
anchors.horizontalCenter: parent.horizontalCenter
}
BusyIndicator {
anchors.horizontalCenter: parent.horizontalCenter
running: parent.opacity > 0
}
}
Sheet {
id: myGpoSheet
acceptButtonText: _('Save')
rejectButtonText: _('Cancel')
visualParent: main
content: Item {
id: myGpoSheetContent
anchors.fill: parent
MouseArea {
anchors.fill: parent
onClicked: console.log('caught')
}
Flickable {
anchors.fill: parent
anchors.margins: Config.largeSpacing
contentWidth: myGpoSettingsColumn.width
contentHeight: myGpoSettingsColumn.height
Column {
id: myGpoSettingsColumn
width: myGpoSheetContent.width - Config.largeSpacing * 2
spacing: Config.smallSpacing
Item {
width: parent.width
height: myGpoEnableSwitch.height
Label {
id: enableText
anchors.left: parent.left
anchors.right: myGpoEnableSwitch.left
elide: Text.ElideRight
anchors.verticalCenter: parent.verticalCenter
text: _('Enable gpodder.net syncing')
}
Switch {
id: myGpoEnableSwitch
anchors.right: parent.right
}
}
Item { height: Config.largeSpacing; width: 1 }
Label { text: _('Username') }
InputField { id: myGpoUsernameField; anchors.left: parent.left; anchors.right: parent.right }
Item { height: 1; width: 1 }
Label { text: _('Password') }
InputField { id: myGpoPasswordField; anchors.left: parent.left; anchors.right: parent.right; echoMode: TextInput.Password }
Item { height: 1; width: 1 }
Label { text: _('Device name') }
InputField { id: myGpoDeviceCaptionField; anchors.left: parent.left; anchors.right: parent.right }
Item { height: Config.largeSpacing; width: 1 }
Button {
text: _('Replace list on server')
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
myGpoSheet.accept()
controller.myGpoUploadList()
}
}
/*Button {
text: _('Download list from server')
anchors.horizontalCenter: parent.horizontalCenter
onClicked: controller.myGpoDownloadList()
}*/
Item { height: Config.largeSpacing; width: 1 }
Button {
text: _('No account? Register here')
anchors.horizontalCenter: parent.horizontalCenter
onClicked: Qt.openUrlExternally('http://gpodder.net/register/')
}
}
}
}
onAccepted: {
controller.myGpoUsername = myGpoUsernameField.text
controller.myGpoPassword = myGpoPasswordField.text
controller.myGpoDeviceCaption = myGpoDeviceCaptionField.text
controller.myGpoEnabled = myGpoEnableSwitch.checked && (controller.myGpoUsername != '' && controller.myGpoPassword != '')
controller.saveMyGpoSettings()
main.myGpoSheetVisible = false
}
onRejected: {
main.myGpoSheetVisible = false
}
}
}