Commit b4bacfc0 authored by George Florea Bănuș's avatar George Florea Bănuș Committed by Nate Graham

Add setting to change color scheme

parent 54ee976e
Pipeline #37305 passed with stage
in 9 minutes and 40 seconds
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
<choice name="AllGenres" /> <choice name="AllGenres" />
</choices> </choices>
</entry> </entry>
<entry key="ColorScheme" type="String">
</entry>
<entry key="SortRolePreferences" type="StringList"> <entry key="SortRolePreferences" type="StringList">
</entry> </entry>
<entry key="SortOrderPreferences" type="StringList"> <entry key="SortOrderPreferences" type="StringList">
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <KXmlGui/KShortcutsDialog> #include <KXmlGui/KShortcutsDialog>
#endif #endif
#include <KColorSchemeManager>
#include <KCoreAddons/KAboutData> #include <KCoreAddons/KAboutData>
#include <QQmlEngine> #include <QQmlEngine>
...@@ -89,6 +90,7 @@ public: ...@@ -89,6 +90,7 @@ public:
QFileSystemWatcher mConfigFileWatcher; QFileSystemWatcher mConfigFileWatcher;
KColorSchemeManager *mSchemes;
}; };
ElisaApplication::ElisaApplication(QObject *parent) : QObject(parent), d(std::make_unique<ElisaApplicationPrivate>(this)) ElisaApplication::ElisaApplication(QObject *parent) : QObject(parent), d(std::make_unique<ElisaApplicationPrivate>(this))
...@@ -99,6 +101,8 @@ ElisaApplication::ElisaApplication(QObject *parent) : QObject(parent), d(std::ma ...@@ -99,6 +101,8 @@ ElisaApplication::ElisaApplication(QObject *parent) : QObject(parent), d(std::ma
Elisa::ElisaConfiguration::self()->load(); Elisa::ElisaConfiguration::self()->load();
Elisa::ElisaConfiguration::self()->save(); Elisa::ElisaConfiguration::self()->save();
d->mSchemes = new KColorSchemeManager(this);
d->mConfigFileWatcher.addPath(Elisa::ElisaConfiguration::self()->config()->name()); d->mConfigFileWatcher.addPath(Elisa::ElisaConfiguration::self()->config()->name());
connect(Elisa::ElisaConfiguration::self(), &Elisa::ElisaConfiguration::configChanged, connect(Elisa::ElisaConfiguration::self(), &Elisa::ElisaConfiguration::configChanged,
...@@ -114,6 +118,16 @@ ElisaApplication::ElisaApplication(QObject *parent) : QObject(parent), d(std::ma ...@@ -114,6 +118,16 @@ ElisaApplication::ElisaApplication(QObject *parent) : QObject(parent), d(std::ma
ElisaApplication::~ElisaApplication() ElisaApplication::~ElisaApplication()
= default; = default;
QAbstractItemModel *ElisaApplication::colorSchemesModel()
{
return d->mSchemes->model();
}
void ElisaApplication::activateColorScheme(const QString &name)
{
d->mSchemes->activateScheme(d->mSchemes->indexForScheme(name));
}
void ElisaApplication::setupActions(const QString &actionName) void ElisaApplication::setupActions(const QString &actionName)
{ {
#if defined KF5XmlGui_FOUND && KF5XmlGui_FOUND #if defined KF5XmlGui_FOUND && KF5XmlGui_FOUND
......
...@@ -31,6 +31,8 @@ class ManageHeaderBar; ...@@ -31,6 +31,8 @@ class ManageHeaderBar;
class QQmlEngine; class QQmlEngine;
class ElisaApplicationPrivate; class ElisaApplicationPrivate;
class QSessionManager; class QSessionManager;
class KColorSchemeManager;
class QAbstractItemModel;
class ELISALIB_EXPORT ElisaApplication : public QObject class ELISALIB_EXPORT ElisaApplication : public QObject
{ {
...@@ -84,6 +86,10 @@ class ELISALIB_EXPORT ElisaApplication : public QObject ...@@ -84,6 +86,10 @@ class ELISALIB_EXPORT ElisaApplication : public QObject
READ showSystemTrayIcon READ showSystemTrayIcon
NOTIFY showSystemTrayIconChanged) NOTIFY showSystemTrayIconChanged)
Q_PROPERTY(QAbstractItemModel* colorSchemesModel
READ colorSchemesModel
CONSTANT)
public: public:
explicit ElisaApplication(QObject *parent = nullptr); explicit ElisaApplication(QObject *parent = nullptr);
...@@ -173,6 +179,8 @@ public Q_SLOTS: ...@@ -173,6 +179,8 @@ public Q_SLOTS:
void initialize(); void initialize();
void activateColorScheme(const QString &name);
public: public:
void setQmlEngine(QQmlEngine *engine); void setQmlEngine(QQmlEngine *engine);
...@@ -208,6 +216,8 @@ private: ...@@ -208,6 +216,8 @@ private:
DataTypes::EntryDataList checkFileListAndMakeAbsolute(const DataTypes::EntryDataList &filesList, DataTypes::EntryDataList checkFileListAndMakeAbsolute(const DataTypes::EntryDataList &filesList,
const QString &workingDirectory) const; const QString &workingDirectory) const;
QAbstractItemModel *colorSchemesModel();
std::unique_ptr<ElisaApplicationPrivate> d; std::unique_ptr<ElisaApplicationPrivate> d;
}; };
......
...@@ -77,6 +77,7 @@ void ElisaConfigurationDialog::save() ...@@ -77,6 +77,7 @@ void ElisaConfigurationDialog::save()
Elisa::ElisaConfiguration::setShowSystemTrayIcon(mShowSystemTrayIcon); Elisa::ElisaConfiguration::setShowSystemTrayIcon(mShowSystemTrayIcon);
Elisa::ElisaConfiguration::setForceUsageOfFastFileSearch(mForceUsageOfFastFileSearch); Elisa::ElisaConfiguration::setForceUsageOfFastFileSearch(mForceUsageOfFastFileSearch);
Elisa::ElisaConfiguration::setPlayAtStartup(mPlayAtStartup); Elisa::ElisaConfiguration::setPlayAtStartup(mPlayAtStartup);
Elisa::ElisaConfiguration::setColorScheme(mColorScheme);
Elisa::ElisaConfiguration::setEmbeddedView(Elisa::ElisaConfiguration::EnumEmbeddedView::NoView); Elisa::ElisaConfiguration::setEmbeddedView(Elisa::ElisaConfiguration::EnumEmbeddedView::NoView);
switch (mEmbeddedView) switch (mEmbeddedView)
...@@ -167,12 +168,24 @@ void ElisaConfigurationDialog::setPlayAtStartup(bool playAtStartup) ...@@ -167,12 +168,24 @@ void ElisaConfigurationDialog::setPlayAtStartup(bool playAtStartup)
setDirty(); setDirty();
} }
void ElisaConfigurationDialog::setColorScheme(const QString &scheme)
{
if (mColorScheme == scheme) {
return;
}
mColorScheme = scheme;
Q_EMIT colorSchemeChanged();
setDirty();
}
void ElisaConfigurationDialog::configChanged() void ElisaConfigurationDialog::configChanged()
{ {
setRootPath(Elisa::ElisaConfiguration::rootPath()); setRootPath(Elisa::ElisaConfiguration::rootPath());
setShowProgressInTaskBar(Elisa::ElisaConfiguration::showProgressOnTaskBar()); setShowProgressInTaskBar(Elisa::ElisaConfiguration::showProgressOnTaskBar());
setShowSystemTrayIcon(Elisa::ElisaConfiguration::showSystemTrayIcon()); setShowSystemTrayIcon(Elisa::ElisaConfiguration::showSystemTrayIcon());
setPlayAtStartup(Elisa::ElisaConfiguration::playAtStartup()); setPlayAtStartup(Elisa::ElisaConfiguration::playAtStartup());
setColorScheme(Elisa::ElisaConfiguration::colorScheme());
switch (Elisa::ElisaConfiguration::embeddedView()) switch (Elisa::ElisaConfiguration::embeddedView())
{ {
......
...@@ -53,6 +53,11 @@ class ELISALIB_EXPORT ElisaConfigurationDialog : public QObject ...@@ -53,6 +53,11 @@ class ELISALIB_EXPORT ElisaConfigurationDialog : public QObject
WRITE setPlayAtStartup WRITE setPlayAtStartup
NOTIFY playAtStartupChanged) NOTIFY playAtStartupChanged)
Q_PROPERTY(QString colorScheme
READ colorScheme
WRITE setColorScheme
NOTIFY colorSchemeChanged)
public: public:
explicit ElisaConfigurationDialog(QObject *parent = nullptr); explicit ElisaConfigurationDialog(QObject *parent = nullptr);
...@@ -91,6 +96,11 @@ public: ...@@ -91,6 +96,11 @@ public:
return mPlayAtStartup; return mPlayAtStartup;
} }
QString colorScheme() const
{
return mColorScheme;
}
Q_SIGNALS: Q_SIGNALS:
void rootPathChanged(const QStringList &rootPath); void rootPathChanged(const QStringList &rootPath);
...@@ -107,6 +117,8 @@ Q_SIGNALS: ...@@ -107,6 +117,8 @@ Q_SIGNALS:
void playAtStartupChanged(); void playAtStartupChanged();
void colorSchemeChanged();
public Q_SLOTS: public Q_SLOTS:
void setRootPath(const QStringList &rootPath); void setRootPath(const QStringList &rootPath);
...@@ -123,6 +135,8 @@ public Q_SLOTS: ...@@ -123,6 +135,8 @@ public Q_SLOTS:
void setPlayAtStartup(bool playAtStartup); void setPlayAtStartup(bool playAtStartup);
void setColorScheme(const QString &scheme);
private Q_SLOTS: private Q_SLOTS:
void configChanged(); void configChanged();
...@@ -145,6 +159,8 @@ private: ...@@ -145,6 +159,8 @@ private:
bool mPlayAtStartup = false; bool mPlayAtStartup = false;
QString mColorScheme;
ElisaUtils::PlayListEntryType mEmbeddedView = ElisaUtils::Unknown; ElisaUtils::PlayListEntryType mEmbeddedView = ElisaUtils::Unknown;
}; };
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import org.kde.elisa 1.0 import org.kde.elisa 1.0
import org.kde.kirigami 2.5 as Kirigami
Menu { Menu {
id: applicationMenu id: applicationMenu
...@@ -29,6 +30,24 @@ Menu { ...@@ -29,6 +30,24 @@ Menu {
} }
} }
Menu {
title: i18n("Color Scheme")
Repeater {
model: ElisaApplication.colorSchemesModel
delegate: Kirigami.BasicListItem {
icon: model.decoration
text: model.display
highlighted: model.display === ElisaConfigurationDialog.colorScheme
onClicked: {
ElisaApplication.activateColorScheme(model.display)
ElisaConfigurationDialog.setColorScheme(model.display)
ElisaConfigurationDialog.save()
applicationMenu.close()
}
}
}
}
MenuSeparator { MenuSeparator {
} }
......
...@@ -32,7 +32,7 @@ Kirigami.ApplicationWindow { ...@@ -32,7 +32,7 @@ Kirigami.ApplicationWindow {
onPausePlayback: ElisaApplication.audioControl.playPause() onPausePlayback: ElisaApplication.audioControl.playPause()
} }
} }
minimumWidth: 590 minimumWidth: 590
property int minHeight: 320 property int minHeight: 320
...@@ -345,6 +345,7 @@ Kirigami.ApplicationWindow { ...@@ -345,6 +345,7 @@ Kirigami.ApplicationWindow {
Component.onCompleted: Component.onCompleted:
{ {
ElisaApplication.initialize() ElisaApplication.initialize()
ElisaApplication.activateColorScheme(ElisaConfigurationDialog.colorScheme)
if (persistentSettings.playListState) { if (persistentSettings.playListState) {
ElisaApplication.mediaPlayListProxyModel.persistentState = persistentSettings.playListState ElisaApplication.mediaPlayListProxyModel.persistentState = persistentSettings.playListState
......
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