feat: add album favorites in header and unify browse controls
Some checks failed
Build for Windows / build-windows (push) Has been cancelled

Improve album workflow with in-header favorite toggle, keep favorite state synced from backend, and normalize browse top-bar sizing while increasing audio output buffer headroom to reduce glitches.
This commit is contained in:
joren
2026-03-31 01:49:53 +02:00
parent cdac82dbef
commit 1ad3ba4e69
7 changed files with 131 additions and 6 deletions

View File

@@ -93,6 +93,13 @@ public:
"QPushButton:pressed { background: #333; }"));
btnRow->addWidget(m_shuffleBtn);
m_favBtn = new QPushButton(tr("♡ Favourite"), info);
m_favBtn->setStyleSheet(btnBase +
QStringLiteral("QPushButton { background: #2a2a2a; color: #ccc; border: 1px solid #555; }"
"QPushButton:pressed { background: #333; }"));
m_favBtn->hide();
btnRow->addWidget(m_favBtn);
m_followBtn = new QPushButton(tr("Follow"), info);
m_followBtn->setStyleSheet(btnBase +
QStringLiteral("QPushButton { background: #2a2a2a; color: #ddd; border: 1px solid #666; }"
@@ -120,24 +127,35 @@ public:
QPushButton *playButton() { return m_playBtn; }
QPushButton *shuffleButton() { return m_shuffleBtn; }
QPushButton *favButton() { return m_favBtn; }
QPushButton *followButton() { return m_followBtn; }
QPushButton *subtitleButton() { return m_subtitle; }
QString albumId() const { return m_albumId; }
bool albumFaved() const { return m_albumFaved; }
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)
void setAlbum(const QJsonObject &album, bool isFaved)
{
const QString base = album["title"].toString();
const QString ver = album["version"].toString().trimmed();
m_title->setText(ver.isEmpty() ? base : base + QStringLiteral(" (") + ver + QLatin1Char(')'));
m_albumId = album["id"].toString();
if (m_albumId.isEmpty() && album["id"].isDouble())
m_albumId = QString::number(static_cast<qint64>(album["id"].toDouble()));
m_artistId = static_cast<qint64>(album["artist"].toObject()["id"].toDouble());
m_subtitle->setText(album["artist"].toObject()["name"].toString());
m_subtitle->setEnabled(m_artistId > 0);
m_subtitle->setCursor(m_artistId > 0 ? Qt::PointingHandCursor : Qt::ArrowCursor);
m_meta->setText(buildAlbumMeta(album));
setAlbumFaved(isFaved);
m_favBtn->setEnabled(!m_albumId.isEmpty());
m_favBtn->show();
m_followBtn->hide();
m_playlistId = 0;
m_playlistFollowed = false;
@@ -160,6 +178,10 @@ public:
m_subtitle->setCursor(Qt::ArrowCursor);
m_meta->setText(buildPlaylistMeta(playlist));
m_albumId.clear();
m_albumFaved = false;
m_favBtn->hide();
if (m_playlistOwned) {
m_followBtn->setText(tr("Owned"));
m_followBtn->setEnabled(false);
@@ -191,6 +213,24 @@ public:
m_followBtn->setText(m_playlistFollowed ? tr("Unfollow") : tr("Follow"));
}
void setAlbumFaved(bool faved)
{
m_albumFaved = faved;
if (faved) {
m_favBtn->setText(tr("♥ Favourited"));
m_favBtn->setStyleSheet(QStringLiteral(
"QPushButton { padding: 5px 16px; border-radius: 4px; font-weight: bold;"
" background: #2a2a2a; color: #FFB232; border: 1px solid #FFB232; }"
"QPushButton:pressed { background: #333; }"));
} else {
m_favBtn->setText(tr("♡ Favourite"));
m_favBtn->setStyleSheet(QStringLiteral(
"QPushButton { padding: 5px 16px; border-radius: 4px; font-weight: bold;"
" background: #2a2a2a; color: #ccc; border: 1px solid #555; }"
"QPushButton:pressed { background: #333; }"));
}
}
private:
void fetchArt(const QJsonObject &img)
{
@@ -256,9 +296,12 @@ private:
QLabel *m_meta = nullptr;
QPushButton *m_playBtn = nullptr;
QPushButton *m_shuffleBtn = nullptr;
QPushButton *m_favBtn = nullptr;
QPushButton *m_followBtn = nullptr;
QNetworkAccessManager *m_nam = nullptr;
QString m_currentArtUrl;
QString m_albumId;
bool m_albumFaved = false;
qint64 m_artistId = 0;
qint64 m_playlistId = 0;
bool m_playlistFollowed = false;