Added history and improved marking of playing track.

This commit is contained in:
The Wobbler 2025-01-26 13:51:31 +01:00
parent 29f86e2196
commit 74bff6ea13
3 changed files with 48 additions and 14 deletions

View file

@ -19,12 +19,11 @@ class PlaylistView(QTreeWidget):
playlist.view = self
self.setDragDropMode(QAbstractItemView.DragDropMode.InternalMove)
#self.setAcceptDrops(True)
self.setSelectionMode(QAbstractItemView.SelectionMode.ExtendedSelection)
self.setColumnCount(4)
self.play_icon = QIcon.fromTheme(QIcon.ThemeIcon.MediaPlaybackStart)
self.playing_mark = QIcon.fromTheme(QIcon.ThemeIcon.MediaPlaybackStart)
headers = [
"",
@ -107,7 +106,7 @@ class PlaylistView(QTreeWidget):
i += 1
if not self.topLevelItemCount() == 0:
self.topLevelItem(0).setIcon(0, self.play_icon)
self.topLevelItem(0).setIcon(0, self.playing_mark)
def on_track_activation(self, item, column):
if not self.app.player.current_playlist == self.playlist:
@ -117,10 +116,16 @@ class PlaylistView(QTreeWidget):
self.app.player.play_track_in_playlist(index)
def on_track_change(self, previous_track, track):
# remove playing mark from first track bc it may not be in the history
self.topLevelItem(0).setIcon(0, QIcon(None))
# unmark the previous track and mark the current track as playing
if previous_track:
previous_track.item.setIcon(0, QIcon(None))
if track:
track.item.setIcon(0, self.play_icon)
track.item.setIcon(0, self.playing_mark)
def append_track(self, track):
TrackItem(track, self.topLevelItemCount() - 1, self)