diff options
11 files changed, 184 insertions, 60 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.cpp new file mode 100644 index 0000000000..164cfcc47d --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.cpp @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** 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 "changelanguagecommand.h" + +namespace QmlDesigner { + +QDataStream &operator<<(QDataStream &out, const ChangeLanguageCommand &command) +{ + return out << command.language; +} + +QDataStream &operator>>(QDataStream &in, ChangeLanguageCommand &command) +{ + return in >> command.language; +} + +QDebug operator<<(QDebug debug, const ChangeLanguageCommand &command) +{ + return debug.nospace() << "ChangeLanguageCommand(" << command.language << ")"; +} + +} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.h b/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.h new file mode 100644 index 0000000000..71a1ebd184 --- /dev/null +++ b/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.h @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** 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 <QString> + +namespace QmlDesigner { + +class ChangeLanguageCommand +{ +public: + friend QDataStream &operator>>(QDataStream &in, ChangeLanguageCommand &command); + +public: + ChangeLanguageCommand() = default; + ChangeLanguageCommand(const QString &language) + : language(language) + {} + + friend QDataStream &operator<<(QDataStream &out, const ChangeLanguageCommand &command); + friend QDataStream &operator>>(QDataStream &in, ChangeLanguageCommand &command); + friend QDebug operator<<(QDebug debug, const ChangeLanguageCommand &command); + +public: + QString language; +}; + +} // namespace QmlDesigner + +Q_DECLARE_METATYPE(QmlDesigner::ChangeLanguageCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri index 1bc858831e..008ea8ff09 100644 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ b/share/qtcreator/qml/qmlpuppet/commands/commands.pri @@ -1,6 +1,7 @@ INCLUDEPATH += $$PWD/ HEADERS += $$PWD/synchronizecommand.h +HEADERS += $$PWD/changelanguagecommand.h HEADERS += $$PWD//debugoutputcommand.h HEADERS += $$PWD/endpuppetcommand.h HEADERS += $$PWD/tokencommand.h @@ -33,6 +34,7 @@ HEADERS += $$PWD/inputeventcommand.h HEADERS += $$PWD/view3dactioncommand.h SOURCES += $$PWD/synchronizecommand.cpp +SOURCES += $$PWD/changelanguagecommand.cpp SOURCES += $$PWD/debugoutputcommand.cpp SOURCES += $$PWD/endpuppetcommand.cpp SOURCES += $$PWD/tokencommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp index 115bb5a90a..98409b57f4 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp @@ -35,28 +35,29 @@ #include "nodeinstanceserverinterface.h" -#include "propertyabstractcontainer.h" -#include "propertyvaluecontainer.h" -#include "propertybindingcontainer.h" -#include "instancecontainer.h" -#include "createinstancescommand.h" -#include "createscenecommand.h" -#include "update3dviewstatecommand.h" -#include "changevaluescommand.h" -#include "changebindingscommand.h" #include "changeauxiliarycommand.h" +#include "changebindingscommand.h" #include "changefileurlcommand.h" -#include "removeinstancescommand.h" -#include "clearscenecommand.h" -#include "removepropertiescommand.h" -#include "reparentinstancescommand.h" #include "changeidscommand.h" +#include "changelanguagecommand.h" #include "changestatecommand.h" +#include "changevaluescommand.h" +#include "clearscenecommand.h" #include "completecomponentcommand.h" -#include "synchronizecommand.h" +#include "createinstancescommand.h" +#include "createscenecommand.h" +#include "inputeventcommand.h" +#include "instancecontainer.h" +#include "propertyabstractcontainer.h" +#include "propertybindingcontainer.h" +#include "propertyvaluecontainer.h" +#include "removeinstancescommand.h" +#include "removepropertiescommand.h" #include "removesharedmemorycommand.h" +#include "reparentinstancescommand.h" +#include "synchronizecommand.h" #include "tokencommand.h" -#include "inputeventcommand.h" +#include "update3dviewstatecommand.h" #include "view3dactioncommand.h" #include "informationchangedcommand.h" @@ -324,6 +325,11 @@ void NodeInstanceClientProxy::view3DAction(const View3DActionCommand &command) nodeInstanceServer()->view3DAction(command); } +void NodeInstanceClientProxy::changeLanguage(const ChangeLanguageCommand &command) +{ + nodeInstanceServer()->changeLanguage(command); +} + void NodeInstanceClientProxy::readDataStream() { QList<QVariant> commandList; @@ -490,6 +496,7 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand"); static const int inputEventCommandType = QMetaType::type("InputEventCommand"); static const int view3DActionCommandType = QMetaType::type("View3DActionCommand"); + static const int changeLanguageCommand = QMetaType::type("ChangeLanguageCommand"); const int commandType = command.userType(); @@ -539,6 +546,8 @@ void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) } else if (commandType == changeSelectionCommandType) { ChangeSelectionCommand changeSelectionCommand = command.value<ChangeSelectionCommand>(); changeSelection(changeSelectionCommand); + } else if (command.userType() == changeLanguageCommand) { + changeLanguage(command.value<ChangeLanguageCommand>()); } else { Q_ASSERT(false); } diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h index f66bb4362b..32b2d9f154 100644 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h @@ -61,6 +61,7 @@ class ChangeSelectionCommand; class PuppetToCreatorCommand; class InputEventCommand; class View3DActionCommand; +class ChangeLanguageCommand; class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface { @@ -116,6 +117,7 @@ protected: static QVariant readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize); void inputEvent(const InputEventCommand &command); void view3DAction(const View3DActionCommand &command); + void changeLanguage(const ChangeLanguageCommand &command); protected slots: void readDataStream(); diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h index 0c6009e477..5902410015 100644 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h +++ b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h @@ -53,6 +53,7 @@ class RemoveSharedMemoryCommand; class ChangeSelectionCommand; class InputEventCommand; class View3DActionCommand; +class ChangeLanguageCommand; class NodeInstanceServerInterface : public QObject { @@ -85,9 +86,9 @@ public: virtual void changeSelection(const ChangeSelectionCommand &command) = 0; virtual void inputEvent(const InputEventCommand &command) = 0; virtual void view3DAction(const View3DActionCommand &command) = 0; + virtual void changeLanguage(const ChangeLanguageCommand &command) = 0; - virtual void benchmark(const QString &) - {} + virtual void benchmark(const QString &) {} static void registerCommands(); }; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp index 813057e10b..51c26a5cd2 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp @@ -1397,6 +1397,7 @@ void NodeInstanceServer::view3DAction(const View3DActionCommand &command) Q_UNUSED(command) } +void NodeInstanceServer::changeLanguage(const ChangeLanguageCommand &command) {} } diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h index 6b11e1b87f..d8295814cf 100644 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h +++ b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h @@ -112,6 +112,7 @@ public: void changeSelection(const ChangeSelectionCommand &command) override; void inputEvent(const InputEventCommand &command) override; void view3DAction(const View3DActionCommand &command) override; + void changeLanguage(const ChangeLanguageCommand &command) override; ServerNodeInstance instanceForId(qint32 id) const; bool hasInstanceForId(qint32 id) const; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp index 82b1e53341..ad38bdbdbb 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.cpp @@ -27,24 +27,25 @@ #include "puppetcreator.h" -#include <createinstancescommand.h> -#include <createscenecommand.h> -#include <update3dviewstatecommand.h> -#include <changevaluescommand.h> -#include <changebindingscommand.h> #include <changeauxiliarycommand.h> +#include <changebindingscommand.h> #include <changefileurlcommand.h> -#include <removeinstancescommand.h> -#include <clearscenecommand.h> -#include <removepropertiescommand.h> -#include <reparentinstancescommand.h> #include <changeidscommand.h> -#include <changestatecommand.h> -#include <completecomponentcommand.h> +#include <changelanguagecommand.h> #include <changenodesourcecommand.h> #include <changeselectioncommand.h> -#include <puppettocreatorcommand.h> +#include <changestatecommand.h> +#include <changevaluescommand.h> +#include <clearscenecommand.h> +#include <completecomponentcommand.h> +#include <createinstancescommand.h> +#include <createscenecommand.h> #include <inputeventcommand.h> +#include <puppettocreatorcommand.h> +#include <removeinstancescommand.h> +#include <removepropertiescommand.h> +#include <reparentinstancescommand.h> +#include <update3dviewstatecommand.h> #include <view3dactioncommand.h> #include <informationchangedcommand.h> @@ -740,4 +741,9 @@ void NodeInstanceServerProxy::view3DAction(const View3DActionCommand &command) writeCommand(QVariant::fromValue(command)); } +void NodeInstanceServerProxy::changeLanguage(const ChangeLanguageCommand &command) +{ + writeCommand(QVariant::fromValue(command)); +} + } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h index 77a86199a6..5d36175db3 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceserverproxy.h @@ -85,6 +85,7 @@ public: void benchmark(const QString &message) override; void inputEvent(const InputEventCommand &command) override; void view3DAction(const View3DActionCommand &command) override; + void changeLanguage(const ChangeLanguageCommand &command) override; protected: void writeCommand(const QVariant &command); diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index 48d3b0e236..270b67419a 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -25,52 +25,53 @@ #include "nodeinstanceview.h" -#include <model.h> -#include <modelnode.h> -#include <metainfo.h> -#include <nodehints.h> -#include <rewriterview.h> #include "abstractproperty.h" -#include "variantproperty.h" #include "bindingproperty.h" +#include "changeauxiliarycommand.h" +#include "changebindingscommand.h" +#include "changefileurlcommand.h" +#include "changeidscommand.h" +#include "changelanguagecommand.h" +#include "changenodesourcecommand.h" +#include "changeselectioncommand.h" +#include "changestatecommand.h" +#include "changevaluescommand.h" +#include "childrenchangedcommand.h" +#include "clearscenecommand.h" +#include "completecomponentcommand.h" +#include "componentcompletedcommand.h" +#include "createinstancescommand.h" +#include "createscenecommand.h" +#include "debugoutputcommand.h" +#include "informationchangedcommand.h" +#include "inputeventcommand.h" #include "nodeabstractproperty.h" +#include "nodeinstanceserverproxy.h" #include "nodelistproperty.h" #include "nodeproperty.h" +#include "pixmapchangedcommand.h" +#include "puppettocreatorcommand.h" #include "qmlchangeset.h" +#include "qmldesignerconstants.h" #include "qmlstate.h" #include "qmltimeline.h" #include "qmltimelinekeyframegroup.h" #include "qmlvisualnode.h" -#include "qmldesignerconstants.h" -#include "createscenecommand.h" -#include "createinstancescommand.h" -#include "clearscenecommand.h" -#include "changefileurlcommand.h" -#include "reparentinstancescommand.h" -#include "update3dviewstatecommand.h" -#include "changevaluescommand.h" -#include "changeauxiliarycommand.h" -#include "changebindingscommand.h" -#include "changeidscommand.h" -#include "changeselectioncommand.h" -#include "changenodesourcecommand.h" #include "removeinstancescommand.h" #include "removepropertiescommand.h" -#include "valueschangedcommand.h" -#include "pixmapchangedcommand.h" -#include "informationchangedcommand.h" -#include "changestatecommand.h" -#include "childrenchangedcommand.h" +#include "removesharedmemorycommand.h" +#include "reparentinstancescommand.h" #include "statepreviewimagechangedcommand.h" -#include "completecomponentcommand.h" -#include "componentcompletedcommand.h" #include "tokencommand.h" -#include "removesharedmemorycommand.h" -#include "debugoutputcommand.h" -#include "nodeinstanceserverproxy.h" -#include "puppettocreatorcommand.h" -#include "inputeventcommand.h" +#include "update3dviewstatecommand.h" +#include "valueschangedcommand.h" +#include "variantproperty.h" #include "view3dactioncommand.h" +#include <metainfo.h> +#include <model.h> +#include <modelnode.h> +#include <nodehints.h> +#include <rewriterview.h> #ifndef QMLDESIGNER_TEST #include <qmldesignerplugin.h> @@ -536,6 +537,8 @@ void NodeInstanceView::auxiliaryDataChanged(const ModelNode &node, } } } + } else if (node.isRootNode() && name == "language") { + nodeInstanceServer()->changeLanguage({value.toString()}); } } |