mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 15:27:54 +00:00
RSS Feed will format plain text descriptions
This commit is contained in:
parent
60bc22119d
commit
195b46673a
@ -567,7 +567,37 @@ void RSSImp::refreshTextBrowser()
|
|||||||
html += "<div style='background-color: #efefef;'><b>"+tr("Author: ")+"</b>"+article->author()+"</div>";
|
html += "<div style='background-color: #efefef;'><b>"+tr("Author: ")+"</b>"+article->author()+"</div>";
|
||||||
}
|
}
|
||||||
html += "</div>";
|
html += "</div>";
|
||||||
html += "<divstyle='margin-left: 5px; margin-right: 5px;'>"+article->description()+"</div>";
|
html += "<div style='margin-left: 5px; margin-right: 5px;'>";
|
||||||
|
if(Qt::mightBeRichText(article->description())) {
|
||||||
|
html += article->description();
|
||||||
|
} else {
|
||||||
|
QString description = article->description();
|
||||||
|
QRegExp rx;
|
||||||
|
// If description is plain text, replace BBCode tags with HTML and wrap everything in <pre></pre> so it looks nice
|
||||||
|
rx.setMinimal(true);
|
||||||
|
rx.setCaseSensitivity(Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
rx.setPattern("\\[img\\](.+)\\[/img\\]");
|
||||||
|
description = description.replace(rx, "<img src=\"\\1\">");
|
||||||
|
|
||||||
|
rx.setPattern("\\[url=(\")?(.+)\\1\\]");
|
||||||
|
description = description.replace(rx, "<a href=\"\\2\">");
|
||||||
|
description = description.replace("[/url]", "</a>", Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
rx.setPattern("\\[(/)?([bius])\\]");
|
||||||
|
description = description.replace(rx, "<\\1\\2>");
|
||||||
|
|
||||||
|
rx.setPattern("\\[color=(\")?(.+)\\1\\]");
|
||||||
|
description = description.replace(rx, "<span style=\"color:\\2\">");
|
||||||
|
description = description.replace("[/color]", "</span>", Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
rx.setPattern("\\[size=(\")?(.+)\\d\\1\\]");
|
||||||
|
description = description.replace(rx, "<span style=\"font-size:\\2px\">");
|
||||||
|
description = description.replace("[/size]", "</span>", Qt::CaseInsensitive);
|
||||||
|
|
||||||
|
html += "<pre>" + description + "</pre>";
|
||||||
|
}
|
||||||
|
html += "</div>";
|
||||||
textBrowser->setHtml(html);
|
textBrowser->setHtml(html);
|
||||||
article->markAsRead();
|
article->markAsRead();
|
||||||
item->setData(Article::ColorRole, QVariant(QColor("grey")));
|
item->setData(Article::ColorRole, QVariant(QColor("grey")));
|
||||||
|
Loading…
Reference in New Issue
Block a user