mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-02-04 03:08:04 +01:00
save work
This commit is contained in:
parent
f1bb2c7c00
commit
05afdf4b4a
@ -2,7 +2,10 @@
|
||||
|
||||
#include "gui/litehtml/litehtmlviewer.h"
|
||||
|
||||
#include "core/message.h"
|
||||
#include "gui/webbrowser.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/skinfactory.h"
|
||||
#include "network-web/networkfactory.h"
|
||||
|
||||
#include <QAction>
|
||||
@ -72,7 +75,77 @@ QUrl LiteHtmlViewer::url() const {
|
||||
void LiteHtmlViewer::clear() {}
|
||||
|
||||
void LiteHtmlViewer::loadMessages(const QList<Message>& messages, RootItem* root) {
|
||||
setHtml(messages.at(0).m_contents);
|
||||
Skin skin = qApp->skins()->currentSkin();
|
||||
QString messages_layout;
|
||||
QString single_message_layout = skin.m_layoutMarkup;
|
||||
|
||||
for (const Message& message : messages) {
|
||||
QString enclosures;
|
||||
QString enclosure_images;
|
||||
|
||||
for (const Enclosure& enclosure : message.m_enclosures) {
|
||||
QString enc_url;
|
||||
|
||||
if (!enclosure.m_url.contains(QRegularExpression(QSL("^(http|ftp|\\/)")))) {
|
||||
enc_url = QSL(INTERNAL_URL_PASSATTACHMENT) + QL1S("/?") + enclosure.m_url;
|
||||
}
|
||||
else {
|
||||
enc_url = enclosure.m_url;
|
||||
}
|
||||
|
||||
enc_url = QUrl::fromPercentEncoding(enc_url.toUtf8());
|
||||
|
||||
enclosures += skin.m_enclosureMarkup.arg(enc_url,
|
||||
QSL("🧷"),
|
||||
enclosure.m_mimeType);
|
||||
|
||||
if (enclosure.m_mimeType.startsWith(QSL("image/")) &&
|
||||
qApp->settings()->value(GROUP(Messages), SETTING(Messages::DisplayEnclosuresInMessage)).toBool()) {
|
||||
// Add thumbnail image.
|
||||
enclosure_images += skin.m_enclosureImageMarkup.arg(
|
||||
enclosure.m_url,
|
||||
enclosure.m_mimeType,
|
||||
qApp->settings()->value(GROUP(Messages), SETTING(Messages::MessageHeadImageHeight)).toString());
|
||||
}
|
||||
}
|
||||
|
||||
QString msg_date = qApp->settings()->value(GROUP(Messages), SETTING(Messages::UseCustomDate)).toBool()
|
||||
? message.m_created.toLocalTime().toString(qApp->settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::CustomDateFormat)).toString())
|
||||
: qApp->localization()->loadedLocale().toString(message.m_created.toLocalTime(),
|
||||
QLocale::FormatType::ShortFormat);
|
||||
|
||||
messages_layout.append(single_message_layout
|
||||
.arg(message.m_title,
|
||||
tr("Written by ") + (message.m_author.isEmpty() ?
|
||||
tr("unknown author") :
|
||||
message.m_author),
|
||||
message.m_url,
|
||||
message.m_contents,
|
||||
msg_date,
|
||||
enclosures,
|
||||
enclosure_images,
|
||||
QString::number(message.m_id)));
|
||||
}
|
||||
|
||||
QString msg_contents = skin.m_layoutMarkupWrapper.arg(messages.size() == 1
|
||||
? messages.at(0).m_title
|
||||
: tr("Newspaper view"),
|
||||
messages_layout);
|
||||
auto* feed = root->getParentServiceRoot()->getItemFromSubTree([messages](const RootItem* it) {
|
||||
return it->kind() == RootItem::Kind::Feed && it->customId() == messages.at(0).m_feedId;
|
||||
})->toFeed();
|
||||
QString base_url;
|
||||
|
||||
if (feed != nullptr) {
|
||||
QUrl url(NetworkFactory::sanitizeUrl(feed->source()));
|
||||
|
||||
if (url.isValid()) {
|
||||
base_url = url.scheme() + QSL("://") + url.host();
|
||||
}
|
||||
}
|
||||
|
||||
setHtml(msg_contents, QUrl::fromUserInput(base_url));
|
||||
}
|
||||
|
||||
double LiteHtmlViewer::verticalScrollBarPosition() const {
|
||||
|
@ -32,25 +32,9 @@ SettingsFeedsMessages::SettingsFeedsMessages(Settings* settings, QWidget* parent
|
||||
"performance of article list with big number of articles."),
|
||||
true);
|
||||
|
||||
#if defined(USE_WEBENGINE)
|
||||
m_ui->m_tabMessages->layout()->removeWidget(m_ui->m_checkDisplayPlaceholders);
|
||||
m_ui->m_checkDisplayPlaceholders->hide();
|
||||
|
||||
connect(m_ui->m_cbShowEnclosuresDirectly, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
connect(m_ui->m_spinHeightImageAttachments, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
|
||||
this, &SettingsFeedsMessages::dirtifySettings);
|
||||
#else
|
||||
m_ui->m_tabMessages->layout()->removeWidget(m_ui->m_cbShowEnclosuresDirectly);
|
||||
m_ui->m_cbShowEnclosuresDirectly->hide();
|
||||
|
||||
m_ui->m_tabMessages->layout()->removeWidget(m_ui->m_lblHeightImageAttachments);
|
||||
m_ui->m_lblHeightImageAttachments->hide();
|
||||
|
||||
m_ui->m_tabMessages->layout()->removeWidget(m_ui->m_spinHeightImageAttachments);
|
||||
m_ui->m_spinHeightImageAttachments->hide();
|
||||
|
||||
connect(m_ui->m_checkDisplayPlaceholders, &QCheckBox::toggled, this, &SettingsFeedsMessages::dirtifySettings);
|
||||
#endif
|
||||
|
||||
connect(m_ui->m_spinRelativeArticleTime, QOverload<int>::of(&QSpinBox::valueChanged), this, [=](int value) {
|
||||
if (value <= 0) {
|
||||
@ -210,14 +194,10 @@ void SettingsFeedsMessages::loadSettings() {
|
||||
m_ui->m_checkMultilineArticleList->setChecked(settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::MultilineArticleList)).toBool());
|
||||
|
||||
#if !defined (USE_WEBENGINE)
|
||||
m_ui->m_checkDisplayPlaceholders->setChecked(settings()->value(GROUP(Messages), SETTING(Messages::DisplayImagePlaceholders)).toBool());
|
||||
#else
|
||||
m_ui->m_spinHeightImageAttachments->setValue(settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::MessageHeadImageHeight)).toInt());
|
||||
m_ui->m_cbShowEnclosuresDirectly->setChecked(settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::DisplayEnclosuresInMessage)).toBool());
|
||||
#endif
|
||||
|
||||
m_ui->m_cbFixupArticleDatetime->setChecked(settings()->value(GROUP(Messages),
|
||||
SETTING(Messages::FixupFutureArticleDateTimes)).toBool());
|
||||
@ -282,15 +262,10 @@ void SettingsFeedsMessages::saveSettings() {
|
||||
settings()->setValue(GROUP(Feeds), Feeds::EnableTooltipsFeedsMessages, m_ui->m_checkShowTooltips->isChecked());
|
||||
settings()->setValue(GROUP(Messages), Messages::IgnoreContentsChanges, m_ui->m_cmbIgnoreContentsChanges->isChecked());
|
||||
settings()->setValue(GROUP(Messages), Messages::MultilineArticleList, m_ui->m_checkMultilineArticleList->isChecked());
|
||||
|
||||
#if !defined (USE_WEBENGINE)
|
||||
settings()->setValue(GROUP(Messages), Messages::DisplayImagePlaceholders, m_ui->m_checkDisplayPlaceholders->isChecked());
|
||||
#else
|
||||
settings()->setValue(GROUP(Messages), Messages::MessageHeadImageHeight, m_ui->m_spinHeightImageAttachments->value());
|
||||
settings()->setValue(GROUP(Messages),
|
||||
Messages::DisplayEnclosuresInMessage,
|
||||
m_ui->m_cbShowEnclosuresDirectly->isChecked());
|
||||
#endif
|
||||
|
||||
settings()->setValue(GROUP(Messages), Messages::FixupFutureArticleDateTimes, m_ui->m_cbFixupArticleDatetime->isChecked());
|
||||
|
||||
|
@ -297,28 +297,28 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_checkDisplayPlaceholders">
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbFixupArticleDatetime">
|
||||
<property name="text">
|
||||
<string>Display placeholders to indicate locations of pictures</string>
|
||||
<string>Fixup date/time of articles which are in the future</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2">
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbShowEnclosuresDirectly">
|
||||
<property name="text">
|
||||
<string>Display attached pictures directly in article</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_checkBringToForegroundAfterMsgOpened">
|
||||
<property name="text">
|
||||
<string>Bring application window to front once article is opened in external web browser</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="m_lblHeightImageAttachments">
|
||||
<property name="text">
|
||||
<string>Image attachments height</string>
|
||||
@ -328,7 +328,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="m_spinHeightImageAttachments">
|
||||
<property name="suffix">
|
||||
<string notr="true"> px</string>
|
||||
@ -341,7 +341,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox_4">
|
||||
@ -384,7 +384,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<item row="7" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -397,13 +397,6 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="m_cbFixupArticleDatetime">
|
||||
<property name="text">
|
||||
<string>Fixup date/time of articles which are in the future</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="m_tabArticlesList">
|
||||
@ -637,7 +630,6 @@
|
||||
<tabstop>m_checkRemoveReadMessagesOnExit</tabstop>
|
||||
<tabstop>m_cmbIgnoreContentsChanges</tabstop>
|
||||
<tabstop>m_cbFixupArticleDatetime</tabstop>
|
||||
<tabstop>m_checkDisplayPlaceholders</tabstop>
|
||||
<tabstop>m_cbShowEnclosuresDirectly</tabstop>
|
||||
<tabstop>m_checkBringToForegroundAfterMsgOpened</tabstop>
|
||||
<tabstop>m_spinHeightImageAttachments</tabstop>
|
||||
|
@ -110,6 +110,11 @@ void WebEngineViewer::loadMessages(const QList<Message>& messages, RootItem* roo
|
||||
QString::number(message.m_id)));
|
||||
}
|
||||
|
||||
m_messageContents = skin.m_layoutMarkupWrapper.arg(messages.size() == 1
|
||||
? messages.at(0).m_title
|
||||
: tr("Newspaper view"),
|
||||
messages_layout);
|
||||
|
||||
m_root = root;
|
||||
|
||||
auto* feed = root->getParentServiceRoot()->getItemFromSubTree([messages](const RootItem* it) {
|
||||
@ -126,9 +131,6 @@ void WebEngineViewer::loadMessages(const QList<Message>& messages, RootItem* roo
|
||||
}
|
||||
}
|
||||
|
||||
m_messageContents = skin.m_layoutMarkupWrapper.arg(messages.size() == 1 ? messages.at(0).m_title : tr("Newspaper view"),
|
||||
messages_layout);
|
||||
|
||||
bool previously_enabled = isEnabled();
|
||||
|
||||
setEnabled(false);
|
||||
|
@ -111,19 +111,12 @@ DKEY Messages::ID = "messages";
|
||||
DKEY Messages::MessageHeadImageHeight = "message_head_image_height";
|
||||
DVALUE(int) Messages::MessageHeadImageHeightDef = 36;
|
||||
|
||||
#if defined (USE_WEBENGINE)
|
||||
DKEY Messages::DisplayEnclosuresInMessage = "show_enclosures_in_message";
|
||||
DVALUE(bool) Messages::DisplayEnclosuresInMessageDef = false;
|
||||
#endif
|
||||
|
||||
DKEY Messages::EnableMessagePreview = "enable_message_preview";
|
||||
DVALUE(bool) Messages::EnableMessagePreviewDef = true;
|
||||
|
||||
#if !defined (USE_WEBENGINE)
|
||||
DKEY Messages::DisplayImagePlaceholders = "display_image_placeholders";
|
||||
DVALUE(bool) Messages::DisplayImagePlaceholdersDef = false;
|
||||
#endif
|
||||
|
||||
DKEY Messages::Zoom = "zoom";
|
||||
DVALUE(qreal) Messages::ZoomDef = double(1.0f);
|
||||
|
||||
|
@ -124,11 +124,6 @@ namespace Messages {
|
||||
KEY EnableMessagePreview;
|
||||
VALUE(bool) EnableMessagePreviewDef;
|
||||
|
||||
#if !defined (USE_WEBENGINE)
|
||||
KEY DisplayImagePlaceholders;
|
||||
VALUE(bool) DisplayImagePlaceholdersDef;
|
||||
#endif
|
||||
|
||||
KEY Zoom;
|
||||
VALUE(qreal) ZoomDef;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user