From 453fe87bf91c0781721e0a26bd6d807d7133ca7c Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Sun, 30 May 2021 21:51:23 +0100 Subject: [PATCH] Co-ordinate right-click play next - Fixes #2 --- app/musicmuster.py | 7 ++++--- app/playlists.py | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/musicmuster.py b/app/musicmuster.py index 23cb4fe..2a46b06 100755 --- a/app/musicmuster.py +++ b/app/musicmuster.py @@ -264,7 +264,7 @@ class Window(QMainWindow, Ui_MainWindow): the database object, get it populated and then add tab. """ - playlist_table = Playlist() + playlist_table = Playlist(self) playlist_table.db = playlist_db playlist_table.populate() idx = self.tabPlaylist.addTab(playlist_table, playlist_db.name) @@ -389,10 +389,11 @@ class Window(QMainWindow, Ui_MainWindow): playlist = Playlists.open(dlg.plid) self.load_playlist(playlist) - def set_next_track(self): + def set_next_track(self, next_track_id=None): "Set selected track as next" - next_track_id = self.visible_playlist().set_selected_as_next() + if not next_track_id: + next_track_id = self.visible_playlist().set_selected_as_next() if next_track_id: if self.next_track_playlist != self.visible_playlist(): if self.next_track_playlist: diff --git a/app/playlists.py b/app/playlists.py index 0bb872a..8612a05 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -37,6 +37,7 @@ class Playlist(QTableWidget): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + self.master_process = self.parent() self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) self.setAlternatingRowColors(True) self.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) @@ -642,12 +643,11 @@ class Playlist(QTableWidget): if row in self._meta_get_notes(): return None - if self.item(row, self.COL_INDEX): - self._meta_set_next(row) + track_id = self._get_row_id(row) + if track_id: + self._meta_set_next(self.currentRow()) self._repaint(save_playlist=False) - return self._get_row_id(row) - else: - return None + self.master_process.set_next_track(track_id) def _repaint(self, clear_selection=True, save_playlist=True): "Set row colours, fonts, etc, and save playlist"