Switch to correct tab when clicking on next/current header

This commit is contained in:
Keith Edmunds 2022-09-30 21:45:15 +01:00
parent 1da0668807
commit c3712eba27

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"""