feat: add playlist browse/search discovery and follow controls
Some checks failed
Build for Windows / build-windows (push) Has been cancelled

This commit is contained in:
joren
2026-03-31 00:23:56 +02:00
parent 07d6c8a88d
commit 96bb21adff
13 changed files with 833 additions and 26 deletions

View File

@@ -93,6 +93,13 @@ public:
"QPushButton:pressed { background: #333; }"));
btnRow->addWidget(m_shuffleBtn);
m_followBtn = new QPushButton(tr("Follow"), info);
m_followBtn->setStyleSheet(btnBase +
QStringLiteral("QPushButton { background: #2a2a2a; color: #ddd; border: 1px solid #666; }"
"QPushButton:pressed { background: #333; }"));
m_followBtn->hide();
btnRow->addWidget(m_followBtn);
btnRow->addStretch();
vlay->addLayout(btnRow);
vlay->addStretch(1);
@@ -113,9 +120,13 @@ public:
QPushButton *playButton() { return m_playBtn; }
QPushButton *shuffleButton() { return m_shuffleBtn; }
QPushButton *followButton() { return m_followBtn; }
QPushButton *subtitleButton() { return m_subtitle; }
qint64 artistId() const { return m_artistId; }
qint64 playlistId() const { return m_playlistId; }
bool playlistFollowed() const { return m_playlistFollowed; }
bool playlistOwned() const { return m_playlistOwned; }
void setAlbum(const QJsonObject &album)
{
@@ -127,14 +138,21 @@ public:
m_subtitle->setEnabled(m_artistId > 0);
m_subtitle->setCursor(m_artistId > 0 ? Qt::PointingHandCursor : Qt::ArrowCursor);
m_meta->setText(buildAlbumMeta(album));
m_followBtn->hide();
m_playlistId = 0;
m_playlistFollowed = false;
m_playlistOwned = false;
fetchArt(album["image"].toObject());
show();
}
void setPlaylist(const QJsonObject &playlist)
void setPlaylist(const QJsonObject &playlist, bool isFollowed, bool isOwned)
{
m_title->setText(playlist["name"].toString());
m_artistId = 0;
m_playlistId = static_cast<qint64>(playlist["id"].toDouble());
m_playlistFollowed = isFollowed;
m_playlistOwned = isOwned;
const QString desc = playlist["description"].toString();
const QString owner = playlist["owner"].toObject()["name"].toString();
m_subtitle->setText(desc.isEmpty() ? owner : desc);
@@ -142,6 +160,16 @@ public:
m_subtitle->setCursor(Qt::ArrowCursor);
m_meta->setText(buildPlaylistMeta(playlist));
if (m_playlistOwned) {
m_followBtn->setText(tr("Owned"));
m_followBtn->setEnabled(false);
m_followBtn->show();
} else {
m_followBtn->setText(m_playlistFollowed ? tr("Unfollow") : tr("Follow"));
m_followBtn->setEnabled(m_playlistId > 0);
m_followBtn->show();
}
// Try images300 → images150 → images (API returns mosaic arrays, not image_rectangle)
const QJsonArray imgs300 = playlist["images300"].toArray();
const QJsonArray imgs150 = playlist["images150"].toArray();
@@ -156,6 +184,13 @@ public:
show();
}
void setPlaylistFollowed(bool followed)
{
m_playlistFollowed = followed;
if (!m_playlistOwned)
m_followBtn->setText(m_playlistFollowed ? tr("Unfollow") : tr("Follow"));
}
private:
void fetchArt(const QJsonObject &img)
{
@@ -221,7 +256,11 @@ private:
QLabel *m_meta = nullptr;
QPushButton *m_playBtn = nullptr;
QPushButton *m_shuffleBtn = nullptr;
QPushButton *m_followBtn = nullptr;
QNetworkAccessManager *m_nam = nullptr;
QString m_currentArtUrl;
qint64 m_artistId = 0;
qint64 m_playlistId = 0;
bool m_playlistFollowed = false;
bool m_playlistOwned = false;
};