From ab25a6381b5a293b3ea68b36942c27f1c53dc64f Mon Sep 17 00:00:00 2001 From: trav Date: Fri, 16 Oct 2026 22:48:03 -0700 Subject: [PATCH] v0.58.1: the track list's headings run over the scrollbar's column The vertical scrollbar now starts under the headings instead of beside them, so the last heading gets the scrollbar's width back. --- lintunes/__init__.py | 2 +- lintunes/gui/track_table.py | 26 +++++++++++++++++++++++++- tests/test_round90.py | 19 +++++++++++++++++++ 3 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 tests/test_round90.py diff --git a/lintunes/__init__.py b/lintunes/__init__.py index 5260d18..8ec2552 100644 --- a/lintunes/__init__.py +++ b/lintunes/__init__.py @@ -1,3 +1,3 @@ """LinTunes — iTunes-style music library manager and player for Linux.""" -__version__ = "0.58.0" +__version__ = "0.58.1" diff --git a/lintunes/gui/track_table.py b/lintunes/gui/track_table.py index fa43006..f7c902b 100644 --- a/lintunes/gui/track_table.py +++ b/lintunes/gui/track_table.py @@ -3,7 +3,7 @@ import os from PyQt6.QtWidgets import ( QTableView, QAbstractItemView, QMenu, QApplication, QProxyStyle, QStyle, - QStyledItemDelegate, QStyleOptionViewItem, + QStyledItemDelegate, QStyleOptionViewItem, QWidget, ) from PyQt6.QtCore import ( Qt, QAbstractTableModel, QModelIndex, QPersistentModelIndex, @@ -677,6 +677,11 @@ class TrackTableView(QTableView): header.customContextMenuRequested.connect(self._show_header_menu) header.sortIndicatorChanged.connect(self._on_sort_indicator) header.sectionResized.connect(self._on_section_resized) + # The headings run the full width, over the scrollbar's column: a + # blank widget as tall as the header sits on top of the scrollbar, + # and updateGeometries widens the header across both. + self._bar_cap = QWidget() + self.addScrollBarWidget(self._bar_cap, Qt.AlignmentFlag.AlignTop) self.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu) self.customContextMenuRequested.connect(self._show_context_menu) @@ -1288,6 +1293,25 @@ class TrackTableView(QTableView): self._drop_indicator_y = y self.viewport().update() + def updateGeometries(self): + super().updateGeometries() + header = self.horizontalHeader() + if header.isHidden() or not hasattr(self, "_bar_cap"): + return # (Qt lays out once before __init__ is done) + self._bar_cap.setFixedHeight(header.height()) + bar = self.verticalScrollBar() + extra = bar.parentWidget().width() if bar.isVisible() else 0 + geometry = header.geometry() + width = self.viewport().width() + extra + if geometry.width() != width: + header.setGeometry(geometry.x(), geometry.y(), width, + geometry.height()) + header.raise_() + if extra and header.length() <= width: + # Only the stretched last heading reaches past the rows; that + # overhang sits over the scrollbar and isn't anything to scroll to. + self.horizontalScrollBar().setRange(0, 0) + # ---- drag auto-scroll ---- def _update_autoscroll(self, pos: QPoint, accepted: bool): diff --git a/tests/test_round90.py b/tests/test_round90.py new file mode 100644 index 0000000..d9a07f4 --- /dev/null +++ b/tests/test_round90.py @@ -0,0 +1,19 @@ +"""Round 90: the track list's headings run over the scrollbar's column.""" + +from lintunes.gui.track_table import TrackTableView +from tests.test_round29 import _local_track + + +def test_headings_span_the_scrollbar_and_dont_scroll_sideways(qapp, tmp_path): + view = TrackTableView() + view.model_.set_tracks([_local_track(tmp_path, i) for i in range(1, 80)]) + view.resize(2400, 300) + view.show() + qapp.processEvents() + bar = view.verticalScrollBar() + assert bar.isVisible() + header = view.horizontalHeader() + assert header.geometry().right() == bar.parentWidget().geometry().right() + assert bar.geometry().top() >= header.height() # starts under them + assert view.horizontalScrollBar().maximum() == 0 + view.close()