Provide scaled pixmaps by UIThemeManager

Avoid leaking the paths of the theme resource files outside of the theme support implementation.

PR #18269.
This commit is contained in:
Vladimir Golovnev 2023-01-17 09:29:00 +03:00 committed by GitHub
parent 43e059801e
commit 53cec6db09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 55 deletions

View file

@ -81,26 +81,6 @@ QPixmap Utils::Gui::scaledPixmap(const Path &path, const QWidget *widget, const
return (height == 0) ? pixmap : pixmap.scaledToHeight(height, Qt::SmoothTransformation);
}
QPixmap Utils::Gui::scaledPixmapSvg(const Path &path, const QWidget *widget, const int height)
{
// (workaround) svg images require the use of `QIcon()` to load and scale losslessly,
// otherwise other image classes will convert it to pixmap first and follow-up scaling will become lossy.
Q_UNUSED(widget);
Q_ASSERT(height > 0);
const QString cacheKey = path.data() + u'@' + QString::number(height);
QPixmap pixmap;
QPixmapCache cache;
if (!cache.find(cacheKey, &pixmap))
{
pixmap = QIcon(path.data()).pixmap(height);
cache.insert(cacheKey, pixmap);
}
return pixmap;
}
QSize Utils::Gui::smallIconSize(const QWidget *widget)
{
// Get DPI scaled icon size (device-dependent), see QT source