From 87e2f33f5918efab3e43c56d63b5c046d5f083d4 Mon Sep 17 00:00:00 2001 From: Keith Edmunds Date: Mon, 15 Aug 2022 15:31:26 +0100 Subject: [PATCH] Scroll to put next, not current, track at top --- app/playlists.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/app/playlists.py b/app/playlists.py index e428b73..d294671 100644 --- a/app/playlists.py +++ b/app/playlists.py @@ -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 ##########