QmlDesigner: Show tooltip preview image for Textures with sourceItem

For non-component sourceItems, the preview shown is simply whatever
image has been stored for form editor for that item.

If the sourceItem is component, the preview image is the same as
sourceItem's preview image, as the form editor image for components
often includes unnecessary empty space.

Note that currently the image stored for form editor doesn't include
child items, so this is not a perfect solution. It is however in line
with what form editor shows for the texture.

Change-Id: I3c0c629ca5e7fa25dbcb390c53e3865e34d5e729
Fixes: QDS-2824
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
Miikka Heikkinen
2020-09-24 16:20:34 +03:00
parent 36a8b8ad99
commit 8d6ee2509d
6 changed files with 107 additions and 53 deletions
@@ -32,10 +32,13 @@ namespace QmlDesigner {
RequestModelNodePreviewImageCommand::RequestModelNodePreviewImageCommand() = default;
RequestModelNodePreviewImageCommand::RequestModelNodePreviewImageCommand(qint32 id, const QSize &size, const QString &componentPath)
RequestModelNodePreviewImageCommand::RequestModelNodePreviewImageCommand(qint32 id, const QSize &size,
const QString &componentPath,
qint32 renderItemId)
: m_instanceId(id)
, m_size(size)
, m_componentPath(componentPath)
, m_renderItemId(renderItemId)
{
}
@@ -54,11 +57,17 @@ QString RequestModelNodePreviewImageCommand::componentPath() const
return m_componentPath;
}
qint32 RequestModelNodePreviewImageCommand::renderItemId() const
{
return m_renderItemId;
}
QDataStream &operator<<(QDataStream &out, const RequestModelNodePreviewImageCommand &command)
{
out << int(command.instanceId());
out << command.size();
out << command.componentPath();
out << command.renderItemId();
return out;
}
@@ -68,6 +77,7 @@ QDataStream &operator>>(QDataStream &in, RequestModelNodePreviewImageCommand &co
in >> command.m_instanceId;
in >> command.m_size;
in >> command.m_componentPath;
in >> command.m_renderItemId;
return in;
}
@@ -76,7 +86,8 @@ QDebug operator <<(QDebug debug, const RequestModelNodePreviewImageCommand &comm
return debug.nospace() << "RequestModelNodePreviewImageCommand("
<< "instanceId: " << command.instanceId() << ", "
<< "size: " << command.size() << ", "
<< "componentPath: " << command.componentPath() << ")";
<< "componentPath: " << command.componentPath() << ", "
<< "renderItemId: " << command.renderItemId() << ")";
}
} // namespace QmlDesigner