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)
|
// 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() {
|
function applyFontScale() {
|
||||||
if (!web.loaded)
|
if (!web.loaded)
|
||||||
return
|
return
|
||||||
var px = Math.round(16 * page.fontScale * 100) / 100
|
var px = Math.round(16 * page.fontScale * 100) / 100
|
||||||
var script = "document.documentElement.style.setProperty('font-size', '"
|
var script = "(function(){"
|
||||||
+ px + "px', 'important');"
|
+ "var s=document.getElementById('cw-font');"
|
||||||
+ "window.scrollTo(0, " + page.chapterFraction
|
+ "if(!s){s=document.createElement('style');s.id='cw-font';document.head.appendChild(s);}"
|
||||||
+ " * Math.max(1, document.documentElement.scrollHeight - window.innerHeight)); true"
|
+ "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() { })
|
web.runJavaScript(script, function() { })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ void Settings::setServerUrl(const QString &value)
|
|||||||
if (value == serverUrl())
|
if (value == serverUrl())
|
||||||
return;
|
return;
|
||||||
m_settings.setValue(QStringLiteral("serverUrl"), value);
|
m_settings.setValue(QStringLiteral("serverUrl"), value);
|
||||||
|
m_settings.sync(); // scrivi subito su disco: l'app può crashare alla chiusura (WebView)
|
||||||
emit serverUrlChanged();
|
emit serverUrlChanged();
|
||||||
emit baseUrlChanged();
|
emit baseUrlChanged();
|
||||||
}
|
}
|
||||||
@@ -33,6 +34,7 @@ void Settings::setUsername(const QString &value)
|
|||||||
if (value == username())
|
if (value == username())
|
||||||
return;
|
return;
|
||||||
m_settings.setValue(QStringLiteral("username"), value);
|
m_settings.setValue(QStringLiteral("username"), value);
|
||||||
|
m_settings.sync();
|
||||||
emit usernameChanged();
|
emit usernameChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ void Settings::setPassword(const QString &value)
|
|||||||
if (value == password())
|
if (value == password())
|
||||||
return;
|
return;
|
||||||
m_settings.setValue(QStringLiteral("password"), value);
|
m_settings.setValue(QStringLiteral("password"), value);
|
||||||
|
m_settings.sync();
|
||||||
emit passwordChanged();
|
emit passwordChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +62,7 @@ void Settings::setIgnoreSslErrors(bool value)
|
|||||||
if (value == ignoreSslErrors())
|
if (value == ignoreSslErrors())
|
||||||
return;
|
return;
|
||||||
m_settings.setValue(QStringLiteral("ignoreSslErrors"), value);
|
m_settings.setValue(QStringLiteral("ignoreSslErrors"), value);
|
||||||
|
m_settings.sync();
|
||||||
emit ignoreSslErrorsChanged();
|
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)
|
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.setValue(QStringLiteral("bookmarks/%1/%2").arg(bookId).arg(format), key);
|
||||||
|
m_settings.sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::bookFilePath(int bookId, const QString &format) const
|
QString Settings::bookFilePath(int bookId, const QString &format) const
|
||||||
|
|||||||
Reference in New Issue
Block a user