fix initial current page number

This commit is contained in:
Agel committed 2026-03-20 14:48:14 +01:00
1 parent a294af8bde
commit 0411de6174
2 files changed
+22 -8

No files matched your search

+21 -7
View File
@@ -95,9 +95,12 @@ Rectangle {
}
}
property bool _restoring: false
Connections {
target: bookController
function onBookReady() {
_restoring = true
var pos = appState.loadBookPosition(bookController.currentFilePath)
var savedChapter = pos["chapter"]
var savedScrollIndex = pos["scrollIndex"]
@@ -105,13 +108,22 @@ Rectangle {
if (savedChapter > 0)
readingModel.goToChapter(savedChapter)
if (savedScrollIndex > 0)
Qt.callLater(function() {
Qt.callLater(function() {
if (savedScrollIndex > 0) {
chunkListView.positionViewAtIndex(savedScrollIndex, ListView.Beginning)
chunkListView.contentY += savedScrollOffset
})
Qt.callLater(function() {
}
readingModel.setViewportSize(chunkListView.width, chunkListView.height)
if (savedScrollIndex > 0) {
var idx = chunkListView.indexAt(0, chunkListView.contentY)
if (idx >= 0) {
var item = chunkListView.itemAtIndex(idx)
var offset = item ? chunkListView.contentY - item.y : 0
readingModel.setScrollInfo(idx, offset, chunkListView.atYEnd)
}
}
_restoring = false
})
}
}
@@ -119,9 +131,11 @@ Rectangle {
Connections {
target: readingModel
function onChapterChanged() {
Qt.callLater(function() {
readingModel.setViewportSize(chunkListView.width, chunkListView.height)
})
if (!_restoring) {
Qt.callLater(function() {
readingModel.setViewportSize(chunkListView.width, chunkListView.height)
})
}
}
}
}