+ viewItemOption.rect = selectionRectFull().toRect();
+ QPainterPath path;
+ path.addRoundedRect(selectionRectFull().adjusted(penWidth, penWidth, -penWidth, -penWidth), roundness, roundness);
+ QColor backgroundColor{widget->palette().color(QPalette::Accent)};
+ painter->setRenderHint(QPainter::Antialiasing);
+ bool current = m_current && styleState & QStyle::State_Active;
+
+ // Background item, alpha values are from
+ // https://invent.kde.org/plasma/libplasma/-/blob/master/src/desktoptheme/breeze/widgets/viewitem.svg
+ backgroundColor.setAlphaF(0.0);
+
+ if (m_clickHighlighted) {
+ backgroundColor.setAlphaF(1.0);
+ } else {
+ if (m_selected && m_hovered) {
+ backgroundColor.setAlphaF(0.40);
+ } else if (m_selected) {
+ backgroundColor.setAlphaF(0.32);
+ } else if (m_hovered) {
+ backgroundColor = widget->palette().color(QPalette::Text);
+ backgroundColor.setAlphaF(0.06);
+ }
+ }
+
+ painter->fillPath(path, backgroundColor);
+
+ // Focus decoration
+ if (current) {
+ QColor focusColor{widget->palette().color(QPalette::Accent)};
+ focusColor = m_styleOption.palette.color(QPalette::Base).lightnessF() > 0.5 ? focusColor.darker(110) : focusColor.lighter(110);
+ focusColor.setAlphaF(m_selected || m_hovered ? 0.8 : 0.6);
+ // Set the pen color lighter or darker depending on background color
+ QPen pen{focusColor, penWidth};
+ pen.setCosmetic(true);
+ painter->setPen(pen);
+ painter->drawPath(path);
+ }