feat: add playlist browse/search discovery and follow controls
Some checks failed
Build for Windows / build-windows (push) Has been cancelled
Some checks failed
Build for Windows / build-windows (push) Has been cancelled
This commit is contained in:
@@ -127,6 +127,18 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
||||
m_backend->getPlaylist(playlistId);
|
||||
statusBar()->showMessage(tr("Track added to playlist"), 3000);
|
||||
});
|
||||
connect(m_backend, &QobuzBackend::playlistSubscribed, this, [this](qint64 playlistId) {
|
||||
m_library->refresh();
|
||||
if (m_content->tracksList()->playlistId() == playlistId)
|
||||
m_content->setCurrentPlaylistFollowed(true);
|
||||
statusBar()->showMessage(tr("Playlist followed"), 3000);
|
||||
});
|
||||
connect(m_backend, &QobuzBackend::playlistUnsubscribed, this, [this](qint64 playlistId) {
|
||||
m_library->refresh();
|
||||
if (m_content->tracksList()->playlistId() == playlistId)
|
||||
m_content->setCurrentPlaylistFollowed(false);
|
||||
statusBar()->showMessage(tr("Playlist unfollowed"), 3000);
|
||||
});
|
||||
connect(m_backend, &QobuzBackend::trackChanged, this, &MainWindow::onTrackChanged);
|
||||
connect(m_backend, &QobuzBackend::error, this, [this](const QString &msg) {
|
||||
statusBar()->showMessage(tr("Error: %1").arg(msg), 6000);
|
||||
@@ -210,6 +222,10 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
||||
m_content->showGenreBrowser();
|
||||
statusBar()->showMessage(tr("Browse Genres"));
|
||||
});
|
||||
connect(m_library, &List::Library::browsePlaylistsRequested, this, [this] {
|
||||
m_content->showPlaylistBrowser();
|
||||
statusBar()->showMessage(tr("Browse Playlists"));
|
||||
});
|
||||
|
||||
// ---- Track list → playback / playlist management ----
|
||||
connect(m_content->tracksList(), &List::Tracks::playTrackRequested,
|
||||
@@ -243,6 +259,18 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
||||
this, &MainWindow::onSearchAlbumSelected);
|
||||
connect(m_content, &MainContent::artistRequested,
|
||||
this, &MainWindow::onSearchArtistSelected);
|
||||
connect(m_content, &MainContent::playlistRequested,
|
||||
this, [this](qint64 playlistId) {
|
||||
m_backend->getPlaylist(playlistId);
|
||||
statusBar()->showMessage(tr("Loading playlist…"));
|
||||
});
|
||||
connect(m_content, &MainContent::playlistFollowToggled,
|
||||
this, [this](qint64 playlistId, bool follow) {
|
||||
if (follow)
|
||||
m_backend->subscribePlaylist(playlistId);
|
||||
else
|
||||
m_backend->unsubscribePlaylist(playlistId);
|
||||
});
|
||||
connect(m_content, &MainContent::playTrackRequested,
|
||||
this, &MainWindow::onPlayTrackRequested);
|
||||
|
||||
@@ -462,7 +490,20 @@ void MainWindow::onArtistLoaded(const QJsonObject &artist)
|
||||
|
||||
void MainWindow::onPlaylistLoaded(const QJsonObject &playlist)
|
||||
{
|
||||
m_content->showPlaylist(playlist);
|
||||
const qint64 id = static_cast<qint64>(playlist["id"].toDouble());
|
||||
const qint64 ownerId = static_cast<qint64>(playlist["owner"].toObject()["id"].toDouble());
|
||||
const qint64 myId = AppSettings::instance().userId();
|
||||
const bool isOwned = (myId > 0 && ownerId == myId);
|
||||
|
||||
bool isFollowed = false;
|
||||
for (const auto &pl : m_userPlaylists) {
|
||||
if (pl.first == id) {
|
||||
isFollowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_content->showPlaylist(playlist, isFollowed, isOwned);
|
||||
statusBar()->showMessage(
|
||||
tr("Playlist: %1").arg(playlist["name"].toString()), 4000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user