mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-10 20:13:24 -08:00
[Icons] Render authored theme SVG art without the SVG image plugin
`QPixmap("theme:file.svg")` needs Qt's SVG *image-format* plugin. Debian
builds that as the separate `qt6-svg-plugins` package, which is only a
Recommends of `qt6-svg-dev`, so a `--no-install-recommends` install (CI,
minimal user installs) does not have it. Authored theme art then loaded as
a null pixmap: the two authored-art render tests failed on Debian 13 and on
the Ubuntu sanitize leg while passing on a developer machine whose Qt
bundles the format.
Render authored SVG assets through QSvgRenderer instead, which is already
linked for the sentinel path and needs no plugin. Raster assets keep the
QPixmap loader. The test suite now hides the plugin directories, so the
dependency cannot come back unnoticed on platforms that ship the plugin.
This commit is contained in:
parent
876d66ffc9
commit
ceef749ac3
2 changed files with 71 additions and 3 deletions
|
|
@ -256,9 +256,21 @@ private:
|
|||
|
||||
QPixmap fromAsset(const QSize &pixelSize, QIcon::Mode mode) const
|
||||
{
|
||||
QPixmap pixmap(QStringLiteral("theme:") + resolvedPath);
|
||||
if (!pixelSize.isEmpty() && pixmap.size() != pixelSize) {
|
||||
pixmap = pixmap.scaled(pixelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
QPixmap pixmap;
|
||||
if (resolvedAssetIsSvg) {
|
||||
// Render authored SVG art through QSvgRenderer rather than QPixmap.
|
||||
// Loading an `.svg` through QPixmap needs Qt's SVG *image-format*
|
||||
// plugin, which is a separate package on Linux distributions and is
|
||||
// absent from minimal installs and from CI (it is a Recommends of
|
||||
// qt6-svg-dev, so `--no-install-recommends` drops it). Art a theme
|
||||
// ships must not disappear because of a packaging choice, and the
|
||||
// renderer is already linked for the sentinel path.
|
||||
pixmap = renderSvg(resolvedSvg, pixelSize.isEmpty() ? intrinsicSize() : pixelSize, 1.0);
|
||||
} else {
|
||||
pixmap = QPixmap(QStringLiteral("theme:") + resolvedPath);
|
||||
if (!pixelSize.isEmpty() && pixmap.size() != pixelSize) {
|
||||
pixmap = pixmap.scaled(pixelSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
}
|
||||
if (mode == QIcon::Disabled && !pixmap.isNull()) {
|
||||
pixmap = QApplication::style()->generatedIconPixmap(QIcon::Disabled, pixmap, nullptr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue