Persistenza: sync() esplicito dopo ogni scrittura QSettings (fix config cancellata al crash di chiusura) + reflow robusto con stile !important su html/body e contenitori

This commit is contained in:
2026-08-12 16:04:41 +02:00
parent 35be6f14be
commit 52d09911f2
2 changed files with 16 additions and 5 deletions
+11 -5
View File
@@ -235,15 +235,21 @@ Page {
}
// reflow: imposta il font-size del documento (il testo si ri-avvolge)
// e ripristina la posizione in frazione sull'altezza ricalcolata
// e ripristina la posizione in frazione sull'altezza ricalcolata.
// Serve uno <style> con !important: molti EPUB impostano px su body/p
// che vincerebbero sul semplice font-size dell'html
function applyFontScale() {
if (!web.loaded)
return
var px = Math.round(16 * page.fontScale * 100) / 100
var script = "document.documentElement.style.setProperty('font-size', '"
+ px + "px', 'important');"
+ "window.scrollTo(0, " + page.chapterFraction
+ " * Math.max(1, document.documentElement.scrollHeight - window.innerHeight)); true"
var script = "(function(){"
+ "var s=document.getElementById('cw-font');"
+ "if(!s){s=document.createElement('style');s.id='cw-font';document.head.appendChild(s);}"
+ "s.textContent='html,body{font-size:" + px + "px!important}"
+ "p,div,li,td,blockquote,section{font-size:1em!important}';"
+ "window.scrollTo(0," + page.chapterFraction
+ "*Math.max(1,document.documentElement.scrollHeight-window.innerHeight));"
+ "true})()"
web.runJavaScript(script, function() { })
}