blob: c519a375dd6b7f7343da744eaea59c9ef32ba680 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
#include "propertyeditorimageprovider.h"
#include "assetslibrarymodel.h"
#include <hdrimage.h>
#include <projectexplorer/target.h>
#include <utils/stylehelper.h>
#include <QMetaObject>
#include <QQuickImageResponse>
namespace QmlDesigner {
QQuickImageResponse *PropertyEditorImageProvider::requestImageResponse(const QString &id,
const QSize &requestedSize)
{
const QString suffix = "*." + id.split('.').last().toLower();
if (suffix == "*.mesh")
return m_smallImageCacheProvider.requestImageResponse(id, requestedSize);
if (suffix == "*.builtin")
return m_smallImageCacheProvider.requestImageResponse("#" + id.split('.').first(),
requestedSize);
QImage image;
auto response = std::make_unique<QmlDesigner::ImageResponse>(image);
QMetaObject::invokeMethod(
response.get(),
[response = QPointer<QmlDesigner::ImageResponse>(response.get()), image, suffix, id] {
if (AssetsLibraryModel::supportedImageSuffixes().contains(suffix))
response->setImage(QImage(Utils::StyleHelper::dpiSpecificImageFile(id)));
else if (AssetsLibraryModel::supportedTexture3DSuffixes().contains(suffix))
response->setImage(HdrImage{id}.image());
else
response->abort();
},
Qt::QueuedConnection);
return response.release();
}
} // namespace QmlDesigner
|