fix initial current page number
This commit is contained in:
2 files changed
+22
-8
No files matched your search
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user