mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Try to intelligently convert \n to <p> in song/artist info views
This commit is contained in:
parent
b97b2138fa
commit
c35ba55e75
@ -87,7 +87,7 @@ void EchoNestBiographies::RequestFinished() {
|
||||
data.icon_ = site_icons_[canonical_site];
|
||||
|
||||
SongInfoTextView* editor = new SongInfoTextView;
|
||||
editor->setHtml(bio.text());
|
||||
editor->SetHtml(bio.text());
|
||||
data.contents_ = editor;
|
||||
|
||||
emit InfoReady(request->id_, data);
|
||||
|
@ -122,7 +122,7 @@ void LastfmTrackInfoProvider::GetWiki(int id, const lastfm::XmlQuery& q) {
|
||||
SongInfoTextView* widget = new SongInfoTextView;
|
||||
data.contents_ = widget;
|
||||
|
||||
widget->setHtml(content);
|
||||
widget->SetHtml(content);
|
||||
|
||||
emit InfoReady(id, data);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QMenu>
|
||||
#include <QSettings>
|
||||
#include <QWheelEvent>
|
||||
#include <QtDebug>
|
||||
|
||||
const qreal SongInfoTextView::kDefaultFontSize = 8.5;
|
||||
const char* SongInfoTextView::kSettingsGroup = "SongInfo";
|
||||
@ -73,3 +74,16 @@ void SongInfoTextView::contextMenuEvent(QContextMenuEvent* e) {
|
||||
|
||||
menu->popup(e->globalPos());
|
||||
}
|
||||
|
||||
void SongInfoTextView::SetHtml(const QString& html) {
|
||||
QString copy(html.trimmed());
|
||||
|
||||
// Simplify newlines, and convert them to <p>
|
||||
copy.replace(QRegExp("[\\r\\n]+"), "\n");
|
||||
copy.replace(QRegExp("([^>])[\\t ]*\\n"), "\\1<p>");
|
||||
|
||||
// Strip any newlines from the end
|
||||
copy.replace(QRegExp("((<\\s*br\\s*/?\\s*>)|(<\\s*/?\\s*p\\s*/?\\s*>))+$"), "");
|
||||
|
||||
setHtml(copy);
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void ReloadSettings();
|
||||
void SetHtml(const QString& html);
|
||||
|
||||
signals:
|
||||
void ShowSettingsDialog();
|
||||
|
@ -122,7 +122,7 @@ void UltimateLyricsProvider::LyricsFetched(quint64 id, QNetworkReply* reply) {
|
||||
data.relevance_ = relevance();
|
||||
|
||||
SongInfoTextView* editor = new SongInfoTextView;
|
||||
editor->setHtml(lyrics);
|
||||
editor->SetHtml(lyrics);
|
||||
data.contents_ = editor;
|
||||
|
||||
emit InfoReady(id, data);
|
||||
|
Loading…
x
Reference in New Issue
Block a user