Skip to content

Commit a39ae59

Browse files
committed
[FIX] All icons are reactive to selection state if using FThumbnailDelegate
1 parent 78a0bbf commit a39ae59

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

fxgui/fxwidgets/_delegates.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,19 @@ def _draw_text(
14311431
icon_x = option.rect.left() + icon_margin
14321432
icon_y = option.rect.top() + (option.rect.height() - icon_size) // 2
14331433
icon_rect = QRect(icon_x, icon_y, icon_size, icon_size)
1434-
icon.paint(painter, icon_rect, Qt.AlignCenter)
1434+
1435+
# Use QIcon's built-in modes for automatic color switching
1436+
# Icons created with get_icon() have Selected/Active pixmaps
1437+
if option.state & QStyle.State_Selected:
1438+
icon.paint(
1439+
painter, icon_rect, Qt.AlignCenter, QIcon.Selected, QIcon.On
1440+
)
1441+
elif option.state & QStyle.State_MouseOver:
1442+
icon.paint(
1443+
painter, icon_rect, Qt.AlignCenter, QIcon.Active, QIcon.On
1444+
)
1445+
else:
1446+
icon.paint(painter, icon_rect)
14351447
text_x = icon_x + icon_size + icon_margin
14361448

14371449
# Draw text

0 commit comments

Comments
 (0)