Commit 23194dde authored by Emmanuel Pescosta's avatar Emmanuel Pescosta

Fix wrong text color in Places Group Header. Use QPalette::Window for base...

Fix wrong text color in Places Group Header. Use QPalette::Window for base color and QPalette::WindowText for text color. Also changed m_roleColor color mixing to 60% (from 70%) -> Better visible color difference when base color is darker than text color. Also changed styleOption().palette.brush(group, role).color() to styleOption().palette.color(group, role) in KStandardItemListWidget -> should be more efficient.

BUG: 303133
FIXED-IN: 4.9.1
(cherry picked from commit b3c3da98)
parent 5ba759b2
......@@ -180,10 +180,10 @@ void KItemListGroupHeader::updateCache()
// Calculate the role- and line-color. No alphablending is used for
// performance reasons.
const QColor c1 = m_styleOption.palette.text().color();
const QColor c2 = m_styleOption.palette.base().color();
const QColor c1 = textColor();
const QColor c2 = baseColor();
m_separatorColor = mixedColor(c1, c2, 10);
m_roleColor = mixedColor(c1, c2, 70);
m_roleColor = mixedColor(c1, c2, 60);
const int padding = qMax(1, m_styleOption.padding);
const int horizontalMargin = qMax(2, m_styleOption.horizontalMargin);
......@@ -211,4 +211,26 @@ QColor KItemListGroupHeader::mixedColor(const QColor& c1, const QColor& c2, int
(c1.blue() * c1Percent + c2.blue() * c2Percent) / 100);
}
QPalette::ColorRole KItemListGroupHeader::normalTextColorRole() const
{
return QPalette::Text;
}
QPalette::ColorRole KItemListGroupHeader::normalBaseColorRole() const
{
return QPalette::Window;
}
QColor KItemListGroupHeader::textColor() const
{
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
return styleOption().palette.color(group, normalTextColorRole());
}
QColor KItemListGroupHeader::baseColor() const
{
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
return styleOption().palette.color(group, normalBaseColorRole());
}
#include "kitemlistgroupheader.moc"
......@@ -104,11 +104,17 @@ protected:
/** @reimp */
virtual void resizeEvent(QGraphicsSceneResizeEvent* event);
virtual QPalette::ColorRole normalTextColorRole() const;
virtual QPalette::ColorRole normalBaseColorRole() const;
private:
void updateCache();
static QColor mixedColor(const QColor& c1, const QColor& c2, int c1Percent = 50);
QColor textColor() const;
QColor baseColor() const;
private:
bool m_dirtyCache;
QByteArray m_role;
......
......@@ -464,7 +464,7 @@ QFont KStandardItemListWidget::customizedFont(const QFont& baseFont) const
return baseFont;
}
QPalette::ColorRole KStandardItemListWidget::normalTextColorPalette() const
QPalette::ColorRole KStandardItemListWidget::normalTextColorRole() const
{
return QPalette::Text;
}
......@@ -485,8 +485,8 @@ QColor KStandardItemListWidget::textColor() const
}
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : normalTextColorPalette();
return styleOption().palette.brush(group, role).color();
const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : normalTextColorRole();
return styleOption().palette.color(group, role);
}
void KStandardItemListWidget::setOverlay(const QPixmap& overlay)
......
......@@ -120,7 +120,7 @@ protected:
*/
virtual QFont customizedFont(const QFont& baseFont) const;
virtual QPalette::ColorRole normalTextColorPalette() const;
virtual QPalette::ColorRole normalTextColorRole() const;
void setTextColor(const QColor& color);
QColor textColor() const;
......
......@@ -28,7 +28,7 @@ FoldersItemListWidget::~FoldersItemListWidget()
{
}
QPalette::ColorRole FoldersItemListWidget::normalTextColorPalette() const
QPalette::ColorRole FoldersItemListWidget::normalTextColorRole() const
{
return QPalette::WindowText;
}
......
......@@ -34,7 +34,7 @@ public:
virtual ~FoldersItemListWidget();
protected:
virtual QPalette::ColorRole normalTextColorPalette() const;
virtual QPalette::ColorRole normalTextColorRole() const;
};
#endif
......
......@@ -37,4 +37,9 @@ void PlacesItemListGroupHeader::paintSeparator(QPainter* painter, const QColor&
Q_UNUSED(color);
}
QPalette::ColorRole PlacesItemListGroupHeader::normalTextColorRole() const
{
return QPalette::WindowText;
}
#include "placesitemlistgroupheader.moc"
......@@ -32,6 +32,8 @@ public:
protected:
virtual void paintSeparator(QPainter* painter, const QColor& color);
virtual QPalette::ColorRole normalTextColorRole() const;
};
#endif
......
......@@ -35,7 +35,7 @@ bool PlacesItemListWidget::isHidden() const
return data().value("isHidden").toBool();
}
QPalette::ColorRole PlacesItemListWidget::normalTextColorPalette() const
QPalette::ColorRole PlacesItemListWidget::normalTextColorRole() const
{
return QPalette::WindowText;
}
......
......@@ -36,7 +36,7 @@ public:
protected:
virtual bool isHidden() const;
virtual QPalette::ColorRole normalTextColorPalette() const;
virtual QPalette::ColorRole normalTextColorRole() const;
};
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment