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:
Alessandro Portale
2024-02-29 16:02:33 +01:00
committed by hjk
parent dfb685d64c
commit 4f30c2b4ed
4 changed files with 18 additions and 16 deletions

View File

@@ -856,10 +856,8 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
painter->save();
painter->translate(bgRGlobal.topLeft());
const QColor fill(themeColor(hovered ? Theme::Token_Foreground_Muted
: Theme::Token_Background_Muted));
const QPen pen(themeColor(hovered ? Theme::Token_Foreground_Muted
: Theme::Token_Stroke_Subtle), itemOutlineWidth);
const QColor fill(themeColor(hovered ? cardHoverBackground : cardDefaultBackground));
const QPen pen(themeColor(hovered ? cardHoverStroke : cardDefaultStroke), itemOutlineWidth);
WelcomePageHelpers::drawCardBackground(painter, bgR, fill, pen, itemCornerRounding);
const int shiftY = thumbnailAreaR.bottom();
@@ -915,7 +913,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
constexpr int filterMargin = hoverBlurRadius;
QImage thumbnail(bgR.size() + QSize(filterMargin, filterMargin) * 2,
QImage::Format_ARGB32_Premultiplied);
thumbnail.fill(themeColor(Theme::Token_Foreground_Muted));
thumbnail.fill(themeColor(cardHoverBackground));
QPainter thumbnailPainter(&thumbnail);
thumbnailPainter.translate(filterMargin, filterMargin);
thumbnailPainter.fillRect(thumbnailAreaR,
@@ -924,8 +922,7 @@ void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
thumbnailPainter.setPen(titleTF.color());
drawPixmapOverlay(item, &thumbnailPainter, option, thumbnailAreaR);
thumbnailPainter.setOpacity(1.0 - hoverBlurOpacity);
thumbnailPainter.fillRect(thumbnail.rect(),
themeColor(Theme::Token_Foreground_Muted));
thumbnailPainter.fillRect(thumbnail.rect(), themeColor(cardHoverBackground));
thumbnailPainter.end();
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);
painter->drawPixmap(backgroundPortionR.topLeft(), thumbnailPortionPM);
} else {
painter->fillRect(thumbnailAreaR, themeColor(Theme::Token_Foreground_Muted));
painter->fillRect(thumbnailAreaR, themeColor(cardHoverBackground));
}
}

View File

@@ -59,6 +59,10 @@ public:
CORE_EXPORT void setBackgroundColor(QWidget *widget, Utils::Theme::Color colorRole);
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,
const QBrush &fill, const QPen &pen = QPen(Qt::NoPen),
qreal rounding = defaultCardBackgroundRounding);

View File

@@ -329,10 +329,13 @@ public:
{
const bool selected = option.state & QStyle::State_Selected;
const bool hovered = option.state & QStyle::State_MouseOver;
const QColor fillColor = creatorTheme()->color(hovered ? Theme::Token_Foreground_Muted
: Theme::Token_Background_Muted);
const QColor strokeColor = creatorTheme()->color(selected ? Theme::Token_Stroke_Strong
: Theme::Token_Stroke_Subtle);
const QColor fillColor =
creatorTheme()->color(hovered ? WelcomePageHelpers::cardHoverBackground
: WelcomePageHelpers::cardDefaultBackground);
const QColor strokeColor =
creatorTheme()->color(selected ? Theme::Token_Stroke_Strong
: hovered ? WelcomePageHelpers::cardHoverStroke
: WelcomePageHelpers::cardDefaultStroke);
WelcomePageHelpers::drawCardBackground(painter, itemRect, fillColor, strokeColor);
}
{

View File

@@ -232,10 +232,8 @@ static QPixmap pixmap(const QString &id, const Theme::Color color)
static void drawBackgroundRect(QPainter *painter, const QRectF &rect, bool hovered)
{
const QColor fill(themeColor(hovered ? Theme::Token_Foreground_Muted
: Theme::Token_Background_Muted));
const QPen pen(themeColor(hovered ? Theme::Token_Foreground_Muted
: Theme::Token_Stroke_Subtle));
const QColor fill(themeColor(hovered ? cardHoverBackground : cardDefaultBackground));
const QPen pen(themeColor(hovered ? cardHoverStroke : cardDefaultStroke));
const qreal rounding = s(defaultCardBackgroundRounding * 1000) / 1000.0;
const qreal saneRounding = rounding <= 2 ? 0 : rounding;