add library with reading history, progress tracking, and view persistence

This commit is contained in:
Agel committed 2026-03-20 11:20:16 +01:00
1 parent c62733bc26
commit c4046d8533
15 files changed
+685 -40

No files matched your search

+39 -24
View File
@@ -12,36 +12,51 @@ Rectangle {
onClicked: {} // Block clicks through overlay
}
Column {
Rectangle {
anchors.centerIn: parent
spacing: 20
width: Math.min(overlay.width * 0.7, 440)
height: dialogColumn.implicitHeight + 48
color: Theme.surface
radius: 8
Text {
anchors.horizontalCenter: parent.horizontalCenter
text: bookController.errorMessage
font.pixelSize: 15
color: Theme.readingText
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
width: Math.min(overlay.width * 0.6, 400)
}
Column {
id: dialogColumn
anchors {
top: parent.top
left: parent.left
right: parent.right
topMargin: 24
leftMargin: 24
rightMargin: 24
}
spacing: 20
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: "Ok"
contentItem: Text {
text: parent.text
font.pixelSize: 14
color: "#ffffff"
Text {
width: parent.width
text: bookController.errorMessage
font.pixelSize: 15
color: Theme.readingText
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
}
background: Rectangle {
implicitWidth: 80
implicitHeight: 36
radius: 4
color: parent.hovered ? Qt.lighter(Theme.primaryAccent, 1.15) : Theme.primaryAccent
Button {
anchors.horizontalCenter: parent.horizontalCenter
text: "Ok"
contentItem: Text {
text: parent.text
font.pixelSize: 14
color: "#ffffff"
horizontalAlignment: Text.AlignHCenter
}
background: Rectangle {
implicitWidth: 80
implicitHeight: 36
radius: 4
color: parent.hovered ? Qt.lighter(Theme.primaryAccent, 1.15) : Theme.primaryAccent
}
onClicked: bookController.clearError()
}
onClicked: bookController.errorMessage = ""
}
}
}
+17 -10
View File
@@ -77,23 +77,30 @@ Rectangle {
var idx = chunkListView.indexAt(0, chunkListView.contentY)
appState.lastScrollIndex = idx
var item = chunkListView.itemAtIndex(idx)
appState.lastScrollOffset = item ? chunkListView.contentY - item.y : 0
var offset = item ? chunkListView.contentY - item.y : 0
appState.lastScrollOffset = offset
appState.lastScrollPosition = chunkListView.contentY
if (bookController.hasBook)
appState.saveBookPosition(bookController.currentFilePath,
readingModel.currentChapter, idx, offset)
}
}
Connections {
target: bookController
function onBookReady() {
if (bookController.currentFilePath === appState.lastFilePath) {
readingModel.goToChapter(appState.lastChapter)
if (appState.lastScrollIndex > 0)
Qt.callLater(function() {
chunkListView.positionViewAtIndex(
appState.lastScrollIndex, ListView.Beginning)
chunkListView.contentY += appState.lastScrollOffset
})
}
var pos = appState.loadBookPosition(bookController.currentFilePath)
var savedChapter = pos["chapter"]
var savedScrollIndex = pos["scrollIndex"]
var savedScrollOffset = pos["scrollOffset"]
if (savedChapter > 0)
readingModel.goToChapter(savedChapter)
if (savedScrollIndex > 0)
Qt.callLater(function() {
chunkListView.positionViewAtIndex(savedScrollIndex, ListView.Beginning)
chunkListView.contentY += savedScrollOffset
})
Qt.callLater(function() {
readingModel.setViewportSize(chunkListView.width, chunkListView.height)
})
+14
View File
@@ -13,6 +13,7 @@ Rectangle {
signal closeDrawer()
signal navigateTo(string page)
signal openFile()
signal closeBook()
Behavior on width {
NumberAnimation {
@@ -59,12 +60,25 @@ Rectangle {
onClicked: sidebar.navigateTo("reader")
}
SideBarButton {
iconText: "\ue02f"
title: "Library"
onClicked: sidebar.navigateTo("library")
}
SideBarButton {
iconText: "\ue30a"
title: "Files"
onClicked: sidebar.openFile()
}
SideBarButton {
visible: bookController.hasBook
iconText: "\ue5cd"
title: "Close Book"
onClicked: sidebar.closeBook()
}
// Divider
Rectangle {
width: parent.width