diff --git a/src/qml/ContentView.qml b/src/qml/ContentView.qml index fa6fd8b7..138af942 100644 --- a/src/qml/ContentView.qml +++ b/src/qml/ContentView.qml @@ -1,621 +1,605 @@ /* * Copyright 2016-2018 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQuick.Layouts 1.2 import QtQuick.Window 2.2 import org.kde.elisa 1.0 RowLayout { id: contentViewContainer spacing: 0 property bool showPlaylist property alias currentViewIndex: listViews.currentIndex signal toggleSearch() function goBack() { viewManager.goBack() } ViewManager { id: viewManager onSwitchOffAllViews: { listViews.currentIndex = 0 while(browseStackView.depth > 1) { browseStackView.pop() } } onSwitchRecentlyPlayedTracksView: { listViews.currentIndex = 1 while(browseStackView.depth > 1) { browseStackView.pop() } browseStackView.push(allRecentlyPlayedTracksView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, stackView: browseStackView, opacity: 0, }) recentlyPlayedTracksIsLoaded() } onSwitchFrequentlyPlayedTracksView: { listViews.currentIndex = 2 while(browseStackView.depth > 1) { browseStackView.pop() } browseStackView.push(allRecentlyPlayedTracksView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, stackView: browseStackView, opacity: 0, }) frequentlyPlayedTracksIsLoaded() } onSwitchAllAlbumsView: { listViews.currentIndex = 3 while(browseStackView.depth > 1) { browseStackView.pop() } browseStackView.push(dataGridView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, defaultIcon: viewDefaultIcon, showRating: viewShowRating, delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText, isSubPage: false, stackView: browseStackView, opacity: 0, }) allAlbumsViewIsLoaded() } onSwitchOneAlbumView: { browseStackView.push(albumView, { mainTitle: mainTitle, secondaryTitle: secondaryTitle, image: imageUrl, stackView: browseStackView, opacity: 0, }) oneAlbumViewIsLoaded() } onSwitchAllArtistsView: { listViews.currentIndex = 4 while(browseStackView.depth > 1) { browseStackView.pop() } browseStackView.push(dataGridView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, defaultIcon: viewDefaultIcon, showRating: viewShowRating, delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText, isSubPage: false, stackView: browseStackView, opacity: 0, }) allArtistsViewIsLoaded() } onSwitchOneArtistView: { browseStackView.push(dataGridView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, defaultIcon: viewDefaultIcon, showRating: viewShowRating, delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText, isSubPage: true, artistFilter: mainTitle, opacity: 0, }) oneArtistViewIsLoaded() } onSwitchAllTracksView: { listViews.currentIndex = 5 while(browseStackView.depth > 1) { browseStackView.pop() } browseStackView.push(allTracksView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, stackView: browseStackView, opacity: 0, }) allTracksViewIsLoaded() } onSwitchAllGenresView: { listViews.currentIndex = 6 while(browseStackView.depth > 1) { browseStackView.pop() } browseStackView.push(dataGridView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, defaultIcon: viewDefaultIcon, showRating: viewShowRating, delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText, isSubPage: false, stackView: browseStackView, opacity: 0, }) allGenresViewIsLoaded() } onSwitchAllArtistsFromGenreView: { browseStackView.push(dataGridView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, defaultIcon: viewDefaultIcon, showRating: viewShowRating, delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText, isSubPage: true, genreFilterText: mainTitle, opacity: 0, }) allArtistsFromGenreViewIsLoaded() } onSwitchOneArtistFromGenreView: { browseStackView.push(dataGridView, { mainTitle: mainTitle, image: imageUrl, modelType: dataType, defaultIcon: viewDefaultIcon, showRating: viewShowRating, delegateDisplaySecondaryText: viewDelegateDisplaySecondaryText, isSubPage: true, genreFilterText: genreName, artistFilter: mainTitle, opacity: 0, }) oneArtistViewIsLoaded() } onSwitchFilesBrowserView: { listViews.currentIndex = 7 while(browseStackView.depth > 1) { browseStackView.pop() } } onPopOneView: browseStackView.pop() } ViewSelector { id: listViews Layout.fillHeight: true Layout.maximumWidth: mainWindow.width * 0.14 maximumSize: mainWindow.width * 0.14 Behavior on Layout.maximumWidth { NumberAnimation { duration: 150 } } - onSwitchView: if (index === 1) { - viewManager.openRecentlyPlayedTracks(mainTitle, imageUrl) - } else if (index === 2) { - viewManager.openFrequentlyPlayedTracks(mainTitle, imageUrl) - } else if (index === 3) { - viewManager.openAllAlbums(mainTitle, imageUrl) - } else if (index === 4) { - viewManager.openAllArtists(mainTitle, imageUrl) - } else if (index === 5) { - viewManager.openAllTracks(mainTitle, imageUrl) - } else if (index === 6) { - viewManager.openAllGenres(mainTitle, imageUrl) - } else if (index === 7) { - viewManager.openFilesBrowser(mainTitle, imageUrl) - } else { - viewManager.closeAllViews() - } + onSwitchView: viewManager.openParentView(viewType, mainTitle, imageUrl) } Rectangle { id: viewSelectorSeparatorItem border.width: 1 border.color: myPalette.mid color: myPalette.mid visible: true Layout.bottomMargin: elisaTheme.layoutVerticalMargin Layout.topMargin: elisaTheme.layoutVerticalMargin Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.fillHeight: true Layout.preferredWidth: 1 Layout.minimumWidth: 1 Layout.maximumWidth: 1 } ColumnLayout { Layout.fillHeight: true Layout.fillWidth: true spacing: 0 TopNotification { id: invalidBalooConfiguration Layout.fillWidth: true musicManager: elisa.musicManager focus: true } Item { Layout.fillHeight: true Layout.fillWidth: true RowLayout { anchors.fill: parent spacing: 0 id: contentZone FocusScope { id: mainContentView focus: true Layout.fillHeight: true Layout.minimumWidth: 0 Layout.maximumWidth: 0 Layout.preferredWidth: 0 visible: Layout.minimumWidth != 0 Rectangle { border { color: (mainContentView.activeFocus ? myPalette.highlight : myPalette.base) width: 1 } radius: 3 color: myPalette.base anchors.fill: parent StackView { id: browseStackView anchors.fill: parent clip: true initialItem: Item { } popEnter: Transition { OpacityAnimator { from: 0.0 to: 1.0 duration: 300 } } popExit: Transition { OpacityAnimator { from: 1.0 to: 0.0 duration: 300 } } pushEnter: Transition { OpacityAnimator { from: 0.0 to: 1.0 duration: 300 } } pushExit: Transition { OpacityAnimator { from: 1.0 to: 0.0 duration: 300 } } replaceEnter: Transition { OpacityAnimator { from: 0.0 to: 1.0 duration: 300 } } replaceExit: Transition { OpacityAnimator { from: 1.0 to: 0.0 duration: 300 } } } Behavior on border.color { ColorAnimation { duration: 300 } } } } Rectangle { id: firstViewSeparatorItem border.width: 1 border.color: myPalette.mid color: myPalette.mid visible: true Layout.bottomMargin: elisaTheme.layoutVerticalMargin Layout.topMargin: elisaTheme.layoutVerticalMargin Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.fillHeight: true Layout.preferredWidth: 1 Layout.minimumWidth: 1 Layout.maximumWidth: 1 } MediaPlayListView { id: playList Layout.fillHeight: true Layout.leftMargin: elisaTheme.layoutHorizontalMargin Layout.rightMargin: elisaTheme.layoutHorizontalMargin Layout.minimumWidth: contentZone.width Layout.maximumWidth: contentZone.width Layout.preferredWidth: contentZone.width onStartPlayback: elisa.audioControl.ensurePlay() onPausePlayback: elisa.audioControl.playPause() onDisplayError: messageNotification.showNotification(errorText) } Rectangle { id: viewSeparatorItem border.width: 1 border.color: myPalette.mid color: myPalette.mid visible: Layout.minimumWidth != 0 Layout.bottomMargin: elisaTheme.layoutVerticalMargin Layout.topMargin: elisaTheme.layoutVerticalMargin Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter Layout.fillHeight: true Layout.preferredWidth: 1 Layout.minimumWidth: 1 Layout.maximumWidth: 1 } ContextView { id: albumContext Layout.fillHeight: true Layout.minimumWidth: contentZone.width Layout.maximumWidth: contentZone.width Layout.preferredWidth: contentZone.width visible: Layout.minimumWidth != 0 artistName: elisa.manageHeaderBar.artist albumName: elisa.manageHeaderBar.album albumArtUrl: elisa.manageHeaderBar.image } } } states: [ State { name: 'playList' when: listViews.currentIndex === 0 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 } }, State { name: "browsingViewsNoPlaylist" when: listViews.currentIndex !== 0 && contentViewContainer.showPlaylist !== true extend: "browsingViews" PropertyChanges { target: mainContentView Layout.fillWidth: true Layout.minimumWidth: contentZone.width Layout.maximumWidth: contentZone.width Layout.preferredWidth: contentZone.width } PropertyChanges { target: playList Layout.minimumWidth: 0 Layout.maximumWidth: 0 Layout.preferredWidth: 0 } }, State { name: 'browsingViews' when: listViews.currentIndex !== 0 PropertyChanges { target: mainContentView Layout.fillWidth: true Layout.minimumWidth: contentZone.width * 0.66 Layout.maximumWidth: contentZone.width * 0.68 Layout.preferredWidth: contentZone.width * 0.68 } 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 } } ] transitions: Transition { NumberAnimation { properties: "Layout.minimumWidth, Layout.maximumWidth, Layout.preferredWidth, opacity" easing.type: Easing.InOutQuad duration: 300 } } } Component { id: allFrequentlyPlayedTracksView FrequentlyPlayedTracks { } } Component { id: allRecentlyPlayedTracksView RecentlyPlayedTracks { } } Component { id: dataGridView DataGridView { } } Component { id: allTracksView TracksView { } } Component { id: albumView AlbumView { } } } diff --git a/src/qml/ViewSelector.qml b/src/qml/ViewSelector.qml index 3548bb9e..3f8ef0fa 100644 --- a/src/qml/ViewSelector.qml +++ b/src/qml/ViewSelector.qml @@ -1,250 +1,250 @@ /* * Copyright 2016-2017 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ import QtQuick 2.7 import QtQuick.Controls 2.2 import QtQml.Models 2.2 import QtGraphicalEffects 1.0 import org.kde.elisa 1.0 FocusScope { id: rootFocusScope property alias currentIndex: viewModeView.currentIndex property double textOpacity property double maximumSize - signal switchView(int index, string mainTitle, url imageUrl) + signal switchView(int index, string mainTitle, url imageUrl, var viewType) implicitWidth: elisaTheme.dp(500) Rectangle { anchors.fill: parent color: myPalette.base border { color: (rootFocusScope.activeFocus ? myPalette.highlight : "transparent") width: 1 } ScrollView { focus: true anchors.fill: parent clip: true ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ListView { id: viewModeView focus: true z: 2 anchors.topMargin: elisaTheme.layoutHorizontalMargin * 2 model: DelegateModel { id: pageDelegateModel model: ViewsModel { id: pageModel } delegate: MouseArea { id: itemMouseArea height: elisaTheme.viewSelectorDelegateHeight * 1.4 width: viewModeView.width hoverEnabled: true acceptedButtons: Qt.LeftButton Loader { anchors.fill: parent active: itemMouseArea && itemMouseArea.containsMouse && !nameLabel.visible sourceComponent: ToolTip { delay: Qt.styleHints.mousePressAndHoldInterval text: model.display visible: itemMouseArea && itemMouseArea.containsMouse && !nameLabel.visible contentItem: Label { text: model.display color: myPalette.highlightedText } enter: Transition { NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad; from: 0.0; to: 1.0; duration: 300; } } exit: Transition { NumberAnimation { properties: "opacity"; easing.type: Easing.InOutQuad; from: 1.0; to: 0.0; duration: 300; } } background: Rectangle { color: myPalette.shadow radius: elisaTheme.tooltipRadius layer.enabled: true layer.effect: DropShadow { horizontalOffset: elisaTheme.shadowOffset verticalOffset: elisaTheme.shadowOffset radius: 8 samples: 17 color: myPalette.shadow } } } } Image { id: viewIcon z: 2 anchors { verticalCenter: parent.verticalCenter leftMargin: elisaTheme.layoutHorizontalMargin left: parent.left } height: elisaTheme.viewSelectorDelegateHeight width: elisaTheme.viewSelectorDelegateHeight sourceSize { width: elisaTheme.viewSelectorDelegateHeight height: elisaTheme.viewSelectorDelegateHeight } source: model.image layer.effect: ColorOverlay { color: (index === viewModeView.currentIndex || itemMouseArea.containsMouse ? myPalette.highlight : "transparent") Behavior on color { ColorAnimation { duration: 300 } } } } LabelWithToolTip { id: nameLabel z: 2 anchors.verticalCenter: parent.verticalCenter anchors.leftMargin: elisaTheme.layoutHorizontalMargin anchors.left: viewIcon.right anchors.right: parent.right anchors.rightMargin: elisaTheme.layoutHorizontalMargin verticalAlignment: "AlignVCenter" font.pointSize: elisaTheme.defaultFontPointSize * 1.4 text: model.display elide: Text.ElideRight opacity: textOpacity visible: opacity > 0 Behavior on opacity { NumberAnimation { duration: 150 } } color: (viewModeView.currentIndex === index || itemMouseArea.containsMouse ? myPalette.highlight : myPalette.text) Behavior on color { ColorAnimation { duration: 300 } } } onClicked: { viewModeView.currentIndex = index rootFocusScope.focus = true - switchView(index, model.display, model.image) + switchView(index, model.display, model.image, model.type) } } } footer: MouseArea { width: viewModeView.width height: viewModeView.height - y acceptedButtons: Qt.LeftButton onClicked: { rootFocusScope.focus = true } } } } Behavior on border.color { ColorAnimation { duration: 300 } } } Connections { target: elisa onInitializationDone: { viewModeView.currentIndex = 0 switchView(viewModeView.currentIndex, "", "", "") } } Behavior on implicitWidth { NumberAnimation { duration: 150 } } Behavior on width { NumberAnimation { duration: 150 } } states: [ State { name: 'iconsAndText' when: maximumSize >= elisaTheme.viewSelectorSmallSizeThreshold PropertyChanges { target: rootFocusScope textOpacity: 1 implicitWidth: elisaTheme.dp(500) } }, State { name: 'iconsOnly' when: maximumSize < elisaTheme.viewSelectorSmallSizeThreshold PropertyChanges { target: rootFocusScope textOpacity: 0 implicitWidth: elisaTheme.viewSelectorDelegateHeight + 2 * elisaTheme.layoutHorizontalMargin } } ] } diff --git a/src/viewmanager.cpp b/src/viewmanager.cpp index c101536b..4519c28b 100644 --- a/src/viewmanager.cpp +++ b/src/viewmanager.cpp @@ -1,287 +1,325 @@ /* * Copyright 2018 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #include "viewmanager.h" ViewManager::ViewManager(QObject *parent) : QObject(parent) { } void ViewManager::closeAllViews() { mCurrentView = ViewsType::NoViews; mTargetView = ViewsType::NoViews; Q_EMIT switchOffAllViews(); } +void ViewManager::openParentView(ViewManager::ViewsType viewType, const QString &mainTitle, const QUrl &mainImage) +{ + switch(viewType) + { + case NoViews: + closeAllViews(); + break; + case RecentlyPlayedTracks: + openRecentlyPlayedTracks(mainTitle, mainImage); + break; + case FrequentlyPlayedTracks: + openFrequentlyPlayedTracks(mainTitle, mainImage); + break; + case AllAlbums: + openAllAlbums(mainTitle, mainImage); + break; + case AllArtists: + openAllArtists(mainTitle, mainImage); + break; + case AllTracks: + openAllTracks(mainTitle, mainImage); + break; + case AllGenres: + openAllGenres(mainTitle, mainImage); + break; + case FilesBrowser: + openFilesBrowser(mainTitle, mainImage); + break; + case OneAlbum: + case OneArtist: + case OneAlbumFromArtist: + case OneArtistFromGenre: + case OneAlbumFromArtistAndGenre: + case AllArtistsFromGenre: + break; + } +} + void ViewManager::openChildView(const QString &innerMainTitle, const QString &innerSecondaryTitle, const QUrl &innerImage, qulonglong databaseId, ElisaUtils::PlayListEntryType dataType) { switch(dataType) { case ElisaUtils::Album: openOneAlbum(innerMainTitle, innerSecondaryTitle, innerImage, databaseId); break; case ElisaUtils::Artist: openOneArtist(innerMainTitle, innerImage, databaseId); break; case ElisaUtils::Genre: openAllArtistsFromGenre(innerMainTitle); break; case ElisaUtils::Track: case ElisaUtils::FileName: case ElisaUtils::Unknown: break; } } void ViewManager::openRecentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::RecentlyPlayedTracks; if (mCurrentView != mTargetView) { Q_EMIT switchRecentlyPlayedTracksView(mainTitle, imageUrl, ElisaUtils::Track); } } void ViewManager::openFrequentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::FrequentlyPlayedTracks; if (mCurrentView != mTargetView) { Q_EMIT switchFrequentlyPlayedTracksView(mainTitle, imageUrl, ElisaUtils::Track); } } void ViewManager::openAllAlbums(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllAlbums; if (mCurrentView != mTargetView) { Q_EMIT switchAllAlbumsView(mainTitle, imageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), true, true); } } void ViewManager::openOneAlbum(const QString &albumTitle, const QString &albumAuthor, const QUrl &albumCover, qulonglong albumDatabaseId) { mTargetAlbumTitle = albumTitle; mTargetAlbumAuthor = albumAuthor; mTargetDatabaseId = albumDatabaseId; mTargetImageUrl = albumCover; if (mCurrentView == ViewsType::AllAlbums) { mTargetView = ViewsType::OneAlbum; Q_EMIT switchOneAlbumView(mTargetAlbumTitle, mTargetImageUrl, mTargetAlbumAuthor, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneArtist) { mTargetView = ViewsType::OneAlbumFromArtist; Q_EMIT switchOneAlbumView(mTargetAlbumTitle, mTargetImageUrl, mTargetAlbumAuthor, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneArtistFromGenre) { mTargetView = ViewsType::OneAlbumFromArtistAndGenre; Q_EMIT switchOneAlbumView(mTargetAlbumTitle, mTargetImageUrl, mTargetAlbumAuthor, mTargetDatabaseId); } else { switchAllAlbumsView({}, {}, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), true, true); } } void ViewManager::openAllArtists(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllArtists; if (mCurrentView != mTargetView) { Q_EMIT switchAllArtistsView(mainTitle, imageUrl, ElisaUtils::Artist, QUrl(QStringLiteral("image://icon/view-media-artist")), false, false); } } void ViewManager::openOneArtist(const QString &artistName, const QUrl &artistImageUrl, qulonglong artistDatabaseId) { mTargetArtistName = artistName; mTargetDatabaseId = artistDatabaseId; mTargetImageUrl = artistImageUrl; if (mCurrentView == ViewsType::AllArtistsFromGenre) { mTargetView = ViewsType::OneArtistFromGenre; } else { mTargetView = ViewsType::OneArtist; } if (mCurrentView == ViewsType::AllArtists && mTargetView == ViewsType::OneArtist) { Q_EMIT switchOneArtistView(mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), true, true, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneArtist && mCurrentArtistName != mTargetArtistName && mTargetView == ViewsType::OneArtist) { Q_EMIT popOneView(); Q_EMIT switchOneArtistView(mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), true, true, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneAlbumFromArtist && mCurrentArtistName != mTargetArtistName && mTargetView == ViewsType::OneArtist) { Q_EMIT popOneView(); Q_EMIT popOneView(); Q_EMIT switchOneArtistView(mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), true, true, mTargetDatabaseId); } else if (mCurrentView == ViewsType::AllArtistsFromGenre && mTargetView == ViewsType::OneArtistFromGenre) { Q_EMIT switchOneArtistFromGenreView(mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), true, true, mTargetDatabaseId, mTargetGenreName); } else { Q_EMIT switchAllArtistsView({}, {}, ElisaUtils::Artist, QUrl(QStringLiteral("image://icon/view-media-artist")), false, false); } } void ViewManager::openAllTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllTracks; if (mCurrentView != mTargetView) { Q_EMIT switchAllTracksView(mainTitle, imageUrl, ElisaUtils::Track); } } void ViewManager::openAllGenres(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllGenres; if (mCurrentView != mTargetView) { Q_EMIT switchAllGenresView(mainTitle, imageUrl, ElisaUtils::Genre, QUrl(QStringLiteral("image://icon/view-media-genre")), false, false); } } void ViewManager::openAllArtistsFromGenre(const QString &genreName) { mTargetView = ViewsType::AllArtistsFromGenre; mTargetGenreName = genreName; if (mCurrentView == ViewsType::AllGenres) { Q_EMIT switchAllArtistsFromGenreView(mTargetGenreName, {}, QUrl(QStringLiteral("image://icon/view-media-artist")), ElisaUtils::Artist, QUrl(QStringLiteral("image://icon/view-media-artist")), false, false); } else { Q_EMIT switchAllGenresView({}, {}, ElisaUtils::Genre, QUrl(QStringLiteral("image://icon/view-media-genre")), false, false); } } void ViewManager::openFilesBrowser(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::FilesBrowser; if (mCurrentView != mTargetView) { Q_EMIT switchFilesBrowserView(mainTitle, imageUrl); } } void ViewManager::recentlyPlayedTracksIsLoaded() { mCurrentView = ViewsType::RecentlyPlayedTracks; } void ViewManager::frequentlyPlayedTracksIsLoaded() { mCurrentView = ViewsType::FrequentlyPlayedTracks; } void ViewManager::allAlbumsViewIsLoaded() { mCurrentView = ViewsType::AllAlbums; if (mTargetView == ViewsType::OneAlbum) { Q_EMIT switchOneAlbumView(mTargetAlbumTitle, mTargetImageUrl, mTargetArtistName, mTargetDatabaseId); } } void ViewManager::oneAlbumViewIsLoaded() { mCurrentAlbumTitle = mTargetAlbumTitle; mCurrentAlbumAuthor = mTargetAlbumAuthor; if (mTargetView == ViewsType::OneAlbum) { mCurrentView = ViewsType::OneAlbum; } else if (mTargetView == ViewsType::OneAlbumFromArtist) { mCurrentView = ViewsType::OneAlbumFromArtist; } else if (mTargetView == ViewsType::OneAlbumFromArtistAndGenre) { mCurrentView = ViewsType::OneAlbumFromArtistAndGenre; } } void ViewManager::allArtistsViewIsLoaded() { mCurrentView = ViewsType::AllArtists; if (mTargetView == ViewsType::OneArtist) { Q_EMIT switchOneArtistView(mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), true, true, mTargetDatabaseId); } } void ViewManager::oneArtistViewIsLoaded() { mCurrentArtistName = mTargetArtistName; if (mTargetView == ViewsType::OneArtist) { mCurrentView = ViewsType::OneArtist; } else { mCurrentGenreName = mTargetGenreName; mCurrentView = ViewsType::OneArtistFromGenre; } } void ViewManager::allTracksViewIsLoaded() { mCurrentView = ViewsType::AllTracks; } void ViewManager::allGenresViewIsLoaded() { mCurrentView = ViewsType::AllGenres; } void ViewManager::allArtistsFromGenreViewIsLoaded() { mCurrentGenreName = mTargetGenreName; mCurrentView = ViewsType::AllArtistsFromGenre; } void ViewManager::filesBrowserViewIsLoaded() { mCurrentView = ViewsType::FilesBrowser; } void ViewManager::goBack() { Q_EMIT popOneView(); if (mCurrentView == ViewsType::OneAlbum) { mCurrentView = ViewsType::AllAlbums; } else if (mCurrentView == ViewsType::OneArtist) { mCurrentView = ViewsType::AllArtists; } else if (mCurrentView == ViewsType::OneAlbumFromArtist) { mCurrentView = ViewsType::OneArtist; } else if (mCurrentView == ViewsType::AllArtistsFromGenre) { mCurrentView = ViewsType::AllGenres; } else if (mCurrentView == ViewsType::OneArtistFromGenre) { mCurrentView = ViewsType::AllArtistsFromGenre; } else if (mCurrentView == ViewsType::OneAlbumFromArtistAndGenre) { mCurrentView = ViewsType::OneArtistFromGenre; } } #include "moc_viewmanager.cpp" diff --git a/src/viewmanager.h b/src/viewmanager.h index ba0cca4f..1f54a95f 100644 --- a/src/viewmanager.h +++ b/src/viewmanager.h @@ -1,168 +1,170 @@ /* * Copyright 2018 Matthieu Gallien * * This program is free software: you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3 of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ #ifndef VIEWMANAGER_H #define VIEWMANAGER_H #include "elisaLib_export.h" #include "elisautils.h" #include #include class ELISALIB_EXPORT ViewManager : public QObject { Q_OBJECT public: enum ViewsType { NoViews, AllAlbums, OneAlbum, AllArtists, OneArtist, OneAlbumFromArtist, AllTracks, AllGenres, AllArtistsFromGenre, OneArtistFromGenre, OneAlbumFromArtistAndGenre, FrequentlyPlayedTracks, RecentlyPlayedTracks, FilesBrowser }; Q_ENUM(ViewsType) explicit ViewManager(QObject *parent = nullptr); Q_SIGNALS: void switchRecentlyPlayedTracksView(const QString &mainTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType); void switchFrequentlyPlayedTracksView(const QString &mainTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType); void switchAllAlbumsView(const QString &mainTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, bool viewShowRating, bool viewDelegateDisplaySecondaryText); void switchOneAlbumView(const QString &mainTitle, const QUrl &imageUrl, const QString &secondaryTitle, qulonglong databaseId); void switchAllArtistsView(const QString &mainTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, bool viewShowRating, bool viewDelegateDisplaySecondaryText); void switchOneArtistView(const QString &mainTitle, const QString &secondaryTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, bool viewShowRating, bool viewDelegateDisplaySecondaryText, qulonglong databaseId); void switchAllTracksView(const QString &mainTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType); void switchAllGenresView(const QString &mainTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, bool viewShowRating, bool viewDelegateDisplaySecondaryText); void switchAllArtistsFromGenreView(const QString &mainTitle, const QString &secondaryTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, bool viewShowRating, bool viewDelegateDisplaySecondaryText); void switchOneArtistFromGenreView(const QString &mainTitle, const QString &secondaryTitle, const QUrl &imageUrl, ElisaUtils::PlayListEntryType dataType, const QUrl &viewDefaultIcon, bool viewShowRating, bool viewDelegateDisplaySecondaryText, qulonglong databaseId, const QString &genreName); void switchFilesBrowserView(const QString &mainTitle, const QUrl &imageUrl); void switchOffAllViews(); void popOneView(); public Q_SLOTS: void closeAllViews(); + void openParentView(ViewManager::ViewsType viewType, const QString &mainTitle, const QUrl &mainImage); + void openChildView(const QString &innerMainTitle, const QString & innerSecondaryTitle, const QUrl &innerImage, qulonglong databaseId, ElisaUtils::PlayListEntryType dataType); - void openRecentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl); - - void openFrequentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl); - - void openAllAlbums(const QString &mainTitle, const QUrl &imageUrl); - - void openAllArtists(const QString &mainTitle, const QUrl &imageUrl); - - void openAllTracks(const QString &mainTitle, const QUrl &imageUrl); - - void openAllGenres(const QString &mainTitle, const QUrl &imageUrl); - - void openFilesBrowser(const QString &mainTitle, const QUrl &imageUrl); - void recentlyPlayedTracksIsLoaded(); void frequentlyPlayedTracksIsLoaded(); void allAlbumsViewIsLoaded(); void oneAlbumViewIsLoaded(); void allArtistsViewIsLoaded(); void oneArtistViewIsLoaded(); void allTracksViewIsLoaded(); void allGenresViewIsLoaded(); void allArtistsFromGenreViewIsLoaded(); void filesBrowserViewIsLoaded(); void goBack(); private: + void openRecentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl); + + void openFrequentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl); + + void openAllAlbums(const QString &mainTitle, const QUrl &imageUrl); + + void openAllArtists(const QString &mainTitle, const QUrl &imageUrl); + + void openAllTracks(const QString &mainTitle, const QUrl &imageUrl); + + void openAllGenres(const QString &mainTitle, const QUrl &imageUrl); + + void openFilesBrowser(const QString &mainTitle, const QUrl &imageUrl); + void openOneAlbum(const QString &albumTitle, const QString &albumAuthor, const QUrl &albumCover, qulonglong albumDatabaseId); void openOneArtist(const QString &artistName, const QUrl &artistImageUrl, qulonglong artistDatabaseId); void openAllArtistsFromGenre(const QString &genreName); ViewsType mCurrentView = ViewsType::NoViews; QString mCurrentAlbumTitle; QString mCurrentAlbumAuthor; QString mCurrentArtistName; QString mCurrentGenreName; ViewsType mTargetView = ViewsType::NoViews; QString mTargetAlbumTitle; QString mTargetAlbumAuthor; QString mTargetArtistName; QString mTargetGenreName; QUrl mTargetImageUrl; qulonglong mTargetDatabaseId = 0; }; #endif // VIEWMANAGER_H