mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 21:38:51 +03:00
RSS Feed will format plain text descriptions
This commit is contained in:
parent
60bc22119d
commit
195b46673a
1 changed files with 31 additions and 1 deletions
|
@ -567,7 +567,37 @@ void RSSImp::refreshTextBrowser()
|
|||
html += "<div style='background-color: #efefef;'><b>"+tr("Author: ")+"</b>"+article->author()+"</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);
|
||||
article->markAsRead();
|
||||
item->setData(Article::ColorRole, QVariant(QColor("grey")));
|
||||
|
|
Loading…
Reference in a new issue