From 96b7838a4b424bd54147e413c29b41f36a61ad8b Mon Sep 17 00:00:00 2001 From: Agel Date: Tue, 14 Apr 2026 20:52:07 +0200 Subject: [PATCH] Add custom theme --- .gitignore | 3 +- CMakeLists.txt | 2 + src/backend/state/UiState.cpp | 27 +- src/backend/state/UiState.h | 28 +- src/qml/Main.qml | 8 +- src/qml/ThemeManager.qml | 107 ++++++- src/qml/components/SideBar.qml | 11 + src/qml/components/SideBarButton.qml | 42 ++- src/qml/pages/CustomThemePage.qml | 439 +++++++++++++++++++++++++++ 9 files changed, 636 insertions(+), 31 deletions(-) create mode 100644 src/qml/pages/CustomThemePage.qml diff --git a/.gitignore b/.gitignore index 5ac02ae..7fceccc 100644 --- a/.gitignore +++ b/.gitignore @@ -38,4 +38,5 @@ ci-output/ Thumbs.db /aqtinstall.log -.claude/worktrees/ \ No newline at end of file +.claude/worktrees/ +.junie \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 144bcbf..0b527a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,6 +158,7 @@ set_source_files_properties(src/qml/pages/StarterPage.qml PROPERTIES QT_RESOURCE set_source_files_properties(src/qml/pages/ReaderPage.qml PROPERTIES QT_RESOURCE_ALIAS pages/ReaderPage.qml) set_source_files_properties(src/qml/pages/SettingsPage.qml PROPERTIES QT_RESOURCE_ALIAS pages/SettingsPage.qml) set_source_files_properties(src/qml/pages/HistoryPage.qml PROPERTIES QT_RESOURCE_ALIAS pages/HistoryPage.qml) +set_source_files_properties(src/qml/pages/CustomThemePage.qml PROPERTIES QT_RESOURCE_ALIAS pages/CustomThemePage.qml) # QML module qt_policy(SET QTP0004 NEW) @@ -180,6 +181,7 @@ qt_add_qml_module(asteria-qt src/qml/pages/ReaderPage.qml src/qml/pages/SettingsPage.qml src/qml/pages/HistoryPage.qml + src/qml/pages/CustomThemePage.qml RESOURCES src/assets/moon1.svg src/assets/MaterialIconsOutlined-Regular.otf diff --git a/src/backend/state/UiState.cpp b/src/backend/state/UiState.cpp index fa1426b..62e2159 100644 --- a/src/backend/state/UiState.cpp +++ b/src/backend/state/UiState.cpp @@ -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}, diff --git a/src/backend/state/UiState.h b/src/backend/state/UiState.h index 8c0f692..0838c31 100644 --- a/src/backend/state/UiState.h +++ b/src/backend/state/UiState.h @@ -3,14 +3,16 @@ #include #include +#include #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; diff --git a/src/qml/Main.qml b/src/qml/Main.qml index ec622c1..81d2bff 100644 --- a/src/qml/Main.qml +++ b/src/qml/Main.qml @@ -34,10 +34,9 @@ ApplicationWindow { x = uiState.windowX y = uiState.windowY } + ThemeManager.loadCustomColors(uiState.customThemeColors) if (uiState.themeName !== "") ThemeManager.currentThemeName = uiState.themeName - - } Connections { @@ -139,6 +138,11 @@ ApplicationWindow { visible: window.currentPage === "history" } + CustomThemePage { + anchors.fill: parent + visible: window.currentPage === "customTheme" + } + BusyIndicator { anchors.centerIn: parent running: window._bookInitializing diff --git a/src/qml/ThemeManager.qml b/src/qml/ThemeManager.qml index bbf3123..afa7581 100644 --- a/src/qml/ThemeManager.qml +++ b/src/qml/ThemeManager.qml @@ -9,9 +9,36 @@ QtObject { readonly property int animDurationClose: 195 property string currentThemeName: "dark" - - readonly property var currentTheme: currentThemeName === "dark" ? DarkTheme : LightTheme - + + property QtObject customTheme: QtObject { + property color backgroundDeepest: "#010620" + property color backgroundDefault: "#191d35" + property color surface: "#191d35" + property color headerBg: "#14172c" + property color footerBg: "#1a1e36" + property color scrollbarTrack: "#131628" + property color scrollbarThumb: "#36486a" + property color primaryAccent: "#3a5688" + property color buttonAccent: "#5785c1" + property color sidebarButtonText: "#98aaf4" + property color readingText: "#c4c8d8" + property color uiText: "#a2a5b4" + property color headerText: "#8488aa" + property color dimText: "#71738c" + property color counterText: "#606175" + property color gradientTop: "#0e1125" + property color gradientBottom: "#191d35" + property color divider: "#1f2040" + property color overlayBg: "#0e0f11" + property color actionDisabled: "#141724" + } + + property var _lastApplied: ({}) + + readonly property var currentTheme: currentThemeName === "dark" ? DarkTheme + : currentThemeName === "light" ? LightTheme + : customTheme + function setDarkTheme() { currentThemeName = "dark" uiState.themeName = "dark" @@ -22,8 +49,74 @@ QtObject { uiState.themeName = "light" } - function toggleTheme() { - currentThemeName = currentThemeName === "dark" ? "light" : "dark" - uiState.themeName = currentThemeName + function setCustomTheme() { + currentThemeName = "custom" + uiState.themeName = "custom" } -} \ No newline at end of file + + function loadCustomColors(map) { + if (map && Object.keys(map).length > 0) + _restoreColors(map) + // Snapshot current state (loaded or defaults) so Revert always has a target + _lastApplied = _captureColors() + } + + function applyCustomColors() { + var c = _captureColors() + _lastApplied = c + uiState.customThemeColors = c + } + + function revertCustomColors() { + _restoreColors(_lastApplied) + } + + function _captureColors() { + return { + backgroundDeepest: customTheme.backgroundDeepest.toString(), + backgroundDefault: customTheme.backgroundDefault.toString(), + surface: customTheme.surface.toString(), + headerBg: customTheme.headerBg.toString(), + footerBg: customTheme.footerBg.toString(), + scrollbarTrack: customTheme.scrollbarTrack.toString(), + scrollbarThumb: customTheme.scrollbarThumb.toString(), + primaryAccent: customTheme.primaryAccent.toString(), + buttonAccent: customTheme.buttonAccent.toString(), + sidebarButtonText: customTheme.sidebarButtonText.toString(), + readingText: customTheme.readingText.toString(), + uiText: customTheme.uiText.toString(), + headerText: customTheme.headerText.toString(), + dimText: customTheme.dimText.toString(), + counterText: customTheme.counterText.toString(), + gradientTop: customTheme.gradientTop.toString(), + gradientBottom: customTheme.gradientBottom.toString(), + divider: customTheme.divider.toString(), + overlayBg: customTheme.overlayBg.toString(), + actionDisabled: customTheme.actionDisabled.toString() + } + } + + function _restoreColors(c) { + if (!c) return + if (c.backgroundDeepest) customTheme.backgroundDeepest = c.backgroundDeepest + if (c.backgroundDefault) customTheme.backgroundDefault = c.backgroundDefault + if (c.surface) customTheme.surface = c.surface + if (c.headerBg) customTheme.headerBg = c.headerBg + if (c.footerBg) customTheme.footerBg = c.footerBg + if (c.scrollbarTrack) customTheme.scrollbarTrack = c.scrollbarTrack + if (c.scrollbarThumb) customTheme.scrollbarThumb = c.scrollbarThumb + if (c.primaryAccent) customTheme.primaryAccent = c.primaryAccent + if (c.buttonAccent) customTheme.buttonAccent = c.buttonAccent + if (c.sidebarButtonText) customTheme.sidebarButtonText = c.sidebarButtonText + if (c.readingText) customTheme.readingText = c.readingText + if (c.uiText) customTheme.uiText = c.uiText + if (c.headerText) customTheme.headerText = c.headerText + if (c.dimText) customTheme.dimText = c.dimText + if (c.counterText) customTheme.counterText = c.counterText + if (c.gradientTop) customTheme.gradientTop = c.gradientTop + if (c.gradientBottom) customTheme.gradientBottom = c.gradientBottom + if (c.divider) customTheme.divider = c.divider + if (c.overlayBg) customTheme.overlayBg = c.overlayBg + if (c.actionDisabled) customTheme.actionDisabled = c.actionDisabled + } +} diff --git a/src/qml/components/SideBar.qml b/src/qml/components/SideBar.qml index d01b580..f52951a 100644 --- a/src/qml/components/SideBar.qml +++ b/src/qml/components/SideBar.qml @@ -98,6 +98,17 @@ Rectangle { onClicked: ThemeManager.setLightTheme() } + SideBarButton { + iconText: "\ue40a" + title: "Custom Theme" + rightIconText: "\ue3c9" + onClicked: ThemeManager.setCustomTheme() + onRightIconClicked: { + ThemeManager.setCustomTheme() + sidebar.navigateTo("customTheme") + } + } + // Divider Rectangle { width: parent.width diff --git a/src/qml/components/SideBarButton.qml b/src/qml/components/SideBarButton.qml index b702045..a3ba68a 100644 --- a/src/qml/components/SideBarButton.qml +++ b/src/qml/components/SideBarButton.qml @@ -10,11 +10,16 @@ Rectangle { property string iconText: "" property string title: "" + property string rightIconText: "" + signal clicked() + signal rightIconClicked() Row { - anchors.fill: parent + anchors.left: parent.left anchors.leftMargin: 16 + anchors.top: parent.top + anchors.bottom: parent.bottom spacing: 16 Text { @@ -33,9 +38,42 @@ Rectangle { } } + // Optional right icon zone — zero-width when unused + Rectangle { + id: rightIconZone + visible: root.rightIconText !== "" + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + width: visible ? 44 : 0 + color: "transparent" + + Text { + anchors.centerIn: parent + text: root.rightIconText + font.family: "Material Icons Outlined" + font.pixelSize: 18 + color: rightIconArea.containsMouse + ? Qt.lighter(ThemeManager.currentTheme.sidebarButtonText, 1.3) + : ThemeManager.currentTheme.sidebarButtonText + } + + MouseArea { + id: rightIconArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: root.rightIconClicked() + } + } + + // Main click area stops before the right icon zone MouseArea { id: mouseArea - anchors.fill: parent + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + width: parent.width - rightIconZone.width hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: root.clicked() diff --git a/src/qml/pages/CustomThemePage.qml b/src/qml/pages/CustomThemePage.qml new file mode 100644 index 0000000..cfe4834 --- /dev/null +++ b/src/qml/pages/CustomThemePage.qml @@ -0,0 +1,439 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import Asteria + +Rectangle { + gradient: Gradient { + GradientStop { position: 0.0; color: ThemeManager.currentTheme.gradientTop } + GradientStop { position: 1.0; color: ThemeManager.currentTheme.gradientBottom } + } + + // Apply on navigate away + onVisibleChanged: { + if (!visible && ThemeManager.currentThemeName === "custom") + ThemeManager.applyCustomColors() + } + + // ── Fixed top panel ────────────────────────────────────────────────────── + + Column { + id: topPanel + anchors.top: parent.top + anchors.topMargin: 8 + anchors.left: parent.left + anchors.leftMargin: 8 + anchors.right: parent.right + anchors.rightMargin: 8 + spacing: 12 + + Text { + text: "Custom Theme" + font.pixelSize: 13 + font.weight: Font.Medium + color: ThemeManager.currentTheme.dimText + leftPadding: 4 + } + + // Lorem Ipsum preview + Rectangle { + width: parent.width + height: previewColumn.implicitHeight + 24 + color: ThemeManager.currentTheme.surface + radius: 6 + border.color: ThemeManager.currentTheme.divider + border.width: 1 + + Column { + id: previewColumn + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + anchors.margins: 16 + spacing: 8 + + Text { + width: parent.width + text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." + font.pixelSize: 15 + color: ThemeManager.currentTheme.readingText + wrapMode: Text.WordWrap + } + + Text { + text: "UI element text \u2022 Header text" + font.pixelSize: 13 + color: ThemeManager.currentTheme.uiText + } + + Text { + text: "Dim / secondary text \u2022 Counter text" + font.pixelSize: 12 + color: ThemeManager.currentTheme.dimText + } + + Row { + spacing: 8 + + Rectangle { + width: accentLabel.implicitWidth + 16 + height: accentLabel.implicitHeight + 8 + color: ThemeManager.currentTheme.primaryAccent + radius: 3 + + Text { + id: accentLabel + anchors.centerIn: parent + text: "Primary accent" + font.pixelSize: 12 + color: ThemeManager.currentTheme.readingText + } + } + + Rectangle { + width: buttonLabel.implicitWidth + 16 + height: buttonLabel.implicitHeight + 8 + color: ThemeManager.currentTheme.buttonAccent + radius: 3 + + Text { + id: buttonLabel + anchors.centerIn: parent + text: "Button accent" + font.pixelSize: 12 + color: ThemeManager.currentTheme.readingText + } + } + } + } + } + + // Divider between fixed panel and scrollable area + Rectangle { + width: parent.width + height: 1 + color: ThemeManager.currentTheme.divider + } + } + + // ── Fixed bottom bar ───────────────────────────────────────────────────── + + Rectangle { + id: bottomBar + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + height: 56 + color: ThemeManager.currentTheme.surface + + Rectangle { + width: parent.width + height: 1 + color: ThemeManager.currentTheme.divider + } + + Row { + anchors.centerIn: parent + spacing: 12 + + Rectangle { + width: revertText.implicitWidth + 32 + height: 36 + color: revertArea.containsMouse + ? Qt.lighter(ThemeManager.currentTheme.surface, 1.2) + : ThemeManager.currentTheme.surface + radius: 4 + border.color: ThemeManager.currentTheme.divider + border.width: 1 + + Text { + id: revertText + anchors.centerIn: parent + text: "Revert" + font.pixelSize: 14 + color: ThemeManager.currentTheme.uiText + } + + MouseArea { + id: revertArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: ThemeManager.revertCustomColors() + } + } + + Rectangle { + width: applyText.implicitWidth + 32 + height: 36 + color: applyArea.containsMouse + ? Qt.lighter(ThemeManager.currentTheme.primaryAccent, 1.2) + : ThemeManager.currentTheme.primaryAccent + radius: 4 + + Text { + id: applyText + anchors.centerIn: parent + text: "Apply" + font.pixelSize: 14 + color: ThemeManager.currentTheme.readingText + } + + MouseArea { + id: applyArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + onClicked: ThemeManager.applyCustomColors() + } + } + } + } + + // ── Scrollable color picker rows ───────────────────────────────────────── + // Full width so the scrollbar sits at the screen edge, outside the 8px margin + + ScrollView { + anchors.top: topPanel.bottom + anchors.topMargin: 4 + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: bottomBar.top + contentWidth: availableWidth + + Column { + width: parent.width + leftPadding: 8 + rightPadding: 8 + bottomPadding: 16 + spacing: 0 + + // ── Background ───────────────────────────────────────────────── + + SectionLabel { text: "Background" } + + ColorRow { + width: parent.width - 16 + label: "Deepest background" + value: ThemeManager.customTheme.backgroundDeepest + apply: function(c) { ThemeManager.customTheme.backgroundDeepest = c } + } + + ColorRow { + width: parent.width - 16 + label: "Default background" + value: ThemeManager.customTheme.backgroundDefault + apply: function(c) { ThemeManager.customTheme.backgroundDefault = c } + } + + ColorRow { + width: parent.width - 16 + label: "Gradient top" + value: ThemeManager.customTheme.gradientTop + apply: function(c) { ThemeManager.customTheme.gradientTop = c } + } + + ColorRow { + width: parent.width - 16 + label: "Gradient bottom" + value: ThemeManager.customTheme.gradientBottom + apply: function(c) { ThemeManager.customTheme.gradientBottom = c } + } + + // ── Surfaces ─────────────────────────────────────────────────── + + SectionLabel { text: "Surfaces" } + + ColorRow { + width: parent.width - 16 + label: "Surface" + value: ThemeManager.customTheme.surface + apply: function(c) { ThemeManager.customTheme.surface = c } + } + + ColorRow { + width: parent.width - 16 + label: "Header background" + value: ThemeManager.customTheme.headerBg + apply: function(c) { ThemeManager.customTheme.headerBg = c } + } + + ColorRow { + width: parent.width - 16 + label: "Footer background" + value: ThemeManager.customTheme.footerBg + apply: function(c) { ThemeManager.customTheme.footerBg = c } + } + + ColorRow { + width: parent.width - 16 + label: "Overlay background" + value: ThemeManager.customTheme.overlayBg + apply: function(c) { ThemeManager.customTheme.overlayBg = c } + } + + ColorRow { + width: parent.width - 16 + label: "Scrollbar track" + value: ThemeManager.customTheme.scrollbarTrack + apply: function(c) { ThemeManager.customTheme.scrollbarTrack = c } + } + + ColorRow { + width: parent.width - 16 + label: "Scrollbar thumb" + value: ThemeManager.customTheme.scrollbarThumb + apply: function(c) { ThemeManager.customTheme.scrollbarThumb = c } + } + + ColorRow { + width: parent.width - 16 + label: "Divider" + value: ThemeManager.customTheme.divider + apply: function(c) { ThemeManager.customTheme.divider = c } + } + + // ── Text ─────────────────────────────────────────────────────── + + SectionLabel { text: "Text" } + + ColorRow { + width: parent.width - 16 + label: "Reading text" + value: ThemeManager.customTheme.readingText + apply: function(c) { ThemeManager.customTheme.readingText = c } + } + + ColorRow { + width: parent.width - 16 + label: "UI text" + value: ThemeManager.customTheme.uiText + apply: function(c) { ThemeManager.customTheme.uiText = c } + } + + ColorRow { + width: parent.width - 16 + label: "Header text" + value: ThemeManager.customTheme.headerText + apply: function(c) { ThemeManager.customTheme.headerText = c } + } + + ColorRow { + width: parent.width - 16 + label: "Dim text" + value: ThemeManager.customTheme.dimText + apply: function(c) { ThemeManager.customTheme.dimText = c } + } + + ColorRow { + width: parent.width - 16 + label: "Counter text" + value: ThemeManager.customTheme.counterText + apply: function(c) { ThemeManager.customTheme.counterText = c } + } + + ColorRow { + width: parent.width - 16 + label: "Sidebar button text" + value: ThemeManager.customTheme.sidebarButtonText + apply: function(c) { ThemeManager.customTheme.sidebarButtonText = c } + } + + // ── Accents ──────────────────────────────────────────────────── + + SectionLabel { text: "Accents" } + + ColorRow { + width: parent.width - 16 + label: "Primary accent" + value: ThemeManager.customTheme.primaryAccent + apply: function(c) { ThemeManager.customTheme.primaryAccent = c } + } + + ColorRow { + width: parent.width - 16 + label: "Button accent" + value: ThemeManager.customTheme.buttonAccent + apply: function(c) { ThemeManager.customTheme.buttonAccent = c } + } + + ColorRow { + width: parent.width - 16 + label: "Action disabled" + value: ThemeManager.customTheme.actionDisabled + apply: function(c) { ThemeManager.customTheme.actionDisabled = c } + } + } + } + + // ── Inline components ──────────────────────────────────────────────────── + + component SectionLabel: Text { + topPadding: 16 + bottomPadding: 4 + leftPadding: 4 + font.pixelSize: 13 + font.weight: Font.Medium + color: ThemeManager.currentTheme.dimText + } + + component ColorRow: Item { + id: colorRowRoot + height: 40 + property string label: "" + property color value: "black" + property var apply: null // (color) => void + property color _savedValue: "black" + + ColorDialog { + id: dlg + onSelectedColorChanged: { if (colorRowRoot.apply) colorRowRoot.apply(selectedColor) } + onRejected: { if (colorRowRoot.apply) colorRowRoot.apply(colorRowRoot._savedValue) } + } + + function openPicker() { + _savedValue = value + dlg.selectedColor = value + dlg.open() + } + + Text { + anchors.left: colorRowRoot.left + anchors.leftMargin: 4 + anchors.verticalCenter: colorRowRoot.verticalCenter + text: colorRowRoot.label + font.pixelSize: 14 + color: ThemeManager.currentTheme.uiText + } + + Row { + anchors.right: colorRowRoot.right + anchors.verticalCenter: colorRowRoot.verticalCenter + spacing: 8 + + Rectangle { + width: 32 + height: 22 + color: colorRowRoot.value + radius: 3 + border.color: ThemeManager.currentTheme.divider + border.width: 1 + + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + onClicked: colorRowRoot.openPicker() + } + } + + Text { + text: colorRowRoot.value.toString().toUpperCase() + font.pixelSize: 11 + font.family: "Courier New" + color: ThemeManager.currentTheme.dimText + anchors.verticalCenter: parent.verticalCenter + width: 90 + } + } + } +}