[Theme] Pass application palette when generating disabled icon pixmap

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
This commit is contained in:
Lukas Brübach 2026-11-09 20:26:38 +00:00
parent 16455c9fd5
commit 0bea891091
2 changed files with 34 additions and 1 deletions

View file

@ -619,6 +619,34 @@ TEST_F(ThemeIconRenderTest, BadgeOnAuthoredArtUsesTheAssetPath)
EXPECT_EQ(countOpaquePixels(pixmap, tone.darker(300)), 0);
}
/**
* @brief Disabled authored art is generated by the style without crashing.
*
* Art that carries its own colors is dimmed through
* QStyle::generatedIconPixmap, which dereferences the style option's palette;
* passing no option crashed in QPalette::brush.
*/
TEST_F(ThemeIconRenderTest, DisabledAuthoredArtIsGeneratedByTheStyle)
{
QTemporaryDir themeDir;
ASSERT_TRUE(themeDir.isValid());
QFile file(QDir(themeDir.path()).absoluteFilePath(QStringLiteral("plain.svg")));
ASSERT_TRUE(file.open(QIODevice::WriteOnly));
file.write(svgWith("#336699"));
file.close();
QDir::addSearchPath(QStringLiteral("theme"), themeDir.path());
const QIcon icon = loadThemedIcon(QStringLiteral("plain"));
const QPixmap normal = icon.pixmap(QSize(32, 32));
const QPixmap disabled = icon.pixmap(QSize(32, 32), QIcon::Disabled);
ASSERT_FALSE(normal.isNull());
ASSERT_FALSE(disabled.isNull());
EXPECT_GT(countOpaquePixels(normal, QColor(QStringLiteral("#336699"))), 0);
// The style dims the art, so the authored color no longer appears verbatim.
EXPECT_EQ(countOpaquePixels(disabled, QColor(QStringLiteral("#336699"))), 0);
}
/** @brief Disabled keeps the shape language but drops back to the line glyph. */
TEST_F(ThemeIconRenderTest, DisabledBadgeFallsBackToLineGlyph)
{