diff options
author | Marco Bubke <marco.bubke@qt.io> | 2020-05-07 14:13:21 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2020-05-12 07:11:15 +0000 |
commit | 0e7a1e6650538f2a00070c3a334c56c9d48cfee8 (patch) | |
tree | a33415a43bda4eb8f2027f6cb31e3fd8cec66b52 /share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp | |
parent | 2e409f792cb1efbc29bf3b14356caa305b6a46b8 (diff) |
QmlDesigner: Preview size is now changeable
You can now change the preview size with
rootModelNode.setAuxiliaryData("previewSize@Internal", size);
If size is null it will use the bounding box size.
Change-Id: Icbe747ccc5a2e26e79783825d2ed94ecc640012b
Reviewed-by: Michael Winkelmann <michael.winkelmann@qt.io>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp')
-rw-r--r-- | share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp index e3716d8787..758f7f0c8f 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp @@ -25,10 +25,12 @@ #include "qt5previewnodeinstanceserver.h" -#include "nodeinstanceclientinterface.h" -#include "statepreviewimagechangedcommand.h" +#include "changepreviewimagesizecommand.h" #include "createscenecommand.h" +#include "nodeinstanceclientinterface.h" #include "removesharedmemorycommand.h" +#include "statepreviewimagechangedcommand.h" + #include <QQuickView> #include <QQuickItem> #include <designersupportdelegate.h> @@ -100,7 +102,9 @@ QImage Qt5PreviewNodeInstanceServer::renderPreviewImage() QRectF boundingRect = rootNodeInstance().boundingRect(); QSize previewImageSize = boundingRect.size().toSize(); - previewImageSize.scale(QSize(160, 160), Qt::KeepAspectRatio); + + if (!m_previewSize.isNull()) + previewImageSize.scale(m_previewSize, Qt::KeepAspectRatio); QImage previewImage = rootNodeInstance().renderPreviewImage(previewImageSize); @@ -113,4 +117,12 @@ void QmlDesigner::Qt5PreviewNodeInstanceServer::removeSharedMemory(const QmlDesi ImageContainer::removeSharedMemorys(command.keyNumbers()); } +void Qt5PreviewNodeInstanceServer::changePreviewImageSize( + const ChangePreviewImageSizeCommand &command) +{ + m_previewSize = command.size; + + collectItemChangesAndSendChangeCommands(); +} + } // namespace QmlDesigner |