diff --git a/autotests/viewmanagertest.cpp b/autotests/viewmanagertest.cpp index d7e4d1dd..445e833a 100644 --- a/autotests/viewmanagertest.cpp +++ b/autotests/viewmanagertest.cpp @@ -1,258 +1,262 @@ /* * Copyright 2015-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 . */ #include "viewmanager.h" #include #include class ViewManagerTests: public QObject { Q_OBJECT private: private Q_SLOTS: void initTestCase() { qRegisterMetaType("ViewManager::ViewsType"); qRegisterMetaType("ElisaUtils::PlayListEntryType"); } void closeAllViewsTest() { ViewManager viewManager; QSignalSpy openGridViewSpy(&viewManager, &ViewManager::openGridView); QSignalSpy switchRecentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchRecentlyPlayedTracksView); QSignalSpy switchFrequentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchFrequentlyPlayedTracksView); QSignalSpy switchOneAlbumViewSpy(&viewManager, &ViewManager::switchOneAlbumView); QSignalSpy switchAllTracksViewSpy(&viewManager, &ViewManager::switchAllTracksView); QSignalSpy switchFilesBrowserViewSpy(&viewManager, &ViewManager::switchFilesBrowserView); QSignalSpy switchOffAllViewsSpy(&viewManager, &ViewManager::switchOffAllViews); QSignalSpy popOneViewSpy(&viewManager, &ViewManager::popOneView); viewManager.closeAllViews(); QCOMPARE(openGridViewSpy.count(), 0); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 1); QCOMPARE(popOneViewSpy.count(), 0); } void openAlbumViewTest() { ViewManager viewManager; QSignalSpy openGridViewSpy(&viewManager, &ViewManager::openGridView); QSignalSpy switchRecentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchRecentlyPlayedTracksView); QSignalSpy switchFrequentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchFrequentlyPlayedTracksView); QSignalSpy switchOneAlbumViewSpy(&viewManager, &ViewManager::switchOneAlbumView); QSignalSpy switchAllTracksViewSpy(&viewManager, &ViewManager::switchAllTracksView); QSignalSpy switchFilesBrowserViewSpy(&viewManager, &ViewManager::switchFilesBrowserView); QSignalSpy switchOffAllViewsSpy(&viewManager, &ViewManager::switchOffAllViews); QSignalSpy popOneViewSpy(&viewManager, &ViewManager::popOneView); viewManager.openChildView(QStringLiteral("album1"), QStringLiteral("artist1"), {}, 12, ElisaUtils::Album); QCOMPARE(openGridViewSpy.count(), 1); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); QCOMPARE(openGridViewSpy.at(0).count(), 11); QCOMPARE(openGridViewSpy.at(0).at(0).value(), ViewManager::AllAlbums); viewManager.viewIsLoaded(ViewManager::AllAlbums); QCOMPARE(openGridViewSpy.count(), 1); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 1); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); + + QCOMPARE(switchOneAlbumViewSpy.at(0).count(), 6); + QCOMPARE(switchOneAlbumViewSpy.at(0).at(2), QStringLiteral("album1")); + QCOMPARE(switchOneAlbumViewSpy.at(0).at(4), QStringLiteral("artist1")); } void openArtistViewTest() { ViewManager viewManager; QSignalSpy openGridViewSpy(&viewManager, &ViewManager::openGridView); QSignalSpy switchRecentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchRecentlyPlayedTracksView); QSignalSpy switchFrequentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchFrequentlyPlayedTracksView); QSignalSpy switchOneAlbumViewSpy(&viewManager, &ViewManager::switchOneAlbumView); QSignalSpy switchAllTracksViewSpy(&viewManager, &ViewManager::switchAllTracksView); QSignalSpy switchFilesBrowserViewSpy(&viewManager, &ViewManager::switchFilesBrowserView); QSignalSpy switchOffAllViewsSpy(&viewManager, &ViewManager::switchOffAllViews); QSignalSpy popOneViewSpy(&viewManager, &ViewManager::popOneView); viewManager.openChildView(QStringLiteral("artist1"), {}, {}, 0, ElisaUtils::Artist); QCOMPARE(openGridViewSpy.count(), 1); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); QCOMPARE(openGridViewSpy.at(0).count(), 11); QCOMPARE(openGridViewSpy.at(0).at(0).value(), ViewManager::AllArtists); viewManager.viewIsLoaded(ViewManager::AllArtists); QCOMPARE(openGridViewSpy.count(), 2); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); QCOMPARE(openGridViewSpy.at(1).count(), 11); QCOMPARE(openGridViewSpy.at(1).at(0).value(), ViewManager::OneArtist); } void openGenreViewTest() { ViewManager viewManager; QSignalSpy openGridViewSpy(&viewManager, &ViewManager::openGridView); QSignalSpy switchRecentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchRecentlyPlayedTracksView); QSignalSpy switchFrequentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchFrequentlyPlayedTracksView); QSignalSpy switchOneAlbumViewSpy(&viewManager, &ViewManager::switchOneAlbumView); QSignalSpy switchAllTracksViewSpy(&viewManager, &ViewManager::switchAllTracksView); QSignalSpy switchFilesBrowserViewSpy(&viewManager, &ViewManager::switchFilesBrowserView); QSignalSpy switchOffAllViewsSpy(&viewManager, &ViewManager::switchOffAllViews); QSignalSpy popOneViewSpy(&viewManager, &ViewManager::popOneView); viewManager.openChildView(QStringLiteral("genre1"), {}, {}, 0, ElisaUtils::Genre); QCOMPARE(openGridViewSpy.count(), 1); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); QCOMPARE(openGridViewSpy.at(0).count(), 11); QCOMPARE(openGridViewSpy.at(0).at(0).value(), ViewManager::AllGenres); viewManager.viewIsLoaded(ViewManager::AllArtists); QCOMPARE(openGridViewSpy.count(), 1); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); } void openArtistFromGenreViewTest() { ViewManager viewManager; QSignalSpy openGridViewSpy(&viewManager, &ViewManager::openGridView); QSignalSpy switchRecentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchRecentlyPlayedTracksView); QSignalSpy switchFrequentlyPlayedTracksViewSpy(&viewManager, &ViewManager::switchFrequentlyPlayedTracksView); QSignalSpy switchOneAlbumViewSpy(&viewManager, &ViewManager::switchOneAlbumView); QSignalSpy switchAllTracksViewSpy(&viewManager, &ViewManager::switchAllTracksView); QSignalSpy switchFilesBrowserViewSpy(&viewManager, &ViewManager::switchFilesBrowserView); QSignalSpy switchOffAllViewsSpy(&viewManager, &ViewManager::switchOffAllViews); QSignalSpy popOneViewSpy(&viewManager, &ViewManager::popOneView); viewManager.openChildView(QStringLiteral("genre1"), {}, {}, 0, ElisaUtils::Genre); QCOMPARE(openGridViewSpy.count(), 1); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); QCOMPARE(openGridViewSpy.at(0).count(), 11); QCOMPARE(openGridViewSpy.at(0).at(0).value(), ViewManager::AllGenres); viewManager.viewIsLoaded(ViewManager::AllGenres); QCOMPARE(openGridViewSpy.count(), 1); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); viewManager.openChildView(QStringLiteral("genre1"), {}, {}, 0, ElisaUtils::Genre); QCOMPARE(openGridViewSpy.count(), 2); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); QCOMPARE(openGridViewSpy.at(1).count(), 11); QCOMPARE(openGridViewSpy.at(1).at(0).value(), ViewManager::AllArtistsFromGenre); viewManager.viewIsLoaded(ViewManager::AllArtistsFromGenre); viewManager.openChildView(QStringLiteral("artist1"), {}, {}, 0, ElisaUtils::Artist); QCOMPARE(openGridViewSpy.count(), 3); QCOMPARE(switchRecentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchFrequentlyPlayedTracksViewSpy.count(), 0); QCOMPARE(switchOneAlbumViewSpy.count(), 0); QCOMPARE(switchAllTracksViewSpy.count(), 0); QCOMPARE(switchFilesBrowserViewSpy.count(), 0); QCOMPARE(switchOffAllViewsSpy.count(), 0); QCOMPARE(popOneViewSpy.count(), 0); QCOMPARE(openGridViewSpy.at(2).count(), 11); QCOMPARE(openGridViewSpy.at(2).at(0).value(), ViewManager::OneArtistFromGenre); viewManager.viewIsLoaded(ViewManager::OneArtistFromGenre); } }; QTEST_GUILESS_MAIN(ViewManagerTests) #include "viewmanagertest.moc" diff --git a/src/viewmanager.cpp b/src/viewmanager.cpp index a4c44820..5c28ee0c 100644 --- a/src/viewmanager.cpp +++ b/src/viewmanager.cpp @@ -1,372 +1,372 @@ /* * 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(mTargetView); } 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::Lyricist: case ElisaUtils::Composer: case ElisaUtils::Unknown: break; } } void ViewManager::viewIsLoaded(ViewManager::ViewsType viewType) { switch (viewType) { case ViewsType::RecentlyPlayedTracks: recentlyPlayedTracksIsLoaded(); break; case ViewsType::FrequentlyPlayedTracks: frequentlyPlayedTracksIsLoaded(); break; case ViewsType::AllAlbums: allAlbumsViewIsLoaded(); break; case ViewsType::OneAlbum: oneAlbumViewIsLoaded(); break; case ViewsType::AllArtists: allArtistsViewIsLoaded(); break; case ViewsType::OneArtist: oneArtistViewIsLoaded(); break; case ViewsType::OneAlbumFromArtist: oneAlbumViewIsLoaded(); break; case ViewsType::AllTracks: allTracksViewIsLoaded(); break; case ViewsType::AllGenres: allGenresViewIsLoaded(); break; case ViewsType::AllArtistsFromGenre: allArtistsFromGenreViewIsLoaded(); break; case ViewsType::OneArtistFromGenre: oneArtistViewIsLoaded(); break; case ViewsType::OneAlbumFromArtistAndGenre: oneAlbumViewIsLoaded(); break; case ViewsType::FilesBrowser: filesBrowserViewIsLoaded(); break; case ViewsType::NoViews: break; } } void ViewManager::openRecentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::RecentlyPlayedTracks; if (mCurrentView != mTargetView) { Q_EMIT switchRecentlyPlayedTracksView(mTargetView, 1, mainTitle, imageUrl, ElisaUtils::Track); } } void ViewManager::openFrequentlyPlayedTracks(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::FrequentlyPlayedTracks; if (mCurrentView != mTargetView) { Q_EMIT switchFrequentlyPlayedTracksView(mTargetView, 1, mainTitle, imageUrl, ElisaUtils::Track); } } void ViewManager::openAllAlbums(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllAlbums; if (mCurrentView != mTargetView) { Q_EMIT openGridView(mTargetView, 1, 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(mTargetView, 2, mTargetAlbumTitle, mTargetImageUrl, mTargetAlbumAuthor, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneArtist) { mTargetView = ViewsType::OneAlbumFromArtist; Q_EMIT switchOneAlbumView(mTargetView, 3, mTargetAlbumTitle, mTargetImageUrl, mTargetAlbumAuthor, mTargetDatabaseId); } else if (mCurrentView == ViewsType::OneArtistFromGenre) { mTargetView = ViewsType::OneAlbumFromArtistAndGenre; Q_EMIT switchOneAlbumView(mTargetView, 4, mTargetAlbumTitle, mTargetImageUrl, mTargetAlbumAuthor, mTargetDatabaseId); } else { mTargetView = ViewsType::OneAlbum; Q_EMIT openGridView(ViewsType::AllAlbums, 1, {}, {}, {}, 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 openGridView(ViewsType::AllArtists, 1, 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 openGridView(mTargetView, 2, mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), {}, mTargetArtistName, true, true); } else if (mCurrentView == ViewsType::OneArtist && mCurrentArtistName != mTargetArtistName && mTargetView == ViewsType::OneArtist) { Q_EMIT openGridView(mTargetView, 2, mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), {}, mTargetArtistName, true, true); } else if (mCurrentView == ViewsType::OneAlbumFromArtist && mCurrentArtistName != mTargetArtistName && mTargetView == ViewsType::OneArtist) { Q_EMIT openGridView(mTargetView, 2, mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), {}, mTargetArtistName, true, true); } else if (mCurrentView == ViewsType::AllArtistsFromGenre && mTargetView == ViewsType::OneArtistFromGenre) { Q_EMIT openGridView(mTargetView, 3, mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), mTargetGenreName, mTargetArtistName, true, true); } else { Q_EMIT openGridView(ViewsType::AllArtists, 1, {}, {}, {}, 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(mTargetView, 1, mainTitle, imageUrl, ElisaUtils::Track); } } void ViewManager::openAllGenres(const QString &mainTitle, const QUrl &imageUrl) { mTargetView = ViewsType::AllGenres; if (mCurrentView != mTargetView) { Q_EMIT openGridView(mTargetView, 1, 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 openGridView(mTargetView, 2, mTargetGenreName, {}, QUrl(QStringLiteral("image://icon/view-media-artist")), ElisaUtils::Artist, QUrl(QStringLiteral("image://icon/view-media-artist")), mTargetGenreName, {}, false, false); } else { Q_EMIT openGridView(ViewsType::AllGenres, 1, {}, {}, {}, 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(mTargetView, 1, 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(mTargetView, 2, mTargetAlbumTitle, mTargetImageUrl, mTargetArtistName, mTargetDatabaseId); + Q_EMIT switchOneAlbumView(mTargetView, 2, mTargetAlbumTitle, mTargetImageUrl, mTargetAlbumAuthor, 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 openGridView(mTargetView, 2, mTargetArtistName, {}, mTargetImageUrl, ElisaUtils::Album, QUrl(QStringLiteral("image://icon/media-optical-audio")), {}, mTargetArtistName, true, true); } } 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; } mTargetView = mCurrentView; } #include "moc_viewmanager.cpp"