feat: refresh views on all playlist mutations
- Add EV_PLAYLIST_TRACK_ADDED (22) — emitted when a track is successfully added to a playlist - If the currently-open playlist is the one modified, re-fetch it so the track appears in the list immediately - After creating a playlist, open it automatically so the user lands in the new (empty) playlist view right away - Sidebar already refreshes on create/delete; this ensures the track list view also stays in sync Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -80,7 +80,13 @@ MainWindow::MainWindow(QobuzBackend *backend, QWidget *parent)
|
||||
connect(m_backend, &QobuzBackend::playlistLoaded, this, &MainWindow::onPlaylistLoaded);
|
||||
connect(m_backend, &QobuzBackend::playlistCreated, this, &MainWindow::onPlaylistCreated);
|
||||
connect(m_backend, &QobuzBackend::playlistDeleted, this, [this](const QJsonObject &) {
|
||||
statusBar()->showMessage(tr("Playlist deleted"), 3000);
|
||||
// status bar message is also shown by library's openPlaylistDeleted handler
|
||||
});
|
||||
connect(m_backend, &QobuzBackend::playlistTrackAdded, this, [this](qint64 playlistId) {
|
||||
// Refresh the currently shown playlist if a track was added to it
|
||||
if (m_content->tracksList()->playlistId() == playlistId)
|
||||
m_backend->getPlaylist(playlistId);
|
||||
statusBar()->showMessage(tr("Track added to playlist"), 3000);
|
||||
});
|
||||
connect(m_backend, &QobuzBackend::trackChanged, this, &MainWindow::onTrackChanged);
|
||||
connect(m_backend, &QobuzBackend::error, this, [this](const QString &msg) {
|
||||
@@ -337,8 +343,12 @@ void MainWindow::onSearchToggled(bool visible)
|
||||
|
||||
void MainWindow::onPlaylistCreated(const QJsonObject &playlist)
|
||||
{
|
||||
statusBar()->showMessage(
|
||||
tr("Playlist '%1' created").arg(playlist["name"].toString()), 4000);
|
||||
const QString name = playlist["name"].toString();
|
||||
statusBar()->showMessage(tr("Playlist '%1' created").arg(name), 4000);
|
||||
// Open the new playlist immediately
|
||||
const qint64 id = static_cast<qint64>(playlist["id"].toDouble());
|
||||
if (id > 0)
|
||||
m_backend->getPlaylist(id);
|
||||
}
|
||||
|
||||
void MainWindow::onUserPlaylistsChanged(const QVector<QPair<qint64, QString>> &playlists)
|
||||
|
||||
Reference in New Issue
Block a user