Only autoscroll when track played

This commit is contained in:
Keith Edmunds 2022-09-07 19:47:51 +01:00
parent 27eba987ca
commit af11f90808

View File

@ -710,6 +710,7 @@ class PlaylistTab(QTableWidget):
next_row = self._find_next_track_row(session, search_from)
if next_row:
self._set_next(session, next_row)
self._scroll_to_top(next_row)
# Update display
self.update_display(session)
@ -1144,14 +1145,6 @@ class PlaylistTab(QTableWidget):
self._get_section_timing_string(section_time, no_end=True)
)
# Scroll to put next track Config.SCROLL_TOP_MARGIN from the
# top. Rows number from zero, so set (current_row -
# Config.SCROLL_TOP_MARGIN + 1) row to be top row
if next_row is not None:
top_row = max(0, next_row - Config.SCROLL_TOP_MARGIN + 1)
scroll_item = self.item(top_row, 0)
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop)
#
# # ########## Internally called functions ##########
@ -1653,6 +1646,17 @@ class PlaylistTab(QTableWidget):
subprocess.call(args)
def _scroll_to_top(self, row: int) -> None:
"""
Scroll to put passed row Config.SCROLL_TOP_MARGIN from the
top.
"""
if row is not None:
top_row = max(0, row - Config.SCROLL_TOP_MARGIN + 1)
scroll_item = self.item(top_row, 0)
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop)
def _select_event(self) -> None:
"""
Called when item selection changes.