diff options
| author | Peter Penz <[email protected]> | 2011-11-18 20:51:47 +0100 |
|---|---|---|
| committer | Peter Penz <[email protected]> | 2011-11-18 20:53:22 +0100 |
| commit | fdab9ee644c57d2039dd7bc6dfc3fbd8a75d13fa (patch) | |
| tree | f49d1617b95a550574bfc804656e0d078030e9d3 /src/kitemviews | |
| parent | 77f9af8044f246d51867723aa159460f8ac40788 (diff) | |
Fix colors for the selection/hover-area
Thanks to Hugo Pereira Da Costa for pointing this out and
the initial patch!
CCMAIL: [email protected]
Diffstat (limited to 'src/kitemviews')
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.cpp | 26 | ||||
| -rw-r--r-- | src/kitemviews/kfileitemlistwidget.h | 1 | ||||
| -rw-r--r-- | src/kitemviews/kitemlistwidget.cpp | 8 |
3 files changed, 30 insertions, 5 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index 710253ae8..a4c18e404 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -279,7 +279,13 @@ void KFileItemListWidget::setTextColor(const QColor& color) QColor KFileItemListWidget::textColor() const { - return m_customTextColor.isValid() ? m_customTextColor : styleOption().palette.text().color(); + if (m_customTextColor.isValid()) { + return m_customTextColor; + } else if (isSelected()) { + return styleOption().palette.highlightedText().color(); + } else { + return styleOption().palette.text().color(); + } } void KFileItemListWidget::setOverlay(const QPixmap& overlay) @@ -345,6 +351,12 @@ void KFileItemListWidget::hoveredChanged(bool hovered) m_dirtyLayout = true; } +void KFileItemListWidget::selectedChanged(bool selected) +{ + Q_UNUSED(selected); + updateAdditionalInfoTextColor(); +} + void KFileItemListWidget::resizeEvent(QGraphicsSceneResizeEvent* event) { KItemListWidget::resizeEvent(event); @@ -741,10 +753,18 @@ void KFileItemListWidget::updateDetailsLayoutTextCache() void KFileItemListWidget::updateAdditionalInfoTextColor() { + QColor c1; + if (m_customTextColor.isValid()) { + c1 = m_customTextColor; + } else if (isSelected() && m_layout != DetailsLayout) { + c1 = styleOption().palette.highlightedText().color(); + } else { + c1 = styleOption().palette.text().color(); + } + // For the color of the additional info the inactive text color // is not used as this might lead to unreadable text for some color schemes. Instead - // the text color is slightly mixed with the background color. - const QColor c1 = textColor(); + // the text color c1 is slightly mixed with the background color. const QColor c2 = styleOption().palette.base().color(); const int p1 = 70; const int p2 = 100 - p1; diff --git a/src/kitemviews/kfileitemlistwidget.h b/src/kitemviews/kfileitemlistwidget.h index 1f0c89449..7c7ecf883 100644 --- a/src/kitemviews/kfileitemlistwidget.h +++ b/src/kitemviews/kfileitemlistwidget.h @@ -85,6 +85,7 @@ protected: virtual void visibleRolesSizesChanged(const QHash<QByteArray, QSizeF>& current, const QHash<QByteArray, QSizeF>& previous); virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous); virtual void hoveredChanged(bool hovered); + virtual void selectedChanged(bool selected); virtual void resizeEvent(QGraphicsSceneResizeEvent* event); private: diff --git a/src/kitemviews/kitemlistwidget.cpp b/src/kitemviews/kitemlistwidget.cpp index cf8b54c0c..193422259 100644 --- a/src/kitemviews/kitemlistwidget.cpp +++ b/src/kitemviews/kitemlistwidget.cpp @@ -111,7 +111,9 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o } if (m_selected) { - drawItemStyleOption(painter, widget, QStyle::State_Enabled | + const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0); + drawItemStyleOption(painter, widget, activeState | + QStyle::State_Enabled | QStyle::State_Selected | QStyle::State_Item); } @@ -133,7 +135,9 @@ void KItemListWidget::paint(QPainter* painter, const QStyleOptionGraphicsItem* o m_hoverCache->fill(Qt::transparent); QPainter pixmapPainter(m_hoverCache); - drawItemStyleOption(&pixmapPainter, widget, QStyle::State_Enabled | + const QStyle::State activeState(isActiveWindow() ? QStyle::State_Active : 0); + drawItemStyleOption(&pixmapPainter, widget, activeState | + QStyle::State_Enabled | QStyle::State_MouseOver | QStyle::State_Item); } |
