forked from qt-creator/qt-creator
QmlDesigner: Fix corrupted preview images in material editor/browser
Now a default preview image is shown if real preview is not yet available. Fixes: QDS-7055 Change-Id: Ia2f9ee3aa3b29f49224b6ba8ae8f22f1b36f629a Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
This commit is contained in:
@@ -320,6 +320,7 @@ extend_qtc_plugin(QmlDesigner
|
|||||||
materialeditorqmlbackend.cpp materialeditorqmlbackend.h
|
materialeditorqmlbackend.cpp materialeditorqmlbackend.h
|
||||||
materialeditortransaction.cpp materialeditortransaction.h
|
materialeditortransaction.cpp materialeditortransaction.h
|
||||||
materialeditorview.cpp materialeditorview.h
|
materialeditorview.cpp materialeditorview.h
|
||||||
|
materialeditor.qrc
|
||||||
)
|
)
|
||||||
|
|
||||||
extend_qtc_plugin(QmlDesigner
|
extend_qtc_plugin(QmlDesigner
|
||||||
|
@@ -81,11 +81,15 @@ public:
|
|||||||
{
|
{
|
||||||
Q_UNUSED(requestedSize)
|
Q_UNUSED(requestedSize)
|
||||||
|
|
||||||
|
static QPixmap defaultPreview = QPixmap::fromImage(QImage(":/materialeditor/images/defaultmaterialpreview.png"));
|
||||||
|
|
||||||
QPixmap pixmap{150, 150};
|
QPixmap pixmap{150, 150};
|
||||||
|
|
||||||
qint32 internalId = id.toInt();
|
qint32 internalId = id.toInt();
|
||||||
if (m_pixmaps.contains(internalId))
|
if (m_pixmaps.contains(internalId))
|
||||||
pixmap = m_pixmaps.value(internalId);
|
pixmap = m_pixmaps.value(internalId);
|
||||||
|
else
|
||||||
|
pixmap = defaultPreview;
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
*size = pixmap.size();
|
*size = pixmap.size();
|
||||||
|
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
@@ -0,0 +1,5 @@
|
|||||||
|
<RCC>
|
||||||
|
<qresource prefix="/materialeditor">
|
||||||
|
<file>images/defaultmaterialpreview.png</file>
|
||||||
|
</qresource>
|
||||||
|
</RCC>
|
@@ -77,16 +77,21 @@ public:
|
|||||||
{
|
{
|
||||||
Q_UNUSED(requestedSize)
|
Q_UNUSED(requestedSize)
|
||||||
|
|
||||||
|
static QPixmap defaultPreview = QPixmap::fromImage(QImage(":/materialeditor/images/defaultmaterialpreview.png"));
|
||||||
|
|
||||||
QPixmap pixmap{150, 150};
|
QPixmap pixmap{150, 150};
|
||||||
|
|
||||||
if (id == "preview") {
|
if (id == "preview") {
|
||||||
if (!m_previewPixmap.isNull())
|
if (!m_previewPixmap.isNull())
|
||||||
pixmap = m_previewPixmap;
|
pixmap = m_previewPixmap;
|
||||||
|
else
|
||||||
|
pixmap = defaultPreview;
|
||||||
} else {
|
} else {
|
||||||
QString path = Core::ICore::resourcePath("qmldesigner/materialEditorQmlSources/images/" + id).toString();
|
qWarning() << __FUNCTION__ << "Unsupported image id:" << id;
|
||||||
pixmap = QPixmap{path};
|
pixmap.fill(Qt::red);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (size)
|
if (size)
|
||||||
*size = pixmap.size();
|
*size = pixmap.size();
|
||||||
|
|
||||||
|
@@ -693,6 +693,7 @@ Project {
|
|||||||
"materialeditor/materialeditortransaction.h",
|
"materialeditor/materialeditortransaction.h",
|
||||||
"materialeditor/materialeditorview.cpp",
|
"materialeditor/materialeditorview.cpp",
|
||||||
"materialeditor/materialeditorview.h",
|
"materialeditor/materialeditorview.h",
|
||||||
|
"materialeditor/materialeditor.qrc",
|
||||||
"navigator/iconcheckboxitemdelegate.cpp",
|
"navigator/iconcheckboxitemdelegate.cpp",
|
||||||
"navigator/iconcheckboxitemdelegate.h",
|
"navigator/iconcheckboxitemdelegate.h",
|
||||||
"navigator/nameitemdelegate.cpp",
|
"navigator/nameitemdelegate.cpp",
|
||||||
|
Reference in New Issue
Block a user