mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
AppFwk : Add border to color gradient icons
This commit is contained in:
parent
869f6ce39b
commit
4ff1f54e16
@ -171,21 +171,34 @@ std::unique_ptr<QIcon> IconProvider::icon(const QSize& size) const
|
||||
{
|
||||
validIcon = true;
|
||||
|
||||
QLinearGradient gradient (QPointF(0.0f, 0.0f), QPoint(size.width(), 0.0f));
|
||||
for (size_t i = 0; i < m_backgroundColorStrings.size(); ++i)
|
||||
{
|
||||
if (!QColor::isValidColor(m_backgroundColorStrings[i]))
|
||||
{
|
||||
validIcon = false;
|
||||
break;
|
||||
{
|
||||
// Draw color gradient based on background colors
|
||||
|
||||
QLinearGradient gradient (QPointF(0.0f, 0.0f), QPoint(size.width(), 0.0f));
|
||||
for (size_t i = 0; i < m_backgroundColorStrings.size(); ++i)
|
||||
{
|
||||
if (!QColor::isValidColor(m_backgroundColorStrings[i]))
|
||||
{
|
||||
validIcon = false;
|
||||
break;
|
||||
}
|
||||
QColor color (m_backgroundColorStrings[i]);
|
||||
float frac = i / ((float) m_backgroundColorStrings.size() - 1.0);
|
||||
gradient.setColorAt(frac, color);
|
||||
}
|
||||
QColor color (m_backgroundColorStrings[i]);
|
||||
float frac = i / ((float) m_backgroundColorStrings.size() - 1.0);
|
||||
gradient.setColorAt(frac, color);
|
||||
QBrush gradientBrush(gradient);
|
||||
QPainter painter (&pixmap);
|
||||
painter.fillRect(0, 0, size.width(), size.height(), gradientBrush);
|
||||
}
|
||||
|
||||
{
|
||||
// Draw border
|
||||
|
||||
QPainter painter2(&pixmap);
|
||||
painter2.setRenderHint(QPainter::Antialiasing);
|
||||
painter2.setPen(QPen(Qt::black, 1));
|
||||
painter2.drawRect(QRectF(0, 0, size.width(), size.height()));
|
||||
}
|
||||
QBrush gradientBrush(gradient);
|
||||
QPainter painter (&pixmap);
|
||||
painter.fillRect(0, 0, size.width(), size.height(), gradientBrush);
|
||||
}
|
||||
}
|
||||
else pixmap.fill(Qt::transparent);
|
||||
|
Loading…
Reference in New Issue
Block a user