summaryrefslogtreecommitdiff
path: root/share/qtcreator/qml/qmlpuppet/qml2puppet
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@nokia.com>2011-06-22 18:17:06 +0200
committerThomas Hartmann <Thomas.Hartmann@nokia.com>2011-06-22 18:24:36 +0200
commit8fe33023297fca0d9181dd26c58c37ab1007650d (patch)
tree9fb409f209ca1507cd765a195a05a33f6af240b2 /share/qtcreator/qml/qmlpuppet/qml2puppet
parent8ec524910a11b3b1c62d4df76e77c8859785be6a (diff)
downloadqt-creator-8fe33023297fca0d9181dd26c58c37ab1007650d.tar.gz
QmlDesigner.NodeInstances: Move qmlpuppet to share
Change-Id: Id50d8c6130e9d5169a74015bc24e84de64eabfa7 Reviewed-on: http://codereview.qt.nokia.com/634 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')
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/Info.plist.in29
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri15
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp275
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h94
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp89
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.h81
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp197
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.h114
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp132
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.h93
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp186
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.h91
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp668
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h170
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/main.cpp71
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pro41
16 files changed, 2346 insertions, 0 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/Info.plist.in b/share/qtcreator/qml/qmlpuppet/qml2puppet/Info.plist.in
new file mode 100644
index 0000000000..b0406b7879
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/Info.plist.in
@@ -0,0 +1,29 @@
+<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
+<plist version=\"1.0\">
+<dict>
+ <key>NSHumanReadableCopyright</key>
+ <string>(C) 2008-2011 Nokia Corporation
+Commercial Usage
+
+Licensees holding valid Qt Commercial licenses may use this file in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
+
+GNU Lesser General Public License Usage
+
+Alternatively, this plugin may be used under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation and appearing in the file LICENSE.LGPL included in the packaging of this file. Please review the following information to ensure the GNU Lesser General Public License version 2.1 requirements will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleSignature</key>
+ <string>@TYPEINFO@</string>
+ <key>CFBundleExecutable</key>
+ <string>@EXECUTABLE@</string>
+ <key>CFBundleIdentifier</key>
+ <string>com.nokia.qtcreator.qml2puppet</string>
+ <key>CFBundleVersion</key>
+ <string>$$QTCREATOR_VERSION</string>
+ <key>CFBundleShortVersionString</key>
+ <string>$$QTCREATOR_VERSION</string>
+ <key>LSUIElement</key>
+ <string>1</string>
+</dict>
+</plist>
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri
new file mode 100644
index 0000000000..1eeb3d40b5
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri
@@ -0,0 +1,15 @@
+INCLUDEPATH += $$PWD/
+
+HEADERS += $$PWD/qt5nodeinstanceserver.h \
+ instances/qt5informationnodeinstanceserver.h \
+ instances/qt5rendernodeinstanceserver.h \
+ instances/qt5previewnodeinstanceserver.h
+HEADERS += $$PWD/qt5nodeinstanceclientproxy.h
+HEADERS += $$PWD/sgitemnodeinstance.h
+
+SOURCES += $$PWD/qt5nodeinstanceserver.cpp \
+ instances/qt5informationnodeinstanceserver.cpp \
+ instances/qt5rendernodeinstanceserver.cpp \
+ instances/qt5previewnodeinstanceserver.cpp
+SOURCES += $$PWD/qt5nodeinstanceclientproxy.cpp
+SOURCES += $$PWD/sgitemnodeinstance.cpp
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
new file mode 100644
index 0000000000..1e8cd6bdf3
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
@@ -0,0 +1,275 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#include "qt5informationnodeinstanceserver.h"
+
+#include <QSGItem>
+
+#include "servernodeinstance.h"
+#include "childrenchangeeventfilter.h"
+#include "propertyabstractcontainer.h"
+#include "propertybindingcontainer.h"
+#include "propertyvaluecontainer.h"
+#include "instancecontainer.h"
+#include "createinstancescommand.h"
+#include "changefileurlcommand.h"
+#include "clearscenecommand.h"
+#include "reparentinstancescommand.h"
+#include "changevaluescommand.h"
+#include "changebindingscommand.h"
+#include "changeidscommand.h"
+#include "removeinstancescommand.h"
+#include "nodeinstanceclientinterface.h"
+#include "removepropertiescommand.h"
+#include "valueschangedcommand.h"
+#include "informationchangedcommand.h"
+#include "pixmapchangedcommand.h"
+#include "commondefines.h"
+#include "childrenchangeeventfilter.h"
+#include "changestatecommand.h"
+#include "childrenchangedcommand.h"
+#include "completecomponentcommand.h"
+#include "componentcompletedcommand.h"
+#include "createscenecommand.h"
+
+#include "dummycontextobject.h"
+
+#include "designersupportfunctions.h"
+
+namespace QmlDesigner {
+
+Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
+ Qt5NodeInstanceServer(nodeInstanceClient)
+{
+}
+
+void Qt5InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands()
+{
+ static bool inFunction = false;
+ if (!inFunction) {
+ inFunction = true;
+
+ QSet<ServerNodeInstance> informationChangedInstanceSet;
+ QVector<InstancePropertyPair> propertyChangedList;
+ bool adjustSceneRect = false;
+
+ if (sgView()) {
+ foreach (QSGItem *item, allItems()) {
+ if (item && hasInstanceForObject(item)) {
+ ServerNodeInstance instance = instanceForObject(item);
+
+ DesignerSupport::DirtyType informationsDirty = DesignerSupport::DirtyType(DesignerSupport::TransformUpdateMask
+ | DesignerSupport::Visible
+ | DesignerSupport::ZValue
+ | DesignerSupport::OpacityValue);
+ if (DesignerSupport::dirty(item, informationsDirty))
+ informationChangedInstanceSet.insert(instance);
+
+
+ if (DesignerSupport::dirty(item, DesignerSupport::ParentChanged)) {
+ m_parentChangedSet.insert(instance);
+ informationChangedInstanceSet.insert(instance);
+ }
+// if (d->geometryChanged) {
+// if (instance.isRootNodeInstance())
+// declarativeView()->scene()->setSceneRect(item->boundingRect());
+// }
+
+ }
+ }
+
+ foreach (const InstancePropertyPair& property, changedPropertyList()) {
+ const ServerNodeInstance instance = property.first;
+ const QString propertyName = property.second;
+
+ if (instance.isValid()) {
+ if (instance.isRootNodeInstance() && (propertyName == "width" || propertyName == "height"))
+ adjustSceneRect = true;
+
+ if (propertyName.contains("anchors"))
+ informationChangedInstanceSet.insert(instance);
+
+ propertyChangedList.append(property);
+ }
+ }
+
+ resetAllItems();
+ clearChangedPropertyList();
+
+ if (!informationChangedInstanceSet.isEmpty())
+ nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(informationChangedInstanceSet.toList()));
+
+ if (!propertyChangedList.isEmpty())
+ nodeInstanceClient()->valuesChanged(createValuesChangedCommand(propertyChangedList));
+
+ if (!m_parentChangedSet.isEmpty()) {
+ sendChildrenChangedCommand(m_parentChangedSet.toList());
+ m_parentChangedSet.clear();
+ }
+
+// if (adjustSceneRect) {
+// QRectF boundingRect = rootNodeInstance().boundingRect();
+// if (boundingRect.isValid()) {
+// declarativeView()->setSceneRect(boundingRect);
+// }
+// }
+
+ if (!m_completedComponentList.isEmpty()) {
+ nodeInstanceClient()->componentCompleted(createComponentCompletedCommand(m_completedComponentList));
+ m_completedComponentList.clear();
+ }
+
+ slowDownRenderTimer();
+ nodeInstanceClient()->flush();
+ nodeInstanceClient()->synchronizeWithClientProcess();
+ }
+
+ inFunction = false;
+ }
+}
+
+void Qt5InformationNodeInstanceServer::reparentInstances(const ReparentInstancesCommand &command)
+{
+ foreach (const ReparentContainer &container, command.reparentInstances()) {
+ ServerNodeInstance instance = instanceForId(container.instanceId());
+ if (instance.isValid()) {
+ m_parentChangedSet.insert(instance);
+ }
+ }
+
+ Qt5NodeInstanceServer::reparentInstances(command);
+}
+
+void Qt5InformationNodeInstanceServer::clearScene(const ClearSceneCommand &command)
+{
+ Qt5NodeInstanceServer::clearScene(command);
+
+ m_parentChangedSet.clear();
+ m_completedComponentList.clear();
+}
+
+void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &command)
+{
+ Qt5NodeInstanceServer::createScene(command);
+
+ QList<ServerNodeInstance> instanceList;
+ foreach (const InstanceContainer &container, command.instances()) {
+ ServerNodeInstance instance = instanceForId(container.instanceId());
+ if (instance.isValid()) {
+ instanceList.append(instance);
+ }
+ }
+
+ nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(instanceList, true));
+ nodeInstanceClient()->valuesChanged(createValuesChangedCommand(instanceList));
+ sendChildrenChangedCommand(instanceList);
+ nodeInstanceClient()->componentCompleted(createComponentCompletedCommand(instanceList));
+
+}
+
+void Qt5InformationNodeInstanceServer::sendChildrenChangedCommand(const QList<ServerNodeInstance> childList)
+{
+ QSet<ServerNodeInstance> parentSet;
+ QList<ServerNodeInstance> noParentList;
+
+ foreach (const ServerNodeInstance &child, childList) {
+ if (!child.hasParent()) {
+ noParentList.append(child);
+ } else {
+ ServerNodeInstance parent = child.parent();
+ if (parent.isValid()) {
+ parentSet.insert(parent);
+ } else {
+ noParentList.append(child);
+ }
+ }
+ }
+
+ foreach (const ServerNodeInstance &parent, parentSet)
+ nodeInstanceClient()->childrenChanged(createChildrenChangedCommand(parent, parent.childItems()));
+
+ if (!noParentList.isEmpty())
+ nodeInstanceClient()->childrenChanged(createChildrenChangedCommand(ServerNodeInstance(), noParentList));
+
+}
+
+void Qt5InformationNodeInstanceServer::completeComponent(const CompleteComponentCommand &command)
+{
+ Qt5NodeInstanceServer::completeComponent(command);
+
+ QList<ServerNodeInstance> instanceList;
+ foreach (qint32 instanceId, command.instances()) {
+ ServerNodeInstance instance = instanceForId(instanceId);
+ if (instance.isValid()) {
+ instanceList.append(instance);
+ }
+ }
+
+ m_completedComponentList.append(instanceList);
+
+ nodeInstanceClient()->valuesChanged(createValuesChangedCommand(instanceList));
+ nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(instanceList, true));
+}
+
+} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
new file mode 100644
index 0000000000..c0c078fc47
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h
@@ -0,0 +1,94 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#ifndef QMLDESIGNER_QT5INFORMATIONNODEINSTANCESERVER_H
+#define QMLDESIGNER_QT5INFORMATIONNODEINSTANCESERVER_H
+
+#include "qt5nodeinstanceserver.h"
+
+namespace QmlDesigner {
+
+class Qt5InformationNodeInstanceServer : public Qt5NodeInstanceServer
+{
+ Q_OBJECT
+public:
+ explicit Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
+
+ void reparentInstances(const ReparentInstancesCommand &command);
+ void clearScene(const ClearSceneCommand &command);
+ void createScene(const CreateSceneCommand &command);
+ void completeComponent(const CompleteComponentCommand &command);
+
+protected:
+ void collectItemChangesAndSendChangeCommands();
+ void sendChildrenChangedCommand(const QList<ServerNodeInstance> childList);
+
+private:
+ QSet<ServerNodeInstance> m_parentChangedSet;
+ QList<ServerNodeInstance> m_completedComponentList;
+};
+
+} // namespace QmlDesigner
+
+#endif // QMLDESIGNER_QT5INFORMATIONNODEINSTANCESERVER_H
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp
new file mode 100644
index 0000000000..b66784a9a5
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp
@@ -0,0 +1,89 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#include "qt5nodeinstanceclientproxy.h"
+
+#include <QCoreApplication>
+
+#include "qt5informationnodeinstanceserver.h"
+#include "qt5previewnodeinstanceserver.h"
+#include "qt5rendernodeinstanceserver.h"
+
+namespace QmlDesigner {
+
+Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) :
+ NodeInstanceClientProxy(parent)
+{
+ if (QCoreApplication::arguments().at(2) == QLatin1String("previewmode")) {
+ setNodeInstanceServer(new Qt5PreviewNodeInstanceServer(this));
+ } else if (QCoreApplication::arguments().at(2) == QLatin1String("editormode")) {
+ setNodeInstanceServer(new Qt5InformationNodeInstanceServer(this));
+ } else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) {
+ setNodeInstanceServer(new Qt5RenderNodeInstanceServer(this));
+ }
+
+ initializeSocket();
+}
+
+} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.h
new file mode 100644
index 0000000000..2739bddbc9
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.h
@@ -0,0 +1,81 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#ifndef QMLDESIGNER_QT5NODEINSTANCECLIENTPROXY_H
+#define QMLDESIGNER_QT5NODEINSTANCECLIENTPROXY_H
+
+#include "nodeinstanceclientproxy.h"
+
+namespace QmlDesigner {
+
+class Qt5NodeInstanceClientProxy : public NodeInstanceClientProxy
+{
+ Q_OBJECT
+public:
+ explicit Qt5NodeInstanceClientProxy(QObject *parent = 0);
+};
+
+} // namespace QmlDesigner
+
+#endif // QMLDESIGNER_QT5NODEINSTANCECLIENTPROXY_H
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
new file mode 100644
index 0000000000..a97b2202ec
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp
@@ -0,0 +1,197 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#include "qt5nodeinstanceserver.h"
+
+#if QT_VERSION >= 0x050000
+
+#include <QSGItem>
+#include <QSGView>
+
+#include <designersupportfunctions.h>
+#include <addimportcontainer.h>
+#include <createscenecommand.h>
+
+namespace QmlDesigner {
+
+Qt5NodeInstanceServer::Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient)
+ : NodeInstanceServer(nodeInstanceClient),
+ m_designerSupport(new DesignerSupport)
+{
+ addImportString("import QtQuick 2.0\n");
+}
+
+Qt5NodeInstanceServer::~Qt5NodeInstanceServer()
+{
+ delete sgView();
+ delete m_designerSupport;
+ m_designerSupport = 0;
+}
+
+QSGView *Qt5NodeInstanceServer::sgView() const
+{
+ return m_sgView.data();
+}
+
+void Qt5NodeInstanceServer::initializeView(const QVector<AddImportContainer> &/*importVector*/)
+{
+ Q_ASSERT(!sgView());
+
+ m_sgView = new QSGView;
+#ifndef Q_WS_MAC
+ sgView()->setAttribute(Qt::WA_DontShowOnScreen, true);
+#endif
+ sgView()->show();
+#ifdef Q_WS_MAC
+ sgView()->setAttribute(Qt::WA_DontShowOnScreen, true);
+#endif
+ sgView()->setUpdatesEnabled(false);
+}
+
+QDeclarativeView *Qt5NodeInstanceServer::declarativeView() const
+{
+ return 0;
+}
+
+QDeclarativeEngine *Qt5NodeInstanceServer::engine() const
+{
+ if (sgView())
+ return sgView()->engine();
+
+ return 0;
+}
+
+void Qt5NodeInstanceServer::resizeCanvasSizeToRootItemSize()
+{
+ if (sgView())
+ sgView()->resize(rootNodeInstance().size().toSize());
+}
+
+void Qt5NodeInstanceServer::resetAllItems()
+{
+ foreach (QSGItem *item, allItems())
+ DesignerSupport::resetDirty(item);
+}
+
+QList<ServerNodeInstance> Qt5NodeInstanceServer::setupScene(const CreateSceneCommand &command)
+{
+ setupFileUrl(command.fileUrl());
+ setupImports(command.imports());
+
+ QList<ServerNodeInstance> instanceList = setupInstances(command);
+
+ sgView()->resize(rootNodeInstance().boundingRect().size().toSize());
+
+ return instanceList;
+}
+
+QList<QSGItem*> subItems(QSGItem *parentItem)
+{
+ QList<QSGItem*> itemList;
+ itemList.append(parentItem->childItems());
+
+ foreach (QSGItem *childItem, parentItem->childItems())
+ itemList.append(subItems(childItem));
+
+ return itemList;
+}
+
+QList<QSGItem*> Qt5NodeInstanceServer::allItems() const
+{
+ QList<QSGItem*> itemList;
+
+ if (sgView()) {
+ itemList.append(sgView()->rootItem());
+ itemList.append(subItems(sgView()->rootItem()));
+ }
+
+ return itemList;
+}
+
+void Qt5NodeInstanceServer::refreshBindings()
+{
+ DesignerSupport::refreshExpressions(context());
+}
+
+DesignerSupport *Qt5NodeInstanceServer::designerSupport() const
+{
+ return m_designerSupport;
+}
+
+void Qt5NodeInstanceServer::createScene(const CreateSceneCommand &command)
+{
+ m_designerSupport = new DesignerSupport;
+ NodeInstanceServer::createScene(command);
+}
+
+void Qt5NodeInstanceServer::clearScene(const ClearSceneCommand &command)
+{
+ NodeInstanceServer::clearScene(command);
+ delete m_designerSupport;
+ m_designerSupport = 0;
+}
+
+} // QmlDesigner
+
+#endif // QT_VERSION
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.h
new file mode 100644
index 0000000000..4faa447eee
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.h
@@ -0,0 +1,114 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#ifndef QT5NODEINSTANCESERVER_H
+#define QT5NODEINSTANCESERVER_H
+
+#include <QtGlobal>
+
+#include "nodeinstanceserver.h"
+
+#if QT_VERSION >= 0x050000
+
+QT_BEGIN_NAMESPACE
+class QSGItem;
+class DesignerSupport;
+QT_END_NAMESPACE
+
+namespace QmlDesigner {
+
+class Qt5NodeInstanceServer : public NodeInstanceServer
+{
+ Q_OBJECT
+public:
+ Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
+ ~Qt5NodeInstanceServer();
+
+ QSGView *sgView() const;
+ QDeclarativeView *declarativeView() const;
+ QDeclarativeEngine *engine() const;
+ void refreshBindings();
+
+ DesignerSupport *designerSupport() const;
+
+ void createScene(const CreateSceneCommand &command);
+ void clearScene(const ClearSceneCommand &command);
+
+protected:
+ void initializeView(const QVector<AddImportContainer> &importVector);
+ void resizeCanvasSizeToRootItemSize();
+ void resetAllItems();
+ QList<ServerNodeInstance> setupScene(const CreateSceneCommand &command);
+ QList<QSGItem*> allItems() const;
+
+private:
+ QWeakPointer<QSGView> m_sgView;
+ DesignerSupport *m_designerSupport;
+};
+
+} // QmlDesigner
+
+#endif // QT_VERSION
+
+#endif // QT5NODEINSTANCESERVER_H
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp
new file mode 100644
index 0000000000..e432ba32fa
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp
@@ -0,0 +1,132 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#include "qt5previewnodeinstanceserver.h"
+
+#include "nodeinstanceclientinterface.h"
+#include "statepreviewimagechangedcommand.h"
+#include "createscenecommand.h"
+
+namespace QmlDesigner {
+
+Qt5PreviewNodeInstanceServer::Qt5PreviewNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
+ Qt5NodeInstanceServer(nodeInstanceClient)
+{
+}
+
+void Qt5PreviewNodeInstanceServer::createScene(const CreateSceneCommand &command)
+{
+ initializeView(command.imports());
+ setupScene(command);
+
+ startRenderTimer();
+}
+void Qt5PreviewNodeInstanceServer::startRenderTimer()
+{
+ if (timerId() != 0)
+ killTimer(timerId());
+
+ int timerId = startTimer(renderTimerInterval());
+
+ setTimerId(timerId);
+}
+
+void Qt5PreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands()
+{
+ static bool inFunction = false;
+
+ if (!inFunction && nodeInstanceClient()->bytesToWrite() < 10000) {
+ inFunction = true;
+ QVector<ImageContainer> imageContainerVector;
+ imageContainerVector.append(ImageContainer(0, renderPreviewImage()));
+
+ foreach (ServerNodeInstance instance, rootNodeInstance().stateInstances()) {
+ instance.activateState();
+ imageContainerVector.append(ImageContainer(instance.instanceId(), renderPreviewImage()));
+ instance.deactivateState();
+ }
+
+ nodeInstanceClient()->statePreviewImagesChanged(StatePreviewImageChangedCommand(imageContainerVector));
+
+ slowDownRenderTimer();
+ inFunction = false;
+ }
+}
+
+void Qt5PreviewNodeInstanceServer::changeState(const ChangeStateCommand &/*command*/)
+{
+
+}
+
+QImage Qt5PreviewNodeInstanceServer::renderPreviewImage()
+{
+ QSize size = rootNodeInstance().boundingRect().size().toSize();
+ size.scale(100, 100, Qt::KeepAspectRatio);
+
+ QImage image(size, QImage::Format_ARGB32);
+
+ return image;
+}
+
+} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.h
new file mode 100644
index 0000000000..bf60721274
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.h
@@ -0,0 +1,93 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#ifndef QMLDESIGNER_QT5PREVIEWNODEINSTANCESERVER_H
+#define QMLDESIGNER_QT5PREVIEWNODEINSTANCESERVER_H
+
+#include "qt5nodeinstanceserver.h"
+
+namespace QmlDesigner {
+
+class Qt5PreviewNodeInstanceServer : public Qt5NodeInstanceServer
+{
+ Q_OBJECT
+public:
+ explicit Qt5PreviewNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
+
+ void createScene(const CreateSceneCommand &command);
+ void changeState(const ChangeStateCommand &command);
+
+ QImage renderPreviewImage();
+
+protected:
+ void collectItemChangesAndSendChangeCommands();
+ void startRenderTimer();
+
+private:
+ ServerNodeInstance m_actualState;
+};
+
+} // namespace QmlDesigner
+
+#endif // QMLDESIGNER_QT5PREVIEWNODEINSTANCESERVER_H
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
new file mode 100644
index 0000000000..e25c0ce3b1
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp
@@ -0,0 +1,186 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#include "qt5rendernodeinstanceserver.h"
+
+#include <QSGItem>
+
+#include "servernodeinstance.h"
+#include "childrenchangeeventfilter.h"
+#include "propertyabstractcontainer.h"
+#include "propertybindingcontainer.h"
+#include "propertyvaluecontainer.h"
+#include "instancecontainer.h"
+#include "createinstancescommand.h"
+#include "changefileurlcommand.h"
+#include "clearscenecommand.h"
+#include "reparentinstancescommand.h"
+#include "changevaluescommand.h"
+#include "changebindingscommand.h"
+#include "changeidscommand.h"
+#include "removeinstancescommand.h"
+#include "nodeinstanceclientinterface.h"
+#include "removepropertiescommand.h"
+#include "valueschangedcommand.h"
+#include "informationchangedcommand.h"
+#include "pixmapchangedcommand.h"
+#include "commondefines.h"
+#include "childrenchangeeventfilter.h"
+#include "changestatecommand.h"
+#include "childrenchangedcommand.h"
+#include "completecomponentcommand.h"
+#include "componentcompletedcommand.h"
+#include "createscenecommand.h"
+
+#include "dummycontextobject.h"
+
+#include "designersupportfunctions.h"
+
+namespace QmlDesigner {
+
+Qt5RenderNodeInstanceServer::Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) :
+ Qt5NodeInstanceServer(nodeInstanceClient)
+{
+}
+
+void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands()
+{
+ static bool inFunction = false;
+ if (!inFunction) {
+ inFunction = true;
+
+ bool adjustSceneRect = false;
+
+ if (sgView()) {
+ foreach (QSGItem *item, allItems()) {
+ if (item && hasInstanceForObject(item)) {
+ ServerNodeInstance instance = instanceForObject(item);
+ if (DesignerSupport::dirty(item, DesignerSupport::ContentUpdateMask))
+ m_dirtyInstanceSet.insert(instance);
+ }
+ }
+
+ clearChangedPropertyList();
+ resetAllItems();
+
+ if (!m_dirtyInstanceSet.isEmpty() && nodeInstanceClient()->bytesToWrite() < 10000) {
+ nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(m_dirtyInstanceSet.toList()));
+ m_dirtyInstanceSet.clear();
+ }
+
+// if (adjustSceneRect) {
+// QRectF boundingRect = rootNodeInstance().boundingRect();
+// if (boundingRect.isValid()) {
+// declarativeView()->setSceneRect(boundingRect);
+// }
+// }
+
+ slowDownRenderTimer();
+ nodeInstanceClient()->flush();
+ nodeInstanceClient()->synchronizeWithClientProcess();
+ }
+
+ inFunction = false;
+ }
+}
+
+
+void Qt5RenderNodeInstanceServer::createScene(const CreateSceneCommand &command)
+{
+ NodeInstanceServer::createScene(command);
+
+ QList<ServerNodeInstance> instanceList;
+ foreach (const InstanceContainer &container, command.instances()) {
+ ServerNodeInstance instance = instanceForId(container.instanceId());
+ if (instance.isValid()) {
+ instanceList.append(instance);
+ }
+ }
+
+ nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList));
+}
+
+void Qt5RenderNodeInstanceServer::clearScene(const ClearSceneCommand &command)
+{
+ NodeInstanceServer::clearScene(command);
+
+ m_dirtyInstanceSet.clear();
+}
+
+void Qt5RenderNodeInstanceServer::completeComponent(const CompleteComponentCommand &command)
+{
+ NodeInstanceServer::completeComponent(command);
+
+ QList<ServerNodeInstance> instanceList;
+ foreach (qint32 instanceId, command.instances()) {
+ ServerNodeInstance instance = instanceForId(instanceId);
+ if (instance.isValid()) {
+ instanceList.append(instance);
+ }
+ }
+
+ nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList));
+}
+
+} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.h
new file mode 100644
index 0000000000..78aae47692
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.h
@@ -0,0 +1,91 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#ifndef QMLDESIGNER_QT5RENDERNODEINSTANCESERVER_H
+#define QMLDESIGNER_QT5RENDERNODEINSTANCESERVER_H
+
+#include "qt5nodeinstanceserver.h"
+
+namespace QmlDesigner {
+
+class Qt5RenderNodeInstanceServer : public Qt5NodeInstanceServer
+{
+ Q_OBJECT
+public:
+ explicit Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient);
+
+ void createScene(const CreateSceneCommand &command);
+ void clearScene(const ClearSceneCommand &command);
+ void completeComponent(const CompleteComponentCommand &command);
+
+protected:
+ void collectItemChangesAndSendChangeCommands();
+
+private:
+ QSet<ServerNodeInstance> m_dirtyInstanceSet;
+};
+
+} // namespace QmlDesigner
+
+#endif // QMLDESIGNER_QT5RENDERNODEINSTANCESERVER_H
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp
new file mode 100644
index 0000000000..8735ddf7d5
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.cpp
@@ -0,0 +1,668 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#include "sgitemnodeinstance.h"
+
+#if QT_VERSION >= 0x050000
+
+#include "qt5nodeinstanceserver.h"
+
+#include <QDeclarativeExpression>
+#include <QSGView>
+#include <cmath>
+
+#include <QHash>
+
+#include <QtDebug>
+
+namespace QmlDesigner {
+namespace Internal {
+
+SGItemNodeInstance::SGItemNodeInstance(QSGItem *item)
+ : ObjectNodeInstance(item),
+ m_hasHeight(false),
+ m_hasWidth(false),
+ m_isResizable(true),
+ m_hasContent(true),
+ m_isMovable(true),
+ m_x(0.0),
+ m_y(0.0),
+ m_width(0.0),
+ m_height(0.0)
+{
+}
+
+SGItemNodeInstance::~SGItemNodeInstance()
+{
+ if (sgItem())
+ designerSupport()->derefFromEffectItem(sgItem());
+}
+
+bool SGItemNodeInstance::hasContent() const
+{
+ return m_hasContent;
+}
+
+QList<ServerNodeInstance> SGItemNodeInstance::childItems() const
+{
+ QList<ServerNodeInstance> instanceList;
+
+ foreach (QSGItem *childItem, sgItem()->childItems())
+ {
+ if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) {
+ instanceList.append(nodeInstanceServer()->instanceForObject(childItem));
+ } else { //there might be an item in between the parent instance
+ //and the child instance.
+ //Popular example is flickable which has a viewport item between
+ //the flickable item and the flickable children
+ instanceList.append(childItemsForChild(childItem)); //In such a case we go deeper inside the item and
+ //search for child items with instances.
+ }
+ }
+
+ return instanceList;
+}
+
+QList<ServerNodeInstance> SGItemNodeInstance::childItemsForChild(QSGItem *childItem) const
+{
+ QList<ServerNodeInstance> instanceList;
+
+ if (childItem) {
+ foreach (QSGItem *childItem, childItem->childItems())
+ {
+ if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) {
+ instanceList.append(nodeInstanceServer()->instanceForObject(childItem));
+ } else {
+ instanceList.append(childItemsForChild(childItem));
+ }
+ }
+ }
+ return instanceList;
+}
+
+void SGItemNodeInstance::setHasContent(bool hasContent)
+{
+ m_hasContent = hasContent;
+}
+
+
+bool anyItemHasContent(QSGItem *graphicsItem)
+{
+ if (graphicsItem->flags().testFlag(QSGItem::ItemHasContents))
+ return true;
+
+ foreach (QSGItem *childItem, graphicsItem->childItems()) {
+ if (anyItemHasContent(childItem))
+ return true;
+ }
+
+ return false;
+}
+
+QPointF SGItemNodeInstance::position() const
+{
+ return sgItem()->pos();
+}
+
+QTransform SGItemNodeInstance::transform() const
+{
+ return DesignerSupport::parentTransform(sgItem());
+}
+
+QTransform SGItemNodeInstance::customTransform() const
+{
+ return QTransform();
+}
+
+QTransform SGItemNodeInstance::sceneTransform() const
+{
+ return DesignerSupport::canvasTransform(sgItem());
+}
+
+double SGItemNodeInstance::rotation() const
+{
+ return sgItem()->rotation();
+}
+
+double SGItemNodeInstance::scale() const
+{
+ return sgItem()->scale();
+}
+
+QPointF SGItemNodeInstance::transformOriginPoint() const
+{
+ return sgItem()->transformOriginPoint();
+}
+
+double SGItemNodeInstance::zValue() const
+{
+ return sgItem()->z();
+}
+
+double SGItemNodeInstance::opacity() const
+{
+ return sgItem()->opacity();
+}
+
+QObject *SGItemNodeInstance::parent() const
+{
+ if (!sgItem() || !sgItem()->parentItem())
+ return 0;
+
+ return sgItem()->parentItem();
+}
+
+bool SGItemNodeInstance::equalSGItem(QSGItem *item) const
+{
+ return item == sgItem();
+}
+
+QImage SGItemNodeInstance::renderImage() const
+{
+ return designerSupport()->renderImageForItem(sgItem());
+}
+
+bool SGItemNodeInstance::isMovable() const
+{
+ return m_isMovable && sgItem() && sgItem()->parentItem();
+}
+
+void SGItemNodeInstance::setMovable(bool movable)
+{
+ m_isMovable = movable;
+}
+
+SGItemNodeInstance::Pointer SGItemNodeInstance::create(QObject *object)
+{
+ QSGItem *sgItem = qobject_cast<QSGItem*>(object);
+
+ Q_ASSERT(sgItem);
+
+ Pointer instance(new SGItemNodeInstance(sgItem));
+
+ instance->setHasContent(anyItemHasContent(sgItem));
+ sgItem->setFlag(QSGItem::ItemHasContents, true);
+
+ if (sgItem->inherits("QSGText"))
+ instance->setResizable(false);
+
+ static_cast<QDeclarativeParserStatus*>(sgItem)->classBegin();
+
+ instance->populateResetValueHash();
+
+ return instance;
+}
+
+void SGItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance)
+{
+ if (instanceId() == 0) {
+ DesignerSupport::setRootItem(nodeInstanceServer()->sgView(), sgItem());
+ } else {
+ sgItem()->setParentItem(qobject_cast<QSGItem*>(nodeInstanceServer()->sgView()->rootObject()));
+ }
+
+ designerSupport()->refFromEffectItem(sgItem());
+ ObjectNodeInstance::initialize(objectNodeInstance);
+ sgItem()->update();
+}
+
+bool SGItemNodeInstance::isSGItem() const
+{
+ return true;
+}
+
+QSizeF SGItemNodeInstance::size() const
+{
+ if (isValid()) {
+ double implicitWidth = sgItem()->implicitWidth();
+ if (!m_hasWidth
+ && implicitWidth // WORKAROUND
+ && sgItem()->width() <= 0
+ && implicitWidth != sgItem()->width()
+ && !hasBindingForProperty("width")) {
+ sgItem()->blockSignals(true);
+ sgItem()->setWidth(implicitWidth);
+ sgItem()->blockSignals(false);
+ }
+
+ double implicitHeight = sgItem()->implicitHeight();
+ if (!m_hasHeight
+ && implicitWidth // WORKAROUND
+ && sgItem()->height() <= 0
+ && implicitHeight != sgItem()->height()
+ && !hasBindingForProperty("height")) {
+ sgItem()->blockSignals(true);
+ sgItem()->setHeight(implicitHeight);
+ sgItem()->blockSignals(false);
+ }
+
+ }
+
+ if (isRootNodeInstance()) {
+ if (!m_hasWidth) {
+ sgItem()->blockSignals(true);
+ if (sgItem()->width() < 10.)
+ sgItem()->setWidth(100.);
+ sgItem()->blockSignals(false);
+ }
+
+ if (!m_hasHeight) {
+ sgItem()->blockSignals(true);
+ if (sgItem()->height() < 10.)
+ sgItem()->setHeight(100.);
+ sgItem()->blockSignals(false);
+ }
+ }
+
+ return QSizeF(sgItem()->width(), sgItem()->height());
+}
+
+QRectF SGItemNodeInstance::boundingRect() const
+{
+ if (isValid()) {
+ double implicitWidth = sgItem()->implicitWidth();
+ if (!m_hasWidth
+ && implicitWidth // WORKAROUND
+ && sgItem()->width() <= 0
+ && implicitWidth != sgItem()->width()
+ && !hasBindingForProperty("width")) {
+ sgItem()->blockSignals(true);
+ sgItem()->setWidth(implicitWidth);
+ sgItem()->blockSignals(false);
+ }
+
+ double implicitHeight = sgItem()->implicitHeight();
+ if (!m_hasHeight
+ && implicitWidth // WORKAROUND
+ && sgItem()->height() <= 0
+ && implicitHeight != sgItem()->height()
+ && !hasBindingForProperty("height")) {
+ sgItem()->blockSignals(true);
+ sgItem()->setHeight(implicitHeight);
+ sgItem()->blockSignals(false);
+ }
+
+ }
+
+ if (isRootNodeInstance()) {
+ if (!m_hasWidth) {
+ sgItem()->blockSignals(true);
+ if (sgItem()->width() < 10.)
+ sgItem()->setWidth(100.);
+ sgItem()->blockSignals(false);
+ }
+
+ if (!m_hasHeight) {
+ sgItem()->blockSignals(true);
+ if (sgItem()->height() < 10.)
+ sgItem()->setHeight(100.);
+ sgItem()->blockSignals(false);
+ }
+ }
+
+ if (sgItem())
+ return sgItem()->boundingRect();
+
+ return QRectF();
+}
+
+void SGItemNodeInstance::setPropertyVariant(const QString &name, const QVariant &value)
+{
+ if (name == "state")
+ return; // states are only set by us
+
+ if (name == "height") {
+ m_height = value.toDouble();
+ if (value.isValid())
+ m_hasHeight = true;
+ else
+ m_hasHeight = false;
+ }
+
+ if (name == "width") {
+ m_width = value.toDouble();
+ if (value.isValid())
+ m_hasWidth = true;
+ else
+ m_hasWidth = false;
+ }
+
+ if (name == "x")
+ m_x = value.toDouble();
+
+ if (name == "y")
+ m_y = value.toDouble();
+
+ ObjectNodeInstance::setPropertyVariant(name, value);
+
+ refresh();
+}
+
+void SGItemNodeInstance::setPropertyBinding(const QString &name, const QString &expression)
+{
+ if (name == "state")
+ return; // states are only set by us
+
+ ObjectNodeInstance::setPropertyBinding(name, expression);
+}
+
+QVariant SGItemNodeInstance::property(const QString &name) const
+{
+ if (name == "width" && !hasBindingForProperty("width")) {
+ double implicitWidth = sgItem()->implicitWidth();
+ if (!m_hasWidth
+ && implicitWidth // WORKAROUND
+ && sgItem()->width() <= 0
+ && implicitWidth != sgItem()->width()) {
+ sgItem()->blockSignals(true);
+ sgItem()->setWidth(implicitWidth);
+ sgItem()->blockSignals(false);
+ }
+ }
+
+ if (name == "height" && !hasBindingForProperty("height")) {
+ double implicitHeight = sgItem()->implicitHeight();
+ if (!m_hasHeight
+ && implicitHeight // WORKAROUND
+ && sgItem()->width() <= 0
+ && implicitHeight != sgItem()->height()) {
+ sgItem()->blockSignals(true);
+ sgItem()->setHeight(implicitHeight);
+ sgItem()->blockSignals(false);
+ }
+ }
+
+ return ObjectNodeInstance::property(name);
+}
+
+void SGItemNodeInstance::resetHorizontal()
+ {
+ setPropertyVariant("x", m_x);
+ if (m_width > 0.0) {
+ setPropertyVariant("width", m_width);
+ } else {
+ setPropertyVariant("width", sgItem()->implicitWidth());
+ }
+}
+
+void SGItemNodeInstance::resetVertical()
+ {
+ setPropertyVariant("y", m_y);
+ if (m_height > 0.0) {
+ setPropertyVariant("height", m_height);
+ } else {
+ setPropertyVariant("height", sgItem()->implicitWidth());
+ }
+}
+
+static void repositioning(QSGItem *item)
+{
+ if (!item)
+ return;
+
+// QDeclarativeBasePositioner *positioner = qobject_cast<QDeclarativeBasePositioner*>(item);
+// if (positioner)
+// positioner->rePositioning();
+
+ if (item->parentItem())
+ repositioning(item->parentItem());
+}
+
+void SGItemNodeInstance::refresh()
+{
+ repositioning(sgItem());
+}
+
+void SGItemNodeInstance::doComponentComplete()
+{
+ if (sgItem()) {
+ if (DesignerSupport::isComponentComplete(sgItem()))
+ return;
+ static_cast<QDeclarativeParserStatus*>(sgItem())->componentComplete();
+ }
+
+ sgItem()->update();
+}
+
+bool SGItemNodeInstance::isResizable() const
+{
+ return m_isResizable && sgItem() && sgItem()->parentItem();
+}
+
+void SGItemNodeInstance::setResizable(bool resizeable)
+{
+ m_isResizable = resizeable;
+}
+
+int SGItemNodeInstance::penWidth() const
+{
+ return DesignerSupport::borderWidth(sgItem());
+}
+
+void SGItemNodeInstance::resetProperty(const QString &name)
+{
+ if (name == "height") {
+ m_hasHeight = false;
+ m_height = 0.0;
+ }
+
+ if (name == "width") {
+ m_hasWidth = false;
+ m_width = 0.0;
+ }
+
+ if (name == "x")
+ m_x = 0.0;
+
+ if (name == "y")
+ m_y = 0.0;
+
+ DesignerSupport::resetAnchor(sgItem(), name);
+
+ if (name == "anchors.fill") {
+ resetHorizontal();
+ resetVertical();
+ } else if (name == "anchors.centerIn") {
+ resetHorizontal();
+ resetVertical();
+ } else if (name == "anchors.top") {
+ resetVertical();
+ } else if (name == "anchors.left") {
+ resetHorizontal();
+ } else if (name == "anchors.right") {
+ resetHorizontal();
+ } else if (name == "anchors.bottom") {
+ resetVertical();
+ } else if (name == "anchors.horizontalCenter") {
+ resetHorizontal();
+ } else if (name == "anchors.verticalCenter") {
+ resetVertical();
+ } else if (name == "anchors.baseline") {
+ resetVertical();
+ }
+
+ ObjectNodeInstance::resetProperty(name);
+}
+
+void SGItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const QString &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const QString &newParentProperty)
+{
+ if (oldParentInstance && oldParentInstance->isPositioner()) {
+ setInPositioner(false);
+ setMovable(true);
+ }
+
+ ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty);
+
+ if (newParentInstance && newParentInstance->isPositioner()) {
+ setInPositioner(true);
+ setMovable(false);
+ }
+
+ if (oldParentInstance && oldParentInstance->isPositioner() && !(newParentInstance && newParentInstance->isPositioner())) {
+ if (!hasBindingForProperty("x"))
+ setPropertyVariant("x", m_x);
+
+ if (!hasBindingForProperty("y"))
+ setPropertyVariant("y", m_y);
+ }
+
+ refresh();
+ DesignerSupport::updateDirtyNode(sgItem());
+}
+
+static bool isValidAnchorName(const QString &name)
+{
+ static QStringList anchorNameList(QStringList() << "anchors.top"
+ << "anchors.left"
+ << "anchors.right"
+ << "anchors.bottom"
+ << "anchors.verticalCenter"
+ << "anchors.horizontalCenter"
+ << "anchors.fill"
+ << "anchors.centerIn"
+ << "anchors.baseline");
+
+ return anchorNameList.contains(name);
+}
+
+bool SGItemNodeInstance::hasAnchor(const QString &name) const
+{
+ return DesignerSupport::hasAnchor(sgItem(), name);
+}
+
+QPair<QString, ServerNodeInstance> SGItemNodeInstance::anchor(const QString &name) const
+{
+ if (!isValidAnchorName(name) || !DesignerSupport::hasAnchor(sgItem(), name))
+ return ObjectNodeInstance::anchor(name);
+
+ QPair<QString, QObject*> nameObjectPair = DesignerSupport::anchorLineTarget(sgItem(), name, context());
+
+ QObject *targetObject = nameObjectPair.second;
+ QString targetName = nameObjectPair.first;
+
+ if (targetObject && nodeInstanceServer()->hasInstanceForObject(targetObject)) {
+ return qMakePair(targetName, nodeInstanceServer()->instanceForObject(targetObject));
+ } else {
+ return ObjectNodeInstance::anchor(name);
+ }
+}
+
+QList<ServerNodeInstance> SGItemNodeInstance::stateInstances() const
+{
+ QList<ServerNodeInstance> instanceList;
+ QList<QObject*> stateList = DesignerSupport::statesForItem(sgItem());
+ foreach (QObject *state, stateList)
+ {
+ if (state && nodeInstanceServer()->hasInstanceForObject(state))
+ instanceList.append(nodeInstanceServer()->instanceForObject(state));
+ }
+
+ return instanceList;
+}
+
+bool SGItemNodeInstance::isAnchoredBySibling() const
+{
+ if (sgItem()->parentItem()) {
+ foreach (QSGItem *siblingItem, sgItem()->parentItem()->childItems()) { // search in siblings for a anchor to this item
+ if (siblingItem) {
+ if (DesignerSupport::isAnchoredTo(siblingItem, sgItem()))
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+bool SGItemNodeInstance::isAnchoredByChildren() const
+{
+ if (DesignerSupport::areChildrenAnchoredTo(sgItem(), sgItem())) // search in children for a anchor to this item
+ return true;
+
+ return false;
+}
+
+QSGItem *SGItemNodeInstance::sgItem() const
+{
+ if (object() == 0)
+ return 0;
+
+ Q_ASSERT(qobject_cast<QSGItem*>(object()));
+ return static_cast<QSGItem*>(object());
+}
+
+DesignerSupport *SGItemNodeInstance::designerSupport() const
+{
+ return qt5NodeInstanceServer()->designerSupport();
+}
+
+Qt5NodeInstanceServer *SGItemNodeInstance::qt5NodeInstanceServer() const
+{
+ return qobject_cast<Qt5NodeInstanceServer*>(nodeInstanceServer());
+}
+
+} // namespace Internal
+} // namespace QmlDesigner
+
+#endif //QT_VERSION
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h
new file mode 100644
index 0000000000..de17a6216e
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/sgitemnodeinstance.h
@@ -0,0 +1,170 @@
+/**************************************************************************
+
+**
+
+** This file is part of Qt Creator
+
+**
+
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+
+**
+
+** Contact: Nokia Corporation (qt-info@nokia.com)
+
+**
+
+** No Commercial Usage
+
+**
+
+** This file contains pre-release code and may not be distributed.
+
+** You may use this file in accordance with the terms and conditions
+
+** contained in the Technology Preview License Agreement accompanying
+
+** this package.
+
+**
+
+** GNU Lesser General Public License Usage
+
+**
+
+** Alternatively, this file may be used under the terms of the GNU Lesser
+
+** General Public License version 2.1 as published by the Free Software
+
+** Foundation and appearing in the file LICENSE.LGPL included in the
+
+** packaging of this file. Please review the following information to
+
+** ensure the GNU Lesser General Public License version 2.1 requirements
+
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+
+**
+
+** In addition, as a special exception, Nokia gives you certain additional
+
+** rights. These rights are described in the Nokia Qt LGPL Exception
+
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+
+**
+
+** If you have questions regarding the use of this file, please contact
+
+** Nokia at qt-info@nokia.com.
+
+**
+
+**************************************************************************/
+
+#ifndef SGITEMNODEINSTANCE_H
+#define SGITEMNODEINSTANCE_H
+
+#include <QtGlobal>
+
+#if QT_VERSION >= 0x050000
+
+#include "objectnodeinstance.h"
+
+#include <QSGItem>
+#include <designersupportfunctions.h>
+
+namespace QmlDesigner {
+namespace Internal {
+
+class SGItemNodeInstance : public ObjectNodeInstance
+{
+public:
+ typedef QSharedPointer<SGItemNodeInstance> Pointer;
+ typedef QWeakPointer<SGItemNodeInstance> WeakPointer;
+
+ ~SGItemNodeInstance();
+
+ static Pointer create(QObject *objectToBeWrapped);
+ void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance);
+
+ bool isSGItem() const;
+
+ QRectF boundingRect() const;
+ QPointF position() const;
+ QSizeF size() const;
+ QTransform transform() const;
+ QTransform customTransform() const;
+ QTransform sceneTransform() const;
+ double opacity() const;
+
+ QObject *parent() const;
+
+ double rotation() const;
+ double scale() const;
+ QPointF transformOriginPoint() const;
+ double zValue() const;
+
+ bool equalSGItem(QSGItem *item) const;
+
+ bool hasContent() const;
+
+ QList<ServerNodeInstance> childItems() const;
+ QList<ServerNodeInstance> childItemsForChild(QSGItem *childItem) const;
+
+ bool isMovable() const;
+ void setMovable(bool movable);
+
+ void setPropertyVariant(const QString &name, const QVariant &value);
+ void setPropertyBinding(const QString &name, const QString &expression);
+
+ QVariant property(const QString &name) const;
+ void resetProperty(const QString &name);
+
+ void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const QString &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const QString &newParentProperty);
+
+ int penWidth() const;
+
+ bool hasAnchor(const QString &name) const;
+ QPair<QString, ServerNodeInstance> anchor(const QString &name) const;
+ bool isAnchoredBySibling() const;
+ bool isAnchoredByChildren() const;
+ void doComponentComplete();
+
+ bool isResizable() const;
+ void setResizable(bool resizeable);
+
+ void setHasContent(bool hasContent);
+
+ QList<ServerNodeInstance> stateInstances() const;
+
+ QImage renderImage() const;
+
+ DesignerSupport *designerSupport() const;
+ Qt5NodeInstanceServer *qt5NodeInstanceServer() const;
+
+protected:
+ SGItemNodeInstance(QSGItem*);
+ QSGItem *sgItem() const;
+ void resetHorizontal();
+ void resetVertical();
+ void refresh();
+
+private: //variables
+ bool m_hasHeight;
+ bool m_hasWidth;
+ bool m_isResizable;
+ bool m_hasContent;
+ bool m_isMovable;
+ double m_x;
+ double m_y;
+ double m_width;
+ double m_height;
+};
+
+} // namespace Internal
+} // namespace QmlDesigner
+
+#endif // QT_VERSION
+#endif // SGITEMNODEINSTANCE_H
+
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/main.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/main.cpp
new file mode 100644
index 0000000000..f1b1c6b90e
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/main.cpp
@@ -0,0 +1,71 @@
+/**************************************************************************
+**
+** This file is part of Qt Creator
+**
+** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
+**
+** Contact: Nokia Corporation (info@qt.nokia.com)
+**
+**
+** GNU Lesser General Public License Usage
+**
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this file.
+** Please review the following information to ensure the GNU Lesser General
+** Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** Other Usage
+**
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at info@qt.nokia.com.
+**
+**************************************************************************/
+
+#include <QtDebug>
+
+#include <QApplication>
+#include <QStringList>
+
+#include <qt5nodeinstanceclientproxy.h>
+
+#ifdef ENABLE_QT_BREAKPAD
+#include <qtsystemexceptionhandler.h>
+#endif
+
+#ifdef Q_OS_WIN
+#include <windows.h>
+#endif
+
+int main(int argc, char *argv[])
+{
+ QApplication application(argc, argv);
+
+ if (application.arguments().count() != 4)
+ return -1;
+
+ QCoreApplication::setOrganizationName("Nokia");
+ QCoreApplication::setOrganizationDomain("nokia.com");
+ QCoreApplication::setApplicationName("Qml2Puppet");
+ QCoreApplication::setApplicationVersion("1.0.0");
+
+#ifdef ENABLE_QT_BREAKPAD
+ QtSystemExceptionHandler systemExceptionHandler;
+#endif
+
+ new QmlDesigner::Qt5NodeInstanceClientProxy(&application);
+
+#if defined(Q_OS_WIN) && defined(QT_NO_DEBUG)
+ SetErrorMode(SEM_NOGPFAULTERRORBOX); //We do not want to see any message boxes
+#endif
+
+ return application.exec();
+}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pro b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pro
new file mode 100644
index 0000000000..2cffe112d3
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pro
@@ -0,0 +1,41 @@
+TARGET = qml2puppet
+
+TEMPLATE = app
+
+QT += core gui declarative network
+
+contains (QT_CONFIG, webkit) {
+ QT += webkit
+}
+
+QT += core-private declarative-private gui-private script-private
+
+DEFINES += QWEAKPOINTER_ENABLE_ARROW
+
+include(../../../../qtcreator.pri)
+DESTDIR = $$[QT_INSTALL_BINS]
+include(../../../rpath.pri)
+
+include (instances/instances.pri)
+include (../instances/instances.pri)
+include (../commands/commands.pri)
+include (../container/container.pri)
+include (../interfaces/interfaces.pri)
+
+QT_BREAKPAD_ROOT_PATH = $$(QT_BREAKPAD_ROOT_PATH)
+!isEmpty(QT_BREAKPAD_ROOT_PATH) {
+ include($$QT_BREAKPAD_ROOT_PATH/qtbreakpad.pri)
+}
+
+SOURCES += main.cpp
+RESOURCES += ../qmlpuppet.qrc
+
+OTHER_FILES += Info.plist.in
+macx {
+ info.input = Info.plist.in
+ info.output = $$DESTDIR/$${TARGET}.app/Contents/Info.plist
+ QMAKE_SUBSTITUTES += info
+} else {
+ target.path = /bin
+ INSTALLS += target
+}