From c4bf8f24b55ebf3dbea97dd9501a5de669b2b0ed Mon Sep 17 00:00:00 2001 From: Martin Rotter Date: Sat, 9 Apr 2022 07:32:11 +0200 Subject: [PATCH] simple article layout in litehtml persistent --- .../gui/webviewers/litehtml/litehtmlviewer.cpp | 17 +++++++++++------ src/librssguard/miscellaneous/settings.cpp | 3 +++ src/librssguard/miscellaneous/settings.h | 3 +++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/librssguard/gui/webviewers/litehtml/litehtmlviewer.cpp b/src/librssguard/gui/webviewers/litehtml/litehtmlviewer.cpp index 019ec0912..458ad9f16 100644 --- a/src/librssguard/gui/webviewers/litehtml/litehtmlviewer.cpp +++ b/src/librssguard/gui/webviewers/litehtml/litehtmlviewer.cpp @@ -24,7 +24,8 @@ #include LiteHtmlViewer::LiteHtmlViewer(QWidget* parent) : QLiteHtmlWidget(parent), m_downloader(new Downloader(this)), - m_reloadingWithImages(false), m_useSimpleArticleLayout(false) { + m_reloadingWithImages(false), + m_useSimpleArticleLayout(qApp->settings()->value(GROUP(Messages), SETTING(Messages::SimpleArticleLayout)).toBool()) { setResourceHandler([this](const QUrl& url) { emit loadProgress(-1); return m_reloadingWithImages ? handleResource(url) : QByteArray{}; @@ -155,12 +156,13 @@ QPair LiteHtmlViewer::prepareHtmlForMessage(const QList& } /*if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::DisplayImagePlaceholders)).toBool()) { - html += message.m_contents; - } - else {*/ - QString cnts = message.m_contents; + html += message.m_contents; + } + else {*/ + QString cnts = message.m_contents; + + html += cnts.replace(imgTagRegex, QString()); - html += cnts.replace(imgTagRegex, QString()); //} html += pictures_html; @@ -216,6 +218,8 @@ void LiteHtmlViewer::setZoomFactor(qreal zoom_factor) { void LiteHtmlViewer::simpleLayoutChanged(bool activated) { m_useSimpleArticleLayout = activated; + + qApp->settings()->setValue(GROUP(Messages), Messages::SimpleArticleLayout, activated); } void LiteHtmlViewer::selectedTextChanged(bool available) { @@ -295,6 +299,7 @@ void LiteHtmlViewer::showContextMenu(const QPoint& pos, const QUrl& url) { tr("Use simple article layout"), this)); m_actionSimpleLayout->setCheckable(true); + m_actionSimpleLayout->setChecked(m_useSimpleArticleLayout); m_actionReloadWithImages.reset(new QAction(qApp->icons()->fromTheme(QSL("viewimage"), QSL("view-refresh")), tr("Reload with images"), diff --git a/src/librssguard/miscellaneous/settings.cpp b/src/librssguard/miscellaneous/settings.cpp index 935535088..8833dfa80 100644 --- a/src/librssguard/miscellaneous/settings.cpp +++ b/src/librssguard/miscellaneous/settings.cpp @@ -120,6 +120,9 @@ DVALUE(bool) Messages::EnableMessagePreviewDef = true; DKEY Messages::Zoom = "zoom"; DVALUE(qreal) Messages::ZoomDef = double(1.0); +DKEY Messages::SimpleArticleLayout = "simple_article_layout"; +DVALUE(bool) Messages::SimpleArticleLayoutDef = false; + DKEY Messages::FixupFutureArticleDateTimes = "fixup_future_datetimes"; DVALUE(bool) Messages::FixupFutureArticleDateTimesDef = false; diff --git a/src/librssguard/miscellaneous/settings.h b/src/librssguard/miscellaneous/settings.h index 7d666e844..bbd5a499a 100644 --- a/src/librssguard/miscellaneous/settings.h +++ b/src/librssguard/miscellaneous/settings.h @@ -127,6 +127,9 @@ namespace Messages { KEY Zoom; VALUE(qreal) ZoomDef; + KEY SimpleArticleLayout; + VALUE(bool) SimpleArticleLayoutDef; + KEY FixupFutureArticleDateTimes; VALUE(bool) FixupFutureArticleDateTimesDef;