summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4d8f89f)
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
viewItemOption.state = styleState;
viewItemOption.viewItemPosition = QStyleOptionViewItemV4::OnlyOne;
viewItemOption.showDecorationSelected = true;
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);
}
widget->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &viewItemOption, painter, widget);
}
*/
virtual QRectF textFocusRect() const;
*/
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
/**
* @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
+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();
QRectF KStandardItemListWidget::expansionToggleRect() const
{
const_cast<KStandardItemListWidget*>(this)->triggerCacheRefreshing();
KIconEffect::semiTransparent(m_pixmap);
}
KIconEffect::semiTransparent(m_pixmap);
}
+ 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);
const QColor color = palette().brush(QPalette::Normal, QPalette::Highlight).color();
QImage image = m_pixmap.toImage();
KIconEffect::colorize(image, color, 0.8f);
virtual QRectF iconRect() const;
virtual QRectF textRect() const;
virtual QRectF textFocusRect() const;
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);
virtual QRectF expansionToggleRect() const;
virtual QRectF selectionToggleRect() const;
virtual QPixmap createDragPixmap(const QStyleOptionGraphicsItem* option, QWidget* widget = 0);