From e1173edc1d5871b68ac579a96425dd3e4a4ecf24 Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Thu, 5 Jan 2012 20:13:49 +0100 Subject: [PATCH] Fix style-issues in items when not using Oxygen Thanks to Jonathan Marten and Christoph Feck for the analyses and the patch. Still open: The focus frame in cleanlooks is not drawn. CCBUG: 290536 --- src/kitemviews/kitemlistwidget.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index 4934da84f..61e06078b 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -119,26 +119,25 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o } if (isCurrent()) { - QStyleOptionViewItemV4 viewItemOption; - viewItemOption.initFrom(widget); + QStyleOptionFocusRect focusRectOption; + focusRectOption.initFrom(widget); const QRect iconBounds = iconRect().toRect(); const QRect textBounds = textRect().toRect(); if (iconBounds.bottom() > textBounds.top()) { - viewItemOption.rect = textBounds; + focusRectOption.rect = textBounds; } else { // See KItemListWidget::drawItemStyleOption(): The selection rectangle // gets decreased. - viewItemOption.rect = textBounds.adjusted(1, 1, -1, -1); + focusRectOption.rect = textBounds.adjusted(1, 1, -1, -1); } - viewItemOption.state = QStyle::State_Enabled | QStyle::State_Item; + focusRectOption.state = QStyle::State_Enabled | QStyle::State_Item; if (m_selected) { - viewItemOption.state |= QStyle::State_Selected; + focusRectOption.state |= QStyle::State_Selected; } - viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - style()->drawPrimitive(QStyle::PE_FrameFocusRect, &viewItemOption, painter, widget); + style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusRectOption, painter, widget); } if (m_hoverOpacity > 0.0) { @@ -438,6 +437,7 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS viewItemOption.initFrom(widget); viewItemOption.state = styleState; viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; + viewItemOption.showDecorationSelected = true; if (iconBounds.bottom() > textBounds.top()) { viewItemOption.rect = iconBounds | textBounds; -- 2.47.3