diff --git a/src/model/tracklistmodel.cpp b/src/model/tracklistmodel.cpp index 1d009d0..07dc515 100644 --- a/src/model/tracklistmodel.cpp +++ b/src/model/tracklistmodel.cpp @@ -51,8 +51,16 @@ void TrackListModel::setTracks(const QJsonArray &tracks, const QJsonObject performer = t["performer"].toObject(); item.artist = performer["name"].toString(); - if (item.artist.isEmpty()) - item.artist = t["album"].toObject()["artist"].toObject()["name"].toString(); + if (item.artist.isEmpty()) { + // album.artist.name may be a plain string or {display:"..."} object + const QJsonValue n = t["album"].toObject()["artist"].toObject()["name"]; + item.artist = n.isObject() ? n.toObject()["display"].toString() : n.toString(); + } + if (item.artist.isEmpty()) { + // top_tracks format: artist.name.display + const QJsonValue n = t["artist"].toObject()["name"]; + item.artist = n.isObject() ? n.toObject()["display"].toString() : n.toString(); + } const QJsonObject album = t["album"].toObject(); item.album = album["title"].toString(); diff --git a/src/view/artistview.cpp b/src/view/artistview.cpp index e83b3b9..6c3dae5 100644 --- a/src/view/artistview.cpp +++ b/src/view/artistview.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -89,11 +90,13 @@ ArtistView::ArtistView(QobuzBackend *backend, PlayQueue *queue, QWidget *parent) m_nameLabel->setFont(f); outerLayout->addWidget(m_nameLabel); - m_bioLabel = new QLabel(this); - m_bioLabel->setWordWrap(true); - m_bioLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); - m_bioLabel->setMaximumHeight(80); - outerLayout->addWidget(m_bioLabel); + m_bioEdit = new QTextEdit(this); + m_bioEdit->setReadOnly(true); + m_bioEdit->setFrameShape(QFrame::NoFrame); + m_bioEdit->setMaximumHeight(110); + m_bioEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); + m_bioEdit->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + outerLayout->addWidget(m_bioEdit); // Scrollable sections area auto *scroll = new QScrollArea(this); @@ -174,7 +177,6 @@ void ArtistView::setArtist(const QJsonObject &artist) const QString bioHtml = artist["biography"].toObject()["content"].toString(); if (!bioHtml.isEmpty()) { QString plain = bioHtml; - // Strip HTML entities and tags to prevent rendering injected content plain.remove(QRegularExpression(QStringLiteral("<[^>]*>"))); plain.replace(QStringLiteral("&"), QStringLiteral("&")); plain.replace(QStringLiteral("<"), QStringLiteral("<")); @@ -183,15 +185,14 @@ void ArtistView::setArtist(const QJsonObject &artist) plain.replace(QStringLiteral("'"), QStringLiteral("'")); plain.replace(QStringLiteral(" "), QStringLiteral(" ")); plain = plain.trimmed(); - m_bioLabel->setTextFormat(Qt::PlainText); - m_bioLabel->setText(plain); - m_bioLabel->setVisible(!plain.isEmpty()); + m_bioEdit->setPlainText(plain); + m_bioEdit->setVisible(!plain.isEmpty()); } else { - m_bioLabel->setVisible(false); + m_bioEdit->setVisible(false); } - // Top tracks are in the default artist/page response under "top_tracks" - const QJsonArray topTracks = artist["top_tracks"].toObject()["items"].toArray(); + // top_tracks is a flat array in the artist/page response + const QJsonArray topTracks = artist["top_tracks"].toArray(); m_topTracks->loadTracks(topTracks); m_topTracksSection->setVisible(!topTracks.isEmpty()); diff --git a/src/view/artistview.hpp b/src/view/artistview.hpp index 0d6f767..46e925b 100644 --- a/src/view/artistview.hpp +++ b/src/view/artistview.hpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -54,7 +55,7 @@ signals: private: QLabel *m_nameLabel = nullptr; - QLabel *m_bioLabel = nullptr; + QTextEdit *m_bioEdit = nullptr; // Top tracks section QWidget *m_topTracksSection = nullptr;