ElisaMainWindow.qml 34.7 KB
Newer Older
1
/*
2
 * Copyright 2016-2017 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
21 22 23 24
import QtQuick.Controls 1.3
import QtQuick.Controls.Styles 1.3
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    Action {
        text: goBackAction.text
        shortcut: goBackAction.shortcut
        iconName: elisa.iconName(goBackAction.icon)
        onTriggered: {
            localAlbums.goBack()
            localArtists.goBack()
        }
    }

    Action {
        id: applicationMenuAction
        text: i18nc("open application menu", "Application Menu")
        iconName: "application-menu"
        onTriggered: applicationMenu.popup()
    }

    ApplicationMenu {
        id: applicationMenu
    }

69 70 71 72 73
    SystemPalette {
        id: myPalette
        colorGroup: SystemPalette.Active
    }

74 75 76 77
    Theme {
        id: elisaTheme
    }

78
    Settings {
79 80 81 82
        id: persistentSettings

        property int x
        property int y
83 84
        property int width : 1000
        property int height : 600
85

86
        property var playListState
87 88

        property var playListControlerState
89 90

        property var audioPlayerState
91

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

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

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

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

114 115
    PlatformIntegration {
        id: platformInterface
116

117 118
        playListModel: elisa.mediaPlayList
        playListControler: elisa.mediaPlayList
119 120 121
        audioPlayerManager: manageAudioPlayer
        headerBarManager: myHeaderBarManager
        manageMediaPlayerControl: myPlayControlManager
122
        player: audioPlayer
123 124 125

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

132
    AudioWrapper {
133 134
        id: audioPlayer

135
        muted: headerBar.playerControl.muted
136

137
        volume: headerBar.playerControl.volume
138

139
        onVolumeChanged: headerBar.playerControl.volume = volume
140
        onMutedChanged: headerBar.playerControl.muted = muted
141

142 143 144 145 146 147 148 149 150
        source: manageAudioPlayer.playerSource

        onPlaying: {
            myPlayControlManager.playerPlaying()
        }

        onPaused: {
            myPlayControlManager.playerPaused()
        }
151

152 153 154
        onStopped: {
            myPlayControlManager.playerStopped()
        }
155 156
    }

Alexander Stippich's avatar
Alexander Stippich committed
157
    Connections {
158
        target: elisa.mediaPlayList
Alexander Stippich's avatar
Alexander Stippich committed
159
        onPlayListLoadFailed: {
160 161
            messageNotification.showNotification(i18nc("message of passive notification when playlist load failed", "Load of playlist failed"), 3000)
        }
Alexander Stippich's avatar
Alexander Stippich committed
162 163
        onEnsurePlay: manageAudioPlayer.ensurePlay()
        onPlayListFinished: manageAudioPlayer.playListFinished()
164 165
    }

166 167 168
    ManageHeaderBar {
        id: myHeaderBarManager

169 170
        playListModel: elisa.mediaPlayList
        currentTrack: elisa.mediaPlayList.currentTrack
171

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

    ManageAudioPlayer {
        id: manageAudioPlayer

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

190 191 192
        playerStatus: audioPlayer.status
        playerPlaybackState: audioPlayer.playbackState
        playerError: audioPlayer.error
193
        audioDuration: audioPlayer.duration
194
        playerIsSeekable: audioPlayer.seekable
195
        playerPosition: audioPlayer.position
196

197
        persistentState: persistentSettings.audioPlayerState
198

199 200 201
        onPlayerPlay: audioPlayer.play()
        onPlayerPause: audioPlayer.pause()
        onPlayerStop: audioPlayer.stop()
202
        onSkipNextTrack: elisa.mediaPlayList.skipNextTrack()
203
        onSeek: audioPlayer.seek(position)
204 205
        onSourceInError:
        {
206
            elisa.mediaPlayList.trackInError(source, playerError)
207 208 209 210
            allListeners.playBackError(source, playerError)
        }

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

    ManageMediaPlayerControl {
        id: myPlayControlManager

216 217
        playListModel: elisa.mediaPlayList
        currentTrack: elisa.mediaPlayList.currentTrack
218 219
    }

220 221 222 223
    PassiveNotification {
        id: messageNotification
    }

224
    Rectangle {
225
        color: myPalette.base
226 227
        anchors.fill: parent

228 229 230
        ColumnLayout {
            anchors.fill: parent
            spacing: 0
231

232 233 234 235
            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
236
                Layout.fillWidth: true
237

238 239
                HeaderBar {
                    id: headerBar
240

241 242
                    focus: true

243
                    anchors.fill: parent
244

245 246 247 248 249
                    tracksCount: myHeaderBarManager.remainingTracks
                    album: myHeaderBarManager.album
                    title: myHeaderBarManager.title
                    artist: myHeaderBarManager.artist
                    image: myHeaderBarManager.image
250

251
                    ratingVisible: false
252

253 254
                    playerControl.duration: audioPlayer.duration
                    playerControl.seekable: audioPlayer.seekable
255

256 257 258 259 260 261 262
                    playerControl.volume: persistentSettings.playControlItemVolume
                    playerControl.muted: persistentSettings.playControlItemMuted
                    playerControl.position: audioPlayer.position
                    playerControl.skipBackwardEnabled: myPlayControlManager.skipBackwardControlEnabled
                    playerControl.skipForwardEnabled: myPlayControlManager.skipForwardControlEnabled
                    playerControl.playEnabled: myPlayControlManager.playControlEnabled
                    playerControl.isPlaying: myPlayControlManager.musicPlaying
263

264
                    playerControl.onSeek: audioPlayer.seek(position)
265

266 267
                    playerControl.onPlay: manageAudioPlayer.playPause()
                    playerControl.onPause: manageAudioPlayer.playPause()
268

269 270
                    playerControl.onPlayPrevious: elisa.mediaPlayList.skipPreviousTrack()
                    playerControl.onPlayNext: elisa.mediaPlayList.skipNextTrack()
271

272 273
                    ToolButton {
                        id: menuButton
274

275
                        action: applicationMenuAction
276

277
                        z: 2
278

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

290
                        z: 1
291

292
                        radius: width / 2
293

294 295
                        color: myPalette.window
                    }
296

297
                    TrackImportNotification {
298 299 300 301 302 303 304 305 306
                        id: importedTracksCountNotification

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

                    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
                        }
332

333
                        active: elisa.musicManager !== undefined
334
                    }
335
                }
336
            }
337

338
            RowLayout {
339
                Layout.fillHeight: true
340 341
                Layout.fillWidth: true
                spacing: 0
342

343 344
                ViewSelector {
                    id: listViews
345

346
                    Layout.fillHeight: true
347 348
                    Layout.preferredWidth: mainWindow.width * 0.15
                    Layout.maximumWidth: mainWindow.width * 0.15
349 350
                }

351
                ColumnLayout {
352 353
                    Layout.fillHeight: true
                    Layout.fillWidth: true
354

355
                    spacing: 0
356

357
                    TopNotification {
358
                        id: invalidBalooConfiguration
359

360
                        Layout.fillWidth: true
361

362
                        musicManager: elisa.musicManager
363

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

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

                        RowLayout {
                            anchors.fill: parent

                            spacing: 0

                            id: contentZone

378
                            FocusScope {
379 380
                                id: mainContentView

381
                                focus: true
382 383 384 385 386 387 388

                                Layout.fillHeight: true

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

Matthieu Gallien's avatar
Matthieu Gallien committed
389

390 391
                                visible: Layout.minimumWidth != 0

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

                                    radius: 3
                                    color: myPalette.base
400

401
                                    anchors.fill: parent
402

403 404
                                    BusyIndicator {
                                        id: busyScanningMusic
405

406
                                        anchors.fill: parent
407

408 409 410 411
                                        anchors.leftMargin: parent.width / 3
                                        anchors.rightMargin: parent.width / 3
                                        anchors.topMargin: parent.height / 3
                                        anchors.bottomMargin: parent.height / 3
412

413
                                        opacity: 0.8
414

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.sourceModel.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
                                        visible: opacity > 0
463
                                    }
464

465 466
                                    MediaBrowser {
                                        id: localArtists
467

468
                                        focus: true
469

470 471 472 473 474 475
                                        anchors {
                                            fill: parent

                                            leftMargin: elisaTheme.layoutHorizontalMargin
                                            rightMargin: elisaTheme.layoutHorizontalMargin
                                        }
476

477
                                        firstPage: GridBrowserView {
478
                                            id: allArtistsView
479
                                            focus: true
480 481 482 483

                                            showRating: false
                                            delegateDisplaySecondaryText: false

484
                                            contentModel: elisa.allArtistsProxyModel
485

486
                                            image: elisaTheme.artistIcon
487 488 489
                                            mainTitle: i18nc("Title of the view of all artists", "Artists")

                                            onOpen: {
490
                                                elisa.singleArtistProxyModel.setArtistFilterText(innerMainTitle)
491 492 493 494 495 496
                                                localArtists.stackView.push(innerAlbumView, {
                                                                                mainTitle: innerMainTitle,
                                                                                secondaryTitle: innerSecondaryTitle,
                                                                                image: innerImage,
                                                                                stackView: localArtists.stackView
                                                                            })
497

498 499
                                            }
                                            onGoBack: localArtists.stackView.pop()
500 501 502
                                        }

                                        visible: opacity > 0
503
                                    }
504

505 506
                                    MediaBrowser {
                                        id: localTracks
507

508
                                        focus: true
509

510 511 512 513 514 515
                                        anchors {
                                            fill: parent

                                            leftMargin: elisaTheme.layoutHorizontalMargin
                                            rightMargin: elisaTheme.layoutHorizontalMargin
                                        }
516

517
                                        firstPage: MediaAllTracksView {
518
                                            focus: true
519
                                            stackView: localTracks.stackView
520

521
                                            contentModel: elisa.allTracksProxyModel
522 523 524
                                        }

                                        visible: opacity > 0
525 526
                                    }

527 528 529 530 531
                                    Behavior on border.color {
                                        ColorAnimation {
                                            duration: 300
                                        }
                                    }
532
                                }
533
                            }
534

535 536
                            Rectangle {
                                id: firstViewSeparatorItem
537

538 539 540 541
                                border.width: 1
                                border.color: myPalette.mid
                                color: myPalette.mid
                                visible: true
542

543 544
                                Layout.bottomMargin: elisaTheme.layoutVerticalMargin
                                Layout.topMargin: elisaTheme.layoutVerticalMargin
545

546
                                Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
547

548
                                Layout.fillHeight: true
549

550 551 552 553
                                Layout.preferredWidth: 1
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                            }
554

555 556
                            MediaPlayListView {
                                id: playList
557

558
                                playListModel: elisa.mediaPlayList
559

560 561
                                randomPlayChecked: elisa.mediaPlayList.randomPlay
                                repeatPlayChecked: elisa.mediaPlayList.repeatPlay
562

563
                                Layout.fillHeight: true
564 565
                                Layout.leftMargin: elisaTheme.layoutHorizontalMargin
                                Layout.rightMargin: elisaTheme.layoutHorizontalMargin
566

567 568 569
                                Layout.minimumWidth: contentZone.width
                                Layout.maximumWidth: contentZone.width
                                Layout.preferredWidth: contentZone.width
570

571 572 573
                                onStartPlayback: manageAudioPlayer.ensurePlay()

                                onPausePlayback: manageAudioPlayer.playPause()
574 575

                                onDisplayError: messageNotification.showNotification(errorText)
576
                            }
577

578 579
                            Rectangle {
                                id: viewSeparatorItem
580

581 582 583 584
                                border.width: 1
                                border.color: myPalette.mid
                                color: myPalette.mid
                                visible: Layout.minimumWidth != 0
585

586 587
                                Layout.bottomMargin: elisaTheme.layoutVerticalMargin
                                Layout.topMargin: elisaTheme.layoutVerticalMargin
588

589
                                Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
590

591
                                Layout.fillHeight: true
592

593 594 595 596
                                Layout.preferredWidth: 1
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                            }
597

598 599
                            ContextView {
                                id: albumContext
600

601
                                Layout.fillHeight: true
602

603 604 605
                                Layout.minimumWidth: contentZone.width
                                Layout.maximumWidth: contentZone.width
                                Layout.preferredWidth: contentZone.width
606

607
                                visible: Layout.minimumWidth != 0
608

609 610 611 612
                                artistName: myHeaderBarManager.artist
                                albumName: myHeaderBarManager.album
                                albumArtUrl: myHeaderBarManager.image
                            }
613 614
                        }
                    }
615 616

                    states: [
617 618
                        State {
                            name: 'full'
619
                            when: listViews.currentIndex === 0
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
                            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
                            }
                        },
664
                        State {
665
                            name: 'allAlbums'
666
                            when: listViews.currentIndex === 1
667 668 669 670 671
                            StateChangeScript {
                                script: {
                                    localAlbums.stackView.pop({item: null, immediate: true})
                                }
                            }
672 673
                            PropertyChanges {
                                target: mainContentView
674
                                Layout.fillWidth: true
675 676 677
                                Layout.minimumWidth: contentZone.width * 0.66
                                Layout.maximumWidth: contentZone.width * 0.68
                                Layout.preferredWidth: contentZone.width * 0.68
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
                            }
                            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
                            }
703 704 705 706 707 708 709 710
                            PropertyChanges {
                                target: localAlbums
                                opacity: 1
                            }
                            PropertyChanges {
                                target: localArtists
                                opacity: 0
                            }
711 712 713 714
                            PropertyChanges {
                                target: localTracks
                                opacity: 0
                            }
715 716 717
                        },
                        State {
                            name: 'allArtists'
718
                            when: listViews.currentIndex === 2
719 720 721 722 723
                            StateChangeScript {
                                script: {
                                    localArtists.stackView.pop({item: null, immediate: true})
                                }
                            }
724 725
                            PropertyChanges {
                                target: mainContentView
726
                                Layout.fillWidth: true
727 728 729
                                Layout.minimumWidth: contentZone.width * 0.66
                                Layout.maximumWidth: contentZone.width * 0.68
                                Layout.preferredWidth: contentZone.width * 0.68
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762
                            }
                            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
                            }
763 764 765 766
                            PropertyChanges {
                                target: localTracks
                                opacity: 0
                            }
767 768
                        },
                        State {
769
                            name: 'allTracks'
770
                            when: listViews.currentIndex === 3
771 772
                            PropertyChanges {
                                target: mainContentView
773
                                Layout.fillWidth: true
774 775 776
                                Layout.minimumWidth: contentZone.width * 0.66
                                Layout.maximumWidth: contentZone.width * 0.68
                                Layout.preferredWidth: contentZone.width * 0.68
777 778 779
                            }
                            PropertyChanges {
                                target: firstViewSeparatorItem
780 781 782
                                Layout.minimumWidth: 1
                                Layout.maximumWidth: 1
                                Layout.preferredWidth: 1
783 784 785
                            }
                            PropertyChanges {
                                target: playList
786 787 788
                                Layout.minimumWidth: contentZone.width * 0.33
                                Layout.maximumWidth: contentZone.width * 0.33
                                Layout.preferredWidth: contentZone.width * 0.33
789 790 791
                            }
                            PropertyChanges {
                                target: viewSeparatorItem
792 793 794
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
795 796 797
                            }
                            PropertyChanges {
                                target: albumContext
798 799 800
                                Layout.minimumWidth: 0
                                Layout.maximumWidth: 0
                                Layout.preferredWidth: 0
801
                            }
802 803 804 805 806 807 808 809
                            PropertyChanges {
                                target: localAlbums
                                opacity: 0
                            }
                            PropertyChanges {
                                target: localArtists
                                opacity: 0
                            }
810 811 812 813
                            PropertyChanges {
                                target: localTracks
                                opacity: 1
                            }
814 815 816 817
                        }
                    ]
                    transitions: Transition {
                        NumberAnimation {
818
                            properties: "Layout.minimumWidth, Layout.maximumWidth, Layout.preferredWidth, opacity"
819 820 821
                            easing.type: Easing.InOutQuad
                            duration: 300
                        }
822 823
                    }
                }
824 825 826
            }
        }
    }
827 828 829 830 831 832 833

    Component {
        id: innerAlbumView

        GridBrowserView {
            property var stackView

834
            contentModel: elisa.singleArtistProxyModel
835 836 837

            isSubPage: true

838
            onOpen: {
839
                elisa.singleAlbumProxyModel.sourceModel.loadAlbumData(databaseId)
840 841 842
                localArtists.stackView.push(albumView, {
                                                stackView: localArtists.stackView,
                                                albumName: innerMainTitle,
843
                                                artistName: innerSecondaryTitle,
844
                                                albumArtUrl: innerImage,
845 846 847 848 849 850 851 852 853 854 855
                                            })
            }
            onGoBack: stackView.pop()
        }
    }

    Component {
        id: albumView

        MediaAlbumView {
            property var stackView
856

857
            contentModel: elisa.singleAlbumProxyModel
858

859 860 861 862 863 864 865 866 867 868 869 870 871
            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()
                    }
                }
872
                allArtistsView.open(name, name, elisaTheme.defaultArtistImage, '')
873 874 875 876
            }
            onGoBack: stackView.pop()
        }
    }
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893

    Component.onCompleted:
    {
        elisa.initialize()

        var d = new Date();
        var n = d.getMilliseconds();
        elisa.mediaPlayList.seedRandomGenerator(n);

        elisa.mediaPlayList.enqueue(elisa.arguments)

        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 })

        elisa.mediaPlayList.persistentState = persistentSettings.playListState
    }
894
}