summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/qmldesigner/CMakeLists.txt1
-rw-r--r--src/plugins/qmldesigner/designercore/include/nodeinstanceview.h7
-rw-r--r--src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp4
-rw-r--r--src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp42
-rw-r--r--src/plugins/qmldesigner/qmldesignerplugin.qbs2
-rw-r--r--src/tools/qml2puppet/CMakeLists.txt1
-rw-r--r--src/tools/qml2puppet/qml2puppet.qbs2
7 files changed, 55 insertions, 4 deletions
diff --git a/src/plugins/qmldesigner/CMakeLists.txt b/src/plugins/qmldesigner/CMakeLists.txt
index 5948c7d3b2..7596514f29 100644
--- a/src/plugins/qmldesigner/CMakeLists.txt
+++ b/src/plugins/qmldesigner/CMakeLists.txt
@@ -143,6 +143,7 @@ extend_qtc_plugin(QmlDesigner
update3dviewstatecommand.cpp update3dviewstatecommand.h
enable3dviewcommand.cpp enable3dviewcommand.h
view3dclosedcommand.cpp view3dclosedcommand.h
+ puppettocreatorcommand.cpp puppettocreatorcommand.h
)
extend_qtc_plugin(QmlDesigner
diff --git a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h
index c55dae2d87..3e18424ca6 100644
--- a/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h
+++ b/src/plugins/qmldesigner/designercore/include/nodeinstanceview.h
@@ -147,6 +147,8 @@ public:
void mainWindowActiveChanged(bool active, bool hasPopup);
void enable3DView(bool enable);
+ void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override;
+
protected:
void timerEvent(QTimerEvent *event) override;
@@ -198,12 +200,13 @@ private: // functions
void restartProcess();
void delayedRestartProcess();
-private:
void handleCrash();
void startPuppetTransaction();
void endPuppetTransaction();
-private: //variables
+ // puppet to creator command handlers
+ void handlePuppetKeyPress(int key, Qt::KeyboardModifiers modifiers);
+
NodeInstance m_rootNodeInstance;
NodeInstance m_activeStateInstance;
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
index 07e3216f37..76e1b34621 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp
@@ -45,6 +45,7 @@
#include <changenodesourcecommand.h>
#include <changeselectioncommand.h>
#include <drop3dlibraryitemcommand.h>
+#include <puppettocreatorcommand.h>
#include <view3dclosedcommand.h>
#include <informationchangedcommand.h>
@@ -286,6 +287,7 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr
static const int puppetAliveCommandType = QMetaType::type("PuppetAliveCommand");
static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand");
static const int drop3DLibraryItemCommandType = QMetaType::type("Drop3DLibraryItemCommand");
+ static const int puppetToCreatorCommand = QMetaType::type("PuppetToCreatorCommand");
static const int view3DClosedCommand = QMetaType::type("View3DClosedCommand");
if (m_destructing)
@@ -314,6 +316,8 @@ void NodeInstanceServerProxy::dispatchCommand(const QVariant &command, PuppetStr
nodeInstanceClient()->selectionChanged(command.value<ChangeSelectionCommand>());
} else if (command.userType() == drop3DLibraryItemCommandType) {
nodeInstanceClient()->library3DItemDropped(command.value<Drop3DLibraryItemCommand>());
+ } else if (command.userType() == puppetToCreatorCommand) {
+ nodeInstanceClient()->handlePuppetToCreatorCommand(command.value<PuppetToCreatorCommand>());
} else if (command.userType() == view3DClosedCommand) {
nodeInstanceClient()->view3DClosed(command.value<View3DClosedCommand>());
} else if (command.userType() == puppetAliveCommandType) {
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
index a550a2e4b2..b06b513726 100644
--- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
+++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp
@@ -30,7 +30,7 @@
#include <metainfo.h>
#include <nodehints.h>
#include <rewriterview.h>
-
+#include "qmldesignerplugin.h"
#include "abstractproperty.h"
#include "variantproperty.h"
#include "bindingproperty.h"
@@ -42,7 +42,10 @@
#include "qmltimeline.h"
#include "qmltimelinekeyframegroup.h"
#include "qmlvisualnode.h"
-
+#include "coreplugin/actionmanager/actionmanager.h"
+#include "coreplugin/editormanager/editormanager.h"
+#include "coreplugin/documentmanager.h"
+#include "plugins/qmldesigner/qmldesignerconstants.h"
#include "createscenecommand.h"
#include "createinstancescommand.h"
#include "clearscenecommand.h"
@@ -71,6 +74,7 @@
#include "removesharedmemorycommand.h"
#include "debugoutputcommand.h"
#include "nodeinstanceserverproxy.h"
+#include "puppettocreatorcommand.h"
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
@@ -1454,6 +1458,40 @@ void NodeInstanceView::library3DItemDropped(const Drop3DLibraryItemCommand &comm
QmlVisualNode::createQmlVisualNode(this, itemLibraryEntry, {});
}
+void NodeInstanceView::handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command)
+{
+ if (command.type() == PuppetToCreatorCommand::Key_Pressed) {
+ QPair<int, int> data = qvariant_cast<QPair<int, int>>(command.data());
+ int key = data.first;
+ Qt::KeyboardModifiers modifiers = Qt::KeyboardModifiers(data.second);
+
+ handlePuppetKeyPress(key, modifiers);
+ }
+}
+
+// puppet to creator command handlers
+void NodeInstanceView::handlePuppetKeyPress(int key, Qt::KeyboardModifiers modifiers)
+{
+ // TODO: optimal way to handle key events is to just pass them on. This is done
+ // using the code below but it is so far not working, if someone could get it to work then
+ // it should be utilized and the rest of the method deleted
+// QCoreApplication::postEvent([receiver], new QKeyEvent(QEvent::KeyPress, key, modifiers));
+
+ // handle common keyboard actions coming from puppet
+ if (Core::ActionManager::command(Core::Constants::UNDO)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch)
+ QmlDesignerPlugin::instance()->currentDesignDocument()->undo();
+ else if (Core::ActionManager::command(Core::Constants::REDO)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch)
+ QmlDesignerPlugin::instance()->currentDesignDocument()->redo();
+ else if (Core::ActionManager::command(Core::Constants::SAVE)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch)
+ Core::EditorManager::saveDocument();
+ else if (Core::ActionManager::command(Core::Constants::SAVEAS)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch)
+ Core::EditorManager::saveDocumentAs();
+ else if (Core::ActionManager::command(Core::Constants::SAVEALL)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch)
+ Core::DocumentManager::saveAllModifiedDocuments();
+ else if (Core::ActionManager::command(QmlDesigner::Constants::C_DELETE)->keySequence().matches(key + modifiers) == QKeySequence::ExactMatch)
+ QmlDesignerPlugin::instance()->currentDesignDocument()->deleteSelected();
+}
+
void NodeInstanceView::view3DClosed(const View3DClosedCommand &command)
{
Q_UNUSED(command)
diff --git a/src/plugins/qmldesigner/qmldesignerplugin.qbs b/src/plugins/qmldesigner/qmldesignerplugin.qbs
index 454fdfced0..6b11bf52bf 100644
--- a/src/plugins/qmldesigner/qmldesignerplugin.qbs
+++ b/src/plugins/qmldesigner/qmldesignerplugin.qbs
@@ -177,6 +177,8 @@ Project {
"commands/enable3dviewcommand.h",
"commands/view3dclosedcommand.cpp",
"commands/view3dclosedcommand.h",
+ "commands/puppettocreatorcommand.cpp",
+ "commands/puppettocreatorcommand.h",
"container/addimportcontainer.cpp",
"container/addimportcontainer.h",
"container/idcontainer.cpp",
diff --git a/src/tools/qml2puppet/CMakeLists.txt b/src/tools/qml2puppet/CMakeLists.txt
index 3912645283..06e224a96f 100644
--- a/src/tools/qml2puppet/CMakeLists.txt
+++ b/src/tools/qml2puppet/CMakeLists.txt
@@ -49,6 +49,7 @@ extend_qtc_executable(qml2puppet
update3dviewstatecommand.cpp update3dviewstatecommand.h
enable3dviewcommand.cpp enable3dviewcommand.h
view3dclosedcommand.cpp view3dclosedcommand.h
+ puppettocreatorcommand.cpp puppettocreatorcommand.h
valueschangedcommand.cpp
)
diff --git a/src/tools/qml2puppet/qml2puppet.qbs b/src/tools/qml2puppet/qml2puppet.qbs
index 645250c2d4..cef1c5fe0b 100644
--- a/src/tools/qml2puppet/qml2puppet.qbs
+++ b/src/tools/qml2puppet/qml2puppet.qbs
@@ -103,6 +103,8 @@ QtcTool {
"commands/enable3dviewcommand.h",
"commands/view3dclosedcommand.cpp",
"commands/view3dclosedcommand.h",
+ "commands/puppettocreatorcommand.cpp",
+ "commands/puppettocreatorcommand.h",
"container/addimportcontainer.cpp",
"container/addimportcontainer.h",
"container/idcontainer.cpp",