add library with reading history, progress tracking, and view persistence
This commit is contained in:
15 files changed
+685
-40
No files matched your search
@@ -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)
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user