mirror of
https://invent.kde.org/system/dolphin
synced 2024-08-22 01:40:02 +00:00
k[standard]itemlistwidget: Account for view focus in selection highlight
This commit is contained in:
parent
c628bb226e
commit
012f8a224a
|
@ -111,11 +111,11 @@ void KItemListWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_selected && m_editedRole.isEmpty()) {
|
if (m_selected && m_editedRole.isEmpty()) {
|
||||||
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
|
const QStyle::State activeState(isActiveWindow() && widget->hasFocus() ? QStyle::State_Active : 0);
|
||||||
drawItemStyleOption(painter, widget, activeState | QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item);
|
drawItemStyleOption(painter, widget, activeState | QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_current && m_editedRole.isEmpty()) {
|
if (m_current && m_editedRole.isEmpty() && widget->hasFocus()) {
|
||||||
QStyleOptionFocusRect focusRectOption;
|
QStyleOptionFocusRect focusRectOption;
|
||||||
initStyleOption(&focusRectOption);
|
initStyleOption(&focusRectOption);
|
||||||
focusRectOption.rect = textFocusRect().toRect();
|
focusRectOption.rect = textFocusRect().toRect();
|
||||||
|
@ -135,8 +135,8 @@ void KItemListWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *o
|
||||||
m_hoverCache->fill(Qt::transparent);
|
m_hoverCache->fill(Qt::transparent);
|
||||||
|
|
||||||
QPainter pixmapPainter(m_hoverCache);
|
QPainter pixmapPainter(m_hoverCache);
|
||||||
const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0);
|
const QStyle::State activeState(isActiveWindow() && widget->hasFocus() ? QStyle::State_Active | QStyle::State_Enabled : 0);
|
||||||
drawItemStyleOption(&pixmapPainter, widget, activeState | QStyle::State_Enabled | QStyle::State_MouseOver | QStyle::State_Item);
|
drawItemStyleOption(&pixmapPainter, widget, activeState | QStyle::State_MouseOver | QStyle::State_Item);
|
||||||
}
|
}
|
||||||
|
|
||||||
const qreal opacity = painter->opacity();
|
const qreal opacity = painter->opacity();
|
||||||
|
|
|
@ -386,7 +386,7 @@ void KStandardItemListWidget::paint(QPainter *painter, const QStyleOptionGraphic
|
||||||
}
|
}
|
||||||
|
|
||||||
painter->setFont(m_customizedFont);
|
painter->setFont(m_customizedFont);
|
||||||
painter->setPen(textColor());
|
painter->setPen(textColor(widget));
|
||||||
const TextInfo *textInfo = m_textInfo.value("text");
|
const TextInfo *textInfo = m_textInfo.value("text");
|
||||||
|
|
||||||
if (!textInfo) {
|
if (!textInfo) {
|
||||||
|
@ -645,7 +645,7 @@ void KStandardItemListWidget::setTextColor(const QColor &color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor KStandardItemListWidget::textColor() const
|
QColor KStandardItemListWidget::textColor(QWidget *widget) const
|
||||||
{
|
{
|
||||||
if (!isSelected()) {
|
if (!isSelected()) {
|
||||||
if (m_isHidden) {
|
if (m_isHidden) {
|
||||||
|
@ -655,7 +655,7 @@ QColor KStandardItemListWidget::textColor() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
|
const QPalette::ColorGroup group = isActiveWindow() && widget->hasFocus() ? QPalette::Active : QPalette::Inactive;
|
||||||
const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : normalTextColorRole();
|
const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : normalTextColorRole();
|
||||||
return styleOption().palette.color(group, role);
|
return styleOption().palette.color(group, role);
|
||||||
}
|
}
|
||||||
|
@ -1015,8 +1015,11 @@ void KStandardItemListWidget::updatePixmapCache()
|
||||||
iconName = QStringLiteral("unknown");
|
iconName = QStringLiteral("unknown");
|
||||||
}
|
}
|
||||||
const QStringList overlays = values["iconOverlays"].toStringList();
|
const QStringList overlays = values["iconOverlays"].toStringList();
|
||||||
m_pixmap =
|
const bool hasFocus = scene()->views()[0]->parentWidget()->hasFocus();
|
||||||
pixmapForIcon(iconName, overlays, maxIconHeight, m_layout != IconsLayout && isActiveWindow() && isSelected() ? QIcon::Selected : QIcon::Normal);
|
m_pixmap = pixmapForIcon(iconName,
|
||||||
|
overlays,
|
||||||
|
maxIconHeight,
|
||||||
|
m_layout != IconsLayout && isActiveWindow() && isSelected() && hasFocus ? QIcon::Selected : QIcon::Normal);
|
||||||
|
|
||||||
} else if (m_pixmap.width() / m_pixmap.devicePixelRatio() != maxIconWidth || m_pixmap.height() / m_pixmap.devicePixelRatio() != maxIconHeight) {
|
} else if (m_pixmap.width() / m_pixmap.devicePixelRatio() != maxIconWidth || m_pixmap.height() / m_pixmap.devicePixelRatio() != maxIconHeight) {
|
||||||
// A custom pixmap has been applied. Assure that the pixmap
|
// A custom pixmap has been applied. Assure that the pixmap
|
||||||
|
|
|
@ -139,7 +139,7 @@ protected:
|
||||||
virtual QPalette::ColorRole normalTextColorRole() const;
|
virtual QPalette::ColorRole normalTextColorRole() const;
|
||||||
|
|
||||||
void setTextColor(const QColor &color);
|
void setTextColor(const QColor &color);
|
||||||
QColor textColor() const;
|
QColor textColor(QWidget *widget) const;
|
||||||
|
|
||||||
void setOverlay(const QPixmap &overlay);
|
void setOverlay(const QPixmap &overlay);
|
||||||
QPixmap overlay() const;
|
QPixmap overlay() const;
|
||||||
|
|
Loading…
Reference in a new issue