WIP V3: click on current/next header scrolls to track
This commit is contained in:
parent
04f0e95653
commit
3cab9f737c
@ -1298,11 +1298,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
def show_current(self) -> None:
|
||||
"""Scroll to show current track"""
|
||||
|
||||
return
|
||||
# TODO Reimplement
|
||||
# if self.current_track.playlist_tab != self.active_tab():
|
||||
# self.tabPlaylist.setCurrentWidget(self.current_track.playlist_tab)
|
||||
# self.tabPlaylist.currentWidget().scroll_current_to_top()
|
||||
self.show_track(track_sequence.now)
|
||||
|
||||
def show_warning(self, title: str, body: str) -> None:
|
||||
"""
|
||||
@ -1315,11 +1311,7 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
def show_next(self) -> None:
|
||||
"""Scroll to show next track"""
|
||||
|
||||
return
|
||||
# TODO Reimplement
|
||||
# if self.next_track.playlist_tab != self.active_tab():
|
||||
# self.tabPlaylist.setCurrentWidget(self.next_track.playlist_tab)
|
||||
# self.tabPlaylist.currentWidget().scroll_next_to_top()
|
||||
self.show_track(track_sequence.next)
|
||||
|
||||
def show_status_message(self, message: str, timing: int) -> None:
|
||||
"""
|
||||
@ -1328,6 +1320,23 @@ class Window(QMainWindow, Ui_MainWindow):
|
||||
|
||||
self.statusbar.showMessage(message, timing)
|
||||
|
||||
def show_track(self, plt: PlaylistTrack) -> None:
|
||||
"""Scroll to show track in plt"""
|
||||
|
||||
# Switch to the correct tab
|
||||
plt_playlist_id = plt.playlist_id
|
||||
if not plt_playlist_id:
|
||||
# No playlist
|
||||
return
|
||||
|
||||
if plt_playlist_id != self.active_tab().playlist_id:
|
||||
for idx in range(self.tabPlaylist.count()):
|
||||
if self.tabPlaylist.widget(idx).playlist_id == plt_playlist_id:
|
||||
self.tabPlaylist.setCurrentIndex(idx)
|
||||
break
|
||||
|
||||
self.tabPlaylist.currentWidget().scroll_to_top(plt.plr_rownum)
|
||||
|
||||
def solicit_playlist_name(
|
||||
self, session: scoped_session, default: str = ""
|
||||
) -> Optional[str]:
|
||||
|
||||
@ -434,14 +434,14 @@ class PlaylistTab(QTableView):
|
||||
# def scroll_current_to_top(self) -> None:
|
||||
# """Scroll currently-playing row to top"""
|
||||
|
||||
# current_row = self._get_current_track_row_number()
|
||||
# current_row = track_sequence.now.plr_rownum
|
||||
# if current_row is not None:
|
||||
# self._scroll_to_top(current_row)
|
||||
|
||||
# def scroll_next_to_top(self) -> None:
|
||||
# """Scroll nextly-playing row to top"""
|
||||
|
||||
# next_row = self._get_next_track_row_number()
|
||||
# next_row = track_sequence.now.plr_rownum
|
||||
# if next_row is not None:
|
||||
# self._scroll_to_top(next_row)
|
||||
|
||||
@ -902,7 +902,7 @@ class PlaylistTab(QTableView):
|
||||
|
||||
subprocess.call(args)
|
||||
|
||||
def _scroll_to_top(self, row_number: int) -> None:
|
||||
def scroll_to_top(self, row_number: int) -> None:
|
||||
"""
|
||||
Scroll to put passed row_number Config.SCROLL_TOP_MARGIN from the
|
||||
top.
|
||||
@ -911,24 +911,8 @@ class PlaylistTab(QTableView):
|
||||
if row_number is None:
|
||||
return
|
||||
|
||||
padding_required = Config.SCROLL_TOP_MARGIN
|
||||
top_row = row_number
|
||||
|
||||
if row_number > Config.SCROLL_TOP_MARGIN:
|
||||
# We can't scroll to a hidden row. Calculate target_row as
|
||||
# the one that is ideal to be at the top. Then count upwards
|
||||
# from passed row_number until we either reach the target,
|
||||
# pass it or reach row_number 0.
|
||||
for i in range(row_number - 1, -1, -1):
|
||||
if self.isRowHidden(i):
|
||||
continue
|
||||
if padding_required == 0:
|
||||
break
|
||||
top_row = i
|
||||
padding_required -= 1
|
||||
|
||||
scroll_item = self.item(top_row, 0)
|
||||
self.scrollToItem(scroll_item, QAbstractItemView.ScrollHint.PositionAtTop)
|
||||
row_index = self.proxy_model.index(row_number, 0)
|
||||
self.scrollTo(row_index, QAbstractItemView.ScrollHint.PositionAtTop)
|
||||
|
||||
# def _search(self, next: bool = True) -> None:
|
||||
# """
|
||||
|
||||
Loading…
Reference in New Issue
Block a user