Commit 7e419868 authored by Matthieu Gallien's avatar Matthieu Gallien

add management of embedded view in configure dialog

parent adfd2e03
......@@ -13,6 +13,7 @@
#include <QStandardPaths>
#include <QFileInfo>
#include <QTimer>
ElisaConfigurationDialog::ElisaConfigurationDialog(QObject* parent)
: QObject(parent)
......@@ -22,11 +23,7 @@ ElisaConfigurationDialog::ElisaConfigurationDialog(QObject* parent)
connect(&mConfigFileWatcher, &QFileSystemWatcher::fileChanged,
this, &ElisaConfigurationDialog::configChanged);
setRootPath(Elisa::ElisaConfiguration::rootPath());
setShowProgressInTaskBar(Elisa::ElisaConfiguration::showProgressOnTaskBar());
setShowSystemTrayIcon(Elisa::ElisaConfiguration::showSystemTrayIcon());
setForceUsageOfFastFileSearch(Elisa::ElisaConfiguration::forceUsageOfFastFileSearch());
configChanged();
save();
mConfigFileWatcher.addPath(Elisa::ElisaConfiguration::self()->config()->name());
......@@ -79,6 +76,31 @@ void ElisaConfigurationDialog::save()
Elisa::ElisaConfiguration::setShowProgressOnTaskBar(mShowProgressInTaskBar);
Elisa::ElisaConfiguration::setShowSystemTrayIcon(mShowSystemTrayIcon);
Elisa::ElisaConfiguration::setForceUsageOfFastFileSearch(mForceUsageOfFastFileSearch);
Elisa::ElisaConfiguration::setEmbeddedView(0);
switch (mEmbeddedView)
{
case ElisaUtils::Unknown:
Elisa::ElisaConfiguration::setEmbeddedView(0);
break;
case ElisaUtils::Album:
Elisa::ElisaConfiguration::setEmbeddedView(1);
break;
case ElisaUtils::Artist:
Elisa::ElisaConfiguration::setEmbeddedView(2);
break;
case ElisaUtils::Genre:
Elisa::ElisaConfiguration::setEmbeddedView(3);
break;
case ElisaUtils::Radio:
case ElisaUtils::Track:
case ElisaUtils::Composer:
case ElisaUtils::FileName:
case ElisaUtils::Lyricist:
case ElisaUtils::Container:
break;
}
Elisa::ElisaConfiguration::self()->save();
mIsDirty = false;
......@@ -121,9 +143,38 @@ void ElisaConfigurationDialog::setForceUsageOfFastFileSearch(bool forceUsageOfFa
setDirty();
}
void ElisaConfigurationDialog::setEmbeddedView(ElisaUtils::PlayListEntryType embeddedView)
{
if (mEmbeddedView == embeddedView) {
return;
}
mEmbeddedView = embeddedView;
QTimer::singleShot(0, [this](){ Q_EMIT embeddedViewChanged(); });
setDirty();
}
void ElisaConfigurationDialog::configChanged()
{
setRootPath(Elisa::ElisaConfiguration::rootPath());
setShowProgressInTaskBar(Elisa::ElisaConfiguration::showProgressOnTaskBar());
setShowSystemTrayIcon(Elisa::ElisaConfiguration::showSystemTrayIcon());
switch (Elisa::ElisaConfiguration::embeddedView())
{
case 0:
setEmbeddedView(ElisaUtils::Unknown);
break;
case 1:
setEmbeddedView(ElisaUtils::Album);
break;
case 2:
setEmbeddedView(ElisaUtils::Artist);
break;
case 3:
setEmbeddedView(ElisaUtils::Genre);
break;
}
}
void ElisaConfigurationDialog::setDirty()
......
......@@ -9,6 +9,8 @@
#include "elisaLib_export.h"
#include "elisautils.h"
#include <QStringList>
#include <QFileSystemWatcher>
......@@ -37,6 +39,11 @@ class ELISALIB_EXPORT ElisaConfigurationDialog : public QObject
WRITE setShowSystemTrayIcon
NOTIFY showSystemTrayIconChanged)
Q_PROPERTY(ElisaUtils::PlayListEntryType embeddedView
READ embeddedView
WRITE setEmbeddedView
NOTIFY embeddedViewChanged)
Q_PROPERTY(bool isDirty
READ isDirty
NOTIFY isDirtyChanged)
......@@ -69,6 +76,11 @@ public:
return mForceUsageOfFastFileSearch;
}
ElisaUtils::PlayListEntryType embeddedView() const
{
return mEmbeddedView;
}
Q_SIGNALS:
void rootPathChanged(const QStringList &rootPath);
......@@ -81,6 +93,8 @@ Q_SIGNALS:
void forceUsageOfFastFileSearchChanged();
void embeddedViewChanged();
public Q_SLOTS:
void setRootPath(const QStringList &rootPath);
......@@ -93,6 +107,8 @@ public Q_SLOTS:
void setForceUsageOfFastFileSearch(bool forceUsageOfFastFileSearch);
void setEmbeddedView(ElisaUtils::PlayListEntryType embeddedView);
private Q_SLOTS:
void configChanged();
......@@ -112,6 +128,8 @@ private:
bool mShowSystemTrayIcon = false;
bool mForceUsageOfFastFileSearch = true;
ElisaUtils::PlayListEntryType mEmbeddedView = ElisaUtils::Unknown;
};
#endif
......@@ -7,11 +7,14 @@
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Layouts 1.3
import org.kde.kirigami 2.8 as Kirigami
import org.kde.elisa 1.0
import org.kde.elisa 1.0
ColumnLayout {
spacing: 0
spacing: Kirigami.Units.smallSpacing
SystemPalette {
id: myPalette
......@@ -33,4 +36,65 @@ ColumnLayout {
onToggled: ElisaConfigurationDialog.showSystemTrayIcon = checked
}
RowLayout {
spacing: Kirigami.Units.smallSpacing
Label {
text: i18n("Embed a category in the views navigation list:")
}
ComboBox {
id: embeddedCategoryCombo
property bool isFinished: false
model: [i18nc("Configure dialog, embed no category in views navigation list", "No embedded data"),
i18nc("Configure dialog, embed all albums in views navigation list", "Embed Albums"),
i18nc("Configure dialog, embed all artists in views navigation list", "Embed Artists"),
i18nc("Configure dialog, embed all genres in views navigation list", "Embed Genres")]
editable: false
currentIndex: (config.embeddedView === ElisaUtils.Genre ? 3 : (config.embeddedView === ElisaUtils.Album ? 1 : (config.embeddedView === ElisaUtils.Artist ? 2 : 0)))
onCurrentIndexChanged: {
if (!isFinished) {
return
}
config.embeddedView = (currentIndex === 0 ? ElisaUtils.Unknown : (currentIndex === 1 ? ElisaUtils.Album : (currentIndex === 2 ? ElisaUtils.Artist : ElisaUtils.Genre)))
}
}
Connections {
target: config
onEmbeddedViewChanged:
{
if (config.embeddedView == ElisaUtils.Unknown) {
embeddedCategoryCombo.currentIndex = 0
} else if (config.embeddedView == ElisaUtils.Album) {
embeddedCategoryCombo.currentIndex = 1
} else if (config.embeddedView == ElisaUtils.Artist) {
embeddedCategoryCombo.currentIndex = 2
} else if (config.embeddedView == ElisaUtils.Genre) {
embeddedCategoryCombo.currentIndex = 3
}
}
}
Component.onCompleted: {
if (config.embeddedView == ElisaUtils.Unknown) {
embeddedCategoryCombo.currentIndex = 0
} else if (config.embeddedView == ElisaUtils.Album) {
embeddedCategoryCombo.currentIndex = 1
} else if (config.embeddedView == ElisaUtils.Artist) {
embeddedCategoryCombo.currentIndex = 2
} else if (config.embeddedView == ElisaUtils.Genre) {
embeddedCategoryCombo.currentIndex = 3
}
embeddedCategoryCombo.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