aboutsummaryrefslogtreecommitdiffstats
path: root/share/qtcreator/qml/qmlpuppet/qml2puppet/instances
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@nokia.com>2011-08-31 18:19:45 +0200
committerMarco Bubke <marco.bubke@nokia.com>2011-08-31 18:50:04 +0200
commit7fa9e52d709ce3e7e3166ea37e3e42528a1c8c72 (patch)
tree41c77da2fc2fbf6ccd5fad9563bb2094393a6783 /share/qtcreator/qml/qmlpuppet/qml2puppet/instances
parentd9b10dca48eb0bf5995888afe0a78742f03bfd4b (diff)
QmlDesigner.NodeInstances: Create effect items only in the render process
Change-Id: I0506bf898582ba8e26a22f51737eae4d82f06c63 Reviewed-on: http://codereview.qt.nokia.com/4004 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet/qml2puppet/instances')
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp3
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp27
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h3
3 files changed, 27 insertions, 6 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
index f76c1f748e..7d32a60138 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
@@ -60,6 +60,8 @@
#include "completecomponentcommand.h"
#include "componentcompletedcommand.h"
#include "createscenecommand.h"
+#include "sgitemnodeinstance.h"
+
#include "dummycontextobject.h"
@@ -70,6 +72,7 @@ namespace QmlDesigner {
Qt5RenderNodeInstanceServer::Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
Qt5NodeInstanceServer(nodeInstanceClient)
{
+ Internal::SGItemNodeInstance::createEffectItem(true);
}
void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands()
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp
index ddfeabec09..8cd232e158 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp
@@ -45,6 +45,8 @@
namespace QmlDesigner {
namespace Internal {
+bool SGItemNodeInstance::s_createEffectItem = false;
+
SGItemNodeInstance::SGItemNodeInstance(QSGItem *item)
: ObjectNodeInstance(item),
m_hasHeight(false),
@@ -186,23 +188,27 @@ bool SGItemNodeInstance::equalSGItem(QSGItem *item) const
void SGItemNodeInstance::updateDirtyNodeRecursive(QSGItem *parentItem) const
{
- DesignerSupport::updateDirtyNode(parentItem);
-
foreach (QSGItem *childItem, parentItem->childItems()) {
if (!nodeInstanceServer()->hasInstanceForObject(childItem))
updateDirtyNodeRecursive(childItem);
}
+
+ DesignerSupport::updateDirtyNode(parentItem);
}
QImage SGItemNodeInstance::renderImage() const
{
updateDirtyNodeRecursive(sgItem());
- QImage image = designerSupport()->renderImageForItem(sgItem(), boundingRectWithStepChilds(sgItem()));
+ QRectF boundingRect = boundingRectWithStepChilds(sgItem());
+
+ QImage renderImage = designerSupport()->renderImageForItem(sgItem(), boundingRect, boundingRect.size().toSize());
- image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+ qDebug() << __FUNCTION__ << renderImage.size();
- return image;
+ renderImage = renderImage.convertToFormat(QImage::Format_ARGB32_Premultiplied);
+
+ return renderImage;
}
bool SGItemNodeInstance::isMovable() const
@@ -244,7 +250,9 @@ void SGItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNod
sgItem()->setParentItem(qobject_cast<QSGItem*>(nodeInstanceServer()->sgView()->rootObject()));
}
- designerSupport()->refFromEffectItem(sgItem());
+ if (s_createEffectItem || instanceId() == 0)
+ designerSupport()->refFromEffectItem(sgItem());
+
ObjectNodeInstance::initialize(objectNodeInstance);
sgItem()->update();
}
@@ -311,6 +319,8 @@ QRectF SGItemNodeInstance::boundingRect() const
void SGItemNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
{
+ if (name == "width" || name == "height")
+ qDebug() << __FUNCTION__ << name << value;
if (name == "state")
return; // states are only set by us
@@ -583,6 +593,11 @@ Qt5NodeInstanceServer *SGItemNodeInstance::qt5NodeInstanceServer() const
return qobject_cast<Qt5NodeInstanceServer*>(nodeInstanceServer());
}
+void SGItemNodeInstance::createEffectItem(bool createEffectItem)
+{
+ s_createEffectItem = createEffectItem;
+}
+
} // namespace Internal
} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h
index d88fead3b3..7b1995608c 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h
@@ -109,6 +109,8 @@ public:
DesignerSupport *designerSupport() const;
Qt5NodeInstanceServer *qt5NodeInstanceServer() const;
+ static void createEffectItem(bool createEffectItem);
+
protected:
SGItemNodeInstance(QSGItem*);
QSGItem *sgItem() const;
@@ -128,6 +130,7 @@ private: //variables
double m_y;
double m_width;
double m_height;
+ static bool s_createEffectItem;
};
} // namespace Internal