make settings a popup

This commit is contained in:
Agel committed 2026-04-17 15:30:00 +02:00
1 parent d9ff29ca03
commit 04bf291229
5 files changed
+369 -229

No files matched your search

+2 -2
View File
@@ -158,7 +158,7 @@ set_source_files_properties(src/qml/components/ErrorPopup.qml PROPERTIES QT_RESO
set_source_files_properties(src/qml/components/SideBarButton.qml PROPERTIES QT_RESOURCE_ALIAS components/SideBarButton.qml) set_source_files_properties(src/qml/components/SideBarButton.qml PROPERTIES QT_RESOURCE_ALIAS components/SideBarButton.qml)
set_source_files_properties(src/qml/pages/StarterPage.qml PROPERTIES QT_RESOURCE_ALIAS pages/StarterPage.qml) set_source_files_properties(src/qml/pages/StarterPage.qml PROPERTIES QT_RESOURCE_ALIAS pages/StarterPage.qml)
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/components/SettingsPopup.qml PROPERTIES QT_RESOURCE_ALIAS components/SettingsPopup.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) set_source_files_properties(src/qml/pages/CustomThemePage.qml PROPERTIES QT_RESOURCE_ALIAS pages/CustomThemePage.qml)
@@ -179,9 +179,9 @@ qt_add_qml_module(asteria-qt
src/qml/components/Footer.qml src/qml/components/Footer.qml
src/qml/components/ErrorPopup.qml src/qml/components/ErrorPopup.qml
src/qml/components/SideBarButton.qml src/qml/components/SideBarButton.qml
src/qml/components/SettingsPopup.qml
src/qml/pages/StarterPage.qml src/qml/pages/StarterPage.qml
src/qml/pages/ReaderPage.qml src/qml/pages/ReaderPage.qml
src/qml/pages/SettingsPage.qml
src/qml/pages/HistoryPage.qml src/qml/pages/HistoryPage.qml
src/qml/pages/CustomThemePage.qml src/qml/pages/CustomThemePage.qml
RESOURCES RESOURCES
+14 -7
View File
@@ -20,6 +20,7 @@ ApplicationWindow {
property bool sidebarOpen: uiState.sidebarOpen property bool sidebarOpen: uiState.sidebarOpen
onSidebarOpenChanged: uiState.sidebarOpen = sidebarOpen onSidebarOpenChanged: uiState.sidebarOpen = sidebarOpen
property string currentPage: "starter" property string currentPage: "starter"
property bool settingsOpen: false
property bool barsVisible: true property bool barsVisible: true
// Set to true on the first book open at startup so we restore the last page. // Set to true on the first book open at startup so we restore the last page.
property bool _startupRestore: false property bool _startupRestore: false
@@ -89,8 +90,14 @@ ApplicationWindow {
sidebarOpen: window.sidebarOpen sidebarOpen: window.sidebarOpen
onCloseDrawer: window.sidebarOpen = false onCloseDrawer: window.sidebarOpen = false
onNavigateTo: function(page) { onNavigateTo: function(page) {
if (page === "settings") {
window.currentPage = book.hasBook ? "reader" : "starter"
window.settingsOpen = true
} else {
window.settingsOpen = false
window.currentPage = page window.currentPage = page
} }
}
onOpenFile: { onOpenFile: {
book.browseAndOpen() book.browseAndOpen()
} }
@@ -128,11 +135,6 @@ ApplicationWindow {
visible: window.currentPage === "reader" visible: window.currentPage === "reader"
} }
SettingsPage {
anchors.fill: parent
visible: window.currentPage === "settings"
}
HistoryPage { HistoryPage {
anchors.fill: parent anchors.fill: parent
visible: window.currentPage === "history" visible: window.currentPage === "history"
@@ -150,6 +152,11 @@ ApplicationWindow {
z: 10 z: 10
} }
SettingsPopup {
id: settingsPopup
visible: window.settingsOpen
onCloseRequested: window.settingsOpen = false
}
} }
@@ -179,7 +186,7 @@ ApplicationWindow {
if (window._startupRestore) { if (window._startupRestore) {
window._startupRestore = false window._startupRestore = false
var savedPage = uiState.lastPage var savedPage = uiState.lastPage
if (savedPage === "history" || savedPage === "settings") if (savedPage === "history")
window.currentPage = savedPage window.currentPage = savedPage
else else
window.currentPage = "reader" window.currentPage = "reader"
@@ -285,7 +292,7 @@ ApplicationWindow {
book.openFromPath(uiState.lastFilePath) book.openFromPath(uiState.lastFilePath)
} else { } else {
var savedPage = uiState.lastPage var savedPage = uiState.lastPage
if (savedPage === "history" || savedPage === "settings") if (savedPage === "history")
window.currentPage = savedPage window.currentPage = savedPage
window.sidebarOpen = true window.sidebarOpen = true
} }
+2 -2
View File
@@ -82,9 +82,9 @@ Rectangle {
ListView { ListView {
id: chunkListView id: chunkListView
anchors.fill: parent anchors.fill: parent
anchors.topMargin: readingPreferences.verticalMargin
anchors.bottomMargin: readingPreferences.verticalMargin
model: contentReady ? readingModel : null model: contentReady ? readingModel : null
header: Item { height: readingPreferences.verticalMargin }
footer: Item { height: readingPreferences.verticalMargin }
cacheBuffer: 20 cacheBuffer: 20
clip: true clip: true
+351
View File
@@ -0,0 +1,351 @@
import QtQuick
import QtQuick.Controls
import Asteria
Item {
id: popup
width: 300
height: shadow.height
x: parent ? parent.width - width - 24 : 0
y: 24
z: 100
signal closeRequested()
// Shadow
Rectangle {
id: shadow
width: panel.width
height: panel.height
x: 3
y: 3
radius: 8
color: "#000000"
opacity: 0.25
}
Rectangle {
id: panel
width: 300
height: headerBar.height + contentScroll.height
radius: 8
color: ThemeManager.currentTheme.surface
clip: true
// Drag handle / title bar
Rectangle {
id: headerBar
width: parent.width
height: 44
color: "transparent"
Text {
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
anchors.leftMargin: 16
text: "Settings"
font.pixelSize: 13
font.weight: Font.Medium
color: ThemeManager.currentTheme.dimText
}
Button {
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 8
flat: true
contentItem: Text {
text: "\ue5cd"
font.family: "Material Icons Outlined"
font.pixelSize: 18
color: ThemeManager.currentTheme.dimText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
background: Item {}
onClicked: popup.closeRequested()
}
MouseArea {
anchors.fill: parent
anchors.rightMargin: 40
property real pressX
property real pressY
cursorShape: Qt.SizeAllCursor
onPressed: function(mouse) {
pressX = mouse.x
pressY = mouse.y
}
onPositionChanged: function(mouse) {
if (!pressed) return
var dx = mouse.x - pressX
var dy = mouse.y - pressY
var par = popup.parent
if (par) {
popup.x = Math.max(0, Math.min(par.width - popup.width, popup.x + dx))
popup.y = Math.max(0, Math.min(par.height - popup.height, popup.y + dy))
} else {
popup.x += dx
popup.y += dy
}
}
}
Rectangle {
anchors.bottom: parent.bottom
width: parent.width
height: 1
color: ThemeManager.currentTheme.scrollbarThumb
}
}
ScrollView {
id: contentScroll
anchors.top: headerBar.bottom
width: parent.width
height: settingsCol.implicitHeight
contentWidth: availableWidth
Column {
id: settingsCol
x: 16
width: parent.width - 32
topPadding: 16
bottomPadding: 16
spacing: 16
// Horizontal margin
Column {
width: parent.width
spacing: 4
Item {
width: parent.width
height: Math.max(labelH.implicitHeight, valueH.implicitHeight)
Text {
id: labelH
text: "Horizontal margin"
font.pixelSize: 13
color: ThemeManager.currentTheme.uiText
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueH
text: hmSlider.value + " px"
font.pixelSize: 12
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: hmTimer
interval: 250
onTriggered: readingPreferences.horizontalMargin = hmSlider.value
}
Slider {
id: hmSlider
width: parent.width
from: 0; to: 64; stepSize: 1
value: readingPreferences.horizontalMargin
onValueChanged: { if (value !== readingPreferences.horizontalMargin) hmTimer.restart() }
background: Rectangle {
x: hmSlider.leftPadding
y: hmSlider.topPadding + hmSlider.availableHeight / 2 - height / 2
width: hmSlider.availableWidth
height: 3
radius: 2
color: ThemeManager.currentTheme.scrollbarThumb
Rectangle {
width: hmSlider.visualPosition * parent.width
height: parent.height
radius: 2
color: ThemeManager.currentTheme.buttonAccent
}
}
handle: Rectangle {
x: hmSlider.leftPadding + hmSlider.visualPosition * (hmSlider.availableWidth - width)
y: hmSlider.topPadding + hmSlider.availableHeight / 2 - height / 2
width: 14; height: 14; radius: 7
color: hmSlider.pressed ? Qt.lighter(ThemeManager.currentTheme.buttonAccent, 1.15) : ThemeManager.currentTheme.buttonAccent
}
}
}
// Vertical margin
Column {
width: parent.width
spacing: 4
Item {
width: parent.width
height: Math.max(labelV.implicitHeight, valueV.implicitHeight)
Text {
id: labelV
text: "Vertical margin"
font.pixelSize: 13
color: ThemeManager.currentTheme.uiText
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueV
text: vmSlider.value + " px"
font.pixelSize: 12
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: vmTimer
interval: 250
onTriggered: readingPreferences.verticalMargin = vmSlider.value
}
Slider {
id: vmSlider
width: parent.width
from: 0; to: 64; stepSize: 1
value: readingPreferences.verticalMargin
onValueChanged: { if (value !== readingPreferences.verticalMargin) vmTimer.restart() }
background: Rectangle {
x: vmSlider.leftPadding
y: vmSlider.topPadding + vmSlider.availableHeight / 2 - height / 2
width: vmSlider.availableWidth
height: 3
radius: 2
color: ThemeManager.currentTheme.scrollbarThumb
Rectangle {
width: vmSlider.visualPosition * parent.width
height: parent.height
radius: 2
color: ThemeManager.currentTheme.buttonAccent
}
}
handle: Rectangle {
x: vmSlider.leftPadding + vmSlider.visualPosition * (vmSlider.availableWidth - width)
y: vmSlider.topPadding + vmSlider.availableHeight / 2 - height / 2
width: 14; height: 14; radius: 7
color: vmSlider.pressed ? Qt.lighter(ThemeManager.currentTheme.buttonAccent, 1.15) : ThemeManager.currentTheme.buttonAccent
}
}
}
// Font size
Column {
width: parent.width
spacing: 4
Item {
width: parent.width
height: Math.max(labelF.implicitHeight, valueF.implicitHeight)
Text {
id: labelF
text: "Font size"
font.pixelSize: 13
color: ThemeManager.currentTheme.uiText
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueF
text: fsSlider.value + " px"
font.pixelSize: 12
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: fsTimer
interval: 250
onTriggered: readingPreferences.fontSize = fsSlider.value
}
Slider {
id: fsSlider
width: parent.width
from: 10; to: 32; stepSize: 1
value: readingPreferences.fontSize
onValueChanged: { if (value !== readingPreferences.fontSize) fsTimer.restart() }
background: Rectangle {
x: fsSlider.leftPadding
y: fsSlider.topPadding + fsSlider.availableHeight / 2 - height / 2
width: fsSlider.availableWidth
height: 3
radius: 2
color: ThemeManager.currentTheme.scrollbarThumb
Rectangle {
width: fsSlider.visualPosition * parent.width
height: parent.height
radius: 2
color: ThemeManager.currentTheme.buttonAccent
}
}
handle: Rectangle {
x: fsSlider.leftPadding + fsSlider.visualPosition * (fsSlider.availableWidth - width)
y: fsSlider.topPadding + fsSlider.availableHeight / 2 - height / 2
width: 14; height: 14; radius: 7
color: fsSlider.pressed ? Qt.lighter(ThemeManager.currentTheme.buttonAccent, 1.15) : ThemeManager.currentTheme.buttonAccent
}
}
}
// Line spacing
Column {
width: parent.width
spacing: 4
Item {
width: parent.width
height: Math.max(labelL.implicitHeight, valueL.implicitHeight)
Text {
id: labelL
text: "Line spacing"
font.pixelSize: 13
color: ThemeManager.currentTheme.uiText
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueL
text: lsSlider.value.toFixed(1) + "×"
font.pixelSize: 12
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: lsTimer
interval: 250
onTriggered: readingPreferences.lineSpacing = lsSlider.value
}
Slider {
id: lsSlider
width: parent.width
from: 0.5; to: 2.0; stepSize: 0.1
value: readingPreferences.lineSpacing
onValueChanged: { if (Math.abs(value - readingPreferences.lineSpacing) > 0.01) lsTimer.restart() }
background: Rectangle {
x: lsSlider.leftPadding
y: lsSlider.topPadding + lsSlider.availableHeight / 2 - height / 2
width: lsSlider.availableWidth
height: 3
radius: 2
color: ThemeManager.currentTheme.scrollbarThumb
Rectangle {
width: lsSlider.visualPosition * parent.width
height: parent.height
radius: 2
color: ThemeManager.currentTheme.buttonAccent
}
}
handle: Rectangle {
x: lsSlider.leftPadding + lsSlider.visualPosition * (lsSlider.availableWidth - width)
y: lsSlider.topPadding + lsSlider.availableHeight / 2 - height / 2
width: 14; height: 14; radius: 7
color: lsSlider.pressed ? Qt.lighter(ThemeManager.currentTheme.buttonAccent, 1.15) : ThemeManager.currentTheme.buttonAccent
}
}
}
}
}
}
}
-218
View File
@@ -1,218 +0,0 @@
import QtQuick
import QtQuick.Controls
import Asteria
Rectangle {
gradient: Gradient {
GradientStop { position: 0.0; color: ThemeManager.currentTheme.gradientTop }
GradientStop { position: 1.0; color: ThemeManager.currentTheme.gradientBottom }
}
ScrollView {
anchors.fill: parent
anchors.margins: 32
contentWidth: availableWidth
Column {
width: parent.width
spacing: 24
// Section header
Text {
text: "Reading"
font.pixelSize: 13
font.weight: Font.Medium
color: ThemeManager.currentTheme.dimText
leftPadding: 4
}
// Horizontal margin slider
Column {
width: parent.width
spacing: 8
Item {
width: parent.width
height: Math.max(labelH.implicitHeight, valueH.implicitHeight)
Text {
id: labelH
text: "Horizontal margin"
font.pixelSize: 15
color: ThemeManager.currentTheme.uiText
leftPadding: 4
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueH
text: hmSlider.value + " px"
font.pixelSize: 13
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.rightMargin: 4
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: hmTimer
interval: 250
onTriggered: readingPreferences.horizontalMargin = hmSlider.value
}
Slider {
id: hmSlider
width: parent.width
from: 0
to: 120
stepSize: 1
value: readingPreferences.horizontalMargin
onValueChanged: {
if (value !== readingPreferences.horizontalMargin)
hmTimer.restart()
}
}
}
// Vertical margin slider
Column {
width: parent.width
spacing: 8
Item {
width: parent.width
height: Math.max(labelV.implicitHeight, valueV.implicitHeight)
Text {
id: labelV
text: "Vertical margin"
font.pixelSize: 15
color: ThemeManager.currentTheme.uiText
leftPadding: 4
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueV
text: vmSlider.value + " px"
font.pixelSize: 13
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.rightMargin: 4
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: vmTimer
interval: 250
onTriggered: readingPreferences.verticalMargin = vmSlider.value
}
Slider {
id: vmSlider
width: parent.width
from: 0
to: 80
stepSize: 1
value: readingPreferences.verticalMargin
onValueChanged: {
if (value !== readingPreferences.verticalMargin)
vmTimer.restart()
}
}
}
// Font size slider
Column {
width: parent.width
spacing: 8
Item {
width: parent.width
height: Math.max(labelF.implicitHeight, valueF.implicitHeight)
Text {
id: labelF
text: "Font size"
font.pixelSize: 15
color: ThemeManager.currentTheme.uiText
leftPadding: 4
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueF
text: fsSlider.value + " px"
font.pixelSize: 13
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.rightMargin: 4
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: fsTimer
interval: 250
onTriggered: readingPreferences.fontSize = fsSlider.value
}
Slider {
id: fsSlider
width: parent.width
from: 10
to: 32
stepSize: 1
value: readingPreferences.fontSize
onValueChanged: {
if (value !== readingPreferences.fontSize)
fsTimer.restart()
}
}
}
// Line spacing slider
Column {
width: parent.width
spacing: 8
Item {
width: parent.width
height: Math.max(labelL.implicitHeight, valueL.implicitHeight)
Text {
id: labelL
text: "Line spacing"
font.pixelSize: 15
color: ThemeManager.currentTheme.uiText
leftPadding: 4
anchors.verticalCenter: parent.verticalCenter
}
Text {
id: valueL
text: lsSlider.value.toFixed(1) + "×"
font.pixelSize: 13
color: ThemeManager.currentTheme.dimText
anchors.right: parent.right
anchors.rightMargin: 4
anchors.verticalCenter: parent.verticalCenter
}
}
Timer {
id: lsTimer
interval: 250
onTriggered: readingPreferences.lineSpacing = lsSlider.value
}
Slider {
id: lsSlider
width: parent.width
from: 0.5
to: 3.0
stepSize: 0.1
value: readingPreferences.lineSpacing
onValueChanged: {
if (Math.abs(value - readingPreferences.lineSpacing) > 0.01)
lsTimer.restart()
}
}
}
}
}
}