From 19377a8e1c52cc0c842390f7d0c62beaf921216f Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sun, 19 Feb 2023 20:26:55 +0000 Subject: [PATCH] WIP: playlists.py refactor Reset background colour of current track when track ended. --- app/musicmuster.py | 15 +++++++++------ app/playlists.py | 9 +++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/musicmuster.py b/app/musicmuster.py index df01f68..d799124 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -722,17 +722,20 @@ class Window(QMainWindow, Ui_MainWindow): # doesn't see player=None and kick off end-of-track actions self.playing = False + # Remove currently playing track colour + if ( + self.current_track and + self.current_track.playlist_tab and + self.current_track.plr_id + ): + self.current_track.playlist_tab.reset_plr_row_colour( + self.current_track.plr_id) + # Reset PlaylistTrack objects if self.current_track.track_id: self.previous_track = self.current_track self.current_track = PlaylistTrack() - # Repaint playlist to remove currently playing track colour - # What was current track is now previous track - with Session() as session: - if self.previous_track.playlist_tab: - self.previous_track.playlist_tab.update_display(session) - # Reset clocks self.frame_fade.setStyleSheet("") self.frame_silent.setStyleSheet("") diff --git a/app/playlists.py b/app/playlists.py index 1c4eeae..7ac73a1 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -830,6 +830,15 @@ class PlaylistTab(QTableWidget): # Reset drag mode self.setDragEnabled(False) + def reset_plr_row_colour(self, plr_id: int) -> None: + """Reset background of row pointed to by plr_id""" + + row = self._plrid_to_row_number(plr_id) + if not row: + return + + self._set_row_colour(row, None) + def save_playlist(self, session: scoped_session) -> None: """ Get the PlaylistRow objects for each row in the display. Correct