forked from qt-creator/qt-creator
Welcome: Fix the hover background color
It used the wrong color token. With the correct one, the hover effect is a bit less prominent. Change-Id: I95a1f5a92f95d4055ae8bce703fdc633b122ac59 Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -856,10 +856,8 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||||||
painter->save();
|
painter->save();
|
||||||
painter->translate(bgRGlobal.topLeft());
|
painter->translate(bgRGlobal.topLeft());
|
||||||
|
|
||||||
const QColor fill(themeColor(hovered ? Theme::Token_Foreground_Muted
|
const QColor fill(themeColor(hovered ? cardHoverBackground : cardDefaultBackground));
|
||||||
: Theme::Token_Background_Muted));
|
const QPen pen(themeColor(hovered ? cardHoverStroke : cardDefaultStroke), itemOutlineWidth);
|
||||||
const QPen pen(themeColor(hovered ? Theme::Token_Foreground_Muted
|
|
||||||
: Theme::Token_Stroke_Subtle), itemOutlineWidth);
|
|
||||||
WelcomePageHelpers::drawCardBackground(painter, bgR, fill, pen, itemCornerRounding);
|
WelcomePageHelpers::drawCardBackground(painter, bgR, fill, pen, itemCornerRounding);
|
||||||
|
|
||||||
const int shiftY = thumbnailAreaR.bottom();
|
const int shiftY = thumbnailAreaR.bottom();
|
||||||
@@ -915,7 +913,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||||||
constexpr int filterMargin = hoverBlurRadius;
|
constexpr int filterMargin = hoverBlurRadius;
|
||||||
QImage thumbnail(bgR.size() + QSize(filterMargin, filterMargin) * 2,
|
QImage thumbnail(bgR.size() + QSize(filterMargin, filterMargin) * 2,
|
||||||
QImage::Format_ARGB32_Premultiplied);
|
QImage::Format_ARGB32_Premultiplied);
|
||||||
thumbnail.fill(themeColor(Theme::Token_Foreground_Muted));
|
thumbnail.fill(themeColor(cardHoverBackground));
|
||||||
QPainter thumbnailPainter(&thumbnail);
|
QPainter thumbnailPainter(&thumbnail);
|
||||||
thumbnailPainter.translate(filterMargin, filterMargin);
|
thumbnailPainter.translate(filterMargin, filterMargin);
|
||||||
thumbnailPainter.fillRect(thumbnailAreaR,
|
thumbnailPainter.fillRect(thumbnailAreaR,
|
||||||
@@ -924,8 +922,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||||||
thumbnailPainter.setPen(titleTF.color());
|
thumbnailPainter.setPen(titleTF.color());
|
||||||
drawPixmapOverlay(item, &thumbnailPainter, option, thumbnailAreaR);
|
drawPixmapOverlay(item, &thumbnailPainter, option, thumbnailAreaR);
|
||||||
thumbnailPainter.setOpacity(1.0 - hoverBlurOpacity);
|
thumbnailPainter.setOpacity(1.0 - hoverBlurOpacity);
|
||||||
thumbnailPainter.fillRect(thumbnail.rect(),
|
thumbnailPainter.fillRect(thumbnail.rect(), themeColor(cardHoverBackground));
|
||||||
themeColor(Theme::Token_Foreground_Muted));
|
|
||||||
thumbnailPainter.end();
|
thumbnailPainter.end();
|
||||||
qt_blurImage(thumbnail, hoverBlurRadius, false, false);
|
qt_blurImage(thumbnail, hoverBlurRadius, false, false);
|
||||||
|
|
||||||
@@ -944,7 +941,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
|||||||
const QPixmap thumbnailPortionPM = m_blurredThumbnail.copy(backgroundPortionR);
|
const QPixmap thumbnailPortionPM = m_blurredThumbnail.copy(backgroundPortionR);
|
||||||
painter->drawPixmap(backgroundPortionR.topLeft(), thumbnailPortionPM);
|
painter->drawPixmap(backgroundPortionR.topLeft(), thumbnailPortionPM);
|
||||||
} else {
|
} else {
|
||||||
painter->fillRect(thumbnailAreaR, themeColor(Theme::Token_Foreground_Muted));
|
painter->fillRect(thumbnailAreaR, themeColor(cardHoverBackground));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -59,6 +59,10 @@ public:
|
|||||||
|
|
||||||
CORE_EXPORT void setBackgroundColor(QWidget *widget, Utils::Theme::Color colorRole);
|
CORE_EXPORT void setBackgroundColor(QWidget *widget, Utils::Theme::Color colorRole);
|
||||||
constexpr qreal defaultCardBackgroundRounding = 3.75;
|
constexpr qreal defaultCardBackgroundRounding = 3.75;
|
||||||
|
constexpr Utils::Theme::Color cardDefaultBackground = Utils::Theme::Token_Background_Muted;
|
||||||
|
constexpr Utils::Theme::Color cardDefaultStroke = Utils::Theme::Token_Stroke_Subtle;
|
||||||
|
constexpr Utils::Theme::Color cardHoverBackground = Utils::Theme::Token_Foreground_Subtle;
|
||||||
|
constexpr Utils::Theme::Color cardHoverStroke = cardHoverBackground;
|
||||||
CORE_EXPORT void drawCardBackground(QPainter *painter, const QRectF &rect,
|
CORE_EXPORT void drawCardBackground(QPainter *painter, const QRectF &rect,
|
||||||
const QBrush &fill, const QPen &pen = QPen(Qt::NoPen),
|
const QBrush &fill, const QPen &pen = QPen(Qt::NoPen),
|
||||||
qreal rounding = defaultCardBackgroundRounding);
|
qreal rounding = defaultCardBackgroundRounding);
|
||||||
|
@@ -329,10 +329,13 @@ public:
|
|||||||
{
|
{
|
||||||
const bool selected = option.state & QStyle::State_Selected;
|
const bool selected = option.state & QStyle::State_Selected;
|
||||||
const bool hovered = option.state & QStyle::State_MouseOver;
|
const bool hovered = option.state & QStyle::State_MouseOver;
|
||||||
const QColor fillColor = creatorTheme()->color(hovered ? Theme::Token_Foreground_Muted
|
const QColor fillColor =
|
||||||
: Theme::Token_Background_Muted);
|
creatorTheme()->color(hovered ? WelcomePageHelpers::cardHoverBackground
|
||||||
const QColor strokeColor = creatorTheme()->color(selected ? Theme::Token_Stroke_Strong
|
: WelcomePageHelpers::cardDefaultBackground);
|
||||||
: Theme::Token_Stroke_Subtle);
|
const QColor strokeColor =
|
||||||
|
creatorTheme()->color(selected ? Theme::Token_Stroke_Strong
|
||||||
|
: hovered ? WelcomePageHelpers::cardHoverStroke
|
||||||
|
: WelcomePageHelpers::cardDefaultStroke);
|
||||||
WelcomePageHelpers::drawCardBackground(painter, itemRect, fillColor, strokeColor);
|
WelcomePageHelpers::drawCardBackground(painter, itemRect, fillColor, strokeColor);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
@@ -232,10 +232,8 @@ static QPixmap pixmap(const QString &id, const Theme::Color color)
|
|||||||
|
|
||||||
static void drawBackgroundRect(QPainter *painter, const QRectF &rect, bool hovered)
|
static void drawBackgroundRect(QPainter *painter, const QRectF &rect, bool hovered)
|
||||||
{
|
{
|
||||||
const QColor fill(themeColor(hovered ? Theme::Token_Foreground_Muted
|
const QColor fill(themeColor(hovered ? cardHoverBackground : cardDefaultBackground));
|
||||||
: Theme::Token_Background_Muted));
|
const QPen pen(themeColor(hovered ? cardHoverStroke : cardDefaultStroke));
|
||||||
const QPen pen(themeColor(hovered ? Theme::Token_Foreground_Muted
|
|
||||||
: Theme::Token_Stroke_Subtle));
|
|
||||||
|
|
||||||
const qreal rounding = s(defaultCardBackgroundRounding * 1000) / 1000.0;
|
const qreal rounding = s(defaultCardBackgroundRounding * 1000) / 1000.0;
|
||||||
const qreal saneRounding = rounding <= 2 ? 0 : rounding;
|
const qreal saneRounding = rounding <= 2 ? 0 : rounding;
|
||||||
|
Reference in New Issue
Block a user