┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorAkseli Lahtinen <[email protected]>2025-08-18 14:40:43 +0300
committerAkseli Lahtinen <[email protected]>2025-08-18 19:20:06 +0300
commit361a65d3fd3f3da217748b845875d4de3464e9a5 (patch)
treee85d27788a10be6c0e6500cffdf6ff29a1d26f74 /src/kitemviews
parent977552ea0792b2f56b7a4c1a6f585446c25617c2 (diff)
KItemListWidget: Use strokePath instead of drawPath
StrokePath gives the focus frame a less blurry look Since the path is bit thinner now, we need to adjust the alpha level to make it easier to see. This is especially visible in dark themes. BUG: 507005
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kitemlistwidget.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp
index c06e46339..154196a3c 100644
--- a/src/kitemviews/kitemlistwidget.cpp
+++ b/src/kitemviews/kitemlistwidget.cpp
@@ -623,14 +623,15 @@ void KItemListWidget::drawItemStyleOption(QPainter *painter, QWidget *widget, QS
{
QStyleOptionViewItem viewItemOption;
constexpr int roundness = 5; // From Breeze style.
- constexpr qreal penWidth = 1.5;
+ constexpr qreal penWidth = 1.25;
initStyleOption(&viewItemOption);
viewItemOption.state = styleState;
viewItemOption.viewItemPosition = QStyleOptionViewItem::OnlyOne;
viewItemOption.showDecorationSelected = true;
viewItemOption.rect = selectionRectFull().toRect();
QPainterPath path;
- path.addRoundedRect(selectionRectFull().adjusted(penWidth, penWidth, -penWidth, -penWidth), roundness, roundness);
+ const qreal adjustment = 0.5 * penWidth; // Use same adjustments as Breeze strokedRect uses, to snap to pixelGrid.
+ path.addRoundedRect(selectionRectFull().adjusted(adjustment, adjustment, -adjustment, -adjustment), roundness, roundness);
QColor backgroundColor{widget->palette().color(QPalette::Accent)};
painter->setRenderHint(QPainter::Antialiasing);
bool current = m_current && styleState & QStyle::State_Active;
@@ -658,12 +659,11 @@ void KItemListWidget::drawItemStyleOption(QPainter *painter, QWidget *widget, QS
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);
+ focusColor.setAlphaF(m_selected || m_hovered ? 1.0 : 0.8);
// Set the pen color lighter or darker depending on background color
QPen pen{focusColor, penWidth};
pen.setCosmetic(true);
- painter->setPen(pen);
- painter->drawPath(path);
+ painter->strokePath(path, pen);
}
}