From df45e6efe0254fd17663c65191248f41f620be89 Mon Sep 17 00:00:00 2001 From: "James D. Smith" Date: Fri, 31 Dec 2021 21:55:02 -0700 Subject: [PATCH] Playlist: Grey invalid song entries when updating items. --- src/playlist/playlist.cpp | 15 ++++++++++----- src/playlist/playlist.h | 2 ++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp index fc41481f9..883a9f67b 100644 --- a/src/playlist/playlist.cpp +++ b/src/playlist/playlist.cpp @@ -173,6 +173,12 @@ Playlist::Playlist(PlaylistBackend* backend, TaskManager* task_manager, settings.endGroup(); + settings.beginGroup(kSettingsGroup); + + grey_unfound_ = settings.value("greyoutdeleted", false).toBool(); + + settings.endGroup(); + qLog(Debug) << "k_max_scrobble_point" << (max_play_count_point_nsecs_ / kNsecPerSec); } @@ -1223,6 +1229,9 @@ void Playlist::UpdateItems(const SongList& songs) { } else { new_item = PlaylistItemPtr(new SongPlaylistItem(song)); } + if (grey_unfound_ && !song.is_valid()) { + new_item->SetForegroundColor(kInvalidSongPriority, kInvalidSongColor); + } items_[i] = new_item; emit dataChanged(index(i, 0), index(i, ColumnCount - 1)); // Also update undo actions @@ -1626,11 +1635,7 @@ void Playlist::ItemsLoaded(QFuture future) { emit RestoreFinished(); - QSettings s; - s.beginGroup(kSettingsGroup); - - // should we gray out deleted songs asynchronously on startup? - if (s.value("greyoutdeleted", false).toBool()) { + if (grey_unfound_) { QtConcurrent::run(this, &Playlist::InvalidateDeletedSongs); } } diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 833f311cd..bf26384a7 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -471,6 +471,8 @@ class Playlist : public QAbstractListModel { // Cancel async restore if songs are already replaced bool cancel_restore_; + + bool grey_unfound_; }; // QDataStream& operator <<(QDataStream&, const Playlist*);