Commit 01982fcf authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

allow to configure initial view index

parent e0842805
Pipeline #37654 passed with stage
in 11 minutes and 27 seconds
......@@ -36,6 +36,19 @@
<choice name="AllGenres" />
</choices>
</entry>
<entry key="InitialView" type="Enum">
<choices>
<choice name="ContextView" />
<choice name="RecentlyPlayed" />
<choice name="FrequentlyPlayed" />
<choice name="AllAlbums" />
<choice name="AllArtists" />
<choice name="AllTracks" />
<choice name="AllGenres" />
<choice name="Files" />
<choice name="Radios" />
</choices>
</entry>
<entry key="ColorScheme" type="String">
</entry>
<entry key="SortRolePreferences" type="StringList">
......
......@@ -611,4 +611,11 @@ ElisaUtils::PlayListEntryType ElisaApplication::embeddedView() const
return result;
}
int ElisaApplication::initialViewIndex() const
{
int result = Elisa::ElisaConfiguration::initialView();
return result;
}
#include "moc_elisaapplication.cpp"
......@@ -90,6 +90,10 @@ class ELISALIB_EXPORT ElisaApplication : public QObject
READ colorSchemesModel
CONSTANT)
Q_PROPERTY(int initialViewIndex
READ initialViewIndex
NOTIFY initialViewIndexChanged)
public:
explicit ElisaApplication(QObject *parent = nullptr);
......@@ -125,6 +129,8 @@ public:
ElisaUtils::PlayListEntryType embeddedView() const;
int initialViewIndex() const;
Q_SIGNALS:
void argumentsChanged();
......@@ -157,6 +163,8 @@ Q_SIGNALS:
void embeddedViewChanged();
void initialViewIndexChanged();
public Q_SLOTS:
void appHelpActivated();
......
......@@ -103,6 +103,8 @@ void ElisaConfigurationDialog::save()
break;
}
Elisa::ElisaConfiguration::setInitialView(mInitialViewIndex);
Elisa::ElisaConfiguration::self()->save();
mIsDirty = false;
......@@ -157,6 +159,18 @@ void ElisaConfigurationDialog::setEmbeddedView(ElisaUtils::PlayListEntryType emb
setDirty();
}
void ElisaConfigurationDialog::setInitialViewIndex(int initialViewIndex)
{
if (mInitialViewIndex == initialViewIndex) {
return;
}
mInitialViewIndex = initialViewIndex;
QTimer::singleShot(0, [this](){ Q_EMIT initialViewIndexChanged(); });
setDirty();
}
void ElisaConfigurationDialog::setPlayAtStartup(bool playAtStartup)
{
if (mPlayAtStartup == playAtStartup) {
......@@ -202,6 +216,8 @@ void ElisaConfigurationDialog::configChanged()
setEmbeddedView(ElisaUtils::Genre);
break;
}
setInitialViewIndex(Elisa::ElisaConfiguration::initialView());
}
void ElisaConfigurationDialog::setDirty()
......
......@@ -44,6 +44,11 @@ class ELISALIB_EXPORT ElisaConfigurationDialog : public QObject
WRITE setEmbeddedView
NOTIFY embeddedViewChanged)
Q_PROPERTY(int initialViewIndex
READ initialViewIndex
WRITE setInitialViewIndex
NOTIFY initialViewIndexChanged)
Q_PROPERTY(bool isDirty
READ isDirty
NOTIFY isDirtyChanged)
......@@ -91,6 +96,11 @@ public:
return mEmbeddedView;
}
int initialViewIndex() const
{
return mInitialViewIndex;
}
bool playAtStartup() const
{
return mPlayAtStartup;
......@@ -115,6 +125,8 @@ Q_SIGNALS:
void embeddedViewChanged();
void initialViewIndexChanged();
void playAtStartupChanged();
void colorSchemeChanged();
......@@ -133,6 +145,8 @@ public Q_SLOTS:
void setEmbeddedView(ElisaUtils::PlayListEntryType embeddedView);
void setInitialViewIndex(int initialViewIndex);
void setPlayAtStartup(bool playAtStartup);
void setColorScheme(const QString &scheme);
......@@ -162,6 +176,8 @@ private:
QString mColorScheme;
ElisaUtils::PlayListEntryType mEmbeddedView = ElisaUtils::Unknown;
int mInitialViewIndex = 2;
};
#endif
......@@ -127,8 +127,6 @@ Kirigami.ApplicationWindow {
property bool showPlaylist: true
property bool headerBarIsMaximized: false
property int initialIndex
}
Connections {
......@@ -159,8 +157,6 @@ Kirigami.ApplicationWindow {
persistentSettings.showPlaylist = contentView.showPlaylist
persistentSettings.headerBarIsMaximized = headerBar.isMaximized
persistentSettings.initialIndex = contentView.currentViewIndex
}
}
......@@ -292,7 +288,7 @@ Kirigami.ApplicationWindow {
showPlaylist: persistentSettings.showPlaylist
showExpandedFilterView: persistentSettings.expandedFilterView
playlistDrawer: playlistDrawer
initialIndex: persistentSettings.value('initialIndex', initialViewIndex)
initialIndex: ElisaApplication.initialViewIndex
}
}
}
......
......@@ -103,4 +103,51 @@ ColumnLayout {
embeddedCategoryCombo.isFinished = true
}
}
RowLayout {
spacing: Kirigami.Units.smallSpacing
Label {
text: i18n("Initial view at start:")
}
ComboBox {
id: initialViewCombo
property bool isFinished: false
model: [i18nc("Title of the view of the playlist", "Now Playing"),
i18nc("Title of the view of recently played tracks", "Recently Played"),
i18nc("Title of the view of frequently played tracks", "Frequently Played"),
i18nc("Title of the view of all albums", "Albums"),
i18nc("Title of the view of all artists", "Artists"),
i18nc("Title of the view of all tracks", "Tracks"),
i18nc("Title of the view of all genres", "Genres"),
i18nc("Title of the file browser view", "Files"),
i18nc("Title of the file radios browser view", "Radios"),
]
editable: false
currentIndex: ElisaConfigurationDialog.initialViewIndex
onCurrentIndexChanged: {
if (!isFinished) {
return
}
ElisaConfigurationDialog.initialViewIndex = currentIndex
}
}
Connections {
target: ElisaConfigurationDialog
onInitialViewIndexChanged: initialViewCombo.currentIndex = ElisaConfigurationDialog.initialViewIndex
}
Component.onCompleted: {
initialViewCombo.currentIndex = ElisaConfigurationDialog.initialViewIndex
initialViewCombo.isFinished = true
}
}
}
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