Audit best practice 0.4.8: orientazioni per pagina (reader in landscape), licenza nel pacchetto, EPUB lazy lengths, cover dinamica (ReaderState), flush config senza sync per tasto, pulizia chapterFraction/commenti
This commit is contained in:
@@ -18,7 +18,6 @@ Page {
|
||||
property string bookFormat: "epub"
|
||||
|
||||
property int currentChapter: 0
|
||||
property double chapterFraction: 0.0
|
||||
// posizione di lettura nel capitolo corrente, stimata in caratteri di testo
|
||||
// dalla frazione di scroll (stabile col reflow del font)
|
||||
property int charOffset: 0
|
||||
@@ -276,11 +275,11 @@ Page {
|
||||
var max = Math.max(0, innerFlick.contentHeight - innerFlick.height)
|
||||
var y = Math.max(0, Math.min(max, innerFlick.contentY))
|
||||
var len = book.chapterTextLength(page.currentChapter)
|
||||
page.chapterFraction = max > 0 ? y / max : 0
|
||||
// posizione per caratteri (stima dalla frazione: stabile col reflow)
|
||||
page.charOffset = Math.round(page.chapterFraction * len)
|
||||
page.charOffset = Math.round((max > 0 ? y / max : 0) * len)
|
||||
page.pageIndex = Math.floor(y / step) + 1
|
||||
page.pageCount = Math.max(1, Math.ceil(max / step) + 1)
|
||||
updateCoverState()
|
||||
maybeSave(false)
|
||||
}
|
||||
|
||||
@@ -308,7 +307,6 @@ Page {
|
||||
return
|
||||
if (index !== page.currentChapter) {
|
||||
maybeSave(true)
|
||||
page.chapterFraction = 0
|
||||
page.charOffset = 0
|
||||
page.lastSavedAbs = -1
|
||||
}
|
||||
@@ -368,7 +366,6 @@ Page {
|
||||
} else if (page.currentChapter > 0) {
|
||||
maybeSave(true)
|
||||
page.currentChapter -= 1
|
||||
page.chapterFraction = 0
|
||||
page.charOffset = 0
|
||||
page.lastSavedAbs = -1
|
||||
// sentinella "fine capitolo": va oltre la lunghezza, così
|
||||
@@ -383,6 +380,17 @@ Page {
|
||||
return Math.round(16 * page.fontScale * 100) / 100
|
||||
}
|
||||
|
||||
// aggiorna lo stato per la cover (titolo + capitolo + percentuale)
|
||||
function updateCoverState() {
|
||||
if (book.chapterCount <= 0)
|
||||
return
|
||||
var pct = Math.round(page.overallProgress() * 100)
|
||||
readerState.setReading(book.title(),
|
||||
(page.currentChapter + 1) + "/" + book.chapterCount
|
||||
+ " · " + book.chapterTitle(page.currentChapter)
|
||||
+ " · " + pct + "%")
|
||||
}
|
||||
|
||||
function showChapterList() {
|
||||
var dialog = pageStack.push(Qt.resolvedUrl("ChapterListDialog.qml"),
|
||||
{ model: book.chapterList() })
|
||||
@@ -424,11 +432,17 @@ Page {
|
||||
page.currentChapter = ch
|
||||
page.pendingRestore = true
|
||||
page.restoreFrac = off >= 0 ? offsetToFrac(off, ch) : 0.0
|
||||
updateCoverState()
|
||||
restoreTimer.start()
|
||||
}
|
||||
|
||||
Component.onDestruction: readerState.clearReading()
|
||||
|
||||
onStatusChanged: {
|
||||
if (status === PageStatus.Inactive) {
|
||||
if (status === PageStatus.Active) {
|
||||
if (page.ready && book.chapterCount > 0)
|
||||
updateCoverState()
|
||||
} else if (status === PageStatus.Inactive) {
|
||||
maybeSave(true)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user