");
-
- // Add links to enclosures.
- if (acc_displays_enclosures) {
- for (const Enclosure& enc : message.m_enclosures) {
- html.m_html += QSL("[
%2]").arg(enc.m_url, enc.m_mimeType);
- }
- }
-
- // Display enclosures which are pictures if user has it enabled.
- auto first_enc_break_added = false;
-
- if (acc_displays_enclosures &&
- qApp->settings()->value(GROUP(Messages), SETTING(Messages::DisplayEnclosuresInMessage)).toBool()) {
- for (const Enclosure& enc : message.m_enclosures) {
- if (enc.m_mimeType.startsWith(QSL("image/"))) {
- if (!first_enc_break_added) {
- html.m_html += QSL("
");
- first_enc_break_added = true;
- }
-
- html.m_html += QSL("

").arg(enc.m_url);
- }
- }
- }
-
- // Append actual contents of article and convert to HTML if needed.
- html.m_html += is_plain ? Qt::convertFromPlainText(message.m_contents, Qt::WhiteSpaceMode::WhiteSpaceNormal)
- : message.m_contents;
-
- static QRegularExpression img_tag_rgx(QSL("\\
![]()
]*src\\s*=\\s*[\"\']([^\"\']*)[\"\'][^\\>]*\\>"),
- QRegularExpression::PatternOption::CaseInsensitiveOption |
- QRegularExpression::PatternOption::InvertedGreedinessOption);
-
- // Extract all images links from article to be appended to end of article.
- QRegularExpressionMatchIterator i = img_tag_rgx.globalMatch(html.m_html);
- QString pictures_html;
-
- while (i.hasNext()) {
- QRegularExpressionMatch match = i.next();
- auto captured_url = match.captured(1);
-
- pictures_html += QSL("
[%1]
%2").arg(tr("image"), captured_url);
- }
-
- // Make alla images clickable as links and also resize them if user has it setup.
- auto forced_img_size = qApp->settings()->value(GROUP(Messages), SETTING(Messages::MessageHeadImageHeight)).toInt();
-
- // Fixup all "img" tags.
- html.m_html = html.m_html.replace(img_tag_rgx,
- QSL("

")
- .arg(forced_img_size <= 0 ? QString() : QString::number(forced_img_size)));
-
- // Append generated list of images.
- html.m_html += pictures_html;
- }
-
- // Close contents.
- html.m_html += QSL("
");
-
- QString base_url;
- auto* feed = selected_item->getParentServiceRoot()
- ->getItemFromSubTree([messages](const RootItem* it) {
- return it->kind() == RootItem::Kind::Feed && it->customId() == messages.at(0).m_feedId;
- })
- ->toFeed();
-
- if (feed != nullptr) {
- QUrl url(NetworkFactory::sanitizeUrl(feed->source()));
-
- if (url.isValid()) {
- base_url = url.scheme() + QSL("://") + url.host();
- }
- }
-
- html.m_baseUrl = base_url;
-
- return html;
-}
-
void TextBrowserViewer::bindToBrowser(WebBrowser* browser) {
installEventFilter(browser);
@@ -302,8 +188,25 @@ void TextBrowserViewer::loadMessages(const QList