X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/fdab9ee644c57d2039dd7bc6dfc3fbd8a75d13fa..0222d552811efb7049de2d024247b0b8eaeffe2b:/src/kitemviews/kitemlistwidget.cpp diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index 193422259..8e6c728f7 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -28,6 +28,7 @@ #include +#include #include #include #include @@ -119,12 +120,25 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o } if (isCurrent()) { - QStyleOptionViewItemV4 viewItemOption; - viewItemOption.initFrom(widget); - viewItemOption.rect = textRect().toRect(); - viewItemOption.state = QStyle::State_Enabled | QStyle::State_Item; - viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; - style()->drawPrimitive(QStyle::PE_FrameFocusRect, &viewItemOption, painter, widget); + QStyleOptionFocusRect focusRectOption; + focusRectOption.initFrom(widget); + + const QRect iconBounds = iconRect().toRect(); + const QRect textBounds = textRect().toRect(); + if (iconBounds.bottom() > textBounds.top()) { + focusRectOption.rect = textBounds; + } else { + // See KItemListWidget::drawItemStyleOption(): The selection rectangle + // gets decreased. + focusRectOption.rect = textBounds.adjusted(1, 1, -1, -1); + } + + focusRectOption.state = QStyle::State_Enabled | QStyle::State_Item | QStyle::State_KeyboardFocusChange; + if (m_selected) { + focusRectOption.state |= QStyle::State_Selected; + } + + style()->drawPrimitive(QStyle::PE_FrameFocusRect, &focusRectOption, painter, widget); } if (m_hoverOpacity > 0.0) { @@ -230,7 +244,8 @@ void KItemListWidget::setHovered(bool hovered) if (!m_hoverAnimation) { m_hoverAnimation = new QPropertyAnimation(this, "hoverOpacity", this); - m_hoverAnimation->setDuration(200); + const int duration = (KGlobalSettings::graphicEffectsLevel() == KGlobalSettings::NoEffects) ? 1 : 200; + m_hoverAnimation->setDuration(duration); connect(m_hoverAnimation, SIGNAL(finished()), this, SLOT(slotHoverAnimationFinished())); } m_hoverAnimation->stop(); @@ -424,18 +439,16 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS viewItemOption.initFrom(widget); viewItemOption.state = styleState; viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne; + viewItemOption.showDecorationSelected = true; - const bool drawMerged = (iconBounds.top() == textBounds.top() && - iconBounds.bottom() == textBounds.bottom()); - - if (drawMerged) { + if (iconBounds.bottom() > textBounds.top()) { viewItemOption.rect = iconBounds | textBounds; widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget); } else { viewItemOption.rect = iconBounds; widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget); - viewItemOption.rect = textBounds.adjusted(2, 2, -2, -2); + viewItemOption.rect = textBounds.adjusted(1, 1, -1, -1); widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget); } }