Add custom theme
This commit is contained in:
9 files changed
+636
-31
No files matched your search
@@ -4,10 +4,11 @@ UiState::UiState(AppState &state, QObject *parent)
|
||||
: QObject(parent), m_state(state)
|
||||
{
|
||||
const QVariantMap d = state.loadSection(QStringLiteral("ui"));
|
||||
m_themeName = d.value(QStringLiteral("themeName"), QStringLiteral("dark")).toString();
|
||||
m_lastPage = d.value(QStringLiteral("lastPage"), QStringLiteral("starter")).toString();
|
||||
m_sidebarOpen = d.value(QStringLiteral("sidebarOpen"), false).toBool();
|
||||
m_lastFilePath = d.value(QStringLiteral("lastFilePath"), QString()).toString();
|
||||
m_themeName = d.value(QStringLiteral("themeName"), QStringLiteral("dark")).toString();
|
||||
m_lastPage = d.value(QStringLiteral("lastPage"), QStringLiteral("starter")).toString();
|
||||
m_sidebarOpen = d.value(QStringLiteral("sidebarOpen"), false).toBool();
|
||||
m_lastFilePath = d.value(QStringLiteral("lastFilePath"), QString()).toString();
|
||||
m_customThemeColors = state.loadSection(QStringLiteral("customTheme"));
|
||||
|
||||
const QVariantMap wg = state.loadSection(QStringLiteral("window"));
|
||||
m_width = wg.value(QStringLiteral("width"), 1024).toInt();
|
||||
@@ -16,10 +17,11 @@ UiState::UiState(AppState &state, QObject *parent)
|
||||
m_y = wg.value(QStringLiteral("y"), -1).toInt();
|
||||
}
|
||||
|
||||
QString UiState::themeName() const { return m_themeName; }
|
||||
QString UiState::lastPage() const { return m_lastPage; }
|
||||
bool UiState::sidebarOpen() const { return m_sidebarOpen; }
|
||||
QString UiState::lastFilePath() const { return m_lastFilePath; }
|
||||
QString UiState::themeName() const { return m_themeName; }
|
||||
QString UiState::lastPage() const { return m_lastPage; }
|
||||
bool UiState::sidebarOpen() const { return m_sidebarOpen; }
|
||||
QString UiState::lastFilePath() const { return m_lastFilePath; }
|
||||
QVariantMap UiState::customThemeColors() const { return m_customThemeColors; }
|
||||
int UiState::windowWidth() const { return m_width; }
|
||||
int UiState::windowHeight() const { return m_height; }
|
||||
int UiState::windowX() const { return m_x; }
|
||||
@@ -53,6 +55,13 @@ void UiState::setLastFilePath(const QString &path)
|
||||
emit lastFilePathChanged();
|
||||
}
|
||||
|
||||
void UiState::setCustomThemeColors(const QVariantMap &colors)
|
||||
{
|
||||
if (m_customThemeColors == colors) return;
|
||||
m_customThemeColors = colors;
|
||||
emit customThemeColorsChanged();
|
||||
}
|
||||
|
||||
void UiState::setWindowWidth(int w)
|
||||
{
|
||||
if (m_width == w) return;
|
||||
@@ -90,6 +99,8 @@ void UiState::save()
|
||||
{QStringLiteral("lastFilePath"), m_lastFilePath},
|
||||
});
|
||||
|
||||
m_state.saveSection(QStringLiteral("customTheme"), m_customThemeColors);
|
||||
|
||||
m_state.saveSection(QStringLiteral("window"), {
|
||||
{QStringLiteral("width"), m_width},
|
||||
{QStringLiteral("height"), m_height},
|
||||
|
||||
+17
-11
@@ -3,14 +3,16 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariantMap>
|
||||
#include "backend/AppState.h"
|
||||
|
||||
class UiState : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
|
||||
Q_PROPERTY(QString lastPage READ lastPage WRITE setLastPage NOTIFY lastPageChanged)
|
||||
Q_PROPERTY(bool sidebarOpen READ sidebarOpen WRITE setSidebarOpen NOTIFY sidebarOpenChanged)
|
||||
Q_PROPERTY(QString lastFilePath READ lastFilePath WRITE setLastFilePath NOTIFY lastFilePathChanged)
|
||||
Q_PROPERTY(QString themeName READ themeName WRITE setThemeName NOTIFY themeNameChanged)
|
||||
Q_PROPERTY(QString lastPage READ lastPage WRITE setLastPage NOTIFY lastPageChanged)
|
||||
Q_PROPERTY(bool sidebarOpen READ sidebarOpen WRITE setSidebarOpen NOTIFY sidebarOpenChanged)
|
||||
Q_PROPERTY(QString lastFilePath READ lastFilePath WRITE setLastFilePath NOTIFY lastFilePathChanged)
|
||||
Q_PROPERTY(QVariantMap customThemeColors READ customThemeColors WRITE setCustomThemeColors NOTIFY customThemeColorsChanged)
|
||||
Q_PROPERTY(int windowWidth READ windowWidth WRITE setWindowWidth NOTIFY windowWidthChanged)
|
||||
Q_PROPERTY(int windowHeight READ windowHeight WRITE setWindowHeight NOTIFY windowHeightChanged)
|
||||
Q_PROPERTY(int windowX READ windowX WRITE setWindowX NOTIFY windowXChanged)
|
||||
@@ -18,10 +20,11 @@ class UiState : public QObject {
|
||||
public:
|
||||
explicit UiState(AppState &state, QObject *parent = nullptr);
|
||||
|
||||
QString themeName() const;
|
||||
QString lastPage() const;
|
||||
bool sidebarOpen() const;
|
||||
QString lastFilePath() const;
|
||||
QString themeName() const;
|
||||
QString lastPage() const;
|
||||
bool sidebarOpen() const;
|
||||
QString lastFilePath() const;
|
||||
QVariantMap customThemeColors() const;
|
||||
int windowWidth() const;
|
||||
int windowHeight() const;
|
||||
int windowX() const;
|
||||
@@ -31,6 +34,7 @@ public:
|
||||
void setLastPage(const QString &page);
|
||||
void setSidebarOpen(bool open);
|
||||
void setLastFilePath(const QString &path);
|
||||
void setCustomThemeColors(const QVariantMap &colors);
|
||||
void setWindowWidth(int w);
|
||||
void setWindowHeight(int h);
|
||||
void setWindowX(int x);
|
||||
@@ -43,6 +47,7 @@ signals:
|
||||
void lastPageChanged();
|
||||
void sidebarOpenChanged();
|
||||
void lastFilePathChanged();
|
||||
void customThemeColorsChanged();
|
||||
void windowWidthChanged();
|
||||
void windowHeightChanged();
|
||||
void windowXChanged();
|
||||
@@ -50,10 +55,11 @@ signals:
|
||||
|
||||
private:
|
||||
AppState &m_state;
|
||||
QString m_themeName = QStringLiteral("dark");
|
||||
QString m_lastPage = QStringLiteral("starter");
|
||||
bool m_sidebarOpen = false;
|
||||
QString m_themeName = QStringLiteral("dark");
|
||||
QString m_lastPage = QStringLiteral("starter");
|
||||
bool m_sidebarOpen = false;
|
||||
QString m_lastFilePath;
|
||||
QVariantMap m_customThemeColors;
|
||||
int m_width = 1024;
|
||||
int m_height = 768;
|
||||
int m_x = -1;
|
||||
|
||||
Reference in new issue
Block a user