Git commit c5125bcf08e7deadbe99934c4499130364ce4aaa by Matthieu Gallien. Committed on 31/05/2018 at 21:14. Pushed by mgallien into branch 'master'. fix several issues caused by the use of loaders for the music views Summary: fix several issues caused by the use of loaders for the music views fix navigation when browsing artists remove useless code to clear the views that are unloaded Test Plan: brings back navigation in artists view Reviewers: astippich Reviewed By: astippich Subscribers: januz Differential Revision: https://phabricator.kde.org/D12951 M +1 -0 src/CMakeLists.txt M +132 -175 src/qml/ContentView.qml M +1 -0 src/qml/GridBrowserView.qml M +1 -0 src/qml/ListBrowserView.qml A +186 -0 src/qml/ViewManager.qml [License: LGPL (v3+)] M +4 -0 src/qml/ViewSelector.qml M +1 -0 src/resources.qrc https://commits.kde.org/elisa/c5125bcf08e7deadbe99934c4499130364ce4aaa diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2fa497..10b991d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -226,6 +226,7 @@ if (Qt5Quick_FOUND AND Qt5Widgets_FOUND AND KF5Declarat= ive_FOUND) qml/ContextView.qml qml/ContentView.qml qml/ViewSelector.qml + qml/ViewManager.qml = qml/MediaPlayListView.qml qml/MediaTrackDelegate.qml diff --git a/src/qml/ContentView.qml b/src/qml/ContentView.qml index dc2bbf1..c0cf886 100644 --- a/src/qml/ContentView.qml +++ b/src/qml/ContentView.qml @@ -30,8 +30,60 @@ RowLayout { signal toggleSearch() = function goBack() { - localAlbums.goBack() - localArtists.goBack() + viewManager.goBack() + } + + ViewManager { + id: viewManager + + onSwitchAllAlbumsView: { + listViews.currentIndex =3D 1 + localArtistsLoader.opacity =3D 0 + localTracksLoader.opacity =3D 0 + localAlbumsLoader.opacity =3D 1 + } + + onSwitchOneAlbumView: { + elisa.singleAlbumProxyModel.loadAlbumData(databaseId) + currentStackView.push(albumView, { + mainTitle: mainTitle, + secondaryTitle: secondaryTitle, + image: imageUrl, + stackView: currentStackView, + }) + oneAlbumViewIsLoaded() + } + + onSwitchAllArtistsView: { + listViews.currentIndex =3D 2 + localArtistsLoader.opacity =3D 1 + localTracksLoader.opacity =3D 0 + localAlbumsLoader.opacity =3D 0 + } + + onSwitchOneArtistView: { + elisa.singleArtistProxyModel.setArtistFilterText(mainTitle) + currentStackView.push(innerAlbumView, { + mainTitle: mainTitle, + secondaryTitle: secondaryTitle, + image: imageUrl, + stackView: currentStackView, + }) + oneArtistViewIsLoaded() + } + + onSwitchAllTracksView: { + listViews.currentIndex =3D 3 + localArtistsLoader.opacity =3D 0 + localTracksLoader.opacity =3D 1 + localAlbumsLoader.opacity =3D 0 + } + + onSwitchOffAllViews: { + localArtistsLoader.opacity =3D 0 + localTracksLoader.opacity =3D 0 + localAlbumsLoader.opacity =3D 0 + } } = ViewSelector { @@ -40,6 +92,16 @@ RowLayout { Layout.fillHeight: true Layout.preferredWidth: mainWindow.width * 0.11 Layout.maximumWidth: mainWindow.width * 0.11 + + onSwitchView: if (index =3D=3D=3D 1) { + viewManager.openAllAlbums() + } else if (index =3D=3D=3D 2) { + viewManager.openAllArtists() + } else if (index =3D=3D=3D 3) { + viewManager.openAllTracks() + } else { + viewManager.closeAllViews() + } } = Rectangle { @@ -150,6 +212,8 @@ RowLayout { = anchors.fill: parent = + onLoaded: viewManager.allAlbumsViewIsLoaded(it= em.stackView) + sourceComponent: MediaBrowser { id: localAlbums = @@ -173,16 +237,10 @@ RowLayout { mainTitle: i18nc("Title of the view of= all albums", "Albums") = onOpen: { - elisa.singleAlbumProxyModel.loadAl= bumData(databaseId) - localAlbums.stackView.push(albumVi= ew, { - mai= nTitle: innerMainTitle, - sec= ondaryTitle: innerSecondaryTitle, - ima= ge: innerImage, - sta= ckView: localAlbums.stackView, - }) + viewManager.openOneAlbum(localAlbu= ms.stackView, innerMainTitle, innerSecondaryTitle, innerImage, databaseId) } = - onGoBack: localAlbums.stackView.pop() + onGoBack: viewManager.goBack() = Binding { target: allAlbumsView @@ -193,6 +251,13 @@ RowLayout { onFilterViewChanged: persistentSetting= s.expandedFilterView =3D expandedFilterView } } + + Behavior on opacity { + NumberAnimation { + easing.type: Easing.InOutQuad + duration: 300 + } + } } = Loader { @@ -202,8 +267,12 @@ RowLayout { = visible: opacity > 0 = + opacity: 0 + anchors.fill: parent = + onLoaded: viewManager.allArtistsViewIsLoaded(i= tem.stackView) + sourceComponent: MediaBrowser { id: localArtists = @@ -229,16 +298,10 @@ RowLayout { mainTitle: i18nc("Title of the view of= all artists", "Artists") = onOpen: { - elisa.singleArtistProxyModel.setAr= tistFilterText(innerMainTitle) - localArtists.stackView.push(innerA= lbumView, { - ma= inTitle: innerMainTitle, - se= condaryTitle: innerSecondaryTitle, - im= age: innerImage, - }) - + viewManager.openOneArtist(localArt= ists.stackView, innerMainTitle, innerImage, 0) } = - onGoBack: localArtists.stackView.pop() + onGoBack: viewManager.goBack() = Binding { target: allArtistsView @@ -249,6 +312,13 @@ RowLayout { onFilterViewChanged: persistentSetting= s.expandedFilterView =3D expandedFilterView } } + + Behavior on opacity { + NumberAnimation { + easing.type: Easing.InOutQuad + duration: 300 + } + } } = Loader { @@ -258,8 +328,12 @@ RowLayout { = visible: opacity > 0 = + opacity: 0 + anchors.fill: parent = + onLoaded: viewManager.allTracksViewIsLoaded(it= em) + sourceComponent: MediaBrowser { id: localTracks = @@ -311,6 +385,13 @@ RowLayout { onFilterViewChanged: persistentSetting= s.expandedFilterView =3D expandedFilterView } } + + Behavior on opacity { + NumberAnimation { + easing.type: Easing.InOutQuad + duration: 300 + } + } } = Behavior on border.color { @@ -401,7 +482,7 @@ RowLayout { = states: [ State { - name: 'full' + name: 'playList' when: listViews.currentIndex =3D=3D=3D 0 PropertyChanges { target: mainContentView @@ -434,81 +515,10 @@ RowLayout { Layout.maximumWidth: contentZone.width / 2 Layout.preferredWidth: contentZone.width / 2 } - PropertyChanges { - target: localAlbumsLoader - opacity: 0 - } - PropertyChanges { - target: localArtistsLoader - opacity: 0 - } - PropertyChanges { - target: localTracksLoader - opacity: 0 - } - }, - State { - name: 'allAlbums' - when: listViews.currentIndex =3D=3D=3D 1 - StateChangeScript { - script: { - if (localAlbumsLoader.localAlbums) - localAlbumsLoader.localAlbums.stackView.pop({i= tem: null, immediate: true}) - } - } - 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 - } - PropertyChanges { - target: localAlbumsLoader - opacity: 1 - } - PropertyChanges { - target: localArtistsLoader - opacity: 0 - } - PropertyChanges { - target: localTracksLoader - opacity: 0 - } }, State { - name: 'allArtists' - when: listViews.currentIndex =3D=3D=3D 2 - StateChangeScript { - script: { - if (localArtistsLoader.localArtists) - localArtistsLoader.localArtists.stackView.pop(= {item: null, immediate: true}) - } - } + name: 'browsingViews' + when: listViews.currentIndex !=3D=3D 0 PropertyChanges { target: mainContentView Layout.fillWidth: true @@ -540,65 +550,6 @@ RowLayout { Layout.maximumWidth: 0 Layout.preferredWidth: 0 } - PropertyChanges { - target: localAlbumsLoader - opacity: 0 - } - PropertyChanges { - target: localArtistsLoader - opacity: 1 - } - PropertyChanges { - target: localTracksLoader - opacity: 0 - } - }, - State { - name: 'allTracks' - when: listViews.currentIndex =3D=3D=3D 3 - 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 - } - PropertyChanges { - target: localAlbumsLoader - opacity: 0 - } - PropertyChanges { - target: localArtistsLoader - opacity: 0 - } - PropertyChanges { - target: localTracksLoader - opacity: 1 - } } ] transitions: Transition { @@ -610,7 +561,6 @@ RowLayout { } } = - Component { id: innerAlbumView = @@ -622,16 +572,36 @@ RowLayout { isSubPage: true = onOpen: { - elisa.singleAlbumProxyModel.loadAlbumData(databaseId) - localArtists.stackView.push(albumView, { - mainTitle: innerMainTitle, - secondaryTitle: innerSecon= daryTitle, - image: innerImage, - stackView: localArtists.st= ackView, - }) + viewManager.openOneAlbum(stackView, innerMainTitle, innerS= econdaryTitle, innerImage, databaseId) } = - onGoBack: localArtists.stackView.pop() + onGoBack: viewManager.goBack() + + Binding { + target: innerAlbumGridView + property: 'expandedFilterView' + value: persistentSettings.expandedFilterView + } + + onFilterViewChanged: persistentSettings.expandedFilterView =3D= expandedFilterView + } + } + + Component { + id: innerArtistView + + GridBrowserView { + id: innerAlbumGridView + + delegateDisplaySecondaryText: false + + isSubPage: true + + onOpen: { + viewManager.openOneArtist(stackView, innerMainTitle, inner= Image, databaseId) + } + + onGoBack: viewManager.goBack() = Binding { target: innerAlbumGridView @@ -648,7 +618,6 @@ RowLayout { = ListBrowserView { id: albumGridView - property var stackView = contentModel: elisa.singleAlbumProxyModel = @@ -680,22 +649,10 @@ RowLayout { allowArtistNavigation: true = onShowArtist: { - listViews.currentIndex =3D 2 - if (localArtists.stackView.depth =3D=3D=3D 3) { - localArtists.stackView.pop() - } - if (localArtists.stackView.depth =3D=3D=3D 2) { - var artistPage =3D localArtists.stackView.get(1) - if (artistPage.mainTitle =3D=3D=3D name) { - return - } else { - localArtists.stackView.pop() - } - } - allArtistsView.open(name, name, elisaTheme.defaultArtistIm= age, '') + viewManager.openOneArtist(stackView, name, elisaTheme.arti= stIcon, 0) } = - onGoBack: stackView.pop() + onGoBack: viewManager.goBack() = expandedFilterView: true = diff --git a/src/qml/GridBrowserView.qml b/src/qml/GridBrowserView.qml index 8446638..46641d8 100644 --- a/src/qml/GridBrowserView.qml +++ b/src/qml/GridBrowserView.qml @@ -37,6 +37,7 @@ FocusScope { property alias showRating: navigationBar.showRating property bool delegateDisplaySecondaryText: true property alias expandedFilterView: navigationBar.expandedFilterView + property var stackView = signal open(var innerMainTitle, var innerSecondaryTitle, var innerImag= e, var databaseId) signal goBack() diff --git a/src/qml/ListBrowserView.qml b/src/qml/ListBrowserView.qml index 0399e8d..1e675fe 100644 --- a/src/qml/ListBrowserView.qml +++ b/src/qml/ListBrowserView.qml @@ -39,6 +39,7 @@ FocusScope { property alias showRating: navigationBar.showRating property alias allowArtistNavigation: navigationBar.allowArtistNavigat= ion property var delegateWidth: scrollBar.visible ? contentDirectoryView.w= idth - scrollBar.width : contentDirectoryView.width + property var stackView = signal goBack() signal showArtist(var name) diff --git a/src/qml/ViewManager.qml b/src/qml/ViewManager.qml new file mode 100644 index 0000000..8e03875 --- /dev/null +++ b/src/qml/ViewManager.qml @@ -0,0 +1,186 @@ +/* + * Copyright 2016-2017 Matthieu Gallien + * + * 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 Licen= se + * 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. + */ + +import QtQuick 2.7 + +QtObject { + + enum ViewsType { + NoViews, + AllAlbums, + OneAlbum, + AllArtists, + OneArtist, + OneAlbumFromArtist, + AllTracks + } + + property int currentView: ViewManager.ViewsType.NoViews + property string currentAlbumTitle + property string currentAlbumAuthor + property string currentArtistName + property var currentStackView + + property int targetView: ViewManager.ViewsType.NoViews + property string targetAlbumTitle + property string targetAlbumAuthor + property string targetArtistName + property url targetImageUrl + property int targetDatabaseId + + signal switchAllAlbumsView() + signal switchOneAlbumView(var currentStackView, string mainTitle, url = imageUrl, string secondaryTitle, int databaseId) + signal switchAllArtistsView() + signal switchOneArtistView(var currentStackView, string mainTitle, url= imageUrl, string secondaryTitle, int databaseId) + signal switchAllTracksView() + signal switchOffAllViews() + + function closeAllViews() + { + currentView =3D ViewManager.ViewsType.NoViews + targetView =3D ViewManager.ViewsType.NoViews + switchOffAllViews() + } + + function openAllAlbums() + { + targetView =3D ViewManager.ViewsType.AllAlbums + + if (currentView !=3D targetView) { + switchAllAlbumsView() + } + } + + function openOneAlbum(stackView, albumTitle, albumAuthor, albumCover, = albumDatabaseId) + { + targetAlbumTitle =3D albumTitle + targetAlbumAuthor =3D albumAuthor + targetDatabaseId =3D albumDatabaseId + targetImageUrl =3D albumCover + currentStackView =3D stackView + + if (currentView =3D=3D ViewManager.ViewsType.AllAlbums) { + targetView =3D ViewManager.ViewsType.OneAlbum + switchOneAlbumView(currentStackView, targetAlbumTitle, targetI= mageUrl, targetAlbumAuthor, targetDatabaseId) + } else if (currentView =3D=3D ViewManager.ViewsType.OneArtist) { + targetView =3D ViewManager.ViewsType.OneAlbumFromArtist + switchOneAlbumView(currentStackView, targetAlbumTitle, targetI= mageUrl, targetAlbumAuthor, targetDatabaseId) + } else { + switchAllAlbumsView() + } + } + + function openAllArtists() + { + targetView =3D ViewManager.ViewsType.AllArtists + + if (currentView !=3D targetView) { + switchAllArtistsView() + } + } + + function openOneArtist(stackView, artistName, artistImageUrl, artistDa= tabaseId) + { + targetArtistName =3D artistName + targetDatabaseId =3D artistDatabaseId + targetImageUrl =3D artistImageUrl + currentStackView =3D stackView + + targetView =3D ViewManager.ViewsType.OneArtist + + if (currentView =3D=3D ViewManager.ViewsType.AllArtists && targetV= iew =3D=3D ViewManager.ViewsType.OneArtist) { + switchOneArtistView(currentStackView, targetArtistName, target= ImageUrl, '', targetDatabaseId) + } else if (currentView =3D=3D ViewManager.ViewsType.OneArtist && c= urrentArtistName !=3D targetArtistName && + targetView =3D=3D ViewManager.ViewsType.OneArtist) { + currentStackView.pop() + switchOneArtistView(currentStackView, targetArtistName, target= ImageUrl, '', targetDatabaseId) + } else if (currentView =3D=3D ViewManager.ViewsType.OneAlbumFromAr= tist && currentArtistName !=3D targetArtistName && + targetView =3D=3D ViewManager.ViewsType.OneArtist) { + currentStackView.pop() + currentStackView.pop() + switchOneArtistView(currentStackView, targetArtistName, target= ImageUrl, '', targetDatabaseId) + } else { + switchAllArtistsView() + } + } + + function openAllTracks() + { + targetView =3D ViewManager.ViewsType.AllTracks + if (currentView !=3D targetView) { + switchAllTracksView() + } + } + + function allAlbumsViewIsLoaded(stackView) + { + currentStackView =3D stackView + currentView =3D ViewManager.ViewsType.AllAlbums + if (targetView =3D=3D ViewManager.ViewsType.OneAlbum) { + switchOneAlbumView(currentStackView, targetAlbumTitle, targetI= mageUrl, targetArtistName, targetDatabaseId) + } + } + + function oneAlbumViewIsLoaded() + { + currentAlbumTitle =3D targetAlbumTitle + currentAlbumAuthor =3D targetAlbumAuthor + + if (targetView =3D=3D ViewManager.ViewsType.OneAlbum) { + currentView =3D ViewManager.ViewsType.OneAlbum + } else if (targetView =3D=3D ViewManager.ViewsType.OneAlbumFromArt= ist) { + currentView =3D ViewManager.ViewsType.OneAlbumFromArtist + } + } + + function allArtistsViewIsLoaded(stackView) + { + currentStackView =3D stackView + currentView =3D ViewManager.ViewsType.AllArtists + if (targetView =3D=3D ViewManager.ViewsType.OneArtist) { + switchOneArtistView(currentStackView, targetArtistName, target= ImageUrl, '', targetDatabaseId) + } + } + + function oneArtistViewIsLoaded() + { + currentArtistName =3D targetArtistName + if (targetView =3D=3D ViewManager.ViewsType.OneArtist) { + currentView =3D ViewManager.ViewsType.OneArtist + } + } + + function allTracksViewIsLoaded(allTracksView) + { + currentView =3D ViewManager.ViewsType.AllTracks + } + + function goBack() + { + currentStackView.pop() + + if (currentView =3D=3D ViewManager.ViewsType.OneAlbum) { + currentView =3D ViewManager.ViewsType.AllAlbums + } else if (currentView =3D=3D ViewManager.ViewsType.OneArtist) { + currentView =3D ViewManager.ViewsType.AllArtists + } else if (currentView =3D=3D ViewManager.ViewsType.OneAlbumFromAr= tist) { + currentView =3D ViewManager.ViewsType.OneArtist + } + } +} diff --git a/src/qml/ViewSelector.qml b/src/qml/ViewSelector.qml index fcb35ab..bda6cd6 100644 --- a/src/qml/ViewSelector.qml +++ b/src/qml/ViewSelector.qml @@ -24,8 +24,11 @@ import QtGraphicalEffects 1.0 = FocusScope { id: rootFocusScope + property alias currentIndex: viewModeView.currentIndex = + signal switchView(int index) + Rectangle { anchors.fill: parent = @@ -145,6 +148,7 @@ FocusScope { { viewModeView.currentIndex =3D index rootFocusScope.focus =3D true + switchView(index) } } = diff --git a/src/resources.qrc b/src/resources.qrc index c84f711..659a983 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -28,6 +28,7 @@ qml/ListBrowserView.qml qtquickcontrols2.conf background.png + qml/ViewManager.qml windows/WindowsTheme.qml