mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-04-29 22:24:26 +02:00
Paint project item backgrounds with native style
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
d0b9073f60
commit
a501441e6e
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "Common.h"
|
#include "Common.h"
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
|
||||||
@ -16,12 +17,12 @@ void ProjectItemDelegate::paint(QPainter* painter, const QStyleOptionViewItem& o
|
|||||||
|
|
||||||
auto rect = opt.rect;
|
auto rect = opt.rect;
|
||||||
|
|
||||||
if (opt.state & QStyle::State_Selected) {
|
const QStyle* style = opt.widget == nullptr ? QApplication::style() : opt.widget->style();
|
||||||
painter->fillRect(rect, opt.palette.highlight());
|
|
||||||
|
style->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, opt.widget);
|
||||||
|
|
||||||
|
if (option.state & QStyle::State_Selected)
|
||||||
painter->setPen(opt.palette.highlightedText().color());
|
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).
|
// The default icon size will be a square (and height is usually the lower value).
|
||||||
auto icon_width = rect.height(), icon_height = rect.height();
|
auto icon_width = rect.height(), icon_height = rect.height();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user