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:
@@ -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() { })
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ void Settings::setServerUrl(const QString &value)
|
||||
if (value == serverUrl())
|
||||
return;
|
||||
m_settings.setValue(QStringLiteral("serverUrl"), value);
|
||||
m_settings.sync(); // scrivi subito su disco: l'app può crashare alla chiusura (WebView)
|
||||
emit serverUrlChanged();
|
||||
emit baseUrlChanged();
|
||||
}
|
||||
@@ -33,6 +34,7 @@ void Settings::setUsername(const QString &value)
|
||||
if (value == username())
|
||||
return;
|
||||
m_settings.setValue(QStringLiteral("username"), value);
|
||||
m_settings.sync();
|
||||
emit usernameChanged();
|
||||
}
|
||||
|
||||
@@ -46,6 +48,7 @@ void Settings::setPassword(const QString &value)
|
||||
if (value == password())
|
||||
return;
|
||||
m_settings.setValue(QStringLiteral("password"), value);
|
||||
m_settings.sync();
|
||||
emit passwordChanged();
|
||||
}
|
||||
|
||||
@@ -59,6 +62,7 @@ void Settings::setIgnoreSslErrors(bool value)
|
||||
if (value == ignoreSslErrors())
|
||||
return;
|
||||
m_settings.setValue(QStringLiteral("ignoreSslErrors"), value);
|
||||
m_settings.sync();
|
||||
emit ignoreSslErrorsChanged();
|
||||
}
|
||||
|
||||
@@ -97,6 +101,7 @@ QString Settings::bookmarkKey(int bookId, const QString &format) const
|
||||
void Settings::setBookmarkKey(int bookId, const QString &format, const QString &key)
|
||||
{
|
||||
m_settings.setValue(QStringLiteral("bookmarks/%1/%2").arg(bookId).arg(format), key);
|
||||
m_settings.sync();
|
||||
}
|
||||
|
||||
QString Settings::bookFilePath(int bookId, const QString &format) const
|
||||
|
||||
Reference in New Issue
Block a user