┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorEvgeniy Harchenko <[email protected]>2026-05-08 08:14:54 +0000
committerMéven Car <[email protected]>2026-05-08 08:14:54 +0000
commita2f56f7ccf5cd41c9286970280bbf29ff2bc96b0 (patch)
treeb318b6bad949f52d9365bfd81c0b49c8cce9148e /src/kitemviews
parent2c5b241551a52fa9a72b4832e883db9a67cdf7dd (diff)
KItemListWidget: stop overriding style‑provided background brushHEADmaster
The previous implementation forced a custom background colour before delegating to the style's PE_PanelItemViewItem primitive. This interferes with theme‑specific drawing and results in a hard‑coded, non‑themed highlight that breaks styling across themes. Remove the explicit brush assignment, allowing the style to paint the background itself. The focus rectangle handling remains unchanged and is still drawn only for the active item. And pass the State_MouseOver to focus rect style option when hovered.
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kitemlistwidget.cpp33
1 files changed, 17 insertions, 16 deletions
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
index b94cf6064..32118c569 100644
--- a/src/kitemviews/kitemlistwidget.cpp
+++ b/src/kitemviews/kitemlistwidget.cpp
@@ -623,21 +623,6 @@ void KItemListWidget::setPressed(bool enabled)
void KItemListWidget::drawItemStyleOption(QPainter *painter, QWidget *widget, QStyle::State styleState)
{
painter->save();
- // Shared between both Breeze and other styles
- QColor backgroundColor{widget->palette().color(QPalette::Highlight)};
- 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);
- }
- }
QStyleOptionViewItem viewItemOption;
initStyleOption(&viewItemOption);
viewItemOption.state = styleState;
@@ -649,6 +634,20 @@ void KItemListWidget::drawItemStyleOption(QPainter *painter, QWidget *widget, QS
// TODO: Remove this check after Plasma 6.8 release
// See: https://invent.kde.org/plasma/breeze/-/merge_requests/595
if (style()->name() == QStringLiteral("breeze")) {
+ QColor backgroundColor{widget->palette().color(QPalette::Highlight)};
+ 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->setRenderHint(QPainter::Antialiasing);
constexpr int roundness = 5; // From Breeze style.
constexpr qreal penWidth = 1.25;
@@ -668,7 +667,6 @@ void KItemListWidget::drawItemStyleOption(QPainter *painter, QWidget *widget, QS
painter->strokePath(path, pen);
}
} else {
- viewItemOption.backgroundBrush = backgroundColor;
style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
// Focus decoration
@@ -679,6 +677,9 @@ void KItemListWidget::drawItemStyleOption(QPainter *painter, QWidget *widget, QS
if (m_selected && widget->hasFocus()) {
focusRectOption.state = QStyle::State_HasFocus | QStyle::State_Selected;
}
+ if (m_hovered) {
+ focusRectOption.state |= QStyle::State_MouseOver;
+ }
focusRectOption.rect = viewItemOption.rect;
style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusRectOption, painter, widget);
}