Drop the tick from drop-lists; the row is already tinted

The selected row carries selection-background-color, so a checkmark repeats
what the colour says — and in a combo as wide as "VN" it repeated it on top of
the letters. A combo's default delegate paints menu-style, which is where the
glyph comes from; a plain QStyledItemDelegate paints item-view style, which has
none. widen_popup does both jobs now, so it is tidy_popup.

check_combo_popup additionally requires the delegate to be the plain one and the
stylesheet to still tint the current row — removing the delegate line fails it.

21/21 checkers pass.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Nam Pham Dinh Thanh
2026-08-18 15:03:39 +09:00
co-authored by Claude Opus 5
parent 509ae96854
commit 416d88d72f
3 changed files with 35 additions and 12 deletions
+15 -7
View File
@@ -162,17 +162,25 @@ def guard_wheel(root: QWidget) -> None:
w.installEventFilter(_wheel_guard)
def widen_popup(combo) -> None:
"""Give a drop-list room for its text AND the tick beside the current item.
def tidy_popup(combo) -> None:
"""Make a drop-list show its options and nothing else.
macOS draws a checkmark against the selected row; Windows does not. A combo
only as wide as "VN" therefore looked fine here and had its two letters
covered there. The popup inherits the combo's width unless told otherwise,
so measure what has to fit and say so.
Two platform habits to undo. macOS marks the current row with a checkmark,
drawn by the menu-style delegate a combo gets by default; the row is already
tinted by selection-background-color, so the tick says nothing twice and, in
a combo only as wide as "VN", covered the letters it was marking. Handing
the view a plain QStyledItemDelegate switches it to item-view painting,
where no such glyph exists.
And the popup inherits the combo's width unless told otherwise, which had
the project and provider names cut off here regardless of platform. So
measure the longest item — plus an indicator's worth of room, in case a
style still draws one — and set that as the view's minimum.
"""
from PySide6.QtWidgets import QStyle
from PySide6.QtWidgets import QStyle, QStyledItemDelegate
view = combo.view()
combo.setItemDelegate(QStyledItemDelegate(combo))
fm = view.fontMetrics()
longest = max((fm.horizontalAdvance(combo.itemText(i))
for i in range(combo.count())), default=0)