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.
This commit is contained in:
2026-10-16 22:48:03 -07:00
parent d77a9fe7f9
commit ab25a6381b
3 changed files with 45 additions and 2 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
"""LinTunes — iTunes-style music library manager and player for Linux.""" """LinTunes — iTunes-style music library manager and player for Linux."""
__version__ = "0.58.0" __version__ = "0.58.1"
+25 -1
View File
@@ -3,7 +3,7 @@ import os
from PyQt6.QtWidgets import ( from PyQt6.QtWidgets import (
QTableView, QAbstractItemView, QMenu, QApplication, QProxyStyle, QStyle, QTableView, QAbstractItemView, QMenu, QApplication, QProxyStyle, QStyle,
QStyledItemDelegate, QStyleOptionViewItem, QStyledItemDelegate, QStyleOptionViewItem, QWidget,
) )
from PyQt6.QtCore import ( from PyQt6.QtCore import (
Qt, QAbstractTableModel, QModelIndex, QPersistentModelIndex, Qt, QAbstractTableModel, QModelIndex, QPersistentModelIndex,
@@ -677,6 +677,11 @@ class TrackTableView(QTableView):
header.customContextMenuRequested.connect(self._show_header_menu) header.customContextMenuRequested.connect(self._show_header_menu)
header.sortIndicatorChanged.connect(self._on_sort_indicator) header.sortIndicatorChanged.connect(self._on_sort_indicator)
header.sectionResized.connect(self._on_section_resized) 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.setContextMenuPolicy(Qt.ContextMenuPolicy.CustomContextMenu)
self.customContextMenuRequested.connect(self._show_context_menu) self.customContextMenuRequested.connect(self._show_context_menu)
@@ -1288,6 +1293,25 @@ class TrackTableView(QTableView):
self._drop_indicator_y = y self._drop_indicator_y = y
self.viewport().update() 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 ---- # ---- drag auto-scroll ----
def _update_autoscroll(self, pos: QPoint, accepted: bool): def _update_autoscroll(self, pos: QPoint, accepted: bool):
+19
View File
@@ -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()