Commit 68e626a3 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵 Committed by Nate Graham
Browse files

switch the root views only by index

at the moment duplicate the views configuration data in ViewManager and
ViewsModel

should be integrated in a common data store
parent fd9f6466
......@@ -158,7 +158,7 @@ RowLayout {
Layout.fillHeight: true
onSwitchView: viewManager.openParentView(viewType, pageModel.viewMainTitle(viewType, ""), pageModel.viewImageUrl(viewType, ""))
onSwitchView: viewManager.openView(viewIndex)
}
Kirigami.Separator {
......
......@@ -29,7 +29,7 @@ FocusScope {
property double textOpacity
property alias model: pageDelegateModel.model
signal switchView(var viewType)
signal switchView(int viewIndex)
function setCurrentIndex(index)
{
......@@ -96,7 +96,7 @@ FocusScope {
}
}
onCurrentItemChanged: if (!ignoreCurrentItemChanges) switchView(currentItem.viewType)
onCurrentItemChanged: if (!ignoreCurrentItemChanges) switchView(currentIndex)
}
}
......
......@@ -19,9 +19,49 @@
#include "datatypes.h"
#include <KI18n/KLocalizedString>
class ViewParameters
{
public:
ViewManager::ViewsType mViewType;
QString mMainTitle;
QUrl mMainImage;
};
class ViewManagerPrivate
{
public:
QList<ViewParameters> mViewsData = {{ViewManager::Context,
{i18nc("Title of the view of the playlist", "Now Playing")},
QUrl{QStringLiteral("image://icon/view-media-lyrics")}},
{ViewManager::RecentlyPlayedTracks,
{i18nc("Title of the view of recently played tracks", "Recently Played")},
QUrl{QStringLiteral("image://icon/media-playlist-play")}},
{ViewManager::FrequentlyPlayedTracks,
{i18nc("Title of the view of frequently played tracks", "Frequently Played")},
QUrl{QStringLiteral("image://icon/view-media-playcount")}},
{ViewManager::AllAlbums,
{i18nc("Title of the view of all albums", "Albums")},
QUrl{QStringLiteral("image://icon/view-media-album-cover")}},
{ViewManager::AllArtists,
{i18nc("Title of the view of all artists", "Artists")},
QUrl{QStringLiteral("image://icon/view-media-artist")}},
{ViewManager::AllTracks,
{i18nc("Title of the view of all tracks", "Tracks")},
QUrl{QStringLiteral("image://icon/view-media-track")}},
{ViewManager::AllGenres,
{i18nc("Title of the view of all genres", "Genres")},
QUrl{QStringLiteral("image://icon/view-media-genre")}},
{ViewManager::FilesBrowser,
{i18nc("Title of the file browser view", "Files")},
QUrl{QStringLiteral("image://icon/document-open-folder")}},
{ViewManager::RadiosBrowser,
{i18nc("Title of the file radios browser view", "Radios")},
QUrl{QStringLiteral("image://icon/radio")}}};
QString mCurrentAlbumTitle;
QString mCurrentAlbumAuthor;
......@@ -48,6 +88,12 @@ ViewManager::ViewManager(QObject *parent)
ViewManager::~ViewManager() = default;
void ViewManager::openView(int viewIndex)
{
const auto &viewData = d->mViewsData[viewIndex];
openParentView(viewData.mViewType, viewData.mMainTitle, viewData.mMainImage);
}
void ViewManager::openParentView(ViewManager::ViewsType viewType, const QString &mainTitle, const QUrl &mainImage)
{
switch(viewType)
......
......@@ -128,6 +128,8 @@ Q_SIGNALS:
public Q_SLOTS:
void openView(int viewIndex);
void openParentView(ViewManager::ViewsType viewType, const QString &mainTitle, const QUrl &mainImage);
void openChildView(const QString &innerMainTitle, const QString & innerSecondaryTitle,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment