simple article layout in litehtml persistent

This commit is contained in:
Martin Rotter 2022-04-09 07:32:11 +02:00
parent e3096aee4f
commit c4bf8f24b5
3 changed files with 17 additions and 6 deletions

View File

@ -24,7 +24,8 @@
#include <QWheelEvent>
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<QString, QUrl> LiteHtmlViewer::prepareHtmlForMessage(const QList<Message>&
}
/*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"),

View File

@ -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;

View File

@ -127,6 +127,9 @@ namespace Messages {
KEY Zoom;
VALUE(qreal) ZoomDef;
KEY SimpleArticleLayout;
VALUE(bool) SimpleArticleLayoutDef;
KEY FixupFutureArticleDateTimes;
VALUE(bool) FixupFutureArticleDateTimesDef;