┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorFilip Fila <[email protected]>2026-04-02 12:18:30 +0000
committerMéven Car <[email protected]>2026-04-02 12:18:30 +0000
commit6e48c057b9595427ee0a5c245c7c98b2817ff2ab (patch)
treefccd82c606a889408889a444f94c434ddbdffb70 /src/kitemviews
parente865a1a33cd23fd8ec55315694152262731f727c (diff)
dolphin/kitemlistwidget: Fix full selected state persisting on deselect with non-Breeze QStyles
For non-Breeze QStyles Dolphin is currently drawing the full highlight effect for items even when they are deselected. The issues is that it treats keyboard focus as the same state as a selected state, resulting in a persisting highlight effect. This patch adds and extra check to paint `State_Selected` only when `m_selected` is true, thereby fixing the problem. **TEST PLAN** Tested with Oxygen, Fusion, Kvantum, Darkly, MS Windows 9x. - all of the styles had the issue with the full selected state persisting on mouse deselect - after this change all of the styles lost the full selected state and retained only their keyboard focus state **SCREENSHOTS** Before (MS Windows 9x): ![2026-03-29_21-42-03](/uploads/b369a63acb817a2b79e769a7c99a0378/2026-03-29_21-42-03.mp4) After (MS Windows 9x): ![2026-03-29_21-40-54](/uploads/b65230529dee7b552d58a1139353eca9/2026-03-29_21-40-54.mp4)
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kitemlistwidget.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
index 7d43a0c14..b94cf6064 100644
--- a/src/kitemviews/kitemlistwidget.cpp
+++ b/src/kitemviews/kitemlistwidget.cpp
@@ -121,9 +121,13 @@ void KItemListWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
painter->fillRect(backgroundRect, backgroundColor);
}
+ const QStyle::State selectedState(m_selected ? QStyle::State_Selected : QStyle::State(0));
if ((m_selected || m_current) && m_editedRole.isEmpty()) {
const QStyle::State activeState(isActiveWindow() && widget->hasFocus() ? QStyle::State_Active : 0);
- drawItemStyleOption(painter, widget, activeState | QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item);
+ // Only pass State_Selected when the item is actually selected, not just when
+ // it has keyboard focus (m_current), to avoid styles drawing a persistent
+ // selection highlight on focused but unselected items.
+ drawItemStyleOption(painter, widget, activeState | selectedState | QStyle::State_Enabled | QStyle::State_Item);
}
if (m_hoverOpacity > 0.0) {
@@ -135,7 +139,7 @@ void KItemListWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
QPainter pixmapPainter(m_hoverCache);
const QStyle::State activeState(isActiveWindow() && widget->hasFocus() ? QStyle::State_Active | QStyle::State_Enabled : 0);
- drawItemStyleOption(&pixmapPainter, widget, activeState | QStyle::State_MouseOver | QStyle::State_Item);
+ drawItemStyleOption(&pixmapPainter, widget, activeState | selectedState | QStyle::State_MouseOver | QStyle::State_Item);
}
const qreal opacity = painter->opacity();
@@ -231,6 +235,7 @@ void KItemListWidget::setSelected(bool selected)
m_selectionToggle->setChecked(selected);
}
selectedChanged(selected);
+ clearHoverCache();
update();
}
}