Add DarkTheme and LightTheme switching

This commit is contained in:
Agel committed 2026-03-31 20:43:37 +02:00
1 parent 7409ba789a
commit ff88cf581b
17 files changed
+206 -73

No files matched your search

+4 -4
View File
@@ -4,7 +4,7 @@ import Asteria
Rectangle {
id: overlay
color: Theme.overlayBg
color: ThemeManager.currentTheme.overlayBg
visible: bookController.errorMessage !== ""
MouseArea {
@@ -16,7 +16,7 @@ Rectangle {
anchors.centerIn: parent
width: Math.min(overlay.width * 0.7, 440)
height: dialogColumn.implicitHeight + 48
color: Theme.surface
color: ThemeManager.currentTheme.surface
radius: 8
Column {
@@ -35,7 +35,7 @@ Rectangle {
width: parent.width
text: bookController.errorMessage
font.pixelSize: 15
color: Theme.readingText
color: ThemeManager.currentTheme.readingText
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
}
@@ -53,7 +53,7 @@ Rectangle {
implicitWidth: 80
implicitHeight: 36
radius: 4
color: parent.hovered ? Qt.lighter(Theme.primaryAccent, 1.15) : Theme.primaryAccent
color: parent.hovered ? Qt.lighter(ThemeManager.currentTheme.primaryAccent, 1.15) : ThemeManager.currentTheme.primaryAccent
}
onClicked: bookController.clearError()
}
+7 -7
View File
@@ -3,13 +3,13 @@ import QtQuick.Controls
import Asteria
Rectangle {
height: Theme.footerHeight
color: Theme.footerBg
height: ThemeManager.currentTheme.footerHeight
color: ThemeManager.currentTheme.footerBg
Rectangle {
width: parent.width
height: 1
color: Theme.divider
color: ThemeManager.currentTheme.divider
anchors.top: parent.top
}
@@ -28,7 +28,7 @@ Rectangle {
text: "\ue5cb"
font.family: "Material Icons Outlined"
font.pixelSize: 16
color: prevBtn.enabled ? Theme.dimText : Theme.actionDisabled
color: prevBtn.enabled ? ThemeManager.currentTheme.dimText : ThemeManager.currentTheme.actionDisabled
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
@@ -45,7 +45,7 @@ Rectangle {
: ""
font.pixelSize: 11
font.bold: true
color: Theme.dimText
color: ThemeManager.currentTheme.dimText
}
// Next chapter button
@@ -63,7 +63,7 @@ Rectangle {
text: "\ue5cc"
font.family: "Material Icons Outlined"
font.pixelSize: 16
color: nextBtn.enabled ? Theme.dimText : Theme.actionDisabled
color: nextBtn.enabled ? ThemeManager.currentTheme.dimText : ThemeManager.currentTheme.actionDisabled
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
@@ -81,6 +81,6 @@ Rectangle {
: ""
font.pixelSize: 11
font.bold: true
color: Theme.counterText
color: ThemeManager.currentTheme.counterText
}
}
+5 -5
View File
@@ -4,9 +4,9 @@ import Asteria
Rectangle {
id: header
height: barsVisible ? Theme.headerHeight : 0
height: barsVisible ? ThemeManager.currentTheme.headerHeight : 0
clip: true
color: Theme.surface
color: ThemeManager.currentTheme.surface
property bool sidebarOpen: false
property string currentPage: "starter"
@@ -28,7 +28,7 @@ Rectangle {
contentItem: Text {
text: "\u2630"
font.pixelSize: 24
color: Theme.buttonAccent
color: ThemeManager.currentTheme.buttonAccent
}
background: Item {}
onClicked: header.menuClicked()
@@ -44,7 +44,7 @@ Rectangle {
}
}
font.pixelSize: 16
color: Theme.headerText
color: ThemeManager.currentTheme.headerText
}
Row {
@@ -58,7 +58,7 @@ Rectangle {
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 16
font.bold: true
color: Theme.dimText
color: ThemeManager.currentTheme.dimText
Timer {
running: true
+5 -5
View File
@@ -53,8 +53,8 @@ Rectangle {
}
gradient: Gradient {
GradientStop { position: 0.0; color: Theme.gradientTop }
GradientStop { position: 1.0; color: Theme.gradientBottom }
GradientStop { position: 0.0; color: ThemeManager.currentTheme.gradientTop }
GradientStop { position: 1.0; color: ThemeManager.currentTheme.gradientBottom }
}
function updateContentWidth() {
@@ -81,7 +81,7 @@ Rectangle {
textFormat: Text.RichText
font.pixelSize: appState.fontSize
lineHeight: appState.lineSpacing
color: Theme.readingText
color: ThemeManager.currentTheme.readingText
text: model.content
}
@@ -101,11 +101,11 @@ Rectangle {
contentItem: Rectangle {
implicitWidth: 18
radius: 3
color: Theme.scrollbarThumb
color: ThemeManager.currentTheme.scrollbarThumb
}
background: Rectangle {
implicitWidth: 18
color: Theme.scrollbarTrack
color: ThemeManager.currentTheme.scrollbarTrack
}
}
+17 -17
View File
@@ -4,9 +4,9 @@ import Asteria
Rectangle {
id: sidebar
width: sidebarOpen ? Theme.sidebarWidth : 0
width: sidebarOpen ? ThemeManager.sidebarWidth : 0
clip: true
color: Theme.surface
color: ThemeManager.currentTheme.surface
property bool sidebarOpen: false
@@ -17,7 +17,7 @@ Rectangle {
Behavior on width {
NumberAnimation {
duration: sidebarOpen ? Theme.animDurationOpen : Theme.animDurationClose
duration: sidebarOpen ? ThemeManager.animDurationOpen : ThemeManager.animDurationClose
easing.type: Easing.OutQuad
}
}
@@ -25,25 +25,25 @@ Rectangle {
Text {
anchors.left: parent.left
anchors.leftMargin: 16
y: Theme.headerHeight / 2 - height / 2
y: ThemeManager.headerHeight / 2 - height / 2
text: "Asteria"
font.pixelSize: 18
font.bold: true
color: Theme.uiText
color: ThemeManager.currentTheme.uiText
}
// Close button aligned with main header row
Button {
anchors.right: parent.right
anchors.rightMargin: 12
y: Theme.headerHeight / 2 - height / 2
y: ThemeManager.headerHeight / 2 - height / 2
z: 1
flat: true
contentItem: Text {
text: "\ue5cb"
font.family: "Material Icons Outlined"
font.pixelSize: 24
color: Theme.sidebarButtonText
color: DarkTheme.sidebarButtonText
}
background: Item {}
onClicked: sidebar.closeDrawer()
@@ -51,8 +51,8 @@ Rectangle {
Column {
id: navColumn
y: Theme.headerHeight
width: Theme.sidebarWidth
y: ThemeManager.headerHeight
width: ThemeManager.sidebarWidth
SideBarButton {
iconText: "\ue86d"
@@ -83,26 +83,26 @@ Rectangle {
Rectangle {
width: parent.width
height: 1
color: Theme.divider
color: ThemeManager.currentTheme.divider
}
SideBarButton {
iconText: "\ue3a9"
title: "Dark Theme"
onClicked: {} // Non-functional
onClicked: ThemeManager.setDarkTheme()
}
SideBarButton {
iconText: "\ue3a6"
title: "Light Theme"
onClicked: {} // Non-functional
onClicked: ThemeManager.setLightTheme()
}
// Divider
Rectangle {
width: parent.width
height: 1
color: Theme.divider
color: ThemeManager.currentTheme.divider
}
SideBarButton {
@@ -123,7 +123,7 @@ Rectangle {
id: tocDivider
width: parent.width
height: 1
color: Theme.divider
color: ThemeManager.currentTheme.divider
}
Text {
@@ -135,7 +135,7 @@ Rectangle {
text: "Contents"
font.pixelSize: 10
font.bold: true
color: Theme.dimText
color: ThemeManager.currentTheme.dimText
font.letterSpacing: 1
}
@@ -162,8 +162,8 @@ Rectangle {
text: modelData.title
font.pixelSize: 13
color: readingModel.currentChapter === modelData.chapterIndex
? Theme.sidebarButtonText
: Theme.uiText
? ThemeManager.sidebarButtonText
: ThemeManager.uiText
elide: Text.ElideRight
wrapMode: Text.NoWrap
}
+3 -3
View File
@@ -6,7 +6,7 @@ Rectangle {
id: root
height: 48
width: parent ? parent.width : 240
color: mouseArea.containsMouse ? Qt.lighter(Theme.headerBg, 1.3) : "transparent"
color: mouseArea.containsMouse ? Qt.lighter(ThemeManager.currentTheme.headerBg, 1.3) : "transparent"
property string iconText: ""
property string title: ""
@@ -22,14 +22,14 @@ Rectangle {
text: root.iconText
font.family: "Material Icons Outlined"
font.pixelSize: 24
color: Theme.sidebarButtonText
color: ThemeManager.currentTheme.sidebarButtonText
}
Text {
anchors.verticalCenter: parent.verticalCenter
text: root.title
font.pixelSize: 14
color: Theme.sidebarButtonText
color: ThemeManager.currentTheme.sidebarButtonText
}
}