mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-21 17:30:15 +00:00
Improve drawing selected items in Compact/Details View and Places Panel
This commit removes the icon tinting for the selected item in Compact and Details View, and extends the selection rectangle such that it includes the icon area as well. The icon tinting can be disturbing, and having a selection rectangle that only includes the text can look a bit strange, especially in the Places Panel. BUG: 304643 REVIEW: 119018 FIXED-IN: 4.14.0
This commit is contained in:
parent
4d8f89f55a
commit
20e13c31df
|
@ -522,7 +522,7 @@ void KItemListWidget::drawItemStyleOption(QPainter* painter, QWidget* widget, QS
|
|||
viewItemOption.state = styleState;
|
||||
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
|
||||
viewItemOption.showDecorationSelected = true;
|
||||
viewItemOption.rect = textRect().toRect();
|
||||
viewItemOption.rect = selectionRect().toRect();
|
||||
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
|
||||
}
|
||||
|
||||
|
|
|
@ -163,6 +163,11 @@ public:
|
|||
*/
|
||||
virtual QRectF textFocusRect() const;
|
||||
|
||||
/**
|
||||
* @return Rectangle around which a selection box should be drawn if the item is selected.
|
||||
*/
|
||||
virtual QRectF selectionRect() const = 0;
|
||||
|
||||
/**
|
||||
* @return Rectangle for the selection-toggle that is used to select or deselect an item.
|
||||
* Per default an empty rectangle is returned which means that no selection-toggle
|
||||
|
|
|
@ -494,6 +494,29 @@ QRectF KStandardItemListWidget::textFocusRect() const
|
|||
return m_textRect;
|
||||
}
|
||||
|
||||
QRectF KStandardItemListWidget::selectionRect() const
|
||||
{
|
||||
const_cast<KStandardItemListWidget*>(this)->triggerCacheRefreshing();
|
||||
|
||||
switch (m_layout) {
|
||||
case IconsLayout:
|
||||
return m_textRect;
|
||||
|
||||
case CompactLayout:
|
||||
case DetailsLayout: {
|
||||
const int padding = styleOption().padding;
|
||||
QRectF adjustedIconRect = iconRect().adjusted(-padding, -padding, padding, padding);
|
||||
return adjustedIconRect | m_textRect;
|
||||
}
|
||||
|
||||
default:
|
||||
Q_ASSERT(false);
|
||||
break;
|
||||
}
|
||||
|
||||
return m_textRect;
|
||||
}
|
||||
|
||||
QRectF KStandardItemListWidget::expansionToggleRect() const
|
||||
{
|
||||
const_cast<KStandardItemListWidget*>(this)->triggerCacheRefreshing();
|
||||
|
@ -945,7 +968,7 @@ void KStandardItemListWidget::updatePixmapCache()
|
|||
KIconEffect::semiTransparent(m_pixmap);
|
||||
}
|
||||
|
||||
if (isSelected()) {
|
||||
if (m_layout == IconsLayout && isSelected()) {
|
||||
const QColor color = palette().brush(QPalette::Normal, QPalette::Highlight).color();
|
||||
QImage image = m_pixmap.toImage();
|
||||
KIconEffect::colorize(image, color, 0.8f);
|
||||
|
|
|
@ -109,6 +109,7 @@ public:
|
|||
virtual QRectF iconRect() const;
|
||||
virtual QRectF textRect() const;
|
||||
virtual QRectF textFocusRect() const;
|
||||
virtual QRectF selectionRect() const;
|
||||
virtual QRectF expansionToggleRect() const;
|
||||
virtual QRectF selectionToggleRect() const;
|
||||
virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
|
||||
|
|
Loading…
Reference in a new issue