Lettore: margini configurabili (Settings.readerMargin + Slider nelle impostazioni, iniettati nello stile del capitolo) + controlli in PushUpMenu (un solo trascinamento in alto)
This commit is contained in:
+4
-3
@@ -406,7 +406,7 @@ QVariantList EpubBook::chapterList() const
|
||||
return list;
|
||||
}
|
||||
|
||||
QString EpubBook::chapterHtml(int index, int fontSizePx) const
|
||||
QString EpubBook::chapterHtml(int index, int fontSizePx, int marginPx) const
|
||||
{
|
||||
if (index < 0 || index >= m_chapters.size())
|
||||
return QString();
|
||||
@@ -417,9 +417,10 @@ QString EpubBook::chapterHtml(int index, int fontSizePx) const
|
||||
|
||||
// stile di reflow iniettato nel documento: !important vince sui CSS del libro
|
||||
const QString style = QStringLiteral(
|
||||
"<style id=\"cw-font\">html,body{font-size:%1px!important}"
|
||||
"<style id=\"cw-font\">html,body{font-size:%1px!important;"
|
||||
"margin-left:%2px!important;margin-right:%2px!important}"
|
||||
"p,div,li,td,blockquote,section{font-size:1em!important}</style>")
|
||||
.arg(fontSizePx);
|
||||
.arg(fontSizePx).arg(marginPx);
|
||||
const int headEnd = html.indexOf(QStringLiteral("</head>"), 0, Qt::CaseInsensitive);
|
||||
if (headEnd >= 0)
|
||||
html.insert(headEnd, style);
|
||||
|
||||
+2
-2
@@ -36,8 +36,8 @@ public:
|
||||
Q_INVOKABLE QString chapterTitle(int index) const;
|
||||
// elenco [{index, title}] per la lista capitoli
|
||||
Q_INVOKABLE QVariantList chapterList() const;
|
||||
// HTML del capitolo con lo stile di reflow iniettato (font-size in px)
|
||||
Q_INVOKABLE QString chapterHtml(int index, int fontSizePx) const;
|
||||
// HTML del capitolo con lo stile di reflow iniettato (font-size e margini in px)
|
||||
Q_INVOKABLE QString chapterHtml(int index, int fontSizePx, int marginPx) const;
|
||||
// base URL (file://) per risolvere immagini/CSS relativi del capitolo
|
||||
Q_INVOKABLE QString chapterBaseUrl(int index) const;
|
||||
|
||||
|
||||
@@ -66,6 +66,20 @@ void Settings::setIgnoreSslErrors(bool value)
|
||||
emit ignoreSslErrorsChanged();
|
||||
}
|
||||
|
||||
int Settings::readerMargin() const
|
||||
{
|
||||
return m_settings.value(QStringLiteral("readerMargin"), 24).toInt();
|
||||
}
|
||||
|
||||
void Settings::setReaderMargin(int value)
|
||||
{
|
||||
if (value == readerMargin())
|
||||
return;
|
||||
m_settings.setValue(QStringLiteral("readerMargin"), value);
|
||||
m_settings.sync();
|
||||
emit readerMarginChanged();
|
||||
}
|
||||
|
||||
QString Settings::downloadDir() const
|
||||
{
|
||||
QString dir = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
|
||||
@@ -12,6 +12,7 @@ class Settings : public QObject
|
||||
Q_PROPERTY(QString username READ username WRITE setUsername NOTIFY usernameChanged)
|
||||
Q_PROPERTY(QString password READ password WRITE setPassword NOTIFY passwordChanged)
|
||||
Q_PROPERTY(bool ignoreSslErrors READ ignoreSslErrors WRITE setIgnoreSslErrors NOTIFY ignoreSslErrorsChanged)
|
||||
Q_PROPERTY(int readerMargin READ readerMargin WRITE setReaderMargin NOTIFY readerMarginChanged)
|
||||
Q_PROPERTY(QString downloadDir READ downloadDir CONSTANT)
|
||||
// derivata da serverUrl (senza slash finale): accesso QML come appSettings.baseUrl
|
||||
Q_PROPERTY(QString baseUrl READ baseUrl NOTIFY baseUrlChanged)
|
||||
@@ -31,6 +32,10 @@ public:
|
||||
bool ignoreSslErrors() const;
|
||||
void setIgnoreSslErrors(bool value);
|
||||
|
||||
// margine laterale del testo nel lettore, in px
|
||||
int readerMargin() const;
|
||||
void setReaderMargin(int value);
|
||||
|
||||
QString downloadDir() const;
|
||||
|
||||
// Header "Authorization: Basic ..." pronto da usare, vuoto se utente non impostato
|
||||
|
||||
Reference in New Issue
Block a user