Scroll to put next, not current, track at top

This commit is contained in:
Keith Edmunds 2022-08-15 15:31:26 +01:00
parent 92bdf216ca
commit 87e2f33f59

View File

@ -623,7 +623,7 @@ class PlaylistTab(QTableWidget):
- Note start time
- Mark next-track row as current
- Mark current row as played
- Scroll to put current track as required
- Scroll to put next track as required
- Set next track
- Update display
"""
@ -640,14 +640,6 @@ class PlaylistTab(QTableWidget):
# Mark current row as played
self._set_played_row(session, current_row)
# Scroll to put current 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
top_row = max(0, current_row - Config.SCROLL_TOP_MARGIN + 1)
scroll_item = self.item(top_row, 0)
self.scrollToItem(scroll_item, QAbstractItemView.PositionAtTop)
# Set next track
search_from = current_row + 1
next_row = self._find_next_track_row(session, search_from)
@ -1074,6 +1066,16 @@ class PlaylistTab(QTableWidget):
section_start_plr,
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 ##########