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

Add setting to change color scheme

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