From a501441e6ee6a4bba3bbf9c0847b6ee9c0007197 Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Mon, 17 Mar 2025 21:32:37 +0000 Subject: [PATCH] Paint project item backgrounds with native style Signed-off-by: TheKodeToad --- launcher/ui/widgets/ProjectItem.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/launcher/ui/widgets/ProjectItem.cpp b/launcher/ui/widgets/ProjectItem.cpp index 6946df41f..f313b58e8 100644 --- a/launcher/ui/widgets/ProjectItem.cpp +++ b/launcher/ui/widgets/ProjectItem.cpp @@ -2,6 +2,7 @@ #include "Common.h" +#include #include #include @@ -16,12 +17,12 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o auto rect = opt.rect; - if (opt.state & QStyle::State_Selected) { - painter->fillRect(rect, opt.palette.highlight()); + const QStyle* style = opt.widget == nullptr ? QApplication::style() : opt.widget->style(); + + style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget); + + if (option.state & QStyle::State_Selected) painter->setPen(opt.palette.highlightedText().color()); - } else if (opt.state & QStyle::State_MouseOver) { - painter->fillRect(rect, opt.palette.window()); - } // The default icon size will be a square (and height is usually the lower value). auto icon_width = rect.height(), icon_height = rect.height();