Commit c13624fb authored by Marco Bubke's avatar Marco Bubke

QmlDesigner.NodeInstances: Preview images for Qml2

Change-Id: I00ba96458ab8cb2e9d9766e1ecfeaea15bf2e040
Reviewed-on: http://codereview.qt.nokia.com/4006Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent cafc2a6c
......@@ -87,14 +87,31 @@ void Qt5PreviewNodeInstanceServer::changeState(const ChangeStateCommand &/*comma
}
static void updateDirtyNodeRecursive(QSGItem *parentItem)
{
foreach (QSGItem *childItem, parentItem->childItems())
updateDirtyNodeRecursive(childItem);
DesignerSupport::updateDirtyNode(parentItem);
}
QImage Qt5PreviewNodeInstanceServer::renderPreviewImage()
{
QSize size = rootNodeInstance().boundingRect().size().toSize();
size.scale(100, 100, Qt::KeepAspectRatio);
updateDirtyNodeRecursive(rootNodeInstance().internalSGItem());
QRectF boundingRect = rootNodeInstance().boundingRect();
QSize previewImageSize = boundingRect.size().toSize();
previewImageSize.scale(QSize(100, 100), Qt::KeepAspectRatio);
QImage previewImage;
if (boundingRect.isValid() && rootNodeInstance().internalSGItem())
previewImage = designerSupport()->renderImageForItem(rootNodeInstance().internalSGItem(), boundingRect, previewImageSize);
QImage image(size, QImage::Format_ARGB32);
previewImage = previewImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
return image;
return previewImage;
}
} // namespace QmlDesigner
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment