forked from qt-creator/qt-creator
QmlDesigner.NodeInstances: Preview images for Qml2
Change-Id: I00ba96458ab8cb2e9d9766e1ecfeaea15bf2e040 Reviewed-on: http://codereview.qt.nokia.com/4006 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
This commit is contained in:
+21
-4
@@ -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());
|
||||
|
||||
QImage image(size, QImage::Format_ARGB32);
|
||||
QRectF boundingRect = rootNodeInstance().boundingRect();
|
||||
|
||||
return image;
|
||||
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);
|
||||
|
||||
previewImage = previewImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||
|
||||
return previewImage;
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
||||
Reference in New Issue
Block a user