diff --git a/lintunes/__init__.py b/lintunes/__init__.py index 56f957e..eadbb55 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.91.2" +__version__ = "0.91.3" diff --git a/lintunes/gui/track_table.py b/lintunes/gui/track_table.py index 843e8ca..7101e1a 100644 --- a/lintunes/gui/track_table.py +++ b/lintunes/gui/track_table.py @@ -131,6 +131,15 @@ class ClickToJumpScrollStyle(QProxyStyle): return QRect(rect) return QRect() # SubLine / AddLine / First / Last: no arrows + def drawPrimitive(self, element, option, painter, widget=None): + if element == QStyle.PrimitiveElement.PE_FrameFocusRect and ( + isinstance(widget, QAbstractItemView) + or isinstance(widget and widget.parent(), QAbstractItemView)): + # A list shows what's chosen by highlighting the whole row; a + # box round the clicked cell on top of that says nothing more. + return + super().drawPrimitive(element, option, painter, widget) + def drawControl(self, element, option, painter, widget=None): if element == QStyle.ControlElement.CE_MenuBarEmptyArea: # Fusion rules a line under a main window's menu bar; the top diff --git a/tests/test_round127.py b/tests/test_round127.py new file mode 100644 index 0000000..9f75e2e --- /dev/null +++ b/tests/test_round127.py @@ -0,0 +1,26 @@ +"""Round 127: a list highlights the whole row and draws no focus box round +the clicked cell on top of it.""" +from PyQt6.QtWidgets import QTableWidget, QTableWidgetItem + +from lintunes.gui.track_table import ClickToJumpScrollStyle + + +def test_no_focus_box_round_the_clicked_cell(qapp): + style = ClickToJumpScrollStyle() + table = QTableWidget(3, 3) + table.setStyle(style) + table.resize(300, 150) + for r in range(3): + for c in range(3): + table.setItem(r, c, QTableWidgetItem(f"x{r}{c}")) + table.setSelectionBehavior(table.SelectionBehavior.SelectRows) + table.show() + table.setFocus() + table.setCurrentCell(1, 1) + qapp.processEvents() + img = table.viewport().grab().toImage() + rect = table.visualRect(table.model().index(1, 1)) + edge = {img.pixelColor(x, rect.top() + 1).name() + for x in range(rect.left(), rect.right())} + table.close() + assert len(edge) == 1, edge