Paint project item backgrounds with native style

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2025-03-17 21:32:37 +00:00
parent d0b9073f60
commit a501441e6e
No known key found for this signature in database
GPG Key ID: 5E39D70B4C93C38E

View File

@ -2,6 +2,7 @@
#include "Common.h"
#include <QApplication>
#include <QIcon>
#include <QPainter>
@ -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();