Compare commits

...

2 Commits

Author SHA1 Message Date
Keith Edmunds
5d3d373abc Update headers when editing current/next track
Fixes #126
2022-09-30 22:26:49 +01:00
Keith Edmunds
c3712eba27 Switch to correct tab when clicking on next/current header 2022-09-30 21:45:15 +01:00
2 changed files with 35 additions and 4 deletions

View File

@ -215,10 +215,8 @@ class Window(QMainWindow, Ui_MainWindow):
self.btnFade.clicked.connect(self.fade)
self.btnHidePlayed.clicked.connect(self.hide_played)
self.btnStop.clicked.connect(self.stop)
self.hdrCurrentTrack.clicked.connect(
lambda: self.tabPlaylist.currentWidget().scroll_current_to_top())
self.hdrNextTrack.clicked.connect(
lambda: self.tabPlaylist.currentWidget().scroll_next_to_top())
self.hdrCurrentTrack.clicked.connect(self.show_current)
self.hdrNextTrack.clicked.connect(self.show_next)
self.tabPlaylist.currentChanged.connect(
lambda: self.tabPlaylist.currentWidget().tab_visible())
self.tabPlaylist.tabCloseRequested.connect(self.close_tab)
@ -772,6 +770,20 @@ class Window(QMainWindow, Ui_MainWindow):
idx = self.tabPlaylist.indexOf(widget)
self.tabPlaylist.tabBar().setTabTextColor(idx, colour)
def show_current(self) -> None:
"""Scroll to show current track"""
if self.current_track_playlist_tab != self.visible_playlist_tab:
self.tabPlaylist.setCurrentWidget(self.current_track_playlist_tab)
self.tabPlaylist.currentWidget().scroll_current_to_top()
def show_next(self) -> None:
"""Scroll to show next track"""
if self.next_track_playlist_tab != self.visible_playlist_tab:
self.tabPlaylist.setCurrentWidget(self.next_track_playlist_tab)
self.tabPlaylist.currentWidget().scroll_next_to_top()
def stop(self) -> None:
"""Stop playing immediately"""
@ -937,6 +949,18 @@ class Window(QMainWindow, Ui_MainWindow):
if self.playing:
self.stop_playing()
def update_current_track(self, track):
"""Update current track with passed details"""
self.current_track = TrackData(track)
self.update_headers()
def update_next_track(self, track):
"""Update next track with passed details"""
self.next_track = TrackData(track)
self.update_headers()
def update_headers(self) -> None:
"""
Update last / current / next track headers

View File

@ -432,10 +432,17 @@ class PlaylistTab(QTableWidget):
if track_id:
track = session.get(Tracks, track_id)
if track:
update_current = row == self._get_current_track_row()
update_next = row == self._get_next_track_row()
if self.edit_cell_type == "title":
track.title = new_text
elif self.edit_cell_type == "artist":
track.artist = new_text
if update_current:
self.musicmuster.update_current_track(track)
elif update_next:
self.musicmuster.update_next_track(track)
# Headers will be incorrect if the edited track is
# previous / current / next TODO: this will require
# the stored data in musicmuster to be updated,