ElisaMainWindow.qml 36.9 KB
Newer Older
1
/*
2
 * Copyright 2016-2018 Matthieu Gallien <matthieu_gallien@yahoo.fr>
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public License
 * along with this library; see the file COPYING.LIB.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

20
import QtQuick 2.7
Alexander Stippich's avatar
Alexander Stippich committed
21 22
import QtQuick.Controls 2.2
import QtQuick.Controls 1.4 as Controls1
23 24
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
25
import org.kde.elisa 1.0
26
import Qt.labs.settings 1.0
27 28

ApplicationWindow {
29 30
    id: mainWindow

31
    visible: true
32

33 34
    minimumWidth: 1000
    minimumHeight: 600
35

Safa AlFulaij's avatar
Safa AlFulaij committed
36 37 38
    LayoutMirroring.enabled: Qt.application.layoutDirection == Qt.RightToLeft
    LayoutMirroring.childrenInherit: true

39 40 41 42 43
    x: persistentSettings.x
    y: persistentSettings.y
    width: persistentSettings.width
    height: persistentSettings.height

Safa AlFulaij's avatar
Safa AlFulaij committed
44
    title: i18n("Elisa")
45

46
    property var goBackAction: elisa.action("go_back")
47

48
    Controls1.Action  {
49 50 51 52 53 54 55
        shortcut: goBackAction.shortcut
        onTriggered: {
            localAlbums.goBack()
            localArtists.goBack()
        }
    }

Alexander Stippich's avatar
Alexander Stippich committed
56
    Controls1.Action {
57 58 59 60 61 62 63 64 65 66
        id: applicationMenuAction
        text: i18nc("open application menu", "Application Menu")
        iconName: "application-menu"
        onTriggered: applicationMenu.popup()
    }

    ApplicationMenu {
        id: applicationMenu
    }

67 68 69 70 71
    SystemPalette {
        id: myPalette
        colorGroup: SystemPalette.Active
    }

72 73 74 75
    Theme {
        id: elisaTheme
    }

76
    Settings {
77 78 79 80
        id: persistentSettings

        property int x
        property int y
81 82
        property int width : 1000
        property int height : 600
83

84
        property var playListState
85 86

        property var playListControlerState
87 88

        property var audioPlayerState
89

90
        property double playControlItemVolume : 100.0
91
        property bool playControlItemMuted : false
92 93 94 95

        property string filterState

   }
96

97 98 99 100 101 102 103 104 105
    Connections {
        target: Qt.application
        onAboutToQuit:
        {
            persistentSettings.x = mainWindow.x;
            persistentSettings.y = mainWindow.y;
            persistentSettings.width = mainWindow.width;
            persistentSettings.height = mainWindow.height;

106 107
            persistentSettings.playListState = elisa.mediaPlayList.persistentState;
            persistentSettings.playListControlerState = elisa.mediaPlayList.persistentState;
108
            persistentSettings.audioPlayerState = manageAudioPlayer.persistentState
109

110 111
            persistentSettings.playControlItemVolume = headerBar.playerControl.volume
            persistentSettings.playControlItemMuted = headerBar.playerControl.muted
112 113 114
        }
    }

115 116
    PlatformIntegration {
        id: platformInterface
117

118 119
        playListModel: elisa.mediaPlayList
        playListControler: elisa.mediaPlayList
120 121 122
        audioPlayerManager: manageAudioPlayer
        headerBarManager: myHeaderBarManager
        manageMediaPlayerControl: myPlayControlManager
Alexander Stippich's avatar
Alexander Stippich committed
123
        player: elisa.audioPlayer
124 125 126

        onRaisePlayer:
        {
127
            mainWindow.show()
128 129 130
            mainWindow.raise()
            mainWindow.requestActivate()
        }
131 132
    }

Alexander Stippich's avatar
Alexander Stippich committed
133 134
    Connections {
        target: elisa.audioPlayer
135

136
        onVolumeChanged: headerBar.playerControl.volume = volume
137
        onMutedChanged: headerBar.playerControl.muted = muted
138

139 140 141 142 143 144 145
        onPlaying: {
            myPlayControlManager.playerPlaying()
        }

        onPaused: {
            myPlayControlManager.playerPaused()
        }
146

147 148 149
        onStopped: {
            myPlayControlManager.playerStopped()
        }
150 151
    }

Alexander Stippich's avatar
Alexander Stippich committed
152
    Connections {
153
        target: elisa.mediaPlayList
154

Alexander Stippich's avatar
Alexander Stippich committed
155
        onPlayListLoadFailed: {
156 157
            messageNotification.showNotification(i18nc("message of passive notification when playlist load failed", "Load of playlist failed"), 3000)
        }
158

Alexander Stippich's avatar
Alexander Stippich committed
159
        onEnsurePlay: manageAudioPlayer.ensurePlay()
160

Alexander Stippich's avatar
Alexander Stippich committed
161
        onPlayListFinished: manageAudioPlayer.playListFinished()
162 163
    }

164 165 166
    ManageHeaderBar {
        id: myHeaderBarManager

167 168
        playListModel: elisa.mediaPlayList
        currentTrack: elisa.mediaPlayList.currentTrack
169

170 171 172 173
        artistRole: MediaPlayList.ArtistRole
        titleRole: MediaPlayList.TitleRole
        albumRole: MediaPlayList.AlbumRole
        imageRole: MediaPlayList.ImageRole
174
        isValidRole: MediaPlayList.IsValidRole
175 176 177 178 179
    }

    ManageAudioPlayer {
        id: manageAudioPlayer

180 181
        currentTrack: elisa.mediaPlayList.currentTrack
        playListModel: elisa.mediaPlayList
182
        urlRole: MediaPlayList.ResourceRole
183
        isPlayingRole: MediaPlayList.IsPlayingRole
184 185 186
        titleRole: MediaPlayList.TitleRole
        artistNameRole: MediaPlayList.ArtistRole
        albumNameRole: MediaPlayList.AlbumRole
187

Alexander Stippich's avatar
Alexander Stippich committed
188 189 190 191 192 193
        playerStatus: elisa.audioPlayer.status
        playerPlaybackState: elisa.audioPlayer.playbackState
        playerError: elisa.audioPlayer.error
        audioDuration: elisa.audioPlayer.duration
        playerIsSeekable: elisa.audioPlayer.seekable
        playerPosition: elisa.audioPlayer.position
194

195
        persistentState: persistentSettings.audioPlayerState
196

Alexander Stippich's avatar
Alexander Stippich committed
197 198 199
        onPlayerPlay: elisa.audioPlayer.play()
        onPlayerPause: elisa.audioPlayer.pause()
        onPlayerStop: elisa.audioPlayer.stop()
200
        onSkipNextTrack: elisa.mediaPlayList.skipNextTrack()
Alexander Stippich's avatar
Alexander Stippich committed
201
        onSeek: elisa.audioPlayer.seek(position)
202 203
        onSourceInError:
        {
204
            elisa.mediaPlayList.trackInError(source, playerError)
205
            elisa.musicManager.playBackError(source, playerError)
206 207 208
        }

        onDisplayTrackError: messageNotification.showNotification(i18n("Error when playing %1", "" + fileName), 3000)
209 210 211 212 213
    }

    ManageMediaPlayerControl {
        id: myPlayControlManager

214 215
        playListModel: elisa.mediaPlayList
        currentTrack: elisa.mediaPlayList.currentTrack
216 217
    }

218 219 220 221
    PassiveNotification {
        id: messageNotification
    }

222
    Rectangle {
223
        color: myPalette.base
224 225
        anchors.fill: parent

226 227 228
        ColumnLayout {
            anchors.fill: parent
            spacing: 0
229

230 231 232 233
            Item {
                Layout.preferredHeight: mainWindow.height * 0.2 + elisaTheme.mediaPlayerControlHeight
                Layout.minimumHeight: mainWindow.height * 0.2 + elisaTheme.mediaPlayerControlHeight
                Layout.maximumHeight: mainWindow.height * 0.2 + elisaTheme.mediaPlayerControlHeight
234
                Layout.fillWidth: true
235

236 237
                HeaderBar {
                    id: headerBar
238

239 240
                    focus: true

241
                    anchors.fill: parent
242

243 244 245 246 247
                    tracksCount: myHeaderBarManager.remainingTracks
                    album: myHeaderBarManager.album
                    title: myHeaderBarManager.title
                    artist: myHeaderBarManager.artist
                    image: myHeaderBarManager.image
248

249
                    ratingVisible: false
250

Alexander Stippich's avatar
Alexander Stippich committed
251 252
                    playerControl.duration: elisa.audioPlayer.duration
                    playerControl.seekable: elisa.audioPlayer.seekable
253

254 255
                    playerControl.volume: persistentSettings.playControlItemVolume
                    playerControl.muted: persistentSettings.playControlItemMuted
Alexander Stippich's avatar
Alexander Stippich committed
256
                    playerControl.position: elisa.audioPlayer.position
257 258 259 260
                    playerControl.skipBackwardEnabled: myPlayControlManager.skipBackwardControlEnabled
                    playerControl.skipForwardEnabled: myPlayControlManager.skipForwardControlEnabled
                    playerControl.playEnabled: myPlayControlManager.playControlEnabled
                    playerControl.isPlaying: myPlayControlManager.musicPlaying
261

Alexander Stippich's avatar
Alexander Stippich committed
262
                    playerControl.onSeek: elisa.audioPlayer.seek(position)
263

264 265
                    playerControl.onPlay: manageAudioPlayer.playPause()
                    playerControl.onPause: manageAudioPlayer.playPause()
266

267 268
                    playerControl.onPlayPrevious: elisa.mediaPlayList.skipPreviousTrack()
                    playerControl.onPlayNext: elisa.mediaPlayList.skipNextTrack()
269

Alexander Stippich's avatar
Alexander Stippich committed
270
                    Controls1.ToolButton {
271
                        id: menuButton
272

273
                        action: applicationMenuAction
274

275
                        z: 2
276

277 278 279 280 281 282 283 284 285 286
                        anchors
                        {
                            right: parent.right
                            top: parent.top
                            rightMargin: elisaTheme.layoutHorizontalMargin * 3
                            topMargin: elisaTheme.layoutHorizontalMargin * 3
                        }
                    }
                    Rectangle {
                        anchors.fill: menuButton
287

288
                        z: 1
289

290
                        radius: width / 2
291

292 293
                        color: myPalette.window
                    }
294

295
                    TrackImportNotification {
296 297 298 299 300 301 302 303 304
                        id: importedTracksCountNotification

                        anchors
                        {
                            right: menuButton.left
                            top: menuButton.top
                            bottom: menuButton.bottom
                            rightMargin: elisaTheme.layoutHorizontalMargin * 3
                        }
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
                    }

                    Binding {
                        target: importedTracksCountNotification
                        property: 'musicManager'
                        value: elisa.musicManager
                        when: elisa.musicManager !== undefined
                    }

                    Loader {
                        sourceComponent: Binding {
                            target: importedTracksCountNotification
                            property: 'indexingRunning'
                            value: elisa.musicManager.indexingRunning
                        }

                        active: elisa.musicManager !== undefined
                    }

                    Loader {
                        sourceComponent: Binding {
                            target: importedTracksCountNotification
                            property: 'importedTracksCount'
                            value: elisa.musicManager.importedTracksCount
                        }
330

331
                        active: elisa.musicManager !== undefined
332
                    }
333
                }
334
            }
335

336
            RowLayout {
337
                Layout.fillHeight: true
338 339
                Layout.fillWidth: true
                spacing: 0
340

341 342
                ViewSelector {
                    id: listViews
343

344
                    Layout.fillHeight: true
345 346
                    Layout.preferredWidth: mainWindow.width * 0.15
                    Layout.maximumWidth: mainWindow.width * 0.15
347 348
                }

349
                ColumnLayout {
350 351
                    Layout.fillHeight: true
                    Layout.fillWidth: true
352

353
                    spacing: 0
354

355
                    TopNotification {
356
                        id: invalidBalooConfiguration
357

358
                        Layout.fillWidth: true
359

360
                        musicManager: elisa.musicManager
361

362
                        focus: true
363 364 365 366 367 368 369 370 371 372 373 374 375
                    }

                    Item {
                        Layout.fillHeight: true
                        Layout.fillWidth: true

                        RowLayout {
                            anchors.fill: parent

                            spacing: 0

                            id: contentZone

376
                            FocusScope {
377 378
                                id: mainContentView

379
                                focus: true
380 381 382 383 384 385 386

                                Layout.fillHeight: true

                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0

Matthieu Gallien's avatar
Matthieu Gallien committed
387

388 389
                                visible: Layout.minimumWidth != 0

390 391 392 393 394 395 396 397
                                Rectangle {
                                    border {
                                        color: (mainContentView.activeFocus ? myPalette.highlight : myPalette.base)
                                        width: 1
                                    }

                                    radius: 3
                                    color: myPalette.base
398

399
                                    anchors.fill: parent
400

401 402
                                    BusyIndicator {
                                        id: busyScanningMusic
403
                                        hoverEnabled: false
404
                                        anchors.fill: parent
405

406 407 408 409
                                        anchors.leftMargin: parent.width / 3
                                        anchors.rightMargin: parent.width / 3
                                        anchors.topMargin: parent.height / 3
                                        anchors.bottomMargin: parent.height / 3
410

411
                                        opacity: 0.8
412

413 414
                                        visible: running

415
                                        z: 2
416 417 418 419 420 421 422 423
                                    }

                                    Loader {
                                        sourceComponent: Binding {
                                            target: busyScanningMusic
                                            property: 'running'
                                            value: elisa.musicManager.indexerBusy
                                        }
424

425
                                        active: elisa.musicManager !== undefined
426 427 428 429 430 431 432 433 434 435 436 437 438 439
                                    }

                                    MediaBrowser {
                                        id: localAlbums

                                        focus: true

                                        anchors {
                                            fill: parent

                                            leftMargin: elisaTheme.layoutHorizontalMargin
                                            rightMargin: elisaTheme.layoutHorizontalMargin
                                        }

440 441 442
                                        firstPage: GridBrowserView {
                                            id: allAlbumsView

443
                                            focus: true
444

445
                                            contentModel: elisa.allAlbumsProxyModel
446

447
                                            image: elisaTheme.albumIcon
448 449 450
                                            mainTitle: i18nc("Title of the view of all albums", "Albums")

                                            onOpen: {
451
                                                elisa.singleAlbumProxyModel.loadAlbumData(databaseId)
452 453 454
                                                localAlbums.stackView.push(albumView, {
                                                                               stackView: localAlbums.stackView,
                                                                               albumName: innerMainTitle,
455
                                                                               artistName:  innerSecondaryTitle,
456 457 458 459
                                                                               albumArtUrl: innerImage,
                                                                           })
                                            }
                                            onGoBack: localAlbums.stackView.pop()
460 461 462 463 464 465 466 467

                                            Binding {
                                                target: allAlbumsView
                                                property: 'filterState'
                                                value: persistentSettings.filterState
                                            }

                                            onFilterViewChanged: persistentSettings.filterState = filterState
468
                                        }
469

470
                                        visible: opacity > 0
471
                                    }
472

473 474
                                    MediaBrowser {
                                        id: localArtists
475

476
                                        focus: true
477

478 479 480 481 482 483
                                        anchors {
                                            fill: parent

                                            leftMargin: elisaTheme.layoutHorizontalMargin
                                            rightMargin: elisaTheme.layoutHorizontalMargin
                                        }
484

485
                                        firstPage: GridBrowserView {
486
                                            id: allArtistsView
487
                                            focus: true
488 489 490 491

                                            showRating: false
                                            delegateDisplaySecondaryText: false

492
                                            contentModel: elisa.allArtistsProxyModel
493

494
                                            image: elisaTheme.artistIcon
495 496 497
                                            mainTitle: i18nc("Title of the view of all artists", "Artists")

                                            onOpen: {
498
                                                elisa.singleArtistProxyModel.setArtistFilterText(innerMainTitle)
499 500 501 502 503 504
                                                localArtists.stackView.push(innerAlbumView, {
                                                                                mainTitle: innerMainTitle,
                                                                                secondaryTitle: innerSecondaryTitle,
                                                                                image: innerImage,
                                                                                stackView: localArtists.stackView
                                                                            })
505

506 507
                                            }
                                            onGoBack: localArtists.stackView.pop()
508 509 510 511 512 513 514 515

                                            Binding {
                                                target: allArtistsView
                                                property: 'filterState'
                                                value: persistentSettings.filterState
                                            }

                                            onFilterViewChanged: persistentSettings.filterState = filterState
516 517 518
                                        }

                                        visible: opacity > 0
519
                                    }
520

521 522
                                    MediaBrowser {
                                        id: localTracks
523

524
                                        focus: true
525

526 527 528 529 530 531
                                        anchors {
                                            fill: parent

                                            leftMargin: elisaTheme.layoutHorizontalMargin
                                            rightMargin: elisaTheme.layoutHorizontalMargin
                                        }
532

533
                                        firstPage: MediaAllTracksView {
534
                                            id: allTracksView
535
                                            focus: true
536
                                            stackView: localTracks.stackView
537

538
                                            contentModel: elisa.allTracksProxyModel
539 540 541 542 543 544 545 546

                                            Binding {
                                                target: allTracksView
                                                property: 'filterState'
                                                value: persistentSettings.filterState
                                            }

                                            onFilterViewChanged: persistentSettings.filterState = filterState
547 548 549
                                        }

                                        visible: opacity > 0
550 551
                                    }

552 553 554 555 556
                                    Behavior on border.color {
                                        ColorAnimation {
                                            duration: 300
                                        }
                                    }
557
                                }
558
                            }
559

560 561
                            Rectangle {
                                id: firstViewSeparatorItem
562

563 564 565 566
                                border.width: 1
                                border.color: myPalette.mid
                                color: myPalette.mid
                                visible: true
567

568 569
                                Layout.bottomMargin: elisaTheme.layoutVerticalMargin
                                Layout.topMargin: elisaTheme.layoutVerticalMargin
570

571
                                Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
572

573
                                Layout.fillHeight: true
574

575 576 577 578
                                Layout.preferredWidth: 1
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                            }
579

580 581
                            MediaPlayListView {
                                id: playList
582

583
                                playListModel: elisa.mediaPlayList
584

585 586
                                randomPlayChecked: elisa.mediaPlayList.randomPlay
                                repeatPlayChecked: elisa.mediaPlayList.repeatPlay
587

588
                                Layout.fillHeight: true
589 590
                                Layout.leftMargin: elisaTheme.layoutHorizontalMargin
                                Layout.rightMargin: elisaTheme.layoutHorizontalMargin
591

592 593 594
                                Layout.minimumWidth: contentZone.width
                                Layout.maximumWidth: contentZone.width
                                Layout.preferredWidth: contentZone.width
595

596 597 598
                                onStartPlayback: manageAudioPlayer.ensurePlay()

                                onPausePlayback: manageAudioPlayer.playPause()
599 600

                                onDisplayError: messageNotification.showNotification(errorText)
601
                            }
602

603 604
                            Rectangle {
                                id: viewSeparatorItem
605

606 607 608 609
                                border.width: 1
                                border.color: myPalette.mid
                                color: myPalette.mid
                                visible: Layout.minimumWidth != 0
610

611 612
                                Layout.bottomMargin: elisaTheme.layoutVerticalMargin
                                Layout.topMargin: elisaTheme.layoutVerticalMargin
613

614
                                Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
615

616
                                Layout.fillHeight: true
617

618 619 620 621
                                Layout.preferredWidth: 1
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                            }
622

623 624
                            ContextView {
                                id: albumContext
625

626
                                Layout.fillHeight: true
627

628 629 630
                                Layout.minimumWidth: contentZone.width
                                Layout.maximumWidth: contentZone.width
                                Layout.preferredWidth: contentZone.width
631

632
                                visible: Layout.minimumWidth != 0
633

634 635 636 637
                                artistName: myHeaderBarManager.artist
                                albumName: myHeaderBarManager.album
                                albumArtUrl: myHeaderBarManager.image
                            }
638 639
                        }
                    }
640 641

                    states: [
642 643
                        State {
                            name: 'full'
644
                            when: listViews.currentIndex === 0
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
                            PropertyChanges {
                                target: mainContentView
                                Layout.fillWidth: false
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
                            }
                            PropertyChanges {
                                target: firstViewSeparatorItem
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
                            }
                            PropertyChanges {
                                target: playList
                                Layout.minimumWidth: contentZone.width / 2
                                Layout.maximumWidth: contentZone.width / 2
                                Layout.preferredWidth: contentZone.width / 2
                            }
                            PropertyChanges {
                                target: viewSeparatorItem
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                                Layout.preferredWidth: 1
                            }
                            PropertyChanges {
                                target: albumContext
                                Layout.minimumWidth: contentZone.width / 2
                                Layout.maximumWidth: contentZone.width / 2
                                Layout.preferredWidth: contentZone.width / 2
                            }
                            PropertyChanges {
                                target: localAlbums
                                opacity: 0
                            }
                            PropertyChanges {
                                target: localArtists
                                opacity: 0
                            }
                            PropertyChanges {
                                target: localTracks
                                opacity: 0
                            }
                        },
689
                        State {
690
                            name: 'allAlbums'
691
                            when: listViews.currentIndex === 1
692 693 694 695 696
                            StateChangeScript {
                                script: {
                                    localAlbums.stackView.pop({item: null, immediate: true})
                                }
                            }
697 698
                            PropertyChanges {
                                target: mainContentView
699
                                Layout.fillWidth: true
700 701 702
                                Layout.minimumWidth: contentZone.width * 0.66
                                Layout.maximumWidth: contentZone.width * 0.68
                                Layout.preferredWidth: contentZone.width * 0.68
703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727
                            }
                            PropertyChanges {
                                target: firstViewSeparatorItem
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                                Layout.preferredWidth: 1
                            }
                            PropertyChanges {
                                target: playList
                                Layout.minimumWidth: contentZone.width * 0.33
                                Layout.maximumWidth: contentZone.width * 0.33
                                Layout.preferredWidth: contentZone.width * 0.33
                            }
                            PropertyChanges {
                                target: viewSeparatorItem
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
                            }
                            PropertyChanges {
                                target: albumContext
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
                            }
728 729 730 731 732 733 734 735
                            PropertyChanges {
                                target: localAlbums
                                opacity: 1
                            }
                            PropertyChanges {
                                target: localArtists
                                opacity: 0
                            }
736 737 738 739
                            PropertyChanges {
                                target: localTracks
                                opacity: 0
                            }
740 741 742
                        },
                        State {
                            name: 'allArtists'
743
                            when: listViews.currentIndex === 2
744 745 746 747 748
                            StateChangeScript {
                                script: {
                                    localArtists.stackView.pop({item: null, immediate: true})
                                }
                            }
749 750
                            PropertyChanges {
                                target: mainContentView
751
                                Layout.fillWidth: true
752 753 754
                                Layout.minimumWidth: contentZone.width * 0.66
                                Layout.maximumWidth: contentZone.width * 0.68
                                Layout.preferredWidth: contentZone.width * 0.68
755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787
                            }
                            PropertyChanges {
                                target: firstViewSeparatorItem
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                                Layout.preferredWidth: 1
                            }
                            PropertyChanges {
                                target: playList
                                Layout.minimumWidth: contentZone.width * 0.33
                                Layout.maximumWidth: contentZone.width * 0.33
                                Layout.preferredWidth: contentZone.width * 0.33
                            }
                            PropertyChanges {
                                target: viewSeparatorItem
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
                            }
                            PropertyChanges {
                                target: albumContext
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
                            }
                            PropertyChanges {
                                target: localAlbums
                                opacity: 0
                            }
                            PropertyChanges {
                                target: localArtists
                                opacity: 1
                            }
788 789 790 791
                            PropertyChanges {
                                target: localTracks
                                opacity: 0
                            }
792 793
                        },
                        State {
794
                            name: 'allTracks'
795
                            when: listViews.currentIndex === 3
796 797
                            PropertyChanges {
                                target: mainContentView
798
                                Layout.fillWidth: true
799 800 801
                                Layout.minimumWidth: contentZone.width * 0.66
                                Layout.maximumWidth: contentZone.width * 0.68
                                Layout.preferredWidth: contentZone.width * 0.68
802 803 804
                            }
                            PropertyChanges {
                                target: firstViewSeparatorItem
805 806 807
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                                Layout.preferredWidth: 1
808 809 810
                            }
                            PropertyChanges {
                                target: playList
811 812 813
                                Layout.minimumWidth: contentZone.width * 0.33
                                Layout.maximumWidth: contentZone.width * 0.33
                                Layout.preferredWidth: contentZone.width * 0.33
814 815 816
                            }
                            PropertyChanges {
                                target: viewSeparatorItem
817 818 819
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
820 821 822
                            }
                            PropertyChanges {
                                target: albumContext
823 824 825
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
826
                            }
827 828 829 830 831 832 833 834
                            PropertyChanges {
                                target: localAlbums
                                opacity: 0
                            }
                            PropertyChanges {
                                target: localArtists
                                opacity: 0
                            }
835 836 837 838
                            PropertyChanges {
                                target: localTracks
                                opacity: 1
                            }
839 840 841 842
                        }
                    ]
                    transitions: Transition {
                        NumberAnimation {
843
                            properties: "Layout.minimumWidth, Layout.maximumWidth, Layout.preferredWidth, opacity"
844 845 846
                            easing.type: Easing.InOutQuad
                            duration: 300
                        }
847 848
                    }
                }
849 850 851
            }
        }
    }
852 853 854 855 856

    Component {
        id: innerAlbumView

        GridBrowserView {
857
            id: innerAlbumGridView
858 859
            property var stackView

860
            contentModel: elisa.singleArtistProxyModel
861 862 863

            isSubPage: true

864
            onOpen: {
865
                elisa.singleAlbumProxyModel.loadAlbumData(databaseId)
866 867 868
                localArtists.stackView.push(albumView, {
                                                stackView: localArtists.stackView,
                                                albumName: innerMainTitle,
869
                                                artistName: innerSecondaryTitle,
870
                                                albumArtUrl: innerImage,
871 872 873
                                            })
            }
            onGoBack: stackView.pop()
874 875 876 877 878 879 880 881

            Binding {
                target: innerAlbumGridView
                property: 'filterState'
                value: persistentSettings.filterState
            }

            onFilterViewChanged: persistentSettings.filterState = filterState
882 883 884 885 886 887 888
        }
    }

    Component {
        id: albumView

        MediaAlbumView {
889
            id: albumGridView
890
            property var stackView
891

892
            contentModel: elisa.singleAlbumProxyModel
893

894 895 896 897 898 899 900 901 902 903 904 905 906
            onShowArtist: {
                listViews.currentIndex = 2
                if (localArtists.stackView.depth === 3) {
                    localArtists.stackView.pop()
                }
                if (localArtists.stackView.depth === 2) {
                    var artistPage = localArtists.stackView.get(1)
                    if (artistPage.mainTitle === name) {
                        return
                    } else {
                        localArtists.stackView.pop()
                    }
                }
907
                allArtistsView.open(name, name, elisaTheme.defaultArtistImage, '')
908 909
            }
            onGoBack: stackView.pop()
910 911 912 913 914 915 916 917

            Binding {
                target: albumGridView
                property: 'filterState'
                value: persistentSettings.filterState
            }

            onFilterViewChanged: persistentSettings.filterState = filterState
918 919
        }
    }
920 921 922 923 924 925 926 927 928

    Component.onCompleted:
    {
        elisa.initialize()

        elisa.mediaPlayList.randomPlay = Qt.binding(function() { return playList.randomPlayChecked })
        elisa.mediaPlayList.repeatPlay = Qt.binding(function() { return playList.repeatPlayChecked })
        myPlayControlManager.randomOrContinuePlay = Qt.binding(function() { return playList.randomPlayChecked || playList.repeatPlayChecked })

929 930 931 932
        if (persistentSettings.playListState) {
            elisa.mediaPlayList.persistentState = persistentSettings.playListState
        }

Alexander Stippich's avatar
Alexander Stippich committed
933 934 935 936 937

        elisa.audioPlayer.muted = Qt.binding(function() { return headerBar.playerControl.muted })
        elisa.audioPlayer.volume = Qt.binding(function() { return headerBar.playerControl.volume })
        elisa.audioPlayer.source = Qt.binding(function() { return manageAudioPlayer.playerSource })

938
        elisa.mediaPlayList.enqueue(elisa.arguments)
Alexander Stippich's avatar
Alexander Stippich committed
939
        volume: headerBar.playerControl.volume
940
    }
941
}