diff options
author | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2020-09-24 16:20:34 +0300 |
---|---|---|
committer | Miikka Heikkinen <miikka.heikkinen@qt.io> | 2020-09-29 09:58:21 +0000 |
commit | 8d6ee2509d60eb5ebc078da538c825cc7ef4c1f0 (patch) | |
tree | 7deabd67a0d84923b7169611b2be8ec485a7100c /share/qtcreator | |
parent | 36a8b8ad99e3cb7ac5b577617016824b40d37799 (diff) |
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>
Diffstat (limited to 'share/qtcreator')
3 files changed, 23 insertions, 4 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.cpp index 17f3a65a13..265b7fd917 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.cpp +++ b/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.cpp @@ -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 diff --git a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.h b/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.h index 14ebe6156f..91ef0eddba 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.h +++ b/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.h @@ -40,16 +40,19 @@ class RequestModelNodePreviewImageCommand public: RequestModelNodePreviewImageCommand(); - explicit RequestModelNodePreviewImageCommand(qint32 id, const QSize &size, const QString &componentPath); + explicit RequestModelNodePreviewImageCommand(qint32 id, const QSize &size, + const QString &componentPath, qint32 renderItemId); qint32 instanceId() const; QSize size() const; QString componentPath() const; + qint32 renderItemId() const; private: qint32 m_instanceId; QSize m_size; QString m_componentPath; + qint32 m_renderItemId; }; QDataStream &operator<<(QDataStream &out, const RequestModelNodePreviewImageCommand &command); diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp index 944bb63c54..2963119def 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp @@ -518,7 +518,12 @@ void Qt5InformationNodeInstanceServer::renderModelNodeImageView() void Qt5InformationNodeInstanceServer::doRenderModelNodeImageView() { - ServerNodeInstance instance = instanceForId(m_modelNodePreviewImageCommand.instanceId()); + ServerNodeInstance instance; + if (m_modelNodePreviewImageCommand.renderItemId() >= 0) + instance = instanceForId(m_modelNodePreviewImageCommand.renderItemId()); + else + instance = instanceForId(m_modelNodePreviewImageCommand.instanceId()); + if (instance.isSubclassOf("QQuick3DObject")) doRenderModelNode3DImageView(); else if (instance.isSubclassOf("QQuickItem")) |