aboutsummaryrefslogtreecommitdiffstats
path: root/share
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2020-01-02 11:58:33 +0200
committerMahmoud Badri <mahmoud.badri@qt.io>2020-01-07 09:16:19 +0000
commitbb02ab161cf956f616ad93da09baf62919641ac5 (patch)
tree29f7b1be53e9fe44ad1106fdf9783120a310ff86 /share
parent76eba270bf54c2e5e52e327551da22faa2426f9a (diff)
Enable common keyboard hotkey actions for the Edit View 3D
Clicking undo, redo, delete, or save keyboard hotkeys while the Edit View 3D has focus is working now. Additionally this commit introduces a generic command for carrying any variant data from puppet to creator side. This significantly simplifies and avoids the boiler plate work of sending actions from puppet to creator side. Current commands can be ported to use this generic command but this is not part of this commit. Also a similar command to work the other way around could be implemented. Task-number: QDS-1266 Change-Id: I40fdf6b215ce77402250a791ea49cbdcd2a9d6eb Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Diffstat (limited to 'share')
-rw-r--r--share/qtcreator/qml/qmlpuppet/commands/commands.pri2
-rw-r--r--share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp55
-rw-r--r--share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h56
-rw-r--r--share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp6
-rw-r--r--share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h2
-rw-r--r--share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h2
-rw-r--r--share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp7
-rw-r--r--share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp8
8 files changed, 138 insertions, 0 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri
index 47ec4473ea..7bc595154b 100644
--- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri
+++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri
@@ -31,6 +31,7 @@ HEADERS += $$PWD/drop3dlibraryitemcommand.h
HEADERS += $$PWD/update3dviewstatecommand.h
HEADERS += $$PWD/enable3dviewcommand.h
HEADERS += $$PWD/view3dclosedcommand.h
+HEADERS += $$PWD/puppettocreatorcommand.h
SOURCES += $$PWD/synchronizecommand.cpp
SOURCES += $$PWD/debugoutputcommand.cpp
@@ -63,3 +64,4 @@ SOURCES += $$PWD/drop3dlibraryitemcommand.cpp
SOURCES += $$PWD/update3dviewstatecommand.cpp
SOURCES += $$PWD/enable3dviewcommand.cpp
SOURCES += $$PWD/view3dclosedcommand.cpp
+SOURCES += $$PWD/puppettocreatorcommand.cpp
diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp
new file mode 100644
index 0000000000..b346776a24
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#include "puppettocreatorcommand.h"
+
+namespace QmlDesigner {
+
+// A generic command that can hold a variant data from puppet to creator
+
+PuppetToCreatorCommand::PuppetToCreatorCommand(Type type, const QVariant &data)
+ : m_type(type)
+ , m_data(data)
+{
+
+}
+
+QDataStream &operator<<(QDataStream &out, const PuppetToCreatorCommand &command)
+{
+ out << qint32(command.type());
+ out << command.data();
+ return out;
+}
+
+QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command)
+{
+ qint32 type;
+ in >> type;
+ command.m_type = PuppetToCreatorCommand::Type(type);
+ in >> command.m_data;
+ return in;
+}
+
+} // namespace QmlDesigner
diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h
new file mode 100644
index 0000000000..aa4dcd1a44
--- /dev/null
+++ b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qt Creator.
+**
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+****************************************************************************/
+
+#pragma once
+
+#include <qmetatype.h>
+#include <QDataStream>
+
+namespace QmlDesigner {
+
+class PuppetToCreatorCommand
+{
+public:
+ enum Type { Key_Pressed, None };
+
+ PuppetToCreatorCommand(Type type, const QVariant &data);
+ PuppetToCreatorCommand() = default;
+
+ Type type() const { return m_type; }
+ QVariant data() const { return m_data; }
+
+private:
+ Type m_type = None;
+ QVariant m_data;
+
+ friend QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command);
+};
+
+QDataStream &operator<<(QDataStream &out, const PuppetToCreatorCommand &command);
+QDataStream &operator>>(QDataStream &in, PuppetToCreatorCommand &command);
+
+} // namespace QmlDesigner
+
+Q_DECLARE_METATYPE(QmlDesigner::PuppetToCreatorCommand)
diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp
index 01d9cd1842..4ca4f0fb38 100644
--- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp
+++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp
@@ -72,6 +72,7 @@
#include "changeselectioncommand.h"
#include "drop3dlibraryitemcommand.h"
#include "view3dclosedcommand.h"
+#include "puppettocreatorcommand.h"
namespace QmlDesigner {
@@ -262,6 +263,11 @@ void NodeInstanceClientProxy::library3DItemDropped(const Drop3DLibraryItemComman
writeCommand(QVariant::fromValue(command));
}
+void NodeInstanceClientProxy::handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command)
+{
+ writeCommand(QVariant::fromValue(command));
+}
+
void NodeInstanceClientProxy::view3DClosed(const View3DClosedCommand &command)
{
writeCommand(QVariant::fromValue(command));
diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h
index 7c9724e1ff..6a114bbe3e 100644
--- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h
+++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h
@@ -60,6 +60,7 @@ class ChangeNodeSourceCommand;
class EndPuppetCommand;
class ChangeSelectionCommand;
class Drop3DLibraryItemCommand;
+class PuppetToCreatorCommand;
class View3DClosedCommand;
class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface
@@ -81,6 +82,7 @@ public:
void puppetAlive(const PuppetAliveCommand &command);
void selectionChanged(const ChangeSelectionCommand &command) override;
void library3DItemDropped(const Drop3DLibraryItemCommand &command) override;
+ void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override;
void view3DClosed(const View3DClosedCommand &command) override;
void flush() override;
diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h
index b188d7edfd..d289a1b259 100644
--- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h
+++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h
@@ -43,6 +43,7 @@ class PuppetAliveCommand;
class ChangeSelectionCommand;
class Drop3DLibraryItemCommand;
class View3DClosedCommand;
+class PuppetToCreatorCommand;
class NodeInstanceClientInterface
{
@@ -59,6 +60,7 @@ public:
virtual void selectionChanged(const ChangeSelectionCommand &command) = 0;
virtual void library3DItemDropped(const Drop3DLibraryItemCommand &command) = 0;
virtual void view3DClosed(const View3DClosedCommand &command) = 0;
+ virtual void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) = 0;
virtual void flush() {}
virtual void synchronizeWithClientProcess() {}
diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
index f606bfacf2..5c7c9d2953 100644
--- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
+++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp
@@ -64,6 +64,7 @@
#include "debugoutputcommand.h"
#include "puppetalivecommand.h"
#include "view3dclosedcommand.h"
+#include "puppettocreatorcommand.h"
#include <enumeration.h>
@@ -209,6 +210,12 @@ void NodeInstanceServerInterface::registerCommands()
qRegisterMetaType<View3DClosedCommand>("View3DClosedCommand");
qRegisterMetaTypeStreamOperators<View3DClosedCommand>("View3DClosedCommand");
+
+ qRegisterMetaType<PuppetToCreatorCommand>("PuppetToCreatorCommand");
+ qRegisterMetaTypeStreamOperators<PuppetToCreatorCommand>("PuppetToCreatorCommand");
+
+ qRegisterMetaType<QPair<int, int>>("QPairIntInt");
+ qRegisterMetaTypeStreamOperators<QPair<int, int>>("QPairIntInt");
}
}
diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
index db38985d90..b9bc5e8a3f 100644
--- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
+++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp
@@ -61,6 +61,7 @@
#include "removesharedmemorycommand.h"
#include "objectnodeinstance.h"
#include "drop3dlibraryitemcommand.h"
+#include "puppettocreatorcommand.h"
#include "view3dclosedcommand.h"
#include "dummycontextobject.h"
@@ -102,6 +103,13 @@ bool Qt5InformationNodeInstanceServer::eventFilter(QObject *, QEvent *event)
nodeInstanceClient()->view3DClosed(View3DClosedCommand());
} break;
+ case QEvent::KeyPress: {
+ QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
+ QPair<int, int> data = {keyEvent->key(), keyEvent->modifiers()};
+ nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::Key_Pressed,
+ QVariant::fromValue(data)});
+ } break;
+
default:
break;
}