Add custom theme
This commit is contained in:
9 files changed
+613
-8
No files matched your search
@@ -39,3 +39,4 @@ Thumbs.db
|
|||||||
/aqtinstall.log
|
/aqtinstall.log
|
||||||
|
|
||||||
.claude/worktrees/
|
.claude/worktrees/
|
||||||
|
.junie
|
||||||
@@ -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/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/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/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
|
# QML module
|
||||||
qt_policy(SET QTP0004 NEW)
|
qt_policy(SET QTP0004 NEW)
|
||||||
@@ -180,6 +181,7 @@ qt_add_qml_module(asteria-qt
|
|||||||
src/qml/pages/ReaderPage.qml
|
src/qml/pages/ReaderPage.qml
|
||||||
src/qml/pages/SettingsPage.qml
|
src/qml/pages/SettingsPage.qml
|
||||||
src/qml/pages/HistoryPage.qml
|
src/qml/pages/HistoryPage.qml
|
||||||
|
src/qml/pages/CustomThemePage.qml
|
||||||
RESOURCES
|
RESOURCES
|
||||||
src/assets/moon1.svg
|
src/assets/moon1.svg
|
||||||
src/assets/MaterialIconsOutlined-Regular.otf
|
src/assets/MaterialIconsOutlined-Regular.otf
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ UiState::UiState(AppState &state, QObject *parent)
|
|||||||
m_lastPage = d.value(QStringLiteral("lastPage"), QStringLiteral("starter")).toString();
|
m_lastPage = d.value(QStringLiteral("lastPage"), QStringLiteral("starter")).toString();
|
||||||
m_sidebarOpen = d.value(QStringLiteral("sidebarOpen"), false).toBool();
|
m_sidebarOpen = d.value(QStringLiteral("sidebarOpen"), false).toBool();
|
||||||
m_lastFilePath = d.value(QStringLiteral("lastFilePath"), QString()).toString();
|
m_lastFilePath = d.value(QStringLiteral("lastFilePath"), QString()).toString();
|
||||||
|
m_customThemeColors = state.loadSection(QStringLiteral("customTheme"));
|
||||||
|
|
||||||
const QVariantMap wg = state.loadSection(QStringLiteral("window"));
|
const QVariantMap wg = state.loadSection(QStringLiteral("window"));
|
||||||
m_width = wg.value(QStringLiteral("width"), 1024).toInt();
|
m_width = wg.value(QStringLiteral("width"), 1024).toInt();
|
||||||
@@ -20,6 +21,7 @@ QString UiState::themeName() const { return m_themeName; }
|
|||||||
QString UiState::lastPage() const { return m_lastPage; }
|
QString UiState::lastPage() const { return m_lastPage; }
|
||||||
bool UiState::sidebarOpen() const { return m_sidebarOpen; }
|
bool UiState::sidebarOpen() const { return m_sidebarOpen; }
|
||||||
QString UiState::lastFilePath() const { return m_lastFilePath; }
|
QString UiState::lastFilePath() const { return m_lastFilePath; }
|
||||||
|
QVariantMap UiState::customThemeColors() const { return m_customThemeColors; }
|
||||||
int UiState::windowWidth() const { return m_width; }
|
int UiState::windowWidth() const { return m_width; }
|
||||||
int UiState::windowHeight() const { return m_height; }
|
int UiState::windowHeight() const { return m_height; }
|
||||||
int UiState::windowX() const { return m_x; }
|
int UiState::windowX() const { return m_x; }
|
||||||
@@ -53,6 +55,13 @@ void UiState::setLastFilePath(const QString &path)
|
|||||||
emit lastFilePathChanged();
|
emit lastFilePathChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UiState::setCustomThemeColors(const QVariantMap &colors)
|
||||||
|
{
|
||||||
|
if (m_customThemeColors == colors) return;
|
||||||
|
m_customThemeColors = colors;
|
||||||
|
emit customThemeColorsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void UiState::setWindowWidth(int w)
|
void UiState::setWindowWidth(int w)
|
||||||
{
|
{
|
||||||
if (m_width == w) return;
|
if (m_width == w) return;
|
||||||
@@ -90,6 +99,8 @@ void UiState::save()
|
|||||||
{QStringLiteral("lastFilePath"), m_lastFilePath},
|
{QStringLiteral("lastFilePath"), m_lastFilePath},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
m_state.saveSection(QStringLiteral("customTheme"), m_customThemeColors);
|
||||||
|
|
||||||
m_state.saveSection(QStringLiteral("window"), {
|
m_state.saveSection(QStringLiteral("window"), {
|
||||||
{QStringLiteral("width"), m_width},
|
{QStringLiteral("width"), m_width},
|
||||||
{QStringLiteral("height"), m_height},
|
{QStringLiteral("height"), m_height},
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVariantMap>
|
||||||
#include "backend/AppState.h"
|
#include "backend/AppState.h"
|
||||||
|
|
||||||
class UiState : public QObject {
|
class UiState : public QObject {
|
||||||
@@ -11,6 +12,7 @@ class UiState : public QObject {
|
|||||||
Q_PROPERTY(QString lastPage READ lastPage WRITE setLastPage NOTIFY lastPageChanged)
|
Q_PROPERTY(QString lastPage READ lastPage WRITE setLastPage NOTIFY lastPageChanged)
|
||||||
Q_PROPERTY(bool sidebarOpen READ sidebarOpen WRITE setSidebarOpen NOTIFY sidebarOpenChanged)
|
Q_PROPERTY(bool sidebarOpen READ sidebarOpen WRITE setSidebarOpen NOTIFY sidebarOpenChanged)
|
||||||
Q_PROPERTY(QString lastFilePath READ lastFilePath WRITE setLastFilePath NOTIFY lastFilePathChanged)
|
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 windowWidth READ windowWidth WRITE setWindowWidth NOTIFY windowWidthChanged)
|
||||||
Q_PROPERTY(int windowHeight READ windowHeight WRITE setWindowHeight NOTIFY windowHeightChanged)
|
Q_PROPERTY(int windowHeight READ windowHeight WRITE setWindowHeight NOTIFY windowHeightChanged)
|
||||||
Q_PROPERTY(int windowX READ windowX WRITE setWindowX NOTIFY windowXChanged)
|
Q_PROPERTY(int windowX READ windowX WRITE setWindowX NOTIFY windowXChanged)
|
||||||
@@ -22,6 +24,7 @@ public:
|
|||||||
QString lastPage() const;
|
QString lastPage() const;
|
||||||
bool sidebarOpen() const;
|
bool sidebarOpen() const;
|
||||||
QString lastFilePath() const;
|
QString lastFilePath() const;
|
||||||
|
QVariantMap customThemeColors() const;
|
||||||
int windowWidth() const;
|
int windowWidth() const;
|
||||||
int windowHeight() const;
|
int windowHeight() const;
|
||||||
int windowX() const;
|
int windowX() const;
|
||||||
@@ -31,6 +34,7 @@ public:
|
|||||||
void setLastPage(const QString &page);
|
void setLastPage(const QString &page);
|
||||||
void setSidebarOpen(bool open);
|
void setSidebarOpen(bool open);
|
||||||
void setLastFilePath(const QString &path);
|
void setLastFilePath(const QString &path);
|
||||||
|
void setCustomThemeColors(const QVariantMap &colors);
|
||||||
void setWindowWidth(int w);
|
void setWindowWidth(int w);
|
||||||
void setWindowHeight(int h);
|
void setWindowHeight(int h);
|
||||||
void setWindowX(int x);
|
void setWindowX(int x);
|
||||||
@@ -43,6 +47,7 @@ signals:
|
|||||||
void lastPageChanged();
|
void lastPageChanged();
|
||||||
void sidebarOpenChanged();
|
void sidebarOpenChanged();
|
||||||
void lastFilePathChanged();
|
void lastFilePathChanged();
|
||||||
|
void customThemeColorsChanged();
|
||||||
void windowWidthChanged();
|
void windowWidthChanged();
|
||||||
void windowHeightChanged();
|
void windowHeightChanged();
|
||||||
void windowXChanged();
|
void windowXChanged();
|
||||||
@@ -54,6 +59,7 @@ private:
|
|||||||
QString m_lastPage = QStringLiteral("starter");
|
QString m_lastPage = QStringLiteral("starter");
|
||||||
bool m_sidebarOpen = false;
|
bool m_sidebarOpen = false;
|
||||||
QString m_lastFilePath;
|
QString m_lastFilePath;
|
||||||
|
QVariantMap m_customThemeColors;
|
||||||
int m_width = 1024;
|
int m_width = 1024;
|
||||||
int m_height = 768;
|
int m_height = 768;
|
||||||
int m_x = -1;
|
int m_x = -1;
|
||||||
|
|||||||
+6
-2
@@ -34,10 +34,9 @@ ApplicationWindow {
|
|||||||
x = uiState.windowX
|
x = uiState.windowX
|
||||||
y = uiState.windowY
|
y = uiState.windowY
|
||||||
}
|
}
|
||||||
|
ThemeManager.loadCustomColors(uiState.customThemeColors)
|
||||||
if (uiState.themeName !== "")
|
if (uiState.themeName !== "")
|
||||||
ThemeManager.currentThemeName = uiState.themeName
|
ThemeManager.currentThemeName = uiState.themeName
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
@@ -139,6 +138,11 @@ ApplicationWindow {
|
|||||||
visible: window.currentPage === "history"
|
visible: window.currentPage === "history"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CustomThemePage {
|
||||||
|
anchors.fill: parent
|
||||||
|
visible: window.currentPage === "customTheme"
|
||||||
|
}
|
||||||
|
|
||||||
BusyIndicator {
|
BusyIndicator {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
running: window._bookInitializing
|
running: window._bookInitializing
|
||||||
|
|||||||
@@ -10,7 +10,34 @@ QtObject {
|
|||||||
|
|
||||||
property string currentThemeName: "dark"
|
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() {
|
function setDarkTheme() {
|
||||||
currentThemeName = "dark"
|
currentThemeName = "dark"
|
||||||
@@ -22,8 +49,74 @@ QtObject {
|
|||||||
uiState.themeName = "light"
|
uiState.themeName = "light"
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleTheme() {
|
function setCustomTheme() {
|
||||||
currentThemeName = currentThemeName === "dark" ? "light" : "dark"
|
currentThemeName = "custom"
|
||||||
uiState.themeName = currentThemeName
|
uiState.themeName = "custom"
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,6 +98,17 @@ Rectangle {
|
|||||||
onClicked: ThemeManager.setLightTheme()
|
onClicked: ThemeManager.setLightTheme()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SideBarButton {
|
||||||
|
iconText: "\ue40a"
|
||||||
|
title: "Custom Theme"
|
||||||
|
rightIconText: "\ue3c9"
|
||||||
|
onClicked: ThemeManager.setCustomTheme()
|
||||||
|
onRightIconClicked: {
|
||||||
|
ThemeManager.setCustomTheme()
|
||||||
|
sidebar.navigateTo("customTheme")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Divider
|
// Divider
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|||||||
@@ -10,11 +10,16 @@ Rectangle {
|
|||||||
|
|
||||||
property string iconText: ""
|
property string iconText: ""
|
||||||
property string title: ""
|
property string title: ""
|
||||||
|
property string rightIconText: ""
|
||||||
|
|
||||||
signal clicked()
|
signal clicked()
|
||||||
|
signal rightIconClicked()
|
||||||
|
|
||||||
Row {
|
Row {
|
||||||
anchors.fill: parent
|
anchors.left: parent.left
|
||||||
anchors.leftMargin: 16
|
anchors.leftMargin: 16
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
spacing: 16
|
spacing: 16
|
||||||
|
|
||||||
Text {
|
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 {
|
MouseArea {
|
||||||
id: 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
|
hoverEnabled: true
|
||||||
cursorShape: Qt.PointingHandCursor
|
cursorShape: Qt.PointingHandCursor
|
||||||
onClicked: root.clicked()
|
onClicked: root.clicked()
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user