diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90f6b43e..86b2643f 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,455 +1,454 @@ include_directories(${elisa_BINARY_DIR}) set(elisaLib_SOURCES mediaplaylist.cpp musicaudiotrack.cpp progressindicator.cpp databaseinterface.cpp musiclistenersmanager.cpp managemediaplayercontrol.cpp manageheaderbar.cpp manageaudioplayer.cpp trackslistener.cpp elisaapplication.cpp modeldataloader.cpp notificationitem.cpp topnotificationmanager.cpp elisautils.cpp datatype.cpp abstractfile/abstractfilelistener.cpp abstractfile/abstractfilelisting.cpp filescanner.cpp viewmanager.cpp file/filelistener.cpp file/localfilelisting.cpp models/datamodel.cpp models/abstractmediaproxymodel.cpp models/allalbumsproxymodel.cpp models/allartistsproxymodel.cpp models/alltracksproxymodel.cpp models/singlealbumproxymodel.cpp models/trackmetadatamodel.cpp models/viewsmodel.cpp ) if (LIBVLC_FOUND) set(elisaLib_SOURCES ${elisaLib_SOURCES} audiowrapper_libvlc.cpp ) else() set(elisaLib_SOURCES ${elisaLib_SOURCES} audiowrapper_qtmultimedia.cpp ) endif() if (ANDROID) set(elisaLib_SOURCES ${elisaLib_SOURCES} android/androidmusiclistener.cpp ) endif() if (KF5KIO_FOUND) set(elisaLib_SOURCES ${elisaLib_SOURCES} models/filebrowsermodel.cpp models/filebrowserproxymodel.cpp ) endif() if (KF5Baloo_FOUND) if (Qt5DBus_FOUND) set(elisaLib_SOURCES ${elisaLib_SOURCES} baloo/localbaloofilelisting.cpp baloo/baloolistener.cpp ) qt5_add_dbus_interface(elisaLib_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.main.xml baloo/main) qt5_add_dbus_interface(elisaLib_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.fileindexer.xml baloo/fileindexer) qt5_add_dbus_interface(elisaLib_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.scheduler.xml baloo/scheduler) qt5_add_dbus_adaptor(elisaLib_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.BalooWatcherApplication.xml baloo/localbaloofilelisting.h LocalBalooFileListing) endif() endif() if (Qt5DBus_FOUND) set(elisaLib_SOURCES ${elisaLib_SOURCES} mpris2/mpris2.cpp mpris2/mediaplayer2.cpp mpris2/mediaplayer2player.cpp ) endif() if (UPNPQT_FOUND) set(elisaLib_SOURCES ${elisaLib_SOURCES} upnp/upnpcontrolcontentdirectory.cpp upnp/upnpcontentdirectorymodel.cpp upnp/upnpcontrolconnectionmanager.cpp upnp/upnpcontrolmediaserver.cpp upnp/didlparser.cpp upnp/upnplistener.cpp upnp/upnpdiscoverallmusic.cpp ) endif() if (KF5Baloo_FOUND) if (Qt5DBus_FOUND) qt5_add_dbus_interface(elisaLib_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.fileindexer.xml baloo/fileindexer) qt5_add_dbus_interface(elisaLib_SOURCES ${BALOO_DBUS_INTERFACES_DIR}/org.kde.baloo.scheduler.xml baloo/scheduler) set(elisaLib_SOURCES ${elisaLib_SOURCES} ../src/baloo/baloolistener.cpp ../src/baloo/localbaloofilelisting.cpp ) endif() endif() kconfig_add_kcfg_files(elisaLib_SOURCES ../src/elisa_settings.kcfgc ) set(elisaLib_SOURCES ${elisaLib_SOURCES} ../src/elisa_core.kcfg ) add_library(elisaLib ${elisaLib_SOURCES}) target_link_libraries(elisaLib LINK_PUBLIC Qt5::Multimedia LINK_PRIVATE Qt5::Core Qt5::Sql Qt5::Widgets Qt5::Concurrent Qt5::Qml KF5::I18n KF5::CoreAddons KF5::ConfigCore KF5::ConfigGui) if (KF5FileMetaData_FOUND) target_link_libraries(elisaLib LINK_PRIVATE KF5::FileMetaData ) endif() if (KF5KIO_FOUND) target_link_libraries(elisaLib LINK_PUBLIC KF5::KIOCore KF5::KIOFileWidgets KF5::KIOWidgets ) endif() if (KF5XmlGui_FOUND) target_link_libraries(elisaLib LINK_PUBLIC KF5::XmlGui ) endif() if (KF5ConfigWidgets_FOUND) target_link_libraries(elisaLib LINK_PUBLIC KF5::ConfigWidgets ) endif() if (KF5KCMUtils_FOUND) target_link_libraries(elisaLib LINK_PUBLIC KF5::KCMUtils ) endif() if (KF5Baloo_FOUND) if (Qt5DBus_FOUND) target_link_libraries(elisaLib LINK_PUBLIC KF5::Baloo ) endif() endif() if (Qt5DBus_FOUND) target_link_libraries(elisaLib LINK_PUBLIC Qt5::DBus ) if (KF5DBusAddons_FOUND) target_link_libraries(elisaLib LINK_PUBLIC KF5::DBusAddons ) endif() endif() if (LIBVLC_FOUND) target_include_directories(elisaLib PRIVATE ${LIBVLC_INCLUDE_DIR} ) target_link_libraries(elisaLib LINK_PRIVATE ${LIBVLC_LIBRARY} ) endif() if (ANDROID) target_link_libraries(elisaLib LINK_PUBLIC Qt5::AndroidExtras ) endif() generate_export_header(elisaLib BASE_NAME ElisaLib EXPORT_FILE_NAME elisaLib_export.h) set_target_properties(elisaLib PROPERTIES VERSION 0.1 SOVERSION 0 EXPORT_NAME ElisaLib ) if (NOT APPLE AND NOT WIN32) install(TARGETS elisaLib LIBRARY DESTINATION ${KDE_INSTALL_FULL_LIBDIR}/elisa RUNTIME DESTINATION ${KDE_INSTALL_FULL_LIBDIR}/elisa BUNDLE DESTINATION ${KDE_INSTALL_FULL_LIBDIR}/elisa ) else() install(TARGETS elisaLib ${INSTALL_TARGETS_DEFAULT_ARGS}) endif() set(elisaqmlplugin_SOURCES elisaqmlplugin.cpp datatype.cpp elisautils.cpp ) if (KF5FileMetaData_FOUND) set(elisaqmlplugin_SOURCES ${elisaqmlplugin_SOURCES} embeddedcoverageimageprovider.cpp ) endif() add_library(elisaqmlplugin SHARED ${elisaqmlplugin_SOURCES}) target_link_libraries(elisaqmlplugin LINK_PRIVATE Qt5::Quick Qt5::Widgets KF5::ConfigCore KF5::ConfigGui elisaLib ) if (KF5FileMetaData_FOUND) target_link_libraries(elisaqmlplugin LINK_PRIVATE KF5::FileMetaData ) endif() set_target_properties(elisaqmlplugin PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/org/kde/elisa ) if (NOT APPLE AND NOT WIN32) set_target_properties(elisaqmlplugin PROPERTIES INSTALL_RPATH "${KDE_INSTALL_FULL_LIBDIR}/elisa;${CMAKE_INSTALL_RPATH}" ) endif() install(TARGETS elisaqmlplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/elisa/) install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/elisa) add_custom_target(copy) add_custom_target(copy2) file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/bin/org/kde/elisa) add_custom_command(TARGET copy PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qmldir ${CMAKE_BINARY_DIR}/bin/org/kde/elisa/) add_custom_command(TARGET copy2 PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/plugins.qmltypes ${CMAKE_BINARY_DIR}/bin/org/kde/elisa/) add_dependencies(elisaqmlplugin copy copy2) if (Qt5Quick_FOUND AND Qt5Widgets_FOUND) set(elisa_SOURCES main.cpp windows/WindowsTheme.qml windows/PlatformIntegration.qml android/ElisaMainWindow.qml android/AndroidTheme.qml android/PlatformIntegration.qml android/AlbumsView.qml android/ArtistsView.qml android/TracksView.qml android/GenresView.qml qml/ElisaMainWindow.qml qml/ApplicationMenu.qml qml/BaseTheme.qml qml/Theme.qml qml/PlatformIntegration.qml qml/LabelWithToolTip.qml qml/RatingStar.qml qml/MediaBrowser.qml qml/DraggableItem.qml qml/PassiveNotification.qml qml/TopNotification.qml qml/TopNotificationItem.qml qml/TrackImportNotification.qml qml/HeaderBar.qml qml/NavigationActionBar.qml qml/MediaPlayerControl.qml qml/ContextView.qml qml/ContentView.qml qml/ViewSelector.qml - qml/ViewNavigation.qml qml/AlbumsView.qml qml/ArtistsView.qml qml/GenresView.qml qml/TracksView.qml qml/AlbumView.qml qml/OneArtistView.qml qml/OneGenreView.qml qml/RecentlyPlayedTracks.qml qml/FrequentlyPlayedTracks.qml qml/MediaPlayListView.qml qml/PlayListBasicView.qml qml/PlayListEntry.qml qml/SimplePlayListView.qml qml/SimplePlayListEntry.qml qml/MediaTrackDelegate.qml qml/MediaAlbumTrackDelegate.qml qml/MediaTrackMetadataView.qml qml/GridBrowserView.qml qml/GridBrowserDelegate.qml qml/ListBrowserView.qml qml/FileBrowserDelegate.qml qml/FileBrowserView.qml qml/ScrollHelper.qml qml/FlatButtonWithToolTip.qml qml/AlbumsView.qml qml/ArtistsView.qml qml/TracksView.qml qml/GenresView.qml ) qt5_add_resources(elisa_SOURCES resources.qrc) set_property(SOURCE qrc_resources.cpp PROPERTY SKIP_AUTOMOC ON) set(elisa_ICONS_PNG ../icons/128-apps-elisa.png ../icons/64-apps-elisa.png ../icons/48-apps-elisa.png ../icons/32-apps-elisa.png ../icons/22-apps-elisa.png ../icons/16-apps-elisa.png ) # add icons to application sources, to have them bundled ecm_add_app_icon(elisa_SOURCES ICONS ${elisa_ICONS_PNG}) add_executable(elisa ${elisa_SOURCES}) target_include_directories(elisa PRIVATE ${KDSoap_INCLUDE_DIRS}) target_link_libraries(elisa LINK_PRIVATE elisaLib Qt5::Widgets Qt5::QuickControls2 KF5::I18n KF5::CoreAddons KF5::ConfigCore KF5::ConfigGui ) if (ANDROID) target_link_libraries(elisa LINK_PRIVATE Qt5::AndroidExtras Qt5::Svg Qt5::Sql Qt5::Concurrent KF5::Kirigami2 ) endif() if (KF5Crash_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::Crash ) endif() if (KF5Declarative_FOUND) target_link_libraries(elisa LINK_PRIVATE KF5::Declarative ) endif() if (NOT APPLE AND NOT WIN32) set_target_properties(elisa PROPERTIES INSTALL_RPATH "${KDE_INSTALL_FULL_LIBDIR}/elisa;${CMAKE_INSTALL_RPATH}" ) endif() install(TARGETS elisa ${INSTALL_TARGETS_DEFAULT_ARGS}) endif() if (KF5ConfigWidgets_FOUND AND KF5Declarative_FOUND) add_subdirectory(localFileConfiguration) endif() set(elisaImport_SOURCES elisaimport.cpp elisaimportapplication.cpp ) kconfig_add_kcfg_files(elisaImport_SOURCES ../src/elisa_settings.kcfgc ) set(elisaImport_SOURCES ${elisaImport_SOURCES} ../src/elisa_core.kcfg ) add_executable(elisaImport ${elisaImport_SOURCES}) target_link_libraries(elisaImport LINK_PRIVATE KF5::ConfigCore KF5::ConfigGui elisaLib ) if (KF5FileMetaData_FOUND) target_link_libraries(elisaImport LINK_PRIVATE KF5::FileMetaData ) endif() set(QML_IMPORT_PATH ${CMAKE_BINARY_DIR}/bin CACHE INTERNAL "qml import path" FORCE) if (ANDROID) kirigami_package_breeze_icons(ICONS elisa) endif() diff --git a/src/qml/AlbumView.qml b/src/qml/AlbumView.qml index 794a44c5..5e4aa145 100644 --- a/src/qml/AlbumView.qml +++ b/src/qml/AlbumView.qml @@ -1,107 +1,106 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -Item { +FocusScope { id: albumView property alias mainTitle: albumGridView.mainTitle property alias secondaryTitle: albumGridView.secondaryTitle property alias image: albumGridView.image - property alias stackView: albumGridView.stackView DataModel { id: realModel } SingleAlbumProxyModel { id: proxyModel sourceModel: realModel onTrackToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } ListBrowserView { id: albumGridView + anchors.fill: parent + contentModel: proxyModel isSubPage: true enableSorting: false - anchors.fill: parent - delegate: MediaAlbumTrackDelegate { id: entry width: albumGridView.delegateWidth height: ((true && !true) ? elisaTheme.delegateHeight*2 : elisaTheme.delegateHeight) focus: true databaseId: model.databaseId title: model.title artist: model.artist album: (model.album !== undefined && model.album !== '' ? model.album : '') albumArtist: model.albumArtist duration: model.duration imageUrl: (model.imageUrl !== undefined && model.imageUrl !== '' ? model.imageUrl : '') trackNumber: model.trackNumber discNumber: model.discNumber rating: model.rating isFirstTrackOfDisc: true isSingleDiscAlbum: true isAlternateColor: (index % 2) === 1 mediaTrack.onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) mediaTrack.onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) mediaTrack.onClicked: albumGridView.currentIndex = index } allowArtistNavigation: true onShowArtist: { - viewManager.openOneArtist(stackView, name, elisaTheme.artistIcon, 0) + viewManager.openOneArtist(name, elisaTheme.artistIcon, 0) } onGoBack: viewManager.goBack() } Connections { target: elisa onMusicManagerChanged: realModel.initializeByAlbumTitleAndArtist(elisa.musicManager, ElisaUtils.Track, mainTitle, secondaryTitle) } Component.onCompleted: { if (elisa.musicManager) { realModel.initializeByAlbumTitleAndArtist(elisa.musicManager, ElisaUtils.Track, mainTitle, secondaryTitle) } } } diff --git a/src/qml/AlbumsView.qml b/src/qml/AlbumsView.qml index fbf86c9a..bc9ad658 100644 --- a/src/qml/AlbumsView.qml +++ b/src/qml/AlbumsView.qml @@ -1,112 +1,80 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -MediaBrowser { +FocusScope { id: allAlbums - focus: true - - anchors { - fill: parent - - leftMargin: elisaTheme.layoutHorizontalMargin - rightMargin: elisaTheme.layoutHorizontalMargin - } - - Loader { - id: modelLoaderIndicator - - anchors.fill: parent - - anchors.leftMargin: parent.width / 3 - anchors.rightMargin: parent.width / 3 - anchors.topMargin: parent.height / 3 - anchors.bottomMargin: parent.height / 3 - - z: 2 - - sourceComponent: BusyIndicator { - id: busyScanningMusic - hoverEnabled: false + property alias mainTitle: gridView.mainTitle + property alias image: gridView.image - anchors.fill: parent - - opacity: 0.8 - - visible: true - running: true - - z: 2 - } - - active: false - } + focus: true DataModel { id: realModel } AllAlbumsProxyModel { id: proxyModel sourceModel: realModel onAlbumToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } - firstPage: GridBrowserView { - id: allAlbumsView + GridBrowserView { + id: gridView focus: true + anchors.fill: parent + defaultIcon: elisaTheme.albumCoverIcon contentModel: proxyModel image: elisaTheme.albumIcon mainTitle: i18nc("Title of the view of all albums", "Albums") onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Album, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Album, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) - onOpen: viewManager.openOneAlbum(allAlbums.stackView, innerMainTitle, - innerSecondaryTitle, innerImage, databaseId) + onOpen: viewManager.openOneAlbum(innerMainTitle, innerSecondaryTitle, innerImage, databaseId) onGoBack: viewManager.goBack() } Connections { target: elisa onMusicManagerChanged: realModel.initialize(elisa.musicManager, ElisaUtils.Album) } Component.onCompleted: { if (elisa.musicManager) { realModel.initialize(elisa.musicManager, ElisaUtils.Album) } } } diff --git a/src/qml/ArtistsView.qml b/src/qml/ArtistsView.qml index d275d61d..353de2a3 100644 --- a/src/qml/ArtistsView.qml +++ b/src/qml/ArtistsView.qml @@ -1,85 +1,83 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -MediaBrowser { +FocusScope { id: allArtists - focus: true - - anchors { - fill: parent + property alias mainTitle: gridView.mainTitle + property alias image: gridView.image - leftMargin: elisaTheme.layoutHorizontalMargin - rightMargin: elisaTheme.layoutHorizontalMargin - } + focus: true DataModel { id: realModel } AllArtistsProxyModel { id: proxyModel sourceModel: realModel onArtistToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } - firstPage: GridBrowserView { - id: allArtistsView + GridBrowserView { + id: gridView focus: true + anchors.fill: parent + showRating: false delegateDisplaySecondaryText: false defaultIcon: elisaTheme.artistIcon contentModel: proxyModel image: elisaTheme.artistIcon mainTitle: i18nc("Title of the view of all artists", "Artists") onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Artist, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Artist, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) - onOpen: viewManager.openOneArtist(allArtists.stackView, innerMainTitle, innerImage, 0) + onOpen: viewManager.openOneArtist(innerMainTitle, innerImage, 0) onGoBack: viewManager.goBack() } Connections { target: elisa onMusicManagerChanged: realModel.initialize(elisa.musicManager, ElisaUtils.Artist) } Component.onCompleted: { if (elisa.musicManager) { realModel.initialize(elisa.musicManager, ElisaUtils.Artist) } } } diff --git a/src/qml/ContentView.qml b/src/qml/ContentView.qml index 3d297747..e25c76e8 100644 --- a/src/qml/ContentView.qml +++ b/src/qml/ContentView.qml @@ -1,655 +1,622 @@ /* * 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() } - ViewNavigation { + ViewManager { id: viewManager + onSwitchOffAllViews: { + listViews.currentIndex = 0 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } + } + onSwitchRecentlyPlayedTracksView: { listViews.currentIndex = 1 - localRecentlyPlayedTracksLoader.opacity = 1 - localFrequentlyPlayedTracksLoader.opacity = 0 - localAlbumsLoader.opacity = 0 - localArtistsLoader.opacity = 0 - localTracksLoader.opacity = 0 - localGenresLoader.opacity = 0 - localFilesLoader.opacity = 0 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } + + browseStackView.push(allRecentlyPlayedTracksView, { + mainTitle: mainTitle, + image: imageUrl, + stackView: browseStackView, + opacity: 0, + }) + + recentlyPlayedTracksIsLoaded() } onSwitchFrequentlyPlayedTracksView: { listViews.currentIndex = 2 - localRecentlyPlayedTracksLoader.opacity = 0 - localFrequentlyPlayedTracksLoader.opacity = 1 - localAlbumsLoader.opacity = 0 - localArtistsLoader.opacity = 0 - localTracksLoader.opacity = 0 - localGenresLoader.opacity = 0 - localFilesLoader.opacity = 0 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } + + browseStackView.push(allRecentlyPlayedTracksView, { + mainTitle: mainTitle, + image: imageUrl, + stackView: browseStackView, + opacity: 0, + }) + + frequentlyPlayedTracksIsLoaded() } onSwitchAllAlbumsView: { listViews.currentIndex = 3 - localRecentlyPlayedTracksLoader.opacity = 0 - localFrequentlyPlayedTracksLoader.opacity = 0 - localAlbumsLoader.opacity = 1 - localArtistsLoader.opacity = 0 - localTracksLoader.opacity = 0 - localGenresLoader.opacity = 0 - localFilesLoader.opacity = 0 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } + + browseStackView.push(allAlbumsView, { + mainTitle: mainTitle, + image: imageUrl, + stackView: browseStackView, + opacity: 0, + }) + + allAlbumsViewIsLoaded() } onSwitchOneAlbumView: { - currentStackView.push(albumView, { - mainTitle: mainTitle, - secondaryTitle: secondaryTitle, - image: imageUrl, - stackView: currentStackView, - }) + browseStackView.push(albumView, { + mainTitle: mainTitle, + secondaryTitle: secondaryTitle, + image: imageUrl, + stackView: browseStackView, + opacity: 0, + }) + oneAlbumViewIsLoaded() } onSwitchAllArtistsView: { listViews.currentIndex = 4 - localRecentlyPlayedTracksLoader.opacity = 0 - localFrequentlyPlayedTracksLoader.opacity = 0 - localAlbumsLoader.opacity = 0 - localArtistsLoader.opacity = 1 - localTracksLoader.opacity = 0 - localGenresLoader.opacity = 0 - localFilesLoader.opacity = 0 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } + + browseStackView.push(allArtistsView, { + mainTitle: mainTitle, + image: imageUrl, + stackView: browseStackView, + opacity: 0, + }) + + allArtistsViewIsLoaded() } onSwitchOneArtistView: { - currentStackView.push(innerAlbumView, { - mainTitle: mainTitle, - secondaryTitle: secondaryTitle, - image: imageUrl, - stackView: currentStackView, - artistFilter: mainTitle, - }) + browseStackView.push(innerAlbumView, { + mainTitle: mainTitle, + secondaryTitle: secondaryTitle, + image: imageUrl, + stackView: browseStackView, + artistFilter: mainTitle, + opacity: 0, + }) + oneArtistViewIsLoaded() } onSwitchOneArtistFromGenreView: { - currentStackView.push(innerAlbumView, { - mainTitle: mainTitle, - secondaryTitle: secondaryTitle, - image: imageUrl, - stackView: currentStackView, - genreFilterText: genreName, - artistFilter: mainTitle, - }) + browseStackView.push(innerAlbumView, { + mainTitle: mainTitle, + secondaryTitle: secondaryTitle, + image: imageUrl, + stackView: browseStackView, + genreFilterText: genreName, + artistFilter: mainTitle, + opacity: 0, + }) + oneArtistViewIsLoaded() } onSwitchAllTracksView: { listViews.currentIndex = 5 - localRecentlyPlayedTracksLoader.opacity = 0 - localFrequentlyPlayedTracksLoader.opacity = 0 - localAlbumsLoader.opacity = 0 - localArtistsLoader.opacity = 0 - localTracksLoader.opacity = 1 - localGenresLoader.opacity = 0 - localFilesLoader.opacity = 0 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } + + browseStackView.push(allTracksView, { + mainTitle: mainTitle, + image: imageUrl, + stackView: browseStackView, + opacity: 0, + }) + + allTracksViewIsLoaded() } onSwitchAllGenresView: { listViews.currentIndex = 6 - localRecentlyPlayedTracksLoader.opacity = 0 - localFrequentlyPlayedTracksLoader.opacity = 0 - localAlbumsLoader.opacity = 0 - localArtistsLoader.opacity = 0 - localTracksLoader.opacity = 0 - localGenresLoader.opacity = 1 - localFilesLoader.opacity = 0 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } + + browseStackView.push(allGenresView, { + mainTitle: mainTitle, + image: imageUrl, + stackView: browseStackView, + opacity: 0, + }) + + allGenresViewIsLoaded() } onSwitchFilesBrowserView: { listViews.currentIndex = 7 - localRecentlyPlayedTracksLoader.opacity = 0 - localFrequentlyPlayedTracksLoader.opacity = 0 - localAlbumsLoader.opacity = 0 - localArtistsLoader.opacity = 0 - localTracksLoader.opacity = 0 - localGenresLoader.opacity = 0 - localFilesLoader.opacity = 1 + + while(browseStackView.depth > 1) { + browseStackView.pop() + } } onSwitchAllArtistsFromGenreView: { - currentStackView.push(innerArtistView, { - mainTitle: genreName, - secondaryTitle: '', - image: elisaTheme.artistIcon, - stackView: currentStackView, - genreFilterText: genreName, - }) + browseStackView.push(innerArtistView, { + mainTitle: genreName, + secondaryTitle: '', + image: elisaTheme.artistIcon, + stackView: browseStackView, + genreFilterText: genreName, + opacity: 0, + }) + allArtistsFromGenreViewIsLoaded() } - onSwitchOffAllViews: { - localRecentlyPlayedTracksLoader.opacity = 0 - localFrequentlyPlayedTracksLoader.opacity = 0 - localAlbumsLoader.opacity = 0 - localArtistsLoader.opacity = 0 - localTracksLoader.opacity = 0 - localGenresLoader.opacity = 0 - localFilesLoader.opacity = 0 - } + 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() + viewManager.openRecentlyPlayedTracks(mainTitle, imageUrl) } else if (index === 2) { - viewManager.openFrequentlyPlayedTracks() + viewManager.openFrequentlyPlayedTracks(mainTitle, imageUrl) } else if (index === 3) { - viewManager.openAllAlbums() + viewManager.openAllAlbums(mainTitle, imageUrl) } else if (index === 4) { - viewManager.openAllArtists() + viewManager.openAllArtists(mainTitle, imageUrl) } else if (index === 5) { - viewManager.openAllTracks() + viewManager.openAllTracks(mainTitle, imageUrl) } else if (index === 6) { - viewManager.openAllGenres() + viewManager.openAllGenres(mainTitle, imageUrl) } else if (index === 7) { - viewManager.openFilesBrowser() + viewManager.openFilesBrowser(mainTitle, imageUrl) } else { viewManager.closeAllViews() } } 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 - Loader { - id: localRecentlyPlayedTracksLoader - - active: opacity > 0 - - visible: opacity > 0 - - opacity: 0 - - anchors.fill: parent - - onLoaded: viewManager.recentlyPlayedTracksIsLoaded(item.stackView) - - sourceComponent: RecentlyPlayedTracks { - } - - Behavior on opacity { - NumberAnimation { - easing.type: Easing.InOutQuad - duration: 300 - } - } - } - - Loader { - id: localFrequentlyPlayedTracksLoader - - active: opacity > 0 - - visible: opacity > 0 - - opacity: 0 + StackView { + id: browseStackView anchors.fill: parent - onLoaded: viewManager.frequentlyPlayedTracksIsLoaded(item.stackView) + clip: true - sourceComponent: FrequentlyPlayedTracks { + initialItem: Item { } - Behavior on opacity { - NumberAnimation { - easing.type: Easing.InOutQuad + popEnter: Transition { + OpacityAnimator { + from: 0.0 + to: 1.0 duration: 300 } } - } - - Loader { - id: localAlbumsLoader - - active: opacity > 0 - - visible: opacity > 0 - - anchors.fill: parent - onLoaded: viewManager.allAlbumsViewIsLoaded(item.stackView) - - sourceComponent: AlbumsView { - } - - Behavior on opacity { - NumberAnimation { - easing.type: Easing.InOutQuad + popExit: Transition { + OpacityAnimator { + from: 1.0 + to: 0.0 duration: 300 } } - } - - Loader { - id: localArtistsLoader - - active: opacity > 0 - - visible: opacity > 0 - - opacity: 0 - - anchors.fill: parent - - onLoaded: viewManager.allArtistsViewIsLoaded(item.stackView) - - sourceComponent: ArtistsView { - } - Behavior on opacity { - NumberAnimation { - easing.type: Easing.InOutQuad + pushEnter: Transition { + OpacityAnimator { + from: 0.0 + to: 1.0 duration: 300 } } - } - - Loader { - id: localTracksLoader - - active: opacity > 0 - - visible: opacity > 0 - opacity: 0 - - anchors.fill: parent - - onLoaded: viewManager.allTracksViewIsLoaded(item) - - sourceComponent: TracksView { - } - - Behavior on opacity { - NumberAnimation { - easing.type: Easing.InOutQuad + pushExit: Transition { + OpacityAnimator { + from: 1.0 + to: 0.0 duration: 300 } } - } - - Loader { - id: localGenresLoader - - active: opacity > 0 - - visible: opacity > 0 - - opacity: 0 - - anchors.fill: parent - - onLoaded: viewManager.allGenresViewIsLoaded(item.stackView) - - sourceComponent: GenresView { - } - Behavior on opacity { - NumberAnimation { - easing.type: Easing.InOutQuad + replaceEnter: Transition { + OpacityAnimator { + from: 0.0 + to: 1.0 duration: 300 } } - } - - Loader { - id: localFilesLoader - anchors.fill: parent - - active: opacity > 0 - - visible: opacity > 0 - - opacity: 0 - - anchors { - fill: parent - - leftMargin: elisaTheme.layoutHorizontalMargin - rightMargin: elisaTheme.layoutHorizontalMargin - } - onLoaded: viewManager.filesBrowserViewIsLoaded(item) - - sourceComponent: FileBrowserView { - id: localFiles - - focus: true - } - - Behavior on opacity { - NumberAnimation { - easing.type: Easing.InOutQuad + 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: allAlbumsView + + AlbumsView { + } + } + + Component { + id: allArtistsView + + ArtistsView { + } + } + + Component { + id: allGenresView + + GenresView { + } + } + + Component { + id: allTracksView + + TracksView { + } + } + Component { id: innerAlbumView OneArtistView { } } Component { id: innerArtistView OneGenreView { } } Component { id: albumView AlbumView { } } } diff --git a/src/qml/FrequentlyPlayedTracks.qml b/src/qml/FrequentlyPlayedTracks.qml index 69502d7c..4f61e83e 100644 --- a/src/qml/FrequentlyPlayedTracks.qml +++ b/src/qml/FrequentlyPlayedTracks.qml @@ -1,102 +1,101 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -MediaBrowser { +FocusScope { id: localTracks - focus: true - - anchors { - fill: parent + property alias mainTitle: listView.mainTitle + property alias image: listView.image - leftMargin: elisaTheme.layoutHorizontalMargin - rightMargin: elisaTheme.layoutHorizontalMargin - } + focus: true DataModel { id: realModel } AllTracksProxyModel { id: proxyModel sortRole: DatabaseInterface.PlayFrequency sourceModel: realModel onTrackToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } - firstPage: ListBrowserView { - id: allTracksView + ListBrowserView { + id: listView + focus: true + anchors.fill: parent + contentModel: proxyModel delegate: MediaTrackDelegate { id: entry - width: allTracksView.delegateWidth + width: listView.delegateWidth height: elisaTheme.trackDelegateHeight focus: true databaseId: model.databaseId title: model.title artist: model.artist album: (model.album !== undefined && model.album !== '' ? model.album : '') albumArtist: model.albumArtist duration: model.duration imageUrl: (model.imageUrl !== undefined && model.imageUrl !== '' ? model.imageUrl : '') trackNumber: model.trackNumber discNumber: model.discNumber rating: model.rating isFirstTrackOfDisc: false isSingleDiscAlbum: model.isSingleDiscAlbum onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) onClicked: contentDirectoryView.currentIndex = index } image: elisaTheme.frequentlyPlayedTracksIcon mainTitle: i18nc("Title of the view of frequently played tracks", "Frequently Played") } Connections { target: elisa onMusicManagerChanged: realModel.initializeFrequentlyPlayed(elisa.musicManager, ElisaUtils.Track) } Component.onCompleted: { if (elisa.musicManager) { realModel.initializeFrequentlyPlayed(elisa.musicManager, ElisaUtils.Track) } proxyModel.sortModel(Qt.DescendingOrder) } } diff --git a/src/qml/GenresView.qml b/src/qml/GenresView.qml index 6d5d5bb7..bb8e685f 100644 --- a/src/qml/GenresView.qml +++ b/src/qml/GenresView.qml @@ -1,83 +1,82 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -MediaBrowser { +FocusScope { id: localGenres - focus: true - - anchors { - fill: parent + property alias mainTitle: gridView.mainTitle + property alias image: gridView.image - leftMargin: elisaTheme.layoutHorizontalMargin - rightMargin: elisaTheme.layoutHorizontalMargin - } + focus: true DataModel { id: realModel } AllArtistsProxyModel { id: proxyModel sourceModel: realModel onArtistToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } - firstPage: GridBrowserView { - id: allGenresView + GridBrowserView { + id: gridView + focus: true + anchors.fill: parent + showRating: false delegateDisplaySecondaryText: false defaultIcon: elisaTheme.genresIcon contentModel: proxyModel image: elisaTheme.genresIcon mainTitle: i18nc("Title of the view of all genres", "Genres") onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Genre, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Genre, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) - onOpen: viewManager.openAllArtistsFromGenre(localGenres.stackView, innerMainTitle) + onOpen: viewManager.openAllArtistsFromGenre(innerMainTitle) onGoBack: viewManager.goBack() } Connections { target: elisa onMusicManagerChanged: realModel.initialize(elisa.musicManager, ElisaUtils.Genre) } Component.onCompleted: { if (elisa.musicManager) { realModel.initialize(elisa.musicManager, ElisaUtils.Genre) } } } diff --git a/src/qml/OneArtistView.qml b/src/qml/OneArtistView.qml index ae6e7f0f..eaccab84 100644 --- a/src/qml/OneArtistView.qml +++ b/src/qml/OneArtistView.qml @@ -1,91 +1,90 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -Item { +FocusScope { id: oneArtist - property alias mainTitle: albumGridView.mainTitle - property alias secondaryTitle: albumGridView.secondaryTitle - property alias image: albumGridView.image - property alias stackView: albumGridView.stackView + property alias mainTitle: gridView.mainTitle + property alias secondaryTitle: gridView.secondaryTitle + property alias image: gridView.image property string genreFilterText property string artistFilter DataModel { id: realModel } AllAlbumsProxyModel { id: proxyModel sourceModel: realModel onAlbumToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } GridBrowserView { - id: albumGridView + id: gridView focus: true + anchors.fill: parent defaultIcon: elisaTheme.albumCoverIcon contentModel: proxyModel isSubPage: true onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Album, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Album, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) - onOpen: viewManager.openOneAlbum(stackView, innerMainTitle, - innerSecondaryTitle, innerImage, databaseId) + onOpen: viewManager.openOneAlbum(innerMainTitle, innerSecondaryTitle, innerImage, databaseId) onGoBack: viewManager.goBack() } Connections { target: elisa onMusicManagerChanged: { if (genreFilterText) { realModel.initializeByGenreAndArtist(elisa.musicManager, ElisaUtils.Album, genreFilterText, artistFilter) } else { realModel.initializeByArtist(elisa.musicManager, ElisaUtils.Album, artistFilter) } } } Component.onCompleted: { if (elisa.musicManager) { if (genreFilterText) { realModel.initializeByGenreAndArtist(elisa.musicManager, ElisaUtils.Album, genreFilterText, artistFilter) } else { realModel.initializeByArtist(elisa.musicManager, ElisaUtils.Album, artistFilter) } } } } diff --git a/src/qml/OneGenreView.qml b/src/qml/OneGenreView.qml index c4e36a55..f3081ff8 100644 --- a/src/qml/OneGenreView.qml +++ b/src/qml/OneGenreView.qml @@ -1,81 +1,81 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -Item { +FocusScope { id: oneGenre - property alias mainTitle: albumGridView.mainTitle - property alias secondaryTitle: albumGridView.secondaryTitle - property alias image: albumGridView.image - property alias stackView: albumGridView.stackView + property alias mainTitle: gridView.mainTitle + property alias secondaryTitle: gridView.secondaryTitle + property alias image: gridView.image property string genreFilterText DataModel { id: realModel } AllArtistsProxyModel { id: proxyModel sourceModel: realModel onArtistToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } GridBrowserView { - id: albumGridView + id: gridView contentModel: proxyModel focus: true + anchors.fill: parent defaultIcon: elisaTheme.artistIcon delegateDisplaySecondaryText: false isSubPage: true onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Artist, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Artist, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) - onOpen: viewManager.openOneArtist(stackView, innerMainTitle, innerImage, 0) + onOpen: viewManager.openOneArtist(innerMainTitle, innerImage, 0) onGoBack: viewManager.goBack() } Connections { target: elisa onMusicManagerChanged: realModel.initializeByGenre(elisa.musicManager, ElisaUtils.Artist, genreFilterText) } Component.onCompleted: { if (elisa.musicManager) { realModel.initializeByGenre(elisa.musicManager, ElisaUtils.Artist, genreFilterText) } } } diff --git a/src/qml/RecentlyPlayedTracks.qml b/src/qml/RecentlyPlayedTracks.qml index 986434ac..467b66a8 100644 --- a/src/qml/RecentlyPlayedTracks.qml +++ b/src/qml/RecentlyPlayedTracks.qml @@ -1,102 +1,101 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -MediaBrowser { +FocusScope { id: localTracks - focus: true - - anchors { - fill: parent + property alias mainTitle: listView.mainTitle + property alias image: listView.image - leftMargin: elisaTheme.layoutHorizontalMargin - rightMargin: elisaTheme.layoutHorizontalMargin - } + focus: true DataModel { id: realModel } AllTracksProxyModel { id: proxyModel sortRole: DatabaseInterface.LastPlayDate sourceModel: realModel onTrackToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } - firstPage: ListBrowserView { - id: allTracksView + ListBrowserView { + id: listView + focus: true + anchors.fill: parent + contentModel: proxyModel delegate: MediaTrackDelegate { id: entry - width: allTracksView.delegateWidth + width: listView.delegateWidth height: elisaTheme.trackDelegateHeight focus: true databaseId: model.databaseId title: model.title artist: model.artist album: (model.album !== undefined && model.album !== '' ? model.album : '') albumArtist: model.albumArtist duration: model.duration imageUrl: (model.imageUrl !== undefined && model.imageUrl !== '' ? model.imageUrl : '') trackNumber: model.trackNumber discNumber: model.discNumber rating: model.rating isFirstTrackOfDisc: false isSingleDiscAlbum: model.isSingleDiscAlbum onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) onClicked: contentDirectoryView.currentIndex = index } image: elisaTheme.recentlyPlayedTracksIcon mainTitle: i18nc("Title of the view of recently played tracks", "Recently Played") } Connections { target: elisa onMusicManagerChanged: realModel.initializeRecentlyPlayed(elisa.musicManager, ElisaUtils.Track) } Component.onCompleted: { if (elisa.musicManager) { realModel.initializeRecentlyPlayed(elisa.musicManager, ElisaUtils.Track) } proxyModel.sortModel(Qt.DescendingOrder) } } diff --git a/src/qml/TracksView.qml b/src/qml/TracksView.qml index 398a2270..9883745f 100644 --- a/src/qml/TracksView.qml +++ b/src/qml/TracksView.qml @@ -1,100 +1,99 @@ /* * 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 . */ import QtQuick 2.10 import QtQuick.Controls 2.3 import org.kde.elisa 1.0 -MediaBrowser { +FocusScope { id: localTracks - focus: true - - anchors { - fill: parent + property alias mainTitle: listView.mainTitle + property alias image: listView.image - leftMargin: elisaTheme.layoutHorizontalMargin - rightMargin: elisaTheme.layoutHorizontalMargin - } + focus: true DataModel { id: realModel } AllTracksProxyModel { id: proxyModel sortRole: Qt.DisplayRole sourceModel: realModel onTrackToEnqueue: elisa.mediaPlayList.enqueue(newEntries, databaseIdType, enqueueMode, triggerPlay) } - firstPage: ListBrowserView { - id: allTracksView + ListBrowserView { + id: listView + focus: true + anchors.fill: parent + contentModel: proxyModel delegate: MediaTrackDelegate { id: entry - width: allTracksView.delegateWidth + width: listView.delegateWidth height: elisaTheme.trackDelegateHeight focus: true databaseId: model.databaseId title: model.title artist: model.artist album: (model.album !== undefined && model.album !== '' ? model.album : '') albumArtist: model.albumArtist duration: model.duration imageUrl: (model.imageUrl !== undefined && model.imageUrl !== '' ? model.imageUrl : '') trackNumber: model.trackNumber discNumber: model.discNumber rating: model.rating isFirstTrackOfDisc: false isSingleDiscAlbum: model.isSingleDiscAlbum onEnqueue: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.AppendPlayList, ElisaUtils.DoNotTriggerPlay) onReplaceAndPlay: elisa.mediaPlayList.enqueue(databaseId, name, ElisaUtils.Track, ElisaUtils.ReplacePlayList, ElisaUtils.TriggerPlay) onClicked: contentDirectoryView.currentIndex = index } image: elisaTheme.tracksIcon mainTitle: i18nc("Title of the view of all tracks", "Tracks") } Connections { target: elisa onMusicManagerChanged: realModel.initialize(elisa.musicManager, ElisaUtils.Track) } Component.onCompleted: { if (elisa.musicManager) { realModel.initialize(elisa.musicManager, ElisaUtils.Track) } } } diff --git a/src/qml/ViewNavigation.qml b/src/qml/ViewNavigation.qml deleted file mode 100644 index 975c27af..00000000 --- a/src/qml/ViewNavigation.qml +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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 org.kde.elisa 1.0 - -ViewManager { - property var currentStackView - - function openOneAlbum(stackView, albumTitle, albumAuthor, albumCover, albumDatabaseId) - { - currentStackView = stackView - abstractOpenOneAlbum(albumTitle, albumAuthor, albumCover, albumDatabaseId) - } - - function openOneArtist(stackView, artistName, artistImageUrl, artistDatabaseId) - { - currentStackView = stackView - abstractOpenOneArtist(artistName, artistImageUrl, artistDatabaseId) - } - - function openAllArtistsFromGenre(stackView, genreName) - { - currentStackView = stackView - abstractOpenAllArtistsFromGenre(genreName) - } - - function allAlbumsViewIsLoaded(stackView) - { - currentStackView = stackView - abstractAllAlbumsViewIsLoaded() - } - - function allArtistsViewIsLoaded(stackView) - { - currentStackView = stackView - abstractAllArtistsViewIsLoaded() - } - - function allGenresViewIsLoaded(stackView) - { - currentStackView = stackView - abstractAllGenresViewIsLoaded() - } - - function recentlyPlayedTracksIsLoaded(stackView) - { - currentStackView = stackView - abstractRecentlyPlayedTracksIsLoaded() - } - - function frequentlyPlayedTracksIsLoaded(stackView) - { - currentStackView = stackView - abstractFrequentlyPlayedTracksIsLoaded() - } - - onPopOneView: currentStackView.pop() -} diff --git a/src/qml/ViewSelector.qml b/src/qml/ViewSelector.qml index 6f82abaa..3548bb9e 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) + signal switchView(int index, string mainTitle, url imageUrl) 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) + switchView(index, model.display, model.image) } } } 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 = 3 - switchView(viewModeView.currentIndex) + 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/resources.qrc b/src/resources.qrc index abc7f34d..d01a05b3 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -1,64 +1,63 @@ qml/MediaPlayerControl.qml qml/RatingStar.qml qml/MediaPlayListView.qml qml/ElisaMainWindow.qml qml/ApplicationMenu.qml qml/HeaderBar.qml qml/ContextView.qml qml/ContentView.qml qml/DraggableItem.qml qml/PassiveNotification.qml qml/NavigationActionBar.qml qml/PlayListEntry.qml qml/MediaBrowser.qml qml/Theme.qml qml/PlatformIntegration.qml qml/LabelWithToolTip.qml qml/TopNotification.qml qml/TrackImportNotification.qml qml/TopNotificationItem.qml - qml/ViewSelector.qml qml/MediaTrackDelegate.qml qml/MediaAlbumTrackDelegate.qml qml/MediaTrackMetadataView.qml qml/GridBrowserView.qml qml/GridBrowserDelegate.qml qml/ListBrowserView.qml qml/FileBrowserDelegate.qml qml/FileBrowserView.qml qtquickcontrols2.conf background.png - qml/ViewNavigation.qml qml/BaseTheme.qml qml/ScrollHelper.qml qml/FlatButtonWithToolTip.qml qml/AlbumsView.qml qml/ArtistsView.qml qml/GenresView.qml qml/TracksView.qml qml/AlbumView.qml qml/OneArtistView.qml qml/OneGenreView.qml qml/RecentlyPlayedTracks.qml qml/FrequentlyPlayedTracks.qml qml/PlayListBasicView.qml qml/SimplePlayListView.qml qml/SimplePlayListEntry.qml + qml/ViewSelector.qml windows/WindowsTheme.qml windows/PlatformIntegration.qml windows/LabelWithToolTip.qml android/ElisaMainWindow.qml android/AndroidTheme.qml android/PlatformIntegration.qml android/AlbumsView.qml android/ArtistsView.qml android/TracksView.qml android/GenresView.qml diff --git a/src/viewmanager.cpp b/src/viewmanager.cpp index eed386db..e4270a29 100644 --- a/src/viewmanager.cpp +++ b/src/viewmanager.cpp @@ -1,248 +1,248 @@ /* * 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::openRecentlyPlayedTracks() +void ViewManager::openRecentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::RecentlyPlayedTracks; if (mCurrentView != mTargetView) { - Q_EMIT switchRecentlyPlayedTracksView(); + Q_EMIT switchRecentlyPlayedTracksView(mainTitle, imageUrl); } } -void ViewManager::openFrequentlyPlayedTracks() +void ViewManager::openFrequentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::FrequentlyPlayedTracks; if (mCurrentView != mTargetView) { - Q_EMIT switchFrequentlyPlayedTracksView(); + Q_EMIT switchFrequentlyPlayedTracksView(mainTitle, imageUrl); } } -void ViewManager::openAllAlbums() +void ViewManager::openAllAlbums(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllAlbums; if (mCurrentView != mTargetView) { - Q_EMIT switchAllAlbumsView(); + Q_EMIT switchAllAlbumsView(mainTitle, imageUrl); } } -void ViewManager::abstractOpenOneAlbum(const QString &albumTitle, const QString &albumAuthor, +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(); + switchAllAlbumsView({}, {}); } } -void ViewManager::openAllArtists() +void ViewManager::openAllArtists(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllArtists; if (mCurrentView != mTargetView) { - Q_EMIT switchAllArtistsView(); + Q_EMIT switchAllArtistsView(mainTitle, imageUrl); } } -void ViewManager::abstractOpenOneArtist(const QString &artistName, const QUrl &artistImageUrl, qulonglong artistDatabaseId) +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, {}, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneArtist && mCurrentArtistName != mTargetArtistName && mTargetView == ViewsType::OneArtist) { Q_EMIT popOneView(); Q_EMIT switchOneArtistView(mTargetArtistName, mTargetImageUrl, {}, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneAlbumFromArtist && mCurrentArtistName != mTargetArtistName && mTargetView == ViewsType::OneArtist) { Q_EMIT popOneView(); Q_EMIT popOneView(); Q_EMIT switchOneArtistView(mTargetArtistName, mTargetImageUrl, {}, mTargetDatabaseId); } else if (mCurrentView == ViewsType::AllArtistsFromGenre && mTargetView == ViewsType::OneArtistFromGenre) { Q_EMIT switchOneArtistFromGenreView(mTargetArtistName, mTargetImageUrl, {}, mTargetDatabaseId, mTargetGenreName); } else { - Q_EMIT switchAllArtistsView(); + Q_EMIT switchAllArtistsView({}, {}); } } -void ViewManager::openAllTracks() +void ViewManager::openAllTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllTracks; if (mCurrentView != mTargetView) { - Q_EMIT switchAllTracksView(); + Q_EMIT switchAllTracksView(mainTitle, imageUrl); } } -void ViewManager::openAllGenres() +void ViewManager::openAllGenres(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllGenres; if (mCurrentView != mTargetView) { - Q_EMIT switchAllGenresView(); + Q_EMIT switchAllGenresView(mainTitle, imageUrl); } } -void ViewManager::abstractOpenAllArtistsFromGenre(const QString &genreName) +void ViewManager::openAllArtistsFromGenre(const QString &genreName) { mTargetView = ViewsType::AllArtistsFromGenre; mTargetGenreName = genreName; if (mCurrentView == ViewsType::AllGenres) { Q_EMIT switchAllArtistsFromGenreView(mTargetGenreName); } else { - Q_EMIT switchAllGenresView(); + Q_EMIT switchAllGenresView({}, {}); } } -void ViewManager::openFilesBrowser() +void ViewManager::openFilesBrowser(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::FilesBrowser; if (mCurrentView != mTargetView) { - Q_EMIT switchFilesBrowserView(); + Q_EMIT switchFilesBrowserView(mainTitle, imageUrl); } } -void ViewManager::abstractRecentlyPlayedTracksIsLoaded() +void ViewManager::recentlyPlayedTracksIsLoaded() { mCurrentView = ViewsType::RecentlyPlayedTracks; } -void ViewManager::abstractFrequentlyPlayedTracksIsLoaded() +void ViewManager::frequentlyPlayedTracksIsLoaded() { mCurrentView = ViewsType::FrequentlyPlayedTracks; } -void ViewManager::abstractAllAlbumsViewIsLoaded() +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::abstractAllArtistsViewIsLoaded() +void ViewManager::allArtistsViewIsLoaded() { mCurrentView = ViewsType::AllArtists; if (mTargetView == ViewsType::OneArtist) { Q_EMIT switchOneArtistView(mTargetArtistName, mTargetImageUrl, {}, 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::abstractAllGenresViewIsLoaded() +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 21e18fdf..5ae57881 100644 --- a/src/viewmanager.h +++ b/src/viewmanager.h @@ -1,147 +1,147 @@ /* * 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 #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(); + void switchRecentlyPlayedTracksView(const QString &mainTitle, const QUrl &imageUrl); - void switchFrequentlyPlayedTracksView(); + void switchFrequentlyPlayedTracksView(const QString &mainTitle, const QUrl &imageUrl); - void switchAllAlbumsView(); + void switchAllAlbumsView(const QString &mainTitle, const QUrl &imageUrl); void switchOneAlbumView(const QString &mainTitle, const QUrl &imageUrl, const QString &secondaryTitle, qulonglong databaseId); - void switchAllArtistsView(); + void switchAllArtistsView(const QString &mainTitle, const QUrl &imageUrl); void switchOneArtistView(const QString &mainTitle, const QUrl &imageUrl, const QString &secondaryTitle, qulonglong databaseId); - void switchAllTracksView(); + void switchAllTracksView(const QString &mainTitle, const QUrl &imageUrl); - void switchAllGenresView(); + void switchAllGenresView(const QString &mainTitle, const QUrl &imageUrl); void switchAllArtistsFromGenreView(const QString &genreName); void switchOneArtistFromGenreView(const QString &mainTitle, const QUrl &imageUrl, const QString &secondaryTitle, qulonglong databaseId, const QString &genreName); - void switchFilesBrowserView(); + void switchFilesBrowserView(const QString &mainTitle, const QUrl &imageUrl); void switchOffAllViews(); void popOneView(); public Q_SLOTS: void closeAllViews(); - void openRecentlyPlayedTracks(); + void openRecentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl); - void openFrequentlyPlayedTracks(); + void openFrequentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl); - void openAllAlbums(); + void openAllAlbums(const QString &mainTitle, const QUrl &imageUrl); - void abstractOpenOneAlbum(const QString &albumTitle, const QString &albumAuthor, + void openOneAlbum(const QString &albumTitle, const QString &albumAuthor, const QUrl &albumCover, qulonglong albumDatabaseId); - void openAllArtists(); + void openAllArtists(const QString &mainTitle, const QUrl &imageUrl); - void abstractOpenOneArtist(const QString &artistName, const QUrl &artistImageUrl, qulonglong artistDatabaseId); + void openOneArtist(const QString &artistName, const QUrl &artistImageUrl, qulonglong artistDatabaseId); - void openAllTracks(); + void openAllTracks(const QString &mainTitle, const QUrl &imageUrl); - void openAllGenres(); + void openAllGenres(const QString &mainTitle, const QUrl &imageUrl); - void abstractOpenAllArtistsFromGenre(const QString &genreName); + void openAllArtistsFromGenre(const QString &genreName); - void openFilesBrowser(); + void openFilesBrowser(const QString &mainTitle, const QUrl &imageUrl); - void abstractRecentlyPlayedTracksIsLoaded(); + void recentlyPlayedTracksIsLoaded(); - void abstractFrequentlyPlayedTracksIsLoaded(); + void frequentlyPlayedTracksIsLoaded(); - void abstractAllAlbumsViewIsLoaded(); + void allAlbumsViewIsLoaded(); void oneAlbumViewIsLoaded(); - void abstractAllArtistsViewIsLoaded(); + void allArtistsViewIsLoaded(); void oneArtistViewIsLoaded(); void allTracksViewIsLoaded(); - void abstractAllGenresViewIsLoaded(); + void allGenresViewIsLoaded(); void allArtistsFromGenreViewIsLoaded(); void filesBrowserViewIsLoaded(); void goBack(); private: 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