QmlDesigner: Add a separate placeholder icon for ktx textures

Fixes: QDS-9140
Change-Id: Ife2d3067860be2ae19e3c8431f1b756544b16975
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2023-02-28 14:22:39 +02:00
parent a194782774
commit 08992261af
10 changed files with 29 additions and 2 deletions

View File

@@ -19,5 +19,8 @@
<file>images/assets_default_128.png</file> <file>images/assets_default_128.png</file>
<file>images/asset_effectClass_128.png</file> <file>images/asset_effectClass_128.png</file>
<file>images/asset_effectExported_128.png</file> <file>images/asset_effectExported_128.png</file>
<file>images/asset_ktx.png</file>
<file>images/asset_ktx@2x.png</file>
<file>images/asset_ktx_128.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@@ -92,8 +92,8 @@ QPair<QPixmap, qint64> AssetsLibraryIconProvider::fetchPixmap(const QString &id,
return {pixmap, size}; return {pixmap, size};
} else if (asset.isKtxFile()) { } else if (asset.isKtxFile()) {
qint64 size = QFileInfo(id).size(); qint64 size = QFileInfo(id).size();
// TODO: Return ktx specific default image once available (QDS-9140) QString filePath = Utils::StyleHelper::dpiSpecificImageFile(":/AssetsLibrary/images/asset_ktx.png");
return {{}, size}; return {QPixmap{filePath}, size};
} else { } else {
QString type; QString type;
if (asset.isShader()) if (asset.isShader())

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@@ -124,6 +124,8 @@ bool MaterialBrowserWidget::eventFilter(QObject *obj, QEvent *event)
const QString suffix = iconPath.split('.').last().toLower(); const QString suffix = iconPath.split('.').last().toLower();
if (suffix == "hdr") if (suffix == "hdr")
pixmap = HdrImage{iconPath}.toPixmap(); pixmap = HdrImage{iconPath}.toPixmap();
else if (suffix == "ktx")
pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/textureeditor/images/texture_ktx.png");
else else
pixmap = Utils::StyleHelper::dpiSpecificImageFile(iconPath); pixmap = Utils::StyleHelper::dpiSpecificImageFile(iconPath);
if (pixmap.isNull()) if (pixmap.isNull())

View File

@@ -24,6 +24,26 @@ QQuickImageResponse *AssetImageProvider::requestImageResponse(const QString &id,
if (id.endsWith(".builtin")) if (id.endsWith(".builtin"))
return m_imageCacheProvider.requestImageResponse("#" + id.split('.').first(), {}); return m_imageCacheProvider.requestImageResponse("#" + id.split('.').first(), {});
if (id.endsWith(".ktx")) {
auto response = std::make_unique<ImageCacheImageResponse>(m_imageCacheProvider.defaultImage());
QMetaObject::invokeMethod(
response.get(),
[response = QPointer<ImageCacheImageResponse>(response.get()), requestedSize] {
QImage ktxImage;
ktxImage.load(Utils::StyleHelper::dpiSpecificImageFile(":/textureeditor/images/texture_ktx.png"));
if (ktxImage.isNull())
ktxImage = response->image();
if (requestedSize.isValid())
response->setImage(ktxImage.scaled(requestedSize, Qt::KeepAspectRatio));
else
response->setImage(ktxImage);
},
Qt::QueuedConnection);
return response.release();
}
return m_imageCacheProvider.requestImageResponse(id, requestedSize); return m_imageCacheProvider.requestImageResponse(id, requestedSize);
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@@ -2,5 +2,7 @@
<qresource prefix="/textureeditor"> <qresource prefix="/textureeditor">
<file>images/texture_default.png</file> <file>images/texture_default.png</file>
<file>images/texture_default@2x.png</file> <file>images/texture_default@2x.png</file>
<file>images/texture_ktx.png</file>
<file>images/texture_ktx@2x.png</file>
</qresource> </qresource>
</RCC> </RCC>