diff options
author | Marco Bubke <marco.bubke@qt.io> | 2022-11-02 13:58:34 +0100 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2022-11-09 12:29:38 +0000 |
commit | 63022d08ea8f9f04a75d301602e639b83b1b7396 (patch) | |
tree | 99fbbfeafcb1ad0b4600f5d63b8071678894e8a5 /share/qtcreator/qml/qmlpuppet | |
parent | ac526d326cab6f19955cec4e19c73bc309bd96c8 (diff) |
QmlDesigner: QmlPuppet as standalone tool
The qmlpuppet is now a standalone tool. There is new a library too with
the communication code. That is shared between the designer and the
puppet. It's in a .cmake file so it can be included by the standalone
tool if it is not part of a designer build.
Task-number: QDS-5879
Change-Id: I2bc2a0b463fbb3e0c8c23d182abfd368cf87e968
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'share/qtcreator/qml/qmlpuppet')
317 files changed, 0 insertions, 33585 deletions
diff --git a/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h b/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h deleted file mode 100644 index 25f580e0b2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/captureddatacommand.h +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVariant> - -#include "imagecontainer.h" - -#include <vector> - -namespace QmlDesigner { - -template<typename Type> -QDataStream &operator<<(QDataStream &out, const std::vector<Type> &vector) -{ - out << quint64(vector.size()); - - for (auto &&entry : vector) - out << entry; - - return out; -} - -template<typename Type> -QDataStream &operator>>(QDataStream &in, std::vector<Type> &vector) -{ - vector.clear(); - - quint64 size; - - in >> size; - - vector.reserve(size); - - for (quint64 i = 0; i < size; ++i) { - Type entry; - - in >> entry; - - vector.push_back(std::move(entry)); - } - - return in; -} - -class CapturedDataCommand -{ -public: - struct Property - { - Property() = default; - Property(QString key, QVariant value) - : key(std::move(key)) - , value(std::move(value)) - {} - - friend QDataStream &operator<<(QDataStream &out, const Property &property) - { - out << property.key; - out << property.value; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, Property &property) - { - in >> property.key; - in >> property.value; - - return in; - } - - QString key; - QVariant value; - }; - - struct NodeData - { - friend QDataStream &operator<<(QDataStream &out, const NodeData &data) - { - out << data.nodeId; - out << data.contentRect; - out << data.sceneTransform; - out << data.properties; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, NodeData &data) - { - in >> data.nodeId; - in >> data.contentRect; - in >> data.sceneTransform; - in >> data.properties; - - return in; - } - - qint32 nodeId = -1; - QRectF contentRect; - QTransform sceneTransform; - std::vector<Property> properties; - }; - - struct StateData - { - friend QDataStream &operator<<(QDataStream &out, const StateData &data) - { - out << data.image; - out << data.nodeData; - out << data.nodeId; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, StateData &data) - { - in >> data.image; - in >> data.nodeData; - in >> data.nodeId; - - return in; - } - - ImageContainer image; - std::vector<NodeData> nodeData; - qint32 nodeId = -1; - }; - - CapturedDataCommand() = default; - - CapturedDataCommand(QVector<StateData> &&stateData) - : stateData{std::move(stateData)} - {} - - CapturedDataCommand(QImage &&image) - : image{std::move(image)} - {} - - friend QDataStream &operator<<(QDataStream &out, const CapturedDataCommand &command) - { - out << command.image; - out << command.stateData; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, CapturedDataCommand &command) - { - in >> command.image; - in >> command.stateData; - - return in; - } - -public: - QImage image; - QVector<StateData> stateData; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::CapturedDataCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changeauxiliarycommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changeauxiliarycommand.cpp deleted file mode 100644 index 1d61f21e89..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changeauxiliarycommand.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changeauxiliarycommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command) -{ - return debug.nospace() << "ChangeAuxiliaryCommand(auxiliaryChanges: " << command.auxiliaryChanges << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changeauxiliarycommand.h b/share/qtcreator/qml/qmlpuppet/commands/changeauxiliarycommand.h deleted file mode 100644 index a9264e606f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changeauxiliarycommand.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDataStream> -#include <QDebug> -#include <QMetaType> -#include <QVector> - -#include "propertyvaluecontainer.h" - -namespace QmlDesigner { - -class ChangeAuxiliaryCommand -{ -public: - friend QDataStream &operator>>(QDataStream &in, ChangeAuxiliaryCommand &command) - { - in >> command.auxiliaryChanges; - return in; - } - - friend QDataStream &operator<<(QDataStream &out, const ChangeAuxiliaryCommand &command) - { - out << command.auxiliaryChanges; - return out; - } - - friend QDebug operator <<(QDebug debug, const ChangeAuxiliaryCommand &command); - - QVector<PropertyValueContainer> auxiliaryChanges; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeAuxiliaryCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changebindingscommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changebindingscommand.cpp deleted file mode 100644 index b32456e70c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changebindingscommand.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changebindingscommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -QDebug operator <<(QDebug debug, const ChangeBindingsCommand &command) -{ - return debug.nospace() << "PropertyValueContainer(bindingChanges: " << command.bindingChanges << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changebindingscommand.h b/share/qtcreator/qml/qmlpuppet/commands/changebindingscommand.h deleted file mode 100644 index 215e143b6f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changebindingscommand.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "propertybindingcontainer.h" - -namespace QmlDesigner { - -class ChangeBindingsCommand -{ -public: - friend QDataStream &operator>>(QDataStream &in, ChangeBindingsCommand &command) { - in >> command.bindingChanges; - return in; - } - - friend QDataStream &operator<<(QDataStream &out, const ChangeBindingsCommand &command) { - out << command.bindingChanges; - return out; - } - - friend QDebug operator <<(QDebug debug, const ChangeBindingsCommand &command); - - QVector<PropertyBindingContainer> bindingChanges; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeBindingsCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changefileurlcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changefileurlcommand.cpp deleted file mode 100644 index caada4abfb..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changefileurlcommand.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changefileurlcommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command) -{ - return debug.nospace() << "ChangeFileUrlCommand(" - << "fileUrl: " << command.fileUrl << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changefileurlcommand.h b/share/qtcreator/qml/qmlpuppet/commands/changefileurlcommand.h deleted file mode 100644 index aed7769d8e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changefileurlcommand.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qmetatype.h> -#include <QDataStream> -#include <QUrl> - -namespace QmlDesigner { - -class ChangeFileUrlCommand -{ -public: - friend QDataStream &operator>>(QDataStream &in, ChangeFileUrlCommand &command) - { - in >> command.fileUrl; - return in; - } - - friend QDataStream &operator<<(QDataStream &out, const ChangeFileUrlCommand &command) - { - out << command.fileUrl; - return out; - } - - friend QDebug operator <<(QDebug debug, const ChangeFileUrlCommand &command); - - QUrl fileUrl; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeFileUrlCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changeidscommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changeidscommand.cpp deleted file mode 100644 index 6133ef3bb0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changeidscommand.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changeidscommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -QDebug operator <<(QDebug debug, const ChangeIdsCommand &command) -{ - return debug.nospace() << "ChangeIdsCommand(ids: " << command.ids << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changeidscommand.h b/share/qtcreator/qml/qmlpuppet/commands/changeidscommand.h deleted file mode 100644 index 77f6392e54..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changeidscommand.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> -#include <QDataStream> - -#include "idcontainer.h" - -namespace QmlDesigner { - -class ChangeIdsCommand -{ -public: - friend QDataStream &operator>>(QDataStream &in, ChangeIdsCommand &command) - { - in >> command.ids; - return in; - } - - friend QDataStream &operator<<(QDataStream &out, const ChangeIdsCommand &command) - { - out << command.ids; - return out; - } - friend QDebug operator <<(QDebug debug, const ChangeIdsCommand &command); - - QVector<IdContainer> ids; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeIdsCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.cpp deleted file mode 100644 index 410db15222..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.cpp +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changelanguagecommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -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 deleted file mode 100644 index e706e3238a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changelanguagecommand.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QString> -#include <QDataStream> - -namespace QmlDesigner { - -class ChangeLanguageCommand -{ -public: - ChangeLanguageCommand() = default; - ChangeLanguageCommand(QString language) : language(std::move(language)) { - } - - friend QDataStream &operator<<(QDataStream &out, const ChangeLanguageCommand &command) - { - return out << command.language; - } - friend QDataStream &operator>>(QDataStream &in, ChangeLanguageCommand &command) - { - return in >> command.language; - } - - friend QDebug operator<<(QDebug debug, const ChangeLanguageCommand &command); - - QString language; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeLanguageCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changenodesourcecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changenodesourcecommand.cpp deleted file mode 100644 index 338de4507a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changenodesourcecommand.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changenodesourcecommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -ChangeNodeSourceCommand::ChangeNodeSourceCommand() = default; - -ChangeNodeSourceCommand::ChangeNodeSourceCommand(qint32 newInstanceId, const QString &newNodeSource) - : m_instanceId(newInstanceId), m_nodeSource(newNodeSource) -{ -} - -qint32 ChangeNodeSourceCommand::instanceId() const -{ - return m_instanceId; -} - -QString ChangeNodeSourceCommand::nodeSource() const -{ - return m_nodeSource; -} - -QDataStream &operator<<(QDataStream &out, const ChangeNodeSourceCommand &command) -{ - out << command.instanceId(); - out << command.nodeSource(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, ChangeNodeSourceCommand &command) -{ - in >> command.m_instanceId; - in >> command.m_nodeSource; - - return in; -} - -QDebug operator <<(QDebug debug, const ChangeNodeSourceCommand &command) -{ - return debug.nospace() << "ReparentInstancesCommand(" - << "instanceId: " << command.m_instanceId - << "nodeSource: " << command.m_nodeSource << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changenodesourcecommand.h b/share/qtcreator/qml/qmlpuppet/commands/changenodesourcecommand.h deleted file mode 100644 index c62e8d9bd6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changenodesourcecommand.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QString> -#include <QDataStream> - -namespace QmlDesigner { - -class ChangeNodeSourceCommand -{ - friend QDataStream &operator>>(QDataStream &in, ChangeNodeSourceCommand &command); - friend QDebug operator <<(QDebug debug, const ChangeNodeSourceCommand &command); - -public: - ChangeNodeSourceCommand(); - explicit ChangeNodeSourceCommand(qint32 instanceId, const QString &nodeSource); - qint32 instanceId() const; - QString nodeSource() const; - -private: - qint32 m_instanceId; - QString m_nodeSource; -}; - -QDataStream &operator<<(QDataStream &out, const ChangeNodeSourceCommand &command); -QDataStream &operator>>(QDataStream &in, ChangeNodeSourceCommand &command); - -QDebug operator <<(QDebug debug, const ChangeNodeSourceCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeNodeSourceCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changepreviewimagesizecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changepreviewimagesizecommand.cpp deleted file mode 100644 index 00ce8506bd..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changepreviewimagesizecommand.cpp +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 -#include "changepreviewimagesizecommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -QDataStream &operator<<(QDataStream &out, const ChangePreviewImageSizeCommand &command) -{ - return out << command.size; -} - -QDataStream &operator>>(QDataStream &in, ChangePreviewImageSizeCommand &command) -{ - return in >> command.size; -} - -QDebug operator<<(QDebug debug, const ChangePreviewImageSizeCommand &command) -{ - return debug.nospace() << "ChangePreviewImageSizeCommand(" << command.size << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changepreviewimagesizecommand.h b/share/qtcreator/qml/qmlpuppet/commands/changepreviewimagesizecommand.h deleted file mode 100644 index b47cc9c067..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changepreviewimagesizecommand.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 -#pragma once - -#include <QMetaType> -#include <QSize> - -namespace QmlDesigner { - -class ChangePreviewImageSizeCommand -{ -public: - ChangePreviewImageSizeCommand() = default; - ChangePreviewImageSizeCommand(const QSize &size) - : size(size) - {} - - friend QDataStream &operator<<(QDataStream &out, const ChangePreviewImageSizeCommand &command); - friend QDataStream &operator>>(QDataStream &in, ChangePreviewImageSizeCommand &command); - friend QDebug operator<<(QDebug debug, const ChangePreviewImageSizeCommand &command); - -public: - QSize size; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangePreviewImageSizeCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changeselectioncommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changeselectioncommand.cpp deleted file mode 100644 index c2f4576bd6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changeselectioncommand.cpp +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changeselectioncommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -ChangeSelectionCommand::ChangeSelectionCommand() = default; - -ChangeSelectionCommand::ChangeSelectionCommand(const QVector<qint32> &idVector) - : m_instanceIdVector(idVector) -{ -} - -QVector<qint32> ChangeSelectionCommand::instanceIds() const -{ - return m_instanceIdVector; -} - -QDataStream &operator<<(QDataStream &out, const ChangeSelectionCommand &command) -{ - out << command.instanceIds(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command) -{ - in >> command.m_instanceIdVector; - - return in; -} - -QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command) -{ - return debug.nospace() << "ChangeSelectionCommand(instanceIdVector: " << command.m_instanceIdVector << ")"; -} - -bool operator ==(const ChangeSelectionCommand &first, const ChangeSelectionCommand &second) -{ - return first.m_instanceIdVector == second.m_instanceIdVector; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changeselectioncommand.h b/share/qtcreator/qml/qmlpuppet/commands/changeselectioncommand.h deleted file mode 100644 index f041dda430..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changeselectioncommand.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> -#include <QDataStream> - -#include "instancecontainer.h" - -namespace QmlDesigner { - -class ChangeSelectionCommand -{ - friend QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command); - friend QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command); - friend bool operator ==(const ChangeSelectionCommand &first, - const ChangeSelectionCommand &second); - -public: - ChangeSelectionCommand(); - explicit ChangeSelectionCommand(const QVector<qint32> &idVector); - - QVector<qint32> instanceIds() const; - -private: - QVector<qint32> m_instanceIdVector; -}; - -QDataStream &operator<<(QDataStream &out, const ChangeSelectionCommand &command); -QDataStream &operator>>(QDataStream &in, ChangeSelectionCommand &command); -bool operator ==(const ChangeSelectionCommand &first, const ChangeSelectionCommand &second); - -QDebug operator <<(QDebug debug, const ChangeSelectionCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeSelectionCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changestatecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changestatecommand.cpp deleted file mode 100644 index 0f52f68750..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changestatecommand.cpp +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changestatecommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -ChangeStateCommand::ChangeStateCommand() - : m_stateInstanceId(-1) -{ -} - -ChangeStateCommand::ChangeStateCommand(qint32 stateInstanceId) - : m_stateInstanceId(stateInstanceId) -{ -} - -qint32 ChangeStateCommand::stateInstanceId() const -{ - return m_stateInstanceId; -} - -QDataStream &operator<<(QDataStream &out, const ChangeStateCommand &command) -{ - out << command.stateInstanceId(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, ChangeStateCommand &command) -{ - in >> command.m_stateInstanceId; - - return in; -} - -QDebug operator <<(QDebug debug, const ChangeStateCommand &command) -{ - return debug.nospace() << "ChangeStateCommand(stateInstanceId: " << command.m_stateInstanceId << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changestatecommand.h b/share/qtcreator/qml/qmlpuppet/commands/changestatecommand.h deleted file mode 100644 index 1e76ee88e5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changestatecommand.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "propertyvaluecontainer.h" - -namespace QmlDesigner { - -class ChangeStateCommand -{ - friend QDataStream &operator>>(QDataStream &in, ChangeStateCommand &command); - friend QDebug operator <<(QDebug debug, const ChangeStateCommand &command); - -public: - ChangeStateCommand(); - explicit ChangeStateCommand(qint32 stateInstanceId); - - qint32 stateInstanceId() const; - -private: - qint32 m_stateInstanceId; -}; - -QDataStream &operator<<(QDataStream &out, const ChangeStateCommand &command); -QDataStream &operator>>(QDataStream &in, ChangeStateCommand &command); - -QDebug operator <<(QDebug debug, const ChangeStateCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeStateCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/changevaluescommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/changevaluescommand.cpp deleted file mode 100644 index a55eea221e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changevaluescommand.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "changevaluescommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -ChangeValuesCommand::ChangeValuesCommand() = default; - -ChangeValuesCommand::ChangeValuesCommand(const QVector<PropertyValueContainer> &valueChangeVector) - : m_valueChangeVector (valueChangeVector) -{ -} - -QVector<PropertyValueContainer> ChangeValuesCommand::valueChanges() const -{ - return m_valueChangeVector; -} - -QDataStream &operator<<(QDataStream &out, const ChangeValuesCommand &command) -{ - out << command.valueChanges(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, ChangeValuesCommand &command) -{ - in >> command.m_valueChangeVector; - - return in; -} - -QDebug operator <<(QDebug debug, const ChangeValuesCommand &command) -{ - return debug.nospace() << "ChangeValuesCommand(valueChanges: " << command.m_valueChangeVector << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/changevaluescommand.h b/share/qtcreator/qml/qmlpuppet/commands/changevaluescommand.h deleted file mode 100644 index cab4effd47..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/changevaluescommand.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "propertyvaluecontainer.h" - -namespace QmlDesigner { - -class ChangeValuesCommand -{ - friend QDataStream &operator>>(QDataStream &in, ChangeValuesCommand &command); - friend QDebug operator <<(QDebug debug, const ChangeValuesCommand &command); - -public: - ChangeValuesCommand(); - explicit ChangeValuesCommand(const QVector<PropertyValueContainer> &valueChangeVector); - - QVector<PropertyValueContainer> valueChanges() const; - -private: - QVector<PropertyValueContainer> m_valueChangeVector; -}; - -QDataStream &operator<<(QDataStream &out, const ChangeValuesCommand &command); -QDataStream &operator>>(QDataStream &in, ChangeValuesCommand &command); - -QDebug operator <<(QDebug debug, const ChangeValuesCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChangeValuesCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.cpp deleted file mode 100644 index 58b22cdf9b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "childrenchangedcommand.h" - -#include <QDebug> - -#include <algorithm> - -namespace QmlDesigner { - -ChildrenChangedCommand::ChildrenChangedCommand() - : m_parentInstanceId(-1) -{ -} - -ChildrenChangedCommand::ChildrenChangedCommand(qint32 parentInstanceId, const QVector<qint32> &children, const QVector<InformationContainer> &informationVector) - : m_parentInstanceId(parentInstanceId), - m_childrenVector(children), - m_informationVector(informationVector) -{ -} - -QVector<qint32> ChildrenChangedCommand::childrenInstances() const -{ - return m_childrenVector; -} - -qint32 ChildrenChangedCommand::parentInstanceId() const -{ - return m_parentInstanceId; -} - -QVector<InformationContainer> ChildrenChangedCommand::informations() const -{ - return m_informationVector; -} - -void ChildrenChangedCommand::sort() -{ - std::sort(m_childrenVector.begin(), m_childrenVector.end()); - std::sort(m_informationVector.begin(), m_informationVector.end()); -} - -QDataStream &operator<<(QDataStream &out, const ChildrenChangedCommand &command) -{ - out << command.parentInstanceId(); - out << command.childrenInstances(); - out << command.informations(); - return out; -} - -QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command) -{ - in >> command.m_parentInstanceId; - in >> command.m_childrenVector; - in >> command.m_informationVector; - - return in; -} - -bool operator ==(const ChildrenChangedCommand &first, const ChildrenChangedCommand &second) -{ - return first.m_parentInstanceId == second.m_parentInstanceId - && first.m_childrenVector == second.m_childrenVector - && first.m_informationVector == second.m_informationVector; -} - -QDebug operator <<(QDebug debug, const ChildrenChangedCommand &command) -{ - return debug.nospace() << "ChildrenChangedCommand(" - << "parentInstanceId: " << command.parentInstanceId() << ", " - << "children: " << command.childrenInstances() << ", " - << "informations: " << command.informations() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.h deleted file mode 100644 index fedcea393f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/childrenchangedcommand.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> -#include "informationcontainer.h" - -namespace QmlDesigner { - -class ChildrenChangedCommand -{ - friend QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command); - friend bool operator ==(const ChildrenChangedCommand &first, const ChildrenChangedCommand &second); - -public: - ChildrenChangedCommand(); - explicit ChildrenChangedCommand(qint32 parentInstanceId, const QVector<qint32> &childrenInstancesconst, const QVector<InformationContainer> &informationVector); - - QVector<qint32> childrenInstances() const; - qint32 parentInstanceId() const; - QVector<InformationContainer> informations() const; - - void sort(); - -private: - qint32 m_parentInstanceId; - QVector<qint32> m_childrenVector; - QVector<InformationContainer> m_informationVector; -}; - -QDataStream &operator<<(QDataStream &out, const ChildrenChangedCommand &command); -QDataStream &operator>>(QDataStream &in, ChildrenChangedCommand &command); - -bool operator ==(const ChildrenChangedCommand &first, const ChildrenChangedCommand &second); -QDebug operator <<(QDebug debug, const ChildrenChangedCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ChildrenChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/clearscenecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/clearscenecommand.cpp deleted file mode 100644 index cfc27ba6c5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/clearscenecommand.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "clearscenecommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -ClearSceneCommand::ClearSceneCommand() = default; - -QDataStream &operator<<(QDataStream &out, const ClearSceneCommand &/*command*/) -{ - return out; -} - -QDataStream &operator>>(QDataStream &in, ClearSceneCommand &/*command*/) -{ - return in; -} - -QDebug operator <<(QDebug debug, const ClearSceneCommand &/*command*/) -{ - return debug.nospace() << "ClearSceneCommand()"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/clearscenecommand.h b/share/qtcreator/qml/qmlpuppet/commands/clearscenecommand.h deleted file mode 100644 index 63374033ad..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/clearscenecommand.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qmetatype.h> - -namespace QmlDesigner { - -class ClearSceneCommand -{ -public: - ClearSceneCommand(); -}; - -QDataStream &operator<<(QDataStream &out, const ClearSceneCommand &command); -QDataStream &operator>>(QDataStream &in, ClearSceneCommand &command); - -QDebug operator <<(QDebug debug, const ClearSceneCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ClearSceneCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/commands.pri b/share/qtcreator/qml/qmlpuppet/commands/commands.pri deleted file mode 100644 index 0fb8e0132c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/commands.pri +++ /dev/null @@ -1,75 +0,0 @@ -INCLUDEPATH += $$PWD $$PWD/../interfaces - -HEADERS += $$PWD/synchronizecommand.h \ \ - $$PWD/captureddatacommand.h \ - $$PWD/changepreviewimagesizecommand.h \ - $$PWD/changelanguagecommand.h \ - $$PWD//debugoutputcommand.h \ - $$PWD/endpuppetcommand.h \ - $$PWD/scenecreatedcommand.h \ - $$PWD/tokencommand.h \ - $$PWD/componentcompletedcommand.h \ - $$PWD/completecomponentcommand.h \ - $$PWD/statepreviewimagechangedcommand.h \ - $$PWD/childrenchangedcommand.h \ - $$PWD/changebindingscommand.h \ - $$PWD/changefileurlcommand.h \ - $$PWD/changeidscommand.h \ - $$PWD/changenodesourcecommand.h \ - $$PWD/changestatecommand.h \ - $$PWD/changevaluescommand.h \ - $$PWD/createscenecommand.h \ - $$PWD/clearscenecommand.h \ - $$PWD/createinstancescommand.h \ - $$PWD/informationchangedcommand.h \ - $$PWD/nanotracecommand.h \ - $$PWD/pixmapchangedcommand.h \ - $$PWD/removeinstancescommand.h \ - $$PWD/removepropertiescommand.h \ - $$PWD/reparentinstancescommand.h \ - $$PWD/valueschangedcommand.h \ - $$PWD/changeauxiliarycommand.h \ - $$PWD/removesharedmemorycommand.h \ - $$PWD/puppetalivecommand.h \ - $$PWD/changeselectioncommand.h \ - $$PWD/update3dviewstatecommand.h \ - $$PWD/puppettocreatorcommand.h \ - $$PWD/inputeventcommand.h \ - $$PWD/view3dactioncommand.h \ - $$PWD/requestmodelnodepreviewimagecommand.h - -SOURCES += \ - $$PWD/changepreviewimagesizecommand.cpp \ - $$PWD/changelanguagecommand.cpp \ - $$PWD/debugoutputcommand.cpp \ - $$PWD/endpuppetcommand.cpp \ - $$PWD/tokencommand.cpp \ - $$PWD/componentcompletedcommand.cpp \ - $$PWD/completecomponentcommand.cpp \ - $$PWD/statepreviewimagechangedcommand.cpp \ - $$PWD/childrenchangedcommand.cpp \ - $$PWD/changebindingscommand.cpp \ - $$PWD/changefileurlcommand.cpp \ - $$PWD/changeidscommand.cpp \ - $$PWD/changenodesourcecommand.cpp \ - $$PWD/changestatecommand.cpp \ - $$PWD/changevaluescommand.cpp \ - $$PWD/informationchangedcommand.cpp \ - $$PWD/nanotracecommand.cpp \ - $$PWD/removeinstancescommand.cpp \ - $$PWD/removepropertiescommand.cpp \ - $$PWD/reparentinstancescommand.cpp \ - $$PWD/valueschangedcommand.cpp \ - $$PWD/clearscenecommand.cpp \ - $$PWD/createinstancescommand.cpp \ - $$PWD/createscenecommand.cpp \ - $$PWD/pixmapchangedcommand.cpp \ - $$PWD/changeauxiliarycommand.cpp \ - $$PWD/removesharedmemorycommand.cpp \ - $$PWD/puppetalivecommand.cpp \ - $$PWD/changeselectioncommand.cpp \ - $$PWD/update3dviewstatecommand.cpp \ - $$PWD/puppettocreatorcommand.cpp \ - $$PWD/inputeventcommand.cpp \ - $$PWD/view3dactioncommand.cpp \ - $$PWD/requestmodelnodepreviewimagecommand.cpp diff --git a/share/qtcreator/qml/qmlpuppet/commands/completecomponentcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/completecomponentcommand.cpp deleted file mode 100644 index 85d134f269..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/completecomponentcommand.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "completecomponentcommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -CompleteComponentCommand::CompleteComponentCommand() = default; - -CompleteComponentCommand::CompleteComponentCommand(const QVector<qint32> &container) - : m_instanceVector(container) -{ -} - -QVector<qint32> CompleteComponentCommand::instances() const -{ - return m_instanceVector; -} - -QDataStream &operator<<(QDataStream &out, const CompleteComponentCommand &command) -{ - out << command.instances(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command) -{ - in >> command.m_instanceVector; - - return in; -} - -QDebug operator <<(QDebug debug, const CompleteComponentCommand &command) -{ - return debug.nospace() << "CompleteComponentCommand(instances: " << command.m_instanceVector << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/completecomponentcommand.h b/share/qtcreator/qml/qmlpuppet/commands/completecomponentcommand.h deleted file mode 100644 index 3da75408d6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/completecomponentcommand.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> -#include <QDataStream> - -namespace QmlDesigner { - -class CompleteComponentCommand -{ - friend QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command); - friend QDebug operator <<(QDebug debug, const CompleteComponentCommand &command); - -public: - CompleteComponentCommand(); - explicit CompleteComponentCommand(const QVector<qint32> &container); - - QVector<qint32> instances() const; - -private: - QVector<qint32> m_instanceVector; -}; - -QDataStream &operator<<(QDataStream &out, const CompleteComponentCommand &command); -QDataStream &operator>>(QDataStream &in, CompleteComponentCommand &command); - -QDebug operator <<(QDebug debug, const CompleteComponentCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::CompleteComponentCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.cpp deleted file mode 100644 index 82bde65a51..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "componentcompletedcommand.h" - -#include <QDataStream> -#include <QDebug> - -#include <algorithm> - -namespace QmlDesigner { - -ComponentCompletedCommand::ComponentCompletedCommand() = default; - -ComponentCompletedCommand::ComponentCompletedCommand(const QVector<qint32> &container) - : m_instanceVector(container) -{ -} - -QVector<qint32> ComponentCompletedCommand::instances() const -{ - return m_instanceVector; -} - -void ComponentCompletedCommand::sort() -{ - std::sort(m_instanceVector.begin(), m_instanceVector.end()); -} - -QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command) -{ - out << command.instances(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command) -{ - in >> command.m_instanceVector; - - return in; -} - -bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second) -{ - return first.m_instanceVector == second.m_instanceVector; -} - -QDebug operator <<(QDebug debug, const ComponentCompletedCommand &command) -{ - return debug.nospace() << "ComponentCompletedCommand(" << command.instances() << ")"; - -} - -} // namespace QmlDesigner - diff --git a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.h deleted file mode 100644 index 86c492fa3b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/componentcompletedcommand.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once -#include <QMetaType> -#include <QVector> -#include <QDataStream> - -namespace QmlDesigner { - -class ComponentCompletedCommand -{ - friend QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command); - friend bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second); - -public: - ComponentCompletedCommand(); - explicit ComponentCompletedCommand(const QVector<qint32> &container); - - QVector<qint32> instances() const; - - void sort(); - -private: - QVector<qint32> m_instanceVector; -}; - -QDataStream &operator<<(QDataStream &out, const ComponentCompletedCommand &command); -QDataStream &operator>>(QDataStream &in, ComponentCompletedCommand &command); - -bool operator ==(const ComponentCompletedCommand &first, const ComponentCompletedCommand &second); -QDebug operator <<(QDebug debug, const ComponentCompletedCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ComponentCompletedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/createinstancescommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/createinstancescommand.cpp deleted file mode 100644 index 81c761461c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/createinstancescommand.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "createinstancescommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -CreateInstancesCommand::CreateInstancesCommand() = default; - -CreateInstancesCommand::CreateInstancesCommand(const QVector<InstanceContainer> &container) - : m_instanceVector(container) -{ -} - -QVector<InstanceContainer> CreateInstancesCommand::instances() const -{ - return m_instanceVector; -} - -QDataStream &operator<<(QDataStream &out, const CreateInstancesCommand &command) -{ - out << command.instances(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, CreateInstancesCommand &command) -{ - in >> command.m_instanceVector; - - return in; -} - -QDebug operator <<(QDebug debug, const CreateInstancesCommand &command) -{ - return debug.nospace() << "CreateInstancesCommand(" << command.instances() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/createinstancescommand.h b/share/qtcreator/qml/qmlpuppet/commands/createinstancescommand.h deleted file mode 100644 index aff5c87a5f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/createinstancescommand.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "instancecontainer.h" - -namespace QmlDesigner { - -class CreateInstancesCommand -{ - friend QDataStream &operator>>(QDataStream &in, CreateInstancesCommand &command); - -public: - CreateInstancesCommand(); - explicit CreateInstancesCommand(const QVector<InstanceContainer> &container); - - QVector<InstanceContainer> instances() const; - -private: - QVector<InstanceContainer> m_instanceVector; -}; - -QDataStream &operator<<(QDataStream &out, const CreateInstancesCommand &command); -QDataStream &operator>>(QDataStream &in, CreateInstancesCommand &command); - -QDebug operator <<(QDebug debug, const CreateInstancesCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::CreateInstancesCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.cpp deleted file mode 100644 index 18c35ff3e2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "createscenecommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -QDebug operator <<(QDebug debug, const CreateSceneCommand &command) -{ - return debug.nospace() << "CreateSceneCommand(" - << "instances: " << command.instances << ", " - << "reparentInstances: " << command.reparentInstances << ", " - << "ids: " << command.ids << ", " - << "valueChanges: " << command.valueChanges << ", " - << "bindingChanges: " << command.bindingChanges << ", " - << "auxiliaryChanges: " << command.auxiliaryChanges << ", " - << "imports: " << command.imports << ", " - << "mockupTypes: " << command.mockupTypes << ", " - << "fileUrl: " << command.fileUrl << ", " - << "resourceUrl: " << command.resourceUrl << ", " - << "edit3dToolStates: " << command.edit3dToolStates << ", " - << "language: " << command.language << ")"; -} - -} diff --git a/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h b/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h deleted file mode 100644 index d2682e4253..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/createscenecommand.h +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QSize> -#include <QUrl> -#include <QVector> -#include <QList> -#include <QColor> -#include <qmetatype.h> - -#include "instancecontainer.h" -#include "reparentcontainer.h" -#include "idcontainer.h" -#include "mockuptypecontainer.h" -#include "propertyvaluecontainer.h" -#include "propertybindingcontainer.h" -#include "addimportcontainer.h" - -namespace QmlDesigner { - -class CreateSceneCommand -{ -public: - CreateSceneCommand() = default; - explicit CreateSceneCommand(const QVector<InstanceContainer> &instanceContainer, - const QVector<ReparentContainer> &reparentContainer, - const QVector<IdContainer> &idVector, - const QVector<PropertyValueContainer> &valueChangeVector, - const QVector<PropertyBindingContainer> &bindingChangeVector, - const QVector<PropertyValueContainer> &auxiliaryChangeVector, - const QVector<AddImportContainer> &importVector, - const QVector<MockupTypeContainer> &mockupTypeVector, - const QUrl &fileUrl, - const QUrl &resourceUrl, - const QHash<QString, QVariantMap> &edit3dToolStates, - const QString &language, - QSize captureImageMinimumSize, - QSize captureImageMaximumSize, - qint32 stateInstanceId, - const QList<QColor> &edit3dBackgroundColor, - const QColor &edit3dGridColor) - : instances(instanceContainer) - , reparentInstances(reparentContainer) - , ids(idVector) - , valueChanges(valueChangeVector) - , bindingChanges(bindingChangeVector) - , auxiliaryChanges(auxiliaryChangeVector) - , imports(importVector) - , mockupTypes(mockupTypeVector) - , fileUrl(fileUrl) - , resourceUrl(resourceUrl) - , edit3dToolStates(edit3dToolStates) - , language(language) - , captureImageMinimumSize(captureImageMinimumSize) - , captureImageMaximumSize(captureImageMaximumSize) - , stateInstanceId{stateInstanceId} - , edit3dBackgroundColor{edit3dBackgroundColor} - , edit3dGridColor{edit3dGridColor} - {} - - friend QDataStream &operator<<(QDataStream &out, const CreateSceneCommand &command) - { - out << command.instances; - out << command.reparentInstances; - out << command.ids; - out << command.valueChanges; - out << command.bindingChanges; - out << command.auxiliaryChanges; - out << command.imports; - out << command.mockupTypes; - out << command.fileUrl; - out << command.resourceUrl; - out << command.edit3dToolStates; - out << command.language; - out << command.stateInstanceId; - out << command.captureImageMinimumSize; - out << command.captureImageMaximumSize; - out << command.edit3dBackgroundColor; - out << command.edit3dGridColor; - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, CreateSceneCommand &command) - { - in >> command.instances; - in >> command.reparentInstances; - in >> command.ids; - in >> command.valueChanges; - in >> command.bindingChanges; - in >> command.auxiliaryChanges; - in >> command.imports; - in >> command.mockupTypes; - in >> command.fileUrl; - in >> command.resourceUrl; - in >> command.edit3dToolStates; - in >> command.language; - in >> command.stateInstanceId; - in >> command.captureImageMinimumSize; - in >> command.captureImageMaximumSize; - in >> command.edit3dBackgroundColor; - in >> command.edit3dGridColor; - - return in; - } - -public: - QVector<InstanceContainer> instances; - QVector<ReparentContainer> reparentInstances; - QVector<IdContainer> ids; - QVector<PropertyValueContainer> valueChanges; - QVector<PropertyBindingContainer> bindingChanges; - QVector<PropertyValueContainer> auxiliaryChanges; - QVector<AddImportContainer> imports; - QVector<MockupTypeContainer> mockupTypes; - QUrl fileUrl; - QUrl resourceUrl; - QHash<QString, QVariantMap> edit3dToolStates; - QString language; - QSize captureImageMinimumSize; - QSize captureImageMaximumSize; - qint32 stateInstanceId = 0; - QList<QColor> edit3dBackgroundColor; - QColor edit3dGridColor; -}; - -QDebug operator<<(QDebug debug, const CreateSceneCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::CreateSceneCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.cpp deleted file mode 100644 index d247341dad..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "debugoutputcommand.h" - -#include <QtDebug> - -namespace QmlDesigner { - -DebugOutputCommand::DebugOutputCommand() = default; - -DebugOutputCommand::DebugOutputCommand(const QString &text, DebugOutputCommand::Type type, const QVector<qint32> &instanceIds) - : m_instanceIds(instanceIds) - , m_text(text) - , m_type(type) -{ -} - -qint32 DebugOutputCommand::type() const -{ - return m_type; -} - -QString DebugOutputCommand::text() const -{ - return m_text; -} - -QVector<qint32> DebugOutputCommand::instanceIds() const -{ - return m_instanceIds; -} - -QDataStream &operator<<(QDataStream &out, const DebugOutputCommand &command) -{ - out << command.type(); - out << command.text(); - out << command.instanceIds(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command) -{ - in >> command.m_type; - in >> command.m_text; - in >> command.m_instanceIds; - - return in; -} - -bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second) -{ - return first.m_type == second.m_type - && first.m_text == second.m_text; -} - -QDebug operator <<(QDebug debug, const DebugOutputCommand &command) -{ - return debug.nospace() << "DebugOutputCommand(" - << "type: " << command.type() << ", " - << "text: " << command.text() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.h b/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.h deleted file mode 100644 index bcdde736bf..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/debugoutputcommand.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QString> -#include <QDataStream> -#include <QVector> - -namespace QmlDesigner { - -class DebugOutputCommand -{ - friend QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command); - friend bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second); - -public: - enum Type { - DebugType, - WarningType, - ErrorType, - FatalType - }; - - DebugOutputCommand(); - explicit DebugOutputCommand(const QString &text, Type type, const QVector<qint32> &instanceIds); - - qint32 type() const; - QString text() const; - QVector<qint32> instanceIds() const; - -private: - QVector<qint32> m_instanceIds; - QString m_text; - quint32 m_type; -}; - -QDataStream &operator<<(QDataStream &out, const DebugOutputCommand &command); -QDataStream &operator>>(QDataStream &in, DebugOutputCommand &command); - -bool operator ==(const DebugOutputCommand &first, const DebugOutputCommand &second); -QDebug operator <<(QDebug debug, const DebugOutputCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::DebugOutputCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.cpp deleted file mode 100644 index 785130aa1b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.cpp +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "endpuppetcommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -EndPuppetCommand::EndPuppetCommand() = default; - -QDataStream &operator<<(QDataStream &out, const EndPuppetCommand &/*command*/) -{ - return out; -} - -QDataStream &operator>>(QDataStream &in, EndPuppetCommand &/*command*/) -{ - return in; -} - -QDebug operator <<(QDebug debug, const EndPuppetCommand &/*command*/) -{ - return debug.nospace() << "EndPuppetCommand()"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.h b/share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.h deleted file mode 100644 index 58cd1a1564..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/endpuppetcommand.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qmetatype.h> - -namespace QmlDesigner { - -class EndPuppetCommand -{ -public: - EndPuppetCommand(); -}; - -QDataStream &operator<<(QDataStream &out, const EndPuppetCommand &command); -QDataStream &operator>>(QDataStream &in, EndPuppetCommand &command); - -QDebug operator <<(QDebug debug, const EndPuppetCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::EndPuppetCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.cpp deleted file mode 100644 index 0111466a31..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "informationchangedcommand.h" - -#include <QMetaType> -#include <QtDebug> - -#include "propertyvaluecontainer.h" - -#include <algorithm> - -namespace QmlDesigner { - -InformationChangedCommand::InformationChangedCommand() = default; - -InformationChangedCommand::InformationChangedCommand(const QVector<InformationContainer> &informationVector) - : m_informationVector(informationVector) -{ -} - -QVector<InformationContainer> InformationChangedCommand::informations() const -{ - return m_informationVector; -} - -void InformationChangedCommand::sort() -{ - std::sort(m_informationVector.begin(), m_informationVector.end()); -} - -QDataStream &operator<<(QDataStream &out, const InformationChangedCommand &command) -{ - out << command.informations(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command) -{ - in >> command.m_informationVector; - - return in; -} - -bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second) -{ - return first.m_informationVector == second.m_informationVector; -} - -QDebug operator <<(QDebug debug, const InformationChangedCommand &command) -{ - return debug.nospace() << "InformationChangedCommand(" << command.informations() << ")"; -} - - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.h deleted file mode 100644 index 348809a7ae..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/informationchangedcommand.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "informationcontainer.h" - -namespace QmlDesigner { - -class InformationChangedCommand -{ - friend QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command); - friend bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second); - -public: - InformationChangedCommand(); - explicit InformationChangedCommand(const QVector<InformationContainer> &informationVector); - - QVector<InformationContainer> informations() const; - - void sort(); - -private: - QVector<InformationContainer> m_informationVector; -}; - -QDataStream &operator<<(QDataStream &out, const InformationChangedCommand &command); -QDataStream &operator>>(QDataStream &in, InformationChangedCommand &command); - -bool operator ==(const InformationChangedCommand &first, const InformationChangedCommand &second); -QDebug operator <<(QDebug debug, const InformationChangedCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::InformationChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.cpp deleted file mode 100644 index e2547ebce7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.cpp +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "inputeventcommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -InputEventCommand::InputEventCommand() = default; - -InputEventCommand::InputEventCommand(QInputEvent *e) - : m_type(e->type()), - m_modifiers(e->modifiers()) -{ - if (m_type == QEvent::Wheel) { - auto we = static_cast<QWheelEvent *>(e); -#if QT_VERSION <= QT_VERSION_CHECK(5, 15, 0) - m_pos = we->pos(); -#else - m_pos = we->position().toPoint(); -#endif - m_buttons = we->buttons(); - m_angleDelta = we->angleDelta().y(); - } else if (m_type == QEvent::KeyPress || m_type == QEvent::KeyRelease) { - auto ke = static_cast<QKeyEvent *>(e); - m_key = ke->key(); - m_count = ke->count(); - m_autoRepeat = ke->isAutoRepeat(); - } else { - auto me = static_cast<QMouseEvent *>(e); - m_pos = me->pos(); - m_button = me->button(); - m_buttons = me->buttons(); - } -} - -QDataStream &operator<<(QDataStream &out, const InputEventCommand &command) -{ - out << int(command.type()); - out << command.pos(); - out << int(command.button()); - out << command.buttons(); - out << command.modifiers(); - out << command.angleDelta(); - out << command.key(); - out << command.count(); - out << command.autoRepeat(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, InputEventCommand &command) -{ - int type; - int button; - in >> type; - command.m_type = (QEvent::Type)type; - in >> command.m_pos; - in >> button; - command.m_button = (Qt::MouseButton)button; - in >> command.m_buttons; - in >> command.m_modifiers; - in >> command.m_angleDelta; - in >> command.m_key; - in >> command.m_count; - in >> command.m_autoRepeat; - - return in; -} - -QDebug operator <<(QDebug debug, const InputEventCommand &command) -{ - return debug.nospace() << "InputEventCommand(" - << "type: " << command.type() << ", " - << "pos: " << command.pos() << ", " - << "button: " << command.button() << ", " - << "buttons: " << command.buttons() << ", " - << "modifiers: " << command.modifiers() << ", " - << "angleDelta: " << command.angleDelta() << ", " - << "key: " << command.key() << ", " - << "count: " << command.count() << ", " - << "autoRepeat: " << command.autoRepeat() << ")"; - -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h b/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h deleted file mode 100644 index 163d8b9521..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/inputeventcommand.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtCore/qmetatype.h> -#include <QtCore/qdatastream.h> -#include <QtGui/qevent.h> - -#include "instancecontainer.h" - -namespace QmlDesigner { - -class InputEventCommand -{ - friend QDataStream &operator>>(QDataStream &in, InputEventCommand &command); - friend QDebug operator <<(QDebug debug, const InputEventCommand &command); - -public: - InputEventCommand(); - explicit InputEventCommand(QInputEvent *e); - - QEvent::Type type() const { return m_type; } - QPoint pos() const { return m_pos; } - Qt::MouseButton button() const { return m_button; } - Qt::MouseButtons buttons() const { return m_buttons; } - Qt::KeyboardModifiers modifiers() const { return m_modifiers; } - int angleDelta() const { return m_angleDelta; } - int key() const { return m_key; } - int count() const { return m_count; } - bool autoRepeat() const { return m_autoRepeat; } - -private: - QEvent::Type m_type = QEvent::None; - Qt::KeyboardModifiers m_modifiers = Qt::NoModifier; - - // Mouse events - QPoint m_pos; - Qt::MouseButton m_button = Qt::NoButton; - Qt::MouseButtons m_buttons = Qt::NoButton; - - // Wheel events - int m_angleDelta = 0; - - // Key events - int m_key = 0; - int m_count = 1; - bool m_autoRepeat = false; -}; - -QDataStream &operator<<(QDataStream &out, const InputEventCommand &command); -QDataStream &operator>>(QDataStream &in, InputEventCommand &command); - -QDebug operator <<(QDebug debug, const InputEventCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::InputEventCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/nanotracecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/nanotracecommand.cpp deleted file mode 100644 index 346b93dd66..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/nanotracecommand.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "nanotracecommand.h" - -namespace QmlDesigner { - -StartNanotraceCommand::StartNanotraceCommand(const QString &path) - : m_filePath(path) -{ } - -QString StartNanotraceCommand::path() const -{ - return m_filePath; -} - -QDataStream &operator<<(QDataStream &out, const StartNanotraceCommand &command) -{ - out << command.m_filePath; - return out; -} - -QDataStream &operator>>(QDataStream &in, StartNanotraceCommand &command) -{ - in >> command.m_filePath; - return in; -} - -QDebug operator<<(QDebug debug, const StartNanotraceCommand &command) -{ - return debug.nospace() << "StartNanotraceCommand(" << command.m_filePath << ")"; -} - - -QDataStream &operator<<(QDataStream &out, const EndNanotraceCommand &/*command*/) -{ - return out; -} - -QDataStream &operator>>(QDataStream &in, EndNanotraceCommand &/*command*/) -{ - return in; -} - -QDebug operator<<(QDebug debug, const EndNanotraceCommand &/*command*/) -{ - return debug.nospace() << "EndNanotraceCommand()"; -} - - -SyncNanotraceCommand::SyncNanotraceCommand(const QString &name) - : m_name(name) -{ } - -QString SyncNanotraceCommand::name() const -{ - return m_name; -} - -QDataStream &operator>>(QDataStream &in, SyncNanotraceCommand &command) -{ - in >> command.m_name; - return in; -} - -QDataStream &operator<<(QDataStream &out, const SyncNanotraceCommand &command) -{ - out << command.m_name; - return out; -} - -QDebug operator<<(QDebug debug, const SyncNanotraceCommand &command) -{ - return debug.nospace() << "SyncNanotraceCommand(" << command.m_name << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/nanotracecommand.h b/share/qtcreator/qml/qmlpuppet/commands/nanotracecommand.h deleted file mode 100644 index 57cd165f6e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/nanotracecommand.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDataStream> -#include <QDebug> -#include <QMetaType> -#include <QString> - -namespace QmlDesigner { - -class StartNanotraceCommand -{ -public: - StartNanotraceCommand() = default; - StartNanotraceCommand(const QString &path); - QString path() const; - friend QDataStream &operator<<(QDataStream &out, const StartNanotraceCommand &command); - friend QDataStream &operator>>(QDataStream &in, StartNanotraceCommand &command); - friend QDebug operator <<(QDebug debug, const StartNanotraceCommand &command); -private: - QString m_filePath; -}; - - -class EndNanotraceCommand -{ -public: - EndNanotraceCommand() = default; - friend QDataStream &operator<<(QDataStream &out, const EndNanotraceCommand &command); - friend QDataStream &operator>>(QDataStream &in, EndNanotraceCommand &command); - friend QDebug operator <<(QDebug debug, const EndNanotraceCommand &command); -}; - - -class SyncNanotraceCommand -{ -public: - SyncNanotraceCommand() = default; - SyncNanotraceCommand(const QString& name); - QString name() const; - friend QDataStream &operator>>(QDataStream &in, SyncNanotraceCommand &command); - friend QDataStream &operator<<(QDataStream &out, const SyncNanotraceCommand &command); - friend QDebug operator <<(QDebug debug, const SyncNanotraceCommand &command); -private: - QString m_name; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::StartNanotraceCommand) -Q_DECLARE_METATYPE(QmlDesigner::EndNanotraceCommand) -Q_DECLARE_METATYPE(QmlDesigner::SyncNanotraceCommand) - diff --git a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.cpp deleted file mode 100644 index 16ce88d69b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "pixmapchangedcommand.h" - -#include <QDebug> - -#include <QVarLengthArray> - -#include <algorithm> - -namespace QmlDesigner { - -PixmapChangedCommand::PixmapChangedCommand() = default; - -PixmapChangedCommand::PixmapChangedCommand(const QVector<ImageContainer> &imageVector) - : m_imageVector(imageVector) -{ -} - -QVector<ImageContainer> PixmapChangedCommand::images() const -{ - return m_imageVector; -} - -void PixmapChangedCommand::sort() -{ - std::sort(m_imageVector.begin(), m_imageVector.end()); -} - -QDataStream &operator<<(QDataStream &out, const PixmapChangedCommand &command) -{ - out << command.images(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command) -{ - in >> command.m_imageVector; - - return in; -} - -bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second) -{ - return first.m_imageVector == second.m_imageVector; -} - -QDebug operator <<(QDebug debug, const PixmapChangedCommand &command) -{ - return debug.nospace() << "PixmapChangedCommand(" << command.images() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.h deleted file mode 100644 index 249bf8714f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/pixmapchangedcommand.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include "imagecontainer.h" - -namespace QmlDesigner { - -class PixmapChangedCommand -{ - friend QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command); - friend bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second); - -public: - PixmapChangedCommand(); - explicit PixmapChangedCommand(const QVector<ImageContainer> &imageVector); - - QVector<ImageContainer> images() const; - - void sort(); - -private: - QVector<ImageContainer> m_imageVector; -}; - -QDataStream &operator<<(QDataStream &out, const PixmapChangedCommand &command); -QDataStream &operator>>(QDataStream &in, PixmapChangedCommand &command); - -bool operator ==(const PixmapChangedCommand &first, const PixmapChangedCommand &second); -QDebug operator <<(QDebug debug, const PixmapChangedCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::PixmapChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.cpp deleted file mode 100644 index 0af289f240..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "puppetalivecommand.h" - -namespace QmlDesigner { - -PuppetAliveCommand::PuppetAliveCommand() = default; - -QDataStream &operator<<(QDataStream &out, const PuppetAliveCommand &/*command*/) -{ - return out; -} - -QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &/*command*/) -{ - return in; -} - -QDebug operator <<(QDebug debug, const PuppetAliveCommand &/*command*/) -{ - return debug.nospace() << "PuppetAliveCommand()"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h b/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h deleted file mode 100644 index 93741252dc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/puppetalivecommand.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QDebug> - -namespace QmlDesigner { - -class PuppetAliveCommand -{ - friend QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &command); - friend QDebug operator <<(QDebug debug, const PuppetAliveCommand &command); - -public: - PuppetAliveCommand(); -}; - -QDataStream &operator<<(QDataStream &out, const PuppetAliveCommand &command); -QDataStream &operator>>(QDataStream &in, PuppetAliveCommand &command); - -QDebug operator <<(QDebug debug, const PuppetAliveCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::PuppetAliveCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp deleted file mode 100644 index 1eb49b66ad..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#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 deleted file mode 100644 index 762054bb9b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/puppettocreatorcommand.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qmetatype.h> -#include <QDataStream> -#include <QVariant> - -namespace QmlDesigner { - -class PuppetToCreatorCommand -{ -public: - enum Type { - Edit3DToolState, - Render3DView, - ActiveSceneChanged, - RenderModelNodePreviewImage, - Import3DSupport, - NodeAtPos, - 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/commands/removeinstancescommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/removeinstancescommand.cpp deleted file mode 100644 index e47fa89654..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/removeinstancescommand.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "removeinstancescommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -RemoveInstancesCommand::RemoveInstancesCommand() = default; - -RemoveInstancesCommand::RemoveInstancesCommand(const QVector<qint32> &idVector) - : m_instanceIdVector(idVector) -{ -} - -QVector<qint32> RemoveInstancesCommand::instanceIds() const -{ - return m_instanceIdVector; -} - -QDataStream &operator<<(QDataStream &out, const RemoveInstancesCommand &command) -{ - out << command.instanceIds(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, RemoveInstancesCommand &command) -{ - in >> command.m_instanceIdVector; - - return in; -} - -QDebug operator <<(QDebug debug, const RemoveInstancesCommand &command) -{ - return debug.nospace() << "RemoveInstancesCommand(instanceIdVector: " << command.m_instanceIdVector << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/removeinstancescommand.h b/share/qtcreator/qml/qmlpuppet/commands/removeinstancescommand.h deleted file mode 100644 index f0d547486b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/removeinstancescommand.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> -#include <QDataStream> - -#include "instancecontainer.h" - -namespace QmlDesigner { - -class RemoveInstancesCommand -{ - friend QDataStream &operator>>(QDataStream &in, RemoveInstancesCommand &command); - friend QDebug operator <<(QDebug debug, const RemoveInstancesCommand &command); - -public: - RemoveInstancesCommand(); - explicit RemoveInstancesCommand(const QVector<qint32> &idVector); - - QVector<qint32> instanceIds() const; - -private: - QVector<qint32> m_instanceIdVector; -}; - -QDataStream &operator<<(QDataStream &out, const RemoveInstancesCommand &command); -QDataStream &operator>>(QDataStream &in, RemoveInstancesCommand &command); - -QDebug operator <<(QDebug debug, const RemoveInstancesCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::RemoveInstancesCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/removepropertiescommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/removepropertiescommand.cpp deleted file mode 100644 index 201d2241c9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/removepropertiescommand.cpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "removepropertiescommand.h" - -#include <QDebug> - -namespace QmlDesigner { - -RemovePropertiesCommand::RemovePropertiesCommand() = default; - -RemovePropertiesCommand::RemovePropertiesCommand(const QVector<PropertyAbstractContainer> &properties) - : m_properties(properties) -{ -} - -QVector<PropertyAbstractContainer> RemovePropertiesCommand::properties() const -{ - return m_properties; -} - -QDataStream &operator<<(QDataStream &out, const RemovePropertiesCommand &command) -{ - out << command.properties(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, RemovePropertiesCommand &command) -{ - in >> command.m_properties; - - return in; -} - -QDebug operator <<(QDebug debug, const RemovePropertiesCommand &command) -{ - return debug.nospace() << "RemovePropertiesCommand(properties: " << command.m_properties << ")"; -} - -} diff --git a/share/qtcreator/qml/qmlpuppet/commands/removepropertiescommand.h b/share/qtcreator/qml/qmlpuppet/commands/removepropertiescommand.h deleted file mode 100644 index f643e9b10b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/removepropertiescommand.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "propertyabstractcontainer.h" - -namespace QmlDesigner { - -class RemovePropertiesCommand -{ - friend QDataStream &operator>>(QDataStream &in, RemovePropertiesCommand &command); - friend QDebug operator <<(QDebug debug, const RemovePropertiesCommand &command); - -public: - RemovePropertiesCommand(); - explicit RemovePropertiesCommand(const QVector<PropertyAbstractContainer> &properties); - - QVector<PropertyAbstractContainer> properties() const; - -private: - QVector<PropertyAbstractContainer> m_properties; -}; - -QDataStream &operator<<(QDataStream &out, const RemovePropertiesCommand &command); -QDataStream &operator>>(QDataStream &in, RemovePropertiesCommand &command); - -QDebug operator <<(QDebug debug, const RemovePropertiesCommand &command); - -} - -Q_DECLARE_METATYPE(QmlDesigner::RemovePropertiesCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/removesharedmemorycommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/removesharedmemorycommand.cpp deleted file mode 100644 index 0c865747a9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/removesharedmemorycommand.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "removesharedmemorycommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -RemoveSharedMemoryCommand::RemoveSharedMemoryCommand() = default; - -RemoveSharedMemoryCommand::RemoveSharedMemoryCommand(const QString &typeName, const QVector<qint32> &keyNumberVector) - : m_typeName(typeName), - m_keyNumberVector(keyNumberVector) -{ -} - -QString RemoveSharedMemoryCommand::typeName() const -{ - return m_typeName; -} - -QVector<qint32> RemoveSharedMemoryCommand::keyNumbers() const -{ - return m_keyNumberVector; -} - -QDataStream &operator<<(QDataStream &out, const RemoveSharedMemoryCommand &command) -{ - out << command.typeName(); - out << command.keyNumbers(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command) -{ - in >> command.m_typeName; - in >> command.m_keyNumberVector; - - return in; -} - -QDebug operator <<(QDebug debug, const RemoveSharedMemoryCommand &command) -{ - return debug.nospace() << "RemoveSharedMemoryCommand(" - << "typeName: " << command.m_typeName - << "keyNumbers: " << command.m_keyNumberVector << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/removesharedmemorycommand.h b/share/qtcreator/qml/qmlpuppet/commands/removesharedmemorycommand.h deleted file mode 100644 index 2a8303dcb5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/removesharedmemorycommand.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QString> -#include <QVector> - -namespace QmlDesigner { - -class RemoveSharedMemoryCommand -{ - friend QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command); - friend QDebug operator <<(QDebug debug, const RemoveSharedMemoryCommand &command); - -public: - RemoveSharedMemoryCommand(); - explicit RemoveSharedMemoryCommand(const QString &typeName, const QVector<qint32> &keyNumberVector); - - QString typeName() const; - QVector<qint32> keyNumbers() const; - -private: - QString m_typeName; - QVector<qint32> m_keyNumberVector; -}; - -QDataStream &operator<<(QDataStream &out, const RemoveSharedMemoryCommand &command); -QDataStream &operator>>(QDataStream &in, RemoveSharedMemoryCommand &command); - -QDebug operator <<(QDebug debug, const RemoveSharedMemoryCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::RemoveSharedMemoryCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/reparentinstancescommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/reparentinstancescommand.cpp deleted file mode 100644 index f681fb5ee2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/reparentinstancescommand.cpp +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "reparentinstancescommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -ReparentInstancesCommand::ReparentInstancesCommand() = default; - -ReparentInstancesCommand::ReparentInstancesCommand(const QVector<ReparentContainer> &container) - : m_reparentInstanceVector(container) -{ -} - -QVector<ReparentContainer> ReparentInstancesCommand::reparentInstances() const -{ - return m_reparentInstanceVector; -} - - -QDataStream &operator<<(QDataStream &out, const ReparentInstancesCommand &command) -{ - out << command.reparentInstances(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, ReparentInstancesCommand &command) -{ - in >> command.m_reparentInstanceVector; - - return in; -} - -QDebug operator <<(QDebug debug, const ReparentInstancesCommand &command) -{ - return debug.nospace() << "ReparentInstancesCommand(reparentInstances: " << command.m_reparentInstanceVector << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/reparentinstancescommand.h b/share/qtcreator/qml/qmlpuppet/commands/reparentinstancescommand.h deleted file mode 100644 index f9f0a3458a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/reparentinstancescommand.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "reparentcontainer.h" - -namespace QmlDesigner { - -class ReparentInstancesCommand -{ - friend QDataStream &operator>>(QDataStream &in, ReparentInstancesCommand &command); - friend QDebug operator <<(QDebug debug, const ReparentInstancesCommand &command); - -public: - ReparentInstancesCommand(); - explicit ReparentInstancesCommand(const QVector<ReparentContainer> &container); - - QVector<ReparentContainer> reparentInstances() const; - -private: - QVector<ReparentContainer> m_reparentInstanceVector; -}; - -QDataStream &operator<<(QDataStream &out, const ReparentInstancesCommand &command); -QDataStream &operator>>(QDataStream &in, ReparentInstancesCommand &command); - -QDebug operator <<(QDebug debug, const ReparentInstancesCommand &command); - -} // - -Q_DECLARE_METATYPE(QmlDesigner::ReparentInstancesCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.cpp deleted file mode 100644 index 07099717b5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "requestmodelnodepreviewimagecommand.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -RequestModelNodePreviewImageCommand::RequestModelNodePreviewImageCommand() = default; - -RequestModelNodePreviewImageCommand::RequestModelNodePreviewImageCommand(qint32 id, const QSize &size, - const QString &componentPath, - qint32 renderItemId) - : m_instanceId(id) - , m_size(size) - , m_componentPath(componentPath) - , m_renderItemId(renderItemId) -{ -} - -qint32 RequestModelNodePreviewImageCommand::instanceId() const -{ - return m_instanceId; -} - -QSize QmlDesigner::RequestModelNodePreviewImageCommand::size() const -{ - return m_size; -} - -QString RequestModelNodePreviewImageCommand::componentPath() const -{ - return m_componentPath; -} - -qint32 RequestModelNodePreviewImageCommand::renderItemId() const -{ - return m_renderItemId; -} - -QDataStream &operator<<(QDataStream &out, const RequestModelNodePreviewImageCommand &command) -{ - out << int(command.instanceId()); - out << command.size(); - out << command.componentPath(); - out << command.renderItemId(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, RequestModelNodePreviewImageCommand &command) -{ - in >> command.m_instanceId; - in >> command.m_size; - in >> command.m_componentPath; - in >> command.m_renderItemId; - return in; -} - -QDebug operator <<(QDebug debug, const RequestModelNodePreviewImageCommand &command) -{ - return debug.nospace() << "RequestModelNodePreviewImageCommand(" - << "instanceId: " << command.instanceId() << ", " - << "size: " << command.size() << ", " - << "componentPath: " << command.componentPath() << ", " - << "renderItemId: " << command.renderItemId() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.h b/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.h deleted file mode 100644 index 41dac0d113..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/requestmodelnodepreviewimagecommand.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtCore/qmetatype.h> -#include <QtCore/qdatastream.h> -#include <QtGui/qevent.h> - -#include "instancecontainer.h" - -namespace QmlDesigner { - -class RequestModelNodePreviewImageCommand -{ - friend QDataStream &operator>>(QDataStream &in, RequestModelNodePreviewImageCommand &command); - friend QDebug operator <<(QDebug debug, const RequestModelNodePreviewImageCommand &command); - -public: - RequestModelNodePreviewImageCommand(); - explicit RequestModelNodePreviewImageCommand(qint32 id, const QSize &size, - const QString &componentPath, qint32 renderItemId); - - qint32 instanceId() const; - QSize size() const; - QString componentPath() const; - qint32 renderItemId() const; - -private: - qint32 m_instanceId; - QSize m_size; - QString m_componentPath; - qint32 m_renderItemId; -}; - -inline bool operator==(const RequestModelNodePreviewImageCommand &first, - const RequestModelNodePreviewImageCommand &second) -{ - return first.instanceId() == second.instanceId() - && first.size() == second.size() - && first.componentPath() == second.componentPath() - && first.renderItemId() == second.renderItemId(); -} - -inline size_t qHash(const RequestModelNodePreviewImageCommand &key, size_t seed = 0) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - return ::qHash(key.instanceId(), seed) - ^ ::qHash(std::make_pair(key.size().width(), key.size().height()), seed) - ^ ::qHash(key.componentPath(), seed) ^ ::qHash(key.renderItemId(), seed); -#else - return qHashMulti(seed, key.instanceId(), key.size(), key.componentPath(), key.renderItemId()); -#endif -} - -QDataStream &operator<<(QDataStream &out, const RequestModelNodePreviewImageCommand &command); -QDataStream &operator>>(QDataStream &in, RequestModelNodePreviewImageCommand &command); - -QDebug operator <<(QDebug debug, const RequestModelNodePreviewImageCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::RequestModelNodePreviewImageCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h deleted file mode 100644 index 86ef8dddd9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/scenecreatedcommand.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> - -namespace QmlDesigner { - -class SceneCreatedCommand -{ -public: - friend QDataStream &operator<<(QDataStream &out, const SceneCreatedCommand &) { return out; } - - friend QDataStream &operator>>(QDataStream &in, SceneCreatedCommand &) { return in; } -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::SceneCreatedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.cpp deleted file mode 100644 index 1f7e628613..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "statepreviewimagechangedcommand.h" - -#include <QDebug> - -#include <algorithm> - -namespace QmlDesigner { - -StatePreviewImageChangedCommand::StatePreviewImageChangedCommand() = default; - -StatePreviewImageChangedCommand::StatePreviewImageChangedCommand(const QVector<ImageContainer> &imageVector) - : m_previewVector(imageVector) -{ -} - -QVector<ImageContainer> StatePreviewImageChangedCommand::previews()const -{ - return m_previewVector; -} - -void StatePreviewImageChangedCommand::sort() -{ - std::sort(m_previewVector.begin(), m_previewVector.end()); -} - -QDataStream &operator<<(QDataStream &out, const StatePreviewImageChangedCommand &command) -{ - out << command.previews(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &command) -{ - in >> command.m_previewVector; - - return in; -} - -bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second) -{ - return first.m_previewVector == second.m_previewVector; -} - -QDebug operator <<(QDebug debug, const StatePreviewImageChangedCommand &command) -{ - return debug.nospace() << "StatePreviewImageChangedCommand(" << command.previews() << ")"; - -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.h deleted file mode 100644 index f9179a23f9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/statepreviewimagechangedcommand.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> - -#include "imagecontainer.h" - -namespace QmlDesigner { - -class StatePreviewImageChangedCommand -{ - friend QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &command); - friend bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second); - -public: - StatePreviewImageChangedCommand(); - explicit StatePreviewImageChangedCommand(const QVector<ImageContainer> &imageVector); - - QVector<ImageContainer> previews() const; - - void sort(); - -private: - QVector<ImageContainer> m_previewVector; -}; - -QDataStream &operator<<(QDataStream &out, const StatePreviewImageChangedCommand &command); -QDataStream &operator>>(QDataStream &in, StatePreviewImageChangedCommand &command); - -bool operator ==(const StatePreviewImageChangedCommand &first, const StatePreviewImageChangedCommand &second); -QDebug operator <<(QDebug debug, const StatePreviewImageChangedCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::StatePreviewImageChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.h b/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.h deleted file mode 100644 index a881d8077c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/synchronizecommand.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDebug> -#include <QMetaType> -#include <QVector> - -namespace QmlDesigner { - -class SynchronizeCommand -{ - friend QDataStream &operator>>(QDataStream &in, SynchronizeCommand &command); - friend bool operator ==(const SynchronizeCommand &first, const SynchronizeCommand &second); - -public: - SynchronizeCommand() - : m_synchronizeId(-1) - {} - explicit SynchronizeCommand(int synchronizeId) - : m_synchronizeId(synchronizeId) - {} - - int synchronizeId() const { return m_synchronizeId; } - - friend QDataStream &operator<<(QDataStream &out, const SynchronizeCommand &command) - { - out << command.synchronizeId(); - - return out; - } - - friend QDataStream &operator>>(QDataStream &in, SynchronizeCommand &command) - { - in >> command.m_synchronizeId; - - return in; - } - - friend bool operator==(const SynchronizeCommand &first, const SynchronizeCommand &second) - { - return first.m_synchronizeId == second.m_synchronizeId; - } - - friend QDebug operator<<(QDebug debug, const SynchronizeCommand &command) - { - return debug.nospace() << "SynchronizeCommand(synchronizeId: " << command.synchronizeId() - << ")"; - } - -private: - int m_synchronizeId; -}; - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::SynchronizeCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp deleted file mode 100644 index 3832e1d1fd..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "tokencommand.h" - -#include <QDataStream> -#include <QDebug> - -#include <algorithm> - -namespace QmlDesigner { - -TokenCommand::TokenCommand() - : m_tokenNumber(-1) -{ -} - -TokenCommand::TokenCommand(const QString &tokenName, qint32 tokenNumber, const QVector<qint32> &instanceIdVector) - : m_tokenName(tokenName), - m_tokenNumber(tokenNumber), - m_instanceIdVector(instanceIdVector) -{ -} - -QString TokenCommand::tokenName() const -{ - return m_tokenName; -} - -qint32 TokenCommand::tokenNumber() const -{ - return m_tokenNumber; -} - -QVector<qint32> TokenCommand::instances() const -{ - return m_instanceIdVector; -} - -void TokenCommand::sort() -{ - std::sort(m_instanceIdVector.begin(), m_instanceIdVector.end()); -} - -QDataStream &operator<<(QDataStream &out, const TokenCommand &command) -{ - out << command.tokenName(); - out << command.tokenNumber(); - out << command.instances(); - return out; -} - -QDataStream &operator>>(QDataStream &in, TokenCommand &command) -{ - in >> command.m_tokenName; - in >> command.m_tokenNumber; - in >> command.m_instanceIdVector; - - return in; -} - -bool operator ==(const TokenCommand &first, const TokenCommand &second) -{ - return first.m_tokenName == second.m_tokenName - && first.m_tokenNumber == second.m_tokenNumber - && first.m_instanceIdVector == second.m_instanceIdVector; -} - -QDebug operator <<(QDebug debug, const TokenCommand &command) -{ - return debug.nospace() << "TokenCommand(" - << "tokenName: " << command.tokenName() << ", " - << "tokenNumber: " << command.tokenNumber() << ", " - << "instances: " << command.instances() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h b/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h deleted file mode 100644 index 4294967cb2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/tokencommand.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - - -#include <QMetaType> -#include <QVector> -#include <QString> -#include <QDataStream> - -namespace QmlDesigner { - -class TokenCommand -{ - friend QDataStream &operator>>(QDataStream &in, TokenCommand &command); - friend bool operator ==(const TokenCommand &first, const TokenCommand &second); - -public: - TokenCommand(); - explicit TokenCommand(const QString &tokenName, qint32 tokenNumber, const QVector<qint32> &instances); - - QString tokenName() const; - qint32 tokenNumber() const; - QVector<qint32> instances() const; - - void sort(); - -private: - QString m_tokenName; - qint32 m_tokenNumber; - QVector<qint32> m_instanceIdVector; -}; - -QDataStream &operator<<(QDataStream &out, const TokenCommand &command); -QDataStream &operator>>(QDataStream &in, TokenCommand &command); - -bool operator ==(const TokenCommand &first, const TokenCommand &second); -QDebug operator <<(QDebug debug, const TokenCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::TokenCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp deleted file mode 100644 index 83486a5195..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "update3dviewstatecommand.h" - -#include <QDebug> -#include <QDataStream> - -namespace QmlDesigner { - -Update3dViewStateCommand::Update3dViewStateCommand(const QSize &size) - : m_size(size) - , m_type(Update3dViewStateCommand::SizeChange) -{ -} - -QSize Update3dViewStateCommand::size() const -{ - return m_size; -} - -Update3dViewStateCommand::Type Update3dViewStateCommand::type() const -{ - return m_type; -} - -QDataStream &operator<<(QDataStream &out, const Update3dViewStateCommand &command) -{ - out << qint32(command.type()); - out << command.size(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command) -{ - qint32 type; - in >> type; - command.m_type = Update3dViewStateCommand::Type(type); - in >> command.m_size; - - return in; -} - -QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command) -{ - return debug.nospace() << "Update3dViewStateCommand(type: " - << command.m_type << "," - << command.m_size << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h b/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h deleted file mode 100644 index e75763c58f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/update3dviewstatecommand.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QtCore/qsize.h> - -namespace QmlDesigner { - -class Update3dViewStateCommand -{ - friend QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command); - friend QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command); - -public: - enum Type { SizeChange, Empty }; - - explicit Update3dViewStateCommand(const QSize &size); - Update3dViewStateCommand() = default; - - QSize size() const; - Type type() const; - -private: - QSize m_size; - - Type m_type = Empty; -}; - -QDataStream &operator<<(QDataStream &out, const Update3dViewStateCommand &command); -QDataStream &operator>>(QDataStream &in, Update3dViewStateCommand &command); - -QDebug operator<<(QDebug debug, const Update3dViewStateCommand &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::Update3dViewStateCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp deleted file mode 100644 index 21de2a7919..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.cpp +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "valueschangedcommand.h" - -#include "sharedmemory.h" - -#include <QCache> -#include <QDebug> -#include <QIODevice> - -#include <cstring> - -#include <algorithm> - -namespace QmlDesigner { - -// using cache as a container which deletes sharedmemory pointers at process exit -using GlobalSharedMemoryContainer = QCache<qint32, SharedMemory>; -Q_GLOBAL_STATIC_WITH_ARGS(GlobalSharedMemoryContainer, globalSharedMemoryContainer, (10000)) - -ValuesChangedCommand::ValuesChangedCommand() - : m_keyNumber(0) -{ -} - -ValuesChangedCommand::ValuesChangedCommand(const QVector<PropertyValueContainer> &valueChangeVector) - : m_valueChangeVector (valueChangeVector), - m_keyNumber(0) -{ -} - -const QVector<PropertyValueContainer> ValuesChangedCommand::valueChanges() const -{ - return m_valueChangeVector; -} - -quint32 ValuesChangedCommand::keyNumber() const -{ - return m_keyNumber; -} - -void ValuesChangedCommand::removeSharedMemorys(const QVector<qint32> &keyNumberVector) -{ - for (qint32 keyNumber : keyNumberVector) { - SharedMemory *sharedMemory = globalSharedMemoryContainer()->take(keyNumber); - delete sharedMemory; - } -} - -void ValuesChangedCommand::sort() -{ - std::sort(m_valueChangeVector.begin(), m_valueChangeVector.end()); -} - -static const QLatin1String valueKeyTemplateString("Values-%1"); - -static SharedMemory *createSharedMemory(qint32 key, int byteCount) -{ - SharedMemory *sharedMemory = new SharedMemory(QString(valueKeyTemplateString).arg(key)); - - bool sharedMemoryIsCreated = sharedMemory->create(byteCount); - - if (sharedMemoryIsCreated) { - globalSharedMemoryContainer()->insert(key, sharedMemory); - return sharedMemory; - } else { - delete sharedMemory; - } - - return nullptr; -} - -QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command) -{ - static const bool dontUseSharedMemory = qEnvironmentVariableIsSet("DESIGNER_DONT_USE_SHARED_MEMORY"); - - QVector<PropertyValueContainer> propertyValueContainer = command.valueChanges(); - - if (command.transactionOption != ValuesChangedCommand::TransactionOption::None) { - PropertyValueContainer optionContainer(command.transactionOption); - propertyValueContainer.append(optionContainer); - } - - if (!dontUseSharedMemory && propertyValueContainer.count() > 5) { - static quint32 keyCounter = 0; - ++keyCounter; - command.m_keyNumber = keyCounter; - QByteArray outDataStreamByteArray; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QDataStream temporaryOutDataStream(&outDataStreamByteArray, QIODevice::WriteOnly); -#else - QDataStream temporaryOutDataStream(&outDataStreamByteArray, QDataStream::WriteOnly); -#endif - temporaryOutDataStream.setVersion(QDataStream::Qt_4_8); - - temporaryOutDataStream << propertyValueContainer; - - SharedMemory *sharedMemory = createSharedMemory(keyCounter, outDataStreamByteArray.size()); - - if (sharedMemory) { - sharedMemory->lock(); - std::memcpy(sharedMemory->data(), outDataStreamByteArray.constData(), sharedMemory->size()); - sharedMemory->unlock(); - - out << command.keyNumber(); - return out; - } - } - - out << qint32(0); - out << propertyValueContainer; - - return out; -} - -void readSharedMemory(qint32 key, QVector<PropertyValueContainer> *valueChangeVector) -{ - SharedMemory sharedMemory(QString(valueKeyTemplateString).arg(key)); - bool canAttach = sharedMemory.attach(QSharedMemory::ReadOnly); - - if (canAttach) { - sharedMemory.lock(); - - QDataStream in(QByteArray::fromRawData(static_cast<const char*>(sharedMemory.constData()), sharedMemory.size())); - in.setVersion(QDataStream::Qt_4_8); - in >> *valueChangeVector; - - sharedMemory.unlock(); - sharedMemory.detach(); - } -} - -QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command) -{ - in >> command.m_keyNumber; - - QVector<PropertyValueContainer> valueChangeVector; - - if (command.keyNumber() > 0) - readSharedMemory(command.keyNumber(), &valueChangeVector); - else - in >> valueChangeVector; - - // '-option-' is not a valid property name and indicates that we store the transaction option. - if (!valueChangeVector.isEmpty() && valueChangeVector.last().name() == "-option-") { - command.transactionOption = - static_cast<ValuesChangedCommand::TransactionOption>(valueChangeVector.last().instanceId()); - valueChangeVector.removeLast(); - } - - command.m_valueChangeVector = valueChangeVector; - - return in; -} - -bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second) -{ - return first.m_valueChangeVector == second.m_valueChangeVector - && first.transactionOption == second.transactionOption; -} - -QDebug operator <<(QDebug debug, const ValuesChangedCommand &command) -{ - return debug.nospace() << "ValuesChangedCommand(" - << "keyNumber: " << command.keyNumber() << ", " - << command.valueChanges() << ")"; -} - -QDataStream &operator<<(QDataStream &out, const ValuesModifiedCommand &command) -{ - return out << static_cast<const ValuesChangedCommand &>(command); -} - -QDataStream &operator>>(QDataStream &in, ValuesModifiedCommand &command) -{ - return in >> static_cast<ValuesChangedCommand &>(command); -} - - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.h b/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.h deleted file mode 100644 index 36a36439dc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/valueschangedcommand.h +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QVector> - -#include "propertyvaluecontainer.h" - -namespace QmlDesigner { - -class ValuesChangedCommand -{ - friend QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command); - friend QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command); - friend bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second); - -public: - enum TransactionOption { Start = 1, End = 2, None = 0 }; - ValuesChangedCommand(); - explicit ValuesChangedCommand(const QVector<PropertyValueContainer> &valueChangeVector); - - const QVector<PropertyValueContainer> valueChanges() const; - quint32 keyNumber() const; - - static void removeSharedMemorys(const QVector<qint32> &keyNumberVector); - - void sort(); - TransactionOption transactionOption = TransactionOption::None; - -private: - QVector<PropertyValueContainer> m_valueChangeVector; - mutable quint32 m_keyNumber; -}; - -QDataStream &operator<<(QDataStream &out, const ValuesChangedCommand &command); -QDataStream &operator>>(QDataStream &in, ValuesChangedCommand &command); - -bool operator ==(const ValuesChangedCommand &first, const ValuesChangedCommand &second); -QDebug operator <<(QDebug debug, const ValuesChangedCommand &instance); - -/* ValuesChangedCommand is used to notify that the values of a specific instatiated - * QObject changed. - * The ValuesModifiedCommand is used to notify that a user changed a QML property and - * that this property should be changed in the data model. - */ - -class ValuesModifiedCommand : public ValuesChangedCommand -{ -public: - ValuesModifiedCommand() = default; - - explicit ValuesModifiedCommand(const QVector<PropertyValueContainer> &valueChangeVector) - : ValuesChangedCommand(valueChangeVector) - {} -}; - -QDataStream &operator<<(QDataStream &out, const ValuesModifiedCommand &command); -QDataStream &operator>>(QDataStream &in, ValuesModifiedCommand &command); - -} // namespace QmlDesigner - - -Q_DECLARE_METATYPE(QmlDesigner::ValuesModifiedCommand) -Q_DECLARE_METATYPE(QmlDesigner::ValuesChangedCommand) diff --git a/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.cpp b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.cpp deleted file mode 100644 index ee3c7da797..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "view3dactioncommand.h" - -#include <QDebug> -#include <QDataStream> - -namespace QmlDesigner { - -View3DActionCommand::View3DActionCommand(View3DActionType type, const QVariant &value) - : m_type(type) - , m_value(value) -{ -} - -bool View3DActionCommand::isEnabled() const -{ - return m_value.toBool(); -} - -QVariant View3DActionCommand::value() const -{ - return m_value; -} - -View3DActionType View3DActionCommand::type() const -{ - return m_type; -} - -int View3DActionCommand::position() const -{ - bool ok = false; - int result = m_value.toInt(&ok); - if (!ok) { - qWarning() << "View3DActionCommand: returning a position that is not int; command type = " - << m_type; - } - - return result; -} - -QDataStream &operator<<(QDataStream &out, const View3DActionCommand &command) -{ - out << command.value(); - out << command.type(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, View3DActionCommand &command) -{ - in >> command.m_value; - in >> command.m_type; - - return in; -} - -QDebug operator<<(QDebug debug, const View3DActionCommand &command) -{ - return debug.nospace() << "View3DActionCommand(type: " - << command.m_type << "," - << command.m_value << ")\n"; -} - -template<typename Enumeration> -constexpr std::underlying_type_t<Enumeration> to_underlying(Enumeration enumeration) noexcept -{ - static_assert(std::is_enum_v<Enumeration>, "to_underlying expect an enumeration"); - return static_cast<std::underlying_type_t<Enumeration>>(enumeration); -} - -QDebug operator<<(QDebug debug, View3DActionType type) -{ - return debug.nospace() << to_underlying(type); -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h b/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h deleted file mode 100644 index 946ea02f6c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/commands/view3dactioncommand.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <nodeinstanceglobal.h> - -#include <QMetaType> -#include <QVariant> - -namespace QmlDesigner { - -class View3DActionCommand -{ - friend QDataStream &operator>>(QDataStream &in, View3DActionCommand &command); - friend QDebug operator<<(QDebug debug, const View3DActionCommand &command); - -public: - View3DActionCommand(View3DActionType type, const QVariant &value); - - View3DActionCommand() = default; - - bool isEnabled() const; - QVariant value() const; - View3DActionType type() const; - int position() const; - -private: - View3DActionType m_type = View3DActionType::Empty; - QVariant m_value; -}; - -QDataStream &operator<<(QDataStream &out, const View3DActionCommand &command); -QDataStream &operator>>(QDataStream &in, View3DActionCommand &command); - -QDebug operator<<(QDebug debug, const View3DActionCommand &command); -QDebug operator<<(QDebug debug, View3DActionType type); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::View3DActionCommand) diff --git a/share/qtcreator/qml/qmlpuppet/container/addimportcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/addimportcontainer.cpp deleted file mode 100644 index eb36d656b0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/addimportcontainer.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "addimportcontainer.h" - -#include <QDebug> -#include <QDataStream> - -namespace QmlDesigner { - -AddImportContainer::AddImportContainer() = default; - -AddImportContainer::AddImportContainer(const QUrl &url, const QString &fileName, const QString &version, const QString &alias, const QStringList &importPathList) - : m_url(url), - m_fileName(fileName), - m_version(version), - m_alias(alias), - m_importPathList(importPathList) -{ -} - -QUrl AddImportContainer::url() const -{ - return m_url; -} - -QString AddImportContainer::fileName() const -{ - return m_fileName; -} - -QString AddImportContainer::version() const -{ - return m_version; -} - -QString AddImportContainer::alias() const -{ - return m_alias; -} - -QStringList AddImportContainer::importPaths() const -{ - return m_importPathList; -} - -QDataStream &operator<<(QDataStream &out, const AddImportContainer &command) -{ - out << command.url(); - out << command.fileName(); - out << command.version(); - out << command.alias(); - out << command.importPaths(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, AddImportContainer &command) -{ - in >> command.m_url; - in >> command.m_fileName; - in >> command.m_version; - in >> command.m_alias; - in >> command.m_importPathList; - - return in; -} - -QDebug operator <<(QDebug debug, const AddImportContainer &container) -{ - debug.nospace() << "AddImportContainer("; - - if (!container.url().isEmpty()) - debug.nospace() << "url: " << container.url() << ", "; - - if (!container.fileName().isEmpty()) - debug.nospace() << "fileName: " << container.fileName() << ", "; - - if (!container.version().isEmpty()) - debug.nospace() << "version: " << container.version() << ", "; - - if (!container.alias().isEmpty()) - debug.nospace() << "alias: " << container.alias() << ", "; - - debug.nospace() << "importPaths: " << container.importPaths(); - - return debug.nospace() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/addimportcontainer.h b/share/qtcreator/qml/qmlpuppet/container/addimportcontainer.h deleted file mode 100644 index fadfbab44e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/addimportcontainer.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QUrl> -#include <QString> -#include <QStringList> - -namespace QmlDesigner { - -class AddImportContainer -{ - friend QDataStream &operator>>(QDataStream &in, AddImportContainer &command); -public: - AddImportContainer(); - AddImportContainer(const QUrl &url, const QString &fileName, const QString &version, const QString &alias, const QStringList &mportPathList); - - QUrl url() const; - QString fileName() const; - QString version() const; - QString alias() const; - QStringList importPaths() const; - -private: - QUrl m_url; - QString m_fileName; - QString m_version; - QString m_alias; - QStringList m_importPathList; -}; - -QDataStream &operator<<(QDataStream &out, const AddImportContainer &command); -QDataStream &operator>>(QDataStream &in, AddImportContainer &command); - -QDebug operator <<(QDebug debug, const AddImportContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::AddImportContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/container.pri b/share/qtcreator/qml/qmlpuppet/container/container.pri deleted file mode 100644 index 381e5cf117..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/container.pri +++ /dev/null @@ -1,26 +0,0 @@ -INCLUDEPATH += $$PWD/ - -HEADERS += $$PWD/addimportcontainer.h -HEADERS += $$PWD/mockuptypecontainer.h -HEADERS += $$PWD/sharedmemory.h -HEADERS += $$PWD/imagecontainer.h -HEADERS += $$PWD/idcontainer.h -HEADERS += $$PWD/informationcontainer.h -HEADERS += $$PWD/instancecontainer.h -HEADERS += $$PWD/reparentcontainer.h -HEADERS += $$PWD/propertyabstractcontainer.h -HEADERS += $$PWD/propertybindingcontainer.h -HEADERS += $$PWD/propertyvaluecontainer.h - -SOURCES += $$PWD/addimportcontainer.cpp -SOURCES += $$PWD/mockuptypecontainer.cpp -unix:SOURCES += $$PWD/sharedmemory_unix.cpp -!unix:SOURCES += $$PWD/sharedmemory_qt.cpp -SOURCES += $$PWD/imagecontainer.cpp -SOURCES += $$PWD/idcontainer.cpp -SOURCES += $$PWD/informationcontainer.cpp -SOURCES += $$PWD/instancecontainer.cpp -SOURCES += $$PWD/reparentcontainer.cpp -SOURCES += $$PWD/propertyabstractcontainer.cpp -SOURCES += $$PWD/propertybindingcontainer.cpp -SOURCES += $$PWD/propertyvaluecontainer.cpp diff --git a/share/qtcreator/qml/qmlpuppet/container/idcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/idcontainer.cpp deleted file mode 100644 index f28c9e91e9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/idcontainer.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "idcontainer.h" - -#include <QDebug> - -namespace QmlDesigner { - -IdContainer::IdContainer() - : m_instanceId(-1) -{ -} - -IdContainer::IdContainer(qint32 instanceId, const QString &id) - : m_instanceId(instanceId), - m_id(id) -{ -} - -qint32 IdContainer::instanceId() const -{ - return m_instanceId; -} - -QString IdContainer::id() const -{ - return m_id; -} - -QDataStream &operator<<(QDataStream &out, const IdContainer &container) -{ - out << container.instanceId(); - out << container.id(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, IdContainer &container) -{ - in >> container.m_instanceId; - in >> container.m_id; - - return in; -} - -QDebug operator <<(QDebug debug, const IdContainer &container) -{ - return debug.nospace() << "IdContainer(" - << "instanceId: " << container.instanceId() << ", " - << "id: " << container.id() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/idcontainer.h b/share/qtcreator/qml/qmlpuppet/container/idcontainer.h deleted file mode 100644 index c9fade64c7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/idcontainer.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDataStream> -#include <qmetatype.h> -#include <QString> - - -namespace QmlDesigner { - -class IdContainer -{ - friend QDataStream &operator>>(QDataStream &in, IdContainer &container); - -public: - IdContainer(); - IdContainer(qint32 instanceId, const QString &id); - - qint32 instanceId() const; - QString id() const; - -private: - qint32 m_instanceId; - QString m_id; -}; - -QDataStream &operator<<(QDataStream &out, const IdContainer &container); -QDataStream &operator>>(QDataStream &in, IdContainer &container); - -QDebug operator <<(QDebug debug, const IdContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::IdContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp deleted file mode 100644 index d71ba4769e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.cpp +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "imagecontainer.h" - -#include "sharedmemory.h" -#include <QCache> -#include <QDebug> -#include <QLoggingCategory> - -#include <cstring> - -#define QTC_ASSERT_STRINGIFY_HELPER(x) #x -#define QTC_ASSERT_STRINGIFY(x) QTC_ASSERT_STRINGIFY_HELPER(x) -#define QTC_ASSERT_STRING(cond) qDebug("SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " QTC_ASSERT_STRINGIFY(__LINE__)) -#define QTC_ASSERT(cond, action) if (cond) {} else { QTC_ASSERT_STRING(#cond); action; } do {} while (0) - -static Q_LOGGING_CATEGORY(imageContainerDebug, "qtc.imagecontainer.debug", QtDebugMsg) - -namespace QmlDesigner { - -// using cache as a container which deletes sharedmemory pointers at process exit -using GlobalSharedMemoryContainer = QCache<qint32, SharedMemory>; -Q_GLOBAL_STATIC_WITH_ARGS(GlobalSharedMemoryContainer, globalSharedMemoryContainer, (10000)) - -ImageContainer::ImageContainer() - : m_instanceId(-1), - m_keyNumber(-2) -{ -} - -ImageContainer::ImageContainer(qint32 instanceId, const QImage &image, qint32 keyNumber) - : m_image(image), - m_instanceId(instanceId), - m_keyNumber(keyNumber) -{ -} - -qint32 ImageContainer::instanceId() const -{ - return m_instanceId; -} - -QImage ImageContainer::image() const -{ - return m_image; -} - -qint32 ImageContainer::keyNumber() const -{ - return m_keyNumber; -} - -void ImageContainer::setImage(const QImage &image) -{ - QTC_ASSERT(m_image.isNull(), /**/); - - m_image = image; -} - -void ImageContainer::removeSharedMemorys(const QVector<qint32> &keyNumberVector) -{ - for (qint32 keyNumber : keyNumberVector) { - SharedMemory *sharedMemory = globalSharedMemoryContainer()->take(keyNumber); - delete sharedMemory; - } -} - -static const QLatin1String imageKeyTemplateString("Image-%1"); - -static SharedMemory *createSharedMemory(qint32 key, int byteCount) -{ - SharedMemory *sharedMemory = (*globalSharedMemoryContainer())[key]; - - if (sharedMemory == nullptr) { - sharedMemory = new SharedMemory(QString(imageKeyTemplateString).arg(key)); - bool sharedMemoryIsCreated = sharedMemory->create(byteCount); - if (sharedMemoryIsCreated) { - if (!globalSharedMemoryContainer()->insert(key, sharedMemory)) - return nullptr; - } else { - delete sharedMemory; - sharedMemory = nullptr; - } - } else { - bool sharedMemoryIsAttached = sharedMemory->isAttached(); - if (!sharedMemoryIsAttached) - sharedMemoryIsAttached = sharedMemory->attach(); - - bool sharedMemorySizeIsSmallerThanByteCount = sharedMemory->size() < byteCount; - bool sharedMemorySizeIsDoubleBiggerThanByteCount = sharedMemory->size() > (byteCount * 2); - - if (!sharedMemoryIsAttached) { - sharedMemory->create(byteCount); - } else if (sharedMemorySizeIsSmallerThanByteCount || sharedMemorySizeIsDoubleBiggerThanByteCount) { - sharedMemory->detach(); - sharedMemory->create(byteCount); - } - - if (!sharedMemory->isAttached()) { - globalSharedMemoryContainer()->remove(key); - sharedMemory = nullptr; - } - } - - return sharedMemory; -} - -static void writeSharedMemory(SharedMemory *sharedMemory, const QImage &image) -{ - sharedMemory->lock(); - - qint32 headerData[6]; - headerData[0] = qint32(image.sizeInBytes()); - headerData[1] = image.bytesPerLine(); - headerData[2] = image.size().width(); - headerData[3] = image.size().height(); - headerData[4] = image.format(); - headerData[5] = image.devicePixelRatio() * 100; - - std::memcpy(sharedMemory->data(), headerData, 24); - std::memcpy(reinterpret_cast<char*>(sharedMemory->data()) + 24, image.constBits(), image.sizeInBytes()); - sharedMemory->unlock(); -} - -static void writeStream(QDataStream &out, const QImage &image) -{ - out << qint32(image.bytesPerLine()); - out << image.size(); - out << qint32(image.format()); - out << qint32(image.sizeInBytes()); - out << qint32(image.devicePixelRatio() * 100); - out.writeRawData(reinterpret_cast<const char*>(image.constBits()), image.sizeInBytes()); -} - -QDataStream &operator<<(QDataStream &out, const ImageContainer &container) -{ - const int extraDataSize = 24; - static const bool dontUseSharedMemory = qEnvironmentVariableIsSet("DESIGNER_DONT_USE_SHARED_MEMORY"); - - out << container.instanceId(); - out << container.keyNumber(); - - const QImage image = container.image(); - - if (dontUseSharedMemory) { - out << qint32(0); - writeStream(out, image); - } else { - const qint32 totalSize = qint32(image.sizeInBytes()) + extraDataSize; - SharedMemory *sharedMemory = createSharedMemory(container.keyNumber(), totalSize); - - out << qint32(sharedMemory != nullptr); // send if shared memory is used - - if (sharedMemory) - writeSharedMemory(sharedMemory, image); - else - writeStream(out, image); - } - - return out; -} - -static void readSharedMemory(qint32 key, ImageContainer &container) -{ - SharedMemory sharedMemory(QString(imageKeyTemplateString).arg(key)); - - bool canAttach = sharedMemory.attach(QSharedMemory::ReadOnly); - - if (canAttach && sharedMemory.size() >= 24) - { - sharedMemory.lock(); - qint32 headerData[6]; - std::memcpy(headerData, sharedMemory.constData(), 24); - - qint32 byteCount = headerData[0]; -// qint32 bytesPerLine = headerData[1]; - qint32 imageWidth = headerData[2]; - qint32 imageHeight = headerData[3]; - qint32 imageFormat = headerData[4]; - qreal pixelRatio = headerData[5] / 100.0; - - QImage image = QImage(imageWidth, imageHeight, QImage::Format(imageFormat)); - image.setDevicePixelRatio(pixelRatio); - - if (image.isNull()) - qCInfo(imageContainerDebug()) << Q_FUNC_INFO << "Not able to create image:" << imageWidth << imageHeight << imageFormat; - else - std::memcpy(image.bits(), reinterpret_cast<const qint32*>(sharedMemory.constData()) + 6, byteCount); - - container.setImage(image); - - sharedMemory.unlock(); - sharedMemory.detach(); - } -} - -static void readStream(QDataStream &in, ImageContainer &container) -{ - qint32 byteCount; - qint32 bytesPerLine; - QSize imageSize; - qint32 imageFormat; - qint32 pixelRatio; - - in >> bytesPerLine; - in >> imageSize; - in >> imageFormat; - in >> byteCount; - in >> pixelRatio; - - QImage image = QImage(imageSize, QImage::Format(imageFormat)); - - in.readRawData(reinterpret_cast<char*>(image.bits()), byteCount); - image.setDevicePixelRatio(pixelRatio / 100.0); - - container.setImage(image); -} - -QDataStream &operator>>(QDataStream &in, ImageContainer &container) -{ - qint32 sharedMemoryIsUsed; - - in >> container.m_instanceId; - in >> container.m_keyNumber; - in >> sharedMemoryIsUsed; - - if (sharedMemoryIsUsed) { - readSharedMemory(container.keyNumber(), container); - } else - readStream(in, container); - - return in; -} - -bool operator ==(const ImageContainer &first, const ImageContainer &second) -{ - return first.m_instanceId == second.m_instanceId - && first.m_image == second.m_image; -} - -bool operator <(const ImageContainer &first, const ImageContainer &second) -{ - return first.m_instanceId < second.m_instanceId; -} - -QDebug operator <<(QDebug debug, const ImageContainer &container) -{ - return debug.nospace() << "ImageContainer(" - << "instanceId: " << container.instanceId() << ", " - << "size: " << container.image().size() << ")"; -} - - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.h b/share/qtcreator/qml/qmlpuppet/container/imagecontainer.h deleted file mode 100644 index c6c101ca8c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/imagecontainer.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QImage> - -namespace QmlDesigner { - -class ImageContainer -{ - friend QDataStream &operator>>(QDataStream &in, ImageContainer &container); - friend bool operator ==(const ImageContainer &first, const ImageContainer &second); - friend bool operator <(const ImageContainer &first, const ImageContainer &second); - -public: - ImageContainer(); - ImageContainer(qint32 instanceId, const QImage &image, qint32 keyNumber); - - qint32 instanceId() const; - QImage image() const; - qint32 keyNumber() const; - - void setImage(const QImage &image); - - static void removeSharedMemorys(const QVector<qint32> &keyNumberVector); - -private: - QImage m_image; - qint32 m_instanceId; - qint32 m_keyNumber; -}; - -QDataStream &operator<<(QDataStream &out, const ImageContainer &container); -QDataStream &operator>>(QDataStream &in, ImageContainer &container); - -bool operator ==(const ImageContainer &first, const ImageContainer &second); -bool operator <(const ImageContainer &first, const ImageContainer &second); -QDebug operator <<(QDebug debug, const ImageContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::ImageContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp deleted file mode 100644 index 7a51877719..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "informationcontainer.h" - -#include <QtDebug> - -namespace QmlDesigner { - -InformationContainer::InformationContainer() - : m_instanceId(-1), - m_name(NoName) -{ -} - -InformationContainer::InformationContainer(qint32 instanceId, - InformationName name, - const QVariant &information, - const QVariant &secondInformation, - const QVariant &thirdInformation) - : m_instanceId(instanceId), - m_name(name), - m_information(information), - m_secondInformation(secondInformation), - m_thirdInformation(thirdInformation) -{ -} - -qint32 InformationContainer::instanceId() const -{ - return m_instanceId; -} - -InformationName InformationContainer::name() const -{ - return InformationName(m_name); -} - -QVariant InformationContainer::information() const -{ - return m_information; -} - -QVariant InformationContainer::secondInformation() const -{ - return m_secondInformation; -} - -QVariant InformationContainer::thirdInformation() const -{ - return m_thirdInformation; -} - -QDataStream &operator<<(QDataStream &out, const InformationContainer &container) -{ - out << container.instanceId();// - out << container.m_name; - out << container.information(); - out << container.secondInformation(); - out << container.thirdInformation(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, InformationContainer &container) -{ - - in >> container.m_instanceId; - in >> container.m_name; - in >> container.m_information; - in >> container.m_secondInformation; - in >> container.m_thirdInformation; - - return in; -} - -bool operator ==(const InformationContainer &first, const InformationContainer &second) -{ - return first.m_instanceId == second.m_instanceId - && first.m_name == second.m_name - && first.m_information == second.m_information - && first.m_secondInformation == second.m_secondInformation - && first.m_thirdInformation == second.m_thirdInformation; -} - -static bool isFirstLessThenSecond(const QVariant &first, const QVariant &second) -{ -#if QT_VERSION < QT_VERSION_CHECK(5, 2, 0) || QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - if (first.userType() == second.userType()) { - if (first.canConvert<QByteArray>()) - return first.value<QByteArray>() < second.value<QByteArray>(); - } - - return true; -#else - return first < second; -#endif -} - -bool operator <(const InformationContainer &first, const InformationContainer &second) -{ - return (first.m_instanceId < second.m_instanceId) - || (first.m_instanceId == second.m_instanceId && first.m_name < second.m_name) - || (first.m_instanceId == second.m_instanceId && first.m_name == second.m_name - && isFirstLessThenSecond(first.m_information, second.m_information)); -} - -QDebug operator <<(QDebug debug, const InformationContainer &container) -{ - debug.nospace() << "InformationContainer(" - << "instanceId: " << container.instanceId() << ", " - << "name: " << container.name() << ", " - << "information: " << container.information(); - - if (container.secondInformation().isValid()) - debug.nospace() << ", " << "secondInformation: " << container.secondInformation(); - - if (container.thirdInformation().isValid()) - debug.nospace() << ", " << "thirdInformation: " << container.thirdInformation(); - - return debug.nospace() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.h b/share/qtcreator/qml/qmlpuppet/container/informationcontainer.h deleted file mode 100644 index 93c06560d2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/informationcontainer.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDataStream> -#include <QMetaType> -#include <QVariant> -#include <QString> - -#include "commondefines.h" - -namespace QmlDesigner { - -class InformationContainer -{ - friend QDataStream &operator>>(QDataStream &in, InformationContainer &container); - friend QDataStream &operator<<(QDataStream &out, const InformationContainer &container); - friend bool operator ==(const InformationContainer &first, const InformationContainer &second); - friend bool operator <(const InformationContainer &first, const InformationContainer &second); - -public: - InformationContainer(); - InformationContainer(qint32 instanceId, - InformationName name, - const QVariant &information, - const QVariant &secondInformation = QVariant(), - const QVariant &thirdInformation = QVariant()); - - qint32 instanceId() const; - InformationName name() const; - QVariant information() const; - QVariant secondInformation() const; - QVariant thirdInformation() const; - -private: - qint32 m_instanceId; - qint32 m_name; - QVariant m_information; - QVariant m_secondInformation; - QVariant m_thirdInformation; -}; - -QDataStream &operator<<(QDataStream &out, const InformationContainer &container); -QDataStream &operator>>(QDataStream &in, InformationContainer &container); - -bool operator ==(const InformationContainer &first, const InformationContainer &second); -bool operator <(const InformationContainer &first, const InformationContainer &second); -QDebug operator <<(QDebug debug, const InformationContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::InformationContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp deleted file mode 100644 index 5e5c688cc6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.cpp +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "instancecontainer.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -static TypeName properDelemitingOfType(const TypeName &typeName) -{ - TypeName convertedTypeName = typeName; - int lastIndex = typeName.lastIndexOf('.'); - if (lastIndex > 0) - convertedTypeName[lastIndex] = '/'; - - return convertedTypeName; -} - -InstanceContainer::InstanceContainer() = default; - -InstanceContainer::InstanceContainer(qint32 instanceId, - const TypeName &type, - int majorNumber, - int minorNumber, - const QString &componentPath, - const QString &nodeSource, - NodeSourceType nodeSourceType, - NodeMetaType metaType, - NodeFlags metaFlags) - : m_instanceId(instanceId) - ,m_type(properDelemitingOfType(type)) - ,m_majorNumber(majorNumber) - ,m_minorNumber(minorNumber) - ,m_componentPath(componentPath) - ,m_nodeSource(nodeSource) - ,m_nodeSourceType(nodeSourceType) - ,m_metaType(metaType) - ,m_metaFlags(metaFlags) -{ -} - -qint32 InstanceContainer::instanceId() const -{ - return m_instanceId; -} - -TypeName InstanceContainer::type() const -{ - return m_type; -} - -int InstanceContainer::majorNumber() const -{ - return m_majorNumber; -} - -int InstanceContainer::minorNumber() const -{ - return m_minorNumber; -} - -QString InstanceContainer::componentPath() const -{ - return m_componentPath; -} - -QString InstanceContainer::nodeSource() const -{ - return m_nodeSource; -} - -InstanceContainer::NodeSourceType InstanceContainer::nodeSourceType() const -{ - return static_cast<NodeSourceType>(m_nodeSourceType); -} - -InstanceContainer::NodeMetaType InstanceContainer::metaType() const -{ - return static_cast<NodeMetaType>(m_metaType); -} - -InstanceContainer::NodeFlags InstanceContainer::metaFlags() const -{ - return NodeFlags(m_metaFlags); -} - -bool InstanceContainer::checkFlag(NodeFlag flag) const -{ - return NodeFlags(m_metaFlags).testFlag(flag); -} - -QDataStream &operator<<(QDataStream &out, const InstanceContainer &container) -{ - out << container.instanceId(); - out << container.type(); - out << container.majorNumber(); - out << container.minorNumber(); - out << container.componentPath(); - out << container.nodeSource(); - out << qint32(container.nodeSourceType()); - out << qint32(container.metaType()); - out << qint32(container.metaFlags()); - - return out; -} - - -QDataStream &operator>>(QDataStream &in, InstanceContainer &container) -{ - in >> container.m_instanceId; - in >> container.m_type; - in >> container.m_majorNumber; - in >> container.m_minorNumber; - in >> container.m_componentPath; - in >> container.m_nodeSource; - in >> container.m_nodeSourceType; - in >> container.m_metaType; - in >> container.m_metaFlags; - - return in; -} - -QDebug operator <<(QDebug debug, const InstanceContainer &command) -{ - debug.nospace() << "InstanceContainer(" - << "instanceId: " << command.instanceId() << ", " - << "type: " << command.type() << ", " - << "majorNumber: " << command.majorNumber() << ", " - << "minorNumber: " << command.minorNumber() << ", "; - - if (!command.componentPath().isEmpty()) - debug.nospace() << "componentPath: " << command.componentPath() << ", "; - - if (!command.nodeSource().isEmpty()) - debug.nospace() << "nodeSource: " << command.nodeSource() << ", "; - - if (command.nodeSourceType() == InstanceContainer::NoSource) - debug.nospace() << "nodeSourceType: NoSource, "; - else if (command.nodeSourceType() == InstanceContainer::CustomParserSource) - debug.nospace() << "nodeSourceType: CustomParserSource, "; - else - debug.nospace() << "nodeSourceType: ComponentSource, "; - - if (command.metaType() == InstanceContainer::ObjectMetaType) - debug.nospace() << "metatype: ObjectMetaType"; - else - debug.nospace() << "metatype: ItemMetaType"; - - return debug.nospace() << ")"; - -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.h b/share/qtcreator/qml/qmlpuppet/container/instancecontainer.h deleted file mode 100644 index 4d0218f248..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/instancecontainer.h +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qmetatype.h> -#include <QString> -#include <QDataStream> - -#include "nodeinstanceglobal.h" - -namespace QmlDesigner { - -class InstanceContainer; - -QDataStream &operator<<(QDataStream &out, const InstanceContainer &container); -QDataStream &operator>>(QDataStream &in, InstanceContainer &container); - -class InstanceContainer -{ - friend QDataStream &operator>>(QDataStream &in, InstanceContainer &container); - -public: - enum NodeSourceType { - NoSource = 0, - CustomParserSource = 1, - ComponentSource = 2 - }; - - enum NodeMetaType { - ObjectMetaType, - ItemMetaType - }; - - enum NodeFlag { - ParentTakesOverRendering = 1 - }; - - Q_DECLARE_FLAGS(NodeFlags, NodeFlag) - - InstanceContainer(); - InstanceContainer(qint32 instanceId, - const TypeName &type, - int majorNumber, - int minorNumber, - const QString &componentPath, - const QString &nodeSource, - NodeSourceType nodeSourceType, - NodeMetaType metaType, - NodeFlags metaFlags); - - qint32 instanceId() const; - TypeName type() const; - int majorNumber() const; - int minorNumber() const; - QString componentPath() const; - QString nodeSource() const; - NodeSourceType nodeSourceType() const; - NodeMetaType metaType() const; - bool checkFlag(NodeFlag flag) const; - NodeFlags metaFlags() const; - -private: - qint32 m_instanceId = -1; - TypeName m_type; - qint32 m_majorNumber = -1; - qint32 m_minorNumber = -1; - QString m_componentPath; - QString m_nodeSource; - qint32 m_nodeSourceType = 0; - qint32 m_metaType = 0; - qint32 m_metaFlags = 0; -}; - -QDebug operator <<(QDebug debug, const InstanceContainer &command); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::InstanceContainer) -Q_DECLARE_OPERATORS_FOR_FLAGS(QmlDesigner::InstanceContainer::NodeFlags) diff --git a/share/qtcreator/qml/qmlpuppet/container/mockuptypecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/mockuptypecontainer.cpp deleted file mode 100644 index b4e7218f79..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/mockuptypecontainer.cpp +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "mockuptypecontainer.h" - -#include <QDebug> - -namespace QmlDesigner { - -QmlDesigner::MockupTypeContainer::MockupTypeContainer() = default; - -QmlDesigner::MockupTypeContainer::MockupTypeContainer(const QmlDesigner::TypeName &type, - const QString &importUri, - int majorVersion, - int minorVersion, bool isItem) - : m_typeName(type) - ,m_importUri(importUri) - ,m_majorVersion(majorVersion) - ,m_minorVersion(minorVersion) - ,m_isItem(isItem) -{ - -} - -QString MockupTypeContainer::importUri() const -{ - return m_importUri; -} - -QDataStream &operator<<(QDataStream &out, const MockupTypeContainer &container) -{ - out << container.typeName(); - out << container.importUri(); - out << container.majorVersion(); - out << container.minorVersion(); - out << container.isItem(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, MockupTypeContainer &container) -{ - in >> container.m_typeName; - in >> container.m_importUri; - in >> container.m_majorVersion; - in >> container.m_minorVersion; - in >> container.m_isItem; - - return in; -} - -QDebug operator <<(QDebug debug, const MockupTypeContainer &container) -{ - return debug.nospace() << "MockupTypeContainer(" - << "typeName: " << container.typeName() << ", " - << "importUri: " << container.importUri() << ", " - << "majorVersion: " << container.majorVersion() << ", " - << "minorVersion: " << container.minorVersion() << ", " - << "isItem: " << container.isItem() << ")"; -} - - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/mockuptypecontainer.h b/share/qtcreator/qml/qmlpuppet/container/mockuptypecontainer.h deleted file mode 100644 index 8294b8a845..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/mockuptypecontainer.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qmetatype.h> -#include <QString> -#include <QDataStream> - -#include "nodeinstanceglobal.h" - -namespace QmlDesigner { - -class MockupTypeContainer -{ - friend QDataStream &operator>>(QDataStream &in, MockupTypeContainer &container); - -public: - MockupTypeContainer(); - MockupTypeContainer(const TypeName &type, const QString &importUri, int majorVersion, int minorVersion, bool isItem); - - TypeName typeName() const - { return m_typeName; } - - QString importUri() const; - - int majorVersion() const - { return m_majorVersion; } - - int minorVersion() const - { return m_minorVersion; } - - bool isItem() const - { return m_isItem; } - -private: - TypeName m_typeName; - QString m_importUri; - int m_majorVersion = -1; - int m_minorVersion = -1; - bool m_isItem = false; -}; - - -QDataStream &operator<<(QDataStream &out, const MockupTypeContainer &container); -QDataStream &operator>>(QDataStream &in, MockupTypeContainer &container); - -QDebug operator <<(QDebug debug, const MockupTypeContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::MockupTypeContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/propertyabstractcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/propertyabstractcontainer.cpp deleted file mode 100644 index 1879bd0a0e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/propertyabstractcontainer.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "propertyabstractcontainer.h" - -#include <QDebug> - -namespace QmlDesigner { - -PropertyAbstractContainer::PropertyAbstractContainer() - : m_instanceId(-1) -{ -} - -PropertyAbstractContainer::PropertyAbstractContainer(qint32 instanceId, const PropertyName &name, const TypeName &dynamicTypeName) - : m_instanceId(instanceId), - m_name(name), - m_dynamicTypeName(dynamicTypeName) -{ -} - -qint32 PropertyAbstractContainer::instanceId() const -{ - return m_instanceId; -} - -PropertyName PropertyAbstractContainer::name() const -{ - return m_name; -} - -bool PropertyAbstractContainer::isDynamic() const -{ - return !m_dynamicTypeName.isEmpty(); -} - -TypeName PropertyAbstractContainer::dynamicTypeName() const -{ - return m_dynamicTypeName; -} - -QDataStream &operator<<(QDataStream &out, const PropertyAbstractContainer &container) -{ - out << container.instanceId(); - out << container.name(); - out << container.dynamicTypeName(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container) -{ - in >> container.m_instanceId; - in >> container.m_name; - in >> container.m_dynamicTypeName; - - return in; -} - -QDebug operator <<(QDebug debug, const PropertyAbstractContainer &container) -{ - debug.nospace() << "PropertyAbstractContainer(" - << "instanceId: " << container.instanceId() << ", " - << "name: " << container.name(); - - if (!container.dynamicTypeName().isEmpty()) - debug.nospace() << ", " << "dynamicTypeName: " << container.dynamicTypeName(); - - debug.nospace() << ")"; - - return debug; -} - - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/propertyabstractcontainer.h b/share/qtcreator/qml/qmlpuppet/container/propertyabstractcontainer.h deleted file mode 100644 index e0f62e1937..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/propertyabstractcontainer.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDataStream> -#include <qmetatype.h> -#include <QString> - -#include "nodeinstanceglobal.h" - -namespace QmlDesigner { - -class PropertyAbstractContainer; - -QDataStream &operator<<(QDataStream &out, const PropertyAbstractContainer &container); -QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container); - -class PropertyAbstractContainer -{ - - friend QDataStream &operator<<(QDataStream &out, const PropertyAbstractContainer &container); - friend QDataStream &operator>>(QDataStream &in, PropertyAbstractContainer &container); - friend QDebug operator <<(QDebug debug, const PropertyAbstractContainer &container); -public: - PropertyAbstractContainer(); - PropertyAbstractContainer(qint32 instanceId, const PropertyName &name, const TypeName &dynamicTypeName); - - qint32 instanceId() const; - PropertyName name() const; - bool isDynamic() const; - TypeName dynamicTypeName() const; - -private: - qint32 m_instanceId; - PropertyName m_name; - TypeName m_dynamicTypeName; -}; - -QDebug operator <<(QDebug debug, const PropertyAbstractContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::PropertyAbstractContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/propertybindingcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/propertybindingcontainer.cpp deleted file mode 100644 index ecb498f260..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/propertybindingcontainer.cpp +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "propertybindingcontainer.h" - -#include <QDebug> - -namespace QmlDesigner { - -PropertyBindingContainer::PropertyBindingContainer() - : m_instanceId(-1) -{ -} - -PropertyBindingContainer::PropertyBindingContainer(qint32 instanceId, const PropertyName &name, const QString &expression, const TypeName &dynamicTypeName) - : m_instanceId(instanceId), - m_name(name), - m_expression(expression), - m_dynamicTypeName(dynamicTypeName) -{ -} - -qint32 PropertyBindingContainer::instanceId() const -{ - return m_instanceId; -} - -PropertyName PropertyBindingContainer::name() const -{ - return m_name; -} - -QString PropertyBindingContainer::expression() const -{ - return m_expression; -} - -bool PropertyBindingContainer::isDynamic() const -{ - return !m_dynamicTypeName.isEmpty(); -} - -TypeName PropertyBindingContainer::dynamicTypeName() const -{ - return m_dynamicTypeName; -} - -QDataStream &operator<<(QDataStream &out, const PropertyBindingContainer &container) -{ - out << container.instanceId(); - out << container.name(); - out << container.expression(); - out << container.dynamicTypeName(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, PropertyBindingContainer &container) -{ - in >> container.m_instanceId; - in >> container.m_name; - in >> container.m_expression; - in >> container.m_dynamicTypeName; - - return in; -} - -QDebug operator <<(QDebug debug, const PropertyBindingContainer &container) -{ - debug.nospace() << "PropertyBindingContainer(" - << "instanceId: " << container.instanceId() << ", " - << "name: " << container.name() << ", " - << "expression: " << container.expression(); - - if (!container.dynamicTypeName().isEmpty()) - debug.nospace() << ", " << "dynamicTypeName: " << container.dynamicTypeName(); - - return debug.nospace() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/propertybindingcontainer.h b/share/qtcreator/qml/qmlpuppet/container/propertybindingcontainer.h deleted file mode 100644 index 11e4afc8f9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/propertybindingcontainer.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDataStream> -#include <qmetatype.h> -#include <QString> - -#include "nodeinstanceglobal.h" - -namespace QmlDesigner { - -class PropertyBindingContainer -{ - friend QDataStream &operator>>(QDataStream &in, PropertyBindingContainer &container); - -public: - PropertyBindingContainer(); - PropertyBindingContainer(qint32 instanceId, const PropertyName &name, const QString &expression, const TypeName &dynamicTypeName); - - qint32 instanceId() const; - PropertyName name() const; - QString expression() const; - bool isDynamic() const; - TypeName dynamicTypeName() const; - -private: - qint32 m_instanceId; - PropertyName m_name; - QString m_expression; - TypeName m_dynamicTypeName; -}; - -QDataStream &operator<<(QDataStream &out, const PropertyBindingContainer &container); -QDataStream &operator>>(QDataStream &in, PropertyBindingContainer &container); - -QDebug operator <<(QDebug debug, const PropertyBindingContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::PropertyBindingContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.cpp deleted file mode 100644 index 160267a21d..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.cpp +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "propertyvaluecontainer.h" - -#include <QtDebug> - -namespace QmlDesigner { - -PropertyValueContainer::PropertyValueContainer() - : m_instanceId(-1) -{ -} - -PropertyValueContainer::PropertyValueContainer(qint32 instanceId, - const PropertyName &name, - const QVariant &value, - const TypeName &dynamicTypeName, - AuxiliaryDataType auxiliaryDataType) - : m_instanceId(instanceId) - , m_name(name) - , m_value(value) - , m_dynamicTypeName(dynamicTypeName) - , m_auxiliaryDataType{auxiliaryDataType} -{ -} - -PropertyValueContainer::PropertyValueContainer(qint32 option) - : m_instanceId(option), - m_name("-option-") -{ -// '-option-' is not a valid property name and indicates that we store the transaction option. -} - -qint32 PropertyValueContainer::instanceId() const -{ - return m_instanceId; -} - -PropertyName PropertyValueContainer::name() const -{ - return m_name; -} - -QVariant PropertyValueContainer::value() const -{ - return m_value; -} - -bool PropertyValueContainer::isDynamic() const -{ - return !m_dynamicTypeName.isEmpty(); -} - -TypeName PropertyValueContainer::dynamicTypeName() const -{ - return m_dynamicTypeName; -} - -// The reflection flag indicates that a property change notification -// is reflected. This means that the notification is the reaction to a -// property change original done by the puppet itself. -// In the Qt5InformationNodeInstanceServer such notification are -// therefore ignored. - -void PropertyValueContainer::setReflectionFlag(bool b) -{ - m_isReflected = b; -} - -bool PropertyValueContainer::isReflected() const -{ - return m_isReflected; -} - -AuxiliaryDataType PropertyValueContainer::auxiliaryDataType() const -{ - return m_auxiliaryDataType; -} - -QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container) -{ - out << container.m_instanceId; - out << container.m_name; - out << container.m_value; - out << container.m_dynamicTypeName; - out << container.m_isReflected; - out << container.m_auxiliaryDataType; - - return out; -} - -QDataStream &operator>>(QDataStream &in, PropertyValueContainer &container) -{ - in >> container.m_instanceId; - in >> container.m_name; - in >> container.m_value; - in >> container.m_dynamicTypeName; - in >> container.m_isReflected; - in >> container.m_auxiliaryDataType; - - return in; -} - -bool operator ==(const PropertyValueContainer &first, const PropertyValueContainer &second) -{ - return first.m_instanceId == second.m_instanceId && first.m_name == second.m_name - && first.m_value == second.m_value && first.m_dynamicTypeName == second.m_dynamicTypeName - && first.m_isReflected == second.m_isReflected - && first.m_auxiliaryDataType == second.m_auxiliaryDataType; -} - -bool operator <(const PropertyValueContainer &first, const PropertyValueContainer &second) -{ - return (first.m_instanceId < second.m_instanceId) - || (first.m_instanceId == second.m_instanceId && first.m_name < second.m_name); -} - -QDebug operator <<(QDebug debug, const PropertyValueContainer &container) -{ - debug.nospace() << "PropertyValueContainer(" - << "instanceId: " << container.instanceId() << ", " - << "name: " << container.name() << ", " - << "value: " << container.value(); - - if (!container.dynamicTypeName().isEmpty()) - debug.nospace() << ", " << "dynamicTypeName: " << container.dynamicTypeName(); - - debug.nospace() << ")"; - - return debug; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.h b/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.h deleted file mode 100644 index c9d03ad9e8..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/propertyvaluecontainer.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDataStream> -#include <QMetaType> -#include <QVariant> -#include <QString> - -#include "nodeinstanceglobal.h" - -namespace QmlDesigner { - -class PropertyValueContainer -{ -public: - PropertyValueContainer(); - PropertyValueContainer(qint32 instanceId, - const PropertyName &name, - const QVariant &value, - const TypeName &dynamicTypeName, - AuxiliaryDataType auxiliaryDataType = AuxiliaryDataType::None); - PropertyValueContainer(qint32 option); - - qint32 instanceId() const; - PropertyName name() const; - QVariant value() const; - bool isDynamic() const; - TypeName dynamicTypeName() const; - void setReflectionFlag(bool b); - bool isReflected() const; - AuxiliaryDataType auxiliaryDataType() const; - - friend QDataStream &operator<<(QDataStream &out, const PropertyValueContainer &container); - friend QDataStream &operator>>(QDataStream &in, PropertyValueContainer &container); - friend bool operator==(const PropertyValueContainer &first, - const PropertyValueContainer &second); - friend bool operator<(const PropertyValueContainer &first, const PropertyValueContainer &second); - -private: - qint32 m_instanceId; - PropertyName m_name; - QVariant m_value; - TypeName m_dynamicTypeName; - AuxiliaryDataType m_auxiliaryDataType = AuxiliaryDataType::None; - bool m_isReflected = false; -}; - -QDebug operator <<(QDebug debug, const PropertyValueContainer &container); - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::PropertyValueContainer) diff --git a/share/qtcreator/qml/qmlpuppet/container/reparentcontainer.cpp b/share/qtcreator/qml/qmlpuppet/container/reparentcontainer.cpp deleted file mode 100644 index 77206f1f9a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/reparentcontainer.cpp +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "reparentcontainer.h" - -#include <QDataStream> -#include <QDebug> - -namespace QmlDesigner { - -ReparentContainer::ReparentContainer() - : m_instanceId(-1), - m_oldParentInstanceId(-1), - m_newParentInstanceId(-1) -{ -} - -ReparentContainer::ReparentContainer(qint32 instanceId, - qint32 oldParentInstanceId, - const PropertyName &oldParentProperty, - qint32 newParentInstanceId, - const PropertyName &newParentProperty) - : m_instanceId(instanceId), - m_oldParentInstanceId(oldParentInstanceId), - m_oldParentProperty(oldParentProperty), - m_newParentInstanceId(newParentInstanceId), - m_newParentProperty(newParentProperty) -{ -} - -qint32 ReparentContainer::instanceId() const -{ - return m_instanceId; -} - -qint32 ReparentContainer::oldParentInstanceId() const -{ - return m_oldParentInstanceId; -} - -PropertyName ReparentContainer::oldParentProperty() const -{ - return m_oldParentProperty; -} - -qint32 ReparentContainer::newParentInstanceId() const -{ - return m_newParentInstanceId; -} - -PropertyName ReparentContainer::newParentProperty() const -{ - return m_newParentProperty; -} - -QDataStream &operator<<(QDataStream &out, const ReparentContainer &container) -{ - out << container.instanceId(); - out << container.oldParentInstanceId(); - out << container.oldParentProperty(); - out << container.newParentInstanceId(); - out << container.newParentProperty(); - - return out; -} - -QDataStream &operator>>(QDataStream &in, ReparentContainer &container) -{ - in >> container.m_instanceId; - in >> container.m_oldParentInstanceId; - in >> container.m_oldParentProperty; - in >> container.m_newParentInstanceId; - in >> container.m_newParentProperty; - - return in; -} - -QDebug operator <<(QDebug debug, const ReparentContainer &container) -{ - debug.nospace() << "ReparentContainer(" - << "instanceId: " << container.instanceId(); - - if (container.oldParentInstanceId() >= 0) - debug.nospace() << ", " << "oldParentInstanceId: " << container.oldParentInstanceId(); - - if (container.oldParentProperty().isEmpty()) - debug.nospace() << ", " << "oldParentProperty: " << container.oldParentProperty(); - - if (container.newParentInstanceId() >= 0) - debug.nospace() << ", " << "newParentInstanceId: " << container.newParentInstanceId(); - - if (container.newParentProperty().isEmpty()) - debug.nospace() << ", " << "newParentProperty: " << container.newParentProperty(); - - return debug.nospace() << ")"; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/reparentcontainer.h b/share/qtcreator/qml/qmlpuppet/container/reparentcontainer.h deleted file mode 100644 index e49f973fb9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/reparentcontainer.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qmetatype.h> -#include <QString> -#include <QDataStream> - -#include "nodeinstanceglobal.h" - -namespace QmlDesigner { - -class ReparentContainer -{ - friend QDataStream &operator>>(QDataStream &in, ReparentContainer &container); -public: - ReparentContainer(); - ReparentContainer(qint32 instanceId, - qint32 oldParentInstanceId, - const PropertyName &oldParentProperty, - qint32 newParentInstanceId, - const PropertyName &newParentProperty); - - qint32 instanceId() const; - qint32 oldParentInstanceId() const; - PropertyName oldParentProperty() const; - qint32 newParentInstanceId() const; - PropertyName newParentProperty() const; - -private: - qint32 m_instanceId; - qint32 m_oldParentInstanceId; - PropertyName m_oldParentProperty; - qint32 m_newParentInstanceId; - PropertyName m_newParentProperty; -}; - -QDataStream &operator<<(QDataStream &out, const ReparentContainer &container); -QDataStream &operator>>(QDataStream &in, ReparentContainer &container); - -QDebug operator <<(QDebug debug, const ReparentContainer &container); - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/sharedmemory.h b/share/qtcreator/qml/qmlpuppet/container/sharedmemory.h deleted file mode 100644 index 1c5da3454a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/sharedmemory.h +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QSharedMemory> -#include <QSystemSemaphore> - -namespace QmlDesigner { - -class SharedMemory -{ - friend class SharedMemoryLocker; -public: - SharedMemory(); - SharedMemory(const QString &key); - ~SharedMemory(); - - void setKey(const QString &key); - QString key() const; - - bool create(int size, QSharedMemory::AccessMode mode = QSharedMemory::ReadWrite); - int size() const; - - bool attach(QSharedMemory::AccessMode mode = QSharedMemory::ReadWrite); - bool isAttached() const; - bool detach(); - - void *data(); - const void* constData() const; - const void *data() const; - - bool lock(); - bool unlock(); - - QSharedMemory::SharedMemoryError error() const; - QString errorString() const; - -protected: -#ifdef Q_OS_UNIX - bool initKeyInternal(); - void cleanHandleInternal(); - bool createInternal(QSharedMemory::AccessMode mode, size_t size); - bool attachInternal(QSharedMemory::AccessMode mode); - bool detachInternal(); - int handle(); - - void setErrorString(const QString &function); -#endif -private: -#ifndef Q_OS_UNIX - QSharedMemory m_sharedMemory; -#else - void *m_memory; - size_t m_size; - QString m_key; - QByteArray m_nativeKey; - QSharedMemory::SharedMemoryError m_error; - QString m_errorString; - QSystemSemaphore m_systemSemaphore; - bool m_lockedByMe; - int m_fileHandle; - bool m_createdByMe; -#endif -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/sharedmemory_qt.cpp b/share/qtcreator/qml/qmlpuppet/container/sharedmemory_qt.cpp deleted file mode 100644 index 4165e86517..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/sharedmemory_qt.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "sharedmemory.h" - -namespace QmlDesigner { - -SharedMemory::SharedMemory() = default; - -SharedMemory::SharedMemory(const QString &key) - : m_sharedMemory(key) -{ -} - -SharedMemory::~SharedMemory() = default; - -void SharedMemory::setKey(const QString &key) -{ - m_sharedMemory.setKey(key); -} - -QString SharedMemory::key() const -{ - return m_sharedMemory.key(); -} - -bool SharedMemory::create(int size, QSharedMemory::AccessMode mode) -{ - return m_sharedMemory.create(size, mode); -} - -int SharedMemory::size() const -{ - return m_sharedMemory.size(); -} - -bool SharedMemory::attach(QSharedMemory::AccessMode mode) -{ - return m_sharedMemory.attach(mode); -} - -bool SharedMemory::isAttached() const -{ - return m_sharedMemory.isAttached(); -} - -bool SharedMemory::detach() -{ - return m_sharedMemory.detach(); -} - -void *SharedMemory::data() -{ - return m_sharedMemory.data(); -} - -const void *SharedMemory::constData() const -{ - return m_sharedMemory.constData(); -} - -const void *SharedMemory::data() const -{ - return m_sharedMemory.data(); -} - -bool SharedMemory::lock() -{ - return m_sharedMemory.lock(); -} - -bool SharedMemory::unlock() -{ - return m_sharedMemory.unlock(); -} - -QSharedMemory::SharedMemoryError SharedMemory::error() const -{ - return m_sharedMemory.error(); -} - -QString SharedMemory::errorString() const -{ - return m_sharedMemory.errorString(); -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp b/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp deleted file mode 100644 index 317aa646b1..0000000000 --- a/share/qtcreator/qml/qmlpuppet/container/sharedmemory_unix.cpp +++ /dev/null @@ -1,464 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "sharedmemory.h" -#include <qdir.h> -#include <qcryptographichash.h> - -#include "qplatformdefs.h" - -#include <errno.h> - -#include <sys/mman.h> -#include <sys/stat.h> /* For mode constants */ -#include <fcntl.h> /* For O_* constants */ - -#include <sys/types.h> -#include <sys/stat.h> -#ifdef Q_OS_OSX -#include <sys/posix_shm.h> -#endif -#include <fcntl.h> -#include <unistd.h> - -#include <private/qcore_unix_p.h> - -namespace QmlDesigner { - -class SharedMemoryLocker -{ -public: - SharedMemoryLocker(SharedMemory *sharedMemory) : m_sharedMemory(sharedMemory) - { - Q_ASSERT(m_sharedMemory); - } - - ~SharedMemoryLocker() - { - if (m_sharedMemory) - m_sharedMemory->unlock(); - } - - bool tryLocker(const QString &function) { - if (!m_sharedMemory) - return false; - - if (m_sharedMemory->lock()) - return true; - - m_sharedMemory->m_errorString = QStringLiteral("%1: unable to lock").arg(function); - m_sharedMemory->m_error = QSharedMemory::LockError; - m_sharedMemory = nullptr; - return false; - } - -private: - SharedMemory *m_sharedMemory; -}; - -static QByteArray makePlatformSafeKey(const QString &key) -{ - if (key.isEmpty()) - return QByteArray(); - QByteArray data(QCryptographicHash::hash(key.toLatin1(), QCryptographicHash::Sha1).toBase64()); - - data = data.replace('+', '-'); - data = data.replace('/', '_'); - - data.truncate(31); // OS X is only supporting 31 byte long names - - return data; -} - - -SharedMemory::SharedMemory() - : m_memory(nullptr), - m_size(0), - m_error(QSharedMemory::NoError), - m_systemSemaphore(QString()), - m_lockedByMe(false), - m_fileHandle(-1), - m_createdByMe(false) -{ -} - -SharedMemory::SharedMemory(const QString &key) - : m_memory(nullptr), - m_size(0), - m_error(QSharedMemory::NoError), - m_systemSemaphore(QString()), - m_lockedByMe(false), - m_fileHandle(-1), - m_createdByMe(false) -{ - setKey(key); -} - -SharedMemory::~SharedMemory() -{ - if (m_memory) { - munmap(m_memory, m_size); - m_memory = nullptr; - m_size = 0; - } - - if (m_fileHandle != -1) { - close(m_fileHandle); - cleanHandleInternal(); - if (m_createdByMe) - shm_unlink(m_nativeKey); - } - - setKey(QString()); -} - -void SharedMemory::setKey(const QString &key) -{ - if (key == m_key && makePlatformSafeKey(key) == m_nativeKey) - return; - - if (isAttached()) - detach(); - - m_key = key; - m_nativeKey = makePlatformSafeKey(key); -} - -QString SharedMemory::key() const -{ - return m_key; -} - -bool SharedMemory::create(int size, QSharedMemory::AccessMode mode) -{ - if (!initKeyInternal()) - return false; - - - m_systemSemaphore.setKey(m_key, 1, QSystemSemaphore::Create); - - - QString function = QLatin1String("SharedMemory::create"); - - SharedMemoryLocker lock(this); - if (!m_key.isNull() && !lock.tryLocker(function)) - return false; - - if (size <= 0) { - m_error = QSharedMemory::InvalidSize; - m_errorString = QStringLiteral("%1: create size is less then 0").arg(function); - return false; - } - - return createInternal(mode, size_t(size)); -} - -int SharedMemory::size() const -{ - return int(m_size); -} - -bool SharedMemory::attach(QSharedMemory::AccessMode mode) -{ - if (isAttached() || !initKeyInternal()) - return false; - - SharedMemoryLocker lock(this); - if (!m_key.isNull() && !lock.tryLocker(QStringLiteral("SharedMemory::attach"))) - return false; - - if (isAttached() || !handle()) - return false; - - return attachInternal(mode); -} - - -bool SharedMemory::isAttached() const -{ - return m_memory != nullptr; -} - -bool SharedMemory::detach() -{ - if (!isAttached()) - return false; - - SharedMemoryLocker lock(this); - if (!m_key.isNull() && !lock.tryLocker(QStringLiteral("SharedMemory::detach"))) - return false; - - return detachInternal(); -} - -void *SharedMemory::data() -{ - return m_memory; -} - -const void* SharedMemory::constData() const -{ - return m_memory; -} - -const void *SharedMemory::data() const -{ - return m_memory; -} - -bool SharedMemory::lock() -{ - if (m_lockedByMe) { - qWarning("SharedMemory::lock: already locked"); - return true; - } - if (m_systemSemaphore.acquire()) { - m_lockedByMe = true; - return true; - } - QString function = QStringLiteral("SharedMemory::lock"); - m_errorString = QStringLiteral("%1: unable to lock").arg(function); - m_error = QSharedMemory::LockError; - return false; -} - -bool SharedMemory::unlock() -{ - if (!m_lockedByMe) - return false; - m_lockedByMe = false; - if (m_systemSemaphore.release()) - return true; - QString function = QStringLiteral("SharedMemory::unlock"); - m_errorString = QStringLiteral("%1: unable to unlock").arg(function); - m_error = QSharedMemory::LockError; - return false; -} - -QSharedMemory::SharedMemoryError SharedMemory::error() const -{ - return m_error; -} - -QString SharedMemory::errorString() const -{ - return m_errorString; -} - -void SharedMemory::setErrorString(const QString &function) -{ - // EINVAL is handled in functions so they can give better error strings - switch (errno) { - case EACCES: - m_errorString = QStringLiteral("%1: permission denied").arg(function); - m_error = QSharedMemory::PermissionDenied; - break; - case EEXIST: - m_errorString = QStringLiteral("%1: already exists").arg(function); - m_error = QSharedMemory::AlreadyExists; - break; - case ENOENT: - m_errorString = QStringLiteral("%1: doesn't exist").arg(function); - m_error = QSharedMemory::NotFound; - break; - case EMFILE: - case ENOMEM: - case ENOSPC: - m_errorString = QStringLiteral("%1: out of resources").arg(function); - m_error = QSharedMemory::OutOfResources; - break; - default: - m_errorString = QStringLiteral("%1: unknown error %2") - .arg(function).arg(QString::fromLocal8Bit(strerror(errno))); - m_error = QSharedMemory::UnknownError; - } -} - -bool SharedMemory::initKeyInternal() -{ - cleanHandleInternal(); - - m_systemSemaphore.setKey(QString(), 1); - m_systemSemaphore.setKey(m_key, 1); - if (m_systemSemaphore.error() != QSystemSemaphore::NoError) { - m_errorString = QStringLiteral("SharedMemoryPrivate::initKey: unable to set key on lock"); - switch (m_systemSemaphore.error()) { - case QSystemSemaphore::PermissionDenied: - m_error = QSharedMemory::PermissionDenied; - break; - case QSystemSemaphore::KeyError: - m_error = QSharedMemory::KeyError; - break; - case QSystemSemaphore::AlreadyExists: - m_error = QSharedMemory::AlreadyExists; - break; - case QSystemSemaphore::NotFound: - m_error = QSharedMemory::NotFound; - break; - case QSystemSemaphore::OutOfResources: - m_error = QSharedMemory::OutOfResources; - break; - case QSystemSemaphore::UnknownError: - default: - m_error = QSharedMemory::UnknownError; - break; - } - - return false; - } - - m_errorString.clear(); - m_error = QSharedMemory::NoError; - return true; -} - -int SharedMemory::handle() -{ - return m_fileHandle; -} - -void SharedMemory::cleanHandleInternal() -{ - m_fileHandle = -1; -} - -bool SharedMemory::createInternal(QSharedMemory::AccessMode mode, size_t size) -{ - detachInternal(); - -#ifdef Q_OS_OSX - if (m_fileHandle > -1 && m_createdByMe) { - close(m_fileHandle); - shm_unlink(m_nativeKey.constData()); - m_fileHandle = -1; - } -#endif - - if (m_fileHandle == -1) { - int permission = mode == QSharedMemory::ReadOnly ? O_RDONLY : O_RDWR; - m_fileHandle = shm_open(m_nativeKey.constData(), O_CREAT | permission, 0666); - - if (m_fileHandle == -1) { - switch (errno) { - case EINVAL: - m_errorString = QStringLiteral("QSharedMemory::create: key is not invalid"); - m_error = QSharedMemory::KeyError; - break; - case EMFILE: - m_errorString = QStringLiteral("QSharedMemory::create: maximum file limit reached"); - m_error = QSharedMemory::UnknownError; - break; - case ENAMETOOLONG: - m_errorString = QStringLiteral("QSharedMemory::create: key is to long"); - m_error = QSharedMemory::KeyError; - break; - default: - setErrorString(QStringLiteral("SharedMemory::create")); - } - return false; - } - - m_createdByMe = true; - } - - struct stat statBuffer; - if (fstat(m_fileHandle, &statBuffer) == -1) - return false; - size_t fileSize = size_t(statBuffer.st_size); - - if (fileSize < size) { - int returnValue = ftruncate(m_fileHandle, ssize_t(size)); - if (returnValue == -1) { - switch (errno) { - case EFBIG: - m_errorString = QStringLiteral("QSharedMemory::create: size is to large"); - m_error = QSharedMemory::InvalidSize; - break; - default: - setErrorString(QStringLiteral("SharedMemory::create")); - } - - close(m_fileHandle); - shm_unlink(m_nativeKey.constData()); - m_fileHandle = -1; - m_size = 0; - - return false; - } - } - - int protection = mode == QSharedMemory::ReadOnly ? PROT_READ : PROT_WRITE; - m_memory = mmap(nullptr, size, protection, MAP_SHARED, m_fileHandle, 0); - - if (m_memory == MAP_FAILED) { - close(m_fileHandle); - shm_unlink(m_nativeKey.constData()); - m_memory = nullptr; - m_fileHandle = -1; - m_size = 0; - - return false; - } - - m_size = size; - - return true; -} - -bool SharedMemory::attachInternal(QSharedMemory::AccessMode mode) -{ - if (m_fileHandle == -1) { - int permission = mode == QSharedMemory::ReadOnly ? O_RDONLY : O_RDWR; - m_fileHandle = shm_open(m_nativeKey.constData(), permission, 0666); - if (m_fileHandle == -1) { - switch (errno) { - case EINVAL: - m_errorString = QStringLiteral("QSharedMemory::attach: key is invalid"); - m_error = QSharedMemory::KeyError; - break; - case EMFILE: - m_errorString = QStringLiteral("QSharedMemory::attach: maximum file limit reached"); - m_error = QSharedMemory::UnknownError; - break; - case ENAMETOOLONG: - m_errorString = QStringLiteral("QSharedMemory::attach: key is to long"); - m_error = QSharedMemory::KeyError; - break; - default: - setErrorString(QStringLiteral("SharedMemory::attach")); - } - return false; - } - } - - struct stat statBuffer; - if (fstat(m_fileHandle, &statBuffer) == -1) - return false; - size_t size = size_t(statBuffer.st_size); - - int protection = mode == QSharedMemory::ReadOnly ? PROT_READ : PROT_WRITE; - m_memory = mmap(nullptr, size, protection, MAP_SHARED, m_fileHandle, 0); - - if (m_memory == MAP_FAILED) { - m_memory = nullptr; - - return false; - } - - m_size = size; - - return true; -} - -bool SharedMemory::detachInternal() -{ - if (m_memory) { - munmap(m_memory, m_size); - m_memory = nullptr; - m_size = 0; - } - - return false; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/editor3d_qt5.qrc b/share/qtcreator/qml/qmlpuppet/editor3d_qt5.qrc deleted file mode 100644 index d4127574a6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/editor3d_qt5.qrc +++ /dev/null @@ -1,58 +0,0 @@ -<RCC> - <qresource prefix="/qtquickplugin"> - <file>mockfiles/meshes/arrow.mesh</file> - <file>mockfiles/meshes/scalerod.mesh</file> - <file>mockfiles/meshes/ring.mesh</file> - <file>mockfiles/meshes/ringselect.mesh</file> - <file>mockfiles/meshes/axishelper.mesh</file> - <file>mockfiles/images/editor_camera.png</file> - <file>mockfiles/images/editor_camera@2x.png</file> - <file>mockfiles/images/area.png</file> - <file>mockfiles/images/area@2x.png</file> - <file>mockfiles/images/directional.png</file> - <file>mockfiles/images/directional@2x.png</file> - <file>mockfiles/images/point.png</file> - <file>mockfiles/images/point@2x.png</file> - <file>mockfiles/images/static_floor.png</file> - <file>mockfiles/images/spot.png</file> - <file>mockfiles/images/spot@2x.png</file> - <file>mockfiles/images/preview_landscape.hdr</file> - <file>mockfiles/images/preview_studio.hdr</file> - <file>mockfiles/qt5/AdjustableArrow.qml</file> - <file>mockfiles/qt5/AreaLightHandle.qml</file> - <file>mockfiles/qt5/Arrow.qml</file> - <file>mockfiles/qt5/AutoScaleHelper.qml</file> - <file>mockfiles/qt5/AxisHelper.qml</file> - <file>mockfiles/qt5/AxisHelperArm.qml</file> - <file>mockfiles/qt5/CameraFrustum.qml</file> - <file>mockfiles/qt5/CameraGizmo.qml</file> - <file>mockfiles/qt5/DirectionalDraggable.qml</file> - <file>mockfiles/qt5/EditCameraController.qml</file> - <file>mockfiles/qt5/EditView3D.qml</file> - <file>mockfiles/qt5/FadeHandle.qml</file> - <file>mockfiles/qt5/HelperGrid.qml</file> - <file>mockfiles/qt5/IconGizmo.qml</file> - <file>mockfiles/qt5/IconRenderer3D.qml</file> - <file>mockfiles/qt5/LightGizmo.qml</file> - <file>mockfiles/qt5/LightIconGizmo.qml</file> - <file>mockfiles/qt5/LightModel.qml</file> - <file>mockfiles/qt5/Line3D.qml</file> - <file>mockfiles/qt5/MaterialNodeView.qml</file> - <file>mockfiles/qt5/ModelNode2DImageView.qml</file> - <file>mockfiles/qt5/ModelNode3DImageView.qml</file> - <file>mockfiles/qt5/ModelNodeView.qml</file> - <file>mockfiles/qt5/MoveGizmo.qml</file> - <file>mockfiles/qt5/NodeNodeView.qml</file> - <file>mockfiles/qt5/Overlay2D.qml</file> - <file>mockfiles/qt5/PlanarDraggable.qml</file> - <file>mockfiles/qt5/PlanarMoveHandle.qml</file> - <file>mockfiles/qt5/PlanarScaleHandle.qml</file> - <file>mockfiles/qt5/RotateGizmo.qml</file> - <file>mockfiles/qt5/RotateRing.qml</file> - <file>mockfiles/qt5/ScaleGizmo.qml</file> - <file>mockfiles/qt5/ScaleRod.qml</file> - <file>mockfiles/qt5/SceneView3D.qml</file> - <file>mockfiles/qt5/SelectionBox.qml</file> - <file>mockfiles/qt5/SpotLightHandle.qml</file> - </qresource> -</RCC> diff --git a/share/qtcreator/qml/qmlpuppet/editor3d_qt6.qrc b/share/qtcreator/qml/qmlpuppet/editor3d_qt6.qrc deleted file mode 100644 index bb29d683a0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/editor3d_qt6.qrc +++ /dev/null @@ -1,61 +0,0 @@ -<RCC> - <qresource prefix="/qtquickplugin"> - <file>mockfiles/meshes/arrow.mesh</file> - <file>mockfiles/meshes/scalerod.mesh</file> - <file>mockfiles/meshes/ring.mesh</file> - <file>mockfiles/meshes/ringselect.mesh</file> - <file>mockfiles/meshes/axishelper.mesh</file> - <file>mockfiles/images/editor_camera.png</file> - <file>mockfiles/images/editor_camera@2x.png</file> - <file>mockfiles/images/editor_particlesystem.png</file> - <file>mockfiles/images/editor_particlesystem@2x.png</file> - <file>mockfiles/images/area.png</file> - <file>mockfiles/images/area@2x.png</file> - <file>mockfiles/images/directional.png</file> - <file>mockfiles/images/directional@2x.png</file> - <file>mockfiles/images/point.png</file> - <file>mockfiles/images/point@2x.png</file> - <file>mockfiles/images/floor_tex.png</file> - <file>mockfiles/images/spot.png</file> - <file>mockfiles/images/spot@2x.png</file> - <file>mockfiles/images/preview_landscape.hdr</file> - <file>mockfiles/images/preview_studio.hdr</file> - <file>mockfiles/qt6/AdjustableArrow.qml</file> - <file>mockfiles/qt6/AreaLightHandle.qml</file> - <file>mockfiles/qt6/Arrow.qml</file> - <file>mockfiles/qt6/AutoScaleHelper.qml</file> - <file>mockfiles/qt6/AxisHelper.qml</file> - <file>mockfiles/qt6/AxisHelperArm.qml</file> - <file>mockfiles/qt6/CameraFrustum.qml</file> - <file>mockfiles/qt6/CameraGizmo.qml</file> - <file>mockfiles/qt6/DirectionalDraggable.qml</file> - <file>mockfiles/qt6/EditCameraController.qml</file> - <file>mockfiles/qt6/EditView3D.qml</file> - <file>mockfiles/qt6/FadeHandle.qml</file> - <file>mockfiles/qt6/HelperGrid.qml</file> - <file>mockfiles/qt6/IconGizmo.qml</file> - <file>mockfiles/qt6/LightGizmo.qml</file> - <file>mockfiles/qt6/LightIconGizmo.qml</file> - <file>mockfiles/qt6/LightModel.qml</file> - <file>mockfiles/qt6/Line3D.qml</file> - <file>mockfiles/qt6/MaterialNodeView.qml</file> - <file>mockfiles/qt6/ModelNode2DImageView.qml</file> - <file>mockfiles/qt6/ModelNode3DImageView.qml</file> - <file>mockfiles/qt6/ModelNodeView.qml</file> - <file>mockfiles/qt6/MoveGizmo.qml</file> - <file>mockfiles/qt6/NodeNodeView.qml</file> - <file>mockfiles/qt6/Overlay2D.qml</file> - <file>mockfiles/qt6/ParticleSystemGizmo.qml</file> - <file>mockfiles/qt6/ParticleEmitterGizmo.qml</file> - <file>mockfiles/qt6/PlanarDraggable.qml</file> - <file>mockfiles/qt6/PlanarMoveHandle.qml</file> - <file>mockfiles/qt6/PlanarScaleHandle.qml</file> - <file>mockfiles/qt6/RotateGizmo.qml</file> - <file>mockfiles/qt6/RotateRing.qml</file> - <file>mockfiles/qt6/ScaleGizmo.qml</file> - <file>mockfiles/qt6/ScaleRod.qml</file> - <file>mockfiles/qt6/SceneView3D.qml</file> - <file>mockfiles/qt6/SelectionBox.qml</file> - <file>mockfiles/qt6/SpotLightHandle.qml</file> - </qresource> -</RCC> diff --git a/share/qtcreator/qml/qmlpuppet/html/welcome.html b/share/qtcreator/qml/qmlpuppet/html/welcome.html deleted file mode 100644 index bde0a094e2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/html/welcome.html +++ /dev/null @@ -1,16 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> -<html> - <head> - <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> - <title>Replace this HTML file</title> - </head> - <body> - <br/> - <div align="center"> - <a href="http://webkit.org/" style="text-decoration:none;"><img src="qrc:/qtquickplugin/images/webkit.png" alt="WebKit" border=0 /></a> - <br/> - Replace this HTML file with your own - </div> - -</body> -</html> diff --git a/share/qtcreator/qml/qmlpuppet/images/non-visual-component.png b/share/qtcreator/qml/qmlpuppet/images/non-visual-component.png Binary files differdeleted file mode 100644 index f66e2b8b11..0000000000 --- a/share/qtcreator/qml/qmlpuppet/images/non-visual-component.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/images/non-visual-component@2x.png b/share/qtcreator/qml/qmlpuppet/images/non-visual-component@2x.png Binary files differdeleted file mode 100644 index 25a136ff25..0000000000 --- a/share/qtcreator/qml/qmlpuppet/images/non-visual-component@2x.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/images/template_image.png b/share/qtcreator/qml/qmlpuppet/images/template_image.png Binary files differdeleted file mode 100644 index 96e7e63796..0000000000 --- a/share/qtcreator/qml/qmlpuppet/images/template_image.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/images/webkit.png b/share/qtcreator/qml/qmlpuppet/images/webkit.png Binary files differdeleted file mode 100644 index cf6d7f1c19..0000000000 --- a/share/qtcreator/qml/qmlpuppet/images/webkit.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/instances/instances.pri deleted file mode 100644 index daf1d3ed51..0000000000 --- a/share/qtcreator/qml/qmlpuppet/instances/instances.pri +++ /dev/null @@ -1,5 +0,0 @@ -INCLUDEPATH += $$PWD/ - -HEADERS += $$PWD/nodeinstanceclientproxy.h - -SOURCES += $$PWD/nodeinstanceclientproxy.cpp diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp deleted file mode 100644 index 0e349f7b86..0000000000 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.cpp +++ /dev/null @@ -1,635 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "nodeinstanceclientproxy.h" - -#include <QLocalSocket> -#include <QVariant> -#include <QCoreApplication> -#include <QStringList> -#include <QFile> -#include <QFileInfo> -#include <QBuffer> - -#include "nodeinstanceserverinterface.h" - -#include "captureddatacommand.h" -#include "changeauxiliarycommand.h" -#include "changebindingscommand.h" -#include "changefileurlcommand.h" -#include "changeidscommand.h" -#include "changelanguagecommand.h" -#include "changenodesourcecommand.h" -#include "changepreviewimagesizecommand.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 "endpuppetcommand.h" -#include "imagecontainer.h" -#include "informationchangedcommand.h" -#include "inputeventcommand.h" -#include "instancecontainer.h" -#include "pixmapchangedcommand.h" -#include "propertyabstractcontainer.h" -#include "propertybindingcontainer.h" -#include "propertyvaluecontainer.h" -#include "puppetalivecommand.h" -#include "puppettocreatorcommand.h" -#include "removeinstancescommand.h" -#include "removepropertiescommand.h" -#include "removesharedmemorycommand.h" -#include "reparentinstancescommand.h" -#include "scenecreatedcommand.h" -#include "statepreviewimagechangedcommand.h" -#include "synchronizecommand.h" -#include "tokencommand.h" -#include "update3dviewstatecommand.h" -#include "valueschangedcommand.h" -#include "view3dactioncommand.h" -#include "requestmodelnodepreviewimagecommand.h" -#include "nanotracecommand.h" - -// Nanotrace headers are not exported to build dir at all if the feature is disabled, so -// runtime puppet build can't find them. -#if NANOTRACE_ENABLED -#include "nanotrace/nanotrace.h" -#else -#define NANOTRACE_INIT(process, thread, filepath) -#define NANOTRACE_SHUTDOWN() -#define NANOTRACE_SCOPE_ARGS(cat, name, ...) -#endif - -namespace QmlDesigner { - -void (QLocalSocket::*LocalSocketErrorFunction)(QLocalSocket::LocalSocketError) -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) - = &QLocalSocket::error; -#else - = &QLocalSocket::errorOccurred; -#endif - -NodeInstanceClientProxy::NodeInstanceClientProxy(QObject *parent) - : QObject(parent) - , m_inputIoDevice(nullptr) - , m_outputIoDevice(nullptr) - , m_writeCommandCounter(0) - , m_synchronizeId(-1) -{ - connect(&m_puppetAliveTimer, &QTimer::timeout, this, &NodeInstanceClientProxy::sendPuppetAliveCommand); - m_puppetAliveTimer.setInterval(2000); - m_puppetAliveTimer.start(); -} - -NodeInstanceClientProxy::~NodeInstanceClientProxy() = default; - -void NodeInstanceClientProxy::initializeSocket() -{ - QLocalSocket *localSocket = new QLocalSocket(this); - connect(localSocket, &QIODevice::readyRead, this, &NodeInstanceClientProxy::readDataStream); - connect(localSocket, LocalSocketErrorFunction, - QCoreApplication::instance(), &QCoreApplication::quit); - connect(localSocket, &QLocalSocket::disconnected, QCoreApplication::instance(), &QCoreApplication::quit); - localSocket->connectToServer(QCoreApplication::arguments().at(1), QIODevice::ReadWrite | QIODevice::Unbuffered); - localSocket->waitForConnected(-1); - - m_inputIoDevice = localSocket; - m_outputIoDevice = localSocket; -} - -void NodeInstanceClientProxy::initializeCapturedStream(const QString &fileName) -{ - m_inputIoDevice = new QFile(fileName, this); - bool inputStreamCanBeOpened = m_inputIoDevice->open(QIODevice::ReadOnly); - if (!inputStreamCanBeOpened) { - qDebug() << "Input stream file cannot be opened: " << fileName; - exit(-1); - } - - if (QCoreApplication::arguments().count() == 3) { - QFileInfo inputFileInfo(fileName); - m_outputIoDevice = new QFile(inputFileInfo.path()+ "/" + inputFileInfo.baseName() + ".commandcontrolstream", this); - bool outputStreamCanBeOpened = m_outputIoDevice->open(QIODevice::WriteOnly); - if (!outputStreamCanBeOpened) { - qDebug() << "Output stream file cannot be opened"; - exit(-1); - } - } else if (QCoreApplication::arguments().count() == 4) { - m_controlStream.setFileName(QCoreApplication::arguments().at(3)); - bool controlStreamCanBeOpened = m_controlStream.open(QIODevice::ReadOnly); - if (!controlStreamCanBeOpened) { - qDebug() << "Control stream file cannot be opened"; - exit(-1); - } - } - -} - -bool compareCommands(const QVariant &command, const QVariant &controlCommand) -{ - static const int informationChangedCommandType = QMetaType::type("InformationChangedCommand"); - static const int valuesChangedCommandType = QMetaType::type("ValuesChangedCommand"); - static const int valuesModifiedCommandType = QMetaType::type("ValuesModifiedCommand"); - static const int pixmapChangedCommandType = QMetaType::type("PixmapChangedCommand"); - static const int childrenChangedCommandType = QMetaType::type("ChildrenChangedCommand"); - static const int statePreviewImageChangedCommandType = QMetaType::type("StatePreviewImageChangedCommand"); - static const int componentCompletedCommandType = QMetaType::type("ComponentCompletedCommand"); - static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand"); - static const int tokenCommandType = QMetaType::type("TokenCommand"); - static const int debugOutputCommandType = QMetaType::type("DebugOutputCommand"); - static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand"); - - if (command.userType() == controlCommand.userType()) { - if (command.userType() == informationChangedCommandType) - return command.value<InformationChangedCommand>() == controlCommand.value<InformationChangedCommand>(); - else if (command.userType() == valuesChangedCommandType) - return command.value<ValuesChangedCommand>() == controlCommand.value<ValuesChangedCommand>(); - else if (command.userType() == valuesModifiedCommandType) - return command.value<ValuesModifiedCommand>() == controlCommand.value<ValuesModifiedCommand>(); - else if (command.userType() == pixmapChangedCommandType) - return command.value<PixmapChangedCommand>() == controlCommand.value<PixmapChangedCommand>(); - else if (command.userType() == childrenChangedCommandType) - return command.value<ChildrenChangedCommand>() == controlCommand.value<ChildrenChangedCommand>(); - else if (command.userType() == statePreviewImageChangedCommandType) - return command.value<StatePreviewImageChangedCommand>() == controlCommand.value<StatePreviewImageChangedCommand>(); - else if (command.userType() == componentCompletedCommandType) - return command.value<ComponentCompletedCommand>() == controlCommand.value<ComponentCompletedCommand>(); - else if (command.userType() == synchronizeCommandType) - return command.value<SynchronizeCommand>() == controlCommand.value<SynchronizeCommand>(); - else if (command.userType() == tokenCommandType) - return command.value<TokenCommand>() == controlCommand.value<TokenCommand>(); - else if (command.userType() == debugOutputCommandType) - return command.value<DebugOutputCommand>() == controlCommand.value<DebugOutputCommand>(); - else if (command.userType() == changeSelectionCommandType) - return command.value<ChangeSelectionCommand>() - == controlCommand.value<ChangeSelectionCommand>(); - } - - return false; -} - -void NodeInstanceClientProxy::writeCommand(const QVariant &command) -{ - if (m_controlStream.isReadable()) { - static quint32 readCommandCounter = 0; - static quint32 blockSize = 0; - - QVariant controlCommand = readCommandFromIOStream(&m_controlStream, &readCommandCounter, &blockSize); - - if (!compareCommands(command, controlCommand)) { - qDebug() << "Commands differ!"; - exit(-1); - } - } else if (m_outputIoDevice) { -#ifdef NANOTRACE_ENABLED - if (command.userType() != QMetaType::type("PuppetAliveCommand")) { - if (command.userType() == QMetaType::type("SyncNanotraceCommand")) { - SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>(); - NANOTRACE_INSTANT_ARGS("Sync", "writeCommand", - {"name", cmd.name().toStdString()}, - {"counter", int64_t(m_writeCommandCounter)}); - - } else { - NANOTRACE_INSTANT_ARGS("Update", "writeCommand", - {"name", command.typeName()}, - {"counter", int64_t(m_writeCommandCounter)}); - } - } -#endif - QByteArray block; - QDataStream out(&block, QIODevice::WriteOnly); - out.setVersion(QDataStream::Qt_4_8); - out << quint32(0); - out << quint32(m_writeCommandCounter); - m_writeCommandCounter++; - out << command; - out.device()->seek(0); - out << quint32(block.size() - sizeof(quint32)); - - m_outputIoDevice->write(block); - } -} - -void NodeInstanceClientProxy::informationChanged(const InformationChangedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::valuesChanged(const ValuesChangedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::valuesModified(const ValuesModifiedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::pixmapChanged(const PixmapChangedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::childrenChanged(const ChildrenChangedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::componentCompleted(const ComponentCompletedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::token(const TokenCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::debugOutput(const DebugOutputCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::puppetAlive(const PuppetAliveCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::selectionChanged(const ChangeSelectionCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::capturedData(const CapturedDataCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::sceneCreated(const SceneCreatedCommand &command) -{ - writeCommand(QVariant::fromValue(command)); -} - -void NodeInstanceClientProxy::flush() -{ -} - -void NodeInstanceClientProxy::synchronizeWithClientProcess() -{ - if (m_synchronizeId >= 0) { - SynchronizeCommand synchronizeCommand(m_synchronizeId); - writeCommand(QVariant::fromValue(synchronizeCommand)); - } -} - -qint64 NodeInstanceClientProxy::bytesToWrite() const -{ - return m_inputIoDevice->bytesToWrite(); -} - -QVariant NodeInstanceClientProxy::readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize) -{ - QDataStream in(ioDevice); - in.setVersion(QDataStream::Qt_4_8); - - if (*blockSize == 0) { - in >> *blockSize; - } - - if (ioDevice->bytesAvailable() < *blockSize) - return QVariant(); - - quint32 commandCounter; - in >> commandCounter; - bool commandLost = !((commandCounter == 0 && *readCommandCounter == 0) || (*readCommandCounter + 1 == commandCounter)); - if (commandLost) - qDebug() << "client command lost: " << *readCommandCounter << commandCounter; - *readCommandCounter = commandCounter; - - QVariant command; - in >> command; - *blockSize = 0; - - if (in.status() != QDataStream::Ok) { - qWarning() << "Stream is not OK"; - exit(1); - } - - return command; -} - -void NodeInstanceClientProxy::inputEvent(const InputEventCommand &command) -{ - nodeInstanceServer()->inputEvent(command); -} - -void NodeInstanceClientProxy::view3DAction(const View3DActionCommand &command) -{ - nodeInstanceServer()->view3DAction(command); -} - -void NodeInstanceClientProxy::requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command) -{ - nodeInstanceServer()->requestModelNodePreviewImage(command); -} - -void NodeInstanceClientProxy::changeLanguage(const ChangeLanguageCommand &command) -{ - nodeInstanceServer()->changeLanguage(command); -} - -void NodeInstanceClientProxy::changePreviewImageSize(const ChangePreviewImageSizeCommand &command) -{ - nodeInstanceServer()->changePreviewImageSize(command); -} - -void NodeInstanceClientProxy::startNanotrace(const StartNanotraceCommand &command) -{ - QString name = qApp->arguments().at(2); - std::string directory = command.path().toStdString(); - std::string processName = name.toStdString(); - std::string fullFilePath = - directory + std::string("/nanotrace_qmlpuppet_") + processName + std::string(".json"); - - for (size_t i=0; i<processName.length(); ++i) { - if (i==0 || processName[i]=='m') - processName[i] = std::toupper(processName[i]); - } - processName = processName + std::string("Puppet"); - - NANOTRACE_INIT(processName.c_str(), "MainThread", fullFilePath); - - writeCommand(QVariant::fromValue(SyncNanotraceCommand(name))); -} - -void NodeInstanceClientProxy::readDataStream() -{ - QList<QVariant> commandList; - - while (!m_inputIoDevice->atEnd()) { - if (m_inputIoDevice->bytesAvailable() < int(sizeof(quint32))) - break; - - static quint32 readCommandCounter = 0; - static quint32 blockSize = 0; - - QVariant command = readCommandFromIOStream(m_inputIoDevice, &readCommandCounter, &blockSize); -#ifdef NANOTRACE_ENABLED - if (command.userType() != QMetaType::type("EndNanotraceCommand")) { - if (command.userType() == QMetaType::type("SyncNanotraceCommand")) { - SyncNanotraceCommand cmd = command.value<SyncNanotraceCommand>(); - NANOTRACE_INSTANT_ARGS("Sync", "readCommand", - {"name", cmd.name().toStdString()}, - {"counter", int64_t(readCommandCounter)}); - // Do not dispatch this command. - continue; - - } else { - NANOTRACE_INSTANT_ARGS("Update", "readCommand", - {"name", command.typeName()}, - {"counter", int64_t(readCommandCounter)}); - } - } -#endif - if (command.isValid()) - commandList.append(command); - else - break; - } - - for (const QVariant &command : std::as_const(commandList)) - dispatchCommand(command); -} - -void NodeInstanceClientProxy::sendPuppetAliveCommand() -{ - puppetAlive(PuppetAliveCommand()); -} - -NodeInstanceServerInterface *NodeInstanceClientProxy::nodeInstanceServer() const -{ - return m_nodeInstanceServer.get(); -} - -void NodeInstanceClientProxy::setNodeInstanceServer( - std::unique_ptr<NodeInstanceServerInterface> nodeInstanceServer) -{ - m_nodeInstanceServer = std::move(nodeInstanceServer); -} - -void NodeInstanceClientProxy::createInstances(const CreateInstancesCommand &command) -{ - nodeInstanceServer()->createInstances(command); -} - -void NodeInstanceClientProxy::changeFileUrl(const ChangeFileUrlCommand &command) -{ - nodeInstanceServer()->changeFileUrl(command); -} - -void NodeInstanceClientProxy::createScene(const CreateSceneCommand &command) -{ - nodeInstanceServer()->createScene(command); -} - -void NodeInstanceClientProxy::update3DViewState(const Update3dViewStateCommand &command) -{ - nodeInstanceServer()->update3DViewState(command); -} - -void NodeInstanceClientProxy::clearScene(const ClearSceneCommand &command) -{ - nodeInstanceServer()->clearScene(command); -} - -void NodeInstanceClientProxy::removeInstances(const RemoveInstancesCommand &command) -{ - nodeInstanceServer()->removeInstances(command); -} - -void NodeInstanceClientProxy::removeProperties(const RemovePropertiesCommand &command) -{ - nodeInstanceServer()->removeProperties(command); -} - -void NodeInstanceClientProxy::changePropertyBindings(const ChangeBindingsCommand &command) -{ - nodeInstanceServer()->changePropertyBindings(command); -} - -void NodeInstanceClientProxy::changePropertyValues(const ChangeValuesCommand &command) -{ - nodeInstanceServer()->changePropertyValues(command); -} - -void NodeInstanceClientProxy::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) -{ - nodeInstanceServer()->changeAuxiliaryValues(command); -} - -void NodeInstanceClientProxy::reparentInstances(const ReparentInstancesCommand &command) -{ - nodeInstanceServer()->reparentInstances(command); -} - -void NodeInstanceClientProxy::changeIds(const ChangeIdsCommand &command) -{ - nodeInstanceServer()->changeIds(command); -} - -void NodeInstanceClientProxy::changeState(const ChangeStateCommand &command) -{ - nodeInstanceServer()->changeState(command); -} - -void NodeInstanceClientProxy::completeComponent(const CompleteComponentCommand &command) -{ - nodeInstanceServer()->completeComponent(command); -} - -void NodeInstanceClientProxy::changeNodeSource(const ChangeNodeSourceCommand &command) -{ - nodeInstanceServer()->changeNodeSource(command); -} - -void NodeInstanceClientProxy::removeSharedMemory(const RemoveSharedMemoryCommand &command) -{ - nodeInstanceServer()->removeSharedMemory(command); -} -void NodeInstanceClientProxy::redirectToken(const TokenCommand &command) -{ - nodeInstanceServer()->token(command); -} - -void NodeInstanceClientProxy::redirectToken(const EndPuppetCommand & /*command*/) -{ - if (m_outputIoDevice && m_outputIoDevice->isOpen()) - m_outputIoDevice->close(); - - if (m_inputIoDevice && m_inputIoDevice->isOpen()) - m_inputIoDevice->close(); - - if (m_controlStream.isOpen()) - m_controlStream.close(); - - qDebug() << "End Process: " << QCoreApplication::applicationPid(); - QCoreApplication::exit(); -} - -void NodeInstanceClientProxy::changeSelection(const ChangeSelectionCommand &command) -{ - nodeInstanceServer()->changeSelection(command); -} - -void NodeInstanceClientProxy::dispatchCommand(const QVariant &command) -{ - NANOTRACE_SCOPE_ARGS("Update", "dispatchCommand", {"name", command.typeName()}); - - static const int createInstancesCommandType = QMetaType::type("CreateInstancesCommand"); - static const int update3dViewStateCommand = QMetaType::type("Update3dViewStateCommand"); - static const int changeFileUrlCommandType = QMetaType::type("ChangeFileUrlCommand"); - static const int createSceneCommandType = QMetaType::type("CreateSceneCommand"); - static const int clearSceneCommandType = QMetaType::type("ClearSceneCommand"); - static const int removeInstancesCommandType = QMetaType::type("RemoveInstancesCommand"); - static const int removePropertiesCommandType = QMetaType::type("RemovePropertiesCommand"); - static const int changeBindingsCommandType = QMetaType::type("ChangeBindingsCommand"); - static const int changeValuesCommandType = QMetaType::type("ChangeValuesCommand"); - static const int changeAuxiliaryCommandType = QMetaType::type("ChangeAuxiliaryCommand"); - static const int reparentInstancesCommandType = QMetaType::type("ReparentInstancesCommand"); - static const int changeIdsCommandType = QMetaType::type("ChangeIdsCommand"); - static const int changeStateCommandType = QMetaType::type("ChangeStateCommand"); - static const int completeComponentCommandType = QMetaType::type("CompleteComponentCommand"); - static const int synchronizeCommandType = QMetaType::type("SynchronizeCommand"); - static const int changeNodeSourceCommandType = QMetaType::type("ChangeNodeSourceCommand"); - static const int removeSharedMemoryCommandType = QMetaType::type("RemoveSharedMemoryCommand"); - static const int tokenCommandType = QMetaType::type("TokenCommand"); - static const int endPuppetCommandType = QMetaType::type("EndPuppetCommand"); - static const int changeSelectionCommandType = QMetaType::type("ChangeSelectionCommand"); - static const int inputEventCommandType = QMetaType::type("InputEventCommand"); - static const int view3DActionCommandType = QMetaType::type("View3DActionCommand"); - static const int requestModelNodePreviewImageCommandType = QMetaType::type("RequestModelNodePreviewImageCommand"); - static const int changeLanguageCommand = QMetaType::type("ChangeLanguageCommand"); - static const int changePreviewImageSizeCommand = QMetaType::type( - "ChangePreviewImageSizeCommand"); - static const int startNanotraceCommandType = QMetaType::type("StartNanotraceCommand"); - static const int endNanotraceCommandType = QMetaType::type("EndNanotraceCommand"); - - const int commandType = command.userType(); - - if (commandType == inputEventCommandType) - inputEvent(command.value<InputEventCommand>()); - else if (commandType == createInstancesCommandType) - createInstances(command.value<CreateInstancesCommand>()); - else if (commandType == update3dViewStateCommand) - update3DViewState(command.value<Update3dViewStateCommand>()); - else if (commandType == changeFileUrlCommandType) - changeFileUrl(command.value<ChangeFileUrlCommand>()); - else if (commandType == createSceneCommandType) - createScene(command.value<CreateSceneCommand>()); - else if (commandType == clearSceneCommandType) - clearScene(command.value<ClearSceneCommand>()); - else if (commandType == removeInstancesCommandType) - removeInstances(command.value<RemoveInstancesCommand>()); - else if (commandType == removePropertiesCommandType) - removeProperties(command.value<RemovePropertiesCommand>()); - else if (commandType == changeBindingsCommandType) - changePropertyBindings(command.value<ChangeBindingsCommand>()); - else if (commandType == changeValuesCommandType) - changePropertyValues(command.value<ChangeValuesCommand>()); - else if (commandType == changeAuxiliaryCommandType) - changeAuxiliaryValues(command.value<ChangeAuxiliaryCommand>()); - else if (commandType == reparentInstancesCommandType) - reparentInstances(command.value<ReparentInstancesCommand>()); - else if (commandType == changeIdsCommandType) - changeIds(command.value<ChangeIdsCommand>()); - else if (commandType == changeStateCommandType) - changeState(command.value<ChangeStateCommand>()); - else if (commandType == completeComponentCommandType) - completeComponent(command.value<CompleteComponentCommand>()); - else if (commandType == changeNodeSourceCommandType) - changeNodeSource(command.value<ChangeNodeSourceCommand>()); - else if (commandType == removeSharedMemoryCommandType) - removeSharedMemory(command.value<RemoveSharedMemoryCommand>()); - else if (commandType == tokenCommandType) - redirectToken(command.value<TokenCommand>()); - else if (commandType == endPuppetCommandType) - redirectToken(command.value<EndPuppetCommand>()); - else if (commandType == view3DActionCommandType) - view3DAction(command.value<View3DActionCommand>()); - else if (commandType == requestModelNodePreviewImageCommandType) - requestModelNodePreviewImage(command.value<RequestModelNodePreviewImageCommand>()); - else if (commandType == synchronizeCommandType) { - SynchronizeCommand synchronizeCommand = command.value<SynchronizeCommand>(); - m_synchronizeId = synchronizeCommand.synchronizeId(); - } else if (commandType == changeSelectionCommandType) { - ChangeSelectionCommand changeSelectionCommand = command.value<ChangeSelectionCommand>(); - changeSelection(changeSelectionCommand); - } else if (command.userType() == changeLanguageCommand) { - changeLanguage(command.value<ChangeLanguageCommand>()); - } else if (command.userType() == changePreviewImageSizeCommand) { - changePreviewImageSize(command.value<ChangePreviewImageSizeCommand>()); - } else if (command.userType() == startNanotraceCommandType) { - startNanotrace(command.value<StartNanotraceCommand>()); - } else if (command.userType() == endNanotraceCommandType) { - NANOTRACE_SHUTDOWN(); - } else { - Q_ASSERT(false); - } -} -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h deleted file mode 100644 index 046117887e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/instances/nodeinstanceclientproxy.h +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "nodeinstanceclientinterface.h" - -#include <QObject> -#include <QHash> -#include <QWeakPointer> -#include <QFile> -#include <QTimer> - -#include <memory> - -QT_BEGIN_NAMESPACE -class QLocalSocket; -class QIODevice; -QT_END_NAMESPACE - -namespace QmlDesigner { - -class NodeInstanceServerInterface; -class CreateSceneCommand; -class CreateInstancesCommand; -class ClearSceneCommand; -class ReparentInstancesCommand; -class Update3dViewStateCommand; -class ChangeFileUrlCommand; -class ChangeValuesCommand; -class ChangeAuxiliaryCommand; -class ChangeBindingsCommand; -class ChangeIdsCommand; -class RemoveInstancesCommand; -class RemovePropertiesCommand; -class CompleteComponentCommand; -class ChangeStateCommand; -class ChangeNodeSourceCommand; -class EndPuppetCommand; -class ChangeSelectionCommand; -class PuppetToCreatorCommand; -class InputEventCommand; -class View3DActionCommand; -class RequestModelNodePreviewImageCommand; -class ChangeLanguageCommand; -class ChangePreviewImageSizeCommand; -class StartNanotraceCommand; - -class NodeInstanceClientProxy : public QObject, public NodeInstanceClientInterface -{ - Q_OBJECT - -public: - NodeInstanceClientProxy(QObject *parent); - ~NodeInstanceClientProxy() override; - - void informationChanged(const InformationChangedCommand &command) override; - void valuesChanged(const ValuesChangedCommand &command) override; - void valuesModified(const ValuesModifiedCommand &command) override; - void pixmapChanged(const PixmapChangedCommand &command) override; - void childrenChanged(const ChildrenChangedCommand &command) override; - void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) override; - void componentCompleted(const ComponentCompletedCommand &command) override; - void token(const TokenCommand &command) override; - void debugOutput(const DebugOutputCommand &command) override; - void puppetAlive(const PuppetAliveCommand &command); - void selectionChanged(const ChangeSelectionCommand &command) override; - void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) override; - void capturedData(const CapturedDataCommand &capturedData) override; - void sceneCreated(const SceneCreatedCommand &command) override; - - void flush() override; - void synchronizeWithClientProcess() override; - qint64 bytesToWrite() const override; - -protected: - void initializeSocket(); - void initializeCapturedStream(const QString &fileName); - void writeCommand(const QVariant &command); - void dispatchCommand(const QVariant &command); - NodeInstanceServerInterface *nodeInstanceServer() const; - void setNodeInstanceServer(std::unique_ptr<NodeInstanceServerInterface> nodeInstanceServer); - - void createInstances(const CreateInstancesCommand &command); - void changeFileUrl(const ChangeFileUrlCommand &command); - void createScene(const CreateSceneCommand &command); - void clearScene(const ClearSceneCommand &command); - void update3DViewState(const Update3dViewStateCommand &command); - void removeInstances(const RemoveInstancesCommand &command); - void removeProperties(const RemovePropertiesCommand &command); - void changePropertyBindings(const ChangeBindingsCommand &command); - void changePropertyValues(const ChangeValuesCommand &command); - void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command); - void reparentInstances(const ReparentInstancesCommand &command); - void changeIds(const ChangeIdsCommand &command); - void changeState(const ChangeStateCommand &command); - void completeComponent(const CompleteComponentCommand &command); - void changeNodeSource(const ChangeNodeSourceCommand &command); - void removeSharedMemory(const RemoveSharedMemoryCommand &command); - void redirectToken(const TokenCommand &command); - void redirectToken(const EndPuppetCommand &command); - void changeSelection(const ChangeSelectionCommand &command); - static QVariant readCommandFromIOStream(QIODevice *ioDevice, quint32 *readCommandCounter, quint32 *blockSize); - void inputEvent(const InputEventCommand &command); - void view3DAction(const View3DActionCommand &command); - void requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command); - void changeLanguage(const ChangeLanguageCommand &command); - void changePreviewImageSize(const ChangePreviewImageSizeCommand &command); - void startNanotrace(const StartNanotraceCommand& command); - -protected slots: - void readDataStream(); - void sendPuppetAliveCommand(); - -private: - QFile m_controlStream; - QTimer m_puppetAliveTimer; - QIODevice *m_inputIoDevice; - QIODevice *m_outputIoDevice; - std::unique_ptr<NodeInstanceServerInterface> m_nodeInstanceServer; - quint32 m_writeCommandCounter; - int m_synchronizeId; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h b/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h deleted file mode 100644 index 7909c097b0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/interfaces/commondefines.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QMetaType> -#include <QPair> - -namespace QmlDesigner { - -enum InformationName -{ - NoName, - NoInformationChange = NoName, - AllStates, - Size, - BoundingRect, - Transform, - HasAnchor, - Anchor, - InstanceTypeForProperty, - PenWidth, - Position, - IsInLayoutable, - SceneTransform, - IsResizable, - IsMovable, - IsAnchoredByChildren, - IsAnchoredBySibling, - HasContent, - HasBindingForProperty, - ContentTransform, - ContentItemTransform, - ContentItemBoundingRect, - MoveView, - ShowView, - ResizeView, - HideView -}; - -} diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/interfaces.pri b/share/qtcreator/qml/qmlpuppet/interfaces/interfaces.pri deleted file mode 100644 index aeaf3a765e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/interfaces/interfaces.pri +++ /dev/null @@ -1,8 +0,0 @@ -INCLUDEPATH += $$PWD/ - -HEADERS += $$PWD/nodeinstanceclientinterface.h -HEADERS += $$PWD/nodeinstanceglobal.h -HEADERS += $$PWD/nodeinstanceserverinterface.h -HEADERS += $$PWD/commondefines.h - -SOURCES += $$PWD/nodeinstanceserverinterface.cpp diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h deleted file mode 100644 index 01d2ac8a2e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceclientinterface.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtGlobal> - -namespace QmlDesigner { - -class ValuesChangedCommand; -class ValuesModifiedCommand; -class PixmapChangedCommand; -class InformationChangedCommand; -class ChildrenChangedCommand; -class StatePreviewImageChangedCommand; -class ComponentCompletedCommand; -class TokenCommand; -class RemoveSharedMemoryCommand; -class DebugOutputCommand; -class PuppetAliveCommand; -class ChangeSelectionCommand; -class PuppetToCreatorCommand; -class CapturedDataCommand; -class SceneCreatedCommand; - -class NodeInstanceClientInterface -{ -public: - virtual void informationChanged(const InformationChangedCommand &command) = 0; - virtual void valuesChanged(const ValuesChangedCommand &command) = 0; - virtual void valuesModified(const ValuesModifiedCommand &command) = 0; - virtual void pixmapChanged(const PixmapChangedCommand &command) = 0; - virtual void childrenChanged(const ChildrenChangedCommand &command) = 0; - virtual void statePreviewImagesChanged(const StatePreviewImageChangedCommand &command) = 0; - virtual void componentCompleted(const ComponentCompletedCommand &command) = 0; - virtual void token(const TokenCommand &command) = 0; - virtual void debugOutput(const DebugOutputCommand &command) = 0; - virtual void selectionChanged(const ChangeSelectionCommand &command) = 0; - virtual void handlePuppetToCreatorCommand(const PuppetToCreatorCommand &command) = 0; - virtual void capturedData(const CapturedDataCommand &command) = 0; - virtual void sceneCreated(const SceneCreatedCommand &command) = 0; - - virtual void flush() {} - virtual void synchronizeWithClientProcess() {} - virtual qint64 bytesToWrite() const {return 0;} -}; - -} diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceglobal.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceglobal.h deleted file mode 100644 index 968a9bef0f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceglobal.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QByteArray> -#include <QList> - -#include <vector> - -namespace QmlDesigner { - -using PropertyName = QByteArray; -using PropertyNameList = QList<PropertyName>; -using PropertyNames = std::vector<PropertyName>; -using TypeName = QByteArray; - -enum class AuxiliaryDataType { - None, - Temporary, - Document, - NodeInstancePropertyOverwrite, - NodeInstanceAuxiliary -}; - -enum class View3DActionType { - Empty, - MoveTool, - ScaleTool, - RotateTool, - FitToView, - AlignCamerasToView, - AlignViewToCamera, - SelectionModeToggle, - CameraToggle, - OrientationToggle, - EditLightToggle, - ShowGrid, - ShowSelectionBox, - ShowIconGizmo, - ShowCameraFrustum, - ShowParticleEmitter, - Edit3DParticleModeToggle, - ParticlesPlay, - ParticlesRestart, - ParticlesSeek, - SelectBackgroundColor, - SelectGridColor, - ResetBackgroundColor, - SyncBackgroundColor, - GetNodeAtPos -}; - -constexpr bool isNanotraceEnabled() -{ -#ifdef NANOTRACE_ENABLED - return true; -#else - return false; -#endif -} -} diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp deleted file mode 100644 index 110db56527..0000000000 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.cpp +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "nodeinstanceserverinterface.h" -#include <qmetatype.h> - -#include "addimportcontainer.h" -#include "captureddatacommand.h" -#include "changeauxiliarycommand.h" -#include "changebindingscommand.h" -#include "changefileurlcommand.h" -#include "changeidscommand.h" -#include "changelanguagecommand.h" -#include "changenodesourcecommand.h" -#include "changepreviewimagesizecommand.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 "endpuppetcommand.h" -#include "imagecontainer.h" -#include "informationchangedcommand.h" -#include "inputeventcommand.h" -#include "instancecontainer.h" -#include "nanotracecommand.h" -#include "pixmapchangedcommand.h" -#include "propertyabstractcontainer.h" -#include "propertybindingcontainer.h" -#include "propertyvaluecontainer.h" -#include "puppetalivecommand.h" -#include "puppettocreatorcommand.h" -#include "removeinstancescommand.h" -#include "removepropertiescommand.h" -#include "removesharedmemorycommand.h" -#include "reparentinstancescommand.h" -#include "scenecreatedcommand.h" -#include "statepreviewimagechangedcommand.h" -#include "synchronizecommand.h" -#include "tokencommand.h" -#include "update3dviewstatecommand.h" -#include "valueschangedcommand.h" -#include "view3dactioncommand.h" -#include "requestmodelnodepreviewimagecommand.h" - -#include <enumeration.h> - -namespace QmlDesigner { - -static bool isRegistered = false; - -NodeInstanceServerInterface::NodeInstanceServerInterface(QObject *parent) : - QObject(parent) -{ - registerCommands(); -} - -template<typename T> -inline void registerCommand(const char *typeName) -{ - qRegisterMetaType<T>(typeName); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - qRegisterMetaTypeStreamOperators<T>(typeName); -#endif -} - -void NodeInstanceServerInterface::registerCommands() -{ - if (isRegistered) - return; - - isRegistered = true; - - registerCommand<CreateInstancesCommand>("CreateInstancesCommand"); - registerCommand<ClearSceneCommand>("ClearSceneCommand"); - registerCommand<CreateSceneCommand>("CreateSceneCommand"); - registerCommand<Update3dViewStateCommand>("Update3dViewStateCommand"); - registerCommand<ChangeBindingsCommand>("ChangeBindingsCommand"); - registerCommand<ChangeValuesCommand>("ChangeValuesCommand"); - registerCommand<ChangeFileUrlCommand>("ChangeFileUrlCommand"); - registerCommand<ChangeStateCommand>("ChangeStateCommand"); - registerCommand<RemoveInstancesCommand>("RemoveInstancesCommand"); - registerCommand<ChangeSelectionCommand>("ChangeSelectionCommand"); - registerCommand<RemovePropertiesCommand>("RemovePropertiesCommand"); - registerCommand<ReparentInstancesCommand>("ReparentInstancesCommand"); - registerCommand<ChangeIdsCommand>("ChangeIdsCommand"); - registerCommand<PropertyAbstractContainer>("PropertyAbstractContainer"); - registerCommand<InformationChangedCommand>("InformationChangedCommand"); - registerCommand<ValuesChangedCommand>("ValuesChangedCommand"); - registerCommand<ValuesModifiedCommand>("ValuesModifiedCommand"); - registerCommand<PixmapChangedCommand>("PixmapChangedCommand"); - registerCommand<InformationContainer>("InformationContainer"); - registerCommand<PropertyValueContainer>("PropertyValueContainer"); - registerCommand<PropertyBindingContainer>("PropertyBindingContainer"); - registerCommand<PropertyAbstractContainer>("PropertyAbstractContainer"); - registerCommand<InstanceContainer>("InstanceContainer"); - registerCommand<IdContainer>("IdContainer"); - registerCommand<ChildrenChangedCommand>("ChildrenChangedCommand"); - registerCommand<ImageContainer>("ImageContainer"); - registerCommand<StatePreviewImageChangedCommand>("StatePreviewImageChangedCommand"); - registerCommand<CompleteComponentCommand>("CompleteComponentCommand"); - registerCommand<ComponentCompletedCommand>("ComponentCompletedCommand"); - registerCommand<AddImportContainer>("AddImportContainer"); - registerCommand<SynchronizeCommand>("SynchronizeCommand"); - registerCommand<ChangeNodeSourceCommand>("ChangeNodeSourceCommand"); - registerCommand<ChangeAuxiliaryCommand>("ChangeAuxiliaryCommand"); - registerCommand<TokenCommand>("TokenCommand"); - registerCommand<RemoveSharedMemoryCommand>("RemoveSharedMemoryCommand"); - registerCommand<EndPuppetCommand>("EndPuppetCommand"); - registerCommand<DebugOutputCommand>("DebugOutputCommand"); - registerCommand<Enumeration>("Enumeration"); - registerCommand<PuppetAliveCommand>("PuppetAliveCommand"); - registerCommand<PuppetToCreatorCommand>("PuppetToCreatorCommand"); - registerCommand<InputEventCommand>("InputEventCommand"); - registerCommand<View3DActionCommand>("View3DActionCommand"); - registerCommand<RequestModelNodePreviewImageCommand>("RequestModelNodePreviewImageCommand"); - registerCommand<QPair<int, int>>("QPairIntInt"); - registerCommand<QList<QColor>>("QColorList"); - registerCommand<ChangeLanguageCommand>("ChangeLanguageCommand"); - registerCommand<ChangePreviewImageSizeCommand>("ChangePreviewImageSizeCommand"); - registerCommand<CapturedDataCommand>("CapturedDataCommand"); - registerCommand<SceneCreatedCommand>("SceneCreatedCommand"); - registerCommand<StartNanotraceCommand>("StartNanotraceCommand"); - registerCommand<EndNanotraceCommand>("EndNanotraceCommand"); - registerCommand<SyncNanotraceCommand>("SyncNanotraceCommand"); -} - -} diff --git a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h b/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h deleted file mode 100644 index 94e35176fd..0000000000 --- a/share/qtcreator/qml/qmlpuppet/interfaces/nodeinstanceserverinterface.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QObject> - -namespace QmlDesigner { - -class PropertyAbstractContainer; -class PropertyBindingContainer; -class PropertyValueContainer; - -class Update3dViewStateCommand; -class ChangeFileUrlCommand; -class ChangeValuesCommand; -class ChangeBindingsCommand; -class ChangeAuxiliaryCommand; -class CreateSceneCommand; -class CreateInstancesCommand; -class ClearSceneCommand; -class ReparentInstancesCommand; -class ChangeIdsCommand; -class RemoveInstancesCommand; -class RemovePropertiesCommand; -class ChangeStateCommand; -class CompleteComponentCommand; -class ChangeNodeSourceCommand; -class TokenCommand; -class RemoveSharedMemoryCommand; -class ChangeSelectionCommand; -class InputEventCommand; -class View3DActionCommand; -class RequestModelNodePreviewImageCommand; -class ChangeLanguageCommand; -class ChangePreviewImageSizeCommand; - -class NodeInstanceServerInterface : public QObject -{ - Q_OBJECT -public: - explicit NodeInstanceServerInterface(QObject *parent = nullptr); - - virtual void createInstances(const CreateInstancesCommand &command) = 0; - virtual void changeFileUrl(const ChangeFileUrlCommand &command) = 0; - virtual void createScene(const CreateSceneCommand &command) = 0; - virtual void clearScene(const ClearSceneCommand &command) = 0; - virtual void update3DViewState(const Update3dViewStateCommand &command) = 0; - virtual void removeInstances(const RemoveInstancesCommand &command) = 0; - virtual void removeProperties(const RemovePropertiesCommand &command) = 0; - virtual void changePropertyBindings(const ChangeBindingsCommand &command) = 0; - virtual void changePropertyValues(const ChangeValuesCommand &command) = 0; - virtual void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) = 0; - virtual void reparentInstances(const ReparentInstancesCommand &command) = 0; - virtual void changeIds(const ChangeIdsCommand &command) = 0; - virtual void changeState(const ChangeStateCommand &command) = 0; - virtual void completeComponent(const CompleteComponentCommand &command) = 0; - virtual void changeNodeSource(const ChangeNodeSourceCommand &command) = 0; - virtual void token(const TokenCommand &command) = 0; - virtual void removeSharedMemory(const RemoveSharedMemoryCommand &command) = 0; - virtual void changeSelection(const ChangeSelectionCommand &command) = 0; - virtual void inputEvent(const InputEventCommand &command) = 0; - virtual void view3DAction(const View3DActionCommand &command) = 0; - virtual void requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command) = 0; - virtual void changeLanguage(const ChangeLanguageCommand &command) = 0; - virtual void changePreviewImageSize(const ChangePreviewImageSizeCommand &command) = 0; - virtual void dispatchCommand(const QVariant &) {} - - virtual void benchmark(const QString &) {} - - static void registerCommands(); -}; - -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/Dialog.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/Dialog.qml deleted file mode 100644 index e6a3ced517..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/Dialog.qml +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.1 - -Rectangle { - property string title - - property var clickedButton - - property var modality - property var standardButtons - - property alias contentItem: contentArea - - property int maximumWidth: 0 - property int minimumWidth: 0 - - property int maximumHeight: 0 - property int minimumHeight: 0 - - Item { - id: contentArea - anchors.top: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: parent.top - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/GenericBackend.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/GenericBackend.qml deleted file mode 100644 index 30083c228f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/GenericBackend.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.6 - -QtObject { - property int x - property int y - property int width - property int height -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/SwipeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/SwipeView.qml deleted file mode 100644 index 751cdf2683..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/SwipeView.qml +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.6 -import QtQuick.Layouts 1.3 - -StackLayout { - id: root - //property alias index: root.currentIndex - property bool interactive: true - default property alias contentData: root.data -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ToggleButton.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ToggleButton.qml deleted file mode 100644 index 3c042b0e98..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/ToggleButton.qml +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.12 -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -Rectangle { - property bool toggled: false - property string tooltip - property bool toggleBackground: false // show a black background for the toggled state - property var states: [] // array of 2 state-objects, idx 0: untoggled, idx 1: toggled - - id: root - color: toggleBackground && toggled ? "#aa000000" : mouseArea.containsMouse ? "#44000000" : "#00000000" - width: txt.width + 5 - height: 16 - - Text { - id: txt - color: "#b5b5b5" - anchors.verticalCenter: parent.verticalCenter - text: root.states[toggled ? 1 : 0].text - } - - ToolTip { - text: tooltip - visible: mouseArea.containsMouse - delay: 1000 - } - - MouseArea { - id: mouseArea - cursorShape: "PointingHandCursor" - hoverEnabled: true - anchors.fill: parent - onClicked: root.toggled = !root.toggled - } -} - - diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml deleted file mode 100644 index c149c10b47..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/ToolBarButton.qml +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.12 -import QtQuick 2.0 -import QtQuick.Controls 2.0 - -Rectangle { - property bool selected: false - property string tooltip - property string shortcut - property string currentShortcut - property string tool - property string buttonGroup - property bool togglable: true - property string sceneId - - property int _buttonGroupIndex: -1 - property var _buttonGroupArray: [] - - id: root - width: 16 - height: 16 - color: root.selected ? "#aa000000" : (mouseArea.containsMouse ? "#44000000" : "#00000000") - radius: 3 - - Component.onCompleted: { - var group = parent.buttonGroups[buttonGroup]; - if (group) { - _buttonGroupArray = group; - for (var i = 0; i < _buttonGroupArray.length; ++i) { - if (_buttonGroupArray[i] === this) { - _buttonGroupIndex = i; - break; - } - } - } - } - - ToolTip { - text: root.tooltip + " (" + root.shortcut + ")" - visible: mouseArea.containsMouse - delay: 1000 - } - - Shortcut { - sequence: root.currentShortcut - onActivated: mouseArea.onClicked(null) - } - - MouseArea { - id: mouseArea - cursorShape: "PointingHandCursor" - anchors.fill: parent - hoverEnabled: true - - onClicked: { - if (!root.selected) { - for (var i = 0; i < root._buttonGroupArray.length; ++i) - root._buttonGroupArray[i].selected = false; - - root.selected = true; - if (_buttonGroupIndex >= 0) - _generalHelper.storeToolState(sceneId, root.buttonGroup, root._buttonGroupIndex) - - if (!root.togglable) { - // Deselect button after a short while (selection acts as simple click indicator) - _generalHelper.delayedPropertySet(root, 200, "selected", false); - } - } - } - } -} - - diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/Window.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/Window.qml deleted file mode 100644 index 7dd8610499..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/Window.qml +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.1 - -Rectangle { - property string title - - property Item toolBar - property Item statusBar - - property alias contentItem : contentArea - default property alias data: contentArea.data - - onStatusBarChanged: { if (statusBar) { statusBar.parent = statusBarArea } } - onToolBarChanged: { if (toolBar) { toolBar.parent = toolBarArea } } - - property int maximumWidth: 0 - property int minimumWidth: 0 - - property int maximumHeight: 0 - property int minimumHeight: 0 - - Item { - id: contentArea - anchors.top: toolBarArea.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.bottom: statusBarArea.top - } - - Item { - id: toolBarArea - anchors.top: parent.top - anchors.left: parent.left - anchors.right: parent.right - implicitHeight: childrenRect.height - height: visibleChildren.length > 0 ? implicitHeight: 0 - } - - Item { - id: statusBarArea - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - implicitHeight: childrenRect.height - height: 0 - //The status bar is not visible for now - //height: visibleChildren.length > 0 ? implicitHeight: 0 - } - -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/area.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/area.png Binary files differdeleted file mode 100644 index ed261ff2d5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/area.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/area@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/area@2x.png Binary files differdeleted file mode 100644 index 1f6e37d7e9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/area@2x.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/directional.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/directional.png Binary files differdeleted file mode 100644 index 289597156c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/directional.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/directional@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/directional@2x.png Binary files differdeleted file mode 100644 index 7c3fa8557d..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/directional@2x.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_camera.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_camera.png Binary files differdeleted file mode 100644 index 4b2bf93d41..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_camera.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_camera@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_camera@2x.png Binary files differdeleted file mode 100644 index 1c690433c2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_camera@2x.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_particlesystem.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_particlesystem.png Binary files differdeleted file mode 100644 index 55d35bc584..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_particlesystem.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_particlesystem@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_particlesystem@2x.png Binary files differdeleted file mode 100644 index e66db81479..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/editor_particlesystem@2x.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/floor_tex.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/floor_tex.png Binary files differdeleted file mode 100644 index d8550f8044..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/floor_tex.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/point.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/point.png Binary files differdeleted file mode 100644 index ba62ebdfb8..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/point.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/point@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/point@2x.png Binary files differdeleted file mode 100644 index 3e53bab0bd..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/point@2x.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/preview_landscape.hdr b/share/qtcreator/qml/qmlpuppet/mockfiles/images/preview_landscape.hdr Binary files differdeleted file mode 100644 index 2c6b4372d4..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/preview_landscape.hdr +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/preview_studio.hdr b/share/qtcreator/qml/qmlpuppet/mockfiles/images/preview_studio.hdr Binary files differdeleted file mode 100644 index 8ab060c1f4..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/preview_studio.hdr +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/spot.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/spot.png Binary files differdeleted file mode 100644 index e2f7371b85..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/spot.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/spot@2x.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/spot@2x.png Binary files differdeleted file mode 100644 index c8a7dba200..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/spot@2x.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/images/static_floor.png b/share/qtcreator/qml/qmlpuppet/mockfiles/images/static_floor.png Binary files differdeleted file mode 100644 index 93073719f5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/images/static_floor.png +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/arrow.mesh b/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/arrow.mesh Binary files differdeleted file mode 100644 index be5f4df3b8..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/arrow.mesh +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/axishelper.mesh b/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/axishelper.mesh Binary files differdeleted file mode 100644 index 3e9e4958e4..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/axishelper.mesh +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/ring.mesh b/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/ring.mesh Binary files differdeleted file mode 100644 index 56e1b82f29..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/ring.mesh +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/ringselect.mesh b/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/ringselect.mesh Binary files differdeleted file mode 100644 index b110b308f0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/ringselect.mesh +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/scalerod.mesh b/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/scalerod.mesh Binary files differdeleted file mode 100644 index b3c1bd883f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/meshes/scalerod.mesh +++ /dev/null diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AdjustableArrow.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AdjustableArrow.qml deleted file mode 100644 index 2b0da44784..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AdjustableArrow.qml +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import LineGeometry 1.0 - -DirectionalDraggable { - id: arrowRoot - - Model { - geometry: LineGeometry { - id: lineGeometry - name: "Edit 3D ScalableArrow" - startPos: Qt.vector3d(0, 0, 0) - endPos: Qt.vector3d(0, 1, 0) - } - scale: Qt.vector3d(1, arrowRoot.length, 1) - materials: [ arrowRoot.material ] - } - - Model { - id: arrowHead - source: "#Cone" - materials: [ arrowRoot.material ] - y: arrowRoot.length - 3 - scale: Qt.vector3d(0.02, 0.035, 0.02) - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AreaLightHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AreaLightHandle.qml deleted file mode 100644 index b3b0dbbc8c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AreaLightHandle.qml +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -DirectionalDraggable { - id: handleRoot - - property string currentLabel - property point currentMousePos - property string propName - property real propValue: 0 - property real newValue: 0 - property real baseScale: 5 - - scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale)) - length: 3 - offset: -1.5 - - Model { - id: handle - source: "#Sphere" - materials: [ handleRoot.material ] - scale: Qt.vector3d(0.02, 0.02, 0.02) - } - - AutoScaleHelper { - id: autoScaler - active: handleRoot.active - view3D: handleRoot.view3D - } - - property real _startValue - property real _startScale - - signal valueCommit() - signal valueChange() - - function updateValue(relativeDistance, screenPos) - { - handleRoot.newValue = Math.round(Math.min(999999, Math.max(0, _startValue + (relativeDistance * _startScale)))); - var l = Qt.locale(); - handleRoot.currentLabel = propName + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 0); - handleRoot.currentMousePos = screenPos; - } - - onPressed: (mouseArea, screenPos)=> { - _startScale = autoScaler.relativeScale * baseScale; - _startValue = propValue; - updateValue(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateValue(relativeDistance, screenPos); - handleRoot.valueChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateValue(relativeDistance, screenPos); - handleRoot.valueCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Arrow.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Arrow.qml deleted file mode 100644 index 98d3abe112..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Arrow.qml +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -DirectionalDraggable { - id: arrow - source: "../meshes/arrow.mesh" - - signal positionCommit() - signal positionMove() - - function localPos(sceneRelativeDistance) - { - var newScenePos = Qt.vector3d( - _targetStartPos.x + sceneRelativeDistance.x, - _targetStartPos.y + sceneRelativeDistance.y, - _targetStartPos.z + sceneRelativeDistance.z); - return targetNode.parent ? targetNode.parent.mapPositionFromScene(newScenePos) : newScenePos; - } - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - } - - onDragged: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(false); - positionMove(); - } - - onReleased: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(true); - positionCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AutoScaleHelper.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AutoScaleHelper.qml deleted file mode 100644 index 9f33abaddd..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AutoScaleHelper.qml +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Node { - id: overlayNode - - property View3D view3D - property Camera camera: view3D.camera - property bool active: true - - // Read-only - property real relativeScale: 1 - - onActiveChanged: updateScale() - onSceneTransformChanged: updateScale() - // Trigger delayed update on camera change to ensure camera values are correct - onCameraChanged: _generalHelper.requestOverlayUpdate(); - - Connections { - target: camera - function onSceneTransformChanged() { updateScale() } - } - - Connections { - target: _generalHelper - function onOverlayUpdateNeeded() { updateScale() } - } - - function getScale(baseScale) - { - return Qt.vector3d(baseScale.x * relativeScale, baseScale.y * relativeScale, - baseScale.z * relativeScale); - } - - function updateScale() - { - if (active) - relativeScale = helper.getRelativeScale(overlayNode); - else - relativeScale = 1; - } - - MouseArea3D { - id: helper - active: false - view3D: overlayNode.view3D - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AxisHelper.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AxisHelper.qml deleted file mode 100644 index de45ff39f5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AxisHelper.qml +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -View3D { - id: axisHelperView - - property var editCameraCtrl - property Node selectedNode - - camera: axisHelperCamera - - Node { - OrthographicCamera { - id: axisHelperCamera - rotation: editCameraCtrl.camera ? editCameraCtrl.camera.rotation : Qt.quaternion(1, 0, 0, 0) - position: editCameraCtrl.camera ? editCameraCtrl.camera.position.minus(editCameraCtrl._lookAtPoint) - .normalized().times(600) : Qt.vector3d(0, 0, 0) - } - - AutoScaleHelper { - id: autoScale - view3D: axisHelperView - position: axisHelperGizmo.scenePosition - } - - Node { - id: axisHelperGizmo - scale: autoScale.getScale(Qt.vector3d(4, 4, 4)) - - AxisHelperArm { - id: armX - eulerRotation: Qt.vector3d(0, 0, -90) - color: Qt.rgba(1, 0, 0, 1) - hoverColor: Qt.lighter(Qt.rgba(1, 0, 0, 1)) - view3D: axisHelperView - camRotPos: Qt.vector3d(0, 90, 0) - camRotNeg: Qt.vector3d(0, -90, 0) - } - - AxisHelperArm { - id: armY - eulerRotation: Qt.vector3d(0, 0, 0) - color: Qt.rgba(0, 0.6, 0, 1) - hoverColor: Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - view3D: axisHelperView - camRotPos: Qt.vector3d(-90, 0, 0) - camRotNeg: Qt.vector3d(90, 0, 0) - } - - AxisHelperArm { - id: armZ - eulerRotation: Qt.vector3d(90, 0, 0) - color: Qt.rgba(0, 0, 1, 1) - hoverColor: Qt.lighter(Qt.rgba(0, 0, 1, 1)) - view3D: axisHelperView - camRotPos: Qt.vector3d(0, 0, 0) - camRotNeg: Qt.vector3d(0, 180, 0) - } - } - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - acceptedButtons: Qt.LeftButton - - property var pickObj: null - - function cancelHover() - { - if (pickObj) { - pickObj.hovering = false; - pickObj = null; - } - } - - function pick(mouse) - { - var result = axisHelperView.pick(mouse.x, mouse.y); - if (result.objectHit) { - if (result.objectHit !== pickObj) { - cancelHover(); - pickObj = result.objectHit; - pickObj.hovering = true; - } - } else { - cancelHover(); - } - } - - onPositionChanged: (mouse)=> { - pick(mouse); - } - - onPressed: (mouse)=> { - pick(mouse); - if (pickObj) { - axisHelperView.editCameraCtrl.focusObject(axisHelperView.selectedNode, - pickObj.cameraRotation, false, false); - } else { - mouse.accepted = false; - } - } - - onExited: cancelHover() - onCanceled: cancelHover() - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AxisHelperArm.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AxisHelperArm.qml deleted file mode 100644 index 9385c9e736..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/AxisHelperArm.qml +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -Node { - id: armRoot - property alias posModel: posModel - property alias negModel: negModel - property View3D view3D - property color hoverColor - property color color - property vector3d camRotPos - property vector3d camRotNeg - - Model { - id: posModel - - property bool hovering: false - property vector3d cameraRotation: armRoot.camRotPos - - source: "../meshes/axishelper.mesh" - materials: DefaultMaterial { - id: posMat - diffuseColor: posModel.hovering ? armRoot.hoverColor : armRoot.color - lighting: DefaultMaterial.NoLighting - } - pickable: true - } - - Model { - id: negModel - - property bool hovering: false - property vector3d cameraRotation: armRoot.camRotNeg - - source: "#Sphere" - y: -6 - scale: Qt.vector3d(0.025, 0.025, 0.025) - materials: DefaultMaterial { - id: negMat - diffuseColor: negModel.hovering ? armRoot.hoverColor : armRoot.color - lighting: DefaultMaterial.NoLighting - } - pickable: true - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/CameraFrustum.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/CameraFrustum.qml deleted file mode 100644 index ad581417cb..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/CameraFrustum.qml +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import CameraGeometry 1.0 - -Model { - id: cameraFrustum - - property alias geometryName: cameraGeometry.name // Name must be unique for each geometry - property alias viewPortRect: cameraGeometry.viewPortRect - property Node targetNode: null - property Node scene: null - property bool selected: false - - function updateGeometry() - { - cameraGeometry.update(); - } - - position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0) - rotation: targetNode ? targetNode.sceneRotation : Qt.quaternion(1, 0, 0, 0) - - geometry: cameraGeometry - materials: [ - DefaultMaterial { - id: defaultMaterial - diffuseColor: cameraFrustum.selected ? "#FF0000" : "#555555" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - - CameraGeometry { - id: cameraGeometry - camera: cameraFrustum.scene && cameraFrustum.targetNode ? cameraFrustum.targetNode : null - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/CameraGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/CameraGizmo.qml deleted file mode 100644 index b1cdbcd89a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/CameraGizmo.qml +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -IconGizmo { - id: cameraGizmo - - property Model frustumModel: null - property bool globalShowFrustum: false - - iconSource: "qrc:///qtquickplugin/mockfiles/images/editor_camera.png" - - function connectFrustum(frustum) - { - frustumModel = frustum; - - frustum.selected = selected; - frustum.selected = Qt.binding(function() {return selected;}); - - frustum.scene = scene; - frustum.scene = Qt.binding(function() {return scene;}); - - frustum.targetNode = targetNode; - frustum.targetNode = Qt.binding(function() {return targetNode;}); - - frustum.visible = (canBeVisible && globalShowFrustum) - || (targetNode && selected && activeScene === scene); - frustum.visible = Qt.binding(function() { - return (canBeVisible && globalShowFrustum) - || (targetNode && selected && activeScene === scene); - }); - } - - onActiveSceneChanged: { - if (frustumModel && activeScene == scene) - frustumModel.updateGeometry(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/DirectionalDraggable.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/DirectionalDraggable.qml deleted file mode 100644 index a9f3b8ae55..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/DirectionalDraggable.qml +++ /dev/null @@ -1,122 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Model { - id: rootModel - - property View3D view3D - property alias color: material.diffuseColor - property Node targetNode: null - property bool dragging: mouseAreaYZ.dragging || mouseAreaXZ.dragging - property bool active: false - property MouseArea3D dragHelper: null - property alias material: material - property real length: 12 - property real offset: 0 - - readonly property bool hovering: mouseAreaYZ.hovering || mouseAreaXZ.hovering - - property vector3d _scenePosPressed - property real _posPressed - property vector3d _targetStartPos - - signal pressed(var mouseArea, point screenPos) - signal dragged(var mouseArea, vector3d sceneRelativeDistance, real relativeDistance, point screenPos) - signal released(var mouseArea, vector3d sceneRelativeDistance, real relativeDistance, point screenPos) - - DefaultMaterial { - id: material - diffuseColor: "white" - lighting: DefaultMaterial.NoLighting - } - - materials: [ material ] - - function handlePressed(mouseArea, planePos, screenPos) - { - if (!targetNode) - return; - - var maskedPosition = Qt.vector3d(planePos.x, 0, 0); - _posPressed = planePos.x; - _scenePosPressed = mouseArea.dragHelper.mapPositionToScene(maskedPosition); - _targetStartPos = mouseArea.pivotScenePosition(targetNode); - pressed(mouseArea, screenPos); - } - - function calcRelativeDistance(mouseArea, planePos) - { - var maskedPosition = Qt.vector3d(planePos.x, 0, 0); - var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(maskedPosition); - return scenePointerPos.minus(_scenePosPressed); - } - - function handleDragged(mouseArea, planePos, screenPos) - { - if (!targetNode) - return; - - dragged(mouseArea, calcRelativeDistance(mouseArea, planePos), planePos.x - _posPressed, screenPos); - } - - function handleReleased(mouseArea, planePos, screenPos) - { - if (!targetNode) - return; - - released(mouseArea, calcRelativeDistance(mouseArea, planePos), planePos.x - _posPressed, screenPos); - } - - MouseArea3D { - id: mouseAreaYZ - view3D: rootModel.view3D - x: rootModel.offset - y: -1.5 - width: rootModel.length - height: 3 - eulerRotation: Qt.vector3d(0, 0, 90) - grabsMouse: targetNode - active: rootModel.active - dragHelper: rootModel.dragHelper - priority: 5 - - onPressed: (planePos, screenPos)=> { - rootModel.handlePressed(mouseAreaYZ, planePos, screenPos); - } - onDragged: (planePos, screenPos)=> { - rootModel.handleDragged(mouseAreaYZ, planePos, screenPos); - } - onReleased: (planePos, screenPos)=> { - rootModel.handleReleased(mouseAreaYZ, planePos, screenPos); - } - } - - MouseArea3D { - id: mouseAreaXZ - view3D: rootModel.view3D - x: rootModel.offset - y: -1.5 - width: rootModel.length - height: 3 - eulerRotation: Qt.vector3d(0, 90, 90) - grabsMouse: targetNode - active: rootModel.active - dragHelper: rootModel.dragHelper - priority: 5 - - onPressed: (planePos, screenPos)=> { - rootModel.handlePressed(mouseAreaXZ, planePos, screenPos); - } - onDragged: (planePos, screenPos)=> { - rootModel.handleDragged(mouseAreaXZ, planePos, screenPos); - } - onReleased: (planePos, screenPos)=> { - rootModel.handleReleased(mouseAreaXZ, planePos, screenPos); - } - } -} - diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditCameraController.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditCameraController.qml deleted file mode 100644 index 5a5796b96b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditCameraController.qml +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.12 -import QtQuick3D 1.15 - -Item { - id: cameraCtrl - - property Camera camera: null - property View3D view3d: null - property string sceneId - property vector3d _lookAtPoint - property vector3d _pressPoint - property vector3d _prevPoint - property vector3d _startRotation - property vector3d _startPosition - property vector3d _startLookAtPoint - property matrix4x4 _startTransform - property bool _dragging - property int _button - property real _zoomFactor: 1 - property Camera _prevCamera: null - readonly property vector3d _defaultCameraPosition: Qt.vector3d(0, 600, 600) - readonly property vector3d _defaultCameraRotation: Qt.vector3d(-45, 0, 0) - readonly property real _defaultCameraLookAtDistance: _defaultCameraPosition.length() - readonly property real _keyPanAmount: 5 - property bool ignoreToolState: false - - function restoreCameraState(cameraState) - { - if (!camera || ignoreToolState) - return; - - _lookAtPoint = cameraState[0]; - _zoomFactor = cameraState[1]; - camera.position = cameraState[2]; - camera.rotation = cameraState[3]; - _generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - _zoomFactor, false); - } - - function restoreDefaultState() - { - if (!camera) - return; - - _lookAtPoint = Qt.vector3d(0, 0, 0); - _zoomFactor = 1; - camera.position = _defaultCameraPosition; - camera.eulerRotation = _defaultCameraRotation; - _generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - _zoomFactor, false); - } - - function storeCameraState(delay) - { - if (!camera || ignoreToolState) - return; - - var cameraState = []; - cameraState[0] = _lookAtPoint; - cameraState[1] = _zoomFactor; - cameraState[2] = camera.position; - cameraState[3] = camera.rotation; - _generalHelper.storeToolState(sceneId, "editCamState", cameraState, delay); - } - - - function focusObject(targetNodes, rotation, updateZoom, closeUp) - { - if (!camera) - return; - - // targetNodes could be a list of nodes or a single node - var nodes = []; - if (targetNodes instanceof Node) - nodes.push(targetNodes); - else - nodes = targetNodes - - camera.eulerRotation = rotation; - var newLookAtAndZoom = _generalHelper.focusNodesToCamera( - camera, _defaultCameraLookAtDistance, nodes, view3d, _zoomFactor, - updateZoom, closeUp); - _lookAtPoint = newLookAtAndZoom.toVector3d(); - _zoomFactor = newLookAtAndZoom.w; - storeCameraState(0); - } - - function alignCameras(targetNodes) - { - if (!camera) - return; - - // targetNodes could be a list of nodes or a single node - var nodes = []; - if (targetNodes instanceof Node) - nodes.push(targetNodes); - else - nodes = targetNodes - - _generalHelper.alignCameras(camera, nodes); - } - - function alignView(targetNodes) - { - if (!camera) - return; - - // targetNodes could be a list of nodes or a single node - var nodes = []; - if (targetNodes instanceof Node) - nodes.push(targetNodes); - else - nodes = targetNodes - - _lookAtPoint = _generalHelper.alignView(camera, nodes, _lookAtPoint); - storeCameraState(0); - } - - function zoomRelative(distance) - { - if (!camera) - return; - - _zoomFactor = _generalHelper.zoomCamera(view3d, camera, distance, _defaultCameraLookAtDistance, - _lookAtPoint, _zoomFactor, true); - } - - onCameraChanged: { - if (camera && _prevCamera) { - // Reset zoom on previous camera to ensure it's properties are good to copy to new cam - _generalHelper.zoomCamera(view3d, _prevCamera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - 1, false); - - camera.position = _prevCamera.position; - camera.rotation = _prevCamera.rotation; - - // Apply correct zoom to new camera - _generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - _zoomFactor, false); - } - _prevCamera = camera; - } - - MouseArea { - id: mouseHandler - acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton - hoverEnabled: false - anchors.fill: parent - onPositionChanged: (mouse)=> { - if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier && cameraCtrl._dragging) { - var currentPoint = Qt.vector3d(mouse.x, mouse.y, 0); - if (cameraCtrl._button == Qt.LeftButton) { - _generalHelper.orbitCamera(cameraCtrl.camera, cameraCtrl._startRotation, - cameraCtrl._lookAtPoint, cameraCtrl._pressPoint, - currentPoint); - } else if (cameraCtrl._button == Qt.MiddleButton) { - cameraCtrl._lookAtPoint = _generalHelper.panCamera( - cameraCtrl.camera, cameraCtrl._startTransform, - cameraCtrl._startPosition, cameraCtrl._startLookAtPoint, - cameraCtrl._pressPoint, currentPoint, _zoomFactor); - } else if (cameraCtrl._button == Qt.RightButton) { - cameraCtrl.zoomRelative(currentPoint.y - cameraCtrl._prevPoint.y) - cameraCtrl._prevPoint = currentPoint; - } - } - } - onPressed: (mouse)=> { - if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier) { - cameraCtrl._dragging = true; - cameraCtrl._startRotation = cameraCtrl.camera.eulerRotation; - cameraCtrl._startPosition = cameraCtrl.camera.position; - cameraCtrl._startLookAtPoint = _lookAtPoint; - cameraCtrl._pressPoint = Qt.vector3d(mouse.x, mouse.y, 0); - cameraCtrl._prevPoint = cameraCtrl._pressPoint; - cameraCtrl._button = mouse.button; - cameraCtrl._startTransform = cameraCtrl.camera.sceneTransform; - } else { - mouse.accepted = false; - } - } - - function handleRelease() { - cameraCtrl._dragging = false; - cameraCtrl.storeCameraState(0); - } - - onReleased: handleRelease() - onCanceled: handleRelease() - - onWheel: (wheel)=> { - if (cameraCtrl.camera) { - // Empirically determined divisor for nice zoom - cameraCtrl.zoomRelative(wheel.angleDelta.y / -40); - cameraCtrl.storeCameraState(500); - } - } - } - - Keys.onPressed: { - var pressPoint = Qt.vector3d(view3d.width / 2, view3d.height / 2, 0); - var currentPoint; - - switch (event.key) { - case Qt.Key_Left: - currentPoint = pressPoint.plus(Qt.vector3d(_keyPanAmount, 0, 0)); - break; - case Qt.Key_Right: - currentPoint = pressPoint.plus(Qt.vector3d(-_keyPanAmount, 0, 0)); - break; - case Qt.Key_Up: - currentPoint = pressPoint.plus(Qt.vector3d(0, _keyPanAmount, 0)); - break; - case Qt.Key_Down: - currentPoint = pressPoint.plus(Qt.vector3d(0, -_keyPanAmount, 0)); - break; - default: - break; - } - - if (currentPoint) { - _lookAtPoint = _generalHelper.panCamera( - camera, cameraCtrl.camera.sceneTransform, - cameraCtrl.camera.position, _lookAtPoint, - pressPoint, currentPoint, _zoomFactor); - event.accepted = true; - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml deleted file mode 100644 index 672aca03c6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/EditView3D.qml +++ /dev/null @@ -1,976 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.12 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Item { - id: viewRoot - width: 1024 - height: 768 - visible: true - - property Node activeScene: null - property View3D editView: null - property string sceneId - - property bool showEditLight: false - property bool showGrid: true - property bool showSelectionBox: true - property bool showIconGizmo: true - property bool showCameraFrustum: false - property bool usePerspective: true - property bool globalOrientation: false - property alias contentItem: contentItem - property color backgroundGradientColorStart: "#222222" - property color backgroundGradientColorEnd: "#999999" - property color gridColor: "#aaaaaa" - property bool syncBackgroundColor: false - - enum SelectionMode { Item, Group } - enum TransformMode { Move, Rotate, Scale } - - property int selectionMode: EditView3D.SelectionMode.Item - property int transformMode: EditView3D.TransformMode.Move - - property Node selectedNode: null // This is multiSelectionNode in multi-selection case - property var selectedNodes: [] // All selected nodes - - property var lightIconGizmos: [] - property var cameraGizmos: [] - property var selectionBoxes: [] - property rect viewPortRect: Qt.rect(0, 0, 1000, 1000) - - property bool shuttingDown: false - - property real fps: 0 - - signal selectionChanged(var selectedNodes) - signal commitObjectProperty(var objects, var propNames) - signal changeObjectProperty(var objects, var propNames) - signal notifyActiveSceneChange() - - onUsePerspectiveChanged: _generalHelper.storeToolState(sceneId, "usePerspective", usePerspective) - onShowEditLightChanged: _generalHelper.storeToolState(sceneId, "showEditLight", showEditLight) - onGlobalOrientationChanged: _generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation) - onShowGridChanged: _generalHelper.storeToolState(sceneId, "showGrid", showGrid); - onSyncBackgroundColorChanged: _generalHelper.storeToolState(sceneId, "syncBackgroundColor", syncBackgroundColor); - onShowSelectionBoxChanged: _generalHelper.storeToolState(sceneId, "showSelectionBox", showSelectionBox); - onShowIconGizmoChanged: _generalHelper.storeToolState(sceneId, "showIconGizmo", showIconGizmo); - onShowCameraFrustumChanged: _generalHelper.storeToolState(sceneId, "showCameraFrustum", showCameraFrustum); - onSelectionModeChanged: _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode); - onTransformModeChanged: _generalHelper.storeToolState(sceneId, "transformMode", transformMode); - - onActiveSceneChanged: updateActiveScene() - - function aboutToShutDown() - { - shuttingDown = true; - } - - function createEditView() - { - var component = Qt.createComponent("SceneView3D.qml"); - if (component.status === Component.Ready) { - editView = component.createObject(viewRect, - {"usePerspective": usePerspective, - "showSceneLight": showEditLight, - "showGrid": showGrid, - "gridColor": gridColor, - "importScene": activeScene, - "cameraZoomFactor": cameraControl._zoomFactor, - "z": 1}); - editView.usePerspective = Qt.binding(function() {return usePerspective;}); - editView.showSceneLight = Qt.binding(function() {return showEditLight;}); - editView.showGrid = Qt.binding(function() {return showGrid;}); - editView.gridColor = Qt.binding(function() {return gridColor;}); - editView.cameraZoomFactor = Qt.binding(function() {return cameraControl._zoomFactor;}); - - selectionBoxes.length = 0; - cameraControl.forceActiveFocus(); - return true; - } - return false; - } - - function updateActiveScene() - { - if (editView) { - // Destroy is async, so make sure we don't get any more updates for the old editView - _generalHelper.enableItemUpdate(editView, false); - editView.visible = false; - editView.destroy(); - } - - // importScene cannot be updated after initial set, so we need to reconstruct entire View3D - if (createEditView()) { - if (activeScene) { - var toolStates = _generalHelper.getToolStates(sceneId); - if (Object.keys(toolStates).length > 0) { - updateToolStates(toolStates, true); - } else { - // Don't inherit the edit light state from the previous scene, but rather - // turn the edit light on for scenes that do not have any scene - // lights, and turn it off for scenes that have. - var hasSceneLight = false; - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].scene === activeScene) { - hasSceneLight = true; - break; - } - } - showEditLight = !hasSceneLight; - storeCurrentToolStates(); - } - } else { - // When active scene is deleted, this function gets called by object deletion - // handlers without going through setActiveScene, so make sure sceneId is cleared. - // This is skipped during application shutdown, as calling QQuickText::setText() - // during application shutdown can crash the application. - if (!shuttingDown) { - sceneId = ""; - storeCurrentToolStates(); - } - } - - notifyActiveSceneChange(); - } - } - - function setActiveScene(newScene, newSceneId) - { - var needExplicitUpdate = !activeScene && !newScene; - - sceneId = newSceneId; - activeScene = newScene; - - if (needExplicitUpdate) - updateActiveScene(); - } - - // Disables edit view update if scene doesn't match current activeScene. - // If it matches, updates are enabled. - function enableEditViewUpdate(scene) - { - if (editView) - _generalHelper.enableItemUpdate(editView, (scene && scene === activeScene)); - } - - function handleActiveSceneIdChange(newId) - { - if (sceneId !== newId) { - sceneId = newId; - storeCurrentToolStates(); - } - } - - function fitToView() - { - if (editView) { - var boxModels = []; - if (selectedNodes.length > 1) { - for (var i = 0; i < selectedNodes.length; ++i) { - if (selectionBoxes.length > i) - boxModels.push(selectionBoxes[i].model) - } - } else if (selectedNodes.length > 0 && selectionBoxes.length > 0) { - boxModels.push(selectionBoxes[0].model); - } - cameraControl.focusObject(boxModels, editView.camera.eulerRotation, true, false); - } - } - - function alignCamerasToView() - { - if (editView) { - cameraControl.alignCameras(selectedNodes); - var propertyNames = ["position", "eulerRotation"]; - viewRoot.changeObjectProperty(selectedNodes, propertyNames); - viewRoot.commitObjectProperty(selectedNodes, propertyNames); - } - } - - function alignViewToCamera() - { - if (editView) - cameraControl.alignView(selectedNodes); - } - - function updateViewStates(viewStates) - { - if ("selectBackgroundColor" in viewStates) { - if (Array.isArray(viewStates.selectBackgroundColor)) { - var colors = viewStates.selectBackgroundColor - backgroundGradientColorStart = colors[0]; - backgroundGradientColorEnd = colors[1]; - } else { - var color = viewStates.selectBackgroundColor - backgroundGradientColorStart = color; - backgroundGradientColorEnd = color; - } - } - - if ("selectGridColor" in viewStates) - viewRoot.gridColor = viewStates.selectGridColor - } - - // If resetToDefault is true, tool states not specifically set to anything will be reset to - // their default state. - function updateToolStates(toolStates, resetToDefault) - { - if ("showEditLight" in toolStates) - showEditLight = toolStates.showEditLight; - else if (resetToDefault) - showEditLight = false; - - if ("showGrid" in toolStates) - showGrid = toolStates.showGrid; - else if (resetToDefault) - showGrid = true; - - if ("syncBackgroundColor" in toolStates) { - syncBackgroundColor = toolStates.syncBackgroundColor; - if (syncBackgroundColor) { - var color = _generalHelper.sceneEnvironmentColor(sceneId); - updateViewStates({"selectBackgroundColor": color}) - } - } else if (resetToDefault) { - syncBackgroundColor = false; - } - - if ("showSelectionBox" in toolStates) - showSelectionBox = toolStates.showSelectionBox; - else if (resetToDefault) - showSelectionBox = true; - - if ("showIconGizmo" in toolStates) - showIconGizmo = toolStates.showIconGizmo; - else if (resetToDefault) - showIconGizmo = true; - - if ("showCameraFrustum" in toolStates) - showCameraFrustum = toolStates.showCameraFrustum; - else if (resetToDefault) - showCameraFrustum = false; - - if ("usePerspective" in toolStates) - usePerspective = toolStates.usePerspective; - else if (resetToDefault) - usePerspective = true; - - if ("globalOrientation" in toolStates) - globalOrientation = toolStates.globalOrientation; - else if (resetToDefault) - globalOrientation = false; - - if ("selectionMode" in toolStates) - selectionMode = toolStates.selectionMode; - else if (resetToDefault) - selectionMode = EditView3D.SelectionMode.Item; - - if ("transformMode" in toolStates) - transformMode = toolStates.transformMode; - else if (resetToDefault) - transformMode = EditView3D.TransformMode.Move; - - if ("editCamState" in toolStates) - cameraControl.restoreCameraState(toolStates.editCamState); - else if (resetToDefault) - cameraControl.restoreDefaultState(); - } - - function storeCurrentToolStates() - { - _generalHelper.storeToolState(sceneId, "showEditLight", showEditLight) - _generalHelper.storeToolState(sceneId, "showGrid", showGrid) - _generalHelper.storeToolState(sceneId, "syncBackgroundColor", syncBackgroundColor) - _generalHelper.storeToolState(sceneId, "showSelectionBox", showSelectionBox) - _generalHelper.storeToolState(sceneId, "showIconGizmo", showIconGizmo) - _generalHelper.storeToolState(sceneId, "showCameraFrustum", showCameraFrustum) - _generalHelper.storeToolState(sceneId, "usePerspective", usePerspective) - _generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation) - _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode); - _generalHelper.storeToolState(sceneId, "transformMode", transformMode); - - cameraControl.storeCameraState(0); - } - - function ensureSelectionBoxes(count) - { - var needMore = count - selectionBoxes.length - if (needMore > 0) { - var component = Qt.createComponent("SelectionBox.qml"); - if (component.status === Component.Ready) { - for (var i = 0; i < needMore; ++i) { - var geometryName = _generalHelper.generateUniqueName("SelectionBoxGeometry"); - var boxParent = null; - if (editView) - boxParent = editView.sceneHelpers; - var box = component.createObject(boxParent, {"view3D": editView, - "geometryName": geometryName}); - selectionBoxes[selectionBoxes.length] = box; - box.view3D = Qt.binding(function() {return editView;}); - box.visible = Qt.binding(function() {return showSelectionBox;}); - } - } - } - } - - function selectObjects(objects) - { - // Create selection boxes as necessary. One more box than is actually needed is created, so - // that we always have a previously created box to use for new selection. - // This fixes an occasional visual glitch when creating a new box. - ensureSelectionBoxes(objects.length + 1) - - var i; - for (i = 0; i < objects.length; ++i) - selectionBoxes[i].targetNode = objects[i]; - for (i = objects.length; i < selectionBoxes.length; ++i) - selectionBoxes[i].targetNode = null; - - selectedNodes = objects; - if (objects.length === 0) { - selectedNode = null; - } else if (objects.length > 1) { - selectedNode = multiSelectionNode; - _generalHelper.setMultiSelectionTargets(multiSelectionNode, objects); - } else { - selectedNode = objects[0]; - } - } - - function handleObjectClicked(object, button, multi) - { - if (object instanceof View3D) { - // View3D can be the resolved pick target in case the 3D editor is showing content - // of a component that has View3D as root. In that case locking is resolved on C++ side - // and we ignore multiselection. - selectObjects([]); - selectionChanged([object]); - return; - } - - var clickedObject; - - // Click on locked object is treated same as click on empty space - if (!_generalHelper.isLocked(object)) - clickedObject = object; - - if (selectionMode === EditView3D.SelectionMode.Group) { - while (clickedObject && clickedObject !== activeScene - && (activeScene instanceof Model || clickedObject.parent !== activeScene)) { - clickedObject = clickedObject.parent; - } - } - // Object selection logic: - // Regular click: Clear any multiselection, single-selects the clicked object - // Ctrl-click: No objects selected: Act as single select - // One or more objects selected: Multiselect - // Null object always clears entire selection - var newSelection = []; - if (clickedObject) { - if (button === Qt.RightButton) { - // Right-clicking does only single selection (when clickedObject is unselected) - // This is needed for selecting a target for the context menu - if (!selectedNodes.includes(clickedObject)) - newSelection[0] = clickedObject; - else - newSelection = selectedNodes; - } else if (multi && selectedNodes.length > 0) { - var deselect = false; - for (var i = 0; i < selectedNodes.length; ++i) { - // Multiselecting already selected object clears that object from selection - if (selectedNodes[i] !== clickedObject) - newSelection[newSelection.length] = selectedNodes[i]; - else - deselect = true; - } - if (!deselect) - newSelection[newSelection.length] = clickedObject; - } else { - newSelection[0] = clickedObject; - } - } - selectObjects(newSelection); - selectionChanged(newSelection); - } - - function addLightGizmo(scene, obj) - { - // Insert into first available gizmo if we don't already have gizmo for this object - var slotFound = -1; - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (!lightIconGizmos[i].targetNode) { - slotFound = i; - } else if (lightIconGizmos[i].targetNode === obj) { - lightIconGizmos[i].scene = scene; - return; - } - } - - if (slotFound !== -1) { - lightIconGizmos[slotFound].scene = scene; - lightIconGizmos[slotFound].targetNode = obj; - lightIconGizmos[slotFound].locked = _generalHelper.isLocked(obj); - lightIconGizmos[slotFound].hidden = _generalHelper.isHidden(obj); - return; - } - - // No free gizmos available, create a new one - var gizmoComponent = Qt.createComponent("LightIconGizmo.qml"); - if (gizmoComponent.status === Component.Ready) { - var gizmo = gizmoComponent.createObject(overlayView, - {"view3D": overlayView, "targetNode": obj, - "selectedNodes": selectedNodes, "scene": scene, - "activeScene": activeScene, - "locked": _generalHelper.isLocked(obj), - "hidden": _generalHelper.isHidden(obj), - "globalShow": showIconGizmo}); - lightIconGizmos[lightIconGizmos.length] = gizmo; - gizmo.clicked.connect(handleObjectClicked); - gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); - gizmo.activeScene = Qt.binding(function() {return activeScene;}); - gizmo.globalShow = Qt.binding(function() {return showIconGizmo;}); - } - } - - function addCameraGizmo(scene, obj) - { - // Insert into first available gizmo if we don't already have gizmo for this object - var slotFound = -1; - for (var i = 0; i < cameraGizmos.length; ++i) { - if (!cameraGizmos[i].targetNode) { - slotFound = i; - } else if (cameraGizmos[i].targetNode === obj) { - cameraGizmos[i].scene = scene; - return; - } - } - - if (slotFound !== -1) { - cameraGizmos[slotFound].scene = scene; - cameraGizmos[slotFound].targetNode = obj; - cameraGizmos[slotFound].locked = _generalHelper.isLocked(obj); - cameraGizmos[slotFound].hidden = _generalHelper.isHidden(obj); - return; - } - - // No free gizmos available, create a new one - var gizmoComponent = Qt.createComponent("CameraGizmo.qml"); - var frustumComponent = Qt.createComponent("CameraFrustum.qml"); - if (gizmoComponent.status === Component.Ready && frustumComponent.status === Component.Ready) { - var geometryName = _generalHelper.generateUniqueName("CameraGeometry"); - var frustum = frustumComponent.createObject( - overlayScene, - {"geometryName": geometryName, "viewPortRect": viewPortRect}); - var gizmo = gizmoComponent.createObject( - overlayView, - {"view3D": overlayView, "targetNode": obj, - "selectedNodes": selectedNodes, "scene": scene, "activeScene": activeScene, - "locked": _generalHelper.isLocked(obj), "hidden": _generalHelper.isHidden(obj), - "globalShow": showIconGizmo, "globalShowFrustum": showCameraFrustum}); - - cameraGizmos[cameraGizmos.length] = gizmo; - gizmo.clicked.connect(handleObjectClicked); - gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); - gizmo.activeScene = Qt.binding(function() {return activeScene;}); - gizmo.globalShow = Qt.binding(function() {return showIconGizmo;}); - gizmo.globalShowFrustum = Qt.binding(function() {return showCameraFrustum;}); - frustum.viewPortRect = Qt.binding(function() {return viewPortRect;}); - gizmo.connectFrustum(frustum); - } - } - - function releaseLightGizmo(obj) - { - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === obj) { - lightIconGizmos[i].scene = null; - lightIconGizmos[i].targetNode = null; - return; - } - } - } - - function releaseCameraGizmo(obj) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === obj) { - cameraGizmos[i].scene = null; - cameraGizmos[i].targetNode = null; - return; - } - } - } - - function updateLightGizmoScene(scene, obj) - { - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === obj) { - lightIconGizmos[i].scene = scene; - return; - } - } - } - - function updateCameraGizmoScene(scene, obj) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === obj) { - cameraGizmos[i].scene = scene; - return; - } - } - } - - function gizmoAt(x, y) - { - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].visible && lightIconGizmos[i].hasPoint(x, y)) - return lightIconGizmos[i].targetNode; - } - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].visible && cameraGizmos[i].hasPoint(x, y)) - return cameraGizmos[i].targetNode; - } - return null; - } - - Component.onCompleted: { - createEditView(); - selectObjects([]); - // Work-around the fact that the projection matrix for the camera is not calculated until - // the first frame is rendered, so any initial calls to mapFrom3DScene() will fail. - _generalHelper.requestOverlayUpdate(); - } - - onWidthChanged: _generalHelper.requestOverlayUpdate() - onHeightChanged: _generalHelper.requestOverlayUpdate() - - Connections { - target: _generalHelper - function onLockedStateChanged(node) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === node) { - cameraGizmos[i].locked = _generalHelper.isLocked(node); - return; - } - } - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === node) { - lightIconGizmos[i].locked = _generalHelper.isLocked(node); - return; - } - } - } - function onHiddenStateChanged(node) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === node) { - cameraGizmos[i].hidden = _generalHelper.isHidden(node); - return; - } - } - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === node) { - lightIconGizmos[i].hidden = _generalHelper.isHidden(node); - return; - } - } - } - } - - Node { - id: overlayScene - - PerspectiveCamera { - id: overlayPerspectiveCamera - clipFar: viewRoot.editView ? viewRoot.editView.perspectiveCamera.clipFar : 1000 - clipNear: viewRoot.editView ? viewRoot.editView.perspectiveCamera.clipNear : 1 - position: viewRoot.editView ? viewRoot.editView.perspectiveCamera.position : Qt.vector3d(0, 0, 0) - rotation: viewRoot.editView ? viewRoot.editView.perspectiveCamera.rotation : Qt.quaternion(1, 0, 0, 0) - } - - OrthographicCamera { - id: overlayOrthoCamera - clipFar: viewRoot.editView ? viewRoot.editView.orthoCamera.clipFar : 1000 - clipNear: viewRoot.editView ? viewRoot.editView.orthoCamera.clipNear : 1 - position: viewRoot.editView ? viewRoot.editView.orthoCamera.position : Qt.vector3d(0, 0, 0) - rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.quaternion(1, 0, 0, 0) - scale: viewRoot.editView ? viewRoot.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0) - } - - MouseArea3D { - id: gizmoDragHelper - view3D: overlayView - } - - Node { - id: multiSelectionNode - objectName: "multiSelectionNode" - } - - MoveGizmo { - id: moveGizmo - scale: autoScale.getScale(Qt.vector3d(5, 5, 5)) - highlightOnHover: true - targetNode: viewRoot.selectedNode - globalOrientation: viewRoot.globalOrientation - visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Move - view3D: overlayView - dragHelper: gizmoDragHelper - property var propertyNames: ["position"] - - onPositionCommit: { - if (targetNode == multiSelectionNode) - viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNames); - else - viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames); - } - onPositionMove: { - if (targetNode == multiSelectionNode) - viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNames); - else - viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames); - } - } - - ScaleGizmo { - id: scaleGizmo - scale: autoScale.getScale(Qt.vector3d(5, 5, 5)) - highlightOnHover: true - targetNode: viewRoot.selectedNode - visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Scale - view3D: overlayView - dragHelper: gizmoDragHelper - property var propertyNames: ["scale"] - property var propertyNamesMulti: ["position", "scale"] - - onScaleCommit: { - if (targetNode == multiSelectionNode) - viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames); - } - onScaleChange: { - if (targetNode == multiSelectionNode) - viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames); - } - } - - RotateGizmo { - id: rotateGizmo - scale: autoScale.getScale(Qt.vector3d(7, 7, 7)) - highlightOnHover: true - targetNode: viewRoot.selectedNode - globalOrientation: viewRoot.globalOrientation - visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Rotate - view3D: overlayView - dragHelper: gizmoDragHelper - property var propertyNames: ["eulerRotation"] - property var propertyNamesMulti: ["position", "eulerRotation"] - - onRotateCommit: { - if (targetNode == multiSelectionNode) - viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames); - } - onRotateChange: { - if (targetNode == multiSelectionNode) - viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames); - } - } - - LightGizmo { - id: lightGizmo - targetNode: viewRoot.selectedNode != multiSelectionNode ? viewRoot.selectedNode : null - view3D: overlayView - dragHelper: gizmoDragHelper - - onPropertyValueCommit: (propName) => { - viewRoot.commitObjectProperty([targetNode], [propName]); - } - onPropertyValueChange: (propName) => { - viewRoot.changeObjectProperty([targetNode], [propName]); - } - } - - AutoScaleHelper { - id: autoScale - view3D: overlayView - position: moveGizmo.scenePosition - } - - AutoScaleHelper { - id: pivotAutoScale - view3D: overlayView - position: pivotLine.startPos - } - - Line3D { - id: pivotLine - visible: viewRoot.selectedNode && viewRoot.selectedNode != multiSelectionNode - name: "3D Edit View Pivot Line" - color: "#ddd600" - - startPos: viewRoot.selectedNode ? viewRoot.selectedNode.scenePosition - : Qt.vector3d(0, 0, 0) - Connections { - target: viewRoot - function onSelectedNodeChanged() - { - pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode); - } - } - Connections { - target: viewRoot.selectedNode - function onSceneTransformChanged() - { - pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode); - } - } - - Model { - id: pivotCap - source: "#Sphere" - scale: pivotAutoScale.getScale(Qt.vector3d(0.03, 0.03, 0.03)) - position: pivotLine.startPos - materials: [ - DefaultMaterial { - id: lineMat - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - diffuseColor: pivotLine.color - } - ] - } - } - } - - Item { - id: contentItem - anchors.fill: parent - - Rectangle { - id: viewRect - anchors.fill: parent - - gradient: Gradient { - GradientStop { position: 1.0; color: backgroundGradientColorStart } - GradientStop { position: 0.0; color: backgroundGradientColorEnd } - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - hoverEnabled: false - - property MouseArea3D freeDraggerArea - property point pressPoint - property bool initialMoveBlock: false - - onPressed: (mouse) => { - if (viewRoot.editView) { - var pickResult = viewRoot.editView.pick(mouse.x, mouse.y); - handleObjectClicked(_generalHelper.resolvePick(pickResult.objectHit), mouse.button, - mouse.modifiers & Qt.ControlModifier); - - if (pickResult.objectHit && pickResult.objectHit instanceof Node) { - if (transformMode === EditView3D.TransformMode.Move) - freeDraggerArea = moveGizmo.freeDraggerArea; - else if (transformMode === EditView3D.TransformMode.Rotate) - freeDraggerArea = rotateGizmo.freeDraggerArea; - else if (transformMode === EditView3D.TransformMode.Scale) - freeDraggerArea = scaleGizmo.freeDraggerArea; - pressPoint.x = mouse.x; - pressPoint.y = mouse.y; - initialMoveBlock = true; - } else { - mouse.accepted = false; - } - } - } - onPositionChanged: (mouse) => { - if (freeDraggerArea) { - if (initialMoveBlock && Math.abs(pressPoint.x - mouse.x) + Math.abs(pressPoint.y - mouse.y) > 10) { - // Don't force press event at actual press, as that puts the gizmo - // in free-dragging state, which is bad UX if drag is not actually done - freeDraggerArea.forcePressEvent(pressPoint.x, pressPoint.y); - freeDraggerArea.forceMoveEvent(mouse.x, mouse.y); - initialMoveBlock = false; - } else { - freeDraggerArea.forceMoveEvent(mouse.x, mouse.y); - } - } - } - - function handleRelease(mouse) - { - if (freeDraggerArea) { - if (initialMoveBlock) - freeDraggerArea.forceReleaseEvent(pressPoint.x, pressPoint.y); - else - freeDraggerArea.forceReleaseEvent(mouse.x, mouse.y); - freeDraggerArea = null; - } - } - - onReleased: (mouse) => { - handleRelease(mouse); - } - onCanceled: (mouse) => { - handleRelease(mouse); - } - } - - DropArea { - anchors.fill: parent - } - - View3D { - id: overlayView - anchors.fill: parent - camera: viewRoot.usePerspective ? overlayPerspectiveCamera : overlayOrthoCamera - importScene: overlayScene - z: 2 - } - - Overlay2D { - id: gizmoLabel - targetNode: moveGizmo.visible ? moveGizmo : scaleGizmo - targetView: overlayView - visible: targetNode.dragging - z: 3 - - Rectangle { - color: "white" - x: -width / 2 - y: -height - 8 - width: gizmoLabelText.width + 4 - height: gizmoLabelText.height + 4 - border.width: 1 - Text { - id: gizmoLabelText - text: { - // This is skipped during application shutdown, as calling QQuickText::setText() - // during application shutdown can crash the application. - if (shuttingDown) - return text; - var l = Qt.locale(); - var targetProperty; - if (viewRoot.selectedNode) { - if (gizmoLabel.targetNode === moveGizmo) - targetProperty = viewRoot.selectedNode.position; - else - targetProperty = viewRoot.selectedNode.scale; - return qsTr("x:") + Number(targetProperty.x).toLocaleString(l, 'f', 1) - + qsTr(" y:") + Number(targetProperty.y).toLocaleString(l, 'f', 1) - + qsTr(" z:") + Number(targetProperty.z).toLocaleString(l, 'f', 1); - } else { - return ""; - } - } - anchors.centerIn: parent - } - } - } - - Rectangle { - id: rotateGizmoLabel - color: "white" - x: rotateGizmo.currentMousePos.x - (10 + width) - y: rotateGizmo.currentMousePos.y - (10 + height) - width: rotateGizmoLabelText.width + 4 - height: rotateGizmoLabelText.height + 4 - border.width: 1 - visible: rotateGizmo.dragging - parent: rotateGizmo.view3D - z: 3 - - Text { - id: rotateGizmoLabelText - text: { - // This is skipped during application shutdown, as calling QQuickText::setText() - // during application shutdown can crash the application. - if (shuttingDown) - return text; - var l = Qt.locale(); - if (rotateGizmo.targetNode) { - var degrees = rotateGizmo.currentAngle * (180 / Math.PI); - return Number(degrees).toLocaleString(l, 'f', 1); - } else { - return ""; - } - } - anchors.centerIn: parent - } - } - - Rectangle { - id: lightGizmoLabel - color: "white" - x: lightGizmo.currentMousePos.x - (10 + width) - y: lightGizmo.currentMousePos.y - (10 + height) - width: lightGizmoLabelText.width + 4 - height: lightGizmoLabelText.height + 4 - border.width: 1 - visible: lightGizmo.dragging - parent: lightGizmo.view3D - z: 3 - - Text { - id: lightGizmoLabelText - text: lightGizmo.currentLabel - anchors.centerIn: parent - } - } - - EditCameraController { - id: cameraControl - camera: viewRoot.editView ? viewRoot.editView.camera : null - anchors.fill: parent - view3d: viewRoot.editView - sceneId: viewRoot.sceneId - } - } - - AxisHelper { - anchors.right: parent.right - anchors.top: parent.top - width: 100 - height: width - editCameraCtrl: cameraControl - selectedNode: viewRoot.selectedNodes.length === 1 ? viewRoot.selectionBoxes[0].model - : viewRoot.selectedNode - } - - Text { - id: sceneLabel - text: viewRoot.sceneId - anchors.top: parent.top - anchors.left: parent.left - anchors.margins: 4 - font.pixelSize: 14 - color: "white" - } - - Text { - id: fpsLabel - text: viewRoot.fps - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.margins: 4 - font.pixelSize: 12 - color: "white" - visible: viewRoot.fps > 0 - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/FadeHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/FadeHandle.qml deleted file mode 100644 index 9ca007057a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/FadeHandle.qml +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -DirectionalDraggable { - id: handleRoot - - property string currentLabel - property point currentMousePos - property real fadeScale - property real baseScale: 5 - property real dragScale: 1 - - scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale)) - length: 3 - offset: -1.5 - - Model { - id: handle - source: "#Sphere" - materials: [ handleRoot.material ] - scale: Qt.vector3d(0.02, 0.02, 0.02) - } - - AutoScaleHelper { - id: autoScaler - active: handleRoot.active - view3D: handleRoot.view3D - } - - property real _q // quadratic fade - property real _l // linear fade - property real _c // constant fade - property real _d: 20 // Divisor from fadeScale calc in lightGizmo - property real _startScale - property real _startFadeScale - property string _currentProp - - signal valueCommit(string propName) - signal valueChange(string propName) - - function updateFade(relativeDistance, screenPos) - { - // Solved from fadeScale equation in LightGizmo - var newValue = 0; - var _x = Math.max(0, (_startFadeScale - (relativeDistance * _startScale)) / 100); - - // Fades capped to range 0-10 because property editor caps them to that range - if (_currentProp === "quadraticFade") { - if (_x === 0) - newValue = 10; - else - newValue = Math.max(0, Math.min(10, -(_c - _d + (_l * _x)) / (_x * _x))); - if (newValue < 0.01) - newValue = 0; // To avoid having tiny positive value when UI shows 0.00 - targetNode.quadraticFade = newValue; - } else if (_currentProp === "linearFade") { - if (_x === 0) - newValue = 10; - else - newValue = Math.max(0, Math.min(10, -(_c - _d) / _x)); - if (newValue < 0.01) - newValue = 0; // To avoid having tiny positive value when UI shows 0.00 - targetNode.linearFade = newValue; - } else { - // Since pure constant fade equates to infinitely long cone, fadeScale calc assumes - // linear fade of one in this case. - newValue = Math.max(0, Math.min(10, _d - _x)); - targetNode.constantFade = newValue; - } - - var l = Qt.locale(); - handleRoot.currentLabel = _currentProp + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 2); - handleRoot.currentMousePos = screenPos; - } - - onPressed: (mouseArea, screenPos)=> { - _startScale = autoScaler.relativeScale * baseScale * dragScale; - _startFadeScale = fadeScale; - _l = targetNode.linearFade; - _c = targetNode.constantFade; - _q = targetNode.quadraticFade; - if (targetNode.quadraticFade === 0) { - if (targetNode.linearFade === 0) { - _currentProp = "constantFade"; - } else { - _currentProp = "linearFade"; - } - } else { - _currentProp = "quadraticFade"; - } - updateFade(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateFade(relativeDistance, screenPos); - handleRoot.valueChange(_currentProp); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateFade(relativeDistance, screenPos); - handleRoot.valueCommit(_currentProp); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml deleted file mode 100644 index eef82d4612..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/HelperGrid.qml +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import GridGeometry 1.0 - -Node { - id: grid - - property alias lines: gridGeometry.lines - property alias step: gridGeometry.step - property alias subdivAlpha: subGridMaterial.opacity - property alias gridColor: mainGridMaterial.diffuseColor - - eulerRotation.x: 90 - - // Note: Only one instance of HelperGrid is supported, as the geometry names are fixed - - Model { // Main grid lines - castsShadows: false - receivesShadows: false - geometry: GridGeometry { - id: gridGeometry - name: "3D Edit View Helper Grid" - } - - materials: [ - DefaultMaterial { - id: mainGridMaterial - diffuseColor: "#aaaaaa" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } - - Model { // Subdivision lines - castsShadows: false - receivesShadows: false - geometry: GridGeometry { - lines: gridGeometry.lines - step: gridGeometry.step - isSubdivision: true - name: "3D Edit View Helper Grid subdivisions" - } - - materials: [ - DefaultMaterial { - id: subGridMaterial - diffuseColor: mainGridMaterial.diffuseColor - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } - - Model { // Z Axis - castsShadows: false - receivesShadows: false - geometry: GridGeometry { - lines: gridGeometry.lines - step: gridGeometry.step - isCenterLine: true - name: "3D Edit View Helper Grid Z Axis" - } - materials: [ - DefaultMaterial { - id: vCenterLineMaterial - diffuseColor: "#00a1d2" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } - Model { // X Axis - castsShadows: false - receivesShadows: false - eulerRotation.z: 90 - geometry: GridGeometry { - lines: gridGeometry.lines - step: gridGeometry.step - isCenterLine: true - name: "3D Edit View Helper Grid X Axis" - } - materials: [ - DefaultMaterial { - id: hCenterLineMaterial - diffuseColor: "#cb211a" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/IconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/IconGizmo.qml deleted file mode 100644 index e44cf74d08..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/IconGizmo.qml +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -Item { - id: iconGizmo - - property Node activeScene: null - property Node scene: null - property View3D view3D - property bool highlightOnHover: true - property Node targetNode: null - property var selectedNodes: [] - readonly property bool selected: { - for (var i = 0; i < selectedNodes.length; ++i) { - if (selectedNodes[i] === targetNode) - return true; - } - return false; - } - property bool hasMouse: false - property bool hidden: false - property bool locked: false - property bool globalShow: true - property bool canBeVisible: activeScene === scene && !hidden && (targetNode ? targetNode.visible : false) - - property alias iconSource: iconImage.source - - signal clicked(Node node, bool multi) - - function hasPoint(x, y) - { - if (!view3D || !targetNode) - return false; - - var point = view3D.mapToItem(iconMouseArea, x, y); - - return point.x >= iconMouseArea.x && (point.x <= iconMouseArea.x + iconMouseArea.width) - && point.y >= iconMouseArea.y && (point.y <= iconMouseArea.y + iconMouseArea.height); - } - - onSelectedChanged: { - if (selected) - hasMouse = false; - } - - visible: canBeVisible && globalShow - - Overlay2D { - id: iconOverlay - targetNode: iconGizmo.targetNode - targetView: view3D - visible: iconGizmo.visible && !isBehindCamera - - Rectangle { - id: iconRect - - width: iconImage.width - height: iconImage.height - x: -width / 2 - y: -height / 2 - color: "transparent" - border.color: "#7777ff" - border.width: !iconGizmo.locked && iconGizmo.highlightOnHover && iconGizmo.hasMouse ? 2 : 0 - radius: 5 - opacity: iconGizmo.selected ? 0.2 : 1 - Image { - id: iconImage - fillMode: Image.Pad - MouseArea { - id: iconMouseArea - anchors.fill: parent - onPressed: (mouse)=> { - // Ignore singleselection mouse presses when we have single object selected - // so that the icon gizmo doesn't hijack mouse clicks meant for other gizmos - if (iconGizmo.selected && !(mouse.modifiers & Qt.ControlModifier) - && selectedNodes.length === 1) { - mouse.accepted = false; - } - } - - onClicked: (mouse)=> { - iconGizmo.clicked(iconGizmo.targetNode, - mouse.modifiers & Qt.ControlModifier); - } - hoverEnabled: iconGizmo.highlightOnHover && !iconGizmo.selected - acceptedButtons: Qt.LeftButton - - // onPositionChanged, onContainsMouseAreaChanged, and hasMouse are used instead - // of just using containsMouse directly, because containsMouse - // cannot be relied upon to update correctly in some situations. - // This is likely because the overlapping 3D mouse areas of the gizmos get - // the mouse events instead of this area, so mouse leaving the area - // doesn't always update containsMouse property. - onPositionChanged: { - if (!iconGizmo.selected) - iconGizmo.hasMouse = containsMouse; - } - - onContainsMouseChanged: { - if (!iconGizmo.selected) - iconGizmo.hasMouse = containsMouse; - else - iconGizmo.hasMouse = false; - } - } - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/IconRenderer3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/IconRenderer3D.qml deleted file mode 100644 index 2f64dd93c0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/IconRenderer3D.qml +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.15 -import QtQuick3D 1.15 - -Item { - id: viewRoot - width: 1024 - height: 1024 - visible: true - - property alias view3D: view3D - property alias camPos: viewCamera.position - - function setSceneToBox() - { - selectionBox.targetNode = view3D.importScene; - } - - function fitAndHideBox() - { - cameraControl.focusObject(selectionBox.model, viewCamera.eulerRotation, true, true); - if (cameraControl._zoomFactor < 0.1) - view3D.importScene.scale = view3D.importScene.scale.times(10); - if (cameraControl._zoomFactor > 10) - view3D.importScene.scale = view3D.importScene.scale.times(0.1); - - selectionBox.visible = false; - } - - View3D { - id: view3D - camera: viewCamera - environment: sceneEnv - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.VeryHigh - } - - PerspectiveCamera { - id: viewCamera - position: Qt.vector3d(-200, 200, 200) - eulerRotation: Qt.vector3d(-45, -45, 0) - } - - DirectionalLight { - rotation: viewCamera.rotation - } - - SelectionBox { - id: selectionBox - view3D: view3D - geometryName: "SB" - } - - EditCameraController { - id: cameraControl - camera: view3D.camera - view3d: view3D - ignoreToolState: true - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightGizmo.qml deleted file mode 100644 index a20d75120c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightGizmo.qml +++ /dev/null @@ -1,334 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 -import LightUtils 1.0 - -Node { - id: lightGizmo - - property View3D view3D - property Node targetNode: null - property MouseArea3D dragHelper: null - property color color: Qt.rgba(1, 1, 0, 1) - property real fadeScale: { - // Value indicates area where intensity is above certain percent of total brightness. - if (lightGizmo.targetNode instanceof SpotLight || lightGizmo.targetNode instanceof PointLight) { - var l = targetNode.linearFade; - var q = targetNode.quadraticFade; - var c = targetNode.constantFade; - var d = 20; // divisor to target intensity value. E.g. 20 = 1/20 = 5% - if (l === 0 && q === 0) - l = 1; // For pure constant fade, cone would be infinite, so pretend we have linear fade - // Solved from equation in shader: - // 1 / d = 1 / (c + (l + q * dist) * dist); - if (q === 0) - return 100 * Math.max(((d - c) / l), 1); - else - return 100 * ((Math.sqrt(4 * q * (d - c) + (l * l)) - l) / (2 * q)); - } else { - return 100; - } - } - readonly property bool dragging: primaryArrow.dragging - || spotLightHandle.dragging - || spotLightInnerHandle.dragging - || spotLightFadeHandle.dragging - || areaHeightHandle.dragging - || areaWidthHandle.dragging - || pointLightFadeHandle.dragging - property point currentMousePos - property string currentLabel - property int brightnessDecimals: _generalHelper.brightnessScaler() > 10. ? 0 : 2; - property real brightnessMultiplier: Math.pow(10, brightnessDecimals); - - signal propertyValueCommit(string propName) - signal propertyValueChange(string propName) - - position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0) - visible: lightGizmo.targetNode instanceof SpotLight - || lightGizmo.targetNode instanceof AreaLight - || lightGizmo.targetNode instanceof DirectionalLight - || lightGizmo.targetNode instanceof PointLight - - AutoScaleHelper { - id: autoScaler - view3D: lightGizmo.view3D - } - - Node { - id: pointLightParts - rotation: lightGizmo.view3D.camera.rotation - visible: lightGizmo.targetNode instanceof PointLight - - LightModel { - id: pointModel - geometryName: "Edit 3D PointLight" - geometryType: LightGeometry.Point - material: lightMaterial - scale: Qt.vector3d(lightGizmo.fadeScale, lightGizmo.fadeScale, lightGizmo.fadeScale) - } - - FadeHandle { - id: pointLightFadeHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof PointLight ? Qt.vector3d(-pointModel.scale.x, 0, 0) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(0, 0, -90) - targetNode: lightGizmo.targetNode instanceof PointLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof PointLight - dragHelper: lightGizmo.dragHelper - fadeScale: lightGizmo.fadeScale - - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: (propName)=> { - lightGizmo.propertyValueChange(propName); - } - onValueCommit: (propName)=> { - lightGizmo.propertyValueCommit(propName); - } - } - } - - - Node { - rotation: !lightGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) - : lightGizmo.targetNode.sceneRotation - - Node { - id: spotParts - visible: lightGizmo.targetNode instanceof SpotLight - - LightModel { - id: spotModel - - property real coneXYScale: spotParts.visible && lightGizmo.targetNode - ? lightGizmo.fadeScale * Math.tan(Math.PI * lightGizmo.targetNode.coneAngle / 180) - : 1 - - geometryName: "Edit 3D SpotLight Cone" - geometryType: LightGeometry.Spot - material: lightMaterial - scale: Qt.vector3d(coneXYScale, coneXYScale, - spotParts.visible && lightGizmo.targetNode && lightGizmo.targetNode.coneAngle > 90 - ? -lightGizmo.fadeScale : lightGizmo.fadeScale) - } - - LightModel { - id: spotInnerModel - - property real coneXYScale: spotParts.visible && lightGizmo.targetNode - ? lightGizmo.fadeScale * Math.tan(Math.PI * lightGizmo.targetNode.innerConeAngle / 180) - : 1 - - geometryName: "Edit 3D SpotLight Inner Cone" - geometryType: LightGeometry.Spot - material: lightMaterial - scale: Qt.vector3d(coneXYScale, coneXYScale, - spotParts.visible && lightGizmo.targetNode && lightGizmo.targetNode.innerConeAngle > 90 - ? -lightGizmo.fadeScale : lightGizmo.fadeScale) - } - - SpotLightHandle { - id: spotLightHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(0, spotModel.scale.y, -spotModel.scale.z) - : Qt.vector3d(0, 0, 0) - targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof SpotLight - dragHelper: lightGizmo.dragHelper - propName: "coneAngle" - propValue: lightGizmo.targetNode instanceof SpotLight ? targetNode.coneAngle : 0 - - onNewValueChanged: targetNode.coneAngle = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: { - if (targetNode.innerConeAngle > targetNode.coneAngle) - targetNode.innerConeAngle = targetNode.coneAngle; - lightGizmo.propertyValueCommit(propName) - lightGizmo.propertyValueCommit(spotLightInnerHandle.propName); - } - } - - SpotLightHandle { - id: spotLightInnerHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(0, -spotInnerModel.scale.y, -spotInnerModel.scale.z) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(180, 0, 0) - targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof SpotLight - dragHelper: lightGizmo.dragHelper - propName: "innerConeAngle" - propValue: lightGizmo.targetNode instanceof SpotLight ? targetNode.innerConeAngle : 0 - - onNewValueChanged: targetNode.innerConeAngle = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: { - if (targetNode.coneAngle < targetNode.innerConeAngle) - targetNode.coneAngle = targetNode.innerConeAngle; - lightGizmo.propertyValueCommit(propName) - lightGizmo.propertyValueCommit(spotLightHandle.propName); - } - } - - FadeHandle { - id: spotLightFadeHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(spotModel.scale.x / 2, 0, -spotInnerModel.scale.z / 2) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof SpotLight - dragHelper: lightGizmo.dragHelper - fadeScale: lightGizmo.fadeScale - dragScale: 2 - - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: (propName)=> { - lightGizmo.propertyValueChange(propName); - } - onValueCommit: (propName)=> { - lightGizmo.propertyValueCommit(propName); - } - } - } - Node { - id: areaParts - visible: lightGizmo.targetNode instanceof AreaLight - - LightModel { - id: areaModel - geometryName: "Edit 3D AreaLight" - geometryType: LightGeometry.Area - material: lightMaterial - scale: areaParts.visible ? Qt.vector3d(lightGizmo.targetNode.width / 2, - lightGizmo.targetNode.height / 2, 1) - .times(lightGizmo.targetNode.scale) - : Qt.vector3d(1, 1, 1) - } - - AreaLightHandle { - id: areaWidthHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(-areaModel.scale.x, 0, 0) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(0, 0, 90) - targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof AreaLight - dragHelper: lightGizmo.dragHelper - propName: "width" - propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.width : 0 - - onNewValueChanged: targetNode.width = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: lightGizmo.propertyValueCommit(propName) - } - - AreaLightHandle { - id: areaHeightHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(0, -areaModel.scale.y, 0) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(0, 0, 180) - targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof AreaLight - dragHelper: lightGizmo.dragHelper - propName: "height" - propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.height : 0 - - onNewValueChanged: targetNode.height = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: lightGizmo.propertyValueCommit(propName) - } - } - - LightModel { - id: directionalModel - geometryName: "Edit 3D DirLight" - geometryType: LightGeometry.Directional - material: lightMaterial - visible: lightGizmo.targetNode instanceof DirectionalLight - scale: autoScaler.getScale(Qt.vector3d(50, 50, 50)) - } - - AdjustableArrow { - id: primaryArrow - eulerRotation: Qt.vector3d(-90, 0, 0) - targetNode: lightGizmo.targetNode - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - view3D: lightGizmo.view3D - active: lightGizmo.visible - dragHelper: lightGizmo.dragHelper - scale: autoScaler.getScale(Qt.vector3d(5, 5, 5)) - length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness / _generalHelper.brightnessScaler() * 10.0) + 3 : 10 - - property real _startBrightness - - function updateBrightness(relativeDistance, screenPos) - { - var currentValue = Math.max(0, (_startBrightness + relativeDistance * _generalHelper.brightnessScaler() / 10.0)); - currentValue *= brightnessMultiplier; - currentValue = Math.round(currentValue); - currentValue /= brightnessMultiplier; - - var l = Qt.locale(); - lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', brightnessDecimals); - lightGizmo.currentMousePos = screenPos; - targetNode.brightness = currentValue; - } - - onPressed: (mouseArea, screenPos)=> { - _startBrightness = targetNode.brightness; - updateBrightness(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateBrightness(relativeDistance, screenPos); - lightGizmo.propertyValueChange("brightness"); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateBrightness(relativeDistance, screenPos); - lightGizmo.propertyValueCommit("brightness"); - } - } - - DefaultMaterial { - id: lightMaterial - diffuseColor: lightGizmo.color - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightIconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightIconGizmo.qml deleted file mode 100644 index 57144df31e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightIconGizmo.qml +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import LightUtils 1.0 - -IconGizmo { - id: lightIconGizmo - - property color overlayColor: targetNode ? targetNode.color : "transparent" - - iconSource: targetNode - ? targetNode instanceof DirectionalLight - ? "image://IconGizmoImageProvider/directional.png:" + overlayColor - : targetNode instanceof AreaLight - ? "image://IconGizmoImageProvider/area.png:" + overlayColor - : targetNode instanceof PointLight - ? "image://IconGizmoImageProvider/point.png:" + overlayColor - : "image://IconGizmoImageProvider/spot.png:" + overlayColor - : "image://IconGizmoImageProvider/point.png:" + overlayColor -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightModel.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightModel.qml deleted file mode 100644 index 081a2a2e4d..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/LightModel.qml +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import LightUtils 1.0 - -Model { - id: lightModel - - property alias geometryName: lightGeometry.name // Name must be unique for each geometry - property alias geometryType: lightGeometry.lightType - property Material material - - function updateGeometry() - { - lightGeometry.update(); - } - - scale: Qt.vector3d(50, 50, 50) - - geometry: lightGeometry - materials: [ material ] - - LightGeometry { - id: lightGeometry - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Line3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Line3D.qml deleted file mode 100644 index 3b2f5141f2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Line3D.qml +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import LineGeometry 1.0 - -Node { - id: pivotLine - - property alias startPos: lineGeometry.startPos - property alias endPos: lineGeometry.endPos - property alias name: lineGeometry.name // Name must be unique for each line - property alias color: lineMat.diffuseColor - - Model { - geometry: LineGeometry { - id: lineGeometry - } - materials: [ - DefaultMaterial { - id: lineMat - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/MaterialNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/MaterialNodeView.qml deleted file mode 100644 index f347253c80..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/MaterialNodeView.qml +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick3D 1.15 - -View3D { - id: root - anchors.fill: parent - environment: sceneEnv - camera: envMode === "SkyBox" && envValue === "preview_studio" ? studioCamera : defaultCamera - - property Material previewMaterial - property string envMode - property string envValue - property string modelSrc: "#Sphere" - - function fitToViewPort(closeUp) - { - // No need to zoom this view, this is here just to avoid runtime warnings - } - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - backgroundMode: envMode === "Color" ? SceneEnvironment.Color - : envMode === "SkyBox" ? SceneEnvironment.SkyBox - : SceneEnvironment.Transparent - clearColor: envMode === "Color" ? envValue : "#000000" - lightProbe: envMode === "SkyBox" ? skyBoxTex : null - - Texture { - id: skyBoxTex - source: envMode === "SkyBox" ? "../images/" + envValue + ".hdr" - : "" - } - } - - Node { - DirectionalLight { - eulerRotation.x: -26 - eulerRotation.y: modelSrc === "#Cube" ? -10 : -50 - brightness: envMode !== "SkyBox" ? 100 : 0 - } - - PerspectiveCamera { - id: defaultCamera - y: 70 - z: 200 - eulerRotation.x: -5.71 - clipNear: 1 - clipFar: 1000 - } - - PerspectiveCamera { - id: studioCamera - y: 232 - z: 85 - eulerRotation.x: -64.98 - clipNear: 1 - clipFar: 1000 - } - - Node { - rotation: root.camera.rotation - y: 50 - Node { - y: modelSrc === "#Cone" ? -40 : 10 - eulerRotation.x: 35 - Model { - id: model - source: modelSrc ? modelSrc : "#Sphere" - eulerRotation.y: 45 - materials: previewMaterial - scale: !modelSrc || modelSrc === "#Sphere" - ? Qt.vector3d(1.7, 1.7, 1.7) : Qt.vector3d(1.2, 1.2, 1.2) - } - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNode2DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNode2DImageView.qml deleted file mode 100644 index a1714e87c9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNode2DImageView.qml +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.15 - -Item { - id: root - width: 150 - height: 150 - - property alias contentItem: contentItem - - /* - View3D { - // Dummy view to hold the context in case View3D items are used in the component - // TODO remove when QTBUG-87678 is fixed - } - */ - - Item { - id: contentItem - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNode3DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNode3DImageView.qml deleted file mode 100644 index 0e460621a1..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNode3DImageView.qml +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.15 -import QtQuick3D 1.15 - -Item { - id: root - width: 150 - height: 150 - visible: true - - property View3D view: null - property alias contentItem: contentItem - - property var previewObject - - property var materialViewComponent - property var modelViewComponent - property var nodeViewComponent - - property bool closeUp: false - - function destroyView() - { - previewObject = null; - if (view) - view.destroy(); - } - - function createViewForObject(obj, env, envValue, model) - { - if (obj instanceof Material) - createViewForMaterial(obj, env, envValue, model); - else if (obj instanceof Model) - createViewForModel(obj); - else if (obj instanceof Node) - createViewForNode(obj); - } - - function createViewForMaterial(material, env, envValue, model) - { - if (!materialViewComponent) - materialViewComponent = Qt.createComponent("MaterialNodeView.qml"); - - // Always recreate the view to ensure material is up to date - if (materialViewComponent.status === Component.Ready) { - view = materialViewComponent.createObject(viewRect, {"previewMaterial": material, - "envMode": env, - "envValue": envValue, - "modelSrc": model}); - } - previewObject = material; - } - - function createViewForModel(model) - { - if (!modelViewComponent) - modelViewComponent = Qt.createComponent("ModelNodeView.qml"); - - // Always recreate the view to ensure model is up to date - if (modelViewComponent.status === Component.Ready) - view = modelViewComponent.createObject(viewRect, {"sourceModel": model}); - - previewObject = model; - } - - function createViewForNode(node) - { - if (!nodeViewComponent) - nodeViewComponent = Qt.createComponent("NodeNodeView.qml"); - - // Always recreate the view to ensure node is up to date - if (nodeViewComponent.status === Component.Ready) - view = nodeViewComponent.createObject(viewRect, {"importScene": node}); - - previewObject = node; - } - - function fitToViewPort() - { - view.fitToViewPort(closeUp); - } - - // Enables/disables icon mode. When in icon mode, camera is zoomed bit closer to reduce margins - // and the background is removed, in order to generate a preview suitable for library icons. - function setIconMode(enable) - { - closeUp = enable; - backgroundRect.visible = !enable; - } - - View3D { - // Dummy view to hold the context - // TODO remove when QTBUG-87678 is fixed - } - - Item { - id: contentItem - anchors.fill: parent - - Item { - id: viewRect - anchors.fill: parent - } - - // We can use static image in Qt5 as only small previews will be generated - Image { - id: backgroundRect - anchors.fill: parent - z: -1 - source: "../images/static_floor.png" - fillMode: Image.Stretch - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNodeView.qml deleted file mode 100644 index aaf725129f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ModelNodeView.qml +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.15 -import QtQuick3D 1.15 - -View3D { - id: root - anchors.fill: parent - environment: sceneEnv - camera: theCamera - - property Model sourceModel - - function fitToViewPort(closeUp) - { - // The magic number is the distance from camera default pos to origin - _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, model, root, - 1040, closeUp); - } - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - } - - DirectionalLight { - eulerRotation.x: -30 - eulerRotation.y: -30 - } - - PerspectiveCamera { - id: theCamera - z: 600 - y: 600 - x: 600 - eulerRotation.x: -45 - eulerRotation.y: -45 - clipFar: 10000 - clipNear: 1 - } - - Model { - id: model - source: sourceModel.source - geometry: sourceModel.geometry - - materials: [ - DefaultMaterial { - diffuseColor: "#999999" - } - ] - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/MoveGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/MoveGizmo.qml deleted file mode 100644 index 76e57cccdb..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/MoveGizmo.qml +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Node { - id: moveGizmo - - property View3D view3D - property bool highlightOnHover: false - property Node targetNode: null - property bool globalOrientation: true - readonly property bool dragging: arrowX.dragging || arrowY.dragging || arrowZ.dragging - || planeX.dragging || planeY.dragging || planeZ.dragging - || centerBall.dragging - property MouseArea3D dragHelper: null - property alias freeDraggerArea: centerBall.mouseArea - - position: dragHelper.pivotScenePosition(targetNode) - - onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode) - - Connections { - target: moveGizmo.targetNode - function onSceneTransformChanged() - { - moveGizmo.position = moveGizmo.dragHelper.pivotScenePosition(moveGizmo.targetNode); - } - } - - signal positionCommit() - signal positionMove() - - Node { - rotation: globalOrientation || !moveGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) - : moveGizmo.targetNode.sceneRotation - Arrow { - id: arrowX - eulerRotation: Qt.vector3d(0, 0, -90) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - Arrow { - id: arrowY - eulerRotation: Qt.vector3d(0, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - Arrow { - id: arrowZ - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - PlanarMoveHandle { - id: planeX - - y: 10 - z: 10 - - eulerRotation: Qt.vector3d(0, 90, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - PlanarMoveHandle { - id: planeY - - x: 10 - z: 10 - - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - PlanarMoveHandle { - id: planeZ - - x: 10 - y: 10 - - eulerRotation: Qt.vector3d(0, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - } - - PlanarMoveHandle { - id: centerBall - - source: "#Sphere" - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1)) - : Qt.rgba(0.5, 0.5, 0.5, 1) - rotation: view3D.camera.rotation - priority: 10 - targetNode: moveGizmo.targetNode - - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/NodeNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/NodeNodeView.qml deleted file mode 100644 index 533af52c39..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/NodeNodeView.qml +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.15 -import QtQuick3D 1.15 - -View3D { - id: root - anchors.fill: parent - environment: sceneEnv - camera: theCamera - - function fitToViewPort(closeUp) - { - // The magic number is the distance from camera default pos to origin - _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, importScene, root, - 1040, closeUp); - } - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - } - - DirectionalLight { - eulerRotation.x: -30 - eulerRotation.y: -30 - } - - PerspectiveCamera { - id: theCamera - z: 600 - y: 600 - x: 600 - eulerRotation.x: -45 - eulerRotation.y: -45 - clipFar: 10000 - clipNear: 1 - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Overlay2D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Overlay2D.qml deleted file mode 100644 index ef59a7717c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/Overlay2D.qml +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -Item { - id: root - property Node targetNode - property View3D targetView - - property vector3d offset: Qt.vector3d(0, 0, 0) - - property bool isBehindCamera - - onTargetNodeChanged: updateOverlay() - - Connections { - target: targetNode - function onSceneTransformChanged() { updateOverlay() } - } - - Connections { - target: targetView.camera - function onSceneTransformChanged() { updateOverlay() } - } - - Connections { - target: _generalHelper - function onOverlayUpdateNeeded() { updateOverlay() } - } - - function updateOverlay() - { - var scenePos = targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0); - // Need separate variable as scenePos is reference to read-only property - var scenePosWithOffset = Qt.vector3d(scenePos.x + offset.x, - scenePos.y + offset.y, - scenePos.z + offset.z); - var viewPos = targetView ? targetView.mapFrom3DScene(scenePosWithOffset) - : Qt.vector3d(0, 0, 0); - root.x = viewPos.x; - root.y = viewPos.y; - - isBehindCamera = viewPos.z <= 0; - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarDraggable.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarDraggable.qml deleted file mode 100644 index 1ae75b2e81..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarDraggable.qml +++ /dev/null @@ -1,97 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Model { - id: rootModel - - property View3D view3D - property alias color: gizmoMaterial.diffuseColor - property alias priority: mouseArea.priority - property Node targetNode: null - property bool dragging: mouseArea.dragging - property bool active: false - property MouseArea3D dragHelper: null - property alias mouseArea: mouseArea - - readonly property bool hovering: mouseArea.hovering - - property vector3d _scenePosPressed - property vector2d _planePosPressed - property vector3d _targetStartPos - - signal pressed(var mouseArea) - signal dragged(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance) - signal released(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance) - - source: "#Rectangle" - - DefaultMaterial { - id: gizmoMaterial - diffuseColor: "white" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - materials: gizmoMaterial - - function handlePressed(mouseArea, planePos) - { - if (!targetNode) - return; - - _planePosPressed = planePos; - _scenePosPressed = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d()); - _targetStartPos = mouseArea.pivotScenePosition(targetNode); - pressed(mouseArea); - } - - function calcRelativeDistance(mouseArea, planePos) - { - var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d()); - return scenePointerPos.minus(_scenePosPressed); - } - - function handleDragged(mouseArea, planePos) - { - if (!targetNode) - return; - - dragged(mouseArea, calcRelativeDistance(mouseArea, planePos), - planePos.minus(_planePosPressed)); - } - - function handleReleased(mouseArea, planePos) - { - if (!targetNode) - return; - - released(mouseArea, calcRelativeDistance(mouseArea, planePos), - planePos.minus(_planePosPressed)); - } - - MouseArea3D { - id: mouseArea - view3D: rootModel.view3D - x: -60 - y: -60 - width: 120 - height: 120 - grabsMouse: targetNode - active: rootModel.active - dragHelper: rootModel.dragHelper - - onPressed: (planePos)=> { - rootModel.handlePressed(mouseArea, planePos); - } - onDragged: (planePos)=> { - rootModel.handleDragged(mouseArea, planePos); - } - onReleased: (planePos)=> { - rootModel.handleReleased(mouseArea, planePos); - } - } -} - diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarMoveHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarMoveHandle.qml deleted file mode 100644 index cb4ba367bc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarMoveHandle.qml +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -PlanarDraggable { - id: planarHandle - scale: Qt.vector3d(0.024, 0.024, 0.024) - - signal positionCommit() - signal positionMove() - - function localPos(sceneRelativeDistance) - { - var newScenePos = Qt.vector3d( - _targetStartPos.x + sceneRelativeDistance.x, - _targetStartPos.y + sceneRelativeDistance.y, - _targetStartPos.z + sceneRelativeDistance.z); - return targetNode.parent ? targetNode.parent.mapPositionFromScene(newScenePos) : newScenePos; - } - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - } - - onDragged: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(false); - positionMove(); - } - - onReleased: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(true); - positionCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarScaleHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarScaleHandle.qml deleted file mode 100644 index 3dd315989a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/PlanarScaleHandle.qml +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -PlanarDraggable { - id: planarHandle - scale: Qt.vector3d(0.024, 0.024, 0.024) - - property bool globalOrientation: false - property vector3d axisX - property vector3d axisY - - signal scaleCommit() - signal scaleChange() - - property vector3d _startScale - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - _startScale = targetNode.scale; - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, relativeDistance.times(scale.x), - axisX, axisY); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(false); - scaleChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, relativeDistance.times(scale.x), - axisX, axisY); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(true); - scaleCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/RotateGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/RotateGizmo.qml deleted file mode 100644 index b0457c4a97..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/RotateGizmo.qml +++ /dev/null @@ -1,271 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Node { - id: rotateGizmo - - property View3D view3D - property bool highlightOnHover: true - property Node targetNode: null - property bool globalOrientation: true - readonly property bool dragging: cameraRing.dragging - || rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging - property MouseArea3D dragHelper: null - property real currentAngle - property point currentMousePos - property alias freeDraggerArea: mouseAreaFree - property bool blocked: false - - position: dragHelper.pivotScenePosition(targetNode) - - onTargetNodeChanged: { - position = dragHelper.pivotScenePosition(targetNode); - blocked = _generalHelper.isRotationBlocked(targetNode); - } - - Connections { - target: rotateGizmo.targetNode - function onSceneTransformChanged() - { - rotateGizmo.position = dragHelper.pivotScenePosition(targetNode); - } - } - - Connections { - target: _generalHelper - function onRotationBlocksChanged() - { - blocked = _generalHelper.isRotationBlocked(targetNode); - } - } - - signal rotateCommit() - signal rotateChange() - - function copyRingProperties(srcRing) { - draggingRing.rotation = srcRing.sceneRotation; - draggingRing.color = srcRing.color; - draggingRing.scale = srcRing.scale; - } - - onDraggingChanged: { - if (rotRingX.dragging) - copyRingProperties(rotRingX) - else if (rotRingY.dragging) - copyRingProperties(rotRingY) - else if (rotRingZ.dragging) - copyRingProperties(rotRingZ) - } - - Node { - id: rotNode - rotation: globalOrientation || !rotateGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) - : rotateGizmo.targetNode.sceneRotation - visible: !rotateGizmo.dragging && !freeRotator.dragging - - RotateRing { - id: rotRingX - objectName: "Rotate Ring X" - eulerRotation: Qt.vector3d(0, 90, 0) - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) : Qt.rgba(1, 0, 0, 1) - priority: 40 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - - RotateRing { - id: rotRingY - objectName: "Rotate Ring Y" - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) : Qt.rgba(0, 0.6, 0, 1) - // Just a smidge smaller than higher priority rings so that it doesn't obscure them - scale: Qt.vector3d(0.998, 0.998, 0.998) - priority: 30 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - - RotateRing { - id: rotRingZ - objectName: "Rotate Ring Z" - eulerRotation: Qt.vector3d(0, 0, 0) - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) : Qt.rgba(0, 0, 1, 1) - // Just a smidge smaller than higher priority rings so that it doesn't obscure them - scale: Qt.vector3d(0.996, 0.996, 0.996) - priority: 20 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - } - - RotateRing { - // This ring is used as visual proxy during dragging to display the currently dragged - // plane in static position, as rotation planes can wobble when ancestors don't have - // uniform scaling. - // Camera ring doesn't need dragging proxy as it doesn't wobble. - id: draggingRing - objectName: "draggingRing" - targetNode: rotateGizmo.targetNode - view3D: rotateGizmo.view3D - active: false - visible: rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging - } - - RotateRing { - id: cameraRing - objectName: "cameraRing" - rotation: rotateGizmo.view3D.camera.rotation - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1)) - : Qt.rgba(0.5, 0.5, 0.5, 1) - scale: Qt.vector3d(1.1, 1.1, 1.1) - priority: 10 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - visible: !rotRingX.dragging && !rotRingY.dragging && !rotRingZ.dragging && !freeRotator.dragging - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - - Model { - id: freeRotator - - source: "#Sphere" - materials: DefaultMaterial { - id: material - diffuseColor: "black" - opacity: mouseAreaFree.hovering && !rotateGizmo.blocked ? 0.15 : 0 - lighting: DefaultMaterial.NoLighting - } - scale: Qt.vector3d(0.15, 0.15, 0.15) - visible: !rotateGizmo.dragging && !dragging - - property bool dragging: false - property vector3d _pointerPosPressed - property vector3d _startRotation - - function handlePressed(screenPos) - { - if (!rotateGizmo.targetNode) - return; - - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - - // Need to recreate vector as we need to adjust it and we can't do that on reference of - // scenePosition, which is read-only property - var scenePos = rotateGizmo.dragHelper.pivotScenePosition(rotateGizmo.targetNode); - _pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0); - - // Recreate vector so we don't follow the changes in targetNode.rotation - _startRotation = Qt.vector3d(rotateGizmo.targetNode.eulerRotation.x, - rotateGizmo.targetNode.eulerRotation.y, - rotateGizmo.targetNode.eulerRotation.z); - // Ensure we never set NaN values for rotation, even if target node originally has them - if (isNaN(_startRotation.x)) - _startRotation.x = 0; - if (isNaN(_startRotation.y)) - _startRotation.y = 0; - if (isNaN(_startRotation.z)) - _startRotation.z = 0; - - dragging = true; - } - - function handleDragged(screenPos) - { - if (!rotateGizmo.targetNode) - return; - - mouseAreaFree.applyFreeRotation( - rotateGizmo.targetNode, _startRotation, _pointerPosPressed, - Qt.vector3d(screenPos.x, screenPos.y, 0)); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(false); - - rotateGizmo.rotateChange(); - } - - function handleReleased(screenPos) - { - if (!rotateGizmo.targetNode) - return; - - mouseAreaFree.applyFreeRotation( - rotateGizmo.targetNode, _startRotation, _pointerPosPressed, - Qt.vector3d(screenPos.x, screenPos.y, 0)); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(true); - - rotateGizmo.rotateCommit(); - dragging = false; - - if (targetNode == multiSelectionNode) - _generalHelper.resetMultiSelectionNode(); - } - - MouseArea3D { - id: mouseAreaFree - view3D: rotateGizmo.view3D - rotation: rotateGizmo.view3D.camera.rotation - objectName: "Free rotator plane" - x: -50 - y: -50 - width: 100 - height: 100 - circlePickArea: Qt.point(25, 50) - grabsMouse: rotateGizmo.targetNode - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onPressed: (planePos, screenPos)=> { - freeRotator.handlePressed(screenPos); - } - onDragged: (planePos, screenPos)=> { - freeRotator.handleDragged(screenPos); - } - onReleased: (planePos, screenPos)=> { - freeRotator.handleReleased(screenPos); - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/RotateRing.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/RotateRing.qml deleted file mode 100644 index 2f898e0d8a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/RotateRing.qml +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Model { - id: rotateRing - - property View3D view3D - property alias color: material.diffuseColor - property Node targetNode: null - property bool dragging: mouseAreaMain.dragging - property bool active: false - property alias hovering: mouseAreaMain.hovering - property alias priority: mouseAreaMain.priority - property real currentAngle - property point currentMousePos - property MouseArea3D dragHelper: null - - property vector3d _pointerPosPressed - property vector3d _targetPosOnScreen - property vector3d _startRotation - property bool _trackBall - - signal rotateCommit() - signal rotateChange() - - source: "../meshes/ring.mesh" - - Model { - id: pickModel - objectName: "PickModel for " + rotateRing.objectName - source: "../meshes/ringselect.mesh" - pickable: true - } - - materials: DefaultMaterial { - id: material - diffuseColor: "white" - lighting: DefaultMaterial.NoLighting - } - - function applyLocalRotation(screenPos) - { - currentAngle = mouseAreaMain.dragHelper.getNewRotationAngle( - targetNode, _pointerPosPressed, Qt.vector3d(screenPos.x, screenPos.y, 0), - _targetPosOnScreen, currentAngle, _trackBall); - mouseAreaMain.dragHelper.applyRotationAngleToNode(targetNode, _startRotation, currentAngle); - } - - function handlePressed(screenPos, angle) - { - if (!targetNode) - return; - - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - - // Need to recreate vector as we need to adjust it and we can't do that on reference of - // scenePosition, which is read-only property - var scenePos = mouseAreaMain.pivotScenePosition(targetNode); - - _targetPosOnScreen = view3D.mapFrom3DScene(scenePos); - _targetPosOnScreen.z = 0; - _pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0); - _trackBall = angle < 0.1; - - // Recreate vector so we don't follow the changes in targetNode.eulerRotation - _startRotation = Qt.vector3d(targetNode.eulerRotation.x, - targetNode.eulerRotation.y, - targetNode.eulerRotation.z); - // Ensure we never set NaN values for rotation, even if target node originally has them - if (isNaN(_startRotation.x)) - _startRotation.x = 0; - if (isNaN(_startRotation.y)) - _startRotation.y = 0; - if (isNaN(_startRotation.z)) - _startRotation.z = 0; - currentAngle = 0; - currentMousePos = screenPos; - } - - function handleDragged(screenPos) - { - if (!targetNode) - return; - - applyLocalRotation(screenPos); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(false); - - currentMousePos = screenPos; - rotateChange(); - } - - function handleReleased(screenPos) - { - if (!targetNode) - return; - - applyLocalRotation(screenPos); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(true); - - rotateCommit(); - currentAngle = 0; - currentMousePos = screenPos; - - if (targetNode == multiSelectionNode) - _generalHelper.resetMultiSelectionNode(); - } - - MouseArea3D { - id: mouseAreaMain - view3D: rotateRing.view3D - objectName: "Main plane of " + rotateRing.objectName - x: -30 - y: -30 - width: 60 - height: 60 - circlePickArea: Qt.point(9.2, 1.4) - grabsMouse: targetNode - active: rotateRing.active - pickNode: pickModel - minAngle: 0.05 - dragHelper: rotateRing.dragHelper - - onPressed: (planePos, screenPos, angle)=> { - rotateRing.handlePressed(screenPos, angle); - } - onDragged: (planePos, screenPos)=> { - rotateRing.handleDragged(screenPos); - } - onReleased: (planePos, screenPos)=> { - rotateRing.handleReleased(screenPos); - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ScaleGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ScaleGizmo.qml deleted file mode 100644 index cafb0088e3..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ScaleGizmo.qml +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -Node { - id: scaleGizmo - - property View3D view3D - property bool highlightOnHover: false - property Node targetNode: null - readonly property bool dragging: scaleRodX.dragging || scaleRodY.dragging || scaleRodZ.dragging - || planeX.dragging || planeY.dragging || planeZ.dragging - || centerMouseArea.dragging - property MouseArea3D dragHelper: null - property alias freeDraggerArea: centerMouseArea - - position: dragHelper.pivotScenePosition(targetNode) - - onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode) - - Connections { - target: scaleGizmo.targetNode - function onSceneTransformChanged() - { - scaleGizmo.position = scaleGizmo.dragHelper.pivotScenePosition(scaleGizmo.targetNode); - } - } - - signal scaleCommit() - signal scaleChange() - - Node { - rotation: !targetNode ? Qt.quaternion(1, 0, 0, 0) : targetNode.sceneRotation - - ScaleRod { - id: scaleRodX - eulerRotation: Qt.vector3d(0, 0, -90) - axis: Qt.vector3d(1, 0, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - ScaleRod { - id: scaleRodY - eulerRotation: Qt.vector3d(0, 0, 0) - axis: Qt.vector3d(0, 1, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - ScaleRod { - id: scaleRodZ - eulerRotation: Qt.vector3d(90, 0, 0) - axis: Qt.vector3d(0, 0, 1) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - PlanarScaleHandle { - id: planeX - - y: 10 - z: 10 - - eulerRotation: Qt.vector3d(0, 90, 0) - axisX: Qt.vector3d(0, 0, -1) - axisY: Qt.vector3d(0, 1, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - PlanarScaleHandle { - id: planeY - - x: 10 - z: 10 - - eulerRotation: Qt.vector3d(90, 0, 0) - axisX: Qt.vector3d(1, 0, 0) - axisY: Qt.vector3d(0, 0, 1) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - PlanarScaleHandle { - id: planeZ - - x: 10 - y: 10 - - eulerRotation: Qt.vector3d(0, 0, 0) - axisX: Qt.vector3d(1, 0, 0) - axisY: Qt.vector3d(0, 1, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - } - - Model { - id: centerCube - - source: "#Cube" - scale: Qt.vector3d(0.024, 0.024, 0.024) - materials: DefaultMaterial { - id: material - diffuseColor: highlightOnHover - && (centerMouseArea.hovering || centerMouseArea.dragging) - ? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1)) - : Qt.rgba(0.5, 0.5, 0.5, 1) - lighting: DefaultMaterial.NoLighting - } - - MouseArea3D { - id: centerMouseArea - view3D: scaleGizmo.view3D - x: -60 - y: -60 - width: 120 - height: 120 - rotation: view3D.camera.rotation - grabsMouse: scaleGizmo.targetNode - priority: 10 - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - property vector3d _startScale - property point _startScreenPos - - function localScale(screenPos) - { - var yDelta = screenPos.y - _startScreenPos.y; - if (yDelta === 0) - return _startScale; - var scaler = 1.0 + (yDelta * 0.025); - if (scaler === 0) - scaler = 0.0001; - return Qt.vector3d(scaler * _startScale.x, - scaler * _startScale.y, - scaler * _startScale.z); - } - - onPressed: (planePos, screenPos)=> { - if (!scaleGizmo.targetNode) - return; - - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - - // Recreate vector so we don't follow the changes in targetNode.scale - _startScale = Qt.vector3d(scaleGizmo.targetNode.scale.x, - scaleGizmo.targetNode.scale.y, - scaleGizmo.targetNode.scale.z); - _startScreenPos = screenPos; - } - onDragged: (planePos, screenPos)=> { - if (!scaleGizmo.targetNode) - return; - scaleGizmo.targetNode.scale = localScale(screenPos); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(false); - scaleGizmo.scaleChange(); - } - onReleased: (planePos, screenPos)=> { - if (!scaleGizmo.targetNode) - return; - - scaleGizmo.targetNode.scale = localScale(screenPos); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(true); - scaleGizmo.scaleCommit(); - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ScaleRod.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ScaleRod.qml deleted file mode 100644 index f13aee9706..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/ScaleRod.qml +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import MouseArea3D 1.0 - -DirectionalDraggable { - id: scaleRod - source: "../meshes/scalerod.mesh" - - property vector3d axis - - signal scaleCommit() - signal scaleChange() - - property vector3d _startScale - - Model { - source: "#Cube" - y: 10 - scale: Qt.vector3d(0.020, 0.020, 0.020) - materials: DefaultMaterial { - id: material - diffuseColor: scaleRod.color - lighting: DefaultMaterial.NoLighting - } - } - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - _startScale = targetNode.scale; - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, Qt.vector2d(relativeDistance, 0), - axis, Qt.vector3d(0, 0, 0)); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(false); - scaleChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, Qt.vector2d(relativeDistance, 0), - axis, Qt.vector3d(0, 0, 0)); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(true); - scaleCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml deleted file mode 100644 index 103c787f8e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SceneView3D.qml +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick3D 1.15 - -View3D { - id: sceneView - anchors.fill: parent - - property bool usePerspective: false - property alias showSceneLight: sceneLight.visible - property alias showGrid: helperGrid.visible - property alias gridColor: helperGrid.gridColor - property alias sceneHelpers: sceneHelpers - property alias perspectiveCamera: scenePerspectiveCamera - property alias orthoCamera: sceneOrthoCamera - property double cameraZoomFactor: .55; - - // Empirical cameraZoomFactor values at which the grid zoom level is doubled. The values are - // approximately uniformally distributed over the non-linear range of cameraZoomFactor. - readonly property var grid_thresholds: [0.55, 1.10, 2.35, 4.9, 10.0, 20.5, 42.0, 85.0, 999999.0] - property var thresIdx: 1 - property var thresPerc: 1.0 // percentage of cameraZoomFactor to the current grid zoom threshold (0.0 - 1.0) - - camera: usePerspective ? scenePerspectiveCamera : sceneOrthoCamera - - onCameraZoomFactorChanged: { - thresIdx = Math.max(1, grid_thresholds.findIndex(v => v > cameraZoomFactor)); - thresPerc = (grid_thresholds[thresIdx] - cameraZoomFactor) / (grid_thresholds[thresIdx] - grid_thresholds[thresIdx - 1]); - } - - Node { - id: sceneHelpers - - HelperGrid { - id: helperGrid - lines: Math.pow(2, grid_thresholds.length - thresIdx - 1); - step: 100 * grid_thresholds[0] * Math.pow(2, thresIdx - 1); - subdivAlpha: thresPerc; - } - - PointLight { - id: sceneLight - position: usePerspective ? scenePerspectiveCamera.position - : sceneOrthoCamera.position - quadraticFade: 0 - linearFade: 0 - } - - // Initial camera position and rotation should be such that they look at origin. - // Otherwise EditCameraController._lookAtPoint needs to be initialized to correct - // point. - PerspectiveCamera { - id: scenePerspectiveCamera - z: 600 - y: 600 - eulerRotation.x: -45 - clipFar: 100000 - clipNear: 1 - } - - OrthographicCamera { - id: sceneOrthoCamera - z: 600 - y: 600 - eulerRotation.x: -45 - clipFar: 100000 - clipNear: -10000 - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SelectionBox.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SelectionBox.qml deleted file mode 100644 index 9fe071d91a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SelectionBox.qml +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 -import SelectionBoxGeometry 1.0 - -Node { - id: selectionBox - - property View3D view3D - property Node targetNode: null - property alias model: selectionBoxModel - property alias geometryName: selectionBoxGeometry.name - - SelectionBoxGeometry { - id: selectionBoxGeometry - name: "Selection Box of 3D Edit View" - view3D: selectionBox.view3D - targetNode: selectionBox.targetNode - rootNode: selectionBox - } - - Model { - id: selectionBoxModel - geometry: selectionBoxGeometry - - scale: selectionBox.targetNode ? selectionBox.targetNode.scale : Qt.vector3d(1, 1, 1) - rotation: selectionBox.targetNode ? selectionBox.targetNode.rotation : Qt.quaternion(1, 0, 0, 0) - position: selectionBox.targetNode ? selectionBox.targetNode.position : Qt.vector3d(0, 0, 0) - pivot: selectionBox.targetNode ? selectionBox.targetNode.pivot : Qt.vector3d(0, 0, 0) - - visible: selectionBox.targetNode && !selectionBoxGeometry.isEmpty - - castsShadows: false - receivesShadows: false - - materials: [ - DefaultMaterial { - diffuseColor: "#fff600" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SpotLightHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SpotLightHandle.qml deleted file mode 100644 index 95e486c5f4..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt5/SpotLightHandle.qml +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 2.0 -import QtQuick3D 1.15 - -DirectionalDraggable { - id: handleRoot - - property string currentLabel - property point currentMousePos - property string propName - property real propValue: 0 - property real newValue: 0 - - scale: autoScaler.getScale(Qt.vector3d(5, 5, 5)) - length: 3 - offset: -1.5 - - Model { - id: handle - source: "#Sphere" - materials: [ handleRoot.material ] - scale: Qt.vector3d(0.02, 0.02, 0.02) - } - - AutoScaleHelper { - id: autoScaler - active: handleRoot.active - view3D: handleRoot.view3D - } - - property real _startAngle - - signal valueCommit() - signal valueChange() - - function updateAngle(relativeDistance, screenPos) - { - handleRoot.newValue = Math.round(Math.min(180, Math.max(0, _startAngle + relativeDistance))); - var l = Qt.locale(); - handleRoot.currentLabel = propName + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 0); - handleRoot.currentMousePos = screenPos; - } - - onPressed: (mouseArea, screenPos)=> { - _startAngle = propValue; - updateAngle(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateAngle(relativeDistance, screenPos); - handleRoot.valueChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateAngle(relativeDistance, screenPos); - handleRoot.valueCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AdjustableArrow.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AdjustableArrow.qml deleted file mode 100644 index 164c0a8404..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AdjustableArrow.qml +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import LineGeometry 1.0 - -DirectionalDraggable { - id: arrowRoot - - Model { - readonly property bool _edit3dLocked: true // Make this non-pickable - geometry: LineGeometry { - id: lineGeometry - name: "Edit 3D ScalableArrow" - startPos: Qt.vector3d(0, 0, 0) - endPos: Qt.vector3d(0, 1, 0) - } - scale: Qt.vector3d(1, arrowRoot.length, 1) - materials: [ arrowRoot.material ] - } - - Model { - id: arrowHead - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Cone" - materials: [ arrowRoot.material ] - y: arrowRoot.length - 3 - scale: Qt.vector3d(0.02, 0.035, 0.02) - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AreaLightHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AreaLightHandle.qml deleted file mode 100644 index 80117b84e4..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AreaLightHandle.qml +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -DirectionalDraggable { - id: handleRoot - - property string currentLabel - property point currentMousePos - property string propName - property real propValue: 0 - property real newValue: 0 - property real baseScale: 5 - - scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale)) - length: 3 - offset: -1.5 - - Model { - id: handle - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Sphere" - materials: [ handleRoot.material ] - scale: Qt.vector3d(0.02, 0.02, 0.02) - } - - AutoScaleHelper { - id: autoScaler - active: handleRoot.active - view3D: handleRoot.view3D - } - - property real _startValue - property real _startScale - - signal valueCommit() - signal valueChange() - - function updateValue(relativeDistance, screenPos) - { - handleRoot.newValue = Math.round(Math.min(999999, Math.max(0, _startValue + (relativeDistance * _startScale)))); - var l = Qt.locale(); - handleRoot.currentLabel = propName + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 0); - handleRoot.currentMousePos = screenPos; - } - - onPressed: (mouseArea, screenPos)=> { - _startScale = autoScaler.relativeScale * baseScale; - _startValue = propValue; - updateValue(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateValue(relativeDistance, screenPos); - handleRoot.valueChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateValue(relativeDistance, screenPos); - handleRoot.valueCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Arrow.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Arrow.qml deleted file mode 100644 index cfa01df830..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Arrow.qml +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -DirectionalDraggable { - id: arrow - source: "../meshes/arrow.mesh" - - signal positionCommit() - signal positionMove() - - function localPos(sceneRelativeDistance) - { - var newScenePos = Qt.vector3d( - _targetStartPos.x + sceneRelativeDistance.x, - _targetStartPos.y + sceneRelativeDistance.y, - _targetStartPos.z + sceneRelativeDistance.z); - return targetNode.parent ? targetNode.parent.mapPositionFromScene(newScenePos) : newScenePos; - } - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - } - - onDragged: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(false); - positionMove(); - } - - onReleased: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(true); - positionCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AutoScaleHelper.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AutoScaleHelper.qml deleted file mode 100644 index 08a2082575..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AutoScaleHelper.qml +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Node { - id: overlayNode - - property View3D view3D - property Camera camera: view3D.camera - property bool active: true - - // Read-only - property real relativeScale: 1 - - onActiveChanged: updateScale() - onSceneTransformChanged: updateScale() - // Trigger delayed update on camera change to ensure camera values are correct - onCameraChanged: _generalHelper.requestOverlayUpdate(); - - Connections { - target: camera - function onSceneTransformChanged() { updateScale() } - } - - Connections { - target: _generalHelper - function onOverlayUpdateNeeded() { updateScale() } - } - - function getScale(baseScale) - { - return Qt.vector3d(baseScale.x * relativeScale, baseScale.y * relativeScale, - baseScale.z * relativeScale); - } - - function updateScale() - { - if (active) - relativeScale = helper.getRelativeScale(overlayNode); - else - relativeScale = 1; - } - - MouseArea3D { - id: helper - active: false - view3D: overlayNode.view3D - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AxisHelper.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AxisHelper.qml deleted file mode 100644 index fc2951c732..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AxisHelper.qml +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -View3D { - id: axisHelperView - - property var editCameraCtrl - property Node selectedNode - - camera: axisHelperCamera - - Node { - OrthographicCamera { - id: axisHelperCamera - rotation: editCameraCtrl.camera ? editCameraCtrl.camera.rotation : Qt.quaternion(1, 0, 0, 0) - position: editCameraCtrl.camera ? editCameraCtrl.camera.position.minus(editCameraCtrl._lookAtPoint) - .normalized().times(600) : Qt.vector3d(0, 0, 0) - } - - AutoScaleHelper { - id: autoScale - view3D: axisHelperView - position: axisHelperGizmo.scenePosition - } - - Node { - id: axisHelperGizmo - scale: autoScale.getScale(Qt.vector3d(4, 4, 4)) - - AxisHelperArm { - id: armX - eulerRotation: Qt.vector3d(0, 0, -90) - color: Qt.rgba(1, 0, 0, 1) - hoverColor: Qt.lighter(Qt.rgba(1, 0, 0, 1)) - view3D: axisHelperView - camRotPos: Qt.vector3d(0, 90, 0) - camRotNeg: Qt.vector3d(0, -90, 0) - } - - AxisHelperArm { - id: armY - eulerRotation: Qt.vector3d(0, 0, 0) - color: Qt.rgba(0, 0.6, 0, 1) - hoverColor: Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - view3D: axisHelperView - camRotPos: Qt.vector3d(-90, 0, 0) - camRotNeg: Qt.vector3d(90, 0, 0) - } - - AxisHelperArm { - id: armZ - eulerRotation: Qt.vector3d(90, 0, 0) - color: Qt.rgba(0, 0, 1, 1) - hoverColor: Qt.lighter(Qt.rgba(0, 0, 1, 1)) - view3D: axisHelperView - camRotPos: Qt.vector3d(0, 0, 0) - camRotNeg: Qt.vector3d(0, 180, 0) - } - } - } - - MouseArea { - anchors.fill: parent - hoverEnabled: true - acceptedButtons: Qt.LeftButton - - property var pickObj: null - - function cancelHover() - { - if (pickObj) { - pickObj.hovering = false; - pickObj = null; - } - } - - function pick(mouse) - { - var result = axisHelperView.pick(mouse.x, mouse.y); - if (result.objectHit) { - if (result.objectHit !== pickObj) { - cancelHover(); - pickObj = result.objectHit; - pickObj.hovering = true; - } - } else { - cancelHover(); - } - } - - onPositionChanged: (mouse)=> { - pick(mouse); - } - - onPressed: (mouse)=> { - pick(mouse); - if (pickObj) { - axisHelperView.editCameraCtrl.focusObject(axisHelperView.selectedNode, - pickObj.cameraRotation, false, false); - } else { - mouse.accepted = false; - } - } - - onExited: cancelHover() - onCanceled: cancelHover() - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AxisHelperArm.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AxisHelperArm.qml deleted file mode 100644 index f8f6e19692..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/AxisHelperArm.qml +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -Node { - id: armRoot - property alias posModel: posModel - property alias negModel: negModel - property View3D view3D - property color hoverColor - property color color - property vector3d camRotPos - property vector3d camRotNeg - - Model { - id: posModel - - property bool hovering: false - property vector3d cameraRotation: armRoot.camRotPos - - source: "../meshes/axishelper.mesh" - materials: DefaultMaterial { - id: posMat - diffuseColor: posModel.hovering ? armRoot.hoverColor : armRoot.color - lighting: DefaultMaterial.NoLighting - } - pickable: true - } - - Model { - id: negModel - - property bool hovering: false - property vector3d cameraRotation: armRoot.camRotNeg - - source: "#Sphere" - y: -6 - scale: Qt.vector3d(0.025, 0.025, 0.025) - materials: DefaultMaterial { - id: negMat - diffuseColor: negModel.hovering ? armRoot.hoverColor : armRoot.color - lighting: DefaultMaterial.NoLighting - } - pickable: true - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/CameraFrustum.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/CameraFrustum.qml deleted file mode 100644 index b7b536477b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/CameraFrustum.qml +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import CameraGeometry 1.0 - -Model { - id: cameraFrustum - - property alias geometryName: cameraGeometry.name // Name must be unique for each geometry - property alias viewPortRect: cameraGeometry.viewPortRect - property Node targetNode: null - property Node scene: null - property bool selected: false - readonly property bool _edit3dLocked: true // Make this non-pickable - - function updateGeometry() - { - cameraGeometry.update(); - } - - position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0) - rotation: targetNode ? targetNode.sceneRotation : Qt.quaternion(1, 0, 0, 0) - - geometry: cameraGeometry - materials: [ - DefaultMaterial { - id: defaultMaterial - diffuseColor: cameraFrustum.selected ? "#FF0000" : "#555555" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - - CameraGeometry { - id: cameraGeometry - camera: cameraFrustum.scene && cameraFrustum.targetNode ? cameraFrustum.targetNode : null - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/CameraGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/CameraGizmo.qml deleted file mode 100644 index 21195cfadd..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/CameraGizmo.qml +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -IconGizmo { - id: cameraGizmo - - property Model frustumModel: null - property bool globalShowFrustum: false - - iconSource: "qrc:///qtquickplugin/mockfiles/images/editor_camera.png" - - function connectFrustum(frustum) - { - frustumModel = frustum; - - frustum.selected = selected; - frustum.selected = Qt.binding(function() {return selected;}); - - frustum.scene = scene; - frustum.scene = Qt.binding(function() {return scene;}); - - frustum.targetNode = targetNode; - frustum.targetNode = Qt.binding(function() {return targetNode;}); - - frustum.visible = (canBeVisible && globalShowFrustum) - || (targetNode && selected && activeScene === scene); - frustum.visible = Qt.binding(function() { - return (canBeVisible && globalShowFrustum) - || (targetNode && selected && activeScene === scene); - }); - } - - onActiveSceneChanged: { - if (frustumModel && activeScene == scene) - frustumModel.updateGeometry(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/DirectionalDraggable.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/DirectionalDraggable.qml deleted file mode 100644 index be4997a3d5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/DirectionalDraggable.qml +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Model { - id: rootModel - - property View3D view3D - property alias color: material.diffuseColor - property Node targetNode: null - property bool dragging: mouseAreaYZ.dragging || mouseAreaXZ.dragging - property bool active: false - property MouseArea3D dragHelper: null - property alias material: material - property real length: 12 - property real offset: 0 - - readonly property bool hovering: mouseAreaYZ.hovering || mouseAreaXZ.hovering - readonly property bool _edit3dLocked: true // Make this non-pickable - - property vector3d _scenePosPressed - property real _posPressed - property vector3d _targetStartPos - - signal pressed(var mouseArea, point screenPos) - signal dragged(var mouseArea, vector3d sceneRelativeDistance, real relativeDistance, point screenPos) - signal released(var mouseArea, vector3d sceneRelativeDistance, real relativeDistance, point screenPos) - - DefaultMaterial { - id: material - diffuseColor: "white" - lighting: DefaultMaterial.NoLighting - } - - materials: [ material ] - - function handlePressed(mouseArea, planePos, screenPos) - { - if (!targetNode) - return; - - var maskedPosition = Qt.vector3d(planePos.x, 0, 0); - _posPressed = planePos.x; - _scenePosPressed = mouseArea.dragHelper.mapPositionToScene(maskedPosition); - _targetStartPos = mouseArea.pivotScenePosition(targetNode); - pressed(mouseArea, screenPos); - } - - function calcRelativeDistance(mouseArea, planePos) - { - var maskedPosition = Qt.vector3d(planePos.x, 0, 0); - var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(maskedPosition); - return scenePointerPos.minus(_scenePosPressed); - } - - function handleDragged(mouseArea, planePos, screenPos) - { - if (!targetNode) - return; - - dragged(mouseArea, calcRelativeDistance(mouseArea, planePos), planePos.x - _posPressed, screenPos); - } - - function handleReleased(mouseArea, planePos, screenPos) - { - if (!targetNode) - return; - - released(mouseArea, calcRelativeDistance(mouseArea, planePos), planePos.x - _posPressed, screenPos); - } - - MouseArea3D { - id: mouseAreaYZ - view3D: rootModel.view3D - x: rootModel.offset - y: -1.5 - width: rootModel.length - height: 3 - eulerRotation: Qt.vector3d(0, 0, 90) - grabsMouse: targetNode - active: rootModel.active - dragHelper: rootModel.dragHelper - priority: 5 - - onPressed: (planePos, screenPos)=> { - rootModel.handlePressed(mouseAreaYZ, planePos, screenPos); - } - onDragged: (planePos, screenPos)=> { - rootModel.handleDragged(mouseAreaYZ, planePos, screenPos); - } - onReleased: (planePos, screenPos)=> { - rootModel.handleReleased(mouseAreaYZ, planePos, screenPos); - } - } - - MouseArea3D { - id: mouseAreaXZ - view3D: rootModel.view3D - x: rootModel.offset - y: -1.5 - width: rootModel.length - height: 3 - eulerRotation: Qt.vector3d(0, 90, 90) - grabsMouse: targetNode - active: rootModel.active - dragHelper: rootModel.dragHelper - priority: 5 - - onPressed: (planePos, screenPos)=> { - rootModel.handlePressed(mouseAreaXZ, planePos, screenPos); - } - onDragged: (planePos, screenPos)=> { - rootModel.handleDragged(mouseAreaXZ, planePos, screenPos); - } - onReleased: (planePos, screenPos)=> { - rootModel.handleReleased(mouseAreaXZ, planePos, screenPos); - } - } -} - diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditCameraController.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditCameraController.qml deleted file mode 100644 index aa15aedb29..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditCameraController.qml +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -Item { - id: cameraCtrl - - property Camera camera: null - property View3D view3d: null - property string sceneId - property vector3d _lookAtPoint - property vector3d _pressPoint - property vector3d _prevPoint - property vector3d _startRotation - property vector3d _startPosition - property vector3d _startLookAtPoint - property matrix4x4 _startTransform - property bool _dragging - property int _button - property real _zoomFactor: 1 - property Camera _prevCamera: null - readonly property vector3d _defaultCameraPosition: Qt.vector3d(0, 600, 600) - readonly property vector3d _defaultCameraRotation: Qt.vector3d(-45, 0, 0) - readonly property real _defaultCameraLookAtDistance: _defaultCameraPosition.length() - readonly property real _keyPanAmount: 5 - property bool ignoreToolState: false - - function restoreCameraState(cameraState) - { - if (!camera || ignoreToolState) - return; - - _lookAtPoint = cameraState[0]; - _zoomFactor = cameraState[1]; - camera.position = cameraState[2]; - camera.rotation = cameraState[3]; - _generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - _zoomFactor, false); - } - - function restoreDefaultState() - { - if (!camera) - return; - - _lookAtPoint = Qt.vector3d(0, 0, 0); - _zoomFactor = 1; - camera.position = _defaultCameraPosition; - camera.eulerRotation = _defaultCameraRotation; - _generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - _zoomFactor, false); - } - - function storeCameraState(delay) - { - if (!camera || ignoreToolState) - return; - - var cameraState = []; - cameraState[0] = _lookAtPoint; - cameraState[1] = _zoomFactor; - cameraState[2] = camera.position; - cameraState[3] = camera.rotation; - _generalHelper.storeToolState(sceneId, "editCamState", cameraState, delay); - } - - - function focusObject(targetNodes, rotation, updateZoom, closeUp) - { - if (!camera) - return; - - // targetNodes could be a list of nodes or a single node - var nodes = []; - if (targetNodes instanceof Node) - nodes.push(targetNodes); - else - nodes = targetNodes - - camera.eulerRotation = rotation; - var newLookAtAndZoom = _generalHelper.focusNodesToCamera( - camera, _defaultCameraLookAtDistance, nodes, view3d, _zoomFactor, - updateZoom, closeUp); - _lookAtPoint = newLookAtAndZoom.toVector3d(); - _zoomFactor = newLookAtAndZoom.w; - storeCameraState(0); - } - - function alignCameras(targetNodes) - { - if (!camera) - return; - - // targetNodes could be a list of nodes or a single node - var nodes = []; - if (targetNodes instanceof Node) - nodes.push(targetNodes); - else - nodes = targetNodes - - _generalHelper.alignCameras(camera, nodes); - } - - function alignView(targetNodes) - { - if (!camera) - return; - - // targetNodes could be a list of nodes or a single node - var nodes = []; - if (targetNodes instanceof Node) - nodes.push(targetNodes); - else - nodes = targetNodes - - _lookAtPoint = _generalHelper.alignView(camera, nodes, _lookAtPoint); - storeCameraState(0); - } - - function zoomRelative(distance) - { - if (!camera) - return; - - _zoomFactor = _generalHelper.zoomCamera(view3d, camera, distance, _defaultCameraLookAtDistance, - _lookAtPoint, _zoomFactor, true); - } - - onCameraChanged: { - if (camera && _prevCamera) { - // Reset zoom on previous camera to ensure it's properties are good to copy to new cam - _generalHelper.zoomCamera(view3d, _prevCamera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - 1, false); - - camera.position = _prevCamera.position; - camera.rotation = _prevCamera.rotation; - - // Apply correct zoom to new camera - _generalHelper.zoomCamera(view3d, camera, 0, _defaultCameraLookAtDistance, _lookAtPoint, - _zoomFactor, false); - } - _prevCamera = camera; - } - - MouseArea { - id: mouseHandler - acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton - hoverEnabled: false - anchors.fill: parent - onPositionChanged: (mouse)=> { - if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier && cameraCtrl._dragging) { - var currentPoint = Qt.vector3d(mouse.x, mouse.y, 0); - if (cameraCtrl._button == Qt.LeftButton) { - _generalHelper.orbitCamera(cameraCtrl.camera, cameraCtrl._startRotation, - cameraCtrl._lookAtPoint, cameraCtrl._pressPoint, - currentPoint); - } else if (cameraCtrl._button == Qt.MiddleButton) { - cameraCtrl._lookAtPoint = _generalHelper.panCamera( - cameraCtrl.camera, cameraCtrl._startTransform, - cameraCtrl._startPosition, cameraCtrl._startLookAtPoint, - cameraCtrl._pressPoint, currentPoint, _zoomFactor); - } else if (cameraCtrl._button == Qt.RightButton) { - cameraCtrl.zoomRelative(currentPoint.y - cameraCtrl._prevPoint.y) - cameraCtrl._prevPoint = currentPoint; - } - } - } - onPressed: (mouse)=> { - if (cameraCtrl.camera && mouse.modifiers === Qt.AltModifier) { - cameraCtrl._dragging = true; - cameraCtrl._startRotation = cameraCtrl.camera.eulerRotation; - cameraCtrl._startPosition = cameraCtrl.camera.position; - cameraCtrl._startLookAtPoint = _lookAtPoint; - cameraCtrl._pressPoint = Qt.vector3d(mouse.x, mouse.y, 0); - cameraCtrl._prevPoint = cameraCtrl._pressPoint; - cameraCtrl._button = mouse.button; - cameraCtrl._startTransform = cameraCtrl.camera.sceneTransform; - } else { - mouse.accepted = false; - } - } - - function handleRelease() { - cameraCtrl._dragging = false; - cameraCtrl.storeCameraState(0); - } - - onReleased: handleRelease() - onCanceled: handleRelease() - - onWheel: (wheel)=> { - if (cameraCtrl.camera) { - // Empirically determined divisor for nice zoom - cameraCtrl.zoomRelative(wheel.angleDelta.y / -40); - cameraCtrl.storeCameraState(500); - } - } - } - - Keys.onPressed: (event)=> { - var pressPoint = Qt.vector3d(view3d.width / 2, view3d.height / 2, 0); - var currentPoint; - - switch (event.key) { - case Qt.Key_Left: - currentPoint = pressPoint.plus(Qt.vector3d(_keyPanAmount, 0, 0)); - break; - case Qt.Key_Right: - currentPoint = pressPoint.plus(Qt.vector3d(-_keyPanAmount, 0, 0)); - break; - case Qt.Key_Up: - currentPoint = pressPoint.plus(Qt.vector3d(0, _keyPanAmount, 0)); - break; - case Qt.Key_Down: - currentPoint = pressPoint.plus(Qt.vector3d(0, -_keyPanAmount, 0)); - break; - default: - break; - } - - if (currentPoint) { - _lookAtPoint = _generalHelper.panCamera( - camera, cameraCtrl.camera.sceneTransform, - cameraCtrl.camera.position, _lookAtPoint, - pressPoint, currentPoint, _zoomFactor); - event.accepted = true; - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml deleted file mode 100644 index 915feea4f2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/EditView3D.qml +++ /dev/null @@ -1,1139 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Item { - id: viewRoot - width: 1024 - height: 768 - visible: true - - property Node activeScene: null - property View3D editView: null - property string sceneId - - property bool showEditLight: false - property bool showGrid: true - property bool showSelectionBox: true - property bool showIconGizmo: true - property bool showCameraFrustum: false - property bool showParticleEmitter: false - property bool usePerspective: true - property bool globalOrientation: false - property alias contentItem: contentItem - property color backgroundGradientColorStart: "#222222" - property color backgroundGradientColorEnd: "#999999" - property color gridColor: "#aaaaaa" - property bool syncBackgroundColor: false - - enum SelectionMode { Item, Group } - enum TransformMode { Move, Rotate, Scale } - - property int selectionMode: EditView3D.SelectionMode.Item - property int transformMode: EditView3D.TransformMode.Move - - property Node selectedNode: null // This is multiSelectionNode in multi-selection case - property var selectedNodes: [] // All selected nodes - - property var lightIconGizmos: [] - property var cameraGizmos: [] - property var particleSystemIconGizmos: [] - property var particleEmitterGizmos: [] - property var selectionBoxes: [] - property rect viewPortRect: Qt.rect(0, 0, 1000, 1000) - property Node activeParticleSystem: null - property bool shuttingDown: false - - property real fps: 0 - - signal selectionChanged(var selectedNodes) - signal commitObjectProperty(var objects, var propNames) - signal changeObjectProperty(var objects, var propNames) - signal notifyActiveSceneChange() - - onUsePerspectiveChanged: _generalHelper.storeToolState(sceneId, "usePerspective", usePerspective) - onShowEditLightChanged: _generalHelper.storeToolState(sceneId, "showEditLight", showEditLight) - onGlobalOrientationChanged: _generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation) - onShowGridChanged: _generalHelper.storeToolState(sceneId, "showGrid", showGrid); - onSyncBackgroundColorChanged: _generalHelper.storeToolState(sceneId, "syncBackgroundColor", syncBackgroundColor); - onShowSelectionBoxChanged: _generalHelper.storeToolState(sceneId, "showSelectionBox", showSelectionBox); - onShowIconGizmoChanged: _generalHelper.storeToolState(sceneId, "showIconGizmo", showIconGizmo); - onShowCameraFrustumChanged: _generalHelper.storeToolState(sceneId, "showCameraFrustum", showCameraFrustum); - onShowParticleEmitterChanged: _generalHelper.storeToolState(sceneId, "showParticleEmitter", showParticleEmitter); - onSelectionModeChanged: _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode); - onTransformModeChanged: _generalHelper.storeToolState(sceneId, "transformMode", transformMode); - - onActiveSceneChanged: updateActiveScene() - - function aboutToShutDown() - { - shuttingDown = true; - } - - function createEditView() - { - var component = Qt.createComponent("SceneView3D.qml"); - if (component.status === Component.Ready) { - editView = component.createObject(viewRect, - {"usePerspective": usePerspective, - "showSceneLight": showEditLight, - "showGrid": showGrid, - "gridColor": gridColor, - "importScene": activeScene, - "cameraZoomFactor": cameraControl._zoomFactor, - "z": 1}); - editView.usePerspective = Qt.binding(function() {return usePerspective;}); - editView.showSceneLight = Qt.binding(function() {return showEditLight;}); - editView.showGrid = Qt.binding(function() {return showGrid;}); - editView.gridColor = Qt.binding(function() {return gridColor;}); - editView.cameraZoomFactor = Qt.binding(function() {return cameraControl._zoomFactor;}); - - selectionBoxes.length = 0; - cameraControl.forceActiveFocus(); - return true; - } - return false; - } - - function updateActiveScene() - { - if (editView) { - editView.visible = false; - editView.destroy(); - } - - // importScene cannot be updated after initial set, so we need to reconstruct entire View3D - if (createEditView()) { - if (activeScene) { - var toolStates = _generalHelper.getToolStates(sceneId); - if (Object.keys(toolStates).length > 0) { - updateToolStates(toolStates, true); - } else { - // Don't inherit the edit light state from the previous scene, but rather - // turn the edit light on for scenes that do not have any scene - // lights, and turn it off for scenes that have. - var hasSceneLight = false; - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].scene === activeScene) { - hasSceneLight = true; - break; - } - } - showEditLight = !hasSceneLight; - storeCurrentToolStates(); - } - } else { - // When active scene is deleted, this function gets called by object deletion - // handlers without going through setActiveScene, so make sure sceneId is cleared. - // This is skipped during application shutdown, as calling QQuickText::setText() - // during application shutdown can crash the application. - if (!shuttingDown) { - sceneId = ""; - storeCurrentToolStates(); - } - } - - notifyActiveSceneChange(); - } - } - - function setActiveScene(newScene, newSceneId) - { - var needExplicitUpdate = !activeScene && !newScene; - - sceneId = newSceneId; - activeScene = newScene; - - if (needExplicitUpdate) - updateActiveScene(); - } - - function handleActiveSceneIdChange(newId) - { - if (sceneId !== newId) { - sceneId = newId; - storeCurrentToolStates(); - } - } - - function fitToView() - { - if (editView) { - var boxModels = []; - if (selectedNodes.length > 1) { - for (var i = 0; i < selectedNodes.length; ++i) { - if (selectionBoxes.length > i) - boxModels.push(selectionBoxes[i].model) - } - } else if (selectedNodes.length > 0 && selectionBoxes.length > 0) { - boxModels.push(selectionBoxes[0].model); - } - cameraControl.focusObject(boxModels, editView.camera.eulerRotation, true, false); - } - } - - function alignCamerasToView() - { - if (editView) { - cameraControl.alignCameras(selectedNodes); - var propertyNames = ["position", "eulerRotation"]; - viewRoot.changeObjectProperty(selectedNodes, propertyNames); - viewRoot.commitObjectProperty(selectedNodes, propertyNames); - } - } - - function alignViewToCamera() - { - if (editView) - cameraControl.alignView(selectedNodes); - } - - function updateViewStates(viewStates) - { - if ("selectBackgroundColor" in viewStates) { - if (Array.isArray(viewStates.selectBackgroundColor)) { - var colors = viewStates.selectBackgroundColor - backgroundGradientColorStart = colors[0]; - backgroundGradientColorEnd = colors[1]; - } else { - var color = viewStates.selectBackgroundColor - backgroundGradientColorStart = color; - backgroundGradientColorEnd = color; - } - } - - if ("selectGridColor" in viewStates) - viewRoot.gridColor = viewStates.selectGridColor - } - - // If resetToDefault is true, tool states not specifically set to anything will be reset to - // their default state. - function updateToolStates(toolStates, resetToDefault) - { - if ("showEditLight" in toolStates) - showEditLight = toolStates.showEditLight; - else if (resetToDefault) - showEditLight = false; - - if ("showGrid" in toolStates) - showGrid = toolStates.showGrid; - else if (resetToDefault) - showGrid = true; - - if ("syncBackgroundColor" in toolStates) { - syncBackgroundColor = toolStates.syncBackgroundColor; - if (syncBackgroundColor) { - var color = _generalHelper.sceneEnvironmentColor(sceneId); - updateViewStates({"selectBackgroundColor": color}) - } - } else if (resetToDefault) { - syncBackgroundColor = false; - } - - if ("showSelectionBox" in toolStates) - showSelectionBox = toolStates.showSelectionBox; - else if (resetToDefault) - showSelectionBox = true; - - if ("showIconGizmo" in toolStates) - showIconGizmo = toolStates.showIconGizmo; - else if (resetToDefault) - showIconGizmo = true; - - if ("showCameraFrustum" in toolStates) - showCameraFrustum = toolStates.showCameraFrustum; - else if (resetToDefault) - showCameraFrustum = false; - - if ("showParticleEmitter" in toolStates) - showParticleEmitter = toolStates.showParticleEmitter; - else if (resetToDefault) - showParticleEmitter = false; - - if ("usePerspective" in toolStates) - usePerspective = toolStates.usePerspective; - else if (resetToDefault) - usePerspective = true; - - if ("globalOrientation" in toolStates) - globalOrientation = toolStates.globalOrientation; - else if (resetToDefault) - globalOrientation = false; - - if ("selectionMode" in toolStates) - selectionMode = toolStates.selectionMode; - else if (resetToDefault) - selectionMode = EditView3D.SelectionMode.Item; - - if ("transformMode" in toolStates) - transformMode = toolStates.transformMode; - else if (resetToDefault) - transformMode = EditView3D.TransformMode.Move; - - if ("editCamState" in toolStates) - cameraControl.restoreCameraState(toolStates.editCamState); - else if (resetToDefault) - cameraControl.restoreDefaultState(); - } - - function storeCurrentToolStates() - { - _generalHelper.storeToolState(sceneId, "showEditLight", showEditLight) - _generalHelper.storeToolState(sceneId, "showGrid", showGrid) - _generalHelper.storeToolState(sceneId, "syncBackgroundColor", syncBackgroundColor) - _generalHelper.storeToolState(sceneId, "showSelectionBox", showSelectionBox) - _generalHelper.storeToolState(sceneId, "showIconGizmo", showIconGizmo) - _generalHelper.storeToolState(sceneId, "showCameraFrustum", showCameraFrustum) - _generalHelper.storeToolState(sceneId, "showParticleEmitter", showParticleEmitter) - _generalHelper.storeToolState(sceneId, "usePerspective", usePerspective) - _generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation) - _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode); - _generalHelper.storeToolState(sceneId, "transformMode", transformMode); - - cameraControl.storeCameraState(0); - } - - function ensureSelectionBoxes(count) - { - var needMore = count - selectionBoxes.length - if (needMore > 0) { - var component = Qt.createComponent("SelectionBox.qml"); - if (component.status === Component.Ready) { - for (var i = 0; i < needMore; ++i) { - var geometryName = _generalHelper.generateUniqueName("SelectionBoxGeometry"); - var boxParent = null; - if (editView) - boxParent = editView.sceneHelpers; - var box = component.createObject(boxParent, {"view3D": editView, - "geometryName": geometryName}); - selectionBoxes[selectionBoxes.length] = box; - box.view3D = Qt.binding(function() {return editView;}); - box.visible = Qt.binding(function() {return showSelectionBox;}); - } - } - } - } - - function selectObjects(objects) - { - // Create selection boxes as necessary. One more box than is actually needed is created, so - // that we always have a previously created box to use for new selection. - // This fixes an occasional visual glitch when creating a new box. - ensureSelectionBoxes(objects.length + 1) - - var i; - for (i = 0; i < objects.length; ++i) - selectionBoxes[i].targetNode = objects[i]; - for (i = objects.length; i < selectionBoxes.length; ++i) - selectionBoxes[i].targetNode = null; - - selectedNodes = objects; - if (objects.length === 0) { - selectedNode = null; - } else if (objects.length > 1) { - selectedNode = multiSelectionNode; - _generalHelper.setMultiSelectionTargets(multiSelectionNode, objects); - } else { - selectedNode = objects[0]; - } - } - - function handleObjectClicked(object, button, multi) - { - if (object instanceof View3D) { - // View3D can be the resolved pick target in case the 3D editor is showing content - // of a component that has View3D as root. In that case locking is resolved on C++ side - // and we ignore multiselection. - selectObjects([]); - selectionChanged([object]); - return; - } - - var clickedObject; - - // Click on locked object is treated same as click on empty space - if (!_generalHelper.isLocked(object)) - clickedObject = object; - - if (selectionMode === EditView3D.SelectionMode.Group) { - while (clickedObject && clickedObject !== activeScene - && (activeScene instanceof Model || clickedObject.parent !== activeScene)) { - clickedObject = clickedObject.parent; - } - } - // Object selection logic: - // Regular click: Clear any multiselection, single-selects the clicked object - // Ctrl-click: No objects selected: Act as single select - // One or more objects selected: Multiselect - // Null object always clears entire selection - var newSelection = []; - if (clickedObject) { - if (button === Qt.RightButton) { - // Right-clicking does only single selection (when clickedObject is unselected) - // This is needed for selecting a target for the context menu - if (!selectedNodes.includes(clickedObject)) - newSelection[0] = clickedObject; - else - newSelection = selectedNodes; - } else if (multi && selectedNodes.length > 0) { - var deselect = false; - for (var i = 0; i < selectedNodes.length; ++i) { - // Multiselecting already selected object clears that object from selection - if (selectedNodes[i] !== clickedObject) - newSelection[newSelection.length] = selectedNodes[i]; - else - deselect = true; - } - if (!deselect) - newSelection[newSelection.length] = clickedObject; - } else { - newSelection[0] = clickedObject; - } - } - selectObjects(newSelection); - selectionChanged(newSelection); - } - - function addLightGizmo(scene, obj) - { - // Insert into first available gizmo if we don't already have gizmo for this object - var slotFound = -1; - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (!lightIconGizmos[i].targetNode) { - slotFound = i; - } else if (lightIconGizmos[i].targetNode === obj) { - lightIconGizmos[i].scene = scene; - return; - } - } - - if (slotFound !== -1) { - lightIconGizmos[slotFound].scene = scene; - lightIconGizmos[slotFound].targetNode = obj; - lightIconGizmos[slotFound].locked = _generalHelper.isLocked(obj); - lightIconGizmos[slotFound].hidden = _generalHelper.isHidden(obj); - return; - } - - // No free gizmos available, create a new one - var gizmoComponent = Qt.createComponent("LightIconGizmo.qml"); - if (gizmoComponent.status === Component.Ready) { - var gizmo = gizmoComponent.createObject(overlayView, - {"view3D": overlayView, "targetNode": obj, - "selectedNodes": selectedNodes, "scene": scene, - "activeScene": activeScene, - "locked": _generalHelper.isLocked(obj), - "hidden": _generalHelper.isHidden(obj), - "globalShow": showIconGizmo}); - lightIconGizmos[lightIconGizmos.length] = gizmo; - gizmo.clicked.connect(handleObjectClicked); - gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); - gizmo.activeScene = Qt.binding(function() {return activeScene;}); - gizmo.globalShow = Qt.binding(function() {return showIconGizmo;}); - } - } - - function addCameraGizmo(scene, obj) - { - // Insert into first available gizmo if we don't already have gizmo for this object - var slotFound = -1; - for (var i = 0; i < cameraGizmos.length; ++i) { - if (!cameraGizmos[i].targetNode) { - slotFound = i; - } else if (cameraGizmos[i].targetNode === obj) { - cameraGizmos[i].scene = scene; - return; - } - } - - if (slotFound !== -1) { - cameraGizmos[slotFound].scene = scene; - cameraGizmos[slotFound].targetNode = obj; - cameraGizmos[slotFound].locked = _generalHelper.isLocked(obj); - cameraGizmos[slotFound].hidden = _generalHelper.isHidden(obj); - return; - } - - // No free gizmos available, create a new one - var gizmoComponent = Qt.createComponent("CameraGizmo.qml"); - var frustumComponent = Qt.createComponent("CameraFrustum.qml"); - if (gizmoComponent.status === Component.Ready && frustumComponent.status === Component.Ready) { - var geometryName = _generalHelper.generateUniqueName("CameraGeometry"); - var frustum = frustumComponent.createObject( - overlayScene, - {"geometryName": geometryName, "viewPortRect": viewPortRect}); - var gizmo = gizmoComponent.createObject( - overlayView, - {"view3D": overlayView, "targetNode": obj, - "selectedNodes": selectedNodes, "scene": scene, "activeScene": activeScene, - "locked": _generalHelper.isLocked(obj), "hidden": _generalHelper.isHidden(obj), - "globalShow": showIconGizmo, "globalShowFrustum": showCameraFrustum}); - - cameraGizmos[cameraGizmos.length] = gizmo; - gizmo.clicked.connect(handleObjectClicked); - gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); - gizmo.activeScene = Qt.binding(function() {return activeScene;}); - gizmo.globalShow = Qt.binding(function() {return showIconGizmo;}); - gizmo.globalShowFrustum = Qt.binding(function() {return showCameraFrustum;}); - frustum.viewPortRect = Qt.binding(function() {return viewPortRect;}); - gizmo.connectFrustum(frustum); - } - } - - function addParticleSystemGizmo(scene, obj) - { - // Insert into first available gizmo if we don't already have gizmo for this object - var slotFound = -1; - for (var i = 0; i < particleSystemIconGizmos.length; ++i) { - if (!particleSystemIconGizmos[i].targetNode) { - slotFound = i; - } else if (particleSystemIconGizmos[i].targetNode === obj) { - particleSystemIconGizmos[i].scene = scene; - return; - } - } - - if (slotFound !== -1) { - particleSystemIconGizmos[slotFound].scene = scene; - particleSystemIconGizmos[slotFound].targetNode = obj; - particleSystemIconGizmos[slotFound].locked = _generalHelper.isLocked(obj); - particleSystemIconGizmos[slotFound].hidden = _generalHelper.isHidden(obj); - return; - } - - // No free gizmos available, create a new one - var gizmoComponent = Qt.createComponent("ParticleSystemGizmo.qml"); - if (gizmoComponent.status === Component.Ready) { - var gizmo = gizmoComponent.createObject(overlayView, - {"view3D": overlayView, "targetNode": obj, - "selectedNodes": selectedNodes, "scene": scene, - "activeScene": activeScene, - "locked": _generalHelper.isLocked(obj), - "hidden": _generalHelper.isHidden(obj), - "globalShow": showIconGizmo, - "activeParticleSystem": activeParticleSystem}); - particleSystemIconGizmos[particleSystemIconGizmos.length] = gizmo; - gizmo.clicked.connect(handleObjectClicked); - gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); - gizmo.activeScene = Qt.binding(function() {return activeScene;}); - gizmo.globalShow = Qt.binding(function() {return showIconGizmo;}); - gizmo.activeParticleSystem = Qt.binding(function() {return activeParticleSystem;}); - } - } - - function addParticleEmitterGizmo(scene, obj) - { - // Insert into first available gizmo if we don't already have gizmo for this object - var slotFound = -1; - for (var i = 0; i < particleEmitterGizmos.length; ++i) { - if (!particleEmitterGizmos[i].targetNode) { - slotFound = i; - } else if (particleEmitterGizmos[i].targetNode === obj) { - particleEmitterGizmos[i].scene = scene; - return; - } - } - - if (slotFound !== -1) { - particleEmitterGizmos[slotFound].scene = scene; - particleEmitterGizmos[slotFound].targetNode = obj; - particleEmitterGizmos[slotFound].hidden = _generalHelper.isHidden(obj); - particleEmitterGizmos[slotFound].systemHidden = _generalHelper.isHidden(obj.system); - return; - } - - // No free gizmos available, create a new one - var gizmoComponent = Qt.createComponent("ParticleEmitterGizmo.qml"); - if (gizmoComponent.status === Component.Ready) { - var gizmo = gizmoComponent.createObject( - overlayScene, - {"targetNode": obj, "selectedNodes": selectedNodes, - "activeParticleSystem": activeParticleSystem, "scene": scene, - "activeScene": activeScene, "hidden": _generalHelper.isHidden(obj), - "systemHidden": _generalHelper.isHidden(obj.system), - "globalShow": showParticleEmitter}); - - particleEmitterGizmos[particleEmitterGizmos.length] = gizmo; - gizmo.selectedNodes = Qt.binding(function() {return selectedNodes;}); - gizmo.activeParticleSystem = Qt.binding(function() {return activeParticleSystem;}); - gizmo.globalShow = Qt.binding(function() {return showParticleEmitter;}); - gizmo.activeScene = Qt.binding(function() {return activeScene;}); - } - } - - function releaseLightGizmo(obj) - { - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === obj) { - lightIconGizmos[i].scene = null; - lightIconGizmos[i].targetNode = null; - return; - } - } - } - - function releaseCameraGizmo(obj) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === obj) { - cameraGizmos[i].scene = null; - cameraGizmos[i].targetNode = null; - return; - } - } - } - - function releaseParticleSystemGizmo(obj) - { - for (var i = 0; i < particleSystemIconGizmos.length; ++i) { - if (particleSystemIconGizmos[i].targetNode === obj) { - particleSystemIconGizmos[i].scene = null; - particleSystemIconGizmos[i].targetNode = null; - return; - } - } - } - - function releaseParticleEmitterGizmo(obj) - { - for (var i = 0; i < particleEmitterGizmos.length; ++i) { - if (particleEmitterGizmos[i].targetNode === obj) { - particleEmitterGizmos[i].scene = null; - particleEmitterGizmos[i].targetNode = null; - return; - } - } - } - - function updateLightGizmoScene(scene, obj) - { - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === obj) { - lightIconGizmos[i].scene = scene; - return; - } - } - } - - function updateCameraGizmoScene(scene, obj) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === obj) { - cameraGizmos[i].scene = scene; - return; - } - } - } - - function updateParticleSystemGizmoScene(scene, obj) - { - for (var i = 0; i < particleSystemIconGizmos.length; ++i) { - if (particleSystemIconGizmos[i].targetNode === obj) { - particleSystemIconGizmos[i].scene = scene; - return; - } - } - } - - function updateParticleEmitterGizmoScene(scene, obj) - { - for (var i = 0; i < particleEmitterGizmos.length; ++i) { - if (particleEmitterGizmos[i].targetNode === obj) { - particleEmitterGizmos[i].scene = scene; - return; - } - } - } - - function gizmoAt(x, y) - { - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].visible && lightIconGizmos[i].hasPoint(x, y)) - return lightIconGizmos[i].targetNode; - } - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].visible && cameraGizmos[i].hasPoint(x, y)) - return cameraGizmos[i].targetNode; - } - for (var i = 0; i < particleSystemIconGizmos.length; ++i) { - if (particleSystemIconGizmos[i].visible && particleSystemIconGizmos[i].hasPoint(x, y)) - return particleSystemIconGizmos[i].targetNode; - } - return null; - } - - Component.onCompleted: { - createEditView(); - selectObjects([]); - // Work-around the fact that the projection matrix for the camera is not calculated until - // the first frame is rendered, so any initial calls to mapFrom3DScene() will fail. - _generalHelper.requestOverlayUpdate(); - } - - onWidthChanged: _generalHelper.requestOverlayUpdate() - onHeightChanged: _generalHelper.requestOverlayUpdate() - - Connections { - target: _generalHelper - function onLockedStateChanged(node) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === node) { - cameraGizmos[i].locked = _generalHelper.isLocked(node); - return; - } - } - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === node) { - lightIconGizmos[i].locked = _generalHelper.isLocked(node); - return; - } - } - for (var i = 0; i < particleSystemIconGizmos.length; ++i) { - if (particleSystemIconGizmos[i].targetNode === node) { - particleSystemIconGizmos[i].locked = _generalHelper.isLocked(node); - return; - } - } - } - function onHiddenStateChanged(node) - { - for (var i = 0; i < cameraGizmos.length; ++i) { - if (cameraGizmos[i].targetNode === node) { - cameraGizmos[i].hidden = _generalHelper.isHidden(node); - return; - } - } - for (var i = 0; i < lightIconGizmos.length; ++i) { - if (lightIconGizmos[i].targetNode === node) { - lightIconGizmos[i].hidden = _generalHelper.isHidden(node); - return; - } - } - for (var i = 0; i < particleSystemIconGizmos.length; ++i) { - if (particleSystemIconGizmos[i].targetNode === node) { - particleSystemIconGizmos[i].hidden = _generalHelper.isHidden(node); - return; - } - } - for (var i = 0; i < particleEmitterGizmos.length; ++i) { - if (particleEmitterGizmos[i].targetNode === node) { - particleEmitterGizmos[i].hidden = _generalHelper.isHidden(node); - return; - } else if (particleEmitterGizmos[i].targetNode && particleEmitterGizmos[i].targetNode.system === node) { - particleEmitterGizmos[i].systemHidden = _generalHelper.isHidden(node); - return; - } - } - } - } - - Node { - id: overlayScene - - PerspectiveCamera { - id: overlayPerspectiveCamera - clipFar: viewRoot.editView ? viewRoot.editView.perspectiveCamera.clipFar : 1000 - clipNear: viewRoot.editView ? viewRoot.editView.perspectiveCamera.clipNear : 1 - position: viewRoot.editView ? viewRoot.editView.perspectiveCamera.position : Qt.vector3d(0, 0, 0) - rotation: viewRoot.editView ? viewRoot.editView.perspectiveCamera.rotation : Qt.quaternion(1, 0, 0, 0) - } - - OrthographicCamera { - id: overlayOrthoCamera - clipFar: viewRoot.editView ? viewRoot.editView.orthoCamera.clipFar : 1000 - clipNear: viewRoot.editView ? viewRoot.editView.orthoCamera.clipNear : 1 - position: viewRoot.editView ? viewRoot.editView.orthoCamera.position : Qt.vector3d(0, 0, 0) - rotation: viewRoot.editView ? viewRoot.editView.orthoCamera.rotation : Qt.quaternion(1, 0, 0, 0) - scale: viewRoot.editView ? viewRoot.editView.orthoCamera.scale : Qt.vector3d(0, 0, 0) - } - - MouseArea3D { - id: gizmoDragHelper - view3D: overlayView - } - - Node { - id: multiSelectionNode - objectName: "multiSelectionNode" - } - - MoveGizmo { - id: moveGizmo - scale: autoScale.getScale(Qt.vector3d(5, 5, 5)) - highlightOnHover: true - targetNode: viewRoot.selectedNode - globalOrientation: viewRoot.globalOrientation - visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Move - view3D: overlayView - dragHelper: gizmoDragHelper - property var propertyNames: ["position"] - - onPositionCommit: { - if (targetNode == multiSelectionNode) - viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNames); - else - viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames); - } - onPositionMove: { - if (targetNode == multiSelectionNode) - viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNames); - else - viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames); - } - } - - ScaleGizmo { - id: scaleGizmo - scale: autoScale.getScale(Qt.vector3d(5, 5, 5)) - highlightOnHover: true - targetNode: viewRoot.selectedNode - visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Scale - view3D: overlayView - dragHelper: gizmoDragHelper - property var propertyNames: ["scale"] - property var propertyNamesMulti: ["position", "scale"] - - onScaleCommit: { - if (targetNode == multiSelectionNode) - viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames); - } - onScaleChange: { - if (targetNode == multiSelectionNode) - viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames); - } - } - - RotateGizmo { - id: rotateGizmo - scale: autoScale.getScale(Qt.vector3d(7, 7, 7)) - highlightOnHover: true - targetNode: viewRoot.selectedNode - globalOrientation: viewRoot.globalOrientation - visible: viewRoot.selectedNode && transformMode === EditView3D.TransformMode.Rotate - view3D: overlayView - dragHelper: gizmoDragHelper - property var propertyNames: ["eulerRotation"] - property var propertyNamesMulti: ["position", "eulerRotation"] - - onRotateCommit: { - if (targetNode == multiSelectionNode) - viewRoot.commitObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.commitObjectProperty([viewRoot.selectedNode], propertyNames); - } - onRotateChange: { - if (targetNode == multiSelectionNode) - viewRoot.changeObjectProperty(_generalHelper.multiSelectionTargets(), propertyNamesMulti); - else - viewRoot.changeObjectProperty([viewRoot.selectedNode], propertyNames); - } - } - - LightGizmo { - id: lightGizmo - targetNode: viewRoot.selectedNode != multiSelectionNode ? viewRoot.selectedNode : null - view3D: overlayView - dragHelper: gizmoDragHelper - - onPropertyValueCommit: (propName) => { - viewRoot.commitObjectProperty([targetNode], [propName]); - } - onPropertyValueChange: (propName) => { - viewRoot.changeObjectProperty([targetNode], [propName]); - } - } - - AutoScaleHelper { - id: autoScale - view3D: overlayView - position: moveGizmo.scenePosition - } - - AutoScaleHelper { - id: pivotAutoScale - view3D: overlayView - position: pivotLine.startPos - } - - Line3D { - id: pivotLine - visible: viewRoot.selectedNode && viewRoot.selectedNode != multiSelectionNode - name: "3D Edit View Pivot Line" - color: "#ddd600" - - startPos: viewRoot.selectedNode ? viewRoot.selectedNode.scenePosition - : Qt.vector3d(0, 0, 0) - Connections { - target: viewRoot - function onSelectedNodeChanged() - { - pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode); - } - } - Connections { - target: viewRoot.selectedNode - function onSceneTransformChanged() - { - pivotLine.endPos = gizmoDragHelper.pivotScenePosition(viewRoot.selectedNode); - } - } - - Model { - id: pivotCap - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Sphere" - scale: pivotAutoScale.getScale(Qt.vector3d(0.03, 0.03, 0.03)) - position: pivotLine.startPos - materials: [ - DefaultMaterial { - id: lineMat - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - diffuseColor: pivotLine.color - } - ] - } - } - } - - Item { - id: contentItem - anchors.fill: parent - - Rectangle { - id: viewRect - anchors.fill: parent - - gradient: Gradient { - GradientStop { position: 1.0; color: backgroundGradientColorStart } - GradientStop { position: 0.0; color: backgroundGradientColorEnd } - } - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - hoverEnabled: false - - property MouseArea3D freeDraggerArea - property point pressPoint - property bool initialMoveBlock: false - - onPressed: (mouse) => { - if (viewRoot.editView) { - // First pick overlay to check for hits there - var pickResult = _generalHelper.pickViewAt(overlayView, mouse.x, mouse.y); - var resolvedResult = _generalHelper.resolvePick(pickResult.objectHit); - if (!resolvedResult) { - // No hits from overlay view, pick the main scene - pickResult = _generalHelper.pickViewAt(viewRoot.editView, mouse.x, mouse.y); - resolvedResult = _generalHelper.resolvePick(pickResult.objectHit); - } - - handleObjectClicked(resolvedResult, mouse.button, mouse.modifiers & Qt.ControlModifier); - - if (pickResult.objectHit && pickResult.objectHit instanceof Node) { - if (transformMode === EditView3D.TransformMode.Move) - freeDraggerArea = moveGizmo.freeDraggerArea; - else if (transformMode === EditView3D.TransformMode.Rotate) - freeDraggerArea = rotateGizmo.freeDraggerArea; - else if (transformMode === EditView3D.TransformMode.Scale) - freeDraggerArea = scaleGizmo.freeDraggerArea; - pressPoint.x = mouse.x; - pressPoint.y = mouse.y; - initialMoveBlock = true; - } else { - mouse.accepted = false; - } - } - } - onPositionChanged: (mouse) => { - if (freeDraggerArea) { - if (initialMoveBlock && Math.abs(pressPoint.x - mouse.x) + Math.abs(pressPoint.y - mouse.y) > 10) { - // Don't force press event at actual press, as that puts the gizmo - // in free-dragging state, which is bad UX if drag is not actually done - freeDraggerArea.forcePressEvent(pressPoint.x, pressPoint.y); - freeDraggerArea.forceMoveEvent(mouse.x, mouse.y); - initialMoveBlock = false; - } else { - freeDraggerArea.forceMoveEvent(mouse.x, mouse.y); - } - } - } - - function handleRelease(mouse) - { - if (freeDraggerArea) { - if (initialMoveBlock) - freeDraggerArea.forceReleaseEvent(pressPoint.x, pressPoint.y); - else - freeDraggerArea.forceReleaseEvent(mouse.x, mouse.y); - freeDraggerArea = null; - } - } - - onReleased: (mouse) => { - handleRelease(mouse); - } - onCanceled: (mouse) => { - handleRelease(mouse); - } - } - - DropArea { - anchors.fill: parent - } - - View3D { - id: overlayView - anchors.fill: parent - camera: viewRoot.usePerspective ? overlayPerspectiveCamera : overlayOrthoCamera - importScene: overlayScene - z: 2 - - environment: sceneEnv - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - } - } - - Overlay2D { - id: gizmoLabel - targetNode: moveGizmo.visible ? moveGizmo : scaleGizmo - targetView: overlayView - visible: targetNode.dragging - z: 3 - - Rectangle { - color: "white" - x: -width / 2 - y: -height - 8 - width: gizmoLabelText.width + 4 - height: gizmoLabelText.height + 4 - border.width: 1 - Text { - id: gizmoLabelText - text: { - // This is skipped during application shutdown, as calling QQuickText::setText() - // during application shutdown can crash the application. - if (shuttingDown) - return text; - var l = Qt.locale(); - var targetProperty; - if (viewRoot.selectedNode) { - if (gizmoLabel.targetNode === moveGizmo) - targetProperty = viewRoot.selectedNode.position; - else - targetProperty = viewRoot.selectedNode.scale; - return qsTr("x:") + Number(targetProperty.x).toLocaleString(l, 'f', 1) - + qsTr(" y:") + Number(targetProperty.y).toLocaleString(l, 'f', 1) - + qsTr(" z:") + Number(targetProperty.z).toLocaleString(l, 'f', 1); - } else { - return ""; - } - } - anchors.centerIn: parent - } - } - } - - Rectangle { - id: rotateGizmoLabel - color: "white" - x: rotateGizmo.currentMousePos.x - (10 + width) - y: rotateGizmo.currentMousePos.y - (10 + height) - width: rotateGizmoLabelText.width + 4 - height: rotateGizmoLabelText.height + 4 - border.width: 1 - visible: rotateGizmo.dragging - parent: rotateGizmo.view3D - z: 3 - - Text { - id: rotateGizmoLabelText - text: { - // This is skipped during application shutdown, as calling QQuickText::setText() - // during application shutdown can crash the application. - if (shuttingDown) - return text; - var l = Qt.locale(); - if (rotateGizmo.targetNode) { - var degrees = rotateGizmo.currentAngle * (180 / Math.PI); - return Number(degrees).toLocaleString(l, 'f', 1); - } else { - return ""; - } - } - anchors.centerIn: parent - } - } - - Rectangle { - id: lightGizmoLabel - color: "white" - x: lightGizmo.currentMousePos.x - (10 + width) - y: lightGizmo.currentMousePos.y - (10 + height) - width: lightGizmoLabelText.width + 4 - height: lightGizmoLabelText.height + 4 - border.width: 1 - visible: lightGizmo.dragging - parent: lightGizmo.view3D - z: 3 - - Text { - id: lightGizmoLabelText - text: lightGizmo.currentLabel - anchors.centerIn: parent - } - } - - EditCameraController { - id: cameraControl - camera: viewRoot.editView ? viewRoot.editView.camera : null - anchors.fill: parent - view3d: viewRoot.editView - sceneId: viewRoot.sceneId - } - } - - AxisHelper { - anchors.right: parent.right - anchors.top: parent.top - width: 100 - height: width - editCameraCtrl: cameraControl - selectedNode: viewRoot.selectedNodes.length === 1 ? viewRoot.selectionBoxes[0].model - : viewRoot.selectedNode - } - - Text { - id: sceneLabel - text: viewRoot.sceneId - anchors.top: parent.top - anchors.left: parent.left - anchors.margins: 4 - font.pixelSize: 14 - color: "white" - } - - Text { - id: fpsLabel - text: viewRoot.fps - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.margins: 4 - font.pixelSize: 12 - color: "white" - visible: viewRoot.fps > 0 - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/FadeHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/FadeHandle.qml deleted file mode 100644 index 9a3e9c4438..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/FadeHandle.qml +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -DirectionalDraggable { - id: handleRoot - - property string currentLabel - property point currentMousePos - property real fadeScale - property real baseScale: 5 - property real dragScale: 1 - - scale: autoScaler.getScale(Qt.vector3d(baseScale, baseScale, baseScale)) - length: 3 - offset: -1.5 - - Model { - id: handle - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Sphere" - materials: [ handleRoot.material ] - scale: Qt.vector3d(0.02, 0.02, 0.02) - } - - AutoScaleHelper { - id: autoScaler - active: handleRoot.active - view3D: handleRoot.view3D - } - - property real _q // quadratic fade - property real _l // linear fade - property real _c // constant fade - property real _d: 20 // Divisor from fadeScale calc in lightGizmo - property real _startScale - property real _startFadeScale - property string _currentProp - - signal valueCommit(string propName) - signal valueChange(string propName) - - function updateFade(relativeDistance, screenPos) - { - // Solved from fadeScale equation in LightGizmo - var newValue = 0; - var _x = Math.max(0, (_startFadeScale - (relativeDistance * _startScale)) / 100); - - // Fades capped to range 0-10 because property editor caps them to that range - if (_currentProp === "quadraticFade") { - if (_x === 0) - newValue = 10; - else - newValue = Math.max(0, Math.min(10, -(_c - _d + (_l * _x)) / (_x * _x))); - if (newValue < 0.01) - newValue = 0; // To avoid having tiny positive value when UI shows 0.00 - targetNode.quadraticFade = newValue; - } else if (_currentProp === "linearFade") { - if (_x === 0) - newValue = 10; - else - newValue = Math.max(0, Math.min(10, -(_c - _d) / _x)); - if (newValue < 0.01) - newValue = 0; // To avoid having tiny positive value when UI shows 0.00 - targetNode.linearFade = newValue; - } else { - // Since pure constant fade equates to infinitely long cone, fadeScale calc assumes - // linear fade of one in this case. - newValue = Math.max(0, Math.min(10, _d - _x)); - targetNode.constantFade = newValue; - } - - var l = Qt.locale(); - handleRoot.currentLabel = _currentProp + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 2); - handleRoot.currentMousePos = screenPos; - } - - onPressed: (mouseArea, screenPos)=> { - _startScale = autoScaler.relativeScale * baseScale * dragScale; - _startFadeScale = fadeScale; - _l = targetNode.linearFade; - _c = targetNode.constantFade; - _q = targetNode.quadraticFade; - if (targetNode.quadraticFade === 0) { - if (targetNode.linearFade === 0) { - _currentProp = "constantFade"; - } else { - _currentProp = "linearFade"; - } - } else { - _currentProp = "quadraticFade"; - } - updateFade(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateFade(relativeDistance, screenPos); - handleRoot.valueChange(_currentProp); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateFade(relativeDistance, screenPos); - handleRoot.valueCommit(_currentProp); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml deleted file mode 100644 index c76490dfe7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/HelperGrid.qml +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import GridGeometry 1.0 - -Node { - id: grid - - property alias lines: gridGeometry.lines - property alias step: gridGeometry.step - property alias subdivAlpha: subGridMaterial.opacity - property alias gridColor: mainGridMaterial.diffuseColor - - eulerRotation.x: 90 - - // Note: Only one instance of HelperGrid is supported, as the geometry names are fixed - - Model { // Main grid lines - readonly property bool _edit3dLocked: true // Make this non-pickable - castsShadows: false - receivesShadows: false - geometry: GridGeometry { - id: gridGeometry - name: "3D Edit View Helper Grid" - } - - materials: [ - DefaultMaterial { - id: mainGridMaterial - diffuseColor: "#aaaaaa" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } - - Model { // Subdivision lines - readonly property bool _edit3dLocked: true // Make this non-pickable - castsShadows: false - receivesShadows: false - geometry: GridGeometry { - lines: gridGeometry.lines - step: gridGeometry.step - isSubdivision: true - name: "3D Edit View Helper Grid subdivisions" - } - - materials: [ - DefaultMaterial { - id: subGridMaterial - diffuseColor: mainGridMaterial.diffuseColor - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } - - Model { // Z Axis - readonly property bool _edit3dLocked: true // Make this non-pickable - castsShadows: false - receivesShadows: false - geometry: GridGeometry { - lines: gridGeometry.lines - step: gridGeometry.step - isCenterLine: true - name: "3D Edit View Helper Grid Z Axis" - } - materials: [ - DefaultMaterial { - id: vCenterLineMaterial - diffuseColor: "#00a1d2" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } - Model { // X Axis - readonly property bool _edit3dLocked: true // Make this non-pickable - castsShadows: false - receivesShadows: false - eulerRotation.z: 90 - geometry: GridGeometry { - lines: gridGeometry.lines - step: gridGeometry.step - isCenterLine: true - name: "3D Edit View Helper Grid X Axis" - } - materials: [ - DefaultMaterial { - id: hCenterLineMaterial - diffuseColor: "#cb211a" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/IconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/IconGizmo.qml deleted file mode 100644 index 70ee9d51f1..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/IconGizmo.qml +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -Item { - id: iconGizmo - - property Node activeScene: null - property Node scene: null - property View3D view3D - property bool highlightOnHover: true - property Node targetNode: null - property var selectedNodes: [] - readonly property bool selected: { - for (var i = 0; i < selectedNodes.length; ++i) { - if (selectedNodes[i] === targetNode) - return true; - } - return false; - } - property bool hasMouse: false - property bool hidden: false - property bool locked: false - property bool globalShow: true - property bool canBeVisible: activeScene === scene && !hidden && (targetNode ? targetNode.visible : false) - property real iconOpacity: selected ? 0.2 : 1 - - property alias iconSource: iconImage.source - - signal clicked(Node node, bool multi) - - function hasPoint(x, y) - { - if (!view3D || !targetNode) - return false; - - var point = view3D.mapToItem(iconMouseArea, x, y); - - return point.x >= iconMouseArea.x && (point.x <= iconMouseArea.x + iconMouseArea.width) - && point.y >= iconMouseArea.y && (point.y <= iconMouseArea.y + iconMouseArea.height); - } - - onSelectedChanged: { - if (selected) - hasMouse = false; - } - - visible: canBeVisible && globalShow - - Overlay2D { - id: iconOverlay - targetNode: iconGizmo.targetNode - targetView: view3D - visible: iconGizmo.visible && !isBehindCamera - - Rectangle { - id: iconRect - - width: iconImage.width - height: iconImage.height - x: -width / 2 - y: -height / 2 - color: "transparent" - border.color: "#7777ff" - border.width: !iconGizmo.locked && iconGizmo.highlightOnHover && iconGizmo.hasMouse ? 2 : 0 - radius: 5 - opacity: iconGizmo.iconOpacity - Image { - id: iconImage - fillMode: Image.Pad - MouseArea { - id: iconMouseArea - anchors.fill: parent - onPressed: (mouse)=> { - // Ignore singleselection mouse presses when we have single object selected - // so that the icon gizmo doesn't hijack mouse clicks meant for other gizmos - if (iconGizmo.selected && !(mouse.modifiers & Qt.ControlModifier) - && selectedNodes.length === 1) { - mouse.accepted = false; - } - } - - onClicked: (mouse)=> { - iconGizmo.clicked(iconGizmo.targetNode, - mouse.modifiers & Qt.ControlModifier); - } - hoverEnabled: iconGizmo.highlightOnHover && !iconGizmo.selected - acceptedButtons: Qt.LeftButton - - // onPositionChanged, onContainsMouseAreaChanged, and hasMouse are used instead - // of just using containsMouse directly, because containsMouse - // cannot be relied upon to update correctly in some situations. - // This is likely because the overlapping 3D mouse areas of the gizmos get - // the mouse events instead of this area, so mouse leaving the area - // doesn't always update containsMouse property. - onPositionChanged: { - if (!iconGizmo.selected) - iconGizmo.hasMouse = containsMouse; - } - - onContainsMouseChanged: { - if (!iconGizmo.selected) - iconGizmo.hasMouse = containsMouse; - else - iconGizmo.hasMouse = false; - } - } - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightGizmo.qml deleted file mode 100644 index e8a25bb39d..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightGizmo.qml +++ /dev/null @@ -1,334 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 -import LightUtils 1.0 - -Node { - id: lightGizmo - - property View3D view3D - property Node targetNode: null - property MouseArea3D dragHelper: null - property color color: Qt.rgba(1, 1, 0, 1) - property real fadeScale: { - // Value indicates area where intensity is above certain percent of total brightness. - if (lightGizmo.targetNode instanceof SpotLight || lightGizmo.targetNode instanceof PointLight) { - var l = targetNode.linearFade; - var q = targetNode.quadraticFade; - var c = targetNode.constantFade; - var d = 20; // divisor to target intensity value. E.g. 20 = 1/20 = 5% - if (l === 0 && q === 0) - l = 1; // For pure constant fade, cone would be infinite, so pretend we have linear fade - // Solved from equation in shader: - // 1 / d = 1 / (c + (l + q * dist) * dist); - if (q === 0) - return 100 * Math.max(((d - c) / l), 1); - else - return 100 * ((Math.sqrt(4 * q * (d - c) + (l * l)) - l) / (2 * q)); - } else { - return 100; - } - } - readonly property bool dragging: primaryArrow.dragging - || spotLightHandle.dragging - || spotLightInnerHandle.dragging - || spotLightFadeHandle.dragging - || areaHeightHandle.dragging - || areaWidthHandle.dragging - || pointLightFadeHandle.dragging - property point currentMousePos - property string currentLabel - property int brightnessDecimals: _generalHelper.brightnessScaler() > 10. ? 0 : 2; - property real brightnessMultiplier: Math.pow(10, brightnessDecimals); - - signal propertyValueCommit(string propName) - signal propertyValueChange(string propName) - - position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0) - visible: lightGizmo.targetNode instanceof SpotLight - || lightGizmo.targetNode instanceof AreaLight - || lightGizmo.targetNode instanceof DirectionalLight - || lightGizmo.targetNode instanceof PointLight - - AutoScaleHelper { - id: autoScaler - view3D: lightGizmo.view3D - } - - Node { - id: pointLightParts - rotation: lightGizmo.view3D.camera.rotation - visible: lightGizmo.targetNode instanceof PointLight - - LightModel { - id: pointModel - geometryName: "Edit 3D PointLight" - geometryType: LightGeometry.Point - material: lightMaterial - scale: Qt.vector3d(lightGizmo.fadeScale, lightGizmo.fadeScale, lightGizmo.fadeScale) - } - - FadeHandle { - id: pointLightFadeHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof PointLight ? Qt.vector3d(-pointModel.scale.x, 0, 0) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(0, 0, -90) - targetNode: lightGizmo.targetNode instanceof PointLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof PointLight - dragHelper: lightGizmo.dragHelper - fadeScale: lightGizmo.fadeScale - - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: (propName)=> { - lightGizmo.propertyValueChange(propName); - } - onValueCommit: (propName)=> { - lightGizmo.propertyValueCommit(propName); - } - } - } - - - Node { - rotation: !lightGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) - : lightGizmo.targetNode.sceneRotation - - Node { - id: spotParts - visible: lightGizmo.targetNode instanceof SpotLight - - LightModel { - id: spotModel - - property real coneXYScale: spotParts.visible && lightGizmo.targetNode - ? lightGizmo.fadeScale * Math.tan(Math.PI * lightGizmo.targetNode.coneAngle / 180) - : 1 - - geometryName: "Edit 3D SpotLight Cone" - geometryType: LightGeometry.Spot - material: lightMaterial - scale: Qt.vector3d(coneXYScale, coneXYScale, - spotParts.visible && lightGizmo.targetNode && lightGizmo.targetNode.coneAngle > 90 - ? -lightGizmo.fadeScale : lightGizmo.fadeScale) - } - - LightModel { - id: spotInnerModel - - property real coneXYScale: spotParts.visible && lightGizmo.targetNode - ? lightGizmo.fadeScale * Math.tan(Math.PI * lightGizmo.targetNode.innerConeAngle / 180) - : 1 - - geometryName: "Edit 3D SpotLight Inner Cone" - geometryType: LightGeometry.Spot - material: lightMaterial - scale: Qt.vector3d(coneXYScale, coneXYScale, - spotParts.visible && lightGizmo.targetNode && lightGizmo.targetNode.innerConeAngle > 90 - ? -lightGizmo.fadeScale : lightGizmo.fadeScale) - } - - SpotLightHandle { - id: spotLightHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(0, spotModel.scale.y, -spotModel.scale.z) - : Qt.vector3d(0, 0, 0) - targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof SpotLight - dragHelper: lightGizmo.dragHelper - propName: "coneAngle" - propValue: lightGizmo.targetNode instanceof SpotLight ? targetNode.coneAngle : 0 - - onNewValueChanged: targetNode.coneAngle = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: { - if (targetNode.innerConeAngle > targetNode.coneAngle) - targetNode.innerConeAngle = targetNode.coneAngle; - lightGizmo.propertyValueCommit(propName) - lightGizmo.propertyValueCommit(spotLightInnerHandle.propName); - } - } - - SpotLightHandle { - id: spotLightInnerHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(0, -spotInnerModel.scale.y, -spotInnerModel.scale.z) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(180, 0, 0) - targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof SpotLight - dragHelper: lightGizmo.dragHelper - propName: "innerConeAngle" - propValue: lightGizmo.targetNode instanceof SpotLight ? targetNode.innerConeAngle : 0 - - onNewValueChanged: targetNode.innerConeAngle = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: { - if (targetNode.coneAngle < targetNode.innerConeAngle) - targetNode.coneAngle = targetNode.innerConeAngle; - lightGizmo.propertyValueCommit(propName) - lightGizmo.propertyValueCommit(spotLightHandle.propName); - } - } - - FadeHandle { - id: spotLightFadeHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof SpotLight ? Qt.vector3d(spotModel.scale.x / 2, 0, -spotInnerModel.scale.z / 2) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: lightGizmo.targetNode instanceof SpotLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof SpotLight - dragHelper: lightGizmo.dragHelper - fadeScale: lightGizmo.fadeScale - dragScale: 2 - - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: (propName)=> { - lightGizmo.propertyValueChange(propName); - } - onValueCommit: (propName)=> { - lightGizmo.propertyValueCommit(propName); - } - } - } - Node { - id: areaParts - visible: lightGizmo.targetNode instanceof AreaLight - - LightModel { - id: areaModel - geometryName: "Edit 3D AreaLight" - geometryType: LightGeometry.Area - material: lightMaterial - scale: areaParts.visible ? Qt.vector3d(lightGizmo.targetNode.width / 2, - lightGizmo.targetNode.height / 2, 1) - .times(lightGizmo.targetNode.scale) - : Qt.vector3d(1, 1, 1) - } - - AreaLightHandle { - id: areaWidthHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(-areaModel.scale.x, 0, 0) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(0, 0, 90) - targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof AreaLight - dragHelper: lightGizmo.dragHelper - propName: "width" - propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.width : 0 - - onNewValueChanged: targetNode.width = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: lightGizmo.propertyValueCommit(propName) - } - - AreaLightHandle { - id: areaHeightHandle - view3D: lightGizmo.view3D - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - position: lightGizmo.targetNode instanceof AreaLight ? Qt.vector3d(0, -areaModel.scale.y, 0) - : Qt.vector3d(0, 0, 0) - eulerRotation: Qt.vector3d(0, 0, 180) - targetNode: lightGizmo.targetNode instanceof AreaLight ? lightGizmo.targetNode : null - active: lightGizmo.targetNode instanceof AreaLight - dragHelper: lightGizmo.dragHelper - propName: "height" - propValue: lightGizmo.targetNode instanceof AreaLight ? targetNode.height : 0 - - onNewValueChanged: targetNode.height = newValue - onCurrentMousePosChanged: { - lightGizmo.currentMousePos = currentMousePos; - lightGizmo.currentLabel = currentLabel; - } - onValueChange: lightGizmo.propertyValueChange(propName) - onValueCommit: lightGizmo.propertyValueCommit(propName) - } - } - - LightModel { - id: directionalModel - geometryName: "Edit 3D DirLight" - geometryType: LightGeometry.Directional - material: lightMaterial - visible: lightGizmo.targetNode instanceof DirectionalLight - scale: autoScaler.getScale(Qt.vector3d(50, 50, 50)) - } - - AdjustableArrow { - id: primaryArrow - eulerRotation: Qt.vector3d(-90, 0, 0) - targetNode: lightGizmo.targetNode - color: (hovering || dragging) ? Qt.rgba(1, 1, 1, 1) : lightGizmo.color - view3D: lightGizmo.view3D - active: lightGizmo.visible - dragHelper: lightGizmo.dragHelper - scale: autoScaler.getScale(Qt.vector3d(5, 5, 5)) - length: targetNode ? Math.max(1.0, 1.0 + targetNode.brightness / _generalHelper.brightnessScaler() * 10.0) + 3 : 10 - - property real _startBrightness - - function updateBrightness(relativeDistance, screenPos) - { - var currentValue = Math.max(0, (_startBrightness + relativeDistance * _generalHelper.brightnessScaler() / 10.0)); - currentValue *= brightnessMultiplier; - currentValue = Math.round(currentValue); - currentValue /= brightnessMultiplier; - - var l = Qt.locale(); - lightGizmo.currentLabel = "brightness" + qsTr(": ") + Number(currentValue).toLocaleString(l, 'f', brightnessDecimals); - lightGizmo.currentMousePos = screenPos; - targetNode.brightness = currentValue; - } - - onPressed: (mouseArea, screenPos)=> { - _startBrightness = targetNode.brightness; - updateBrightness(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateBrightness(relativeDistance, screenPos); - lightGizmo.propertyValueChange("brightness"); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateBrightness(relativeDistance, screenPos); - lightGizmo.propertyValueCommit("brightness"); - } - } - - DefaultMaterial { - id: lightMaterial - diffuseColor: lightGizmo.color - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightIconGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightIconGizmo.qml deleted file mode 100644 index b4d7abbb6a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightIconGizmo.qml +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import LightUtils 1.0 - -IconGizmo { - id: lightIconGizmo - - property color overlayColor: targetNode ? targetNode.color : "transparent" - - iconSource: targetNode - ? targetNode instanceof DirectionalLight - ? "image://IconGizmoImageProvider/directional.png:" + overlayColor - : targetNode instanceof AreaLight - ? "image://IconGizmoImageProvider/area.png:" + overlayColor - : targetNode instanceof PointLight - ? "image://IconGizmoImageProvider/point.png:" + overlayColor - : "image://IconGizmoImageProvider/spot.png:" + overlayColor - : "image://IconGizmoImageProvider/point.png:" + overlayColor -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightModel.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightModel.qml deleted file mode 100644 index 3208c2211a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/LightModel.qml +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import LightUtils 1.0 - -Model { - id: lightModel - - property alias geometryName: lightGeometry.name // Name must be unique for each geometry - property alias geometryType: lightGeometry.lightType - property Material material - readonly property bool _edit3dLocked: true // Make this non-pickable - - function updateGeometry() - { - lightGeometry.update(); - } - - scale: Qt.vector3d(50, 50, 50) - - geometry: lightGeometry - materials: [ material ] - - LightGeometry { - id: lightGeometry - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Line3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Line3D.qml deleted file mode 100644 index df29d0990d..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Line3D.qml +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import LineGeometry 1.0 - -Node { - id: pivotLine - - property alias startPos: lineGeometry.startPos - property alias endPos: lineGeometry.endPos - property alias name: lineGeometry.name // Name must be unique for each line - property alias color: lineMat.diffuseColor - - Model { - readonly property bool _edit3dLocked: true // Make this non-pickable - geometry: LineGeometry { - id: lineGeometry - } - materials: [ - DefaultMaterial { - id: lineMat - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/MaterialNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/MaterialNodeView.qml deleted file mode 100644 index 9fd74b55dd..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/MaterialNodeView.qml +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick3D 6.0 - -View3D { - id: root - anchors.fill: parent - environment: sceneEnv - camera: !envMode || (envMode === "SkyBox" && envValue === "preview_studio") ? studioCamera - : defaultCamera - - property Material previewMaterial - property string envMode - property string envValue - property string modelSrc: "#Sphere" - - function fitToViewPort(closeUp) - { - // No need to zoom this view, this is here just to avoid runtime warnings - } - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - backgroundMode: envMode === "Color" ? SceneEnvironment.Color - : envMode === "Basic" ? SceneEnvironment.Transparent - : SceneEnvironment.SkyBox - clearColor: envMode === "Color" ? envValue : "#000000" - lightProbe: !envMode || envMode === "SkyBox" ? skyBoxTex : null - - Texture { - id: skyBoxTex - source: !envMode ? "../images/preview_studio.hdr" - : envMode === "SkyBox" ? "../images/" + envValue + ".hdr" - : "" - } - } - - Node { - DirectionalLight { - eulerRotation.x: -26 - eulerRotation.y: modelSrc === "#Cube" ? -10 : -50 - brightness: envMode && envMode !== "SkyBox" ? 1 : 0 - } - - PerspectiveCamera { - id: defaultCamera - y: 70 - z: 200 - eulerRotation.x: -5.71 - clipNear: 1 - clipFar: 1000 - } - - PerspectiveCamera { - id: studioCamera - y: 232 - z: 85 - eulerRotation.x: -64.98 - clipNear: 1 - clipFar: 1000 - } - - Node { - rotation: root.camera.rotation - y: 50 - Node { - y: modelSrc === "#Cone" ? -40 : 10 - eulerRotation.x: 35 - Model { - id: model - readonly property bool _edit3dLocked: true // Make this non-pickable - source: modelSrc ? modelSrc : "#Sphere" - eulerRotation.y: 45 - materials: previewMaterial - scale: !modelSrc || modelSrc === "#Sphere" - ? Qt.vector3d(1.7, 1.7, 1.7) : Qt.vector3d(1.2, 1.2, 1.2) - } - } - } - Model { - id: floorModel - source: "#Rectangle" - scale.y: 8 - scale.x: 8 - eulerRotation.x: -60 - visible: envMode === "Basic" - materials: floorMaterial - DefaultMaterial { - id: floorMaterial - diffuseMap: floorTex - Texture { - id: floorTex - source: "../images/floor_tex.png" - scaleU: floorModel.scale.x - scaleV: floorModel.scale.y - } - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNode2DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNode2DImageView.qml deleted file mode 100644 index bf95be9c82..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNode2DImageView.qml +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 - -Item { - id: root - width: 150 - height: 150 - - property alias contentItem: contentItem - - /* - View3D { - // Dummy view to hold the context in case View3D items are used in the component - // TODO remove when QTBUG-87678 is fixed - } - */ - - Item { - id: contentItem - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNode3DImageView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNode3DImageView.qml deleted file mode 100644 index 3eaed5c210..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNode3DImageView.qml +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -Item { - id: root - width: 150 - height: 150 - visible: true - - property View3D view: null - property alias contentItem: contentItem - - property var previewObject - - property var materialViewComponent - property var modelViewComponent - property var nodeViewComponent - - property bool closeUp: false - - function destroyView() - { - previewObject = null; - if (view) - view.destroy(); - } - - function createViewForObject(obj, env, envValue, model) - { - backgroundView3d.visible = true; - if (obj instanceof Material) - createViewForMaterial(obj, env, envValue, model); - else if (obj instanceof Model) - createViewForModel(obj); - else if (obj instanceof Node) - createViewForNode(obj); - } - - function createViewForMaterial(material, env, envValue, model) - { - if (!materialViewComponent) - materialViewComponent = Qt.createComponent("MaterialNodeView.qml"); - - // Always recreate the view to ensure material is up to date - if (materialViewComponent.status === Component.Ready) { - view = materialViewComponent.createObject(viewRect, {"previewMaterial": material, - "envMode": env, - "envValue": envValue, - "modelSrc": model}); - } - // Floor must be in same view as material so material can reflect it, so hide it in this one - backgroundView3d.visible = false; - previewObject = material; - } - - function createViewForModel(model) - { - if (!modelViewComponent) - modelViewComponent = Qt.createComponent("ModelNodeView.qml"); - - // Always recreate the view to ensure model is up to date - if (modelViewComponent.status === Component.Ready) - view = modelViewComponent.createObject(viewRect, {"sourceModel": model}); - - previewObject = model; - } - - function createViewForNode(node) - { - if (!nodeViewComponent) - nodeViewComponent = Qt.createComponent("NodeNodeView.qml"); - - // Always recreate the view to ensure node is up to date - if (nodeViewComponent.status === Component.Ready) - view = nodeViewComponent.createObject(viewRect, {"importScene": node}); - - previewObject = node; - } - - function fitToViewPort() - { - view.fitToViewPort(closeUp); - } - - // Enables/disables icon mode. When in icon mode, camera is zoomed bit closer to reduce margins - // and the background is removed, in order to generate a preview suitable for library icons. - function setIconMode(enable) - { - closeUp = enable; - backgroundRect.visible = !enable; - } - - Item { - id: contentItem - anchors.fill: parent - - Item { - id: viewRect - anchors.fill: parent - } - - Rectangle { - id: backgroundRect - anchors.fill: parent - z: -1 - gradient: Gradient { - GradientStop { position: 1.0; color: "#222222" } - GradientStop { position: 0.0; color: "#999999" } - } - - // Use View3D instead of static image to make background look good on all resolutions - View3D { - id: backgroundView3d - anchors.fill: parent - environment: sceneEnv - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - } - - DirectionalLight { - eulerRotation.x: -26 - eulerRotation.y: -57 - } - - PerspectiveCamera { - y: 125 - z: 120 - eulerRotation.x: -31 - clipNear: 1 - clipFar: 1000 - } - - Model { - id: floorModel - source: "#Rectangle" - scale.y: 8 - scale.x: 8 - eulerRotation.x: -90 - materials: floorMaterial - DefaultMaterial { - id: floorMaterial - diffuseMap: floorTex - Texture { - id: floorTex - source: "../images/floor_tex.png" - scaleU: floorModel.scale.x - scaleV: floorModel.scale.y - } - } - } - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNodeView.qml deleted file mode 100644 index 7ae513d27a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ModelNodeView.qml +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -View3D { - id: root - anchors.fill: parent - environment: sceneEnv - camera: theCamera - - property Model sourceModel - - function fitToViewPort(closeUp) - { - // The magic number is the distance from camera default pos to origin - _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, model, root, - 1040, closeUp); - } - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - } - - DirectionalLight { - eulerRotation.x: -30 - eulerRotation.y: -30 - } - - PerspectiveCamera { - id: theCamera - z: 600 - y: 600 - x: 600 - eulerRotation.x: -45 - eulerRotation.y: -45 - clipFar: 10000 - clipNear: 1 - } - - Model { - id: model - source: _generalHelper.resolveAbsoluteSourceUrl(sourceModel) - geometry: sourceModel.geometry - materials: sourceModel.materials - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/MoveGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/MoveGizmo.qml deleted file mode 100644 index 6f10038d1b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/MoveGizmo.qml +++ /dev/null @@ -1,153 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Node { - id: moveGizmo - - property View3D view3D - property bool highlightOnHover: false - property Node targetNode: null - property bool globalOrientation: true - readonly property bool dragging: arrowX.dragging || arrowY.dragging || arrowZ.dragging - || planeX.dragging || planeY.dragging || planeZ.dragging - || centerBall.dragging - property MouseArea3D dragHelper: null - property alias freeDraggerArea: centerBall.mouseArea - - position: dragHelper.pivotScenePosition(targetNode) - - onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode) - - Connections { - target: moveGizmo.targetNode - function onSceneTransformChanged() - { - moveGizmo.position = moveGizmo.dragHelper.pivotScenePosition(moveGizmo.targetNode); - } - } - - signal positionCommit() - signal positionMove() - - Node { - rotation: globalOrientation || !moveGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) - : moveGizmo.targetNode.sceneRotation - Arrow { - id: arrowX - eulerRotation: Qt.vector3d(0, 0, -90) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - Arrow { - id: arrowY - eulerRotation: Qt.vector3d(0, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - Arrow { - id: arrowZ - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - PlanarMoveHandle { - id: planeX - - y: 10 - z: 10 - - eulerRotation: Qt.vector3d(0, 90, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - PlanarMoveHandle { - id: planeY - - x: 10 - z: 10 - - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - - PlanarMoveHandle { - id: planeZ - - x: 10 - y: 10 - - eulerRotation: Qt.vector3d(0, 0, 0) - targetNode: moveGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } - } - - PlanarMoveHandle { - id: centerBall - - source: "#Sphere" - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1)) - : Qt.rgba(0.5, 0.5, 0.5, 1) - rotation: view3D.camera.rotation - priority: 10 - targetNode: moveGizmo.targetNode - - view3D: moveGizmo.view3D - active: moveGizmo.visible - dragHelper: moveGizmo.dragHelper - - onPositionCommit: moveGizmo.positionCommit() - onPositionMove: moveGizmo.positionMove() - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/NodeNodeView.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/NodeNodeView.qml deleted file mode 100644 index 242d9cf0b9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/NodeNodeView.qml +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -View3D { - id: root - anchors.fill: parent - environment: sceneEnv - camera: theCamera - - function fitToViewPort(closeUp) - { - // The magic number is the distance from camera default pos to origin - _generalHelper.calculateNodeBoundsAndFocusCamera(theCamera, importScene, root, - 1040, closeUp); - } - - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - } - - DirectionalLight { - eulerRotation.x: -30 - eulerRotation.y: -30 - } - - PerspectiveCamera { - id: theCamera - z: 600 - y: 600 - x: 600 - eulerRotation.x: -45 - eulerRotation.y: -45 - clipFar: 10000 - clipNear: 1 - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Overlay2D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Overlay2D.qml deleted file mode 100644 index e2573bed66..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/Overlay2D.qml +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -Item { - id: root - property Node targetNode - property View3D targetView - - property vector3d offset: Qt.vector3d(0, 0, 0) - - property bool isBehindCamera - - onTargetNodeChanged: updateOverlay() - - Connections { - target: targetNode - function onSceneTransformChanged() { updateOverlay() } - } - - Connections { - target: targetView.camera - function onSceneTransformChanged() { updateOverlay() } - } - - Connections { - target: _generalHelper - function onOverlayUpdateNeeded() { updateOverlay() } - } - - function updateOverlay() - { - var scenePos = targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0); - // Need separate variable as scenePos is reference to read-only property - var scenePosWithOffset = Qt.vector3d(scenePos.x + offset.x, - scenePos.y + offset.y, - scenePos.z + offset.z); - var viewPos = targetView ? targetView.mapFrom3DScene(scenePosWithOffset) - : Qt.vector3d(0, 0, 0); - root.x = viewPos.x; - root.y = viewPos.y; - - isBehindCamera = viewPos.z <= 0; - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ParticleEmitterGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ParticleEmitterGizmo.qml deleted file mode 100644 index 829556ecb2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ParticleEmitterGizmo.qml +++ /dev/null @@ -1,112 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick -import QtQuick3D -import QtQuick3D.Particles3D - -// Note: This gizmo is also used to visualize Attractor3D in addition to ParticleEmitter3D, -// as the two are very similar. - -Node { - id: root - - property Node targetNode: null - property var selectedNodes: [] - property Node activeParticleSystem: null - property Node scene: null - property Node activeScene: null - property bool hidden: false - property bool systemHidden: false - property Node shapeModel: null - property bool globalShow: false - property bool canBeVisible: activeScene === scene && targetNode && !hidden && !systemHidden - property bool partOfActiveSystem: root.targetNode && root.targetNode.system === activeParticleSystem - property bool isEmitter: targetNode && targetNode instanceof ParticleEmitter3D - - opacity: 0.15 - - readonly property bool selected: selectedNodes.includes(targetNode) - - visible: canBeVisible && (globalShow || selected) - - position: targetNode ? targetNode.scenePosition : Qt.vector3d(0, 0, 0) - rotation: targetNode ? targetNode.sceneRotation : Qt.quaternion(1, 0, 0, 0) - scale: targetNode ? targetNode.sceneScale : Qt.vector3d(1, 1, 1) - - function basicShape() - { - if (targetNode && targetNode.shape && targetNode.shape instanceof ParticleShape3D) { - if (targetNode.shape.type === ParticleShape3D.Cube) - return "#Cube"; - else if (targetNode.shape.type === ParticleShape3D.Cylinder) - return "#Cylinder"; - } - return "#Sphere"; - } - - function updateShape() - { - if (shapeModel) - shapeModel.destroy(); - - if (!targetNode) - return; - - if (targetNode.shape instanceof ParticleModelShape3D) { - shapeModel = _generalHelper.createParticleEmitterGizmoModel(targetNode, defaultMaterial); - shapeModel.parent = root; - } - } - - Component.onCompleted: { - updateShape(); - } - - Connections { - target: targetNode - function onSystemChanged() { systemHidden = _generalHelper.isHidden(system); } - } - - Connections { - target: targetNode - function onShapeChanged() { updateShape(); } - } - - Connections { - target: targetNode.shape instanceof ParticleModelShape3D ? targetNode.shape - :null - function onDelegateChanged() { updateShape(); } - } - - Connections { - target: targetNode.shape instanceof ParticleModelShape3D ? targetNode.shape.delegate - : null - function onSourceChanged() { updateShape(); } - } - - Model { - readonly property Node _pickTarget: root.targetNode - materials: [defaultMaterial] - source: basicShape() - scale: root.targetNode && root.targetNode.shape && targetNode.shape instanceof ParticleShape3D - ? root.targetNode.shape.extents.times(0.02) // default extent is 50 - : autoScale.getScale(Qt.vector3d(0.1, 0.1, 0.1)) - visible: !shapeModel - } - - AutoScaleHelper { - id: autoScale - view3D: overlayView - } - - DefaultMaterial { - id: defaultMaterial - diffuseColor: root.selected ? "#FF0000" - : root.partOfActiveSystem - ? root.isEmitter ? "#FFFF00" : "#0000FF" - : "#AAAAAA" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ParticleSystemGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ParticleSystemGizmo.qml deleted file mode 100644 index 153db46680..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ParticleSystemGizmo.qml +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -IconGizmo { - id: particleSystemGizmo - - property Node activeParticleSystem: null - - iconSource: "qrc:///qtquickplugin/mockfiles/images/editor_particlesystem.png" - iconOpacity: selected || activeParticleSystem == targetNode ? 0.2 : 1 -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarDraggable.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarDraggable.qml deleted file mode 100644 index bc11445cf0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarDraggable.qml +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Model { - id: rootModel - - property View3D view3D - property alias color: gizmoMaterial.diffuseColor - property alias priority: mouseArea.priority - property Node targetNode: null - property bool dragging: mouseArea.dragging - property bool active: false - property MouseArea3D dragHelper: null - property alias mouseArea: mouseArea - - readonly property bool hovering: mouseArea.hovering - readonly property bool _edit3dLocked: true // Make this non-pickable - - property vector3d _scenePosPressed - property vector2d _planePosPressed - property vector3d _targetStartPos - - signal pressed(var mouseArea) - signal dragged(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance) - signal released(var mouseArea, vector3d sceneRelativeDistance, vector2d relativeDistance) - - source: "#Rectangle" - - DefaultMaterial { - id: gizmoMaterial - diffuseColor: "white" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - materials: gizmoMaterial - - function handlePressed(mouseArea, planePos) - { - if (!targetNode) - return; - - _planePosPressed = planePos; - _scenePosPressed = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d()); - _targetStartPos = mouseArea.pivotScenePosition(targetNode); - pressed(mouseArea); - } - - function calcRelativeDistance(mouseArea, planePos) - { - var scenePointerPos = mouseArea.dragHelper.mapPositionToScene(planePos.toVector3d()); - return scenePointerPos.minus(_scenePosPressed); - } - - function handleDragged(mouseArea, planePos) - { - if (!targetNode) - return; - - dragged(mouseArea, calcRelativeDistance(mouseArea, planePos), - planePos.minus(_planePosPressed)); - } - - function handleReleased(mouseArea, planePos) - { - if (!targetNode) - return; - - released(mouseArea, calcRelativeDistance(mouseArea, planePos), - planePos.minus(_planePosPressed)); - } - - MouseArea3D { - id: mouseArea - view3D: rootModel.view3D - x: -60 - y: -60 - width: 120 - height: 120 - grabsMouse: targetNode - active: rootModel.active - dragHelper: rootModel.dragHelper - - onPressed: (planePos)=> { - rootModel.handlePressed(mouseArea, planePos); - } - onDragged: (planePos)=> { - rootModel.handleDragged(mouseArea, planePos); - } - onReleased: (planePos)=> { - rootModel.handleReleased(mouseArea, planePos); - } - } -} - diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarMoveHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarMoveHandle.qml deleted file mode 100644 index c2969f1ab1..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarMoveHandle.qml +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -PlanarDraggable { - id: planarHandle - scale: Qt.vector3d(0.024, 0.024, 0.024) - - signal positionCommit() - signal positionMove() - - function localPos(sceneRelativeDistance) - { - var newScenePos = Qt.vector3d( - _targetStartPos.x + sceneRelativeDistance.x, - _targetStartPos.y + sceneRelativeDistance.y, - _targetStartPos.z + sceneRelativeDistance.z); - return targetNode.parent ? targetNode.parent.mapPositionFromScene(newScenePos) : newScenePos; - } - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - } - - onDragged: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(false); - positionMove(); - } - - onReleased: (mouseArea, sceneRelativeDistance)=> { - targetNode.position = localPos(sceneRelativeDistance); - if (targetNode == multiSelectionNode) - _generalHelper.moveMultiSelection(true); - positionCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarScaleHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarScaleHandle.qml deleted file mode 100644 index 916640b230..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/PlanarScaleHandle.qml +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -PlanarDraggable { - id: planarHandle - scale: Qt.vector3d(0.024, 0.024, 0.024) - - property bool globalOrientation: false - property vector3d axisX - property vector3d axisY - - signal scaleCommit() - signal scaleChange() - - property vector3d _startScale - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - _startScale = targetNode.scale; - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, relativeDistance.times(scale.x), - axisX, axisY); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(false); - scaleChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, relativeDistance.times(scale.x), - axisX, axisY); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(true); - scaleCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/RotateGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/RotateGizmo.qml deleted file mode 100644 index 0e40045bb2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/RotateGizmo.qml +++ /dev/null @@ -1,272 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Node { - id: rotateGizmo - - property View3D view3D - property bool highlightOnHover: true - property Node targetNode: null - property bool globalOrientation: true - readonly property bool dragging: cameraRing.dragging - || rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging - property MouseArea3D dragHelper: null - property real currentAngle - property point currentMousePos - property alias freeDraggerArea: mouseAreaFree - property bool blocked: false - - position: dragHelper.pivotScenePosition(targetNode) - - onTargetNodeChanged: { - position = dragHelper.pivotScenePosition(targetNode); - blocked = _generalHelper.isRotationBlocked(targetNode); - } - - Connections { - target: rotateGizmo.targetNode - function onSceneTransformChanged() - { - rotateGizmo.position = dragHelper.pivotScenePosition(targetNode); - } - } - - Connections { - target: _generalHelper - function onRotationBlocksChanged() - { - blocked = _generalHelper.isRotationBlocked(targetNode); - } - } - - signal rotateCommit() - signal rotateChange() - - function copyRingProperties(srcRing) { - draggingRing.rotation = srcRing.sceneRotation; - draggingRing.color = srcRing.color; - draggingRing.scale = srcRing.scale; - } - - onDraggingChanged: { - if (rotRingX.dragging) - copyRingProperties(rotRingX) - else if (rotRingY.dragging) - copyRingProperties(rotRingY) - else if (rotRingZ.dragging) - copyRingProperties(rotRingZ) - } - - Node { - id: rotNode - rotation: globalOrientation || !rotateGizmo.targetNode ? Qt.quaternion(1, 0, 0, 0) - : rotateGizmo.targetNode.sceneRotation - visible: !rotateGizmo.dragging && !freeRotator.dragging - - RotateRing { - id: rotRingX - objectName: "Rotate Ring X" - eulerRotation: Qt.vector3d(0, 90, 0) - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) : Qt.rgba(1, 0, 0, 1) - priority: 40 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - - RotateRing { - id: rotRingY - objectName: "Rotate Ring Y" - eulerRotation: Qt.vector3d(90, 0, 0) - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) : Qt.rgba(0, 0.6, 0, 1) - // Just a smidge smaller than higher priority rings so that it doesn't obscure them - scale: Qt.vector3d(0.998, 0.998, 0.998) - priority: 30 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - - RotateRing { - id: rotRingZ - objectName: "Rotate Ring Z" - eulerRotation: Qt.vector3d(0, 0, 0) - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) : Qt.rgba(0, 0, 1, 1) - // Just a smidge smaller than higher priority rings so that it doesn't obscure them - scale: Qt.vector3d(0.996, 0.996, 0.996) - priority: 20 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - } - - RotateRing { - // This ring is used as visual proxy during dragging to display the currently dragged - // plane in static position, as rotation planes can wobble when ancestors don't have - // uniform scaling. - // Camera ring doesn't need dragging proxy as it doesn't wobble. - id: draggingRing - objectName: "draggingRing" - targetNode: rotateGizmo.targetNode - view3D: rotateGizmo.view3D - active: false - visible: rotRingX.dragging || rotRingY.dragging || rotRingZ.dragging - } - - RotateRing { - id: cameraRing - objectName: "cameraRing" - rotation: rotateGizmo.view3D.camera.rotation - targetNode: rotateGizmo.targetNode - color: rotateGizmo.blocked ? Qt.rgba(0.5, 0.5, 0.5, 1) - : highlightOnHover && (hovering || dragging) - ? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1)) - : Qt.rgba(0.5, 0.5, 0.5, 1) - scale: Qt.vector3d(1.1, 1.1, 1.1) - priority: 10 - view3D: rotateGizmo.view3D - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - visible: !rotRingX.dragging && !rotRingY.dragging && !rotRingZ.dragging && !freeRotator.dragging - - onRotateCommit: rotateGizmo.rotateCommit() - onRotateChange: rotateGizmo.rotateChange() - onCurrentAngleChanged: rotateGizmo.currentAngle = currentAngle - onCurrentMousePosChanged: rotateGizmo.currentMousePos = currentMousePos - } - - Model { - id: freeRotator - - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Sphere" - materials: DefaultMaterial { - id: material - diffuseColor: "black" - opacity: mouseAreaFree.hovering && !rotateGizmo.blocked ? 0.15 : 0 - lighting: DefaultMaterial.NoLighting - } - scale: Qt.vector3d(0.15, 0.15, 0.15) - visible: !rotateGizmo.dragging && !dragging - - property bool dragging: false - property vector3d _pointerPosPressed - property vector3d _startRotation - - function handlePressed(screenPos) - { - if (!rotateGizmo.targetNode) - return; - - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - - // Need to recreate vector as we need to adjust it and we can't do that on reference of - // scenePosition, which is read-only property - var scenePos = rotateGizmo.dragHelper.pivotScenePosition(rotateGizmo.targetNode); - _pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0); - - // Recreate vector so we don't follow the changes in targetNode.rotation - _startRotation = Qt.vector3d(rotateGizmo.targetNode.eulerRotation.x, - rotateGizmo.targetNode.eulerRotation.y, - rotateGizmo.targetNode.eulerRotation.z); - // Ensure we never set NaN values for rotation, even if target node originally has them - if (isNaN(_startRotation.x)) - _startRotation.x = 0; - if (isNaN(_startRotation.y)) - _startRotation.y = 0; - if (isNaN(_startRotation.z)) - _startRotation.z = 0; - - dragging = true; - } - - function handleDragged(screenPos) - { - if (!rotateGizmo.targetNode) - return; - - mouseAreaFree.applyFreeRotation( - rotateGizmo.targetNode, _startRotation, _pointerPosPressed, - Qt.vector3d(screenPos.x, screenPos.y, 0)); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(false); - - rotateGizmo.rotateChange(); - } - - function handleReleased(screenPos) - { - if (!rotateGizmo.targetNode) - return; - - mouseAreaFree.applyFreeRotation( - rotateGizmo.targetNode, _startRotation, _pointerPosPressed, - Qt.vector3d(screenPos.x, screenPos.y, 0)); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(true); - - rotateGizmo.rotateCommit(); - dragging = false; - - if (targetNode == multiSelectionNode) - _generalHelper.resetMultiSelectionNode(); - } - - MouseArea3D { - id: mouseAreaFree - view3D: rotateGizmo.view3D - rotation: rotateGizmo.view3D.camera.rotation - objectName: "Free rotator plane" - x: -50 - y: -50 - width: 100 - height: 100 - circlePickArea: Qt.point(25, 50) - grabsMouse: rotateGizmo.targetNode - active: rotateGizmo.visible && !rotateGizmo.blocked - dragHelper: rotateGizmo.dragHelper - - onPressed: (planePos, screenPos)=> { - freeRotator.handlePressed(screenPos); - } - onDragged: (planePos, screenPos)=> { - freeRotator.handleDragged(screenPos); - } - onReleased: (planePos, screenPos)=> { - freeRotator.handleReleased(screenPos); - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/RotateRing.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/RotateRing.qml deleted file mode 100644 index 9c0d49ed82..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/RotateRing.qml +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Model { - id: rotateRing - - property View3D view3D - property alias color: material.diffuseColor - property Node targetNode: null - property bool dragging: mouseAreaMain.dragging - property bool active: false - property alias hovering: mouseAreaMain.hovering - property alias priority: mouseAreaMain.priority - property real currentAngle - property point currentMousePos - property MouseArea3D dragHelper: null - - property vector3d _pointerPosPressed - property vector3d _targetPosOnScreen - property vector3d _startRotation - property bool _trackBall - readonly property bool _edit3dLocked: true // Make this non-pickable - - signal rotateCommit() - signal rotateChange() - - source: "../meshes/ring.mesh" - - Model { - id: pickModel - readonly property bool _edit3dLocked: true // Make this non-pickable in main picking handling - objectName: "PickModel for " + rotateRing.objectName - source: "../meshes/ringselect.mesh" - pickable: true - } - - materials: DefaultMaterial { - id: material - diffuseColor: "white" - lighting: DefaultMaterial.NoLighting - } - - function applyLocalRotation(screenPos) - { - currentAngle = mouseAreaMain.dragHelper.getNewRotationAngle( - targetNode, _pointerPosPressed, Qt.vector3d(screenPos.x, screenPos.y, 0), - _targetPosOnScreen, currentAngle, _trackBall); - mouseAreaMain.dragHelper.applyRotationAngleToNode(targetNode, _startRotation, currentAngle); - } - - function handlePressed(screenPos, angle) - { - if (!targetNode) - return; - - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - - // Need to recreate vector as we need to adjust it and we can't do that on reference of - // scenePosition, which is read-only property - var scenePos = mouseAreaMain.pivotScenePosition(targetNode); - - _targetPosOnScreen = view3D.mapFrom3DScene(scenePos); - _targetPosOnScreen.z = 0; - _pointerPosPressed = Qt.vector3d(screenPos.x, screenPos.y, 0); - _trackBall = angle < 0.1; - - // Recreate vector so we don't follow the changes in targetNode.eulerRotation - _startRotation = Qt.vector3d(targetNode.eulerRotation.x, - targetNode.eulerRotation.y, - targetNode.eulerRotation.z); - // Ensure we never set NaN values for rotation, even if target node originally has them - if (isNaN(_startRotation.x)) - _startRotation.x = 0; - if (isNaN(_startRotation.y)) - _startRotation.y = 0; - if (isNaN(_startRotation.z)) - _startRotation.z = 0; - currentAngle = 0; - currentMousePos = screenPos; - } - - function handleDragged(screenPos) - { - if (!targetNode) - return; - - applyLocalRotation(screenPos); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(false); - - currentMousePos = screenPos; - rotateChange(); - } - - function handleReleased(screenPos) - { - if (!targetNode) - return; - - applyLocalRotation(screenPos); - - if (targetNode == multiSelectionNode) - _generalHelper.rotateMultiSelection(true); - - rotateCommit(); - currentAngle = 0; - currentMousePos = screenPos; - - if (targetNode == multiSelectionNode) - _generalHelper.resetMultiSelectionNode(); - } - - MouseArea3D { - id: mouseAreaMain - view3D: rotateRing.view3D - objectName: "Main plane of " + rotateRing.objectName - x: -30 - y: -30 - width: 60 - height: 60 - circlePickArea: Qt.point(9.2, 1.4) - grabsMouse: targetNode - active: rotateRing.active - pickNode: pickModel - minAngle: 0.05 - dragHelper: rotateRing.dragHelper - - onPressed: (planePos, screenPos, angle)=> { - rotateRing.handlePressed(screenPos, angle); - } - onDragged: (planePos, screenPos)=> { - rotateRing.handleDragged(screenPos); - } - onReleased: (planePos, screenPos)=> { - rotateRing.handleReleased(screenPos); - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ScaleGizmo.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ScaleGizmo.qml deleted file mode 100644 index 6335e7707c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ScaleGizmo.qml +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -Node { - id: scaleGizmo - - property View3D view3D - property bool highlightOnHover: false - property Node targetNode: null - readonly property bool dragging: scaleRodX.dragging || scaleRodY.dragging || scaleRodZ.dragging - || planeX.dragging || planeY.dragging || planeZ.dragging - || centerMouseArea.dragging - property MouseArea3D dragHelper: null - property alias freeDraggerArea: centerMouseArea - - position: dragHelper.pivotScenePosition(targetNode) - - onTargetNodeChanged: position = dragHelper.pivotScenePosition(targetNode) - - Connections { - target: scaleGizmo.targetNode - function onSceneTransformChanged() - { - scaleGizmo.position = scaleGizmo.dragHelper.pivotScenePosition(scaleGizmo.targetNode); - } - } - - signal scaleCommit() - signal scaleChange() - - Node { - rotation: !targetNode ? Qt.quaternion(1, 0, 0, 0) : targetNode.sceneRotation - - ScaleRod { - id: scaleRodX - eulerRotation: Qt.vector3d(0, 0, -90) - axis: Qt.vector3d(1, 0, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - ScaleRod { - id: scaleRodY - eulerRotation: Qt.vector3d(0, 0, 0) - axis: Qt.vector3d(0, 1, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - ScaleRod { - id: scaleRodZ - eulerRotation: Qt.vector3d(90, 0, 0) - axis: Qt.vector3d(0, 0, 1) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - PlanarScaleHandle { - id: planeX - - y: 10 - z: 10 - - eulerRotation: Qt.vector3d(0, 90, 0) - axisX: Qt.vector3d(0, 0, -1) - axisY: Qt.vector3d(0, 1, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(1, 0, 0, 1)) - : Qt.rgba(1, 0, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - PlanarScaleHandle { - id: planeY - - x: 10 - z: 10 - - eulerRotation: Qt.vector3d(90, 0, 0) - axisX: Qt.vector3d(1, 0, 0) - axisY: Qt.vector3d(0, 0, 1) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0.6, 0, 1)) - : Qt.rgba(0, 0.6, 0, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - - PlanarScaleHandle { - id: planeZ - - x: 10 - y: 10 - - eulerRotation: Qt.vector3d(0, 0, 0) - axisX: Qt.vector3d(1, 0, 0) - axisY: Qt.vector3d(0, 1, 0) - targetNode: scaleGizmo.targetNode - color: highlightOnHover && (hovering || dragging) ? Qt.lighter(Qt.rgba(0, 0, 1, 1)) - : Qt.rgba(0, 0, 1, 1) - view3D: scaleGizmo.view3D - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - onScaleCommit: scaleGizmo.scaleCommit() - onScaleChange: scaleGizmo.scaleChange() - } - } - - Model { - id: centerCube - - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Cube" - scale: Qt.vector3d(0.024, 0.024, 0.024) - materials: DefaultMaterial { - id: material - diffuseColor: highlightOnHover - && (centerMouseArea.hovering || centerMouseArea.dragging) - ? Qt.lighter(Qt.rgba(0.5, 0.5, 0.5, 1)) - : Qt.rgba(0.5, 0.5, 0.5, 1) - lighting: DefaultMaterial.NoLighting - } - - MouseArea3D { - id: centerMouseArea - view3D: scaleGizmo.view3D - x: -60 - y: -60 - width: 120 - height: 120 - rotation: view3D.camera.rotation - grabsMouse: scaleGizmo.targetNode - priority: 10 - active: scaleGizmo.visible - dragHelper: scaleGizmo.dragHelper - - property vector3d _startScale - property point _startScreenPos - - function localScale(screenPos) - { - var yDelta = screenPos.y - _startScreenPos.y; - if (yDelta === 0) - return _startScale; - var scaler = 1.0 + (yDelta * 0.025); - if (scaler === 0) - scaler = 0.0001; - return Qt.vector3d(scaler * _startScale.x, - scaler * _startScale.y, - scaler * _startScale.z); - } - - onPressed: (planePos, screenPos)=> { - if (!scaleGizmo.targetNode) - return; - - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - - // Recreate vector so we don't follow the changes in targetNode.scale - _startScale = Qt.vector3d(scaleGizmo.targetNode.scale.x, - scaleGizmo.targetNode.scale.y, - scaleGizmo.targetNode.scale.z); - _startScreenPos = screenPos; - } - onDragged: (planePos, screenPos)=> { - if (!scaleGizmo.targetNode) - return; - scaleGizmo.targetNode.scale = localScale(screenPos); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(false); - scaleGizmo.scaleChange(); - } - onReleased: (planePos, screenPos)=> { - if (!scaleGizmo.targetNode) - return; - - scaleGizmo.targetNode.scale = localScale(screenPos); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(true); - scaleGizmo.scaleCommit(); - } - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ScaleRod.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ScaleRod.qml deleted file mode 100644 index 2c6cf64997..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/ScaleRod.qml +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import MouseArea3D 1.0 - -DirectionalDraggable { - id: scaleRod - source: "../meshes/scalerod.mesh" - - property vector3d axis - - signal scaleCommit() - signal scaleChange() - - property vector3d _startScale - - Model { - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Cube" - y: 10 - scale: Qt.vector3d(0.020, 0.020, 0.020) - materials: DefaultMaterial { - id: material - diffuseColor: scaleRod.color - lighting: DefaultMaterial.NoLighting - } - } - - onPressed: { - if (targetNode == multiSelectionNode) - _generalHelper.restartMultiSelection(); - _startScale = targetNode.scale; - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, Qt.vector2d(relativeDistance, 0), - axis, Qt.vector3d(0, 0, 0)); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(false); - scaleChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance)=> { - targetNode.scale = mouseArea.getNewScale(_startScale, Qt.vector2d(relativeDistance, 0), - axis, Qt.vector3d(0, 0, 0)); - if (targetNode == multiSelectionNode) - _generalHelper.scaleMultiSelection(true); - scaleCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml deleted file mode 100644 index 3fd0417b27..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SceneView3D.qml +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick3D 6.0 - -View3D { - id: sceneView - anchors.fill: parent - - property bool usePerspective: false - property alias showSceneLight: sceneLight.visible - property alias showGrid: helperGrid.visible - property alias gridColor: helperGrid.gridColor - property alias sceneHelpers: sceneHelpers - property alias perspectiveCamera: scenePerspectiveCamera - property alias orthoCamera: sceneOrthoCamera - property double cameraZoomFactor: .55; - - // Empirical cameraZoomFactor values at which the grid zoom level is doubled. The values are - // approximately uniformally distributed over the non-linear range of cameraZoomFactor. - readonly property var grid_thresholds: [0.55, 1.10, 2.35, 4.9, 10.0, 20.5, 42.0, 85.0, 999999.0] - property var thresIdx: 1 - property var thresPerc: 1.0 // percentage of cameraZoomFactor to the current grid zoom threshold (0.0 - 1.0) - - camera: usePerspective ? scenePerspectiveCamera : sceneOrthoCamera - - onCameraZoomFactorChanged: { - thresIdx = Math.max(1, grid_thresholds.findIndex(v => v > cameraZoomFactor)); - thresPerc = (grid_thresholds[thresIdx] - cameraZoomFactor) / (grid_thresholds[thresIdx] - grid_thresholds[thresIdx - 1]); - } - - environment: sceneEnv - SceneEnvironment { - id: sceneEnv - antialiasingMode: SceneEnvironment.MSAA - antialiasingQuality: SceneEnvironment.High - } - - Node { - id: sceneHelpers - - HelperGrid { - id: helperGrid - lines: Math.pow(2, grid_thresholds.length - thresIdx - 1); - step: 100 * grid_thresholds[0] * Math.pow(2, thresIdx - 1); - subdivAlpha: thresPerc; - } - - PointLight { - id: sceneLight - position: usePerspective ? scenePerspectiveCamera.position - : sceneOrthoCamera.position - quadraticFade: 0 - linearFade: 0 - } - - // Initial camera position and rotation should be such that they look at origin. - // Otherwise EditCameraController._lookAtPoint needs to be initialized to correct - // point. - PerspectiveCamera { - id: scenePerspectiveCamera - z: 600 - y: 600 - eulerRotation.x: -45 - clipFar: 100000 - clipNear: 1 - } - - OrthographicCamera { - id: sceneOrthoCamera - z: 600 - y: 600 - eulerRotation.x: -45 - clipFar: 100000 - clipNear: -10000 - } - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SelectionBox.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SelectionBox.qml deleted file mode 100644 index d365387052..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SelectionBox.qml +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 -import SelectionBoxGeometry 1.0 - -Node { - id: selectionBox - - property View3D view3D - property Node targetNode: null - property alias model: selectionBoxModel - property alias geometryName: selectionBoxGeometry.name - - SelectionBoxGeometry { - id: selectionBoxGeometry - name: "Selection Box of 3D Edit View" - view3D: selectionBox.view3D - targetNode: selectionBox.targetNode - rootNode: selectionBox - } - - Model { - id: selectionBoxModel - readonly property bool _edit3dLocked: true // Make this non-pickable - geometry: selectionBoxGeometry - - scale: selectionBox.targetNode ? selectionBox.targetNode.scale : Qt.vector3d(1, 1, 1) - rotation: selectionBox.targetNode ? selectionBox.targetNode.rotation : Qt.quaternion(1, 0, 0, 0) - position: selectionBox.targetNode ? selectionBox.targetNode.position : Qt.vector3d(0, 0, 0) - pivot: selectionBox.targetNode ? selectionBox.targetNode.pivot : Qt.vector3d(0, 0, 0) - - visible: selectionBox.targetNode && !selectionBoxGeometry.isEmpty - - castsShadows: false - receivesShadows: false - - materials: [ - DefaultMaterial { - diffuseColor: "#fff600" - lighting: DefaultMaterial.NoLighting - cullMode: Material.NoCulling - } - ] - } -} diff --git a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SpotLightHandle.qml b/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SpotLightHandle.qml deleted file mode 100644 index def0a5b4fc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/mockfiles/qt6/SpotLightHandle.qml +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -import QtQuick 6.0 -import QtQuick3D 6.0 - -DirectionalDraggable { - id: handleRoot - - property string currentLabel - property point currentMousePos - property string propName - property real propValue: 0 - property real newValue: 0 - - scale: autoScaler.getScale(Qt.vector3d(5, 5, 5)) - length: 3 - offset: -1.5 - - Model { - id: handle - readonly property bool _edit3dLocked: true // Make this non-pickable - source: "#Sphere" - materials: [ handleRoot.material ] - scale: Qt.vector3d(0.02, 0.02, 0.02) - } - - AutoScaleHelper { - id: autoScaler - active: handleRoot.active - view3D: handleRoot.view3D - } - - property real _startAngle - - signal valueCommit() - signal valueChange() - - function updateAngle(relativeDistance, screenPos) - { - handleRoot.newValue = Math.round(Math.min(180, Math.max(0, _startAngle + relativeDistance))); - var l = Qt.locale(); - handleRoot.currentLabel = propName + qsTr(": ") + Number(newValue).toLocaleString(l, 'f', 0); - handleRoot.currentMousePos = screenPos; - } - - onPressed: (mouseArea, screenPos)=> { - _startAngle = propValue; - updateAngle(0, screenPos); - } - - onDragged: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateAngle(relativeDistance, screenPos); - handleRoot.valueChange(); - } - - onReleased: (mouseArea, sceneRelativeDistance, relativeDistance, screenPos)=> { - updateAngle(relativeDistance, screenPos); - handleRoot.valueCommit(); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/Info.plist b/share/qtcreator/qml/qmlpuppet/qml2puppet/Info.plist deleted file mode 100644 index f8d63231ea..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/Info.plist +++ /dev/null @@ -1,34 +0,0 @@ -<?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) 2016 The Qt Company Ltd -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.</string> - <key>CFBundlePackageType</key> - <string>APPL</string> - <key>CFBundleSignature</key> - <string>????</string> - <key>CFBundleExecutable</key> - <string>qml2puppet</string> - <key>CFBundleIdentifier</key> - <string>org.qt-project.qtcreator.qml2puppet</string> - <key>LSUIElement</key> - <string>1</string> -</dict> -</plist> diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp deleted file mode 100644 index b551617e09..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.cpp +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "camerageometry.h" - -#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h> -#include <QtQuick3D/private/qquick3dcustomcamera_p.h> -#include <QtQuick3D/private/qquick3dfrustumcamera_p.h> -#include <QtQuick3D/private/qquick3dorthographiccamera_p.h> -#include <QtQuick3D/private/qquick3dperspectivecamera_p.h> -#include <QtQuick3D/private/qquick3dutils_p.h> -#include <QtCore/qmath.h> - -#include <limits> - -namespace QmlDesigner { -namespace Internal { - -CameraGeometry::CameraGeometry() - : GeometryBase() -{ -} - -CameraGeometry::~CameraGeometry() -{ -} - -QQuick3DCamera *CameraGeometry::camera() const -{ - return m_camera; -} - -QRectF CameraGeometry::viewPortRect() const -{ - return m_viewPortRect; -} - -void CameraGeometry::setCamera(QQuick3DCamera *camera) -{ - if (m_camera == camera) - return; - - if (m_camera) - m_camera->disconnect(this); - m_camera = camera; - if (auto perspectiveCamera = qobject_cast<QQuick3DPerspectiveCamera *>(m_camera)) { - QObject::connect(perspectiveCamera, &QQuick3DPerspectiveCamera::clipNearChanged, - this, &CameraGeometry::handleCameraPropertyChange); - QObject::connect(perspectiveCamera, &QQuick3DPerspectiveCamera::clipFarChanged, - this, &CameraGeometry::handleCameraPropertyChange); - QObject::connect(perspectiveCamera, &QQuick3DPerspectiveCamera::fieldOfViewChanged, - this, &CameraGeometry::handleCameraPropertyChange); - QObject::connect(perspectiveCamera, &QQuick3DPerspectiveCamera::fieldOfViewOrientationChanged, - this, &CameraGeometry::handleCameraPropertyChange); - if (auto frustumCamera = qobject_cast<QQuick3DFrustumCamera *>(m_camera)) { - QObject::connect(frustumCamera, &QQuick3DFrustumCamera::topChanged, - this, &CameraGeometry::handleCameraPropertyChange); - QObject::connect(frustumCamera, &QQuick3DFrustumCamera::bottomChanged, - this, &CameraGeometry::handleCameraPropertyChange); - QObject::connect(frustumCamera, &QQuick3DFrustumCamera::rightChanged, - this, &CameraGeometry::handleCameraPropertyChange); - QObject::connect(frustumCamera, &QQuick3DFrustumCamera::leftChanged, - this, &CameraGeometry::handleCameraPropertyChange); - } - } else if (auto orthoCamera = qobject_cast<QQuick3DOrthographicCamera *>(m_camera)) { - QObject::connect(orthoCamera, &QQuick3DOrthographicCamera::clipNearChanged, - this, &CameraGeometry::handleCameraPropertyChange); - QObject::connect(orthoCamera, &QQuick3DOrthographicCamera::clipFarChanged, - this, &CameraGeometry::handleCameraPropertyChange); - } else if (auto customCamera = qobject_cast<QQuick3DCustomCamera *>(m_camera)) { - QObject::connect(customCamera, &QQuick3DCustomCamera::projectionChanged, - this, &CameraGeometry::handleCameraPropertyChange); - } - emit cameraChanged(); - handleCameraPropertyChange(); -} - -void CameraGeometry::setViewPortRect(const QRectF &rect) -{ - if (m_viewPortRect == rect) - return; - - m_viewPortRect = rect; - emit viewPortRectChanged(); - updateGeometry(); -} - -void CameraGeometry::handleCameraPropertyChange() -{ - m_cameraUpdatePending = true; - clear(); - setStride(12); // To avoid div by zero inside QtQuick3D - update(); -} - -QSSGRenderGraphObject *CameraGeometry::updateSpatialNode(QSSGRenderGraphObject *node) -{ - if (m_cameraUpdatePending) { - m_cameraUpdatePending = false; - updateGeometry(); - } - - return QQuick3DGeometry::updateSpatialNode(node); -} - -void CameraGeometry::doUpdateGeometry() -{ - if (!m_camera) - return; - - // If camera properties have been updated, we need to defer updating the frustum geometry - // to the next frame to ensure camera's spatial node has been properly updated. - if (m_cameraUpdatePending) { - update(); - return; - } - - if (!QQuick3DObjectPrivate::get(m_camera)->spatialNode) { - // Doing explicit viewport mapping forces cameraNode creation - m_camera->mapToViewport({}, m_viewPortRect.width(), m_viewPortRect.height()); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (!m_nodeCreationUpdateDone) { - // Post-node creation update is done only once to avoid infinite loop in case the node - // creation fails. - m_nodeCreationUpdateDone = true; - m_cameraUpdatePending = true; - update(); - return; - } -#endif - } - - GeometryBase::doUpdateGeometry(); - - QByteArray vertexData; - QByteArray indexData; - QVector3D minBounds; - QVector3D maxBounds; - fillVertexData(vertexData, indexData, minBounds, maxBounds); - - addAttribute(QQuick3DGeometry::Attribute::IndexSemantic, 0, - QQuick3DGeometry::Attribute::U16Type); - setVertexData(vertexData); - setIndexData(indexData); - setBounds(minBounds, maxBounds); -} - -void CameraGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexData, - QVector3D &minBounds, QVector3D &maxBounds) -{ - const int vertexSize = int(sizeof(float)) * 8 * 3; // 8 vertices, 3 floats/vert - vertexData.resize(vertexSize); - const int indexSize = int(sizeof(quint16)) * 12 * 2; // 12 lines, 2 vert/line - indexData.resize(indexSize); - - auto dataPtr = reinterpret_cast<float *>(vertexData.data()); - auto indexPtr = reinterpret_cast<quint16 *>(indexData.data()); - - QMatrix4x4 m; - QSSGRenderCamera *camera = static_cast<QSSGRenderCamera *>(QQuick3DObjectPrivate::get(m_camera)->spatialNode); - if (camera) { - QRectF rect = m_viewPortRect; - if (rect.isNull()) - rect = QRectF(0, 0, 1000, 1000); // Let's have some visualization for null viewports - camera->calculateGlobalVariables(rect); - m = camera->projection.inverted(); - } - - const QVector3D farTopLeft = m * QVector3D(1.f, -1.f, 1.f); - const QVector3D farBottomRight = m * QVector3D(-1.f, 1.f, 1.f); - const QVector3D nearTopLeft = m * QVector3D(1.f, -1.f, -1.f); - const QVector3D nearBottomRight = m * QVector3D(-1.f, 1.f, -1.f); - - *dataPtr++ = nearTopLeft.x(); *dataPtr++ = nearBottomRight.y(); *dataPtr++ = nearTopLeft.z(); - *dataPtr++ = nearTopLeft.x(); *dataPtr++ = nearTopLeft.y(); *dataPtr++ = nearTopLeft.z(); - *dataPtr++ = nearBottomRight.x(); *dataPtr++ = nearTopLeft.y(); *dataPtr++ = nearTopLeft.z(); - *dataPtr++ = nearBottomRight.x(); *dataPtr++ = nearBottomRight.y(); *dataPtr++ = nearTopLeft.z(); - *dataPtr++ = farTopLeft.x(); *dataPtr++ = farBottomRight.y(); *dataPtr++ = farTopLeft.z(); - *dataPtr++ = farTopLeft.x(); *dataPtr++ = farTopLeft.y(); *dataPtr++ = farTopLeft.z(); - *dataPtr++ = farBottomRight.x(); *dataPtr++ = farTopLeft.y(); *dataPtr++ = farTopLeft.z(); - *dataPtr++ = farBottomRight.x(); *dataPtr++ = farBottomRight.y(); *dataPtr++ = farTopLeft.z(); - - // near rect - *indexPtr++ = 0; *indexPtr++ = 1; - *indexPtr++ = 1; *indexPtr++ = 2; - *indexPtr++ = 2; *indexPtr++ = 3; - *indexPtr++ = 3; *indexPtr++ = 0; - // near to far - *indexPtr++ = 0; *indexPtr++ = 4; - *indexPtr++ = 1; *indexPtr++ = 5; - *indexPtr++ = 2; *indexPtr++ = 6; - *indexPtr++ = 3; *indexPtr++ = 7; - // far rect - *indexPtr++ = 4; *indexPtr++ = 5; - *indexPtr++ = 5; *indexPtr++ = 6; - *indexPtr++ = 6; *indexPtr++ = 7; - *indexPtr++ = 7; *indexPtr++ = 4; - - static const float floatMin = std::numeric_limits<float>::lowest(); - static const float floatMax = std::numeric_limits<float>::max(); - auto vertexPtr = reinterpret_cast<QVector3D *>(vertexData.data()); - minBounds = QVector3D(floatMax, floatMax, floatMax); - maxBounds = QVector3D(floatMin, floatMin, floatMin); - for (int i = 0; i < vertexSize / 12; ++i) { - minBounds[0] = qMin((*vertexPtr)[0], minBounds[0]); - minBounds[1] = qMin((*vertexPtr)[1], minBounds[1]); - minBounds[2] = qMin((*vertexPtr)[2], minBounds[2]); - maxBounds[0] = qMax((*vertexPtr)[0], maxBounds[0]); - maxBounds[1] = qMax((*vertexPtr)[1], maxBounds[1]); - maxBounds[2] = qMax((*vertexPtr)[2], maxBounds[2]); - ++vertexPtr; - } -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h deleted file mode 100644 index 9b4ec924fc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/camerageometry.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include "geometrybase.h" - -#include <QtQuick3D/private/qquick3dcamera_p.h> - -namespace QmlDesigner { -namespace Internal { - -class CameraGeometry : public GeometryBase -{ - Q_OBJECT - Q_PROPERTY(QQuick3DCamera *camera READ camera WRITE setCamera NOTIFY cameraChanged) - Q_PROPERTY(QRectF viewPortRect READ viewPortRect WRITE setViewPortRect NOTIFY viewPortRectChanged) - -public: - CameraGeometry(); - ~CameraGeometry() override; - - QQuick3DCamera *camera() const; - QRectF viewPortRect() const; - -public slots: - void setCamera(QQuick3DCamera *camera); - void setViewPortRect(const QRectF &rect); - void handleCameraPropertyChange(); - -signals: - void cameraChanged(); - void viewPortRectChanged(); - -protected: - QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; - void doUpdateGeometry() override; - -private: - void fillVertexData(QByteArray &vertexData, QByteArray &indexData, - QVector3D &minBounds, QVector3D &maxBounds); - - QQuick3DCamera *m_camera = nullptr; - QRectF m_viewPortRect; - bool m_cameraUpdatePending = false; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - bool m_nodeCreationUpdateDone = false; -#endif -}; - -} -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::CameraGeometry) - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri deleted file mode 100644 index 6eedaad8f1..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/editor3d.pri +++ /dev/null @@ -1,24 +0,0 @@ -HEADERS += $$PWD/generalhelper.h \ - $$PWD/mousearea3d.h \ - $$PWD/geometrybase.h \ - $$PWD/camerageometry.h \ - $$PWD/lightgeometry.h \ - $$PWD/gridgeometry.h \ - $$PWD/selectionboxgeometry.h \ - $$PWD/linegeometry.h \ - $$PWD/icongizmoimageprovider.h - -SOURCES += $$PWD/generalhelper.cpp \ - $$PWD/mousearea3d.cpp \ - $$PWD/geometrybase.cpp \ - $$PWD/camerageometry.cpp \ - $$PWD/lightgeometry.cpp \ - $$PWD/gridgeometry.cpp \ - $$PWD/selectionboxgeometry.cpp \ - $$PWD/linegeometry.cpp \ - $$PWD/icongizmoimageprovider.cpp - -versionAtLeast(QT_VERSION, 6.0.0) { - HEADERS += $$PWD/qt5compat/qquick3darealight_p.h - SOURCES += $$PWD/qt5compat/qquick3darealight.cpp -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp deleted file mode 100644 index 7109bddae0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.cpp +++ /dev/null @@ -1,936 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 -#include "generalhelper.h" - -#ifdef QUICK3D_MODULE - -#include "selectionboxgeometry.h" - -#include <QtQuick3D/qquick3dobject.h> -#include <QtQuick3D/private/qquick3dorthographiccamera_p.h> -#include <QtQuick3D/private/qquick3dperspectivecamera_p.h> -#include <QtQuick3D/private/qquick3dcamera_p.h> -#include <QtQuick3D/private/qquick3dnode_p.h> -#include <QtQuick3D/private/qquick3dmodel_p.h> -#include <QtQuick3D/private/qquick3dviewport_p.h> -#include <QtQuick3D/private/qquick3ddefaultmaterial_p.h> -#include <QtQuick3D/private/qquick3dscenemanager_p.h> -#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h> -#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h> -#include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h> -#include <QtQuick3DUtils/private/qssgbounds3_p.h> -#include <QtQuick3DUtils/private/qssgutils_p.h> -#include <QtQml/qqml.h> -#include <QtQuick/qquickwindow.h> -#include <QtQuick/qquickitem.h> -#include <QtCore/qmath.h> - -#ifdef QUICK3D_PARTICLES_MODULE -#include <QtQuick3DParticles/private/qquick3dparticlemodelshape_p.h> -#include <QtQuick3DParticles/private/qquick3dparticleemitter_p.h> -#include <QtQuick3DParticles/private/qquick3dparticletrailemitter_p.h> -#include <QtQuick3DParticles/private/qquick3dparticleattractor_p.h> -#endif - -#include <limits> - -namespace QmlDesigner { -namespace Internal { - -const QString _globalStateId = QStringLiteral("@GTS"); // global tool state -const QString _lastSceneIdKey = QStringLiteral("lastSceneId"); -const QString _rootSizeKey = QStringLiteral("rootSize"); - -static const float floatMin = std::numeric_limits<float>::lowest(); -static const float floatMax = std::numeric_limits<float>::max(); -static const QVector3D maxVec = QVector3D(floatMax, floatMax, floatMax); -static const QVector3D minVec = QVector3D(floatMin, floatMin, floatMin); - -GeneralHelper::GeneralHelper() - : QObject() -{ - m_overlayUpdateTimer.setInterval(16); - m_overlayUpdateTimer.setSingleShot(true); - QObject::connect(&m_overlayUpdateTimer, &QTimer::timeout, - this, &GeneralHelper::overlayUpdateNeeded); - - m_toolStateUpdateTimer.setSingleShot(true); - QObject::connect(&m_toolStateUpdateTimer, &QTimer::timeout, - this, &GeneralHelper::handlePendingToolStateUpdate); -} - -void GeneralHelper::requestOverlayUpdate() -{ - // Restart the timer on each request in attempt to ensure there's one frame between the last - // request and actual update. - m_overlayUpdateTimer.start(); -} - -QString GeneralHelper::generateUniqueName(const QString &nameRoot) -{ - static QHash<QString, int> counters; - int count = counters[nameRoot]++; - return QStringLiteral("%1_%2").arg(nameRoot).arg(count); -} - -// Resolves absolute model source path -QUrl GeneralHelper::resolveAbsoluteSourceUrl(const QQuick3DModel *sourceModel) -{ - if (!sourceModel) - return {}; - - const QUrl source = sourceModel->source(); - if (source.hasFragment()) { - // Fragment is part of the url separated by '#', check if it is an index or primitive - bool isNumber = false; - source.fragment().toInt(&isNumber); - // If it wasn't an index, then it was a primitive and we can return it as-is - if (!isNumber) - return source; - } - - QQmlContext *context = qmlContext(sourceModel); - return context ? context->resolvedUrl(source) : source; -} - -void GeneralHelper::orbitCamera(QQuick3DCamera *camera, const QVector3D &startRotation, - const QVector3D &lookAtPoint, const QVector3D &pressPos, - const QVector3D ¤tPos) -{ - QVector3D dragVector = currentPos - pressPos; - - if (dragVector.length() < 0.001f) - return; - - camera->setEulerRotation(startRotation); - QVector3D newRotation(-dragVector.y(), -dragVector.x(), 0.f); - newRotation *= 0.5f; // Emprically determined multiplier for nice drag - newRotation += startRotation; - - camera->setEulerRotation(newRotation); - - const QVector3D oldLookVector = camera->position() - lookAtPoint; - QMatrix4x4 m = camera->sceneTransform(); - const float *dataPtr(m.data()); - QVector3D newLookVector(dataPtr[8], dataPtr[9], dataPtr[10]); - newLookVector.normalize(); - newLookVector *= oldLookVector.length(); - - camera->setPosition(lookAtPoint + newLookVector); -} - -// Pans camera and returns the new look-at point -QVector3D GeneralHelper::panCamera(QQuick3DCamera *camera, const QMatrix4x4 startTransform, - const QVector3D &startPosition, const QVector3D &startLookAt, - const QVector3D &pressPos, const QVector3D ¤tPos, - float zoomFactor) -{ - QVector3D dragVector = currentPos - pressPos; - - if (dragVector.length() < 0.001f) - return startLookAt; - - const float *dataPtr(startTransform.data()); - const QVector3D xAxis = QVector3D(dataPtr[0], dataPtr[1], dataPtr[2]).normalized(); - const QVector3D yAxis = QVector3D(dataPtr[4], dataPtr[5], dataPtr[6]).normalized(); - const QVector3D xDelta = -1.f * xAxis * dragVector.x(); - const QVector3D yDelta = yAxis * dragVector.y(); - const QVector3D delta = (xDelta + yDelta) * zoomFactor; - - camera->setPosition(startPosition + delta); - return startLookAt + delta; -} - -float GeneralHelper::zoomCamera([[maybe_unused]] QQuick3DViewport *viewPort, - QQuick3DCamera *camera, - float distance, - float defaultLookAtDistance, - const QVector3D &lookAt, - float zoomFactor, - bool relative) -{ - // Emprically determined divisor for nice zoom - float multiplier = 1.f + (distance / 40.f); - float newZoomFactor = relative ? qBound(.01f, zoomFactor * multiplier, 100.f) - : zoomFactor; - - if (qobject_cast<QQuick3DOrthographicCamera *>(camera)) { - // Ortho camera we can simply scale - float orthoFactor = newZoomFactor; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (viewPort) { - if (const QQuickWindow *w = viewPort->window()) - orthoFactor *= w->devicePixelRatio(); - } -#endif - camera->setScale(QVector3D(orthoFactor, orthoFactor, orthoFactor)); - } else if (qobject_cast<QQuick3DPerspectiveCamera *>(camera)) { - // Perspective camera is zoomed by moving camera forward or backward while keeping the - // look-at point the same - const QVector3D lookAtVec = (camera->position() - lookAt).normalized(); - const float newDistance = defaultLookAtDistance * newZoomFactor; - camera->setPosition(lookAt + (lookAtVec * newDistance)); - } - - return newZoomFactor; -} - -// Return value contains new lookAt point (xyz) and zoom factor (w) -QVector4D GeneralHelper::focusNodesToCamera(QQuick3DCamera *camera, float defaultLookAtDistance, - const QVariant &nodes, QQuick3DViewport *viewPort, - float oldZoom, bool updateZoom, bool closeUp) -{ - if (!camera) - return QVector4D(0.f, 0.f, 0.f, 1.f); - - QList<QQuick3DNode *> nodeList; - const QVariantList varNodes = nodes.value<QVariantList>(); - for (const auto &varNode : varNodes) { - auto model = varNode.value<QQuick3DNode *>(); - if (model) - nodeList.append(model); - } - - // Get bounds - QVector3D totalMinBound; - QVector3D totalMaxBound; - const qreal defaultExtent = 200.; - - if (!nodeList.isEmpty()) { - static const float floatMin = std::numeric_limits<float>::lowest(); - static const float floatMax = std::numeric_limits<float>::max(); - totalMinBound = {floatMax, floatMax, floatMax}; - totalMaxBound = {floatMin, floatMin, floatMin}; - } else { - const float halfExtent = defaultExtent / 2.f; - totalMinBound = {-halfExtent, -halfExtent, -halfExtent}; - totalMaxBound = {halfExtent, halfExtent, halfExtent}; - } - for (const auto node : std::as_const(nodeList)) { - auto model = qobject_cast<QQuick3DModel *>(node); - qreal maxExtent = defaultExtent; - QVector3D center = node->scenePosition(); - if (model) { - auto targetPriv = QQuick3DObjectPrivate::get(model); - if (auto renderModel = static_cast<QSSGRenderModel *>(targetPriv->spatialNode)) { - QWindow *window = static_cast<QWindow *>(viewPort->window()); - if (window) { - QSSGRef<QSSGRenderContextInterface> context; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); -#else - context = targetPriv->sceneManager->rci; -#endif - if (!context.isNull()) { - QSSGBounds3 bounds; - auto geometry = qobject_cast<SelectionBoxGeometry *>(model->geometry()); - if (geometry) { - bounds = geometry->bounds(); - } else { - auto bufferManager = context->bufferManager(); -#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0) - bounds = renderModel->getModelBounds(bufferManager); -#else - bounds = bufferManager->getModelBounds(renderModel); -#endif - } - - center = renderModel->globalTransform.map(bounds.center()); - const QVector3D e = bounds.extents(); - const QVector3D s = model->sceneScale(); - qreal maxScale = qSqrt(qreal(s.x() * s.x() + s.y() * s.y() + s.z() * s.z())); - maxExtent = qSqrt(qreal(e.x() * e.x() + e.y() * e.y() + e.z() * e.z())); - maxExtent *= maxScale; - - if (maxExtent < 0.0001) - maxExtent = defaultExtent; - } - } - } - } - float halfExtent = float(maxExtent / 2.); - const QVector3D halfExtents {halfExtent, halfExtent, halfExtent}; - - const QVector3D minBound = center - halfExtents; - const QVector3D maxBound = center + halfExtents; - - for (int i = 0; i < 3; ++i) { - totalMinBound[i] = qMin(minBound[i], totalMinBound[i]); - totalMaxBound[i] = qMax(maxBound[i], totalMaxBound[i]); - } - } - - QVector3D extents = totalMaxBound - totalMinBound; - QVector3D lookAt = totalMinBound + (extents / 2.f); - float maxExtent = qMax(extents.x(), qMax(extents.y(), extents.z())); - - // Reset camera position to default zoom - QMatrix4x4 m = camera->sceneTransform(); - const float *dataPtr(m.data()); - QVector3D newLookVector(dataPtr[8], dataPtr[9], dataPtr[10]); - newLookVector.normalize(); - newLookVector *= defaultLookAtDistance; - - camera->setPosition(lookAt + newLookVector); - - float divisor = closeUp ? 900.f : 725.f; - - float newZoomFactor = updateZoom ? qBound(.01f, maxExtent / divisor, 100.f) : oldZoom; - float cameraZoomFactor = zoomCamera(viewPort, camera, 0, defaultLookAtDistance, lookAt, - newZoomFactor, false); - - return QVector4D(lookAt, cameraZoomFactor); -} - -// This function can be used to synchronously focus camera on a node, which doesn't have to be -// a selection box for bound calculations to work. This is used to focus the view for -// various preview image generations, where doing things asynchronously is not good -// and recalculating bounds for every frame is not a problem. -void GeneralHelper::calculateNodeBoundsAndFocusCamera( - QQuick3DCamera *camera, QQuick3DNode *node, QQuick3DViewport *viewPort, - float defaultLookAtDistance, bool closeUp) -{ - QVector3D minBounds; - QVector3D maxBounds; - - getBounds(viewPort, node, minBounds, maxBounds); - - QVector3D extents = maxBounds - minBounds; - QVector3D lookAt = minBounds + (extents / 2.f); - float maxExtent = qSqrt(qreal(extents.x()) * qreal(extents.x()) - + qreal(extents.y()) * qreal(extents.y()) - + qreal(extents.z()) * qreal(extents.z())); - - // Reset camera position to default zoom - QMatrix4x4 m = camera->sceneTransform(); - const float *dataPtr(m.data()); - QVector3D newLookVector(dataPtr[8], dataPtr[9], dataPtr[10]); - newLookVector.normalize(); - newLookVector *= defaultLookAtDistance; - - camera->setPosition(lookAt + newLookVector); - - // CloseUp divisor is used for icon generation, where we can allow some extreme models to go - // slightly out of bounds for better results generally. The other divisor is used for other - // previews, where the image is larger to begin with and we would also like some margin - // between preview edge and the rendered model, so we can be more conservative with the zoom. - // The divisor values are empirically selected to provide nice result. - float divisor = closeUp ? 1250.f : 1050.f; - float newZoomFactor = maxExtent / divisor; - - zoomCamera(viewPort, camera, 0, defaultLookAtDistance, lookAt, newZoomFactor, false); - - if (auto perspectiveCamera = qobject_cast<QQuick3DPerspectiveCamera *>(camera)) { - // Fix camera near/far clips in case we are dealing with extreme zooms - const float cameraDist = qAbs((camera->position() - lookAt).length()); - const float minDist = cameraDist - (maxExtent / 2.f); - const float maxDist = cameraDist + (maxExtent / 2.f); - if (minDist < perspectiveCamera->clipNear() || maxDist > perspectiveCamera->clipFar()) { - perspectiveCamera->setClipNear(minDist * 0.99); - perspectiveCamera->setClipFar(maxDist * 1.01); - } - - } -} - -// Aligns any cameras found in nodes list to a camera. -// Only position and rotation are copied, rest of the camera properties stay the same. -void GeneralHelper::alignCameras(QQuick3DCamera *camera, const QVariant &nodes) -{ - QList<QQuick3DCamera *> nodeList; - const QVariantList varNodes = nodes.value<QVariantList>(); - for (const auto &varNode : varNodes) { - auto cameraNode = varNode.value<QQuick3DCamera *>(); - if (cameraNode) - nodeList.append(cameraNode); - } - - for (QQuick3DCamera *node : std::as_const(nodeList)) { - node->setPosition(camera->position()); - node->setRotation(camera->rotation()); - } -} - -// Aligns the camera to the first camera in nodes list. -// Aligning means taking the position and XY rotation from the source camera. Rest of the properties -// remain the same, as this is used to align edit cameras, which have fixed Z-rot, fov, and clips. -// The new lookAt is set at same distance away as it was previously and scale isn't adjusted, so -// the zoom factor of the edit camera stays the same. -QVector3D GeneralHelper::alignView(QQuick3DCamera *camera, const QVariant &nodes, - const QVector3D &lookAtPoint) -{ - float lastDistance = (lookAtPoint - camera->position()).length(); - const QVariantList varNodes = nodes.value<QVariantList>(); - QQuick3DCamera *cameraNode = nullptr; - for (const auto &varNode : varNodes) { - cameraNode = varNode.value<QQuick3DCamera *>(); - if (cameraNode) - break; - } - - if (cameraNode) { - camera->setPosition(cameraNode->position()); - QVector3D newRotation = cameraNode->eulerRotation(); - newRotation.setZ(0.f); - camera->setEulerRotation(newRotation); - } - - QVector3D lookAt = camera->position() + camera->forward() * lastDistance; - - return lookAt; -} - -bool GeneralHelper::fuzzyCompare(double a, double b) -{ - return qFuzzyCompare(a, b); -} - -void GeneralHelper::delayedPropertySet(QObject *obj, int delay, const QString &property, - const QVariant &value) -{ - QTimer::singleShot(delay, [obj, property, value]() { - obj->setProperty(property.toLatin1().constData(), value); - }); -} - -// Returns the first valid QQuick3DPickResult from view at (posX, PosY). -QQuick3DPickResult GeneralHelper::pickViewAt(QQuick3DViewport *view, float posX, float posY) -{ - if (!view) - return QQuick3DPickResult(); - -#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 1) - // Make sure global picking is on - view->setGlobalPickingEnabled(true); - - // With Qt 6.2+, select first suitable result from all picked objects - auto pickResults = view->pickAll(posX, posY); - for (auto pickResult : pickResults) { - if (isPickable(pickResult.objectHit())) - return pickResult; - } -#else - // With older Qt version we'll just pick the single object - auto pickResult = view->pick(posX, posY); - if (isPickable(pickResult.objectHit())) - return pickResult; -#endif - return QQuick3DPickResult(); -} - -QObject *GeneralHelper::resolvePick(QQuick3DNode *pickNode) -{ - if (pickNode) { - // Check if the picked node actually specifies another object as the pick target - QVariant componentVar = pickNode->property("_pickTarget"); - if (componentVar.isValid()) { - auto componentObj = componentVar.value<QObject *>(); - if (componentObj) - return componentObj; - } - } - return pickNode; -} - -bool GeneralHelper::isLocked(QQuick3DNode *node) const -{ - if (node) { - QVariant lockValue = node->property("_edit3dLocked"); - return lockValue.isValid() && lockValue.toBool(); - } - return false; -} - -bool GeneralHelper::isHidden(QQuick3DNode *node) const -{ - if (node) { - QVariant hideValue = node->property("_edit3dHidden"); - return hideValue.isValid() && hideValue.toBool(); - } - return false; -} - -bool GeneralHelper::isPickable(QQuick3DNode *node) const -{ - if (!node) - return false; - -#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0) - // Instancing doesn't hide child nodes, so only check for instancing on the requested node - if (auto model = qobject_cast<QQuick3DModel *>(node)) { - if (model->instancing()) - return false; - } -#endif - - QQuick3DNode *n = node; - while (n) { - if (!n->visible() || isLocked(n) || isHidden(n)) - return false; - n = n->parentNode(); - } - return true; -} - -// Emitter gizmo model creation is done in C++ as creating dynamic properties and -// assigning materials to dynamically created models is lot simpler in C++ -QQuick3DNode *GeneralHelper::createParticleEmitterGizmoModel(QQuick3DNode *emitter, - QQuick3DMaterial *material) const -{ -#ifdef QUICK3D_PARTICLES_MODULE - if (qobject_cast<QQuick3DParticleTrailEmitter *>(emitter) || !material) - return nullptr; - - QQuick3DParticleModelShape *shape = nullptr; - if (auto e = qobject_cast<QQuick3DParticleEmitter *>(emitter)) - shape = qobject_cast<QQuick3DParticleModelShape *>(e->shape()); - else if (auto a = qobject_cast<QQuick3DParticleAttractor *>(emitter)) - shape = qobject_cast<QQuick3DParticleModelShape *>(a->shape()); - - if (shape && shape->delegate()) { - if (auto model = qobject_cast<QQuick3DModel *>( - shape->delegate()->create(shape->delegate()->creationContext()))) { - QQmlEngine::setObjectOwnership(model, QQmlEngine::JavaScriptOwnership); - model->setProperty("_pickTarget", QVariant::fromValue(emitter)); - QQmlListReference matRef(model, "materials"); - matRef.append(material); - return model; - } - } -#endif - return nullptr; -} - -void GeneralHelper::storeToolState(const QString &sceneId, const QString &tool, const QVariant &state, - int delay) -{ - if (delay > 0) { - QVariantMap sceneToolState; - sceneToolState.insert(tool, state); - m_toolStatesPending.insert(sceneId, sceneToolState); - m_toolStateUpdateTimer.start(delay); - } else { - if (m_toolStateUpdateTimer.isActive()) - handlePendingToolStateUpdate(); - QVariant theState; - // Convert JS arrays to QVariantLists for easier handling down the line - // metaType().id() which only exist in Qt6 is the same as userType() - if (state.userType() != QMetaType::QString && state.canConvert(QMetaType::QVariantList)) - theState = state.value<QVariantList>(); - else - theState = state; - QVariantMap &sceneToolState = m_toolStates[sceneId]; - if (sceneToolState[tool] != theState) { - sceneToolState.insert(tool, theState); - emit toolStateChanged(sceneId, tool, theState); - } - } -} - -void GeneralHelper::setSceneEnvironmentColor(const QString &sceneId, const QColor &color) -{ - m_sceneEnvironmentColor[sceneId] = color; -} - -QColor GeneralHelper::sceneEnvironmentColor(const QString &sceneId) const -{ - return m_sceneEnvironmentColor[sceneId]; -} - -void GeneralHelper::initToolStates(const QString &sceneId, const QVariantMap &toolStates) -{ - m_toolStates[sceneId] = toolStates; -} - -void GeneralHelper::enableItemUpdate(QQuickItem *item, bool enable) -{ - if (item) - item->setFlag(QQuickItem::ItemHasContents, enable); -} - -QVariantMap GeneralHelper::getToolStates(const QString &sceneId) -{ - handlePendingToolStateUpdate(); - if (m_toolStates.contains(sceneId)) - return m_toolStates[sceneId]; - return {}; -} - -QString GeneralHelper::globalStateId() const -{ - return _globalStateId; -} - -QString GeneralHelper::lastSceneIdKey() const -{ - return _lastSceneIdKey; -} - -QString GeneralHelper::rootSizeKey() const -{ - return _rootSizeKey; -} - -double GeneralHelper::brightnessScaler() const -{ - // Light brightness was rescaled in Qt6 from 100 -> 1. -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - return 100.; -#else - return 1.; -#endif -} - -void GeneralHelper::setMultiSelectionTargets(QQuick3DNode *multiSelectRootNode, - const QVariantList &selectedList) -{ - // Filter selection to contain only topmost parent nodes in the selection - m_multiSelDataMap.clear(); - m_multiSelNodes.clear(); - for (auto &connection : std::as_const(m_multiSelectConnections)) - disconnect(connection); - m_multiSelectConnections.clear(); - m_multiSelectRootNode = multiSelectRootNode; - QSet<QQuick3DNode *> selNodes; - - for (const auto &var : selectedList) { - QQuick3DNode *node = nullptr; - node = var.value<QQuick3DNode *>(); - if (node) - selNodes.insert(node); - } - for (const auto selNode : std::as_const(selNodes)) { - bool found = false; - QQuick3DNode *parent = selNode->parentNode(); - while (parent) { - if (selNodes.contains(parent)) { - found = true; - break; - } - parent = parent->parentNode(); - } - if (!found) { - m_multiSelDataMap.insert(selNode, {}); - m_multiSelNodes.append(QVariant::fromValue(selNode)); - m_multiSelectConnections.append(connect(selNode, &QObject::destroyed, [this]() { - // If any multiselected node is destroyed, assume the entire selection is invalid. - // The new selection should be notified by creator immediately after anyway. - m_multiSelDataMap.clear(); - m_multiSelNodes.clear(); - for (auto &connection : std::as_const(m_multiSelectConnections)) - disconnect(connection); - m_multiSelectConnections.clear(); - })); - m_multiSelectConnections.append(connect(selNode, &QQuick3DNode::sceneTransformChanged, - [this]() { - // Reposition the multiselection root node if scene transform of any multiselected - // node changes outside of drag (i.e. changes originating from creator side) - if (!m_blockMultiSelectionNodePositioning) - resetMultiSelectionNode(); - })); - } - } - - resetMultiSelectionNode(); - m_blockMultiSelectionNodePositioning = false; -} - -void GeneralHelper::resetMultiSelectionNode() -{ - for (auto it = m_multiSelDataMap.begin(); it != m_multiSelDataMap.end(); ++it) - it.value() = {pivotScenePosition(it.key()), it.key()->scale(), - it.key()->rotation(), it.key()->sceneRotation()}; - - m_multiSelNodeData = {}; - if (!m_multiSelDataMap.isEmpty()) { - for (const auto &data : std::as_const(m_multiSelDataMap)) - m_multiSelNodeData.startScenePos += data.startScenePos; - m_multiSelNodeData.startScenePos /= m_multiSelDataMap.size(); - } - m_multiSelectRootNode->setPosition(m_multiSelNodeData.startScenePos); - m_multiSelectRootNode->setRotation({}); - m_multiSelectRootNode->setScale({1.f, 1.f, 1.f}); -} - -void GeneralHelper::restartMultiSelection() -{ - resetMultiSelectionNode(); - m_blockMultiSelectionNodePositioning = true; -} - -QVariantList GeneralHelper::multiSelectionTargets() const -{ - return m_multiSelNodes; -} - -void GeneralHelper::moveMultiSelection(bool commit) -{ - // Move the multiselected nodes in global space by offset from multiselection start to scenePos - QVector3D globalOffset = m_multiSelectRootNode->scenePosition() - m_multiSelNodeData.startScenePos; - for (auto it = m_multiSelDataMap.constBegin(); it != m_multiSelDataMap.constEnd(); ++it) { - QVector3D newGlobalPos = it.value().startScenePos + globalOffset; - QMatrix4x4 m; - if (it.key()->parentNode()) - m = it.key()->parentNode()->sceneTransform(); - it.key()->setPosition(m.inverted() * newGlobalPos); - } - m_blockMultiSelectionNodePositioning = !commit; -} - -void GeneralHelper::scaleMultiSelection(bool commit) -{ - // Offset the multiselected nodes in global space according to scale factor and scale them by - // the same factor. - - const QVector3D sceneScale = m_multiSelectRootNode->scale(); - const QVector3D unitVector {1.f, 1.f, 1.f}; - const QVector3D diffScale = sceneScale - unitVector; - - for (auto it = m_multiSelDataMap.constBegin(); it != m_multiSelDataMap.constEnd(); ++it) { - const QVector3D newGlobalPos = m_multiSelNodeData.startScenePos - + (it.value().startScenePos - m_multiSelNodeData.startScenePos) * sceneScale; - QMatrix4x4 parentMat; - if (it.key()->parentNode()) - parentMat = it.key()->parentNode()->sceneTransform().inverted(); - it.key()->setPosition(parentMat * newGlobalPos); - - QMatrix4x4 mat; - mat.rotate(it.value().startSceneRot); - - auto scaleDim = [&](int dim) -> QVector3D { - QVector3D dimScale; - float diffScaleDim = diffScale[dim]; - dimScale[dim] = diffScaleDim; - dimScale = (mat.inverted() * dimScale).normalized() * diffScaleDim; - for (int i = 0; i < 3; ++i) - dimScale[i] = qAbs(dimScale[i]); - if (sceneScale[dim] < 1.0f) - dimScale = -dimScale; - return dimScale; - }; - - QVector3D finalScale = scaleDim(0) + scaleDim(1) + scaleDim(2) + unitVector; - - it.key()->setScale(finalScale * it.value().startScale); - } - m_blockMultiSelectionNodePositioning = !commit; -} - -void GeneralHelper::rotateMultiSelection(bool commit) -{ - // Rotate entire selection around the multiselection node - const QQuaternion sceneRotation = m_multiSelectRootNode->sceneRotation(); - QVector3D rotAxis; - float rotAngle = 0; - sceneRotation.getAxisAndAngle(&rotAxis, &rotAngle); - - for (auto it = m_multiSelDataMap.constBegin(); it != m_multiSelDataMap.constEnd(); ++it) { - QVector3D globalOffset = it.value().startScenePos - m_multiSelNodeData.startScenePos; - QVector3D newGlobalPos = m_multiSelNodeData.startScenePos + sceneRotation * globalOffset; - QMatrix4x4 parentMat; - if (it.key()->parentNode()) - parentMat = it.key()->parentNode()->sceneTransform().inverted(); - it.key()->setPosition(parentMat * newGlobalPos); - it.key()->setRotation(it.value().startRot); - it.key()->rotate(rotAngle, rotAxis, QQuick3DNode::SceneSpace); - } - m_blockMultiSelectionNodePositioning = !commit; -} - -bool GeneralHelper::isMacOS() const -{ -#ifdef Q_OS_MACOS - return true; -#else - return false; -#endif -} - -void GeneralHelper::addRotationBlocks(const QSet<QQuick3DNode *> &nodes) -{ - m_rotationBlockedNodes.unite(nodes); - emit rotationBlocksChanged(); -} - -void GeneralHelper::removeRotationBlocks(const QSet<QQuick3DNode *> &nodes) -{ - for (auto node : nodes) - m_rotationBlockedNodes.remove(node); - emit rotationBlocksChanged(); -} - -bool GeneralHelper::isRotationBlocked(QQuick3DNode *node) const -{ - return m_rotationBlockedNodes.contains(node); -} - -void GeneralHelper::handlePendingToolStateUpdate() -{ - m_toolStateUpdateTimer.stop(); - auto sceneIt = m_toolStatesPending.constBegin(); - while (sceneIt != m_toolStatesPending.constEnd()) { - const QVariantMap &sceneToolState = sceneIt.value(); - auto toolIt = sceneToolState.constBegin(); - while (toolIt != sceneToolState.constEnd()) { - storeToolState(sceneIt.key(), toolIt.key(), toolIt.value()); - ++toolIt; - } - ++sceneIt; - } - m_toolStatesPending.clear(); -} - -// Calculate scene position of the node's pivot point, which in practice is just the position -// of the node without applying the pivot offset. -QVector3D GeneralHelper::pivotScenePosition(QQuick3DNode *node) const -{ - if (!node) - return {}; - - QQuick3DNode *parent = node->parentNode(); - if (!parent) - return node->position(); - - QMatrix4x4 localTransform; - localTransform.translate(node->position()); - - const QMatrix4x4 sceneTransform = parent->sceneTransform() * localTransform; - - return mat44::getPosition(sceneTransform); -} - -// Calculate bounds for given node, including all child nodes. -// Returns true if the tree contains at least one Model node. -bool GeneralHelper::getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVector3D &minBounds, - QVector3D &maxBounds) -{ - if (!node) { - const float halfExtent = 100.f; - minBounds = {-halfExtent, -halfExtent, -halfExtent}; - maxBounds = {halfExtent, halfExtent, halfExtent}; - return false; - } - - QMatrix4x4 localTransform; - auto nodePriv = QQuick3DObjectPrivate::get(node); - auto renderNode = static_cast<QSSGRenderNode *>(nodePriv->spatialNode); - - if (renderNode) { -#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) - if (renderNode->flags.testFlag(QSSGRenderNode::Flag::TransformDirty)) - renderNode->calculateLocalTransform(); -#else - if (renderNode->isDirty(QSSGRenderNode::DirtyFlag::TransformDirty)) { - renderNode->localTransform = QSSGRenderNode::calculateTransformMatrix( - node->position(), node->scale(), node->pivot(), node->rotation()); - } -#endif - localTransform = renderNode->localTransform; - } - - QVector3D localMinBounds = maxVec; - QVector3D localMaxBounds = minVec; - - // Find bounds for children - QVector<QVector3D> minBoundsVec; - QVector<QVector3D> maxBoundsVec; - const auto children = node->childItems(); - bool hasModel = false; - for (const auto child : children) { - if (auto childNode = qobject_cast<QQuick3DNode *>(child)) { - QVector3D newMinBounds = minBounds; - QVector3D newMaxBounds = maxBounds; - bool childHasModel = getBounds(view3D, childNode, newMinBounds, newMaxBounds); - // Ignore any subtrees that do not have Model in them as we don't need those - // for visual bounds calculations - if (childHasModel) { - minBoundsVec << newMinBounds; - maxBoundsVec << newMaxBounds; - hasModel = true; - } - } - } - - auto combineMinBounds = [](QVector3D &target, const QVector3D &source) { - target.setX(qMin(source.x(), target.x())); - target.setY(qMin(source.y(), target.y())); - target.setZ(qMin(source.z(), target.z())); - }; - auto combineMaxBounds = [](QVector3D &target, const QVector3D &source) { - target.setX(qMax(source.x(), target.x())); - target.setY(qMax(source.y(), target.y())); - target.setZ(qMax(source.z(), target.z())); - }; - auto transformCorner = [&](const QMatrix4x4 &m, QVector3D &minTarget, QVector3D &maxTarget, - const QVector3D &corner) { - QVector3D mappedCorner = m.map(corner); - combineMinBounds(minTarget, mappedCorner); - combineMaxBounds(maxTarget, mappedCorner); - }; - auto transformCorners = [&](const QMatrix4x4 &m, QVector3D &minTarget, QVector3D &maxTarget, - const QVector3D &minCorner, const QVector3D &maxCorner) { - transformCorner(m, minTarget, maxTarget, minCorner); - transformCorner(m, minTarget, maxTarget, maxCorner); - transformCorner(m, minTarget, maxTarget, QVector3D(minCorner.x(), minCorner.y(), maxCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(minCorner.x(), maxCorner.y(), minCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(maxCorner.x(), minCorner.y(), minCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(minCorner.x(), maxCorner.y(), maxCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(maxCorner.x(), maxCorner.y(), minCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(maxCorner.x(), minCorner.y(), maxCorner.z())); - }; - - // Combine all child bounds - for (const auto &newBounds : std::as_const(minBoundsVec)) - combineMinBounds(localMinBounds, newBounds); - for (const auto &newBounds : std::as_const(maxBoundsVec)) - combineMaxBounds(localMaxBounds, newBounds); - - if (qobject_cast<QQuick3DModel *>(node)) { - if (auto renderModel = static_cast<QSSGRenderModel *>(renderNode)) { - QWindow *window = static_cast<QWindow *>(view3D->window()); - if (window) { - QSSGRef<QSSGRenderContextInterface> context; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); -#else - context = QQuick3DObjectPrivate::get(node)->sceneManager->rci; -#endif - if (!context.isNull()) { - auto bufferManager = context->bufferManager(); -#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0) - QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager); -#else - QSSGBounds3 bounds = bufferManager->getModelBounds(renderModel); -#endif - QVector3D center = bounds.center(); - QVector3D extents = bounds.extents(); - QVector3D localMin = center - extents; - QVector3D localMax = center + extents; - - combineMinBounds(localMinBounds, localMin); - combineMaxBounds(localMaxBounds, localMax); - - hasModel = true; - } - } - } - } else { - combineMinBounds(localMinBounds, {}); - combineMaxBounds(localMaxBounds, {}); - } - - if (localMaxBounds == minVec) { - localMinBounds = {}; - localMaxBounds = {}; - } - - // Transform local space bounding box to parent space - transformCorners(localTransform, minBounds, maxBounds, localMinBounds, localMaxBounds); - - return hasModel; -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h deleted file mode 100644 index 402cd94a3c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/generalhelper.h +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include <QColor> -#include <QHash> -#include <QMatrix4x4> -#include <QObject> -#include <QPointer> -#include <QQuaternion> -#include <QTimer> -#include <QUrl> -#include <QVariant> -#include <QVector3D> -#include <QtQuick3D/private/qquick3dpickresult_p.h> - -QT_BEGIN_NAMESPACE -class QQuick3DCamera; -class QQuick3DNode; -class QQuick3DViewport; -class QQuick3DMaterial; -class QQuickItem; -QT_END_NAMESPACE - -namespace QmlDesigner { -namespace Internal { - -class GeneralHelper : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool isMacOS READ isMacOS CONSTANT) - -public: - GeneralHelper(); - - Q_INVOKABLE void requestOverlayUpdate(); - Q_INVOKABLE QString generateUniqueName(const QString &nameRoot); - Q_INVOKABLE QUrl resolveAbsoluteSourceUrl(const QQuick3DModel *sourceModel); - - Q_INVOKABLE void orbitCamera(QQuick3DCamera *camera, const QVector3D &startRotation, - const QVector3D &lookAtPoint, const QVector3D &pressPos, - const QVector3D ¤tPos); - Q_INVOKABLE QVector3D panCamera(QQuick3DCamera *camera, const QMatrix4x4 startTransform, - const QVector3D &startPosition, const QVector3D &startLookAt, - const QVector3D &pressPos, const QVector3D ¤tPos, - float zoomFactor); - Q_INVOKABLE float zoomCamera(QQuick3DViewport *viewPort, QQuick3DCamera *camera, float distance, - float defaultLookAtDistance, const QVector3D &lookAt, - float zoomFactor, bool relative); - Q_INVOKABLE QVector4D focusNodesToCamera(QQuick3DCamera *camera, float defaultLookAtDistance, - const QVariant &nodes, QQuick3DViewport *viewPort, - float oldZoom, bool updateZoom = true, - bool closeUp = false); - Q_INVOKABLE void calculateNodeBoundsAndFocusCamera(QQuick3DCamera *camera, QQuick3DNode *node, - QQuick3DViewport *viewPort, - float defaultLookAtDistance, bool closeUp); - Q_INVOKABLE void alignCameras(QQuick3DCamera *camera, const QVariant &nodes); - Q_INVOKABLE QVector3D alignView(QQuick3DCamera *camera, const QVariant &nodes, - const QVector3D &lookAtPoint); - Q_INVOKABLE bool fuzzyCompare(double a, double b); - Q_INVOKABLE void delayedPropertySet(QObject *obj, int delay, const QString &property, - const QVariant& value); - Q_INVOKABLE QQuick3DPickResult pickViewAt(QQuick3DViewport *view, float posX, float posY); - Q_INVOKABLE QObject *resolvePick(QQuick3DNode *pickNode); - - Q_INVOKABLE bool isLocked(QQuick3DNode *node) const; - Q_INVOKABLE bool isHidden(QQuick3DNode *node) const; - Q_INVOKABLE bool isPickable(QQuick3DNode *node) const; - Q_INVOKABLE QQuick3DNode *createParticleEmitterGizmoModel(QQuick3DNode *emitter, - QQuick3DMaterial *material) const; - - Q_INVOKABLE void storeToolState(const QString &sceneId, const QString &tool, - const QVariant &state, int delayEmit = 0); - void initToolStates(const QString &sceneId, const QVariantMap &toolStates); - Q_INVOKABLE void enableItemUpdate(QQuickItem *item, bool enable); - Q_INVOKABLE QVariantMap getToolStates(const QString &sceneId); - QString globalStateId() const; - QString lastSceneIdKey() const; - QString rootSizeKey() const; - - Q_INVOKABLE double brightnessScaler() const; - - Q_INVOKABLE void setMultiSelectionTargets(QQuick3DNode *multiSelectRootNode, - const QVariantList &selectedList); - Q_INVOKABLE void resetMultiSelectionNode(); - Q_INVOKABLE void restartMultiSelection(); - Q_INVOKABLE QVariantList multiSelectionTargets() const; - Q_INVOKABLE void moveMultiSelection(bool commit); - Q_INVOKABLE void scaleMultiSelection(bool commit); - Q_INVOKABLE void rotateMultiSelection(bool commit); - - void setSceneEnvironmentColor(const QString &sceneId, const QColor &color); - Q_INVOKABLE QColor sceneEnvironmentColor(const QString &sceneId) const; - - bool isMacOS() const; - - void addRotationBlocks(const QSet<QQuick3DNode *> &nodes); - void removeRotationBlocks(const QSet<QQuick3DNode *> &nodes); - Q_INVOKABLE bool isRotationBlocked(QQuick3DNode *node) const; - -signals: - void overlayUpdateNeeded(); - void toolStateChanged(const QString &sceneId, const QString &tool, const QVariant &toolState); - void hiddenStateChanged(QQuick3DNode *node); - void lockedStateChanged(QQuick3DNode *node); - void rotationBlocksChanged(); - -private: - void handlePendingToolStateUpdate(); - QVector3D pivotScenePosition(QQuick3DNode *node) const; - bool getBounds(QQuick3DViewport *view3D, QQuick3DNode *node, QVector3D &minBounds, - QVector3D &maxBounds); - - QTimer m_overlayUpdateTimer; - QTimer m_toolStateUpdateTimer; - QHash<QString, QVariantMap> m_toolStates; - QHash<QString, QVariantMap> m_toolStatesPending; - QHash<QString, QColor> m_sceneEnvironmentColor; - QSet<QQuick3DNode *> m_rotationBlockedNodes; - - struct MultiSelData { - QVector3D startScenePos; - QVector3D startScale; - QQuaternion startRot; - QQuaternion startSceneRot; - }; - - QHash<QQuick3DNode *, MultiSelData> m_multiSelDataMap; - QVariantList m_multiSelNodes; - MultiSelData m_multiSelNodeData; - QQuick3DNode *m_multiSelectRootNode = nullptr; - QList<QMetaObject::Connection> m_multiSelectConnections; - bool m_blockMultiSelectionNodePositioning = false; -}; - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/geometrybase.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/geometrybase.cpp deleted file mode 100644 index 4e09944739..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/geometrybase.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "geometrybase.h" - -namespace QmlDesigner { -namespace Internal { - -GeometryBase::GeometryBase() - : QQuick3DGeometry() -{ - m_updatetimer.setSingleShot(true); - m_updatetimer.setInterval(0); - connect(&m_updatetimer, &QTimer::timeout, this, &GeometryBase::doUpdateGeometry); - updateGeometry(); - setStride(12); // To avoid div by zero inside QtQuick3D -} - -GeometryBase::~GeometryBase() -{ -} - -void GeometryBase::doUpdateGeometry() -{ - clear(); - - setStride(12); - - addAttribute(QQuick3DGeometry::Attribute::PositionSemantic, 0, - QQuick3DGeometry::Attribute::F32Type); - setPrimitiveType(QQuick3DGeometry::PrimitiveType::Lines); - - update(); -} - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -QString GeometryBase::name() const -{ - return objectName(); -} - -void GeometryBase::setName(const QString &name) -{ - setObjectName(name); - emit nameChanged(); -} -#endif - -void GeometryBase::updateGeometry() -{ - m_updatetimer.start(); -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/geometrybase.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/geometrybase.h deleted file mode 100644 index a50009b0c8..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/geometrybase.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include <QtQuick3D/private/qquick3dgeometry_p.h> - -#include <QTimer> - -namespace QmlDesigner { -namespace Internal { - -class GeometryBase : public QQuick3DGeometry -{ - Q_OBJECT - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - // Name property was removed in Qt 6, so define it here for compatibility. - // Name maps to object name. - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) -public: - QString name() const; - void setName(const QString &name); -signals: - void nameChanged(); -#endif - -public: - GeometryBase(); - ~GeometryBase() override; - -protected: - void updateGeometry(); - virtual void doUpdateGeometry(); - -private: - QTimer m_updatetimer; -}; - -} -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::GeometryBase) - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp deleted file mode 100644 index d2f04ef38f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "gridgeometry.h" - -namespace QmlDesigner { -namespace Internal { - -GridGeometry::GridGeometry() - : GeometryBase() -{ - updateGeometry(); -} - -GridGeometry::~GridGeometry() -{ -} - -int GridGeometry::lines() const -{ - return m_lines; -} - -float GridGeometry::step() const -{ - return m_step; -} - -bool GridGeometry::isCenterLine() const -{ - return m_isCenterLine; -} - -// Number of lines on each side of the center lines. -// These lines are not drawn if m_isCenterLine is true; lines and step are simply used to calculate -// the length of the center line in that case. -void GridGeometry::setLines(int count) -{ - count = qMax(count, 1); - if (m_lines == count) - return; - m_lines = qMax(count, 1); - emit linesChanged(); - updateGeometry(); -} - -// Space between lines -void GridGeometry::setStep(float step) -{ - step = qMax(step, 0.0f); - if (qFuzzyCompare(m_step, step)) - return; - m_step = step; - emit stepChanged(); - updateGeometry(); -} - -void GridGeometry::setIsCenterLine(bool enabled) -{ - if (m_isCenterLine == enabled) - return; - - m_isCenterLine = enabled; - emit isCenterLineChanged(); - updateGeometry(); -} - -void GridGeometry::doUpdateGeometry() -{ - GeometryBase::doUpdateGeometry(); - - QByteArray vertexData; - fillVertexData(vertexData); - - setVertexData(vertexData); - - int lastIndex = (vertexData.size() - 1) / int(sizeof(QVector3D)); - auto vertexPtr = reinterpret_cast<QVector3D *>(vertexData.data()); - setBounds(QVector3D(vertexPtr[0][0], vertexPtr[0][1], 0.0), - QVector3D(vertexPtr[lastIndex][0], vertexPtr[lastIndex][1], 0.0)); -} - -void GridGeometry::fillVertexData(QByteArray &vertexData) -{ - const int numSubdivs = 1; // number of subdivision lines (i.e. lines between main grid lines) - const int vtxSize = int(sizeof(float)) * 3 * 2; - const int size = m_isCenterLine ? vtxSize - : m_isSubdivision ? 4 * m_lines * vtxSize * numSubdivs - : 4 * m_lines * vtxSize; - vertexData.resize(size); - float *dataPtr = reinterpret_cast<float *>(vertexData.data()); - - float x0 = -float(m_lines) * m_step; - float y0 = x0; - float x1 = -x0; - float y1 = x1; - - if (m_isCenterLine) { - // start position - dataPtr[0] = 0.f; - dataPtr[1] = y0; - dataPtr[2] = 0.f; - // end position - dataPtr[3] = 0.f; - dataPtr[4] = y1; - dataPtr[5] = 0.f; - } else { - // Lines are created so that bounding box can later be calculated from first and last vertex - if (m_isSubdivision) { - const float subdivStep = m_step / float(numSubdivs + 1); - const int subdivMainLines = m_lines * 2; - auto generateSubLines = [&](float x0, float y0, float x1, float y1, bool vertical) { - for (int i = 0; i < subdivMainLines; ++i) { - for (int j = 1; j <= numSubdivs; ++j) { - // start position - dataPtr[0] = vertical ? x0 + i * m_step + j * subdivStep : x0; - dataPtr[1] = vertical ? y0 : y0 + i * m_step + j * subdivStep; - dataPtr[2] = .0f; - // end position - dataPtr[3] = vertical ? x0 + i * m_step + j * subdivStep : x1; - dataPtr[4] = vertical ? y1 : y0 + i * m_step + j * subdivStep; - dataPtr[5] = .0f; - dataPtr += 6; - } - } - }; - generateSubLines(x0, y0, x1, y1, true); - generateSubLines(x0, y0, x1, y1, false); - } else { - auto generateLines = [this, &dataPtr](float x0, float y0, float x1, float y1, bool vertical) { - for (int i = 0; i < m_lines; ++i) { - // start position - dataPtr[0] = vertical ? x0 + i * m_step : x0; - dataPtr[1] = vertical ? y0 : y0 + i * m_step; - dataPtr[2] = .0f; - // end position - dataPtr[3] = vertical ? x0 + i * m_step : x1; - dataPtr[4] = vertical ? y1 : y0 + i * m_step; - dataPtr[5] = .0f; - dataPtr += 6; - } - }; - generateLines(x0, y0, x1, y1, true); - generateLines(x0, y0, x1, y1, false); - generateLines(x0, m_step, x1, y1, false); - generateLines(m_step, y0, x1, y1, true); - } - } -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h deleted file mode 100644 index 376c9d3bf4..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/gridgeometry.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include "geometrybase.h" - -namespace QmlDesigner { -namespace Internal { - -class GridGeometry : public GeometryBase -{ - Q_OBJECT - - Q_PROPERTY(int lines READ lines WRITE setLines NOTIFY linesChanged) - Q_PROPERTY(float step READ step WRITE setStep NOTIFY stepChanged) - Q_PROPERTY(bool isCenterLine READ isCenterLine WRITE setIsCenterLine NOTIFY isCenterLineChanged) - Q_PROPERTY(bool isSubdivision MEMBER m_isSubdivision) - -public: - GridGeometry(); - ~GridGeometry() override; - - int lines() const; - float step() const; - bool isCenterLine() const; - -public slots: - void setLines(int count); - void setStep(float step); - void setIsCenterLine(bool enabled); - -signals: - void linesChanged(); - void stepChanged(); - void isCenterLineChanged(); - -protected: - void doUpdateGeometry() override; - -private: - void fillVertexData(QByteArray &vertexData); - - int m_lines = 20; // number of lines on 1 side of an axis (so total number of grid lines in 1 direction = 2 * m_lines + 1) - float m_step = .1f; - bool m_isCenterLine = false; - bool m_isSubdivision = false; -}; - -} -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::GridGeometry) - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/icongizmoimageprovider.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/icongizmoimageprovider.cpp deleted file mode 100644 index 9f045ebe40..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/icongizmoimageprovider.cpp +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "icongizmoimageprovider.h" - -namespace QmlDesigner { -namespace Internal { - -IconGizmoImageProvider::IconGizmoImageProvider() - : QQuickImageProvider(QQuickImageProvider::Image) -{ -} - -QImage IconGizmoImageProvider::requestImage(const QString &id, - [[maybe_unused]] QSize *size, - [[maybe_unused]] const QSize &requestedSize) -{ - // id format: <file name>:<color name> - QStringList parts = id.split(':'); - if (parts.size() == 2) { - QImage image(QStringLiteral("://qtquickplugin/mockfiles/images/%1").arg(parts[0])); - - // Recolorize non-transparent image pixels - QColor targetColor(parts[1]); - int r = targetColor.red(); - int g = targetColor.green(); - int b = targetColor.blue(); - int size = image.sizeInBytes(); - uchar *byte = image.bits(); - for (int i = 0; i < size; i += 4) { - // Skip if alpha is zero - if (*(byte + 3) != 0) { - // Average between target color and current color - *byte = uchar((int(*byte) + b) / 2); - ++byte; - *byte = uchar((int(*byte) + g) / 2); - ++byte; - *byte = uchar((int(*byte) + r) / 2); - ++byte; - // Preserve alpha - ++byte; - } else { - byte += 4; - } - } - return image; - } else { - return {}; - } -} - -} -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/icongizmoimageprovider.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/icongizmoimageprovider.h deleted file mode 100644 index 4cc9ee3795..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/icongizmoimageprovider.h +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtQuick/qquickimageprovider.h> - -namespace QmlDesigner { -namespace Internal { - -class IconGizmoImageProvider : public QQuickImageProvider -{ -public: - IconGizmoImageProvider(); - - QImage requestImage(const QString &id, QSize *size, const QSize &requestedSize) override; -}; -} -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp deleted file mode 100644 index dd15a65595..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.cpp +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "lightgeometry.h" - -#include <QtQuick3DRuntimeRender/private/qssgrendergeometry_p.h> -#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h> -#include <QtCore/qmath.h> - -#include <limits> - -namespace QmlDesigner { -namespace Internal { - -LightGeometry::LightGeometry() - : GeometryBase() -{ -} - -LightGeometry::~LightGeometry() -{ -} - -LightGeometry::LightType LightGeometry::lightType() const -{ - return m_lightType; -} - -void LightGeometry::setLightType(LightGeometry::LightType lightType) -{ - if (m_lightType == lightType) - return; - - m_lightType = lightType; - - emit lightTypeChanged(); - updateGeometry(); -} - -void LightGeometry::doUpdateGeometry() -{ - if (m_lightType == LightType::Invalid) - return; - - GeometryBase::doUpdateGeometry(); - - QByteArray vertexData; - QByteArray indexData; - QVector3D minBounds; - QVector3D maxBounds; - - fillVertexData(vertexData, indexData, minBounds, maxBounds); - - addAttribute(QQuick3DGeometry::Attribute::IndexSemantic, 0, - QQuick3DGeometry::Attribute::U16Type); - - setVertexData(vertexData); - setIndexData(indexData); - setBounds(minBounds, maxBounds); -} - -void LightGeometry::fillVertexData(QByteArray &vertexData, QByteArray &indexData, - QVector3D &minBounds, QVector3D &maxBounds) -{ - int vertexSize = 0; - int indexSize = 0; - const int arc = 12; // Segment lines per cone line in spot/directional light arc - const int dirLines = 4; // Directional lines in spot/directional light - const quint16 segments = arc * dirLines; - const double segment = M_PI * 2. / double(segments); - - if (m_lightType == LightType::Area) { - // Area light model is a rectangle - vertexSize = int(sizeof(float)) * 3 * 4; - indexSize = int(sizeof(quint16)) * 4 * 2; - } else if (m_lightType == LightType::Directional) { - // Directional light model is a circle with perpendicular lines on circumference vertices - vertexSize = int(sizeof(float)) * 3 * (segments + dirLines); - indexSize = int(sizeof(quint16)) * (segments + dirLines) * 2; - } else if (m_lightType == LightType::Spot) { - vertexSize = int(sizeof(float)) * 3 * (segments + 1); - indexSize = int(sizeof(quint16)) * (segments + dirLines) * 2; - } else if (m_lightType == LightType::Point) { - vertexSize = int(sizeof(float)) * 3 * segments; - indexSize = int(sizeof(quint16)) * segments * 2; - } - vertexData.resize(vertexSize); - indexData.resize(indexSize); - - auto dataPtr = reinterpret_cast<float *>(vertexData.data()); - auto indexPtr = reinterpret_cast<quint16 *>(indexData.data()); - - auto createCircle = [&](quint16 startIndex, float zVal, int xIdx, int yIdx, int zIdx) { - for (quint16 i = 0; i < segments; ++i) { - float x = float(qCos(i * segment)); - float y = float(qSin(i * segment)); - auto vecPtr = reinterpret_cast<QVector3D *>(dataPtr); - (*vecPtr)[xIdx] = x; - (*vecPtr)[yIdx] = y; - (*vecPtr)[zIdx] = zVal; - dataPtr += 3; - *indexPtr++ = startIndex + i; *indexPtr++ = startIndex + i + 1; - } - // Adjust the final index to complete the circle - *(indexPtr - 1) = startIndex; - }; - - if (m_lightType == LightType::Area) { - *dataPtr++ = -1.f; *dataPtr++ = 1.f; *dataPtr++ = 0.f; - *dataPtr++ = -1.f; *dataPtr++ = -1.f; *dataPtr++ = 0.f; - *dataPtr++ = 1.f; *dataPtr++ = -1.f; *dataPtr++ = 0.f; - *dataPtr++ = 1.f; *dataPtr++ = 1.f; *dataPtr++ = 0.f; - - *indexPtr++ = 0; *indexPtr++ = 1; - *indexPtr++ = 1; *indexPtr++ = 2; - *indexPtr++ = 2; *indexPtr++ = 3; - *indexPtr++ = 3; *indexPtr++ = 0; - } else if (m_lightType == LightType::Directional) { - createCircle(0, 0.f, 0, 1, 2); - - // Dir lines - for (quint16 i = 0; i < dirLines; ++i) { - auto circlePtr = reinterpret_cast<float *>(vertexData.data()) + (3 * arc * i); - *dataPtr++ = *circlePtr; *dataPtr++ = *(circlePtr + 1); *dataPtr++ = -3.f; - *indexPtr++ = i * arc; - *indexPtr++ = i + segments; - } - } else if (m_lightType == LightType::Spot) { - createCircle(0, -1.f, 0, 1, 2); - - // Cone tip - *dataPtr++ = 0.f; *dataPtr++ = 0.f; *dataPtr++ = 0.f; - quint16 tipIndex = segments; - - // Cone lines - for (quint16 i = 0; i < dirLines; ++i) { - *indexPtr++ = tipIndex; - *indexPtr++ = i * arc; - } - } else if (m_lightType == LightType::Point) { - createCircle(0, 0.f, 0, 1, 2); - } - - static const float floatMin = std::numeric_limits<float>::lowest(); - static const float floatMax = std::numeric_limits<float>::max(); - auto vertexPtr = reinterpret_cast<QVector3D *>(vertexData.data()); - minBounds = QVector3D(floatMax, floatMax, floatMax); - maxBounds = QVector3D(floatMin, floatMin, floatMin); - for (int i = 0; i < vertexSize / 12; ++i) { - minBounds[0] = qMin((*vertexPtr)[0], minBounds[0]); - minBounds[1] = qMin((*vertexPtr)[1], minBounds[1]); - minBounds[2] = qMin((*vertexPtr)[2], minBounds[2]); - maxBounds[0] = qMax((*vertexPtr)[0], maxBounds[0]); - maxBounds[1] = qMax((*vertexPtr)[1], maxBounds[1]); - maxBounds[2] = qMax((*vertexPtr)[2], maxBounds[2]); - ++vertexPtr; - } -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h deleted file mode 100644 index d9eff21c76..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/lightgeometry.h +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include "geometrybase.h" - -namespace QmlDesigner { -namespace Internal { - -class LightGeometry : public GeometryBase -{ - Q_OBJECT - Q_PROPERTY(LightType lightType READ lightType WRITE setLightType NOTIFY lightTypeChanged) - -public: - enum class LightType { - Invalid, - Spot, - Area, - Directional, - Point - }; - Q_ENUM(LightType) - - LightGeometry(); - ~LightGeometry() override; - - LightType lightType() const; - -public slots: - void setLightType(LightType lightType); - -signals: - void lightTypeChanged(); - -protected: - void doUpdateGeometry() override; - -private: - void fillVertexData(QByteArray &vertexData, QByteArray &indexData, - QVector3D &minBounds, QVector3D &maxBounds); - LightType m_lightType = LightType::Invalid; -}; - -} -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::LightGeometry) - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp deleted file mode 100644 index c4a18f1e8f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.cpp +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "linegeometry.h" - -namespace QmlDesigner { -namespace Internal { - -LineGeometry::LineGeometry() - : GeometryBase() -{ -} - -LineGeometry::~LineGeometry() -{ -} - -QVector3D LineGeometry::startPos() const -{ - return m_startPos; -} - -QVector3D LineGeometry::endPos() const -{ - return m_endPos; -} - -void LineGeometry::setStartPos(const QVector3D &pos) -{ - if (pos != m_startPos) { - m_startPos = pos; - emit startPosChanged(); - updateGeometry(); - } -} - -void LineGeometry::setEndPos(const QVector3D &pos) -{ - if (pos != m_endPos) { - m_endPos = pos; - emit endPosChanged(); - updateGeometry(); - } -} - -void LineGeometry::doUpdateGeometry() -{ - GeometryBase::doUpdateGeometry(); - - QByteArray vertexData; - vertexData.resize(2 * 3 * 4); // 2 vertices of 3 floats each 4 bytes - float *dataPtr = reinterpret_cast<float *>(vertexData.data()); - - dataPtr[0] = m_startPos[0]; - dataPtr[1] = m_startPos[1]; - dataPtr[2] = m_startPos[2]; - dataPtr[3] = m_endPos[0]; - dataPtr[4] = m_endPos[1]; - dataPtr[5] = m_endPos[2]; - - setVertexData(vertexData); - setBounds(m_startPos, m_endPos); -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h deleted file mode 100644 index 79ac58721d..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/linegeometry.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include "geometrybase.h" - -#include <QtGui/QVector3D> - -namespace QmlDesigner { -namespace Internal { - -class LineGeometry : public GeometryBase -{ - Q_OBJECT - Q_PROPERTY(QVector3D startPos READ startPos WRITE setStartPos NOTIFY startPosChanged) - Q_PROPERTY(QVector3D endPos READ endPos WRITE setEndPos NOTIFY endPosChanged) - -public: - LineGeometry(); - ~LineGeometry() override; - - QVector3D startPos() const; - QVector3D endPos() const; - -public slots: - void setStartPos(const QVector3D &pos); - void setEndPos(const QVector3D &pos); - -signals: - void startPosChanged(); - void endPosChanged(); - -protected: - void doUpdateGeometry() override; - -private: - QVector3D m_startPos; - QVector3D m_endPos; -}; - -} -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::LineGeometry) - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp deleted file mode 100644 index 7430fb0e95..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.cpp +++ /dev/null @@ -1,1037 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "mousearea3d.h" - -#include <QtGui/qguiapplication.h> -#include <QtQml/qqmlinfo.h> -#include <QtQuick3D/private/qquick3dcamera_p.h> -#include <QtQuick3D/private/qquick3dorthographiccamera_p.h> -#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h> -#include <QtQuick3DUtils/private/qssgutils_p.h> -#include <QtCore/qmath.h> - -namespace QmlDesigner { -namespace Internal { - -// Double precision vector for cases where float calculations can suffer from rounding errors -class DoubleVec3D { -public: - DoubleVec3D() = default; - DoubleVec3D(const QVector3D &v) - : x(double(v.x())), - y(double(v.y())), - z(double(v.z())) - {} - DoubleVec3D(double xx, double yy, double zz) - : x(xx), - y(yy), - z(zz) - {} - - static double dotProduct(const DoubleVec3D &v1, const DoubleVec3D &v2) - { - return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z; - } - - QVector3D toVec3() const { return {float(x), float(y), float(z)}; } - - DoubleVec3D normalized() const - { - double len = x * x + y * y + z * z; - if (qFuzzyIsNull(len - 1.)) { - return *this; - } else if (!qFuzzyIsNull(len)) { - double sqrtLen = std::sqrt(len); - return DoubleVec3D(x / sqrtLen, y / sqrtLen, z / sqrtLen); - } else { - return {}; - } - } - - double length() const - { - double len = x * x + y * y + z * z; - return std::sqrt(len); - } - - DoubleVec3D operator-() { return {-x, -y, -z}; } - - double x = 0.; - double y = 0.; - double z = 0.; -}; - - - -DoubleVec3D operator*(double factor, const DoubleVec3D &v) -{ - return DoubleVec3D(v.x * factor, v.y * factor, v.z * factor); -} - -DoubleVec3D operator*(DoubleVec3D &v1, const DoubleVec3D &v2) -{ - return DoubleVec3D(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); -} - -DoubleVec3D operator+(const DoubleVec3D &v1, const DoubleVec3D &v2) -{ - return DoubleVec3D(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z); -} - -DoubleVec3D operator-(const DoubleVec3D &v1, const DoubleVec3D &v2) -{ - return DoubleVec3D(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z); -} - -DoubleVec3D operator/(const DoubleVec3D &v, double div) -{ - return DoubleVec3D(v.x / div, v.y / div, v.z / div); -} - -DoubleVec3D operator/(const DoubleVec3D &v1, const DoubleVec3D &v2) -{ - return DoubleVec3D(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); -} - -// Limited functionality double precision matrix4x4 for cases where float calculations -// can suffer from rounding errors -class DoubleMat44 { -public: - DoubleMat44() - { - // Default is identity matrix - m[0][0] = 1.; - m[0][1] = 0.; - m[0][2] = 0.; - m[0][3] = 0.; - m[1][0] = 0.; - m[1][1] = 1.; - m[1][2] = 0.; - m[1][3] = 0.; - m[2][0] = 0.; - m[2][1] = 0.; - m[2][2] = 1.; - m[2][3] = 0.; - m[3][0] = 0.; - m[3][1] = 0.; - m[3][2] = 0.; - m[3][3] = 1.; - } - - DoubleMat44(const QMatrix4x4 &mat) - { - for (int i = 0; i < 4; ++i) { - for (int j = 0; j < 4; ++j) - m[i][j] = double(mat(j, i)); - } - } - - QMatrix4x4 toQMatrix4x4() - { - return QMatrix4x4(float(m[0][0]), float(m[1][0]), float(m[2][0]), float(m[3][0]), - float(m[0][1]), float(m[1][1]), float(m[2][1]), float(m[3][1]), - float(m[0][2]), float(m[1][2]), float(m[2][2]), float(m[3][2]), - float(m[0][3]), float(m[1][3]), float(m[2][3]), float(m[3][3])); - } - - static inline double matrixDet2(const double m[4][4], int col0, int col1, int row0, int row1) - { - return m[col0][row0] * m[col1][row1] - m[col0][row1] * m[col1][row0]; - } - - static inline double matrixDet3(const double m[4][4], int col0, int col1, int col2, - int row0, int row1, int row2) - { - return m[col0][row0] * matrixDet2(m, col1, col2, row1, row2) - - m[col1][row0] * matrixDet2(m, col0, col2, row1, row2) - + m[col2][row0] * matrixDet2(m, col0, col1, row1, row2); - } - - DoubleMat44 inverted() - { - DoubleMat44 inv; - - double det = matrixDet3(m, 0, 1, 2, 0, 1, 2); - if (det != 0.) { - det = 1. / det; - - inv.m[0][0] = matrixDet2(m, 1, 2, 1, 2) * det; - inv.m[0][1] = -matrixDet2(m, 0, 2, 1, 2) * det; - inv.m[0][2] = matrixDet2(m, 0, 1, 1, 2) * det; - inv.m[0][3] = 0; - inv.m[1][0] = -matrixDet2(m, 1, 2, 0, 2) * det; - inv.m[1][1] = matrixDet2(m, 0, 2, 0, 2) * det; - inv.m[1][2] = -matrixDet2(m, 0, 1, 0, 2) * det; - inv.m[1][3] = 0; - inv.m[2][0] = matrixDet2(m, 1, 2, 0, 1) * det; - inv.m[2][1] = -matrixDet2(m, 0, 2, 0, 1) * det; - inv.m[2][2] = matrixDet2(m, 0, 1, 0, 1) * det; - inv.m[2][3] = 0; - inv.m[3][0] = -inv.m[0][0] * m[3][0] - inv.m[1][0] * m[3][1] - inv.m[2][0] * m[3][2]; - inv.m[3][1] = -inv.m[0][1] * m[3][0] - inv.m[1][1] * m[3][1] - inv.m[2][1] * m[3][2]; - inv.m[3][2] = -inv.m[0][2] * m[3][0] - inv.m[1][2] * m[3][1] - inv.m[2][2] * m[3][2]; - inv.m[3][3] = 1; - } - return inv; - } - - DoubleVec3D transform(const DoubleVec3D &v) - { - DoubleVec3D ret; - - auto multCol = [&](int c, double d) { - ret.x += m[c][0] * d; - ret.y += m[c][1] * d; - ret.z += m[c][2] * d; - }; - - multCol(0, v.x); - multCol(1, v.y); - multCol(2, v.z); - multCol(3, 1.); - - return ret; - } - - static DoubleMat44 matrixMultiD(const QMatrix4x4& m1, const QMatrix4x4& m2) - { - DoubleMat44 m1d(m1); - DoubleMat44 m2d(m2); - - return matrixMultiD(m1d, m2d); - } - - static DoubleMat44 matrixMultiD(const DoubleMat44& m1, const DoubleMat44& m2) - { - DoubleMat44 m; - - m.m[0][0] = m1.m[0][0] * m2.m[0][0] - + m1.m[1][0] * m2.m[0][1] - + m1.m[2][0] * m2.m[0][2] - + m1.m[3][0] * m2.m[0][3]; - m.m[0][1] = m1.m[0][1] * m2.m[0][0] - + m1.m[1][1] * m2.m[0][1] - + m1.m[2][1] * m2.m[0][2] - + m1.m[3][1] * m2.m[0][3]; - m.m[0][2] = m1.m[0][2] * m2.m[0][0] - + m1.m[1][2] * m2.m[0][1] - + m1.m[2][2] * m2.m[0][2] - + m1.m[3][2] * m2.m[0][3]; - m.m[0][3] = m1.m[0][3] * m2.m[0][0] - + m1.m[1][3] * m2.m[0][1] - + m1.m[2][3] * m2.m[0][2] - + m1.m[3][3] * m2.m[0][3]; - - m.m[1][0] = m1.m[0][0] * m2.m[1][0] - + m1.m[1][0] * m2.m[1][1] - + m1.m[2][0] * m2.m[1][2] - + m1.m[3][0] * m2.m[1][3]; - m.m[1][1] = m1.m[0][1] * m2.m[1][0] - + m1.m[1][1] * m2.m[1][1] - + m1.m[2][1] * m2.m[1][2] - + m1.m[3][1] * m2.m[1][3]; - m.m[1][2] = m1.m[0][2] * m2.m[1][0] - + m1.m[1][2] * m2.m[1][1] - + m1.m[2][2] * m2.m[1][2] - + m1.m[3][2] * m2.m[1][3]; - m.m[1][3] = m1.m[0][3] * m2.m[1][0] - + m1.m[1][3] * m2.m[1][1] - + m1.m[2][3] * m2.m[1][2] - + m1.m[3][3] * m2.m[1][3]; - - m.m[2][0] = m1.m[0][0] * m2.m[2][0] - + m1.m[1][0] * m2.m[2][1] - + m1.m[2][0] * m2.m[2][2] - + m1.m[3][0] * m2.m[2][3]; - m.m[2][1] = m1.m[0][1] * m2.m[2][0] - + m1.m[1][1] * m2.m[2][1] - + m1.m[2][1] * m2.m[2][2] - + m1.m[3][1] * m2.m[2][3]; - m.m[2][2] = m1.m[0][2] * m2.m[2][0] - + m1.m[1][2] * m2.m[2][1] - + m1.m[2][2] * m2.m[2][2] - + m1.m[3][2] * m2.m[2][3]; - m.m[2][3] = m1.m[0][3] * m2.m[2][0] - + m1.m[1][3] * m2.m[2][1] - + m1.m[2][3] * m2.m[2][2] - + m1.m[3][3] * m2.m[2][3]; - - m.m[3][0] = m1.m[0][0] * m2.m[3][0] - + m1.m[1][0] * m2.m[3][1] - + m1.m[2][0] * m2.m[3][2] - + m1.m[3][0] * m2.m[3][3]; - m.m[3][1] = m1.m[0][1] * m2.m[3][0] - + m1.m[1][1] * m2.m[3][1] - + m1.m[2][1] * m2.m[3][2] - + m1.m[3][1] * m2.m[3][3]; - m.m[3][2] = m1.m[0][2] * m2.m[3][0] - + m1.m[1][2] * m2.m[3][1] - + m1.m[2][2] * m2.m[3][2] - + m1.m[3][2] * m2.m[3][3]; - m.m[3][3] = m1.m[0][3] * m2.m[3][0] - + m1.m[1][3] * m2.m[3][1] - + m1.m[2][3] * m2.m[3][2] - + m1.m[3][3] * m2.m[3][3]; - - return m; - } - - static DoubleMat44 rotationMatrix(const QQuaternion &rot) - { - DoubleMat44 rotMat; - double xp = double(rot.x()); - double yp = double(rot.y()); - double zp = double(rot.z()); - double wp = double(rot.scalar()); - - const double f2x = xp + xp; - const double f2y = yp + yp; - const double f2z = zp + zp; - const double f2xw = f2x * wp; - const double f2yw = f2y * wp; - const double f2zw = f2z * wp; - const double f2xx = f2x * xp; - const double f2xy = f2x * yp; - const double f2xz = f2x * zp; - const double f2yy = f2y * yp; - const double f2yz = f2y * zp; - const double f2zz = f2z * zp; - - rotMat.m[0][0] = 1. - (f2yy + f2zz); - rotMat.m[1][0] = f2xy - f2zw; - rotMat.m[2][0] = f2xz + f2yw; - rotMat.m[0][1] = f2xy + f2zw; - rotMat.m[1][1] = 1. - (f2xx + f2zz); - rotMat.m[2][1] = f2yz - f2xw; - rotMat.m[0][2] = f2xz - f2yw; - rotMat.m[1][2] = f2yz + f2xw; - rotMat.m[2][2] = 1. - (f2xx + f2yy); - - return rotMat; - } - - double m[4][4]; -}; - -static DoubleMat44 calcLocalTransform(const QQuick3DNode *node) -{ - DoubleVec3D pivotD(-node->pivot()); - const DoubleVec3D scaleD(node->scale()); - const DoubleVec3D posD(node->position()); - pivotD = pivotD * scaleD; - DoubleMat44 localTransform; - - localTransform.m[0][0] = scaleD.x; - localTransform.m[1][1] = scaleD.y; - localTransform.m[2][2] = scaleD.z; - - localTransform.m[3][0] = pivotD.x; - localTransform.m[3][1] = pivotD.y; - localTransform.m[3][2] = pivotD.z; - - DoubleMat44 rotMat = DoubleMat44::rotationMatrix(node->rotation()); - localTransform = DoubleMat44::matrixMultiD(rotMat, localTransform); - - localTransform.m[3][0] += posD.x; - localTransform.m[3][1] += posD.y; - localTransform.m[3][2] += posD.z; - - return localTransform; -} - -static DoubleMat44 calcGlobalTransform(const QQuick3DNode *node) -{ - DoubleMat44 localTrans = calcLocalTransform(node); - QQuick3DNode *parent = node->parentNode(); - if (parent) { - DoubleMat44 globalTrans = calcGlobalTransform(parent); - return DoubleMat44::matrixMultiD(globalTrans, localTrans); - } - return localTrans; -} - -static DoubleVec3D getNormalD(const DoubleMat44 &m) -{ - return DoubleVec3D(m.m[2][0], m.m[2][1], m.m[2][2]).normalized(); -} - -MouseArea3D *MouseArea3D::s_mouseGrab = nullptr; - -MouseArea3D::MouseArea3D(QQuick3DNode *parent) - : QQuick3DNode(parent) -{ -} - -QQuick3DViewport *MouseArea3D::view3D() const -{ - return m_view3D; -} - -bool MouseArea3D::hovering() const -{ - return m_hovering; -} - -bool MouseArea3D::dragging() const -{ - return m_dragging; -} - -bool MouseArea3D::grabsMouse() const -{ - return m_grabsMouse; -} - -bool MouseArea3D::active() const -{ - return m_active; -} - -QPointF MouseArea3D::circlePickArea() const -{ - return m_circlePickArea; -} - -qreal MouseArea3D::minAngle() const -{ - return m_minAngle; -} - -QQuick3DNode *MouseArea3D::pickNode() const -{ - return m_pickNode; -} - -MouseArea3D *MouseArea3D::dragHelper() const -{ - return m_dragHelper; -} - -qreal MouseArea3D::x() const -{ - return m_x; -} - -qreal MouseArea3D::y() const -{ - return m_y; -} - -qreal MouseArea3D::width() const -{ - return m_width; -} - -qreal MouseArea3D::height() const -{ - return m_height; -} - -int MouseArea3D::priority() const -{ - return m_priority; -} - -void MouseArea3D::setView3D(QQuick3DViewport *view3D) -{ - if (m_view3D == view3D) - return; - - m_view3D = view3D; - emit view3DChanged(); -} - -void MouseArea3D::setGrabsMouse(bool grabsMouse) -{ - if (m_grabsMouse == grabsMouse) - return; - - m_grabsMouse = grabsMouse; - - if (!m_grabsMouse && s_mouseGrab == this) { - setDragging(false); - setHovering(false); - s_mouseGrab = nullptr; - } - - emit grabsMouseChanged(); -} - -void MouseArea3D::setActive(bool active) -{ - if (m_active == active) - return; - - m_active = active; - - if (!m_active && s_mouseGrab == this) { - setDragging(false); - setHovering(false); - s_mouseGrab = nullptr; - } - - emit activeChanged(); -} - -void MouseArea3D::setCirclePickArea(const QPointF &pickArea) -{ - if (m_circlePickArea == pickArea) - return; - - m_circlePickArea = pickArea; - emit circlePickAreaChanged(); -} - -// This is the minimum angle for circle picking. At lower angles we fall back to picking on pickNode -void MouseArea3D::setMinAngle(qreal angle) -{ - if (qFuzzyCompare(m_minAngle, angle)) - return; - - m_minAngle = angle; - emit minAngleChanged(); -} - -// This is the fallback pick node when circle picking can't be done due to low angle -// Pick node can't be used except in low angles, as long as only bounding box picking is supported -void MouseArea3D::setPickNode(QQuick3DNode *node) -{ - if (m_pickNode == node) - return; - - m_pickNode = node; - emit pickNodeChanged(); -} - -void MouseArea3D::setDragHelper(MouseArea3D *dragHelper) -{ - if (m_dragHelper == dragHelper) - return; - - m_dragHelper = dragHelper; - emit dragHelperChanged(); -} - -void MouseArea3D::setX(qreal x) -{ - if (qFuzzyCompare(m_x, x)) - return; - - m_x = x; - emit xChanged(); -} - -void MouseArea3D::setY(qreal y) -{ - if (qFuzzyCompare(m_y, y)) - return; - - m_y = y; - emit yChanged(); -} - -void MouseArea3D::setWidth(qreal width) -{ - if (qFuzzyCompare(m_width, width)) - return; - - m_width = width; - emit widthChanged(); -} - -void MouseArea3D::setHeight(qreal height) -{ - if (qFuzzyCompare(m_height, height)) - return; - - m_height = height; - emit heightChanged(); -} - -void MouseArea3D::setPriority(int level) -{ - if (m_priority == level) - return; - - m_priority = level; - emit priorityChanged(); -} - -void MouseArea3D::componentComplete() -{ - if (!m_view3D) { - qmlDebug(this) << "property 'view3D' is not set!"; - return; - } - m_view3D->setAcceptedMouseButtons(Qt::LeftButton); - m_view3D->setAcceptHoverEvents(true); - m_view3D->setAcceptTouchEvents(false); - m_view3D->installEventFilter(this); -} - -static DoubleVec3D rayIntersectsPlaneD(const DoubleVec3D &rayPos0, - const DoubleVec3D &rayPos1, - const DoubleVec3D &planePos, - const DoubleVec3D &planeNormal) -{ - const DoubleVec3D rayDirection = rayPos1 - rayPos0; - const DoubleVec3D rayPos0RelativeToPlane = rayPos0 - planePos; - - const double dotPlaneRayDirection = DoubleVec3D::dotProduct(planeNormal, rayDirection); - const double dotPlaneRayPos0 = -DoubleVec3D::dotProduct(planeNormal, rayPos0RelativeToPlane); - - if (qFuzzyIsNull(dotPlaneRayDirection)) { - // The ray is is parallel to the plane. Note that if dotPlaneRayPos0 == 0, it - // additionally means that the line lies in plane as well. In any case, we - // signal that we cannot find a single intersection point. - return DoubleVec3D(0., 0., -1.); - } - - // Since we work with a ray (that has a start), distanceFromRayPos0ToPlane - // must be above 0. If it was a line segment (with an end), it also need to be less than 1. - // (Note: a third option would be a "line", which is different from a ray or segment in that - // it has neither a start, nor an end). Then we wouldn't need to check the distance at all. - // But that would also mean that the line could intersect the plane behind the camera, if - // the line were directed away from the plane when looking forward. - const double distanceFromRayPos0ToPlane = dotPlaneRayPos0 / dotPlaneRayDirection; - if (distanceFromRayPos0ToPlane <= 0.) - return DoubleVec3D(0., 0., -1.); - return (rayPos0 + distanceFromRayPos0ToPlane * rayDirection); -} - -QVector3D MouseArea3D::rayIntersectsPlane(const QVector3D &rayPos0, - const QVector3D &rayPos1, - const QVector3D &planePos, - const QVector3D &planeNormal) const -{ - const DoubleVec3D rayPos0D(rayPos0); - const DoubleVec3D rayPos1D(rayPos1); - const DoubleVec3D planePosD(planePos); - const DoubleVec3D planeNormalD(planeNormal); - - return rayIntersectsPlaneD(rayPos0D, rayPos1D, planePosD, planeNormalD).toVec3(); -} - -// Get a new scale based on a relative scene distance along a drag axes. -// relativeDistance contains x and y distance on drag plane. axisX indicates which axis corresponds -// to x value of relative distance. Similarly to axisY. -QVector3D MouseArea3D::getNewScale(const QVector3D &startScale, const QVector2D &relativeDistance, - const QVector3D &axisX, const QVector3D &axisY) -{ - // Distance factor was calculated based on scale rod size. - // For other use cases, relativeDistance needs to be adjusted to the same scale prior calling - // this method. - const float distanceFactor = 0.1f; - QVector3D scaleVec(1.f, 1.f, 1.f); - QVector3D xScaler(1.f, 1.f, 1.f); - QVector3D yScaler(1.f, 1.f, 1.f); - xScaler += axisX * relativeDistance.x() * distanceFactor; - yScaler += axisY * relativeDistance.y() * distanceFactor; - scaleVec *= xScaler; - scaleVec *= yScaler; - return startScale * scaleVec; -} - -qreal QmlDesigner::Internal::MouseArea3D::getNewRotationAngle( - QQuick3DNode *node, const QVector3D &pressPos, const QVector3D ¤tPos, - const QVector3D &nodePos, qreal prevAngle, bool trackBall) -{ - const QVector3D dragVector = currentPos - pressPos; - - if (dragVector.length() < 0.001f) - return prevAngle; - - // Get camera to node direction - QVector3D cameraToNodeDir = getCameraToNodeDir(node); - if (trackBall) { - // Only the distance in plane direction is relevant in trackball drag - QVector3D dragDir = QVector3D::crossProduct(getNormal(), cameraToNodeDir).normalized(); - QVector3D scenePos = pivotScenePosition(node); - QVector3D screenDragDir = m_view3D->mapFrom3DScene(scenePos + dragDir); - screenDragDir.setZ(0); - dragDir = (screenDragDir - nodePos).normalized(); - const QVector3D pressToCurrent = (currentPos - pressPos); - float magnitude = QVector3D::dotProduct(pressToCurrent, dragDir); - qreal angle = -mouseDragMultiplier() * qreal(magnitude); - return angle; - } else { - const QVector3D nodeToPress = (pressPos - nodePos).normalized(); - const QVector3D nodeToCurrent = (currentPos - nodePos).normalized(); - qreal angle = qAcos(qreal(QVector3D::dotProduct(nodeToPress, nodeToCurrent))); - - // Determine drag direction left/right - QVector3D dragNormal = QVector3D::crossProduct(nodeToPress, nodeToCurrent).normalized(); - angle *= QVector3D::dotProduct(QVector3D(0.f, 0.f, 1.f), dragNormal) < 0 ? -1.0 : 1.0; - - // Determine drag ring orientation relative to camera - angle *= QVector3D::dotProduct(getNormal(), cameraToNodeDir) < 0 ? -1.0 : 1.0; - - qreal adjustedPrevAngle = prevAngle; - const qreal PI_2 = M_PI * 2.0; - while (adjustedPrevAngle < -PI_2) - adjustedPrevAngle += PI_2; - while (adjustedPrevAngle > PI_2) - adjustedPrevAngle -= PI_2; - - // at M_PI rotation, the angle flips to negative - if (qAbs(angle - adjustedPrevAngle) > M_PI) { - if (angle > adjustedPrevAngle) - return prevAngle - (PI_2 - angle + adjustedPrevAngle); - else - return prevAngle + (PI_2 + angle - adjustedPrevAngle); - } else { - return prevAngle + angle - adjustedPrevAngle; - } - } - -} - -void QmlDesigner::Internal::MouseArea3D::applyRotationAngleToNode( - QQuick3DNode *node, const QVector3D &startRotation, qreal angle) -{ - if (!qFuzzyIsNull(angle)) { - node->setEulerRotation(startRotation); - QVector3D normal = getNormal(); - node->rotate(qRadiansToDegrees(angle), normal, QQuick3DNode::SceneSpace); - } -} - -void MouseArea3D::applyFreeRotation(QQuick3DNode *node, const QVector3D &startRotation, - const QVector3D &pressPos, const QVector3D ¤tPos) -{ - QVector3D dragVector = currentPos - pressPos; - - if (dragVector.length() < 0.001f) - return; - - const auto &transform = sceneTransform(); - const float *dataPtr(transform.data()); - QVector3D xAxis = QVector3D(dataPtr[0], dataPtr[1], dataPtr[2]).normalized(); - QVector3D yAxis = QVector3D(dataPtr[4], dataPtr[5], dataPtr[6]).normalized(); - QVector3D finalAxis = (dragVector.x() * yAxis + dragVector.y() * xAxis); - - qreal degrees = qRadiansToDegrees(qreal(finalAxis.length()) * mouseDragMultiplier()); - - finalAxis.normalize(); - - node->setEulerRotation(startRotation); - node->rotate(degrees, finalAxis, QQuick3DNode::SceneSpace); -} - -// Calculate scene position of the node's pivot point, which in practice is just the position -// of the node without applying the pivot offset. -QVector3D MouseArea3D::pivotScenePosition(QQuick3DNode *node) const -{ - if (!node) - return {}; - - QQuick3DNode *parent = node->parentNode(); - if (!parent) - return node->position(); - - QMatrix4x4 localTransform; - localTransform.translate(node->position()); - - const QMatrix4x4 sceneTransform = parent->sceneTransform() * localTransform; - - return mat44::getPosition(sceneTransform); -} - -double MouseArea3D::getRelativeScale(QQuick3DNode *node) const -{ - // Calculate the distance independent scale by first mapping the target's position to - // the view. We then measure up a distance on the view (100px) that we use as an - // "anchor" distance. Map the two positions back to the target node, and measure the - // distance between them now, in the 3D scene. The difference between the two distances, - // view and scene, will tell us what the distance independent scale should be. - - QVector3D nodePos(node->scenePosition()); - - DoubleVec3D posInView1(m_view3D->mapFrom3DScene(nodePos)); - - DoubleVec3D posInView2 = posInView1; - posInView2.x = posInView2.x + 100.; - - DoubleVec3D scenePos1(m_view3D->mapTo3DScene(posInView1.toVec3())); - DoubleVec3D scenePos2(m_view3D->mapTo3DScene(posInView2.toVec3())); - - return (scenePos1 - scenePos2).length() / 100.; -} - -void MouseArea3D::forcePressEvent(double x, double y) -{ - m_forceCaptureNextPress = true; - - Qt::MouseButtons buttons; - Qt::KeyboardModifiers mods; - QMouseEvent event(QEvent::MouseButtonPress, QPointF(x, y), Qt::LeftButton, buttons, mods); - eventFilter(m_view3D, &event); -} - -void QmlDesigner::Internal::MouseArea3D::forceMoveEvent(double x, double y) -{ - Qt::MouseButtons buttons; - Qt::KeyboardModifiers mods; - QMouseEvent event(QEvent::MouseMove, QPointF(x, y), Qt::LeftButton, buttons, mods); - eventFilter(m_view3D, &event); -} - -void QmlDesigner::Internal::MouseArea3D::forceReleaseEvent(double x, double y) -{ - Qt::MouseButtons buttons; - Qt::KeyboardModifiers mods; - QMouseEvent event(QEvent::MouseButtonRelease, QPointF(x, y), Qt::LeftButton, buttons, mods); - eventFilter(m_view3D, &event); -} - -QVector3D MouseArea3D::getMousePosInPlane(const MouseArea3D *helper, - const QPointF &mousePosInView) const -{ - if (!helper) - helper = this; - - const DoubleVec3D mousePos1(float(mousePosInView.x()), float(mousePosInView.y()), 0); - const DoubleVec3D rayPos0 = m_view3D->mapTo3DScene(mousePos1.toVec3()); - DoubleVec3D rayPos1; - if (qobject_cast<QQuick3DOrthographicCamera *>(m_view3D->camera())) { - if (auto cameraNode = static_cast<QSSGRenderCamera *>(QQuick3DObjectPrivate::get(m_view3D->camera())->spatialNode)) - rayPos1 = rayPos0 - rayPos0.length() * DoubleVec3D(cameraNode->getDirection()); - } else { - DoubleVec3D dir; - DoubleVec3D camPos = m_view3D->camera()->scenePosition(); - dir = (rayPos0 - camPos).normalized(); - rayPos1 = rayPos0 + rayPos0.length() * dir; - } - - const DoubleVec3D globalPlanePosition = helper->mapPositionToScene(QVector3D(0, 0, 0)); - DoubleMat44 sceneTrans = calcGlobalTransform(helper); - const DoubleVec3D intersectGlobalPos = rayIntersectsPlaneD(rayPos0, rayPos1, - globalPlanePosition, - -getNormalD(sceneTrans)); - - if (qFuzzyCompare(intersectGlobalPos.z, -1.)) - return intersectGlobalPos.toVec3(); - - return sceneTrans.inverted().transform(intersectGlobalPos).toVec3(); -} - -static QPoint getPosFromMoveEvent(QEvent *event) -{ - switch (event->type()) { - case QEvent::MouseMove: - return static_cast<QMouseEvent *>(event)->pos(); - case QEvent::HoverMove: - return static_cast<QHoverEvent *>(event)->pos(); - default: - break; - } - return {}; -} - -bool MouseArea3D::eventFilter(QObject *, QEvent *event) -{ - if (!m_active || (m_grabsMouse && s_mouseGrab && s_mouseGrab != this - && (m_priority <= s_mouseGrab->m_priority || s_mouseGrab->m_dragging - || s_mouseGrab->m_forceCaptureNextPress))) { - return false; - } - - qreal pickAngle = 0.; - - auto mouseOnTopOfMouseArea = [this, &pickAngle]( - const QVector3D &mousePosInPlane, const QPointF &mousePos) -> bool { - const bool onPlane = !qFuzzyCompare(mousePosInPlane.z(), -1) - && mousePosInPlane.x() >= float(m_x) - && mousePosInPlane.x() <= float(m_x + m_width) - && mousePosInPlane.y() >= float(m_y) - && mousePosInPlane.y() <= float(m_y + m_height); - - bool onCircle = true; - bool pickSuccess = false; - if (!qFuzzyIsNull(m_circlePickArea.y()) || !qFuzzyIsNull(m_minAngle)) { - - QVector3D cameraToMouseAreaDir = getCameraToNodeDir(this); - const QVector3D mouseAreaDir = getNormal(); - qreal angle = qreal(QVector3D::dotProduct(cameraToMouseAreaDir, mouseAreaDir)); - // Do not allow selecting ring that is nearly perpendicular to camera, as dragging along - // that plane would be difficult - pickAngle = qAcos(angle); - pickAngle = pickAngle > M_PI_2 ? pickAngle - M_PI_2 : M_PI_2 - pickAngle; - if (pickAngle > m_minAngle) { - if (!qFuzzyIsNull(m_circlePickArea.y())) { - qreal ringCenter = m_circlePickArea.x(); - // Thickness is increased according to the angle to camera to keep projected - // circle thickness constant at all angles. - qreal divisor = qSin(pickAngle) * 2.; // This is never zero - qreal thickness = ((m_circlePickArea.y() / divisor)); - qreal mousePosRadius = qSqrt(qreal(mousePosInPlane.x() * mousePosInPlane.x()) - + qreal(mousePosInPlane.y() * mousePosInPlane.y())); - onCircle = ringCenter - thickness <= mousePosRadius - && ringCenter + thickness >= mousePosRadius; - } - } else { - // Fall back to picking on the pickNode. At this angle, bounding box pick is not - // a problem - onCircle = false; - if (m_pickNode) { -#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1) - QQuick3DPickResult pr = m_view3D->pick(float(mousePos.x()), float(mousePos.y())); - pickSuccess = pr.objectHit() == m_pickNode; -#else - // With the introduction of global picking API, - // we need to pick all as various other geometries can often be the first - // pick result, such as camera frustum or light geometry - const QList<QQuick3DPickResult> results = m_view3D->pickAll(float(mousePos.x()), - float(mousePos.y())); - for (const auto &pr : results) { - if (pr.objectHit() == m_pickNode) { - pickSuccess = true; - break; - } - } -#endif - } - } - } - return (onCircle && onPlane) || pickSuccess; - }; - - switch (event->type()) { - case QEvent::MouseButtonPress: { - auto const mouseEvent = static_cast<QMouseEvent *>(event); - if (mouseEvent->button() == Qt::LeftButton) { - // Reset drag helper area to global transform of this area - if (m_dragHelper) { - m_dragHelper->setPosition(scenePosition()); - m_dragHelper->setRotation(sceneRotation()); - m_dragHelper->setScale(sceneScale()); - } - m_mousePosInPlane = getMousePosInPlane(m_dragHelper, mouseEvent->pos()); - if (m_forceCaptureNextPress || mouseOnTopOfMouseArea(m_mousePosInPlane, mouseEvent->pos())) { - m_forceCaptureNextPress = false; - setDragging(true); - emit pressed(m_mousePosInPlane.toVector2D(), mouseEvent->pos(), pickAngle); - if (m_grabsMouse) { - if (s_mouseGrab && s_mouseGrab != this) { - s_mouseGrab->setDragging(false); - s_mouseGrab->setHovering(false); - } - s_mouseGrab = this; - setHovering(true); - } - event->accept(); - return true; - } - } - break; - } - case QEvent::MouseButtonRelease: { - auto const mouseEvent = static_cast<QMouseEvent *>(event); - if (mouseEvent->button() == Qt::LeftButton) { - if (m_dragging) { - QVector3D mousePosInPlane = getMousePosInPlane(m_dragHelper, mouseEvent->pos()); - if (qFuzzyCompare(mousePosInPlane.z(), -1)) - mousePosInPlane = m_mousePosInPlane; - setDragging(false); - emit released(mousePosInPlane.toVector2D(), mouseEvent->pos()); - if (m_grabsMouse) { - if (s_mouseGrab && s_mouseGrab != this) { - s_mouseGrab->setDragging(false); - s_mouseGrab->setHovering(false); - } - if (mouseOnTopOfMouseArea(mousePosInPlane, mouseEvent->pos())) { - s_mouseGrab = this; - setHovering(true); - } else { - s_mouseGrab = nullptr; - setHovering(false); - } - } - event->accept(); - return true; - } - } - break; - } - case QEvent::MouseMove: - case QEvent::HoverMove: { - const QPoint pos = getPosFromMoveEvent(event); - const QVector3D mousePosInPlane = getMousePosInPlane(m_dragging ? m_dragHelper : this, pos); - const bool hasMouse = mouseOnTopOfMouseArea(mousePosInPlane, pos); - - setHovering(hasMouse); - - if (m_grabsMouse) { - if (m_hovering && s_mouseGrab && s_mouseGrab != this) - s_mouseGrab->setHovering(false); - - if (m_hovering || m_dragging) - s_mouseGrab = this; - else if (s_mouseGrab == this) - s_mouseGrab = nullptr; - } - - if (m_dragging && (m_circlePickArea.y() > 0. || !qFuzzyCompare(mousePosInPlane.z(), -1))) { - m_mousePosInPlane = mousePosInPlane; - emit dragged(mousePosInPlane.toVector2D(), pos); - } - - break; - } - default: - break; - } - - return false; -} - -void MouseArea3D::setDragging(bool enable) -{ - if (m_dragging == enable) - return; - - m_dragging = enable; - emit draggingChanged(); -} - -void MouseArea3D::setHovering(bool enable) -{ - if (m_hovering == enable) - return; - - m_hovering = enable; - emit hoveringChanged(); -} - -QVector3D MouseArea3D::getNormal() const -{ - const auto &transform = sceneTransform(); - const float *dataPtr(transform.data()); - return QVector3D(dataPtr[8], dataPtr[9], dataPtr[10]).normalized(); -} - -QVector3D MouseArea3D::getCameraToNodeDir(QQuick3DNode *node) const -{ - QVector3D dir; - if (m_view3D->camera()) { - // We need to do a cast here to be compatible with Qt 5.x. - // From Qt 6.2 the type can be read from the node directly. - if (qobject_cast<QQuick3DOrthographicCamera *>(m_view3D->camera())) { - if (auto renderCamera = QQuick3DObjectPrivate::get(m_view3D->camera())->spatialNode) - dir -= static_cast<QSSGRenderCamera *>(renderCamera)->getDirection(); - } else { - QVector3D camPos = m_view3D->camera()->scenePosition(); - QVector3D nodePos = pivotScenePosition(node); - dir = (nodePos - camPos).normalized(); - } - } - return dir; -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.h deleted file mode 100644 index a6bea46e59..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/mousearea3d.h +++ /dev/null @@ -1,165 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include <QtGui/qvector3d.h> -#include <QtCore/qpoint.h> -#include <QtCore/qpointer.h> - -#include <QtQml/qqmlparserstatus.h> - -#include <QtQuick3D/private/qquick3dnode_p.h> -#include <QtQuick3D/private/qquick3dmodel_p.h> -#include <QtQuick3D/private/qquick3dviewport_p.h> -#include <QtQuick3D/private/qtquick3dglobal_p.h> - -namespace QmlDesigner { -namespace Internal { - -class MouseArea3D : public QQuick3DNode -{ - Q_OBJECT - Q_PROPERTY(QQuick3DViewport *view3D READ view3D WRITE setView3D NOTIFY view3DChanged) - Q_PROPERTY(bool grabsMouse READ grabsMouse WRITE setGrabsMouse NOTIFY grabsMouseChanged) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) - Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged) - Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(bool hovering READ hovering NOTIFY hoveringChanged) - Q_PROPERTY(bool dragging READ dragging NOTIFY draggingChanged) - Q_PROPERTY(int priority READ priority WRITE setPriority NOTIFY priorityChanged) - Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged) - Q_PROPERTY(QPointF circlePickArea READ circlePickArea WRITE setCirclePickArea NOTIFY circlePickAreaChanged) - Q_PROPERTY(qreal minAngle READ minAngle WRITE setMinAngle NOTIFY minAngleChanged) - Q_PROPERTY(QQuick3DNode *pickNode READ pickNode WRITE setPickNode NOTIFY pickNodeChanged) - Q_PROPERTY(MouseArea3D *dragHelper READ dragHelper WRITE setDragHelper NOTIFY dragHelperChanged) - - Q_INTERFACES(QQmlParserStatus) - -public: - MouseArea3D(QQuick3DNode *parent = nullptr); - - QQuick3DViewport *view3D() const; - - qreal x() const; - qreal y() const; - qreal width() const; - qreal height() const; - int priority() const; - - bool hovering() const; - bool dragging() const; - bool grabsMouse() const; - bool active() const; - QPointF circlePickArea() const; - qreal minAngle() const; - QQuick3DNode *pickNode() const; - MouseArea3D *dragHelper() const; - - QVector3D getMousePosInPlane(const MouseArea3D *helper, const QPointF &mousePosInView) const; - - static qreal mouseDragMultiplier() { return .02; } - - Q_INVOKABLE QVector3D rayIntersectsPlane(const QVector3D &rayPos0, - const QVector3D &rayPos1, - const QVector3D &planePos, - const QVector3D &planeNormal) const; - - Q_INVOKABLE QVector3D getNewScale(const QVector3D &startScale, const QVector2D &relativeDistance, - const QVector3D &axisX, const QVector3D &axisY); - - Q_INVOKABLE qreal getNewRotationAngle(QQuick3DNode *node, const QVector3D &pressPos, - const QVector3D ¤tPos, const QVector3D &nodePos, - qreal prevAngle, bool trackBall); - Q_INVOKABLE void applyRotationAngleToNode(QQuick3DNode *node, const QVector3D &startRotation, - qreal angle); - Q_INVOKABLE void applyFreeRotation(QQuick3DNode *node, const QVector3D &startRotation, - const QVector3D &pressPos, const QVector3D ¤tPos); - Q_INVOKABLE QVector3D pivotScenePosition(QQuick3DNode *node) const; - Q_INVOKABLE double getRelativeScale(QQuick3DNode *node) const; - - Q_INVOKABLE void forcePressEvent(double x, double y); - Q_INVOKABLE void forceMoveEvent(double x, double y); - Q_INVOKABLE void forceReleaseEvent(double x, double y); - -public slots: - void setView3D(QQuick3DViewport *view3D); - void setGrabsMouse(bool grabsMouse); - void setActive(bool active); - void setCirclePickArea(const QPointF &pickArea); - void setMinAngle(qreal angle); - void setPickNode(QQuick3DNode *node); - void setDragHelper(MouseArea3D *dragHelper); - - void setX(qreal x); - void setY(qreal y); - void setWidth(qreal width); - void setHeight(qreal height); - void setPriority(int level); - -signals: - void view3DChanged(); - - void xChanged(); - void yChanged(); - void widthChanged(); - void heightChanged(); - void priorityChanged(); - - void hoveringChanged(); - void draggingChanged(); - void activeChanged(); - void grabsMouseChanged(); - void circlePickAreaChanged(); - void minAngleChanged(); - void pickNodeChanged(); - void dragHelperChanged(); - - // angle parameter is only set if circlePickArea is specified - void pressed(const QVector2D &planePos, const QPoint &screenPos, qreal angle); - void released(const QVector2D &planePos, const QPoint &screenPos); - void dragged(const QVector2D &planePos, const QPoint &screenPos); - -protected: - void classBegin() override {} - void componentComplete() override; - bool eventFilter(QObject *obj, QEvent *event) override; - -private: - void setDragging(bool enable); - void setHovering(bool enable); - QVector3D getNormal() const; - QVector3D getCameraToNodeDir(QQuick3DNode *node) const; - - Q_DISABLE_COPY(MouseArea3D) - QQuick3DViewport *m_view3D = nullptr; - - qreal m_x; - qreal m_y; - qreal m_width; - qreal m_height; - int m_priority = 0; - - bool m_hovering = false; - bool m_dragging = false; - bool m_active = false; - - static MouseArea3D *s_mouseGrab; - bool m_grabsMouse = false; - QVector3D m_mousePosInPlane; - QPointF m_circlePickArea; - qreal m_minAngle = 0.; - QQuick3DNode *m_pickNode = nullptr; - MouseArea3D *m_dragHelper = nullptr; - bool m_forceCaptureNextPress = false; -}; - -} -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::MouseArea3D) - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp deleted file mode 100644 index dd43ba8221..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "qquick3darealight_p.h" -#include <QtQuick3D/private/qquick3dobject_p.h> - -#include <QtQuick3DRuntimeRender/private/qssgrenderlight_p.h> - -namespace QmlDesigner::Internal { - -float QQuick3DAreaLight::width() const -{ - return m_width; -} - -float QQuick3DAreaLight::height() const -{ - return m_height; -} - -void QQuick3DAreaLight::setWidth(float width) -{ - m_width = width; - emit widthChanged(); -} - -void QQuick3DAreaLight::setHeight(float height) -{ - m_height = height; - emit heightChanged(); -} - -} - -#endif diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h deleted file mode 100644 index b1bda055b2..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/qt5compat/qquick3darealight_p.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -// This is a dummy class for Qt 5 compatibility purposes only - -#include <QtQuick3D/private/qquick3dabstractlight_p.h> - -namespace QmlDesigner::Internal { - -class QQuick3DAreaLight : public QQuick3DAbstractLight -{ - Q_OBJECT - Q_PROPERTY(float width READ width WRITE setWidth NOTIFY widthChanged) - Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged) - -public: - ~QQuick3DAreaLight() override {} - - float width() const; - float height() const; - -public slots: - void setWidth(float width); - void setHeight(float height); - -signals: - void widthChanged(); - void heightChanged(); - -private: - float m_width = 100.0f; - float m_height = 100.0f; -}; - -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::QQuick3DAreaLight) - -#endif diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp deleted file mode 100644 index 1198047848..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.cpp +++ /dev/null @@ -1,427 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#ifdef QUICK3D_MODULE - -#include "selectionboxgeometry.h" - -#include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h> -#include <QtQuick3DRuntimeRender/private/qssgrendercontextcore_p.h> -#include <QtQuick3DRuntimeRender/private/qssgrenderbuffermanager_p.h> -#include <QtQuick3D/private/qquick3dmodel_p.h> -#include <QtQuick3D/private/qquick3dscenemanager_p.h> -#include <QtQuick3D/qquick3dobject.h> -#include <QtQuick/qquickwindow.h> -#include <QtCore/qvector.h> - -#include <limits> - -namespace QmlDesigner { -namespace Internal { - -static const float floatMin = std::numeric_limits<float>::lowest(); -static const float floatMax = std::numeric_limits<float>::max(); -static const QVector3D maxVec = QVector3D(floatMax, floatMax, floatMax); -static const QVector3D minVec = QVector3D(floatMin, floatMin, floatMin); - -SelectionBoxGeometry::SelectionBoxGeometry() - : GeometryBase() -{ -} - -SelectionBoxGeometry::~SelectionBoxGeometry() -{ - for (auto &connection : std::as_const(m_connections)) - QObject::disconnect(connection); - m_connections.clear(); -} - -QQuick3DNode *SelectionBoxGeometry::targetNode() const -{ - return m_targetNode; -} - -QQuick3DNode *SelectionBoxGeometry::rootNode() const -{ - return m_rootNode; -} - -QQuick3DViewport *SelectionBoxGeometry::view3D() const -{ - return m_view3D; -} - -bool QmlDesigner::Internal::SelectionBoxGeometry::isEmpty() const -{ - return m_isEmpty; -} - -void SelectionBoxGeometry::setEmpty(bool isEmpty) -{ - if (m_isEmpty != isEmpty) { - m_isEmpty = isEmpty; - emit isEmptyChanged(); - } -} - -QSSGBounds3 SelectionBoxGeometry::bounds() const -{ - return m_bounds; -} - -void SelectionBoxGeometry::clearGeometry() -{ - clear(); - setStride(12); // To avoid div by zero inside QtQuick3D - setEmpty(true); -} - -void SelectionBoxGeometry::setTargetNode(QQuick3DNode *targetNode) -{ - if (m_targetNode == targetNode) - return; - - if (m_targetNode) - m_targetNode->disconnect(this); - m_targetNode = targetNode; - - if (auto model = qobject_cast<QQuick3DModel *>(m_targetNode)) { - QObject::connect(model, &QQuick3DModel::sourceChanged, - this, &SelectionBoxGeometry::spatialNodeUpdateNeeded, Qt::QueuedConnection); - QObject::connect(model, &QQuick3DModel::geometryChanged, - this, &SelectionBoxGeometry::spatialNodeUpdateNeeded, Qt::QueuedConnection); - } - if (m_targetNode) { - QObject::connect(m_targetNode, &QQuick3DNode::parentChanged, - this, &SelectionBoxGeometry::spatialNodeUpdateNeeded, Qt::QueuedConnection); - } - - clearGeometry(); - emit targetNodeChanged(); - spatialNodeUpdateNeeded(); -} - -void SelectionBoxGeometry::setRootNode(QQuick3DNode *rootNode) -{ - if (m_rootNode == rootNode) - return; - - m_rootNode = rootNode; - - emit rootNodeChanged(); - spatialNodeUpdateNeeded(); -} - -void SelectionBoxGeometry::setView3D(QQuick3DViewport *view) -{ - if (m_view3D == view) - return; - - m_view3D = view; - - emit view3DChanged(); - spatialNodeUpdateNeeded(); -} - -QSSGRenderGraphObject *SelectionBoxGeometry::updateSpatialNode(QSSGRenderGraphObject *node) -{ - - if (m_spatialNodeUpdatePending) { - m_spatialNodeUpdatePending = false; - updateGeometry(); - } - - return QQuick3DGeometry::updateSpatialNode(node); -} - -void SelectionBoxGeometry::doUpdateGeometry() -{ - // Some changes require a frame to be rendered for us to be able to calculate geometry, - // so defer calculations until after next frame. - if (m_spatialNodeUpdatePending) { - update(); - return; - } - - GeometryBase::doUpdateGeometry(); - - for (auto &connection : std::as_const(m_connections)) - QObject::disconnect(connection); - m_connections.clear(); - - QByteArray vertexData; - QByteArray indexData; - - QVector3D minBounds = maxVec; - QVector3D maxBounds = minVec; - - if (m_targetNode) { - auto rootPriv = QQuick3DObjectPrivate::get(m_rootNode); - auto targetPriv = QQuick3DObjectPrivate::get(m_targetNode); - auto rootRN = static_cast<QSSGRenderNode *>(rootPriv->spatialNode); - auto targetRN = static_cast<QSSGRenderNode *>(targetPriv->spatialNode); - if (rootRN && targetRN) { - // Explicitly set local transform of root node to target node parent's global transform - // to avoid having to reparent the selection box. This has to be done directly on render - // nodes. - QMatrix4x4 m; - if (targetRN->parent) { - targetRN->parent->calculateGlobalVariables(); - m = targetRN->parent->globalTransform; - } - rootRN->localTransform = m; -#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) - rootRN->markDirty(QSSGRenderNode::TransformDirtyFlag::TransformNotDirty); -#else - rootRN->markDirty(QSSGRenderNode::DirtyFlag::TransformDirty); -#endif - rootRN->calculateGlobalVariables(); - } else if (!m_spatialNodeUpdatePending) { - // Necessary spatial nodes do not yet exist. Defer selection box creation one frame. - m_spatialNodeUpdatePending = true; - update(); - } - getBounds(m_targetNode, vertexData, indexData, minBounds, maxBounds); - generateVertexData(vertexData, indexData, minBounds, maxBounds); - - // Track changes in ancestors, as they can move node without affecting node properties - auto parentNode = m_targetNode->parentNode(); - while (parentNode) { - trackNodeChanges(parentNode); - parentNode = parentNode->parentNode(); - } - } else { - // Fill some dummy data so geometry won't get rejected - minBounds = {}; - maxBounds = {}; - generateVertexData(vertexData, indexData, minBounds, maxBounds); - } - - addAttribute(QQuick3DGeometry::Attribute::IndexSemantic, 0, - QQuick3DGeometry::Attribute::U16Type); - setVertexData(vertexData); - setIndexData(indexData); - setBounds(minBounds, maxBounds); - - m_bounds = QSSGBounds3(minBounds, maxBounds); - - setEmpty(minBounds.isNull() && maxBounds.isNull()); -} - -void SelectionBoxGeometry::getBounds( - QQuick3DNode *node, QByteArray &vertexData, QByteArray &indexData, - QVector3D &minBounds, QVector3D &maxBounds) -{ - QMatrix4x4 localTransform; - auto nodePriv = QQuick3DObjectPrivate::get(node); - auto renderNode = static_cast<QSSGRenderNode *>(nodePriv->spatialNode); - - if (node != m_targetNode) { - if (renderNode) { -#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) - if (renderNode->flags.testFlag(QSSGRenderNode::Flag::TransformDirty)) - renderNode->calculateLocalTransform(); -#else - if (renderNode->isDirty(QSSGRenderNode::DirtyFlag::TransformDirty)) { - renderNode->localTransform = QSSGRenderNode::calculateTransformMatrix( - node->position(), node->scale(), node->pivot(), node->rotation()); - } -#endif - localTransform = renderNode->localTransform; - } - trackNodeChanges(node); - } - - QVector3D localMinBounds = maxVec; - QVector3D localMaxBounds = minVec; - - // Find bounds for children - QVector<QVector3D> minBoundsVec; - QVector<QVector3D> maxBoundsVec; - const auto children = node->childItems(); - for (const auto child : children) { - if (auto childNode = qobject_cast<QQuick3DNode *>(child)) { - QVector3D newMinBounds = minBounds; - QVector3D newMaxBounds = maxBounds; - getBounds(childNode, vertexData, indexData, newMinBounds, newMaxBounds); - minBoundsVec << newMinBounds; - maxBoundsVec << newMaxBounds; - } - } - - auto combineMinBounds = [](QVector3D &target, const QVector3D &source) { - target.setX(qMin(source.x(), target.x())); - target.setY(qMin(source.y(), target.y())); - target.setZ(qMin(source.z(), target.z())); - }; - auto combineMaxBounds = [](QVector3D &target, const QVector3D &source) { - target.setX(qMax(source.x(), target.x())); - target.setY(qMax(source.y(), target.y())); - target.setZ(qMax(source.z(), target.z())); - }; - auto transformCorner = [&](const QMatrix4x4 &m, QVector3D &minTarget, QVector3D &maxTarget, - const QVector3D &corner) { - QVector3D mappedCorner = m.map(corner); - combineMinBounds(minTarget, mappedCorner); - combineMaxBounds(maxTarget, mappedCorner); - }; - auto transformCorners = [&](const QMatrix4x4 &m, QVector3D &minTarget, QVector3D &maxTarget, - const QVector3D &minCorner, const QVector3D &maxCorner) { - transformCorner(m, minTarget, maxTarget, minCorner); - transformCorner(m, minTarget, maxTarget, maxCorner); - transformCorner(m, minTarget, maxTarget, QVector3D(minCorner.x(), minCorner.y(), maxCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(minCorner.x(), maxCorner.y(), minCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(maxCorner.x(), minCorner.y(), minCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(minCorner.x(), maxCorner.y(), maxCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(maxCorner.x(), maxCorner.y(), minCorner.z())); - transformCorner(m, minTarget, maxTarget, QVector3D(maxCorner.x(), minCorner.y(), maxCorner.z())); - }; - - // Combine all child bounds - for (const auto &newBounds : std::as_const(minBoundsVec)) - combineMinBounds(localMinBounds, newBounds); - for (const auto &newBounds : std::as_const(maxBoundsVec)) - combineMaxBounds(localMaxBounds, newBounds); - - if (qobject_cast<QQuick3DModel *>(node)) { - if (auto renderModel = static_cast<QSSGRenderModel *>(renderNode)) { - QWindow *window = static_cast<QWindow *>(m_view3D->window()); - if (window) { - QSSGRef<QSSGRenderContextInterface> context; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - context = QSSGRenderContextInterface::getRenderContextInterface(quintptr(window)); -#else - context = QQuick3DObjectPrivate::get(this)->sceneManager->rci; -#endif - if (!context.isNull()) { - auto bufferManager = context->bufferManager(); -#if QT_VERSION < QT_VERSION_CHECK(6, 3, 0) - QSSGBounds3 bounds = renderModel->getModelBounds(bufferManager); -#else - QSSGBounds3 bounds = bufferManager->getModelBounds(renderModel); -#endif - QVector3D center = bounds.center(); - QVector3D extents = bounds.extents(); - QVector3D localMin = center - extents; - QVector3D localMax = center + extents; - - combineMinBounds(localMinBounds, localMin); - combineMaxBounds(localMaxBounds, localMax); - } - } - } - } else { - combineMinBounds(localMinBounds, {}); - combineMaxBounds(localMaxBounds, {}); - } - - if (localMaxBounds == minVec) { - localMinBounds = {}; - localMaxBounds = {}; - } - - // Transform local space bounding box to parent space - transformCorners(localTransform, minBounds, maxBounds, localMinBounds, localMaxBounds); -} - -void SelectionBoxGeometry::generateVertexData(QByteArray &vertexData, QByteArray &indexData, - const QVector3D &minBounds, const QVector3D &maxBounds) -{ - // Adjust bounds to reduce targetNode pixels obscuring the selection box - QVector3D extents = (maxBounds - minBounds) / 1000.f; - QVector3D minAdjBounds = minBounds - extents; - QVector3D maxAdjBounds = maxBounds + extents; - - // Selection box has 8 corners with three short lines towards other corners on each corner - const int vertexSize = int(sizeof(float)) * 8 * 4 * 3; // 8 corners, 4 verts/corner, 3 floats/vert - vertexData.resize(vertexSize); - const int indexSize = int(sizeof(quint16)) * 8 * 3 * 2; // 8 * 3 lines, 2 vert/line - indexData.resize(indexSize); - - auto dataPtr = reinterpret_cast<float *>(vertexData.data()); - auto indexPtr = reinterpret_cast<quint16 *>(indexData.data()); - - QVector3D corners[8]; - corners[0] = QVector3D(maxAdjBounds.x(), maxAdjBounds.y(), maxAdjBounds.z()); - corners[1] = QVector3D(minAdjBounds.x(), maxAdjBounds.y(), maxAdjBounds.z()); - corners[2] = QVector3D(minAdjBounds.x(), minAdjBounds.y(), maxAdjBounds.z()); - corners[3] = QVector3D(maxAdjBounds.x(), minAdjBounds.y(), maxAdjBounds.z()); - corners[4] = QVector3D(maxAdjBounds.x(), maxAdjBounds.y(), minAdjBounds.z()); - corners[5] = QVector3D(minAdjBounds.x(), maxAdjBounds.y(), minAdjBounds.z()); - corners[6] = QVector3D(minAdjBounds.x(), minAdjBounds.y(), minAdjBounds.z()); - corners[7] = QVector3D(maxAdjBounds.x(), minAdjBounds.y(), minAdjBounds.z()); - - for (int i = 0; i < 8; ++i) { - *dataPtr++ = corners[i].x(); - *dataPtr++ = corners[i].y(); - *dataPtr++ = corners[i].z(); - } - - // Percentage of full box lines to show at each corner. Set to .5 for full box - static const float lineLen = .15f; - - int nextVertIdx = 8; - - // Add line from corner 'start', towards corner 'end' - auto addCornerLine = [&](int start, int end) { - QVector3D vert = corners[start] + lineLen * (corners[end] - corners[start]); - *dataPtr++ = vert.x(); *dataPtr++ = vert.y(); *dataPtr++ = vert.z(); - *indexPtr++ = start; *indexPtr++ = nextVertIdx++; - }; - - addCornerLine(0, 1); - addCornerLine(0, 3); - addCornerLine(0, 4); - - addCornerLine(1, 0); - addCornerLine(1, 2); - addCornerLine(1, 5); - - addCornerLine(2, 1); - addCornerLine(2, 3); - addCornerLine(2, 6); - - addCornerLine(3, 0); - addCornerLine(3, 2); - addCornerLine(3, 7); - - addCornerLine(4, 0); - addCornerLine(4, 5); - addCornerLine(4, 7); - - addCornerLine(5, 1); - addCornerLine(5, 4); - addCornerLine(5, 6); - - addCornerLine(6, 2); - addCornerLine(6, 5); - addCornerLine(6, 7); - - addCornerLine(7, 3); - addCornerLine(7, 4); - addCornerLine(7, 6); -} - -void SelectionBoxGeometry::trackNodeChanges(QQuick3DNode *node) -{ - m_connections << QObject::connect(node, &QQuick3DNode::sceneScaleChanged, - this, &SelectionBoxGeometry::updateGeometry, Qt::QueuedConnection); - m_connections << QObject::connect(node, &QQuick3DNode::sceneRotationChanged, - this, &SelectionBoxGeometry::updateGeometry, Qt::QueuedConnection); - m_connections << QObject::connect(node, &QQuick3DNode::scenePositionChanged, - this, &SelectionBoxGeometry::updateGeometry, Qt::QueuedConnection); - m_connections << QObject::connect(node, &QQuick3DNode::pivotChanged, - this, &SelectionBoxGeometry::updateGeometry, Qt::QueuedConnection); -} - -void SelectionBoxGeometry::spatialNodeUpdateNeeded() -{ - m_spatialNodeUpdatePending = true; - clearGeometry(); - update(); -} - -} -} - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h deleted file mode 100644 index 46a9d25159..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/editor3d/selectionboxgeometry.h +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#ifdef QUICK3D_MODULE - -#include "geometrybase.h" - -#include <QtQuick3D/private/qquick3dnode_p.h> -#include <QtQuick3D/private/qquick3dviewport_p.h> -#include <QtQuick3DUtils/private/qssgbounds3_p.h> - -namespace QmlDesigner { -namespace Internal { - -class SelectionBoxGeometry : public GeometryBase -{ - Q_OBJECT - Q_PROPERTY(QQuick3DNode *targetNode READ targetNode WRITE setTargetNode NOTIFY targetNodeChanged) - Q_PROPERTY(QQuick3DNode *rootNode READ rootNode WRITE setRootNode NOTIFY rootNodeChanged) - Q_PROPERTY(QQuick3DViewport *view3D READ view3D WRITE setView3D NOTIFY view3DChanged) - Q_PROPERTY(bool isEmpty READ isEmpty NOTIFY isEmptyChanged) - -public: - SelectionBoxGeometry(); - ~SelectionBoxGeometry() override; - - QQuick3DNode *targetNode() const; - QQuick3DNode *rootNode() const; - QQuick3DViewport *view3D() const; - bool isEmpty() const; - void setEmpty(bool isEmpty); - - QSSGBounds3 bounds() const; - -public slots: - void setTargetNode(QQuick3DNode *targetNode); - void setRootNode(QQuick3DNode *rootNode); - void setView3D(QQuick3DViewport *view); - -signals: - void targetNodeChanged(); - void rootNodeChanged(); - void view3DChanged(); - void isEmptyChanged(); - -protected: - QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override; - void doUpdateGeometry() override; - -private: - void getBounds(QQuick3DNode *node, QByteArray &vertexData, - QByteArray &indexData, QVector3D &minBounds, QVector3D &maxBounds); - void generateVertexData(QByteArray &vertexData, QByteArray &indexData, - const QVector3D &minBounds, const QVector3D &maxBounds); - void trackNodeChanges(QQuick3DNode *node); - void spatialNodeUpdateNeeded(); - void clearGeometry(); - - QQuick3DNode *m_targetNode = nullptr; - QQuick3DViewport *m_view3D = nullptr; - QQuick3DNode *m_rootNode = nullptr; - bool m_isEmpty = true; - QVector<QMetaObject::Connection> m_connections; - QSSGBounds3 m_bounds; - bool m_spatialNodeUpdatePending = false; -}; - -} -} - -QML_DECLARE_TYPE(QmlDesigner::Internal::SelectionBoxGeometry) - -#endif // QUICK3D_MODULE diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp deleted file mode 100644 index 453fa24473..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.cpp +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "iconrenderer.h" - -#include "../editor3d/selectionboxgeometry.h" -#include "../editor3d/generalhelper.h" - -#include <private/qquickdesignersupport_p.h> -#include <QtQml/qqmlcomponent.h> -#include <QtQml/qqmlengine.h> -#include <QtQml/qqmlproperty.h> -#include <QtQml/qqmlcontext.h> -#include <QtQuick/qquickview.h> -#include <QtQuick/qquickitem.h> -#include <QtGui/qsurfaceformat.h> -#include <QtGui/qimage.h> -#include <QtGui/qguiapplication.h> -#include <QtCore/qtimer.h> -#include <QtCore/qfileinfo.h> -#include <QtCore/qdir.h> - -#ifdef QUICK3D_MODULE -#include <QtQuick3D/private/qquick3dnode_p.h> -#include <QtQuick3D/private/qquick3dviewport_p.h> -#endif - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include <QtGui/private/qrhi_p.h> -#include <QtQuick/private/qquickrendercontrol_p.h> -#include <QtQuick/private/qquickrendertarget_p.h> -#endif - -#include <private/qquickdesignersupportitems_p.h> - -IconRenderer::IconRenderer(int size, const QString &filePath, const QString &source) - : QObject(nullptr) - , m_size(size) - , m_filePath(filePath) - , m_source(source) -{ -} - -IconRenderer::~IconRenderer() = default; - -void IconRenderer::setupRender() -{ - QQuickDesignerSupport::activateDesignerMode(); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - DesignerSupport::activateDesignerWindowManager(); -#endif - - QQmlEngine *engine = nullptr; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - auto view = new QQuickView; - engine = view->engine(); - m_window = view; - QSurfaceFormat surfaceFormat = view->requestedFormat(); - surfaceFormat.setVersion(4, 1); - surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); - view->setFormat(surfaceFormat); - DesignerSupport::createOpenGLContext(view); -#else - engine = new QQmlEngine; - m_renderControl = new QQuickRenderControl; - m_window = new QQuickWindow(m_renderControl); - m_window->setDefaultAlphaBuffer(true); - m_window->setColor(Qt::transparent); - m_renderControl->initialize(); -#endif - - QQmlComponent component(engine); - component.loadUrl(QUrl::fromLocalFile(m_source)); - QObject *iconItem = component.create(); - - if (iconItem) { -#ifdef QUICK3D_MODULE - if (auto scene = qobject_cast<QQuick3DNode *>(iconItem)) { - qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry"); - QQmlComponent component(engine); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/qt5/IconRenderer3D.qml")); - m_containerItem = qobject_cast<QQuickItem *>(component.create()); - DesignerSupport::setRootItem(view, m_containerItem); -#else - component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/qt6/IconRenderer3D.qml")); - m_containerItem = qobject_cast<QQuickItem *>(component.create()); - m_window->contentItem()->setSize(m_containerItem->size()); - m_window->setGeometry(0, 0, m_containerItem->width(), m_containerItem->height()); - m_containerItem->setParentItem(m_window->contentItem()); -#endif - - auto helper = new QmlDesigner::Internal::GeneralHelper(); - engine->rootContext()->setContextProperty("_generalHelper", helper); - - m_contentItem = QQmlProperty::read(m_containerItem, "view3D").value<QQuickItem *>(); - auto view3D = qobject_cast<QQuick3DViewport *>(m_contentItem); - view3D->setImportScene(scene); - m_is3D = true; - } else -#endif - if (auto scene = qobject_cast<QQuickItem *>(iconItem)) { - m_contentItem = scene; - m_containerItem = new QQuickItem(); - m_containerItem->setSize(QSizeF(1024, 1024)); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - DesignerSupport::setRootItem(view, m_containerItem); -#else - m_window->contentItem()->setSize(m_containerItem->size()); - m_window->setGeometry(0, 0, m_containerItem->width(), m_containerItem->height()); - m_containerItem->setParentItem(m_window->contentItem()); -#endif - m_contentItem->setParentItem(m_containerItem); - } - - if (m_containerItem && m_contentItem) { - resizeContent(m_size); - if (!initRhi()) - QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit); - QTimer::singleShot(0, this, &IconRenderer::startCreateIcon); - } else { - QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit); - } - } else { - QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit); - } -} - -void IconRenderer::startCreateIcon() -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - m_designerSupport.refFromEffectItem(m_containerItem, false); -#endif - QQuickDesignerSupportItems::disableNativeTextRendering(m_containerItem); - - if (m_is3D) - QTimer::singleShot(0, this, &IconRenderer::focusCamera); - else - QTimer::singleShot(0, this, &IconRenderer::finishCreateIcon); -} - -void IconRenderer::focusCamera() -{ -#ifdef QUICK3D_MODULE - if (m_focusStep >= 10) { - QTimer::singleShot(0, this, &IconRenderer::finishCreateIcon); - return; - } - - render({}); - - if (m_focusStep == 0) { - QMetaObject::invokeMethod(m_containerItem, "setSceneToBox"); - } else if (m_focusStep > 1 && m_focusStep < 10) { - QMetaObject::invokeMethod(m_containerItem, "fitAndHideBox"); - } - ++m_focusStep; - QTimer::singleShot(0, this, &IconRenderer::focusCamera); -#endif -} - -void IconRenderer::finishCreateIcon() -{ - QFileInfo fi(m_filePath); - - // Render regular size image - render(fi.absoluteFilePath()); - - // Render @2x image - resizeContent(m_size * 2); - if (!initRhi()) - QTimer::singleShot(1000, qGuiApp, &QGuiApplication::quit); - - QString saveFile; - saveFile = fi.absolutePath() + '/' + fi.completeBaseName() + "@2x"; - if (!fi.suffix().isEmpty()) - saveFile += '.' + fi.suffix(); - - fi.absoluteDir().mkpath("."); - - render(saveFile); - - QTimer::singleShot(0, qGuiApp, &QGuiApplication::quit); -} - -void IconRenderer::render(const QString &fileName) -{ - std::function<void (QQuickItem *)> updateNodesRecursive; - updateNodesRecursive = [&updateNodesRecursive](QQuickItem *item) { - const auto childItems = item->childItems(); - for (QQuickItem *childItem : childItems) - updateNodesRecursive(childItem); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - DesignerSupport::updateDirtyNode(item); -#else - if (item->flags() & QQuickItem::ItemHasContents) - item->update(); -#endif - }; - updateNodesRecursive(m_containerItem); - - QRect rect(QPoint(), m_contentItem->size().toSize()); - QImage renderImage; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - renderImage = m_designerSupport.renderImageForItem(m_containerItem, rect, rect.size()); -#else - m_renderControl->polishItems(); - m_renderControl->beginFrame(); - m_renderControl->sync(); - m_renderControl->render(); - - bool readCompleted = false; - QRhiReadbackResult readResult; - readResult.completed = [&] { - readCompleted = true; - QImage wrapperImage(reinterpret_cast<const uchar *>(readResult.data.constData()), - readResult.pixelSize.width(), readResult.pixelSize.height(), - QImage::Format_RGBA8888_Premultiplied); - if (m_rhi->isYUpInFramebuffer()) - renderImage = wrapperImage.mirrored().copy(0, 0, rect.width(), rect.height()); - else - renderImage = wrapperImage.copy(0, 0, rect.width(), rect.height()); - }; - QRhiResourceUpdateBatch *readbackBatch = m_rhi->nextResourceUpdateBatch(); - readbackBatch->readBackTexture(m_texture, &readResult); - - QQuickRenderControlPrivate *rd = QQuickRenderControlPrivate::get(m_renderControl); - rd->cb->resourceUpdate(readbackBatch); - - m_renderControl->endFrame(); -#endif - if (!fileName.isEmpty()) { - QFileInfo fi(fileName); - if (fi.suffix().isEmpty()) - renderImage.save(fileName, "PNG"); - else - renderImage.save(fileName); - } -} - -void IconRenderer::resizeContent(int dimensions) -{ - QSizeF size(dimensions, dimensions); - m_contentItem->setSize(size); - if (m_contentItem->width() > m_containerItem->width()) - m_containerItem->setWidth(m_contentItem->width()); - if (m_contentItem->height() > m_containerItem->height()) - m_containerItem->setHeight(m_contentItem->height()); -} - -bool IconRenderer::initRhi() -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!m_rhi) { - QQuickRenderControlPrivate *rd = QQuickRenderControlPrivate::get(m_renderControl); - m_rhi = rd->rhi; - if (!m_rhi) { - qWarning() << __FUNCTION__ << "Rhi is null"; - return false; - } - } - - // Don't bother deleting old ones as iconrender is a single shot executable - m_texTarget = nullptr; - m_rpDesc = nullptr; - m_buffer = nullptr; - m_texture = nullptr; - - const QSize size = m_containerItem->size().toSize(); - m_texture = m_rhi->newTexture(QRhiTexture::RGBA8, size, 1, - QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource); - if (!m_texture->create()) { - qWarning() << __FUNCTION__ << "QRhiTexture creation failed"; - return false; - } - - m_buffer = m_rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, size, 1); - if (!m_buffer->create()) { - qWarning() << __FUNCTION__ << "Depth/stencil buffer creation failed"; - return false; - } - - QRhiTextureRenderTargetDescription rtDesc {QRhiColorAttachment(m_texture)}; - rtDesc.setDepthStencilBuffer(m_buffer); - m_texTarget = m_rhi->newTextureRenderTarget(rtDesc); - m_rpDesc = m_texTarget->newCompatibleRenderPassDescriptor(); - m_texTarget->setRenderPassDescriptor(m_rpDesc); - if (!m_texTarget->create()) { - qWarning() << __FUNCTION__ << "Texture render target creation failed"; - return false; - } - - // redirect Qt Quick rendering into our texture - m_window->setRenderTarget(QQuickRenderTarget::fromRhiRenderTarget(m_texTarget)); -#endif - return true; -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h deleted file mode 100644 index 856811b767..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.h +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtCore/qobject.h> -#include <QtCore/qstring.h> - -QT_BEGIN_NAMESPACE -class QQuickWindow; -class QQuickItem; -class QQuickDesignerSupport; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -class QQuickRenderControl; -class QRhi; -class QRhiTexture; -class QRhiRenderBuffer; -class QRhiTextureRenderTarget; -class QRhiRenderPassDescriptor; -#endif -QT_END_NAMESPACE - -class IconRenderer : public QObject -{ - Q_OBJECT - -public: - explicit IconRenderer(int size, const QString &filePath, const QString &source); - ~IconRenderer(); - - void setupRender(); - -private: - void startCreateIcon(); - void focusCamera(); - void finishCreateIcon(); - void render(const QString &fileName); - void resizeContent(int dimensions); - bool initRhi(); - - int m_size = 16; - QString m_filePath; - QString m_source; - QQuickWindow *m_window = nullptr; - QQuickItem *m_contentItem = nullptr; - QQuickItem *m_containerItem = nullptr; - std::unique_ptr<QQuickDesignerSupport> m_designerSupport; - bool m_is3D = false; - int m_focusStep = 0; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - QQuickRenderControl *m_renderControl = nullptr; - QRhi *m_rhi = nullptr; - QRhiTexture *m_texture = nullptr; - QRhiRenderBuffer *m_buffer = nullptr; - QRhiTextureRenderTarget *m_texTarget = nullptr; - QRhiRenderPassDescriptor *m_rpDesc = nullptr; -#endif -}; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.pri deleted file mode 100644 index 59d5b12cee..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/iconrenderer/iconrenderer.pri +++ /dev/null @@ -1,3 +0,0 @@ -HEADERS += $$PWD/iconrenderer.h - -SOURCES += $$PWD/iconrenderer.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.cpp deleted file mode 100644 index 70857065ee..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.cpp +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "import3d.h" - -#ifdef IMPORT_QUICK3D_ASSETS -#include <QtQuick3DAssetImport/private/qssgassetimportmanager_p.h> -#endif - -#include <QCoreApplication> -#include <QDebug> -#include <QFile> -#include <QJsonDocument> -#include <QJsonObject> -#include <QScopedPointer> -#include <QTextStream> -#include <QTimer> - -namespace Import3D -{ - -void import3D([[maybe_unused]] const QString &sourceAsset, - [[maybe_unused]] const QString &outDir, - [[maybe_unused]] const QString &options) -{ - QString errorStr; -#ifdef IMPORT_QUICK3D_ASSETS - QScopedPointer importer {new QSSGAssetImportManager}; - - QJsonParseError error; - QJsonDocument optDoc = QJsonDocument::fromJson(options.toUtf8(), &error); - - if (!optDoc.isNull() && optDoc.isObject()) { - QJsonObject optObj = optDoc.object(); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) - const auto &optionsMap = optObj; -#else - const auto optionsMap = optObj.toVariantMap(); -#endif // QT_VERSION >= 6.4.0 - if (importer->importFile(sourceAsset, outDir, optionsMap, &errorStr) - != QSSGAssetImportManager::ImportState::Success) { - } - } else { - errorStr = QObject::tr("Failed to parse import options: %1").arg(error.errorString()); - } -#endif - if (!errorStr.isEmpty()) { - qWarning() << __FUNCTION__ << "Failed to import asset:" << errorStr << outDir; - - // Write the error into a file in outDir to pass it to creator side - QString errorFileName = outDir + "/__error.log"; - QFile file(errorFileName); - if (file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { - QTextStream out(&file); - out << errorStr; - file.close(); - } - } - - QTimer::singleShot(0, nullptr, []() { - qApp->quit(); - }); -} - -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.h deleted file mode 100644 index 57b1013acc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QString> - -namespace Import3D -{ - void import3D(const QString &sourceAsset, const QString &outDir, const QString &options); -}; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.pri deleted file mode 100644 index 8e4d6b6a31..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/import3d/import3d.pri +++ /dev/null @@ -1,3 +0,0 @@ -HEADERS += $$PWD/import3d.h - -SOURCES += $$PWD/import3d.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/anchorchangesnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/anchorchangesnodeinstance.cpp deleted file mode 100644 index 5a32a599fb..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/anchorchangesnodeinstance.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "anchorchangesnodeinstance.h" - -namespace QmlDesigner { - -namespace Internal { - -AnchorChangesNodeInstance::AnchorChangesNodeInstance(QObject *object) : - ObjectNodeInstance(object) -{ -} - -AnchorChangesNodeInstance::Pointer AnchorChangesNodeInstance::create(QObject *object) -{ - Q_ASSERT(object); - - Pointer instance(new AnchorChangesNodeInstance(object)); - - return instance; -} - -void AnchorChangesNodeInstance::setPropertyVariant(const PropertyName &/*name*/, const QVariant &/*value*/) -{ -} - -void AnchorChangesNodeInstance::setPropertyBinding(const PropertyName &/*name*/, const QString &/*expression*/) -{ -} - -QVariant AnchorChangesNodeInstance::property(const PropertyName &/*name*/) const -{ - return QVariant(); -} - -void AnchorChangesNodeInstance::resetProperty(const PropertyName &/*name*/) -{ -} - -void AnchorChangesNodeInstance::reparent(const ObjectNodeInstance::Pointer &/*oldParentInstance*/, - const PropertyName &/*oldParentProperty*/, - const ObjectNodeInstance::Pointer &/*newParentInstance*/, - const PropertyName &/*newParentProperty*/) -{ -} - -QObject *AnchorChangesNodeInstance::changesObject() const -{ - return object(); -} - -} // namespace Internal - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/anchorchangesnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/anchorchangesnodeinstance.h deleted file mode 100644 index cab4ba631a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/anchorchangesnodeinstance.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -#include <QPair> -#include <QWeakPointer> - -QT_BEGIN_NAMESPACE -class QQmlProperty; -QT_END_NAMESPACE - -namespace QmlDesigner { - -namespace Internal { - -class AnchorChangesNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<AnchorChangesNodeInstance>; - using WeakPointer = QWeakPointer<AnchorChangesNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - void setPropertyVariant(const PropertyName &name, const QVariant &value) override; - void setPropertyBinding(const PropertyName &name, const QString &expression) override; - QVariant property(const PropertyName &name) const override; - void resetProperty(const PropertyName &name) override; - - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, - const PropertyName &oldParentProperty, - const ObjectNodeInstance::Pointer &newParentInstance, - const PropertyName &newParentProperty) override; - -protected: - AnchorChangesNodeInstance(QObject *object); - QObject *changesObject() const; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/animationdriver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/animationdriver.cpp deleted file mode 100644 index bc8251f2d8..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/animationdriver.cpp +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "animationdriver.h" -#include "private/qabstractanimation_p.h" - -AnimationDriver::AnimationDriver(QObject *parent) - : QAnimationDriver(parent) -{ - setProperty("allowNegativeDelta", true); - install(); -} - -AnimationDriver::~AnimationDriver() -{ - -} - -void AnimationDriver::timerEvent([[maybe_unused]] QTimerEvent *e) -{ - Q_ASSERT(e->timerId() == m_timer.timerId()); - - quint32 old = elapsed(); - // Provide same time for all users - if (m_seekerEnabled) { - m_seekerElapsed += (m_seekerPos * 100) / 30; - if (m_seekerElapsed + m_elapsed - m_pauseTime < -100) // -100 to allow small negative value - m_seekerElapsed = -(m_elapsed - m_pauseTime) - 100; - } else { - if (!m_elapsedTimer.isValid()) - m_elapsedTimer.restart(); - else - m_elapsed = m_elapsedTimer.elapsed(); - } - m_delta = elapsed() - old; - advance(); - Q_EMIT advanced(); -} - -void AnimationDriver::startTimer() -{ - m_timer.start(m_interval, Qt::PreciseTimer, this); -} - -void AnimationDriver::stopTimer() -{ - m_timer.stop(); -} - -void AnimationDriver::setSeekerPosition(int position) -{ - if (!m_seekerEnabled) - return; - - if (!m_timer.isActive()) - startTimer(); - - m_seekerPos = position; -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/animationdriver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/animationdriver.h deleted file mode 100644 index 8b945dc725..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/animationdriver.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qabstractanimation.h> -#include <QtCore/qbasictimer.h> -#include <QtCore/qelapsedtimer.h> -#include <QtCore/qmath.h> - -class AnimationDriver : public QAnimationDriver -{ - Q_OBJECT -public: - AnimationDriver(QObject *parent = nullptr); - ~AnimationDriver(); - void timerEvent(QTimerEvent *e) override; - void setInterval(int interval) - { - m_interval = qBound(1, interval, 60); - } - int interval() const - { - return m_interval; - } - void reset() - { - m_elapsedTimer.invalidate(); - m_pauseBegin = 0; - m_pauseTime = 0; - m_elapsed = 0; - m_seekerElapsed = 0; - stopTimer(); - } - void restart() - { - m_pauseTime = 0; - m_elapsed = 0; - m_seekerElapsed = 0; - startTimer(); - } - void pause() - { - m_pauseBegin = m_elapsedTimer.elapsed(); - stopTimer(); - } - void play() - { - if (m_elapsedTimer.isValid()) - m_pauseTime += m_elapsedTimer.elapsed() - m_pauseBegin; - startTimer(); - } - qint64 elapsed() const override - { - return m_elapsed + m_seekerElapsed - m_pauseTime; - } - void setSeekerPosition(int position); - void setSeekerEnabled(bool enable) - { - m_seekerEnabled = enable; - } - bool isSeekerEnabled() const - { - return m_seekerEnabled; - } - bool isAnimating() const - { - return (!m_seekerEnabled && m_timer.isActive()) || (m_seekerEnabled && m_delta && m_seekerPos); - } -Q_SIGNALS: - void advanced(); - -private: - Q_SLOT void startTimer(); - Q_SLOT void stopTimer(); - - QBasicTimer m_timer; - QElapsedTimer m_elapsedTimer; - int m_interval = 16; - int m_seekerPos = 0; - bool m_seekerEnabled = false; - qint64 m_elapsed = 0; - qint64 m_seekerElapsed = 0; - qint64 m_delta = 0; - qint64 m_pauseTime = 0; - qint64 m_pauseBegin = 0; -}; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/behaviornodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/behaviornodeinstance.cpp deleted file mode 100644 index dd15d24167..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/behaviornodeinstance.cpp +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "behaviornodeinstance.h" - -#include <qmlprivategate.h> - -namespace QmlDesigner { -namespace Internal { - -BehaviorNodeInstance::BehaviorNodeInstance(QObject *object) - : ObjectNodeInstance(object), - m_isEnabled(true) -{ -} - -BehaviorNodeInstance::Pointer BehaviorNodeInstance::create(QObject *object) -{ - Pointer instance(new BehaviorNodeInstance(object)); - - instance->populateResetHashes(); - - QmlPrivateGate::disableBehaivour(object); - - return instance; -} - -QVariant BehaviorNodeInstance::property(const PropertyName &name) const -{ - if (name == "enabled") - return QVariant::fromValue(m_isEnabled); - - return ObjectNodeInstance::property(name); -} - -void BehaviorNodeInstance::resetProperty(const PropertyName &name) -{ - if (name == "enabled") - m_isEnabled = true; - - ObjectNodeInstance::resetProperty(name); -} - -PropertyNameList BehaviorNodeInstance::ignoredProperties() const -{ - return PropertyNameList({"enabled"}); -} - - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/behaviornodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/behaviornodeinstance.h deleted file mode 100644 index 0203718d02..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/behaviornodeinstance.h +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -class BehaviorNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<BehaviorNodeInstance>; - using WeakPointer = QWeakPointer<BehaviorNodeInstance>; - - BehaviorNodeInstance(QObject *object); - - static Pointer create(QObject *objectToBeWrapped); - - QVariant property(const PropertyName &name) const override; - void resetProperty(const PropertyName &name) override; - - PropertyNameList ignoredProperties() const override; - -private: - bool m_isEnabled; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.cpp deleted file mode 100644 index df207c0ba7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "capturenodeinstanceserverdispatcher.h" - -#include "nodeinstanceclientinterface.h" -#include "qt5capturepreviewnodeinstanceserver.h" -#include "qt5informationnodeinstanceserver.h" -#include "qt5rendernodeinstanceserver.h" -#include "scenecreatedcommand.h" - -namespace QmlDesigner { - -void CaptureNodeInstanceServerDispatcher::createScene(const CreateSceneCommand &command) -{ - NodeInstanceServerDispatcher::createScene(command); - - QTimer::singleShot(100, - this, - &CaptureNodeInstanceServerDispatcher::collectItemChangesAndSendChangeCommands); -} - -void CaptureNodeInstanceServerDispatcher::collectItemChangesAndSendChangeCommands() -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->collectItemChangesAndSendChangeCommands(); - - m_nodeInstanceClient->sceneCreated({}); -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.h deleted file mode 100644 index 396caa4d72..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/capturenodeinstanceserverdispatcher.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "nodeinstanceserverdispatcher.h" - -namespace QmlDesigner { - -class CaptureNodeInstanceServerDispatcher : public NodeInstanceServerDispatcher -{ -public: - CaptureNodeInstanceServerDispatcher(const QStringList &serverNames, - NodeInstanceClientInterface *nodeInstanceClient) - : NodeInstanceServerDispatcher{serverNames, nodeInstanceClient} - , m_nodeInstanceClient{nodeInstanceClient} - {} - - void createScene(const CreateSceneCommand &command); - -private: - void collectItemChangesAndSendChangeCommands(); - -private: - NodeInstanceClientInterface *m_nodeInstanceClient; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/childrenchangeeventfilter.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/childrenchangeeventfilter.cpp deleted file mode 100644 index 63a8070240..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/childrenchangeeventfilter.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "childrenchangeeventfilter.h" - -#include <QEvent> - -namespace QmlDesigner { -namespace Internal { - -ChildrenChangeEventFilter::ChildrenChangeEventFilter(QObject *parent) - : QObject(parent) -{ -} - - -bool ChildrenChangeEventFilter::eventFilter(QObject * /*object*/, QEvent *event) -{ - switch (event->type()) { - case QEvent::ChildAdded: - case QEvent::ChildRemoved: - { - QChildEvent *childEvent = static_cast<QChildEvent*>(event); - emit childrenChanged(childEvent->child()); break; - } - default: break; - } - - return false; -} -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/childrenchangeeventfilter.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/childrenchangeeventfilter.h deleted file mode 100644 index 5e1a4c9dd6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/childrenchangeeventfilter.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QObject> - -namespace QmlDesigner { -namespace Internal { - -class ChildrenChangeEventFilter : public QObject -{ - Q_OBJECT -public: - ChildrenChangeEventFilter(QObject *parent); - - -signals: - void childrenChanged(QObject *object); - -protected: - bool eventFilter(QObject *object, QEvent *event) override; - -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/componentnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/componentnodeinstance.cpp deleted file mode 100644 index a0b297c95f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/componentnodeinstance.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "componentnodeinstance.h" - -#include <QQmlComponent> -#include <QQmlContext> - -#include <QDebug> - -namespace QmlDesigner { -namespace Internal { - -ComponentNodeInstance::ComponentNodeInstance(QQmlComponent *component) - : ObjectNodeInstance(component) -{ -} - -QQmlComponent *ComponentNodeInstance::component() const -{ - Q_ASSERT(qobject_cast<QQmlComponent*>(object())); - return static_cast<QQmlComponent*>(object()); -} - -ComponentNodeInstance::Pointer ComponentNodeInstance::create(QObject *object) -{ - QQmlComponent *component = qobject_cast<QQmlComponent *>(object); - - Q_ASSERT(component); - - Pointer instance(new ComponentNodeInstance(component)); - - instance->populateResetHashes(); - - return instance; -} - -bool ComponentNodeInstance::hasContent() const -{ - return true; -} - -void ComponentNodeInstance::setNodeSource(const QString &source) -{ - QByteArray data(source.toUtf8() + "\n"); - data.prepend(nodeInstanceServer()->importCode()); - - component()->setData(data, QUrl(nodeInstanceServer()->fileUrl().toString() + - QLatin1Char('_')+ id())); - setId(id()); - - if (component()->isError()) { - const QList<QQmlError> errors = component()->errors(); - for (const QQmlError &error : errors) - qWarning() << error; - } - -} - -} // Internal -} // QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/componentnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/componentnodeinstance.h deleted file mode 100644 index ef0f89e27c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/componentnodeinstance.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -QT_BEGIN_NAMESPACE -class QQmlComponent; -QT_END_NAMESPACE - -namespace QmlDesigner { -namespace Internal { - -class ComponentNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<ComponentNodeInstance>; - using WeakPointer = QWeakPointer<ComponentNodeInstance>; - - ComponentNodeInstance(QQmlComponent *component); - static Pointer create(QObject *objectToBeWrapped); - - bool hasContent() const override; - - void setNodeSource(const QString &source) override; - -private: //function - QQmlComponent *component() const; - -}; - -} // Internal -} // QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummycontextobject.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummycontextobject.cpp deleted file mode 100644 index c0074eccbc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummycontextobject.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "dummycontextobject.h" - -namespace QmlDesigner { - -DummyContextObject::DummyContextObject(QObject *parent) : - QObject(parent) -{ -} - -QObject *DummyContextObject::parentDummy() const -{ - return m_dummyParent.data(); -} - -void DummyContextObject::setParentDummy(QObject *parentDummy) -{ - if (m_dummyParent.data() != parentDummy) { - m_dummyParent = parentDummy; - emit parentDummyChanged(); - } -} - -bool DummyContextObject::runningInDesigner() const -{ - return true; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummycontextobject.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummycontextobject.h deleted file mode 100644 index cd5b884dfc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummycontextobject.h +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QObject> -#include <QPointer> -#include <qqml.h> - -namespace QmlDesigner { - -class DummyContextObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(QObject * parent READ parentDummy WRITE setParentDummy NOTIFY parentDummyChanged DESIGNABLE false FINAL) - Q_PROPERTY(bool runningInDesigner READ runningInDesigner FINAL) - -public: - explicit DummyContextObject(QObject *parent = nullptr); - - QObject *parentDummy() const; - void setParentDummy(QObject *parentDummy); - bool runningInDesigner() const; - -signals: - void parentDummyChanged(); - -private: - QPointer<QObject> m_dummyParent; -}; - -} // namespace QmlDesigner - -QML_DECLARE_TYPE(QmlDesigner::DummyContextObject) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummynodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummynodeinstance.cpp deleted file mode 100644 index e993d4f8ea..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummynodeinstance.cpp +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "dummynodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -DummyNodeInstance::DummyNodeInstance() - : ObjectNodeInstance(new QObject) -{ -} - -DummyNodeInstance::Pointer DummyNodeInstance::create() -{ - return Pointer(new DummyNodeInstance); -} - -QRectF DummyNodeInstance::boundingRect() const -{ - return QRectF(); -} - -QPointF DummyNodeInstance::position() const -{ - return QPointF(); -} - -QSizeF DummyNodeInstance::size() const -{ - return QSizeF(); -} - -QTransform DummyNodeInstance::transform() const -{ - return QTransform(); -} - -double DummyNodeInstance::opacity() const -{ - return 0.0; -} - -void DummyNodeInstance::setPropertyVariant(const PropertyName &/*name*/, const QVariant &/*value*/) -{ -} - -void DummyNodeInstance::setPropertyBinding(const PropertyName &/*name*/, const QString &/*expression*/) -{ - -} - -void DummyNodeInstance::setId(const QString &/*id*/) -{ - -} - -QVariant DummyNodeInstance::property(const PropertyName &/*name*/) const -{ - return QVariant(); -} - -void DummyNodeInstance::initializePropertyWatcher(const ObjectNodeInstance::Pointer &/*objectNodeInstance*/) -{ - -} - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummynodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummynodeinstance.h deleted file mode 100644 index 1ab8ad4bf6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/dummynodeinstance.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QWeakPointer> - -#include "objectnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -class DummyNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<DummyNodeInstance>; - using WeakPointer = QWeakPointer<DummyNodeInstance>; - - static Pointer create(); - - QRectF boundingRect() const override; - QPointF position() const override; - QSizeF size() const override; - QTransform transform() const override; - double opacity() const override; - - void setPropertyVariant(const PropertyName &name, const QVariant &value) override; - void setPropertyBinding(const PropertyName &name, const QString &expression) override; - void setId(const QString &id) override; - QVariant property(const PropertyName &name) const override; - - void initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance); - -protected: - DummyNodeInstance(); - -}; - -} -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri deleted file mode 100644 index 2d3b4ceedf..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/instances.pri +++ /dev/null @@ -1,89 +0,0 @@ -INCLUDEPATH += $$PWD/ - -versionAtLeast(QT_VERSION, 5.15.0) { - qtHaveModule(quick3d) { - QT *= quick3d-private - DEFINES *= QUICK3D_MODULE - } - qtHaveModule(quick3dassetimport) { - QT *= quick3dassetimport-private - DEFINES *= IMPORT_QUICK3D_ASSETS - } - qtHaveModule(quick3dparticles) { - QT *= quick3dparticles-private - DEFINES *= QUICK3D_PARTICLES_MODULE - } - qtHaveModule(quick3dassetutils) { - QT *= quick3dassetutils-private - DEFINES *= QUICK3D_ASSET_UTILS_MODULE - } -} - -HEADERS += $$PWD/qt5nodeinstanceserver.h \ - $$PWD/capturenodeinstanceserverdispatcher.h \ - $$PWD/nodeinstanceserverdispatcher.h \ - $$PWD/qt5captureimagenodeinstanceserver.h \ - $$PWD/qt5capturepreviewnodeinstanceserver.h \ - $$PWD/qt5testnodeinstanceserver.h \ - $$PWD/qt5informationnodeinstanceserver.h \ - $$PWD/qt5rendernodeinstanceserver.h \ - $$PWD/qt5previewnodeinstanceserver.h \ - $$PWD/qt5nodeinstanceclientproxy.h \ - $$PWD/quickitemnodeinstance.h \ - $$PWD/behaviornodeinstance.h \ - $$PWD/dummycontextobject.h \ - $$PWD/childrenchangeeventfilter.h \ - $$PWD/componentnodeinstance.h \ - $$PWD/dummynodeinstance.h \ - $$PWD/nodeinstanceserver.h \ - $$PWD/nodeinstancesignalspy.h \ - $$PWD/objectnodeinstance.h \ - $$PWD/qmlpropertychangesnodeinstance.h \ - $$PWD/qmlstatenodeinstance.h \ - $$PWD/qmltransitionnodeinstance.h \ - $$PWD/servernodeinstance.h \ - $$PWD/anchorchangesnodeinstance.h \ - $$PWD/positionernodeinstance.h \ - $$PWD/layoutnodeinstance.h \ - $$PWD/qt3dpresentationnodeinstance.h \ - $$PWD/quick3dmaterialnodeinstance.h \ - $$PWD/quick3dnodeinstance.h \ - $$PWD/quick3drenderablenodeinstance.h \ - $$PWD/quick3dtexturenodeinstance.h \ - $$PWD/viewconfig.h \ - $$PWD/animationdriver.h - - -SOURCES += $$PWD/qt5nodeinstanceserver.cpp \ - $$PWD/capturenodeinstanceserverdispatcher.cpp \ - $$PWD/nodeinstanceserverdispatcher.cpp \ - $$PWD/qt5captureimagenodeinstanceserver.cpp \ - $$PWD/qt5capturepreviewnodeinstanceserver.cpp \ - $$PWD/qt5testnodeinstanceserver.cpp \ - $$PWD/qt5informationnodeinstanceserver.cpp \ - $$PWD/qt5rendernodeinstanceserver.cpp \ - $$PWD/qt5previewnodeinstanceserver.cpp \ - $$PWD/qt5nodeinstanceclientproxy.cpp \ - $$PWD/quickitemnodeinstance.cpp \ - $$PWD/behaviornodeinstance.cpp \ - $$PWD/dummycontextobject.cpp \ - $$PWD/childrenchangeeventfilter.cpp \ - $$PWD/componentnodeinstance.cpp \ - $$PWD/dummynodeinstance.cpp \ - $$PWD/nodeinstanceserver.cpp \ - $$PWD/nodeinstancesignalspy.cpp \ - $$PWD/objectnodeinstance.cpp \ - $$PWD/qmlpropertychangesnodeinstance.cpp \ - $$PWD/qmlstatenodeinstance.cpp \ - $$PWD/qmltransitionnodeinstance.cpp \ - $$PWD/servernodeinstance.cpp \ - $$PWD/anchorchangesnodeinstance.cpp \ - $$PWD/positionernodeinstance.cpp \ - $$PWD/layoutnodeinstance.cpp \ - $$PWD/qt3dpresentationnodeinstance.cpp \ - $$PWD/quick3dmaterialnodeinstance.cpp \ - $$PWD/quick3dnodeinstance.cpp \ - $$PWD/quick3drenderablenodeinstance.cpp \ - $$PWD/quick3dtexturenodeinstance.cpp \ - $$PWD/viewconfig.cpp \ - $$PWD/animationdriver.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp deleted file mode 100644 index e895e58e40..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.cpp +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "layoutnodeinstance.h" - -#include <QCoreApplication> - -namespace QmlDesigner { -namespace Internal { - -LayoutNodeInstance::LayoutNodeInstance(QQuickItem *item) - : QuickItemNodeInstance(item) -{ -} - -bool LayoutNodeInstance::isLayoutable() const -{ - return true; -} - -bool LayoutNodeInstance::isResizable() const -{ - return true; -} - -LayoutNodeInstance::Pointer LayoutNodeInstance::create(QObject *object) -{ - QQuickItem *item = qobject_cast<QQuickItem*>(object); - - Q_ASSERT(item); - - Pointer instance(new LayoutNodeInstance(item)); - - instance->setHasContent(anyItemHasContent(item)); - item->setFlag(QQuickItem::ItemHasContents, true); - - static_cast<QQmlParserStatus*>(item)->classBegin(); - - instance->populateResetHashes(); - - return instance; -} - -void LayoutNodeInstance::refreshLayoutable() -{ - if (quickItem()->parent()) - QCoreApplication::postEvent(quickItem(), new QEvent(QEvent::LayoutRequest)); - -} - -PropertyNameList LayoutNodeInstance::ignoredProperties() const -{ - static const PropertyNameList properties({"move", "add", "populate"}); - return properties; -} - -} -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h deleted file mode 100644 index 015273b6ba..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/layoutnodeinstance.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "quickitemnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -class LayoutNodeInstance : public QuickItemNodeInstance -{ - -public: - using Pointer = QSharedPointer<LayoutNodeInstance>; - using WeakPointer = QWeakPointer<LayoutNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - bool isLayoutable() const override; - - bool isResizable() const override; - - void refreshLayoutable() override; - - PropertyNameList ignoredProperties() const override; - -protected: - LayoutNodeInstance(QQuickItem *item); -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp deleted file mode 100644 index 9fe970f8c7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.cpp +++ /dev/null @@ -1,1614 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "nodeinstanceserver.h" - -#include "servernodeinstance.h" -#include "objectnodeinstance.h" -#include "childrenchangeeventfilter.h" - -#include "dummycontextobject.h" - -#include <propertyabstractcontainer.h> -#include <propertybindingcontainer.h> -#include <propertyvaluecontainer.h> -#include <instancecontainer.h> - -#include <commondefines.h> -#include <nodeinstanceclientinterface.h> - -#include <qmlprivategate.h> - -#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) -#include <private/qquickdesignersupportmetainfo_p.h> -#endif - -#include <createinstancescommand.h> -#include <changefileurlcommand.h> -#include <clearscenecommand.h> -#include <reparentinstancescommand.h> -#include <changevaluescommand.h> -#include <changeauxiliarycommand.h> -#include <changebindingscommand.h> -#include <changeidscommand.h> -#include <removeinstancescommand.h> -#include <removepropertiescommand.h> -#include <valueschangedcommand.h> -#include <informationchangedcommand.h> -#include <pixmapchangedcommand.h> -#include <changestatecommand.h> -#include <childrenchangedcommand.h> -#include <completecomponentcommand.h> -#include <componentcompletedcommand.h> -#include <createscenecommand.h> -#include <changenodesourcecommand.h> -#include <tokencommand.h> -#include <removesharedmemorycommand.h> -#include <changeselectioncommand.h> -#include <inputeventcommand.h> -#include <view3dactioncommand.h> -#include <requestmodelnodepreviewimagecommand.h> -#include <changelanguagecommand.h> - -// Nanotrace headers are not exported to build dir at all if the feature is disabled, so -// runtime puppet build can't find them. -#if NANOTRACE_ENABLED -#include "nanotrace/nanotrace.h" -#else -#define NANOTRACE_SCOPE(cat, name) -#endif - -#include <QAbstractAnimation> -#include <QDebug> -#include <QDir> -#include <QFileSystemWatcher> -#include <QMetaType> -#include <QQmlApplicationEngine> -#include <QQmlComponent> -#include <QQmlContext> -#include <QQmlEngine> -#include <QQuickItemGrabResult> -#include <QQuickView> -#include <QSet> -#include <QUrl> -#include <QVariant> -#include <qqmllist.h> -#include <QFontDatabase> -#include <QFileInfo> -#include <QDirIterator> - -#include <algorithm> - -namespace { - -bool testImportStatements(const QStringList &importStatementList, - const QUrl &url, QString *errorMessage = nullptr) -{ - if (importStatementList.isEmpty()) - return false; - // ToDo: move engine outside of this function, this makes it expensive - QQmlEngine engine; - QQmlComponent testImportComponent(&engine); - - QByteArray testComponentCode = QStringList(importStatementList).join('\n').toUtf8(); - - testImportComponent.setData(testComponentCode.append("\nItem {}\n"), url); - testImportComponent.create(); - - if (testImportComponent.isError()) { - if (errorMessage) { - errorMessage->append("found not working imports: "); - errorMessage->append(testImportComponent.errorString()); - } - return false; - } - return true; -} - -void sortFilterImports(const QStringList &imports, QStringList *workingImports, QStringList *failedImports, - const QUrl &url, QString *errorMessage) -{ - static QSet<QString> visited; - QString visitCheckId("imports: %1, workingImports: %2, failedImports: %3"); - visitCheckId = visitCheckId.arg(imports.join(""), workingImports->join(""), failedImports->join("")); - if (visited.contains(visitCheckId)) - return; - else - visited.insert(visitCheckId); - - for (const QString &import : imports) { - const QStringList alreadyTestedImports = *workingImports + *failedImports; - if (!alreadyTestedImports.contains(import)) { - QStringList readyForTestImports = *workingImports; - readyForTestImports.append(import); - - QString lastErrorMessage; - if (testImportStatements(readyForTestImports, url, &lastErrorMessage)) { - Q_ASSERT(!workingImports->contains(import)); - workingImports->append(import); - } else { - if (imports.endsWith(import) == false) { - // the not working import is not the last import, so there could be some - // import dependency which we try with the reorderd remaining imports - QStringList reorderedImports; - std::copy_if(imports.cbegin(), imports.cend(), std::back_inserter(reorderedImports), - [&import, &alreadyTestedImports] (const QString &checkForResortingImport){ - if (checkForResortingImport == import) - return false; - return !alreadyTestedImports.contains(checkForResortingImport); - }); - reorderedImports.append(import); - sortFilterImports(reorderedImports, workingImports, failedImports, url, errorMessage); - } else { - Q_ASSERT(!failedImports->contains(import)); - failedImports->append(import); - if (errorMessage) - errorMessage->append(lastErrorMessage); - } - } - } - } -} -} // anonymous - -namespace QmlDesigner { - -static NodeInstanceServer *nodeInstanceServerInstance = nullptr; - -static void notifyPropertyChangeCallBackFunction(QObject *object, const PropertyName &propertyName) -{ - qint32 id = nodeInstanceServerInstance->instanceForObject(object).instanceId(); - nodeInstanceServerInstance->notifyPropertyChange(id, propertyName); -} - -static void (*notifyPropertyChangeCallBackPointer)(QObject *, const PropertyName &) = ¬ifyPropertyChangeCallBackFunction; - -NodeInstanceServer::NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) : - NodeInstanceServerInterface(), - m_childrenChangeEventFilter(new Internal::ChildrenChangeEventFilter(this)), - m_nodeInstanceClient(nodeInstanceClient) -{ - m_idInstances.reserve(1000); - - qmlRegisterType<DummyContextObject>("QmlDesigner", 1, 0, "DummyContextObject"); - - connect(m_childrenChangeEventFilter.data(), &Internal::ChildrenChangeEventFilter::childrenChanged, - this, &NodeInstanceServer::emitParentChanged); - nodeInstanceServerInstance = this; - Internal::QmlPrivateGate::registerNotifyPropertyChangeCallBack(notifyPropertyChangeCallBackPointer); - Internal::QmlPrivateGate::registerFixResourcePathsForObjectCallBack(); -} - -NodeInstanceServer::~NodeInstanceServer() -{ - m_objectInstanceHash.clear(); -} - -QList<ServerNodeInstance> NodeInstanceServer::createInstances(const QVector<InstanceContainer> &containerVector) -{ - Q_ASSERT(declarativeView() || quickWindow()); - QList<ServerNodeInstance> instanceList; - for (const InstanceContainer &instanceContainer : containerVector) { - ServerNodeInstance instance; - if (instanceContainer.nodeSourceType() == InstanceContainer::ComponentSource) { - instance = ServerNodeInstance::create(this, instanceContainer, ServerNodeInstance::WrapAsComponent); - } else { - instance = ServerNodeInstance::create(this, instanceContainer, ServerNodeInstance::DoNotWrapAsComponent); - } - insertInstanceRelationship(instance); - instanceList.append(instance); - instance.internalObject()->installEventFilter(childrenChangeEventFilter()); - if (instanceContainer.instanceId() == 0) { - m_rootNodeInstance = instance; - if (quickView()) - quickView()->setContent(fileUrl(), m_importComponent, m_rootNodeInstance.rootQuickItem()); - } - - const QList<QQmlContext *> subContexts = allSubContextsForObject(instance.internalObject()); - for (QQmlContext *context : subContexts) - setupDummysForContext(context); - } - - return instanceList; -} - -void NodeInstanceServer::createInstances(const CreateInstancesCommand &command) -{ - createInstances(command.instances()); - startRenderTimer(); -} - -ServerNodeInstance NodeInstanceServer::instanceForId(qint32 id) const -{ - if (id < 0) - return ServerNodeInstance(); - - Q_ASSERT(m_idInstances.size() > id); - return m_idInstances[id]; -} - -bool NodeInstanceServer::hasInstanceForId(qint32 id) const -{ - if (id < 0) - return false; - - return m_idInstances.size() > id && m_idInstances[id].isValid(); -} - -ServerNodeInstance NodeInstanceServer::instanceForObject(QObject *object) const -{ - Q_ASSERT(m_objectInstanceHash.contains(object)); - return m_objectInstanceHash.value(object); -} - -bool NodeInstanceServer::hasInstanceForObject(QObject *object) const -{ - if (object == nullptr) - return false; - - return m_objectInstanceHash.contains(object) && m_objectInstanceHash.value(object).isValid(); -} - -void NodeInstanceServer::setRenderTimerInterval(int timerInterval) -{ - m_renderTimerInterval = timerInterval; -} - -void NodeInstanceServer::setSlowRenderTimerInterval(int timerInterval) -{ - m_timerModeInterval = timerInterval; -} - -void NodeInstanceServer::setTimerId(int timerId) -{ - m_timer = timerId; -} - -int NodeInstanceServer::timerId() const -{ - return m_timer; -} - -int NodeInstanceServer::renderTimerInterval() const -{ - return m_renderTimerInterval; -} - -void NodeInstanceServer::startRenderTimer() -{ - if (m_timerMode == TimerMode::SlowTimer) - stopRenderTimer(); - - if (m_timerMode == TimerMode::DisableTimer) - return; - - if (m_timer == 0) - m_timer = startTimer(m_renderTimerInterval); - - m_timerMode = TimerMode::NormalTimer; -} - -void NodeInstanceServer::slowDownRenderTimer() -{ - if (m_timer != 0) { - killTimer(m_timer); - m_timer = 0; - } - - if (m_timerMode == TimerMode::DisableTimer) - return; - - m_timer = startTimer(m_timerModeInterval); - - m_timerMode = TimerMode::SlowTimer; -} - -void NodeInstanceServer::stopRenderTimer() -{ - if (m_timer) { - killTimer(m_timer); - m_timer = 0; - } -} - -void NodeInstanceServer::createScene(const CreateSceneCommand &command) -{ - initializeView(); - registerFonts(command.resourceUrl); - setTranslationLanguage(command.language); - - if (!ViewConfig::isParticleViewMode()) - Internal::QmlPrivateGate::stopUnifiedTimer(); - - setupScene(command); - setupState(command.stateInstanceId); - refreshBindings(); - startRenderTimer(); -} - -void NodeInstanceServer::clearScene(const ClearSceneCommand &/*command*/) -{ - stopRenderTimer(); - - removeAllInstanceRelationships(); - m_fileSystemWatcherHash.clear(); - m_rootNodeInstance.makeInvalid(); - m_changedPropertyList.clear(); - m_fileUrl.clear(); -} - -void NodeInstanceServer::update3DViewState(const Update3dViewStateCommand &/*command*/) -{ -} - -void NodeInstanceServer::changeSelection(const ChangeSelectionCommand &/*command*/) -{ -} - -void NodeInstanceServer::removeInstances(const RemoveInstancesCommand &command) -{ - ServerNodeInstance oldState = activeStateInstance(); - if (activeStateInstance().isValid()) - activeStateInstance().deactivateState(); - - const QVector<qint32> instanceIds = command.instanceIds(); - for (qint32 instanceId : instanceIds) - removeInstanceRelationsip(instanceId); - - if (oldState.isValid()) - oldState.activateState(); - - refreshBindings(); - startRenderTimer(); -} - -void NodeInstanceServer::removeProperties(const RemovePropertiesCommand &command) -{ - bool hasDynamicProperties = false; - const QVector<PropertyAbstractContainer> props = command.properties(); - for (const PropertyAbstractContainer &container : props) { - hasDynamicProperties |= container.isDynamic(); - resetInstanceProperty(container); - } - - if (hasDynamicProperties) - refreshBindings(); - - startRenderTimer(); -} - -void NodeInstanceServer::reparentInstances(const QVector<ReparentContainer> &containerVector) -{ - for (const ReparentContainer &container : containerVector) { - if (hasInstanceForId(container.instanceId())) { - ServerNodeInstance instance = instanceForId(container.instanceId()); - if (instance.isValid()) { - ServerNodeInstance newParent = instanceForId(container.newParentInstanceId()); - PropertyName newParentProperty = container.newParentProperty(); - if (!isInformationServer()) { - // Children of the component wraps are left out of the node tree to avoid - // incorrectly rendering them - if (newParent.isComponentWrap()) { - newParent = {}; - newParentProperty.clear(); - } - } - instance.reparent(instanceForId(container.oldParentInstanceId()), - container.oldParentProperty(), - newParent, newParentProperty); - } - } - } -} - -void NodeInstanceServer::reparentInstances(const ReparentInstancesCommand &command) -{ - reparentInstances(command.reparentInstances()); - refreshBindings(); - startRenderTimer(); -} - -void NodeInstanceServer::changeState(const ChangeStateCommand &command) -{ - setupState(command.stateInstanceId()); - startRenderTimer(); -} - -void NodeInstanceServer::completeComponent(const CompleteComponentCommand &command) -{ - QList<ServerNodeInstance> instanceList; - - const QVector<qint32> instanceIds = command.instances(); - for (qint32 instanceId : instanceIds) { - if (hasInstanceForId(instanceId)) { - ServerNodeInstance instance = instanceForId(instanceId); - instance.doComponentComplete(); - instanceList.append(instance); - } - } - - startRenderTimer(); -} - -void NodeInstanceServer::changeNodeSource(const ChangeNodeSourceCommand &command) -{ - if (hasInstanceForId(command.instanceId())) { - ServerNodeInstance instance = instanceForId(command.instanceId()); - if (instance.isValid()) - instance.setNodeSource(command.nodeSource()); - } - - startRenderTimer(); -} - -void NodeInstanceServer::token(const TokenCommand &/*command*/) -{ -} - -void NodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &/*command*/) -{ -} - -void NodeInstanceServer::setupImports(const QVector<AddImportContainer> &containerVector) -{ - Q_ASSERT(quickWindow()); - QSet<QString> importStatementSet; - QString qtQuickImport; - - for (const AddImportContainer &container : containerVector) { - QString importStatement = QString("import "); - - if (!container.fileName().isEmpty()) - importStatement += '"' + container.fileName() + '"'; - else if (!container.url().isEmpty()) - importStatement += container.url().toString(); - - if (!container.version().isEmpty()) - importStatement += ' ' + container.version(); - - if (!container.alias().isEmpty()) - importStatement += " as " + container.alias(); - - if (importStatement.startsWith(QLatin1String("import QtQuick") + QChar(QChar::Space))) - qtQuickImport = importStatement; - else - importStatementSet.insert(importStatement); - } - - delete m_importComponent.data(); - delete m_importComponentObject.data(); - const QStringList importStatementList = QtHelpers::toList(importStatementSet); - const QStringList fullImportStatementList(QStringList(qtQuickImport) + importStatementList); - - // check possible import statements combinations - // but first try the current order -> maybe it just works - if (testImportStatements(fullImportStatementList, fileUrl())) { - setupOnlyWorkingImports(fullImportStatementList); - } else { - QString errorMessage; - - if (!testImportStatements(QStringList(qtQuickImport), fileUrl(), &errorMessage)) - qtQuickImport = "import QtQuick 2.0"; - if (testImportStatements(QStringList(qtQuickImport), fileUrl(), &errorMessage)) { - QStringList workingImportStatementList; - QStringList failedImportList; - sortFilterImports(QStringList(qtQuickImport) + importStatementList, &workingImportStatementList, - &failedImportList, fileUrl(), &errorMessage); - setupOnlyWorkingImports(workingImportStatementList); - } - if (!errorMessage.isEmpty()) - sendDebugOutput(DebugOutputCommand::WarningType, errorMessage); - } -} - -void NodeInstanceServer::setupOnlyWorkingImports(const QStringList &workingImportStatementList) -{ - QByteArray componentCode = workingImportStatementList.join("\n").toUtf8().append("\n"); - m_importCode = componentCode; - - m_importComponent = new QQmlComponent(engine(), quickWindow()); - if (quickView()) - quickView()->setContent(fileUrl(), m_importComponent, quickView()->rootObject()); - - m_importComponent->setData(componentCode.append("\nItem {}\n"), fileUrl()); - m_importComponentObject = m_importComponent->create(engine()->rootContext()); - - Q_ASSERT(m_importComponent && m_importComponentObject); - Q_ASSERT_X(m_importComponent->errors().isEmpty(), __FUNCTION__, m_importComponent->errorString().toLatin1()); -} - -void NodeInstanceServer::setupFileUrl(const QUrl &fileUrl) -{ - if (!fileUrl.isEmpty()) { - engine()->setBaseUrl(fileUrl); - m_fileUrl = fileUrl; - } -} - -void NodeInstanceServer::setupDummyData(const QUrl &fileUrl) -{ - if (!fileUrl.isEmpty()) { - const QStringList dummyDataDirectoryList = dummyDataDirectories(QFileInfo(fileUrl.toLocalFile()).path()); - for (const QString &dummyDataDirectory : dummyDataDirectoryList) { - loadDummyDataFiles(dummyDataDirectory); - loadDummyDataContext(dummyDataDirectory); - } - } - - if (m_dummyContextObject.isNull()) - setupDefaultDummyData(); - rootContext()->setContextObject(m_dummyContextObject); -} - -void NodeInstanceServer::setupDefaultDummyData() -{ - QQmlComponent component(engine()); - QByteArray defaultContextObjectArray("import QtQml 2.0\n" - "import QmlDesigner 1.0\n" - "DummyContextObject {\n" - " parent: QtObject {\n" - " property real width: 360\n" - " property real height: 640\n" - " }\n" - "}\n"); - - component.setData(defaultContextObjectArray, fileUrl()); - m_dummyContextObject = component.create(); - - if (component.isError()) { - const QList<QQmlError> errors = component.errors(); - for (const QQmlError &error : errors) - qWarning() << error; - } - - if (m_dummyContextObject) - m_dummyContextObject->setParent(this); - - - refreshBindings(); -} - -QList<ServerNodeInstance> NodeInstanceServer::setupInstances(const CreateSceneCommand &command) -{ - QList<ServerNodeInstance> instanceList = createInstances(command.instances); - - for (const IdContainer &container : std::as_const(command.ids)) { - if (hasInstanceForId(container.instanceId())) - instanceForId(container.instanceId()).setId(container.id()); - } - - for (const PropertyValueContainer &container : std::as_const(command.valueChanges)) { - if (container.isDynamic()) - setInstancePropertyVariant(container); - } - - for (const PropertyValueContainer &container : std::as_const(command.valueChanges)) { - if (!container.isDynamic()) - setInstancePropertyVariant(container); - } - - reparentInstances(command.reparentInstances); - - for (const PropertyBindingContainer &container : std::as_const(command.bindingChanges)) { - if (container.isDynamic()) - setInstancePropertyBinding(container); - } - - for (const PropertyBindingContainer &container : std::as_const(command.bindingChanges)) { - if (!container.isDynamic()) - setInstancePropertyBinding(container); - } - - for (const PropertyValueContainer &container : std::as_const(command.auxiliaryChanges)) - setInstanceAuxiliaryData(container); - - for (int i = instanceList.size(); --i >= 0; ) - instanceList[i].doComponentComplete(); - - return instanceList; -} - -void NodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command) -{ - m_fileUrl = command.fileUrl; - - if (engine()) - engine()->setBaseUrl(m_fileUrl); - - refreshBindings(); - startRenderTimer(); -} - -void NodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command) -{ - bool hasDynamicProperties = false; - const QVector<PropertyValueContainer> valueChanges = command.valueChanges(); - for (const PropertyValueContainer &container : valueChanges) { - hasDynamicProperties |= container.isDynamic(); - setInstancePropertyVariant(container); - } - - if (hasDynamicProperties) - refreshBindings(); - - startRenderTimer(); -} - -void NodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) -{ - const QVector<PropertyValueContainer> auxiliaryChanges = command.auxiliaryChanges; - for (const PropertyValueContainer &container : auxiliaryChanges) - setInstanceAuxiliaryData(container); - - startRenderTimer(); -} - -void NodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &command) -{ - bool hasDynamicProperties = false; - const QVector<PropertyBindingContainer> bindingChanges = command.bindingChanges; - for (const PropertyBindingContainer &container : bindingChanges) { - hasDynamicProperties |= container.isDynamic(); - setInstancePropertyBinding(container); - } - - if (hasDynamicProperties) - refreshBindings(); - - startRenderTimer(); -} - -void NodeInstanceServer::changeIds(const ChangeIdsCommand &command) -{ - for (const IdContainer &container : command.ids) { - if (hasInstanceForId(container.instanceId())) - instanceForId(container.instanceId()).setId(container.id()); - } - - refreshBindings(); - startRenderTimer(); -} - -QQmlContext *NodeInstanceServer::context() const -{ - if (m_importComponentObject) { - QQmlContext *importComponentContext = QQmlEngine::contextForObject(m_importComponentObject.data()); - if (importComponentContext) // this should be the default - return importComponentContext; - } - - if (engine()) - return rootContext(); - - return nullptr; -} - -QQmlContext *NodeInstanceServer::rootContext() const -{ - return engine()->rootContext(); -} - -const QVector<NodeInstanceServer::InstancePropertyPair> NodeInstanceServer::changedPropertyList() const -{ - return m_changedPropertyList; -} - -void NodeInstanceServer::clearChangedPropertyList() -{ - m_changedPropertyList.clear(); -} - -void NodeInstanceServer::setupDummysForContext(QQmlContext *context) -{ - for (const DummyPair &dummyPair : std::as_const(m_dummyObjectList)) { - if (dummyPair.second) - context->setContextProperty(dummyPair.first, dummyPair.second.data()); - } -} - -static bool isTypeAvailable(const MockupTypeContainer &mockupType, QQmlEngine *engine) -{ - QString qmlSource; - qmlSource.append("import " + - mockupType.importUri() - + " " - + QString::number(mockupType.majorVersion()) - + "." + QString::number(mockupType.minorVersion()) - + "\n"); - - qmlSource.append(QString::fromUtf8(mockupType.typeName()) + "{\n}\n"); - - QQmlComponent component(engine); - component.setData(qmlSource.toUtf8(), QUrl()); - - return !component.isError(); -} - -void NodeInstanceServer::setupMockupTypes(const QVector<MockupTypeContainer> &container) -{ - for (const MockupTypeContainer &mockupType : container) { - if (!isTypeAvailable(mockupType, engine())) { -#if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0)) - if (mockupType.majorVersion() == -1 && mockupType.minorVersion() == -1) { - QQuickDesignerSupportMetaInfo::registerMockupObject(mockupType.importUri().toUtf8(), - 1, - 0, - mockupType.typeName()); - } else { - QQuickDesignerSupportMetaInfo::registerMockupObject(mockupType.importUri().toUtf8(), - mockupType.majorVersion(), - mockupType.minorVersion(), - mockupType.typeName()); - } -#else - qmlRegisterType(QUrl("qrc:/qtquickplugin/mockfiles/GenericBackend.qml"), - mockupType.importUri().toUtf8(), - mockupType.majorVersion(), - mockupType.minorVersion(), - mockupType.typeName()); -#endif - } - } -} - -QList<QQmlContext *> NodeInstanceServer::allSubContextsForObject(QObject *object) -{ - QList<QQmlContext *> contextList; - - if (object) { - const QList<QObject *> subObjects = object->findChildren<QObject *>(); - for (QObject *subObject : subObjects) { - QQmlContext *contextOfObject = QQmlEngine::contextForObject(subObject); - if (contextOfObject) { - if (contextOfObject != context() && !contextList.contains(contextOfObject)) - contextList.append(contextOfObject); - } - } - } - - return contextList; -} - -QList<QObject *> NodeInstanceServer::allSubObjectsForObject(QObject *object) -{ - QList<QObject *> subChildren; - if (object) - subChildren = object->findChildren<QObject *>(); - - return subChildren; -} - -void NodeInstanceServer::removeAllInstanceRelationships() -{ - for (ServerNodeInstance &instance : m_objectInstanceHash) { - if (instance.isValid()) - instance.setId({}); - } - - // First the root object - // This also cleans up all objects that have root object as ancestor - rootNodeInstance().makeInvalid(); - - // Invalidate any remaining objects - for (ServerNodeInstance &instance : m_objectInstanceHash) - instance.makeInvalid(); - - m_idInstances.clear(); - m_objectInstanceHash.clear(); -} - -QFileSystemWatcher *NodeInstanceServer::dummydataFileSystemWatcher() -{ - if (m_dummdataFileSystemWatcher.isNull()) { - m_dummdataFileSystemWatcher = new QFileSystemWatcher(this); - connect(m_dummdataFileSystemWatcher.data(), &QFileSystemWatcher::fileChanged, this, - &NodeInstanceServer::refreshDummyData); - } - - return m_dummdataFileSystemWatcher.data(); -} - -QFileSystemWatcher *NodeInstanceServer::fileSystemWatcher() -{ - if (m_fileSystemWatcher.isNull()) { - m_fileSystemWatcher = new QFileSystemWatcher(this); - connect(m_fileSystemWatcher.data(), &QFileSystemWatcher::fileChanged, this, - &NodeInstanceServer::refreshLocalFileProperty); - } - - return m_fileSystemWatcher.data(); -} - -Internal::ChildrenChangeEventFilter *NodeInstanceServer::childrenChangeEventFilter() const -{ - return m_childrenChangeEventFilter.data(); -} - -void NodeInstanceServer::addFilePropertyToFileSystemWatcher(QObject *object, const PropertyName &propertyName, - const QString &path) -{ - if (!m_fileSystemWatcherHash.contains(path)) { - m_fileSystemWatcherHash.insert(path, ObjectPropertyPair(object, propertyName)); - fileSystemWatcher()->addPath(path); - } -} - -void NodeInstanceServer::removeFilePropertyFromFileSystemWatcher(QObject *object, const PropertyName &propertyName, - const QString &path) -{ - if (m_fileSystemWatcherHash.contains(path)) { - fileSystemWatcher()->removePath(path); - m_fileSystemWatcherHash.remove(path, ObjectPropertyPair(object, propertyName)); - } -} - -void NodeInstanceServer::refreshLocalFileProperty(const QString &path) -{ - if (m_fileSystemWatcherHash.contains(path)) { - for (const ObjectPropertyPair &objectPropertyPair : std::as_const(m_fileSystemWatcherHash)) { - QObject *object = objectPropertyPair.first.data(); - PropertyName propertyName = objectPropertyPair.second; - - if (hasInstanceForObject(object)) { - instanceForObject(object).refreshProperty(propertyName); - } - } - } -} - -void NodeInstanceServer::refreshDummyData(const QString &path) -{ - engine()->clearComponentCache(); - QFileInfo filePath(path); - if (filePath.completeBaseName().contains("_dummycontext")) - loadDummyContextObjectFile(filePath); - else - loadDummyDataFile(filePath); - - refreshBindings(); - startRenderTimer(); -} - -void NodeInstanceServer::addChangedProperty(const InstancePropertyPair &property) -{ - if (!m_changedPropertyList.contains(property)) - m_changedPropertyList.append(property); -} - -void NodeInstanceServer::emitParentChanged(QObject *child) -{ - if (hasInstanceForObject(child)) { - addChangedProperty(InstancePropertyPair(instanceForObject(child), "parent")); - } -} - -Internal::ChildrenChangeEventFilter *NodeInstanceServer::childrenChangeEventFilter() -{ - if (m_childrenChangeEventFilter.isNull()) { - m_childrenChangeEventFilter = new Internal::ChildrenChangeEventFilter(this); - connect(m_childrenChangeEventFilter.data(), &Internal::ChildrenChangeEventFilter::childrenChanged, - this, &NodeInstanceServer::emitParentChanged); - } - - return m_childrenChangeEventFilter.data(); -} - -void NodeInstanceServer::resetInstanceProperty(const PropertyAbstractContainer &propertyContainer) -{ - if (hasInstanceForId(propertyContainer.instanceId())) { // TODO ugly workaround - ServerNodeInstance instance = instanceForId(propertyContainer.instanceId()); - Q_ASSERT(instance.isValid()); - - const PropertyName name = propertyContainer.name(); - - if (activeStateInstance().isValid() && !instance.isSubclassOf("QtQuick/PropertyChanges")) { - bool statePropertyWasReseted = activeStateInstance().resetStateProperty(instance, name, - instance.resetVariant(name)); - if (!statePropertyWasReseted) - instance.resetProperty(name); - } else { - instance.resetProperty(name); - } - - if (propertyContainer.isDynamic() && propertyContainer.instanceId() == 0 && engine()) - rootContext()->setContextProperty(QString::fromUtf8(name), QVariant()); - } -} - - -void NodeInstanceServer::setInstancePropertyBinding(const PropertyBindingContainer &bindingContainer) -{ - if (hasInstanceForId(bindingContainer.instanceId())) { - ServerNodeInstance instance = instanceForId(bindingContainer.instanceId()); - - const PropertyName name = bindingContainer.name(); - const QString expression = bindingContainer.expression(); - - - if (activeStateInstance().isValid() && !instance.isSubclassOf("QtQuick/PropertyChanges")) { - bool stateBindingWasUpdated = activeStateInstance().updateStateBinding(instance, name, expression); - if (!stateBindingWasUpdated) { - if (bindingContainer.isDynamic()) - Internal::QmlPrivateGate::createNewDynamicProperty(instance.internalInstance()->object(), engine(), - QString::fromUtf8(name)); - instance.setPropertyBinding(name, expression); - } - } else { - if (bindingContainer.isDynamic()) - Internal::QmlPrivateGate::createNewDynamicProperty(instance.internalInstance()->object(), engine(), - QString::fromUtf8(name)); - instance.setPropertyBinding(name, expression); - - if (instance.instanceId() == 0 && (name == "width" || name == "height")) - resizeCanvasToRootItem(); - } - } -} - - -void NodeInstanceServer::removeProperties(const QList<PropertyAbstractContainer> &propertyList) -{ - for (const PropertyAbstractContainer &property : propertyList) - resetInstanceProperty(property); -} - -void NodeInstanceServer::setInstancePropertyVariant(const PropertyValueContainer &valueContainer) -{ - if (hasInstanceForId(valueContainer.instanceId())) { - ServerNodeInstance instance = instanceForId(valueContainer.instanceId()); - - const PropertyName name = valueContainer.name(); - const QVariant value = valueContainer.value(); - - if (activeStateInstance().isValid() && !instance.isSubclassOf("QtQuick/PropertyChanges")) { - bool stateValueWasUpdated = activeStateInstance().updateStateVariant(instance, name, value); - if (!stateValueWasUpdated) { - if (valueContainer.isDynamic()) { - Internal::QmlPrivateGate::createNewDynamicProperty(instance.internalInstance()->object(), - engine(), QString::fromUtf8(name)); - } - instance.setPropertyVariant(name, value); - } - } else { // base state - if (valueContainer.isDynamic()) { - Internal::QmlPrivateGate::createNewDynamicProperty(instance.internalInstance()->object(), - engine(), QString::fromUtf8(name)); - } - instance.setPropertyVariant(name, value); - } - - if (valueContainer.isDynamic() && valueContainer.instanceId() == 0 && engine()) - rootContext()->setContextProperty(QString::fromUtf8(name), Internal::QmlPrivateGate::fixResourcePaths(value)); - - if (valueContainer.instanceId() == 0 && (name == "width" || name == "height" || name == "x" || name == "y")) - resizeCanvasToRootItem(); - } -} - -void NodeInstanceServer::setInstanceAuxiliaryData(const PropertyValueContainer &auxiliaryContainer) -{ - if (auxiliaryContainer.auxiliaryDataType() == AuxiliaryDataType::NodeInstancePropertyOverwrite) { - if (!auxiliaryContainer.value().isNull()) - setInstancePropertyVariant(auxiliaryContainer); - else - rootNodeInstance().resetProperty(auxiliaryContainer.name()); - } else if (auxiliaryContainer.auxiliaryDataType() == AuxiliaryDataType::Document) { - if (auxiliaryContainer.name() == "invisible") { - if (hasInstanceForId(auxiliaryContainer.instanceId())) { - ServerNodeInstance instance = instanceForId(auxiliaryContainer.instanceId()); - if (!auxiliaryContainer.value().isNull()) - instance.setHiddenInEditor(auxiliaryContainer.value().toBool()); - else - instance.setHiddenInEditor(false); - } - } else if (auxiliaryContainer.name() == "locked") { - if (hasInstanceForId(auxiliaryContainer.instanceId())) { - ServerNodeInstance instance = instanceForId(auxiliaryContainer.instanceId()); - if (!auxiliaryContainer.value().isNull()) - instance.setLockedInEditor(auxiliaryContainer.value().toBool()); - else - instance.setLockedInEditor(false); - } - } - } -} - -QUrl NodeInstanceServer::fileUrl() const -{ - return m_fileUrl; -} - -ServerNodeInstance NodeInstanceServer::activeStateInstance() const -{ - return m_activeStateInstance; -} - -ServerNodeInstance NodeInstanceServer::rootNodeInstance() const -{ - return m_rootNodeInstance; -} - -QList<ServerNodeInstance> NodeInstanceServer::allGroupStateInstances() const -{ - QList<ServerNodeInstance> groups; - std::copy_if(nodeInstances().cbegin(), - nodeInstances().cend(), - std::back_inserter(groups), - [](const ServerNodeInstance &instance) { - return instance.isValid() && instance.internalObject()->metaObject() - && instance.internalObject()->metaObject()->className() - == QByteArrayLiteral("QQuickStateGroup"); - }); - - return groups; -} - -void NodeInstanceServer::setStateInstance(const ServerNodeInstance &stateInstance) -{ - m_activeStateInstance = stateInstance; -} - -void NodeInstanceServer::clearStateInstance() -{ - m_activeStateInstance = ServerNodeInstance(); -} - -void NodeInstanceServer::timerEvent(QTimerEvent *event) -{ - if (event->timerId() == m_timer) { - collectItemChangesAndSendChangeCommands(); - } - - NodeInstanceServerInterface::timerEvent(event); -} - -NodeInstanceClientInterface *NodeInstanceServer::nodeInstanceClient() const -{ - return m_nodeInstanceClient; -} - -static QVector<InformationContainer> createInformationVector(const QList<ServerNodeInstance> &instanceList, bool initial) -{ - QVector<InformationContainer> informationVector; - - for (const ServerNodeInstance &instance : instanceList) { - if (instance.isValid()) { - informationVector.append(InformationContainer(instance.instanceId(), Position, instance.position())); - informationVector.append(InformationContainer(instance.instanceId(), Transform, instance.transform())); - informationVector.append(InformationContainer(instance.instanceId(), SceneTransform, instance.sceneTransform())); - informationVector.append(InformationContainer(instance.instanceId(), Size, instance.size())); - informationVector.append(InformationContainer(instance.instanceId(), BoundingRect, instance.boundingRect())); - informationVector.append(InformationContainer(instance.instanceId(), ContentItemBoundingRect, instance.contentItemBoundingRect())); - informationVector.append(InformationContainer(instance.instanceId(), Transform, instance.transform())); - informationVector.append(InformationContainer(instance.instanceId(), ContentTransform, instance.contentTransform())); - informationVector.append(InformationContainer(instance.instanceId(), ContentItemTransform, instance.contentItemTransform())); - informationVector.append(InformationContainer(instance.instanceId(), HasContent, instance.hasContent())); - informationVector.append(InformationContainer(instance.instanceId(), IsMovable, instance.isMovable())); - informationVector.append(InformationContainer(instance.instanceId(), IsResizable, instance.isResizable())); - informationVector.append(InformationContainer(instance.instanceId(), IsInLayoutable, instance.isInLayoutable())); - informationVector.append(InformationContainer(instance.instanceId(), PenWidth, instance.penWidth())); - informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredByChildren, instance.isAnchoredByChildren())); - informationVector.append(InformationContainer(instance.instanceId(), IsAnchoredBySibling, instance.isAnchoredBySibling())); - informationVector.append(InformationContainer(instance.instanceId(), AllStates, instance.allStates())); - - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.fill"), instance.hasAnchor("anchors.fill"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.centerIn"), instance.hasAnchor("anchors.centerIn"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.right"), instance.hasAnchor("anchors.right"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.top"), instance.hasAnchor("anchors.top"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.left"), instance.hasAnchor("anchors.left"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.bottom"), instance.hasAnchor("anchors.bottom"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.horizontalCenter"), instance.hasAnchor("anchors.horizontalCenter"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.verticalCenter"), instance.hasAnchor("anchors.verticalCenter"))); - informationVector.append(InformationContainer(instance.instanceId(), HasAnchor, PropertyName("anchors.baseline"), instance.hasAnchor("anchors.baseline"))); - - QPair<PropertyName, ServerNodeInstance> anchorPair = instance.anchor("anchors.fill"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.fill"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.centerIn"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.centerIn"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.right"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.right"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.top"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.top"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.left"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.left"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.bottom"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.bottom"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.horizontalCenter"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.horizontalCenter"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.verticalCenter"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.verticalCenter"), anchorPair.first, anchorPair.second.instanceId())); - - anchorPair = instance.anchor("anchors.baseline"); - informationVector.append(InformationContainer(instance.instanceId(), Anchor, PropertyName("anchors.baseline"), anchorPair.first, anchorPair.second.instanceId())); - - const PropertyNameList propertyNames = instance.propertyNames(); - - if (initial) { - for (const PropertyName &propertyName : propertyNames) - informationVector.append(InformationContainer(instance.instanceId(), InstanceTypeForProperty, propertyName, instance.instanceType(propertyName))); - } - - for (const PropertyName &propertyName : propertyNames) { - bool hasChanged = false; - bool hasBinding = instance.hasBindingForProperty(propertyName, &hasChanged); - if (hasChanged) - informationVector.append(InformationContainer(instance.instanceId(), HasBindingForProperty, propertyName, hasBinding)); - } - } - } - - return informationVector; -} - -ChildrenChangedCommand NodeInstanceServer::createChildrenChangedCommand(const ServerNodeInstance &parentInstance, - const QList<ServerNodeInstance> &instanceList) const -{ - QVector<qint32> instanceVector; - - for (const ServerNodeInstance &instance : instanceList) - instanceVector.append(instance.instanceId()); - - return ChildrenChangedCommand(parentInstance.instanceId(), instanceVector, - createInformationVector(instanceList, false)); -} - -InformationChangedCommand NodeInstanceServer::createAllInformationChangedCommand( - const QList<ServerNodeInstance> &instanceList, bool initial) const -{ - return InformationChangedCommand(createInformationVector(instanceList, initial)); -} - -static bool supportedVariantType(int type) -{ - return type < int(QVariant::UserType) && type != QMetaType::QObjectStar - && type != QMetaType::QModelIndex && type != QMetaType::VoidStar; -} - -ValuesChangedCommand NodeInstanceServer::createValuesChangedCommand(const QList<ServerNodeInstance> &instanceList) const -{ - QVector<PropertyValueContainer> valueVector; - - for (const ServerNodeInstance &instance : instanceList) { - const QList<PropertyName> propertyNames = instance.propertyNames(); - for (const PropertyName &propertyName : propertyNames) { - QVariant propertyValue = instance.property(propertyName); - if (supportedVariantType(propertyValue.userType())) { - valueVector.append(PropertyValueContainer(instance.instanceId(), propertyName, - propertyValue, PropertyName())); - } - } - } - - return ValuesChangedCommand(valueVector); -} - -ComponentCompletedCommand NodeInstanceServer::createComponentCompletedCommand(const QList<ServerNodeInstance> &instanceList) -{ - QVector<qint32> idVector; - for (const ServerNodeInstance &instance : instanceList) { - if (instance.instanceId() >= 0) - idVector.append(instance.instanceId()); - } - - return ComponentCompletedCommand(idVector); -} - -ChangeSelectionCommand NodeInstanceServer::createChangeSelectionCommand(const QList<ServerNodeInstance> &instanceList) -{ - QVector<qint32> idVector; - for (const ServerNodeInstance &instance : instanceList) { - if (instance.instanceId() >= 0) - idVector.append(instance.instanceId()); - } - - return ChangeSelectionCommand(idVector); -} - -ValuesChangedCommand NodeInstanceServer::createValuesChangedCommand(const QVector<InstancePropertyPair> &propertyList) const -{ - QVector<PropertyValueContainer> valueVector; - - for (const InstancePropertyPair &property : propertyList) { - const PropertyName propertyName = property.second; - const ServerNodeInstance instance = property.first; - - if (instance.isValid()) { - QVariant propertyValue = instance.property(propertyName); - bool isValid = QMetaType::isRegistered(propertyValue.userType()) - && supportedVariantType(propertyValue.type()); - if (!isValid && propertyValue.userType() == 0) { - // If the property is QVariant type, invalid variant can be a valid value - const QMetaObject *mo = instance.internalObject()->metaObject(); - const int idx = mo->indexOfProperty(propertyName); - isValid = idx >= 0 && mo->property(idx).userType() == QMetaType::QVariant; - } - if (isValid) { - valueVector.append(PropertyValueContainer(instance.instanceId(), propertyName, - propertyValue, PropertyName())); - } - } - } - - return ValuesChangedCommand(valueVector); -} - -ValuesModifiedCommand NodeInstanceServer::createValuesModifiedCommand( - const QVector<InstancePropertyValueTriple> &propertyList) const -{ - QVector<PropertyValueContainer> valueVector; - - for (const InstancePropertyValueTriple &property : propertyList) { - const PropertyName propertyName = property.propertyName; - const ServerNodeInstance instance = property.instance; - const QVariant propertyValue = property.propertyValue; - - if (instance.isValid()) { - if (QMetaType::isRegistered(propertyValue.userType()) - && supportedVariantType(propertyValue.type())) { - valueVector.append(PropertyValueContainer(instance.instanceId(), - propertyName, - propertyValue, - PropertyName())); - } - } - } - - return ValuesModifiedCommand(valueVector); -} - -QByteArray NodeInstanceServer::importCode() const -{ - return m_importCode; -} - -QObject *NodeInstanceServer::dummyContextObject() const -{ - return m_dummyContextObject.data(); -} - -void NodeInstanceServer::notifyPropertyChange(qint32 instanceid, const PropertyName &propertyName) -{ - if (hasInstanceForId(instanceid)) - addChangedProperty(InstancePropertyPair(instanceForId(instanceid), propertyName)); -} - -void NodeInstanceServer::insertInstanceRelationship(const ServerNodeInstance &instance) -{ - Q_ASSERT(instance.isValid()); - Q_ASSERT(!m_objectInstanceHash.contains(instance.internalObject())); - m_objectInstanceHash.insert(instance.internalObject(), instance); - if (instance.instanceId() >= m_idInstances.size()) - m_idInstances.resize(instance.instanceId() + 1); - m_idInstances[instance.instanceId()] = instance; -} - -void NodeInstanceServer::removeInstanceRelationsip(qint32 instanceId) -{ - if (hasInstanceForId(instanceId)) { - ServerNodeInstance instance = instanceForId(instanceId); - if (instance.isValid()) - instance.setId(QString()); - m_idInstances[instanceId] = ServerNodeInstance{}; - m_objectInstanceHash.remove(instance.internalObject()); - instance.makeInvalid(); - } -} - -PixmapChangedCommand NodeInstanceServer::createPixmapChangedCommand(const QList<ServerNodeInstance> &instanceList) const -{ - NANOTRACE_SCOPE("Update", "createPixmapChangedCommand"); - - QVector<ImageContainer> imageVector; - - for (const ServerNodeInstance &instance : instanceList) { - if (!instance.isValid()) - continue; - - QImage renderImage; - // We need to return empty image if instance has no content to correctly update the - // item image in case the instance changed from having content to not having content. - if (instance.hasContent()) - renderImage = instance.renderImage(); - imageVector.append(ImageContainer(instance.instanceId(), renderImage, instance.instanceId())); - } - - return PixmapChangedCommand(imageVector); -} - -void NodeInstanceServer::loadDummyDataFile(const QFileInfo &qmlFileInfo) -{ - QQmlComponent component(engine(), qmlFileInfo.filePath()); - QObject *dummyData = component.create(); - if (component.isError()) { - const QList<QQmlError> errors = component.errors(); - for (const QQmlError &error : errors) - qWarning() << error; - } - - QVariant oldDummyDataObject = rootContext()->contextProperty(qmlFileInfo.completeBaseName()); - - if (dummyData) { - qDebug() << "Loaded dummy data:" << qmlFileInfo.filePath(); - rootContext()->setContextProperty(qmlFileInfo.completeBaseName(), dummyData); - dummyData->setParent(this); - m_dummyObjectList.append(DummyPair(qmlFileInfo.completeBaseName(), dummyData)); - } - - if (!oldDummyDataObject.isNull()) - delete oldDummyDataObject.value<QObject*>(); - - if (!dummydataFileSystemWatcher()->files().contains(qmlFileInfo.filePath())) - dummydataFileSystemWatcher()->addPath(qmlFileInfo.filePath()); - - if (rootNodeInstance().isValid() && rootNodeInstance().internalObject()) { - const QList<QQmlContext *> subContexts = allSubContextsForObject(rootNodeInstance().internalObject()); - for (QQmlContext *context : subContexts) - setupDummysForContext(context); - } -} - -void NodeInstanceServer::loadDummyContextObjectFile(const QFileInfo &qmlFileInfo) -{ - delete m_dummyContextObject.data(); - - QQmlComponent component(engine(), qmlFileInfo.filePath()); - m_dummyContextObject = component.create(); - - if (component.isError()) { - const QList<QQmlError> errors = component.errors(); - for (const QQmlError &error : errors) - qWarning() << error; - } - - if (m_dummyContextObject) { - qWarning() << "Loaded dummy context object:" << qmlFileInfo.filePath(); - m_dummyContextObject->setParent(this); - } - - if (!dummydataFileSystemWatcher()->files().contains(qmlFileInfo.filePath())) - dummydataFileSystemWatcher()->addPath(qmlFileInfo.filePath()); - - refreshBindings(); -} - -void NodeInstanceServer::setTranslationLanguage(const QString &language) -{ -#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - // if there exists an /i18n directory it sets default translators - engine()->setUiLanguage(language); -#endif - static QPointer<MultiLanguage::Translator> multilanguageTranslator; - if (!MultiLanguage::databaseFilePath().isEmpty() - && QFileInfo::exists(QString::fromUtf8(MultiLanguage::databaseFilePath()))) { - try { - if (!multilanguageLink) { - multilanguageLink = std::make_unique<MultiLanguage::Link>(); - multilanguageTranslator = multilanguageLink->translator().release(); - QCoreApplication::installTranslator(multilanguageTranslator); - } - if (multilanguageTranslator) - multilanguageTranslator->setLanguage(language); - } catch (std::exception &e) { - qWarning() << "QmlPuppet is unable to initialize MultiLanguage translator:" << e.what(); - } - } -} - -void NodeInstanceServer::loadDummyDataFiles(const QString &directory) -{ - QDir dir(directory, "*.qml"); - const QFileInfoList filePathList = dir.entryInfoList(); - for (const QFileInfo &qmlFileInfo : filePathList) - loadDummyDataFile(qmlFileInfo); -} - -void NodeInstanceServer::loadDummyDataContext(const QString &directory) -{ - QDir dir(directory + "/context", "*.qml"); - QString baseName = QFileInfo(fileUrl().toLocalFile()).completeBaseName(); - const QFileInfoList filePathList = dir.entryInfoList(); - for (const QFileInfo &qmlFileInfo : filePathList) { - if (qmlFileInfo.completeBaseName() == baseName) - loadDummyContextObjectFile(qmlFileInfo); - } -} - -void NodeInstanceServer::sendDebugOutput(DebugOutputCommand::Type type, const QString &message, - qint32 instanceId) -{ - QVector<qint32> ids; - ids.append(instanceId); - sendDebugOutput(type, message, ids); -} - -void NodeInstanceServer::sendDebugOutput(DebugOutputCommand::Type type, const QString &message, - const QVector<qint32> &instanceIds) -{ - DebugOutputCommand command(message, type, instanceIds); - nodeInstanceClient()->debugOutput(command); -} - -void NodeInstanceServer::removeInstanceRelationsipForDeletedObject(QObject *object, qint32 instanceId) -{ - if (m_objectInstanceHash.contains(object)) { - ServerNodeInstance instance = instanceForObject(object); - m_objectInstanceHash.remove(object); - - if (instanceId >= 0 && m_idInstances.size() > instanceId) - m_idInstances[instanceId] = {}; - } -} - -QStringList NodeInstanceServer::dummyDataDirectories(const QString &directoryPath) -{ - QStringList dummyDataDirectoryList; - QDir directory(directoryPath); - while (true) { - if (directory.isRoot() || !directory.exists()) - return dummyDataDirectoryList; - - if (directory.exists("dummydata")) - dummyDataDirectoryList.prepend(directory.absoluteFilePath("dummydata")); - - directory.cdUp(); - } -} - -void NodeInstanceServer::inputEvent([[maybe_unused]] const InputEventCommand &command) {} - -void NodeInstanceServer::view3DAction([[maybe_unused]] const View3DActionCommand &command) {} - -void NodeInstanceServer::requestModelNodePreviewImage( - [[maybe_unused]] const RequestModelNodePreviewImageCommand &command) -{ -} - -void NodeInstanceServer::changeLanguage(const ChangeLanguageCommand &command) -{ - setTranslationLanguage(command.language); - QEvent ev(QEvent::LanguageChange); - QCoreApplication::sendEvent(QCoreApplication::instance(), &ev); - engine()->retranslate(); -} - -void NodeInstanceServer::changePreviewImageSize(const ChangePreviewImageSizeCommand &) {} - -void NodeInstanceServer::incrementNeedsExtraRender() -{ - ++m_needsExtraRenderCount; -} - -void NodeInstanceServer::decrementNeedsExtraRender() -{ - --m_needsExtraRenderCount; -} - -void NodeInstanceServer::handleExtraRender() -{ - // If multipass is needed, render two additional times to ensure correct result - if (m_extraRenderCurrentPass == 0 && m_needsExtraRenderCount > 0) - m_extraRenderCurrentPass = 3; - - if (m_extraRenderCurrentPass > 0) { - --m_extraRenderCurrentPass; - if (m_extraRenderCurrentPass > 0) - startRenderTimer(); - } -} - -void NodeInstanceServer::disableTimer() -{ - m_timerMode = TimerMode::DisableTimer; -} - -void NodeInstanceServer::sheduleRootItemRender() -{ - QSharedPointer<QQuickItemGrabResult> result = m_rootNodeInstance.createGrabResult(); - qint32 instanceId = m_rootNodeInstance.instanceId(); - - if (result) { - connect(result.data(), &QQuickItemGrabResult::ready, [this, result, instanceId] { - QVector<ImageContainer> imageVector; - ImageContainer container(instanceId, result->image(), instanceId); - imageVector.append(container); - nodeInstanceClient()->pixmapChanged(PixmapChangedCommand(imageVector)); - }); - } -} - -void NodeInstanceServer::initializeAuxiliaryViews() -{ -} - -void NodeInstanceServer::handleInstanceLocked(const ServerNodeInstance &/*instance*/, bool /*enable*/, - bool /*checkAncestors*/) -{ -} - -void NodeInstanceServer::handleInstanceHidden(const ServerNodeInstance &/*instance*/, bool /*enable*/, - bool /*checkAncestors*/) -{ -} - -void NodeInstanceServer::handlePickTarget(const ServerNodeInstance &/*instance*/) -{ -} - -void NodeInstanceServer::setupState(qint32 stateInstanceId) -{ - if (hasInstanceForId(stateInstanceId)) { - if (activeStateInstance().isValid()) - activeStateInstance().deactivateState(); - ServerNodeInstance instance = instanceForId(stateInstanceId); - instance.activateState(); - } else { - if (activeStateInstance().isValid()) - activeStateInstance().deactivateState(); - } -} - -void NodeInstanceServer::registerFonts(const QUrl &resourceUrl) const -{ - if (!resourceUrl.isValid()) - return; - - // Autoregister all fonts found inside the project - QDirIterator it {QFileInfo(resourceUrl.toLocalFile()).absoluteFilePath(), - {"*.ttf", "*.otf"}, QDir::Files, QDirIterator::Subdirectories}; - while (it.hasNext()) - QFontDatabase::addApplicationFont(it.next()); -} - -bool NodeInstanceServer::isInformationServer() const -{ - return false; -} - -bool NodeInstanceServer::isPreviewServer() const -{ - return false; -} - -static QString baseProperty(const QString &property) -{ - int index = property.indexOf('.'); - if (index > 0) - return property.left(index); - return property; -} - -void NodeInstanceServer::addAnimation(QQuickAbstractAnimation *animation) -{ - if (!m_animations.contains(animation)) { - m_animations.push_back(animation); - - QQuickPropertyAnimation *panim = qobject_cast<QQuickPropertyAnimation *>(animation); - if (panim && panim->target()) { - QObject *target = panim->target(); - QString property = panim->property(); - QVariant value = target->property(qPrintable(baseProperty(property))); - m_defaultValues.push_back(value); - } else { - m_defaultValues.push_back({}); - } - } -} - -QVector<QQuickAbstractAnimation *> NodeInstanceServer::animations() const -{ - return m_animations; -} - -QVariant NodeInstanceServer::animationDefaultValue(int index) const -{ - return m_defaultValues.at(index); -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h deleted file mode 100644 index 59236a236f..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserver.h +++ /dev/null @@ -1,330 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QDebug> -#include <QUrl> -#include <QVector> -#include <QSet> -#include <QStringList> -#include <QPointer> -#include <QImage> - -#ifdef MULTILANGUAGE_TRANSLATIONPROVIDER -#include <multilanguagelink.h> -#endif - -#include <QTranslator> -#include <memory> - -#include <nodeinstanceserverinterface.h> -#include "servernodeinstance.h" -#include "debugoutputcommand.h" -#include "viewconfig.h" - -#include <private/qabstractanimation_p.h> -#include <private/qobject_p.h> -#include <private/qquickbehavior_p.h> -#include <private/qquicktext_p.h> -#include <private/qquicktextinput_p.h> -#include <private/qquicktextedit_p.h> -#include <private/qquicktransition_p.h> -#include <private/qquickloader_p.h> - -#include <private/qquickanimation_p.h> -#include <private/qqmlmetatype_p.h> -#include <private/qqmltimer_p.h> - -namespace QtHelpers { -template <class T> -QList<T>toList(const QSet<T> &set) -{ -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) - return set.toList(); -#else - return QList<T>(set.begin(), set.end()); -#endif -} -} // QtHelpers - -#ifndef MULTILANGUAGE_TRANSLATIONPROVIDER -namespace MultiLanguage { -inline QByteArray databaseFilePath() -{ - return {}; -} - -class Translator : public QTranslator -{ -public: - void setLanguage(const QString &) {} -}; - -class Link -{ -public: - Link() - { - if (qEnvironmentVariableIsSet("QT_MULTILANGUAGE_DATABASE")) - qWarning() << "QT_MULTILANGUAGE_DATABASE is set but QQmlDebugTranslationService is without MULTILANGUAGE_TRANSLATIONPROVIDER support compiled."; - } - std::unique_ptr<MultiLanguage::Translator> translator() { - //should never be called - Q_ASSERT(false); - return std::make_unique<MultiLanguage::Translator>(); - } - const bool isActivated = false; -}; -} // namespace MultiLanguage -#endif - -QT_BEGIN_NAMESPACE -class QFileSystemWatcher; -class QQmlView; -class QQuickView; -class QQuickWindow; -class QQmlEngine; -class QFileInfo; -class QQmlComponent; -QT_END_NAMESPACE - -namespace QmlDesigner { - -class NodeInstanceClientInterface; -class ValuesChangedCommand; -class ValuesModifiedCommand; -class PixmapChangedCommand; -class InformationChangedCommand; -class ChildrenChangedCommand; -class ReparentContainer; -class ComponentCompletedCommand; -class AddImportContainer; -class MockupTypeContainer; -class IdContainer; -class ChangeSelectionCommand; - -namespace Internal { - class ChildrenChangeEventFilter; -} - -enum class TimerMode { DisableTimer, NormalTimer, SlowTimer }; - -class NodeInstanceServer : public NodeInstanceServerInterface -{ - Q_OBJECT -public: - using ObjectPropertyPair = QPair<QPointer<QObject>, PropertyName>; - using IdPropertyPair = QPair<qint32, QString>; - using InstancePropertyPair= QPair<ServerNodeInstance, PropertyName>; - using DummyPair = QPair<QString, QPointer<QObject> >; - using InstancePropertyValueTriple = struct { - ServerNodeInstance instance; - PropertyName propertyName; - QVariant propertyValue; - }; - - explicit NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); - ~NodeInstanceServer() override; - - void createInstances(const CreateInstancesCommand &command) override; - void changeFileUrl(const ChangeFileUrlCommand &command) override; - void changePropertyValues(const ChangeValuesCommand &command) override; - void changePropertyBindings(const ChangeBindingsCommand &command) override; - void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) override; - void changeIds(const ChangeIdsCommand &command) override; - void createScene(const CreateSceneCommand &command) override; - void clearScene(const ClearSceneCommand &command) override; - void update3DViewState(const Update3dViewStateCommand &command) override; - void removeInstances(const RemoveInstancesCommand &command) override; - void removeProperties(const RemovePropertiesCommand &command) override; - void reparentInstances(const ReparentInstancesCommand &command) override; - void changeState(const ChangeStateCommand &command) override; - void completeComponent(const CompleteComponentCommand &command) override; - void changeNodeSource(const ChangeNodeSourceCommand &command) override; - void token(const TokenCommand &command) override; - void removeSharedMemory(const RemoveSharedMemoryCommand &command) override; - void changeSelection(const ChangeSelectionCommand &command) override; - void inputEvent(const InputEventCommand &command) override; - void view3DAction(const View3DActionCommand &command) override; - void requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command) override; - void changeLanguage(const ChangeLanguageCommand &command) override; - void changePreviewImageSize(const ChangePreviewImageSizeCommand &command) override; - - ServerNodeInstance instanceForId(qint32 id) const; - bool hasInstanceForId(qint32 id) const; - - ServerNodeInstance instanceForObject(QObject *object) const; - bool hasInstanceForObject(QObject *object) const; - - const QVector<ServerNodeInstance> &nodeInstances() const { return m_idInstances; } - - virtual QQmlEngine *engine() const = 0; - QQmlContext *context() const; - - void removeAllInstanceRelationships(); - - QFileSystemWatcher *fileSystemWatcher(); - QFileSystemWatcher *dummydataFileSystemWatcher(); - Internal::ChildrenChangeEventFilter *childrenChangeEventFilter() const; - void addFilePropertyToFileSystemWatcher(QObject *object, const PropertyName &propertyName, const QString &path); - void removeFilePropertyFromFileSystemWatcher(QObject *object, const PropertyName &propertyName, const QString &path); - - QUrl fileUrl() const; - - ServerNodeInstance activeStateInstance() const; - void setStateInstance(const ServerNodeInstance &stateInstance); - void clearStateInstance(); - - ServerNodeInstance rootNodeInstance() const; - - QList<ServerNodeInstance> allGroupStateInstances() const; - - void notifyPropertyChange(qint32 instanceid, const PropertyName &propertyName); - - QByteArray importCode() const; - QObject *dummyContextObject() const; - - virtual QQmlView *declarativeView() const = 0; - virtual QQuickView *quickView() const = 0; - virtual QQuickWindow *quickWindow() const = 0; - virtual QQuickItem *rootItem() const = 0; - virtual void setRootItem(QQuickItem *item) = 0; - - void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, qint32 instanceId = 0); - void sendDebugOutput(DebugOutputCommand::Type type, const QString &message, const QVector<qint32> &instanceIds); - - void removeInstanceRelationsipForDeletedObject(QObject *object, qint32 instanceId); - - void incrementNeedsExtraRender(); - void decrementNeedsExtraRender(); - void handleExtraRender(); - - void disableTimer(); - - virtual void collectItemChangesAndSendChangeCommands() = 0; - - virtual void handleInstanceLocked(const ServerNodeInstance &instance, bool enable, bool checkAncestors); - virtual void handleInstanceHidden(const ServerNodeInstance &instance, bool enable, bool checkAncestors); - virtual void handlePickTarget(const ServerNodeInstance &instance); - - virtual QImage grabWindow() = 0; - virtual QImage grabItem(QQuickItem *item) = 0; - virtual bool renderWindow() = 0; - - virtual bool isInformationServer() const; - virtual bool isPreviewServer() const; - void addAnimation(QQuickAbstractAnimation *animation); - QVector<QQuickAbstractAnimation *> animations() const; - QVariant animationDefaultValue(int index) const; - -public slots: - void refreshLocalFileProperty(const QString &path); - void refreshDummyData(const QString &path); - void emitParentChanged(QObject *child); - -protected: - virtual QList<ServerNodeInstance> createInstances(const QVector<InstanceContainer> &container); - void reparentInstances(const QVector<ReparentContainer> &containerVector); - - Internal::ChildrenChangeEventFilter *childrenChangeEventFilter(); - void resetInstanceProperty(const PropertyAbstractContainer &propertyContainer); - void setInstancePropertyBinding(const PropertyBindingContainer &bindingContainer); - void setInstancePropertyVariant(const PropertyValueContainer &valueContainer); - void setInstanceAuxiliaryData(const PropertyValueContainer &auxiliaryContainer); - void removeProperties(const QList<PropertyAbstractContainer> &propertyList); - - void insertInstanceRelationship(const ServerNodeInstance &instance); - void removeInstanceRelationsip(qint32 instanceId); - - NodeInstanceClientInterface *nodeInstanceClient() const; - - void timerEvent(QTimerEvent *) override; - - ValuesChangedCommand createValuesChangedCommand(const QList<ServerNodeInstance> &instanceList) const; - ValuesChangedCommand createValuesChangedCommand(const QVector<InstancePropertyPair> &propertyList) const; - ValuesModifiedCommand createValuesModifiedCommand(const QVector<InstancePropertyValueTriple> &propertyList) const; - PixmapChangedCommand createPixmapChangedCommand(const QList<ServerNodeInstance> &instanceList) const; - InformationChangedCommand createAllInformationChangedCommand(const QList<ServerNodeInstance> &instanceList, bool initial = false) const; - ChildrenChangedCommand createChildrenChangedCommand(const ServerNodeInstance &parentInstance, const QList<ServerNodeInstance> &instanceList) const; - ComponentCompletedCommand createComponentCompletedCommand(const QList<ServerNodeInstance> &instanceList); - ChangeSelectionCommand createChangeSelectionCommand(const QList<ServerNodeInstance> &instanceList); - - void sheduleRootItemRender(); - - void addChangedProperty(const InstancePropertyPair &property); - - virtual void startRenderTimer(); - void slowDownRenderTimer(); - void stopRenderTimer(); - void setRenderTimerInterval(int timerInterval); - int renderTimerInterval() const; - void setSlowRenderTimerInterval(int timerInterval); - - virtual void initializeView() = 0; - virtual void initializeAuxiliaryViews(); - virtual void setupScene(const CreateSceneCommand &command) = 0; - void setTranslationLanguage(const QString &language); - void loadDummyDataFiles(const QString &directory); - void loadDummyDataContext(const QString &directory); - void loadDummyDataFile(const QFileInfo &fileInfo); - void loadDummyContextObjectFile(const QFileInfo &fileInfo); - static QStringList dummyDataDirectories(const QString &directoryPath); - - void setTimerId(int timerId); - int timerId() const; - - QQmlContext *rootContext() const; - - - const QVector<InstancePropertyPair> changedPropertyList() const; - void clearChangedPropertyList(); - - virtual void refreshBindings() = 0; - - void setupDummysForContext(QQmlContext *context); - - void setupMockupTypes(const QVector<MockupTypeContainer> &container); - void setupFileUrl(const QUrl &fileUrl); - void setupImports(const QVector<AddImportContainer> &container); - void setupDummyData(const QUrl &fileUrl); - void setupDefaultDummyData(); - QList<ServerNodeInstance> setupInstances(const CreateSceneCommand &command); - - QList<QQmlContext*> allSubContextsForObject(QObject *object); - static QList<QObject*> allSubObjectsForObject(QObject *object); - - virtual void resizeCanvasToRootItem() = 0; - void setupState(qint32 stateInstanceId); - void registerFonts(const QUrl &resourceUrl) const; - -private: - void setupOnlyWorkingImports(const QStringList &workingImportStatementList); - ServerNodeInstance m_rootNodeInstance; - ServerNodeInstance m_activeStateInstance; - QVector<ServerNodeInstance> m_idInstances; - QHash<QObject*, ServerNodeInstance> m_objectInstanceHash; - QMultiHash<QString, ObjectPropertyPair> m_fileSystemWatcherHash; - QList<QPair<QString, QPointer<QObject> > > m_dummyObjectList; - QPointer<QFileSystemWatcher> m_fileSystemWatcher; - QPointer<QFileSystemWatcher> m_dummdataFileSystemWatcher; - QPointer<Internal::ChildrenChangeEventFilter> m_childrenChangeEventFilter; - QUrl m_fileUrl; - NodeInstanceClientInterface *m_nodeInstanceClient; - int m_timer = 0; - int m_renderTimerInterval = 16; - TimerMode m_timerMode = TimerMode::NormalTimer; - int m_timerModeInterval = 200; - QVector<InstancePropertyPair> m_changedPropertyList; - QByteArray m_importCode; - QPointer<QObject> m_dummyContextObject; - QPointer<QQmlComponent> m_importComponent; - QPointer<QObject> m_importComponentObject; - std::unique_ptr<MultiLanguage::Link> multilanguageLink; - int m_needsExtraRenderCount = 0; - int m_extraRenderCurrentPass = 0; - QVector<QQuickAbstractAnimation *> m_animations; - QVector<QVariant> m_defaultValues; -}; - -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.cpp deleted file mode 100644 index 8a78b79cce..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.cpp +++ /dev/null @@ -1,189 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "nodeinstanceserverdispatcher.h" - -#include "qt5captureimagenodeinstanceserver.h" -#include "qt5capturepreviewnodeinstanceserver.h" -#include "qt5informationnodeinstanceserver.h" -#include "qt5rendernodeinstanceserver.h" - -namespace QmlDesigner { - -NodeInstanceServerDispatcher::NodeInstanceServerDispatcher(const QStringList &serverNames, - NodeInstanceClientInterface *nodeInstanceClient) -{ - for (const QString &serverName : serverNames) - addServer(serverName, nodeInstanceClient); -} - -void NodeInstanceServerDispatcher::createInstances(const CreateInstancesCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->createInstances(command); -} - -void NodeInstanceServerDispatcher::changeFileUrl(const ChangeFileUrlCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changeFileUrl(command); -} - -void NodeInstanceServerDispatcher::createScene(const CreateSceneCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->createScene(command); -} - -void NodeInstanceServerDispatcher::clearScene(const ClearSceneCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->clearScene(command); -} - -void NodeInstanceServerDispatcher::update3DViewState(const Update3dViewStateCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->update3DViewState(command); -} - -void NodeInstanceServerDispatcher::removeInstances(const RemoveInstancesCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->removeInstances(command); -} - -void NodeInstanceServerDispatcher::removeProperties(const RemovePropertiesCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->removeProperties(command); -} - -void NodeInstanceServerDispatcher::changePropertyBindings(const ChangeBindingsCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changePropertyBindings(command); -} - -void NodeInstanceServerDispatcher::changePropertyValues(const ChangeValuesCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changePropertyValues(command); -} - -void NodeInstanceServerDispatcher::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changeAuxiliaryValues(command); -} - -void NodeInstanceServerDispatcher::reparentInstances(const ReparentInstancesCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->reparentInstances(command); -} - -void NodeInstanceServerDispatcher::changeIds(const ChangeIdsCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changeIds(command); -} - -void NodeInstanceServerDispatcher::changeState(const ChangeStateCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changeState(command); -} - -void NodeInstanceServerDispatcher::completeComponent(const CompleteComponentCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->completeComponent(command); -} - -void NodeInstanceServerDispatcher::changeNodeSource(const ChangeNodeSourceCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changeNodeSource(command); -} - -void NodeInstanceServerDispatcher::token(const TokenCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->token(command); -} - -void NodeInstanceServerDispatcher::removeSharedMemory(const RemoveSharedMemoryCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->removeSharedMemory(command); -} - -void NodeInstanceServerDispatcher::changeSelection(const ChangeSelectionCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changeSelection(command); -} - -void NodeInstanceServerDispatcher::inputEvent(const InputEventCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->inputEvent(command); -} - -void NodeInstanceServerDispatcher::view3DAction(const View3DActionCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->view3DAction(command); -} - -void NodeInstanceServerDispatcher::requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->requestModelNodePreviewImage(command); -} - -void NodeInstanceServerDispatcher::changeLanguage(const ChangeLanguageCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changeLanguage(command); -} - -void NodeInstanceServerDispatcher::changePreviewImageSize(const ChangePreviewImageSizeCommand &command) -{ - for (std::unique_ptr<NodeInstanceServer> &server : m_servers) - server->changePreviewImageSize(command); -} - -namespace { - -std::unique_ptr<NodeInstanceServer> createNodeInstanceServer( - const QString &serverName, NodeInstanceClientInterface *nodeInstanceClient) -{ - if (serverName == "capturemode") - return std::make_unique<Qt5CapturePreviewNodeInstanceServer>(nodeInstanceClient); - else if (serverName == "captureiconmode") - return std::make_unique<Qt5CaptureImageNodeInstanceServer>(nodeInstanceClient); - else if (serverName == "rendermode") - return std::make_unique<Qt5RenderNodeInstanceServer>(nodeInstanceClient); - else if (serverName == "editormode") - return std::make_unique<Qt5InformationNodeInstanceServer>(nodeInstanceClient); - else if (serverName == "previewmode") - return std::make_unique<Qt5PreviewNodeInstanceServer>(nodeInstanceClient); - - return {}; -} - -} // namespace - -void NodeInstanceServerDispatcher::addServer(const QString &serverName, - NodeInstanceClientInterface *nodeInstanceClient) -{ - auto server = createNodeInstanceServer(serverName, nodeInstanceClient); - - server->disableTimer(); - - m_servers.push_back(std::move(server)); -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.h deleted file mode 100644 index a691858c30..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstanceserverdispatcher.h +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <nodeinstanceserver.h> - -#include <memory> -#include <vector> - -namespace QmlDesigner { - -class NodeInstanceServerDispatcher : public NodeInstanceServerInterface -{ -public: - NodeInstanceServerDispatcher(const QStringList &serverNames, - NodeInstanceClientInterface *nodeInstanceClient); - - void createInstances(const CreateInstancesCommand &command); - void changeFileUrl(const ChangeFileUrlCommand &command); - void createScene(const CreateSceneCommand &command); - void clearScene(const ClearSceneCommand &command); - void update3DViewState(const Update3dViewStateCommand &command); - void removeInstances(const RemoveInstancesCommand &command); - void removeProperties(const RemovePropertiesCommand &command); - void changePropertyBindings(const ChangeBindingsCommand &command); - void changePropertyValues(const ChangeValuesCommand &command); - void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command); - void reparentInstances(const ReparentInstancesCommand &command); - void changeIds(const ChangeIdsCommand &command); - void changeState(const ChangeStateCommand &command); - void completeComponent(const CompleteComponentCommand &command); - void changeNodeSource(const ChangeNodeSourceCommand &command); - void token(const TokenCommand &command); - void removeSharedMemory(const RemoveSharedMemoryCommand &command); - void changeSelection(const ChangeSelectionCommand &command); - void inputEvent(const InputEventCommand &command); - void view3DAction(const View3DActionCommand &command); - void requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command); - void changeLanguage(const ChangeLanguageCommand &command); - void changePreviewImageSize(const ChangePreviewImageSizeCommand &command); - -private: - void addServer(const QString &serverName, NodeInstanceClientInterface *nodeInstanceClient); - -protected: - std::vector<std::unique_ptr<NodeInstanceServer>> m_servers; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstancesignalspy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstancesignalspy.cpp deleted file mode 100644 index 6688c809d5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstancesignalspy.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "nodeinstancesignalspy.h" -#include "objectnodeinstance.h" - -#include <qmlprivategate.h> - -#include <QMetaProperty> -#include <QMetaObject> -#include <QDebug> -#include <QSharedPointer> - -#include <QQmlProperty> - -namespace QmlDesigner { -namespace Internal { - -NodeInstanceSignalSpy::NodeInstanceSignalSpy() : - QObject() -{ - blockSignals(true); -} - -void NodeInstanceSignalSpy::setObjectNodeInstance(const ObjectNodeInstance::Pointer &nodeInstance) -{ - methodeOffset = QObject::staticMetaObject.methodCount() + 1; - registerObject(nodeInstance->object()); - m_objectNodeInstance = nodeInstance; - -} - -void NodeInstanceSignalSpy::registerObject(QObject *spiedObject) -{ - if (m_registeredObjectList.contains(spiedObject)) // prevent cycles - return; - - m_registeredObjectList.append(spiedObject); - for (int index = QObject::staticMetaObject.propertyOffset(); - index < spiedObject->metaObject()->propertyCount(); - index++) { - QMetaProperty metaProperty = spiedObject->metaObject()->property(index); - - registerProperty(metaProperty, spiedObject); - registerChildObject(metaProperty, spiedObject); - } -} - -void NodeInstanceSignalSpy::registerProperty(const QMetaProperty &metaProperty, QObject *spiedObject, const PropertyName &propertyPrefix) -{ - if (metaProperty.isReadable() - && metaProperty.isWritable() - && !QmlPrivateGate::isPropertyQObject(metaProperty) - && metaProperty.hasNotifySignal()) { - QMetaMethod metaMethod = metaProperty.notifySignal(); - QMetaObject::connect(spiedObject, metaMethod.methodIndex(), this, methodeOffset, Qt::DirectConnection); - - m_indexPropertyHash.insert(methodeOffset, propertyPrefix + PropertyName(metaProperty.name())); - - - methodeOffset++; - } -} - -void NodeInstanceSignalSpy::registerChildObject(const QMetaProperty &metaProperty, QObject *spiedObject) -{ - if (metaProperty.isReadable() - && !metaProperty.isWritable() - && QmlPrivateGate::isPropertyQObject(metaProperty) - && QLatin1String(metaProperty.name()) != QLatin1String("parent")) { - QObject *childObject = QmlPrivateGate::readQObjectProperty(metaProperty, spiedObject); - - if (childObject) { - for (int index = QObject::staticMetaObject.propertyOffset(); - index < childObject->metaObject()->propertyCount(); - index++) { - QMetaProperty childMetaProperty = childObject->metaObject()->property(index); - registerProperty(childMetaProperty, childObject, PropertyName(metaProperty.name()) + '.'); - } - } - } -} - -int NodeInstanceSignalSpy::qt_metacall(QMetaObject::Call call, int methodId, void **a) -{ - if (call == QMetaObject::InvokeMetaMethod && methodId > QObject::staticMetaObject.methodCount()) { - ObjectNodeInstance::Pointer nodeInstance = m_objectNodeInstance.toStrongRef(); - - if (nodeInstance && nodeInstance->nodeInstanceServer() && nodeInstance->isValid()) { - foreach (const PropertyName &propertyName, m_indexPropertyHash.values(methodId)) - nodeInstance->nodeInstanceServer()->notifyPropertyChange(nodeInstance->instanceId(), propertyName); - } - - } - - return QObject::qt_metacall(call, methodId, a); -} - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstancesignalspy.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstancesignalspy.h deleted file mode 100644 index 6691da10fb..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/nodeinstancesignalspy.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QObject> -#include <QHash> -#include <QSharedPointer> - -#include "nodeinstanceglobal.h" - -namespace QmlDesigner { - -namespace Internal { - -class ObjectNodeInstance; - -using ObjectNodeInstancePointer = QSharedPointer<ObjectNodeInstance>; -using ObjectNodeInstanceWeakPointer = QWeakPointer<ObjectNodeInstance>; - -class NodeInstanceSignalSpy : public QObject -{ -public: - explicit NodeInstanceSignalSpy(); - - void setObjectNodeInstance(const ObjectNodeInstancePointer &nodeInstance); - - int qt_metacall(QMetaObject::Call, int, void **) override; - -protected: - void registerObject(QObject *spiedObject); - void registerProperty(const QMetaProperty &metaProperty, QObject *spiedObject, const PropertyName &propertyPrefix = PropertyName()); - void registerChildObject(const QMetaProperty &metaProperty, QObject *spiedObject); - -private: - int methodeOffset; - QMultiHash<int, PropertyName> m_indexPropertyHash; - QObjectList m_registeredObjectList; - ObjectNodeInstanceWeakPointer m_objectNodeInstance; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp deleted file mode 100644 index fe51d7ecc7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp +++ /dev/null @@ -1,1047 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "objectnodeinstance.h" - -#include <enumeration.h> -#include <qmlprivategate.h> - -#include <QDebug> -#include <QEvent> -#include <QQmlContext> -#include <QQmlError> -#include <QQmlEngine> -#include <QQmlProperty> -#include <QQmlComponent> -#include <QSharedPointer> -#include <QFileInfo> -#include <QFileSystemWatcher> -#include <QPixmapCache> -#include <QQuickItem> -#include <QQmlExpression> -#include <QQmlParserStatus> -#include <QTextDocument> -#include <QLibraryInfo> -#include <QJSValue> - -#include <private/qquickstategroup_p.h> - -#include <qquickitem.h> - -static bool isSimpleExpression(const QString &expression) -{ - if (expression.startsWith(QStringLiteral("{"))) - return false; - - return true; -} - -namespace QmlDesigner { -namespace Internal { - -ObjectNodeInstance::ObjectNodeInstance(QObject *object) - : m_object(object), - m_instanceId(-1), - m_deleteHeldInstance(true), - m_isInLayoutable(false) -{ - if (object) - QObject::connect(m_object.data(), &QObject::destroyed, [=] { - handleObjectDeletion(object); - }); -} - -ObjectNodeInstance::~ObjectNodeInstance() -{ - destroy(); -} - -void ObjectNodeInstance::destroy() -{ - if (deleteHeldInstance()) { - // Remove from old property - if (object()) { - setId(QString()); - if (m_instanceId >= 0) { - reparent(parentInstance(), m_parentProperty, ObjectNodeInstance::Pointer(), PropertyName()); - } - } - - if (object()) { - QObject *obj = object(); - m_object.clear(); - delete obj; - } - } - - m_instanceId = -1; -} - -void ObjectNodeInstance::handleObjectDeletion(QObject *object) -{ - // We must pass the m_instanceId here, because this instance is no longer - // valid, so the wrapper ServerNodeInstance will report -1 for id. - if (m_nodeInstanceServer) - m_nodeInstanceServer->removeInstanceRelationsipForDeletedObject(object, m_instanceId); -} - -void ObjectNodeInstance::setInstanceId(qint32 id) -{ - m_instanceId = id; -} - -qint32 ObjectNodeInstance::instanceId() const -{ - return m_instanceId; -} - -NodeInstanceServer *ObjectNodeInstance::nodeInstanceServer() const -{ - return m_nodeInstanceServer.data(); -} - -void ObjectNodeInstance::setNodeInstanceServer(NodeInstanceServer *server) -{ - Q_ASSERT(!m_nodeInstanceServer.data()); - - m_nodeInstanceServer = server; -} - -void ObjectNodeInstance::initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance) -{ - m_signalSpy.setObjectNodeInstance(objectNodeInstance); -} - -void ObjectNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance, - InstanceContainer::NodeFlags /*flags*/) -{ - initializePropertyWatcher(objectNodeInstance); - QmlPrivateGate::registerNodeInstanceMetaObject(objectNodeInstance->object(), objectNodeInstance->nodeInstanceServer()->engine()); -} - -void ObjectNodeInstance::setId(const QString &id) -{ - if (!m_id.isEmpty() && context()) { - context()->engine()->rootContext()->setContextProperty(m_id, nullptr); - } - - if (!id.isEmpty() && context()) { - context()->engine()->rootContext()->setContextProperty(id, object()); // will also force refresh of all bindings - } - - m_id = id; -} - -QString ObjectNodeInstance::id() const -{ - return m_id; -} - -bool ObjectNodeInstance::isTransition() const -{ - return false; -} - -bool ObjectNodeInstance::isPositioner() const -{ - return false; -} - -bool ObjectNodeInstance::isQuickItem() const -{ - return false; -} - -bool ObjectNodeInstance::isQuickWindow() const -{ - return false; -} - -bool ObjectNodeInstance::isLayoutable() const -{ - return false; -} - -bool ObjectNodeInstance::isRenderable() const -{ - return false; -} - -bool ObjectNodeInstance::equalGraphicsItem(QGraphicsItem * /*item*/) const -{ - return false; -} - -QTransform ObjectNodeInstance::transform() const -{ - return QTransform(); -} - -QTransform ObjectNodeInstance::contentTransform() const -{ - return QTransform(); -} - -QTransform ObjectNodeInstance::customTransform() const -{ - return QTransform(); -} - -QTransform ObjectNodeInstance::contentItemTransform() const -{ - return QTransform(); -} - -QTransform ObjectNodeInstance::sceneTransform() const -{ - return QTransform(); -} - -double ObjectNodeInstance::rotation() const -{ - return 0.0; -} - -double ObjectNodeInstance::scale() const -{ - return 1.0; -} - -QList<QGraphicsTransform *> ObjectNodeInstance::transformations() const -{ - QList<QGraphicsTransform *> transformationsList; - - return transformationsList; -} - -QPointF ObjectNodeInstance::transformOriginPoint() const -{ - return QPoint(); -} - -double ObjectNodeInstance::zValue() const -{ - return 0.0; -} - -double ObjectNodeInstance::opacity() const -{ - return 1.0; -} - -bool ObjectNodeInstance::hasAnchor(const PropertyName &/*name*/) const -{ - return false; -} - -bool ObjectNodeInstance::isAnchoredBySibling() const -{ - return false; -} - -bool ObjectNodeInstance::isAnchoredByChildren() const -{ - return false; -} - -QPair<PropertyName, ServerNodeInstance> ObjectNodeInstance::anchor(const PropertyName &/*name*/) const -{ - return {PropertyName(), ServerNodeInstance()}; -} - - -static bool isList(const QQmlProperty &property) -{ - return property.propertyTypeCategory() == QQmlProperty::List; -} - -static bool isQJSValue(const QQmlProperty &property) -{ - return property.isValid() && !strcmp(property.propertyTypeName(), "QJSValue"); -} - -static bool isObject(const QQmlProperty &property) -{ - /* QVariant and QJSValue can also store QObjects. Lets trust our model. */ - return property.isValid() && (property.propertyTypeCategory() == QQmlProperty::Object - || !strcmp(property.propertyTypeName(), "QVariant") - || isQJSValue(property)); -} - -static QVariant objectToVariant(QObject *object) -{ - return QVariant::fromValue(object); -} - -static void removeObjectFromList(const QQmlProperty &property, QObject *objectToBeRemoved, QQmlEngine * engine) -{ - QQmlListReference listReference(property.object(), property.name().toUtf8(), engine); - - if (!QmlPrivateGate::hasFullImplementedListInterface(listReference)) { - qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!"; - return; - } - - int count = listReference.count(); - - QObjectList objectList; - - for (int i = 0; i < count; i ++) { - QObject *listItem = listReference.at(i); - if (listItem && listItem != objectToBeRemoved) - objectList.append(listItem); - } - - listReference.clear(); - - foreach (QObject *object, objectList) - listReference.append(object); -} - -void ObjectNodeInstance::removeFromOldProperty(QObject *object, QObject *oldParent, const PropertyName &oldParentProperty) -{ - QQmlProperty property(oldParent, QString::fromUtf8(oldParentProperty), context()); - - if (!property.isValid()) - return; - - if (isList(property)) { - removeObjectFromList(property, object, nodeInstanceServer()->engine()); - } else if (isObject(property)) { - if (nodeInstanceServer()->hasInstanceForObject(oldParent)) { - nodeInstanceServer()->instanceForObject(oldParent).resetProperty(oldParentProperty); - } - } - - if (object && object->parent()) - object->setParent(nullptr); -} - -void ObjectNodeInstance::addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty) -{ - QQmlProperty property(newParent, QString::fromUtf8(newParentProperty), context()); - - if (object) - object->setParent(newParent); - - if (isList(property)) { - QQmlListReference list = qvariant_cast<QQmlListReference>(property.read()); - - if (!QmlPrivateGate::hasFullImplementedListInterface(list)) { - qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!"; - return; - } - - list.append(object); - } else if (isObject(property)) { - if (isQJSValue(property)) /* In this case we have to explcitly generate and convert a QJSValue */ - property.write(QVariant::fromValue(engine()->newQObject(object))); - else - property.write(objectToVariant(object)); - - if (QQuickItem *item = qobject_cast<QQuickItem *>(object)) - if (QQuickItem *newParentItem = qobject_cast<QQuickItem *>(newParent)) - item->setParentItem(newParentItem); - } - - Q_ASSERT(objectToVariant(object).isValid()); -} - -void ObjectNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) -{ - if (oldParentInstance && !oldParentInstance->ignoredProperties().contains(oldParentProperty)) { - removeFromOldProperty(object(), oldParentInstance->object(), oldParentProperty); - m_parentProperty.clear(); - } - - if (newParentInstance && !newParentInstance->ignoredProperties().contains(newParentProperty)) { - m_parentProperty = newParentProperty; - addToNewProperty(object(), newParentInstance->object(), newParentProperty); - } -} - -QVariant ObjectNodeInstance::convertSpecialCharacter(const QVariant& value) const -{ - QVariant specialCharacterConvertedValue = value; - if (value.type() == QVariant::String) { - QString string = value.toString(); - string.replace(QLatin1String("\\n"), QLatin1String("\n")); - string.replace(QLatin1String("\\t"), QLatin1String("\t")); - specialCharacterConvertedValue = string; - } - - return specialCharacterConvertedValue; -} - -void ObjectNodeInstance::updateAllDirtyNodesRecursive() -{ -} - -PropertyNameList ObjectNodeInstance::ignoredProperties() const -{ - return PropertyNameList(); -} - -void ObjectNodeInstance::setHiddenInEditor(bool b) -{ - m_isHiddenInEditor = b; -} - -bool ObjectNodeInstance::isHiddenInEditor() const -{ - return m_isHiddenInEditor; -} - -void ObjectNodeInstance::setLockedInEditor(bool b) -{ - m_isLockedInEditor = b; -} - -bool ObjectNodeInstance::isLockedInEditor() const -{ - return m_isLockedInEditor; -} - -bool ObjectNodeInstance::isComponentWrap() const -{ - return m_isComponentWrap; -} - -void ObjectNodeInstance::setComponentWrap(bool wrap) -{ - m_isComponentWrap = wrap; -} - -void ObjectNodeInstance::setModifiedFlag(bool b) -{ - m_isModified = b; -} - -QVariant ObjectNodeInstance::convertEnumToValue(const QVariant &value, const PropertyName &name) -{ - Q_ASSERT(value.canConvert<Enumeration>()); - int propertyIndex = object()->metaObject()->indexOfProperty(name); - QMetaProperty metaProperty = object()->metaObject()->property(propertyIndex); - - QVariant adjustedValue; - Enumeration enumeration = value.value<Enumeration>(); - if (metaProperty.isValid() && metaProperty.isEnumType()) { - adjustedValue = metaProperty.enumerator().keyToValue(enumeration.name()); - } else { - QQmlExpression expression(context(), object(), enumeration.toString()); - adjustedValue = expression.evaluate(); - if (expression.hasError()) - qDebug() << "Enumeration cannot be evaluated:" << object() << name << enumeration; - } - return adjustedValue; -} - -void ObjectNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (name == "state" && object() && object()->metaObject() - && object()->metaObject()->className() == QByteArrayLiteral("QQuickStateGroup")) - return; - - if (ignoredProperties().contains(name)) - return; - - if (m_isModified) - return; - - QQmlProperty property(object(), QString::fromUtf8(name), context()); - - if (!property.isValid()) - return; - - QVariant adjustedValue; - if (value.canConvert<Enumeration>()) - adjustedValue = convertEnumToValue(value, name); - else - adjustedValue = QmlPrivateGate::fixResourcePaths(value); - - - QVariant oldValue = property.read(); - if (oldValue.type() == QVariant::Url) { - QUrl url = oldValue.toUrl(); - QString path = url.toLocalFile(); - if (QFileInfo::exists(path) && nodeInstanceServer() && !path.isEmpty()) - nodeInstanceServer()->removeFilePropertyFromFileSystemWatcher(object(), name, path); - } - - if (hasValidResetBinding(name)) { - QmlPrivateGate::keepBindingFromGettingDeleted(object(), context(), name); - } - - bool isWritten = property.write(convertSpecialCharacter(adjustedValue)); - - if (!isWritten) - qDebug() << "ObjectNodeInstance.setPropertyVariant: Cannot be written: " << object() << name << adjustedValue; - - QVariant newValue = property.read(); - if (newValue.type() == QVariant::Url) { - QUrl url = newValue.toUrl(); - QString path = url.toLocalFile(); - if (QFileInfo::exists(path) && nodeInstanceServer() && !path.isEmpty()) - nodeInstanceServer()->addFilePropertyToFileSystemWatcher(object(), name, path); - } -} - -void ObjectNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - if (ignoredProperties().contains(name)) - return; - - if (!isSimpleExpression(expression)) - return; - - QmlPrivateGate::setPropertyBinding(object(), context(), name, expression); -} - -void ObjectNodeInstance::deleteObjectsInList(const QQmlProperty &property) -{ - QObjectList objectList; - QQmlListReference list = qvariant_cast<QQmlListReference>(property.read()); - - if (!QmlPrivateGate::hasFullImplementedListInterface(list)) { - qWarning() << "Property list interface not fully implemented for Class " << property.property().typeName() << " in property " << property.name() << "!"; - return; - } - - for (int i = 0; i < list.count(); i++) { - objectList += list.at(i); - } - - list.clear(); -} - -void ObjectNodeInstance::resetProperty(const PropertyName &name) -{ - if (ignoredProperties().contains(name)) - return; - - doResetProperty(name); - - if (name == "font.pixelSize") - doResetProperty("font.pointSize"); - - if (name == "font.pointSize") - doResetProperty("font.pixelSize"); -} - -void ObjectNodeInstance::refreshProperty(const PropertyName &name) -{ - QQmlProperty property(object(), QString::fromUtf8(name), context()); - - if (!property.isValid()) - return; - - QVariant oldValue(property.read()); - - if (property.isResettable()) - property.reset(); - else - property.write(resetValue(name)); - - if (oldValue.type() == QVariant::Url) { - QByteArray key = oldValue.toUrl().toEncoded(QUrl::UrlFormattingOption(0x100)); - QString pixmapKey = QString::fromUtf8(key.constData(), key.count()); - QPixmapCache::remove(pixmapKey); - } - - property.write(oldValue); -} - -bool ObjectNodeInstance::hasBindingForProperty(const PropertyName &propertyName, bool *hasChanged) const -{ - return QmlPrivateGate::hasBindingForProperty(object(), context(), propertyName, hasChanged); -} - -void ObjectNodeInstance::doResetProperty(const PropertyName &propertyName) -{ - QmlPrivateGate::doResetProperty(object(), context(), propertyName); -} - -QVariant ObjectNodeInstance::property(const PropertyName &name) const -{ - if (ignoredProperties().contains(name)) - return QVariant(); - - // TODO: handle model nodes - - if (QmlPrivateGate::isPropertyBlackListed(name)) - return QVariant(); - - QQmlProperty property(object(), QString::fromUtf8(name), context()); - if (property.property().isEnumType()) { - QVariant value = property.read(); - return property.property().enumerator().valueToKey(value.toInt()); - } - - if (property.propertyType() == QVariant::Url) { - QUrl url = property.read().toUrl(); - if (url.isEmpty()) - return QVariant(); - - if (url.scheme() == "file") { - int basePathLength = nodeInstanceServer()->fileUrl().toLocalFile().lastIndexOf('/'); - return QUrl(url.toLocalFile().mid(basePathLength + 1)); - } - } - - return property.read(); -} - -void ObjectNodeInstance::ensureVector3DDotProperties(PropertyNameList &list) const -{ - const PropertyNameList properties = { "rotation", "scale", "pivot" }; - for (const auto &property : properties) { - if (list.contains(property) && instanceType(property) == "QVector3D") { - const PropertyNameList dotProperties = { "x", "y", "z" }; - for (const auto &dotProperty : dotProperties) { - const PropertyName dotPropertyName = property + "." + dotProperty; - if (!list.contains(dotPropertyName)) - list.append(dotPropertyName); - } - } - } -} - -PropertyNameList ObjectNodeInstance::propertyNames() const -{ - PropertyNameList list; - if (isValid()) - list = QmlPrivateGate::allPropertyNames(object()); - - ensureVector3DDotProperties(list); - - return list; -} - -QString ObjectNodeInstance::instanceType(const PropertyName &name) const -{ - if (QmlPrivateGate::isPropertyBlackListed(name)) - return QLatin1String("undefined"); - - QQmlProperty property(object(), QString::fromUtf8(name), context()); - if (!property.isValid()) - return QLatin1String("undefined"); - return QString::fromUtf8(property.propertyTypeName()); -} - -QList<ServerNodeInstance> ObjectNodeInstance::childItems() const -{ - return QList<ServerNodeInstance>(); -} - -QList<QQuickItem *> ObjectNodeInstance::allItemsRecursive() const -{ - return QList<QQuickItem *>(); -} - -QList<ServerNodeInstance> ObjectNodeInstance::stateInstances() const -{ - if (auto group = qobject_cast<QQuickStateGroup*>(object())) { - QList<ServerNodeInstance> instanceList; - const QList<QQuickState *> stateList = group->states(); - for (QQuickState *state : stateList) { - if (state && nodeInstanceServer()->hasInstanceForObject(state)) - instanceList.append(nodeInstanceServer()->instanceForObject(state)); - } - return instanceList; - } - - return QList<ServerNodeInstance>(); -} - -void ObjectNodeInstance::setNodeSource(const QString & /*source*/) -{ -} - -void ObjectNodeInstance::setDeleteHeldInstance(bool deleteInstance) -{ - m_deleteHeldInstance = deleteInstance; -} - -bool ObjectNodeInstance::deleteHeldInstance() const -{ - return m_deleteHeldInstance; -} - -ObjectNodeInstance::Pointer ObjectNodeInstance::create(QObject *object) -{ - Pointer instance(new ObjectNodeInstance(object)); - - instance->populateResetHashes(); - - return instance; -} - -QObject *ObjectNodeInstance::createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context) -{ - QString polishTypeName = typeName; - if (typeName == "QtQuick.Controls/Popup" || typeName == "QtQuick.Controls/Drawer" - || typeName == "QtQuick.Controls/Dialog" || typeName == "QtQuick.Controls/Menu" - || typeName == "QtQuick.Controls/ToolTip" - || typeName == "QtQuick.Controls/ApplicationWindow") - polishTypeName = "QtQuick/Item"; - - const QHash<QString, QString> mockHash = {{"QtQuick.Controls/SwipeView","qrc:/qtquickplugin/mockfiles/SwipeView.qml"}, - {"QtQuick.Dialogs/Dialog","qrc:/qtquickplugin/mockfiles/Dialog.qml"}}; - - QObject *object = nullptr; - - if (mockHash.contains(typeName)) - object = QmlPrivateGate::createComponent(mockHash.value(typeName), context); - else if (majorNumber != -1 && minorNumber != -1) - object = QmlPrivateGate::createPrimitive(polishTypeName, majorNumber, minorNumber, context); - else - object = QmlPrivateGate::createPrimitive(polishTypeName, 0, 0, context); - - /* Let's try to create the primitive from source, since with incomplete meta info this might be a pure - * QML type. This is the case for example if a C++ type is mocked up with a QML file. - */ - - if (!object && majorNumber == 6 && minorNumber == 0) { - object = QmlPrivateGate::createPrimitive(polishTypeName, 2, 15, context); - if (!object) - object = QmlPrivateGate::createPrimitive(polishTypeName, 1, 0, context); - } - - if (!object) - object = createPrimitiveFromSource(polishTypeName, majorNumber, minorNumber, context); - - return object; -} - -QObject *ObjectNodeInstance::createPrimitiveFromSource(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context) -{ - if (typeName.isEmpty()) - return nullptr; - - QStringList parts = typeName.split("/"); - const QString unqualifiedTypeName = parts.last(); - parts.removeLast(); - - if (parts.isEmpty()) - return nullptr; - - QString importString = parts.join("."); - if (majorNumber >= 0) - importString = importString + " " + QString::number(majorNumber) + "." - + QString::number(minorNumber); - if (importString == "QtQuick 1.0") /* Workaround for implicit QQml import */ - importString = "QtQuick 2.0"; - QString source = "import " + importString + "\n" + unqualifiedTypeName + " {\n" + "}\n"; - return createCustomParserObject(source, "", context); -} - -QObject *ObjectNodeInstance::createComponentWrap(const QString &nodeSource, const QByteArray &importCode, QQmlContext *context) -{ - [[maybe_unused]] QmlPrivateGate::ComponentCompleteDisabler disableComponentComplete; - - QQmlComponent *component = new QQmlComponent(context->engine()); - - QByteArray data(nodeSource.toUtf8()); - if (data.isEmpty()) { - // Add a fake root element as an empty component is not valid and crashes in some cases - data.append("QtObject{}"); - } - data.prepend(importCode); - component->setData(data, context->baseUrl().resolved(QUrl("createComponent.qml"))); - QObject *object = component; - QmlPrivateGate::tweakObjects(object); - QQmlEngine::setContextForObject(object, context); - QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); - - if (component->isError()) { - qWarning() << "Error in:" << Q_FUNC_INFO << component->url().toString(); - foreach (const QQmlError &error, component->errors()) - qWarning() << error; - qWarning() << "file data:\n" << data; - } - return object; -} - -//The component might also be shipped with Creator. -//To avoid trouble with import "." we use the component shipped with Creator. -static inline QString fixComponentPathForIncompatibleQt(const QString &componentPath) -{ - QString result = componentPath; - const QLatin1String importString("/imports/"); - - if (componentPath.contains(importString)) { - int index = componentPath.indexOf(importString) + 8; - const QString relativeImportPath = componentPath.right(componentPath.length() - index); - QString fixedComponentPath = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath) + relativeImportPath; - fixedComponentPath.replace(QLatin1Char('\\'), QLatin1Char('/')); - if (QFileInfo::exists(fixedComponentPath)) - return fixedComponentPath; - QString fixedPath = QFileInfo(fixedComponentPath).path(); - if (fixedPath.endsWith(QLatin1String(".1.0"))) { - //plugin directories might contain the version number - fixedPath.chop(4); - fixedPath += QLatin1Char('/') + QFileInfo(componentPath).fileName(); - if (QFileInfo::exists(fixedPath)) - return fixedPath; - } - } - - return result; -} - -QObject *ObjectNodeInstance::createComponent([[maybe_unused]] const QString &componentPath, - QQmlContext *context) -{ - QmlPrivateGate::ComponentCompleteDisabler disableComponentComplete; - - QQmlComponent component(context->engine(), fixComponentPathForIncompatibleQt(componentPath)); - - QObject *object = nullptr; - if (!component.isError()) { - object = component.beginCreate(context); - QmlPrivateGate::tweakObjects(object); - component.completeCreate(); - QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); - } - - if (component.isError()) { - qDebug() << componentPath; - foreach (const QQmlError &error, component.errors()) - qWarning() << error; - } - - if (object) - object->setProperty("__designer_url__", QUrl::fromLocalFile(componentPath)); - - return object; -} - -QObject *ObjectNodeInstance::createComponent(const QUrl &componentUrl, QQmlContext *context) -{ - return QmlPrivateGate::createComponent(componentUrl, context); -} - -QObject *ObjectNodeInstance::createCustomParserObject(const QString &nodeSource, - const QByteArray &importCode, - QQmlContext *context) -{ - [[maybe_unused]] QmlPrivateGate::ComponentCompleteDisabler disableComponentComplete; - - QQmlComponent component(context->engine()); - - QByteArray data(nodeSource.toUtf8()); - data.prepend(importCode); - component.setData(data, context->baseUrl().resolved(QUrl("createCustomParserObject.qml"))); - QObject *object = component.beginCreate(context); - if (object) { - QmlPrivateGate::tweakObjects(object); - component.completeCreate(); - QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership); - } - - if (component.isError()) { - qWarning() << "Error in:" << Q_FUNC_INFO << component.url().toString(); - foreach (const QQmlError &error, component.errors()) - qWarning() << error; - qWarning() << "file data:\n" << data; - } - return object; -} - -QObject *ObjectNodeInstance::object() const -{ - if (!m_object.isNull() && !QmlPrivateGate::objectWasDeleted(m_object.data())) - return m_object.data(); - return nullptr; -} - -QQuickItem *ObjectNodeInstance::contentItem() const -{ - return nullptr; -} - -bool ObjectNodeInstance::hasContent() const -{ - return false; -} - -bool ObjectNodeInstance::isResizable() const -{ - return false; -} - -bool ObjectNodeInstance::isMovable() const -{ - return false; -} - -bool ObjectNodeInstance::isInLayoutable() const -{ - return m_isInLayoutable; -} - -void ObjectNodeInstance::setInLayoutable(bool isInLayoutable) -{ - m_isInLayoutable = isInLayoutable; -} - -void ObjectNodeInstance::refreshLayoutable() -{ -} - -void ObjectNodeInstance::updateAnchors() -{ -} - -QQmlContext *ObjectNodeInstance::context() const -{ - if (nodeInstanceServer()) - return nodeInstanceServer()->context(); - - qWarning() << "Error: No NodeInstanceServer"; - return nullptr; -} - -QQmlEngine *ObjectNodeInstance::engine() const -{ - return nodeInstanceServer()->engine(); -} - -void ObjectNodeInstance::paintUpdate() -{ -} - -void ObjectNodeInstance::activateState() -{ -} - -void ObjectNodeInstance::deactivateState() -{ -} - -QStringList ObjectNodeInstance::allStates() const -{ - return {}; -} - -void ObjectNodeInstance::populateResetHashes() -{ - QmlPrivateGate::registerCustomData(object()); -} - -bool ObjectNodeInstance::hasValidResetBinding(const PropertyName &propertyName) const -{ - return QmlPrivateGate::hasValidResetBinding(object(), propertyName); -} - -QVariant ObjectNodeInstance::resetValue(const PropertyName &propertyName) const -{ - return QmlPrivateGate::getResetValue(object(), propertyName); -} - -QImage ObjectNodeInstance::renderImage() const -{ - return QImage(); -} - -QImage ObjectNodeInstance::renderPreviewImage(const QSize & /*previewImageSize*/) const -{ - return QImage(); -} - -QSharedPointer<QQuickItemGrabResult> ObjectNodeInstance::createGrabResult() const -{ - return {}; -} - -QObject *ObjectNodeInstance::parent() const -{ - if (!object()) - return nullptr; - - return object()->parent(); -} - -QObject *ObjectNodeInstance::parentObject(QObject *object) -{ - QQuickItem *quickItem = qobject_cast<QQuickItem*>(object); - if (quickItem && quickItem->parentItem()) - return quickItem->parentItem(); - - return object->parent(); -} - -ObjectNodeInstance::Pointer ObjectNodeInstance::parentInstance() const -{ - QObject *parentHolder = parent(); - if (!nodeInstanceServer()) - return Pointer(); - - while (parentHolder) { - if (nodeInstanceServer()->hasInstanceForObject(parentHolder)) - return nodeInstanceServer()->instanceForObject(parentHolder).internalInstance(); - - parentHolder = parentObject(parentHolder); - } - - return Pointer(); -} - -QRectF ObjectNodeInstance::boundingRect() const -{ - return QRectF(); -} - -QRectF ObjectNodeInstance::contentItemBoundingBox() const -{ - return QRectF(); -} - -QPointF ObjectNodeInstance::position() const -{ - return QPointF(); -} - -QSizeF ObjectNodeInstance::size() const -{ - return QSizeF(); -} - -int ObjectNodeInstance::penWidth() const -{ - return 0; -} - -bool ObjectNodeInstance::updateStateVariant(const ObjectNodeInstance::Pointer &/*target*/, const PropertyName &/*propertyName*/, const QVariant &/*value*/) -{ - return false; -} - -bool ObjectNodeInstance::updateStateBinding(const ObjectNodeInstance::Pointer &/*target*/, const PropertyName &/*propertyName*/, const QString &/*expression*/) -{ - return false; -} - -bool ObjectNodeInstance::resetStateProperty(const ObjectNodeInstance::Pointer &/*target*/, const PropertyName &/*propertyName*/, const QVariant &/*resetValue*/) -{ - return false; -} - -void ObjectNodeInstance::doComponentComplete() -{ - QmlPrivateGate::doComponentCompleteRecursive(object(), nodeInstanceServer()); -} - -bool ObjectNodeInstance::isRootNodeInstance() const -{ - return nodeInstanceServer()->rootNodeInstance().isWrappingThisObject(object()); -} - -bool ObjectNodeInstance::isValid() const -{ - return instanceId() >= 0 && object(); -} - -} -} - diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h deleted file mode 100644 index f4724e6cd7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.h +++ /dev/null @@ -1,224 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "nodeinstanceserver.h" -#include "nodeinstancesignalspy.h" - -#include "instancecontainer.h" - -#include <QPainter> -#include <QSharedPointer> -#include <QWeakPointer> - -#include <enumeration.h> - -QT_BEGIN_NAMESPACE -class QQmlContext; -class QQmlEngine; -class QQmlProperty; -class QQmlAbstractBinding; -class QQuickItem; -QT_END_NAMESPACE - -namespace QmlDesigner { - -class NodeInstanceServer; - -namespace Internal { - -class QmlGraphicsItemNodeInstance; -class GraphicsWidgetNodeInstance; -class GraphicsViewNodeInstance; -class GraphicsSceneNodeInstance; -class ProxyWidgetNodeInstance; -class WidgetNodeInstance; - -class ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<ObjectNodeInstance>; - using WeakPointer = QWeakPointer<ObjectNodeInstance>; - - virtual ~ObjectNodeInstance(); - void destroy(); - virtual void handleObjectDeletion(QObject *object); - - static Pointer create(QObject *objectToBeWrapped); - static QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context); - static QObject *createPrimitiveFromSource(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context); - static QObject *createCustomParserObject(const QString &nodeSource, const QByteArray &importCode, QQmlContext *context); - static QObject *createComponent(const QString &componentPath, QQmlContext *context); - static QObject *createComponent(const QUrl &componentUrl, QQmlContext *context); - static QObject *createComponentWrap(const QString &nodeSource, const QByteArray &importCode, QQmlContext *context); - - void setInstanceId(qint32 id); - qint32 instanceId() const; - - NodeInstanceServer *nodeInstanceServer() const; - void setNodeInstanceServer(NodeInstanceServer *server); - virtual void initialize(const Pointer &objectNodeInstance, InstanceContainer::NodeFlags flags); - virtual QImage renderImage() const; - virtual QImage renderPreviewImage(const QSize &previewImageSize) const; - - virtual QSharedPointer<QQuickItemGrabResult> createGrabResult() const; - - virtual QObject *parent() const; - - Pointer parentInstance() const; - - virtual void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, - const PropertyName &oldParentProperty, - const ObjectNodeInstance::Pointer &newParentInstance, - const PropertyName &newParentProperty); - - virtual void setId(const QString &id); - virtual QString id() const; - - virtual bool isTransition() const; - virtual bool isPositioner() const; - virtual bool isQuickItem() const; - virtual bool isQuickWindow() const; - virtual bool isLayoutable() const; - virtual bool isRenderable() const; - - virtual bool equalGraphicsItem(QGraphicsItem *item) const; - - virtual QRectF boundingRect() const; - virtual QRectF contentItemBoundingBox() const; - - virtual QPointF position() const; - virtual QSizeF size() const; - virtual QTransform transform() const; - virtual QTransform contentTransform() const; - virtual QTransform customTransform() const; - virtual QTransform contentItemTransform() const; - virtual QTransform sceneTransform() const; - virtual double opacity() const; - - virtual int penWidth() const; - - virtual bool hasAnchor(const PropertyName &name) const; - virtual QPair<PropertyName, ServerNodeInstance> anchor(const PropertyName &name) const; - virtual bool isAnchoredBySibling() const; - virtual bool isAnchoredByChildren() const; - - virtual double rotation() const; - virtual double scale() const; - virtual QList<QGraphicsTransform *> transformations() const; - virtual QPointF transformOriginPoint() const; - virtual double zValue() const; - - virtual void setPropertyVariant(const PropertyName &name, const QVariant &value); - virtual void setPropertyBinding(const PropertyName &name, const QString &expression); - virtual QVariant property(const PropertyName &name) const; - virtual void resetProperty(const PropertyName &name); - virtual void refreshProperty(const PropertyName &name); - virtual QString instanceType(const PropertyName &name) const; - PropertyNameList propertyNames() const; - - virtual QList<ServerNodeInstance> childItems() const; - virtual QList<QQuickItem*> allItemsRecursive() const; - - void setDeleteHeldInstance(bool deleteInstance); - bool deleteHeldInstance() const; - - virtual void updateAnchors(); - virtual void paintUpdate(); - - virtual void activateState(); - virtual void deactivateState(); - virtual QStringList allStates() const; - - void populateResetHashes(); - bool hasValidResetBinding(const PropertyName &propertyName) const; - QVariant resetValue(const PropertyName &propertyName) const; - - QObject *object() const; - virtual QQuickItem *contentItem() const; - - virtual bool hasContent() const; - virtual bool isResizable() const; - virtual bool isMovable() const; - bool isInLayoutable() const; - void setInLayoutable(bool isInLayoutable); - virtual void refreshLayoutable(); - - bool hasBindingForProperty(const PropertyName &propertyName, bool *hasChanged = nullptr) const; - - QQmlContext *context() const; - QQmlEngine *engine() const; - - virtual bool updateStateVariant(const ObjectNodeInstance::Pointer &target, - const PropertyName &propertyName, - const QVariant &value); - - virtual bool updateStateBinding(const ObjectNodeInstance::Pointer &target, - const PropertyName &propertyName, - const QString &expression); - - virtual bool resetStateProperty(const ObjectNodeInstance::Pointer &target, - const PropertyName &propertyName, - const QVariant &resetValue); - - bool isValid() const; - bool isRootNodeInstance() const; - - virtual void doComponentComplete(); - - virtual QList<ServerNodeInstance> stateInstances() const; - - virtual void setNodeSource(const QString &source); - - virtual void updateAllDirtyNodesRecursive(); - - virtual PropertyNameList ignoredProperties() const; - - virtual void setHiddenInEditor(bool b); - bool isHiddenInEditor() const; - - virtual void setLockedInEditor(bool b); - bool isLockedInEditor() const; - - bool isComponentWrap() const; - void setComponentWrap(bool wrap); - - void setModifiedFlag(bool b); - -protected: - explicit ObjectNodeInstance(QObject *object); - void doResetProperty(const PropertyName &propertyName); - void removeFromOldProperty(QObject *object, QObject *oldParent, const PropertyName &oldParentProperty); - void addToNewProperty(QObject *object, QObject *newParent, const PropertyName &newParentProperty); - void deleteObjectsInList(const QQmlProperty &metaProperty); - QVariant convertSpecialCharacter(const QVariant& value) const; - QVariant convertEnumToValue(const QVariant &value, const PropertyName &name); - static QObject *parentObject(QObject *object); - static QVariant enumationValue(const Enumeration &enumeration); - - void initializePropertyWatcher(const ObjectNodeInstance::Pointer &objectNodeInstance); - void ensureVector3DDotProperties(PropertyNameList &list) const; - -private: - QString m_id; - - QPointer<NodeInstanceServer> m_nodeInstanceServer; - PropertyName m_parentProperty; - - QPointer<QObject> m_object; - - NodeInstanceSignalSpy m_signalSpy; - - qint32 m_instanceId; - bool m_deleteHeldInstance; - bool m_isInLayoutable; - bool m_isModified = false; - bool m_isLockedInEditor = false; - bool m_isHiddenInEditor = false; - bool m_isComponentWrap = false; - static QHash<EnumerationName, QVariant> m_enumationValueHash; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp deleted file mode 100644 index ea83b83f33..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.cpp +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "positionernodeinstance.h" -#include <QQuickItem> - -namespace QmlDesigner { -namespace Internal { - -PositionerNodeInstance::PositionerNodeInstance(QQuickItem *item) - : QuickItemNodeInstance(item) -{ -} - -bool PositionerNodeInstance::isPositioner() const -{ - return true; -} - -bool PositionerNodeInstance::isLayoutable() const -{ - return true; -} - -bool PositionerNodeInstance::isResizable() const -{ - return true; -} - -PositionerNodeInstance::Pointer PositionerNodeInstance::create(QObject *object) -{ - QQuickItem *positioner = qobject_cast<QQuickItem*>(object); - - Q_ASSERT(positioner); - - Pointer instance(new PositionerNodeInstance(positioner)); - - instance->setHasContent(anyItemHasContent(positioner)); - positioner->setFlag(QQuickItem::ItemHasContents, true); - - static_cast<QQmlParserStatus*>(positioner)->classBegin(); - - instance->populateResetHashes(); - - return instance; -} - -void PositionerNodeInstance::refreshLayoutable() -{ - [[maybe_unused]] bool success = QMetaObject::invokeMethod(object(), "prePositioning"); - Q_ASSERT(success); -} - -PropertyNameList PositionerNodeInstance::ignoredProperties() const -{ - static const PropertyNameList properties({"move", "add", "populate"}); - return properties; -} -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h deleted file mode 100644 index a8052225f7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/positionernodeinstance.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "quickitemnodeinstance.h" - -QT_BEGIN_NAMESPACE -class QQuickBasePositioner; -QT_END_NAMESPACE - -namespace QmlDesigner { -namespace Internal { - -class PositionerNodeInstance : public QuickItemNodeInstance -{ -public: - using Pointer = QSharedPointer<PositionerNodeInstance>; - using WeakPointer = QWeakPointer<PositionerNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - bool isPositioner() const override; - bool isLayoutable() const override; - - bool isResizable() const override; - - void refreshLayoutable() override; - - PropertyNameList ignoredProperties() const override; - -protected: - PositionerNodeInstance(QQuickItem *item); -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlpropertychangesnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlpropertychangesnodeinstance.cpp deleted file mode 100644 index e836cd49a3..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlpropertychangesnodeinstance.cpp +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qmlpropertychangesnodeinstance.h" -#include "qmlstatenodeinstance.h" - -#include <qmlprivategate.h> - -#include <QQmlEngine> -#include <QQmlContext> -#include <QQmlExpression> - -namespace QmlDesigner { -namespace Internal { - -QmlPropertyChangesNodeInstance::QmlPropertyChangesNodeInstance(QObject *propertyChangesObject) : - ObjectNodeInstance(propertyChangesObject) -{ -} - -QmlPropertyChangesNodeInstance::Pointer QmlPropertyChangesNodeInstance::create(QObject *object) -{ - Pointer instance(new QmlPropertyChangesNodeInstance(object)); - - instance->populateResetHashes(); - - return instance; -} - -void QmlPropertyChangesNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (QmlPrivateGate::PropertyChanges::isNormalProperty(name)) { // 'restoreEntryValues', 'explicit' - ObjectNodeInstance::setPropertyVariant(name, value); - } else { - QmlPrivateGate::PropertyChanges::changeValue(object(), name, value); - QObject *targetObject = QmlPrivateGate::PropertyChanges::targetObject(object()); - if (targetObject - && nodeInstanceServer()->activeStateInstance(). - isWrappingThisObject(QmlPrivateGate::PropertyChanges::stateObject(object()))) { - if (nodeInstanceServer()->hasInstanceForObject(targetObject)) { - ServerNodeInstance targetInstance = nodeInstanceServer()->instanceForObject(targetObject); - targetInstance.setPropertyVariant(name, value); - } - } - } -} - -void QmlPropertyChangesNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - if (QmlPrivateGate::PropertyChanges::isNormalProperty(name)) { // 'restoreEntryValues', 'explicit' - ObjectNodeInstance::setPropertyBinding(name, expression); - } else { - QmlPrivateGate::PropertyChanges::changeExpression(object(), name, expression); - } -} - -QVariant QmlPropertyChangesNodeInstance::property(const PropertyName &name) const -{ - return QmlPrivateGate::PropertyChanges::getProperty(object(), name); -} - -void QmlPropertyChangesNodeInstance::resetProperty(const PropertyName &name) -{ - QmlPrivateGate::PropertyChanges::removeProperty(object(), name); -} - - -void QmlPropertyChangesNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) -{ - QmlPrivateGate::PropertyChanges::detachFromState(object()); - - ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty); - - QmlPrivateGate::PropertyChanges::attachToState(object()); -} - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlpropertychangesnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlpropertychangesnodeinstance.h deleted file mode 100644 index 85285a7412..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlpropertychangesnodeinstance.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -#include <QPair> -#include <QWeakPointer> - -namespace QmlDesigner { - -namespace Internal { - -class QmlPropertyChangesNodeInstance; - -class QmlPropertyChangesNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<QmlPropertyChangesNodeInstance>; - using WeakPointer = QWeakPointer<QmlPropertyChangesNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - void setPropertyVariant(const PropertyName &name, const QVariant &value) override; - void setPropertyBinding(const PropertyName &name, const QString &expression) override; - QVariant property(const PropertyName &name) const override; - void resetProperty(const PropertyName &name) override; - - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) override; - -protected: - QmlPropertyChangesNodeInstance(QObject *object); -}; - -} // namespace Internal -} // namespace QmlDesigner - -//QML_DECLARE_TYPE(QmlDesigner::Internal::QmlPropertyChangesObject) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.cpp deleted file mode 100644 index e60ca48da7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qmlstatenodeinstance.h" - -#include "qmlpropertychangesnodeinstance.h" - -#include <qmlprivategate.h> -#include <private/qquickdesignersupport_p.h> - -namespace QmlDesigner { -namespace Internal { - -/** - \class QmlStateNodeInstance - - QmlStateNodeInstance manages a QQuickState object. - */ - -QmlStateNodeInstance::QmlStateNodeInstance(QObject *object) : - ObjectNodeInstance(object) -{ -} - -QmlStateNodeInstance::Pointer - QmlStateNodeInstance::create(QObject *object) -{ - Pointer instance(new QmlStateNodeInstance(object)); - - instance->populateResetHashes(); - - return instance; -} - -void setAllNodesDirtyRecursive([[maybe_unused]] QQuickItem *parentItem) -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!parentItem) - return; - const QList<QQuickItem *> children = parentItem->childItems(); - for (QQuickItem *childItem : children) - setAllNodesDirtyRecursive(childItem); - QQuickDesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content); -#endif -} - -void QmlStateNodeInstance::activateState() -{ - if (!QmlPrivateGate::States::isStateActive(object(), context()) - && nodeInstanceServer()->hasInstanceForObject(object())) { - nodeInstanceServer()->setStateInstance(nodeInstanceServer()->instanceForObject(object())); - QmlPrivateGate::States::activateState(object(), context()); - - setAllNodesDirtyRecursive(nodeInstanceServer()->rootItem()); - } -} - -void QmlStateNodeInstance::deactivateState() -{ - if (QmlPrivateGate::States::isStateActive(object(), context())) { - nodeInstanceServer()->clearStateInstance(); - QmlPrivateGate::States::deactivateState(object()); - } -} - -void QmlStateNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (name == "when") - return; - - ObjectNodeInstance::setPropertyVariant(name, value); -} - -void QmlStateNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - if (name == "when") - return; - - ObjectNodeInstance::setPropertyBinding(name, expression); -} - -bool QmlStateNodeInstance::updateStateVariant(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant &value) -{ - return QmlPrivateGate::States::changeValueInRevertList(object(), target->object(), propertyName, value); -} - -bool QmlStateNodeInstance::updateStateBinding(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QString &expression) -{ - return QmlPrivateGate::States::updateStateBinding(object(), target->object(), propertyName, expression); -} - -bool QmlStateNodeInstance::resetStateProperty(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant & resetValue) -{ - return QmlPrivateGate::States::resetStateProperty(object(), target->object(), propertyName, resetValue); -} - -void QmlStateNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, - const PropertyName &oldParentProperty, - const ObjectNodeInstance::Pointer &newParentInstance, - const PropertyName &newParentProperty) -{ - ServerNodeInstance oldState = nodeInstanceServer()->activeStateInstance(); - - ObjectNodeInstance::reparent(oldParentInstance, - oldParentProperty, - newParentInstance, - newParentProperty); - - if (oldState.isValid()) - oldState.activateState(); -} - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.h deleted file mode 100644 index 95fce95c1b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmlstatenodeinstance.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -namespace QmlDesigner { - -namespace Internal { - -class QmlStateNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<QmlStateNodeInstance>; - using WeakPointer = QWeakPointer<QmlStateNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - void setPropertyVariant(const PropertyName &name, const QVariant &value) override; - void setPropertyBinding(const PropertyName &name, const QString &expression) override; - - void activateState() override; - void deactivateState() override; - - bool updateStateVariant(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant &value) override; - bool updateStateBinding(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QString &expression) override; - bool resetStateProperty(const ObjectNodeInstance::Pointer &target, const PropertyName &propertyName, const QVariant &resetValue) override; - - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, - const PropertyName &oldParentProperty, - const ObjectNodeInstance::Pointer &newParentInstance, - const PropertyName &newParentProperty) override; - -protected: - QmlStateNodeInstance(QObject *object); -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmltransitionnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmltransitionnodeinstance.cpp deleted file mode 100644 index 6f0e01c457..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmltransitionnodeinstance.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qmltransitionnodeinstance.h" - -#include <qmlprivategate.h> - -namespace QmlDesigner { -namespace Internal { - -QmlTransitionNodeInstance::QmlTransitionNodeInstance(QObject *transition) - : ObjectNodeInstance(transition) -{ -} - -QmlTransitionNodeInstance::Pointer QmlTransitionNodeInstance::create(QObject *object) -{ - Pointer instance(new QmlTransitionNodeInstance(object)); - - instance->populateResetHashes(); - QmlPrivateGate::disableTransition(object); - - return instance; -} - -bool QmlTransitionNodeInstance::isTransition() const -{ - return true; -} - -PropertyNameList QmlTransitionNodeInstance::ignoredProperties() const -{ - static const PropertyNameList properties({"from", "to"}); - return properties; -} - -} -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmltransitionnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmltransitionnodeinstance.h deleted file mode 100644 index 2fa9aca127..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qmltransitionnodeinstance.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -class QmlTransitionNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<QmlTransitionNodeInstance>; - using WeakPointer = QWeakPointer<QmlTransitionNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - bool isTransition() const override; - - PropertyNameList ignoredProperties() const override; - -private: - QmlTransitionNodeInstance(QObject *transition); -}; -} -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt3dpresentationnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt3dpresentationnodeinstance.cpp deleted file mode 100644 index 55df28a3f9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt3dpresentationnodeinstance.cpp +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt3dpresentationnodeinstance.h" -#include <QQuickItem> - -namespace QmlDesigner { -namespace Internal { - -Qt3DPresentationNodeInstance::Qt3DPresentationNodeInstance(QObject *object) - : ObjectNodeInstance(object) -{ -} - -Qt3DPresentationNodeInstance::Pointer Qt3DPresentationNodeInstance::create(QObject *object) -{ - Pointer instance(new Qt3DPresentationNodeInstance(object)); - instance->populateResetHashes(); - - return instance; -} - -PropertyNameList Qt3DPresentationNodeInstance::ignoredProperties() const -{ - static const PropertyNameList properties({"source"}); - return properties; -} -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt3dpresentationnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt3dpresentationnodeinstance.h deleted file mode 100644 index 6d30b9809c..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt3dpresentationnodeinstance.h +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -class Qt3DPresentationNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<Qt3DPresentationNodeInstance>; - using WeakPointer = QWeakPointer<Qt3DPresentationNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - PropertyNameList ignoredProperties() const override; - -protected: - Qt3DPresentationNodeInstance(QObject *item); -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5captureimagenodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5captureimagenodeinstanceserver.cpp deleted file mode 100644 index de779748ae..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5captureimagenodeinstanceserver.cpp +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5captureimagenodeinstanceserver.h" -#include "servernodeinstance.h" - -#include <captureddatacommand.h> -#include <createscenecommand.h> -#include <nodeinstanceclientinterface.h> - -#include <QImage> -#include <QQuickItem> -#include <QQuickView> - -#include <private/qquickdesignersupport_p.h> - -namespace QmlDesigner { - -namespace { - -QImage renderImage(ServerNodeInstance rootNodeInstance, QSize minimumSize, QSize maximumSize) -{ - rootNodeInstance.updateDirtyNodeRecursive(); - - QSize previewImageSize = rootNodeInstance.boundingRect().size().toSize(); - if (previewImageSize.isEmpty()) { - previewImageSize = minimumSize; - } else if (previewImageSize.width() < minimumSize.width() - || previewImageSize.height() < minimumSize.height()) { - previewImageSize.scale(minimumSize, Qt::KeepAspectRatio); - } - - if (previewImageSize.width() > maximumSize.width() - || previewImageSize.height() > maximumSize.height()) { - previewImageSize.scale(maximumSize, Qt::KeepAspectRatio); - } - - QImage previewImage = rootNodeInstance.renderPreviewImage(previewImageSize); - - return previewImage; -} -} // namespace - -void Qt5CaptureImageNodeInstanceServer::collectItemChangesAndSendChangeCommands() -{ - static bool inFunction = false; - - if (!rootNodeInstance().holdsGraphical()) { - nodeInstanceClient()->capturedData(CapturedDataCommand{}); - return; - } - - if (!inFunction) { - inFunction = true; - - auto rooNodeInstance = rootNodeInstance(); - if (QQuickItem *qitem = rooNodeInstance.rootQuickItem()) - qitem->setClip(true); - - QQuickDesignerSupport::polishItems(quickWindow()); - - QImage image = renderImage(rooNodeInstance, m_minimumSize, m_maximumSize); - - nodeInstanceClient()->capturedData(CapturedDataCommand{std::move(image)}); - - slowDownRenderTimer(); - inFunction = false; - } -} - -void QmlDesigner::Qt5CaptureImageNodeInstanceServer::createScene(const CreateSceneCommand &command) -{ - m_minimumSize = command.captureImageMinimumSize; - m_maximumSize = command.captureImageMaximumSize; - - Qt5PreviewNodeInstanceServer::createScene(command); -} - -} // namespace diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5captureimagenodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5captureimagenodeinstanceserver.h deleted file mode 100644 index 895daec5d6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5captureimagenodeinstanceserver.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qt5previewnodeinstanceserver.h> - -namespace QmlDesigner { - -class Qt5CaptureImageNodeInstanceServer : public Qt5PreviewNodeInstanceServer -{ -public: - explicit Qt5CaptureImageNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) - : Qt5PreviewNodeInstanceServer(nodeInstanceClient) - {} - - void createScene(const CreateSceneCommand &command) override; - -protected: - void collectItemChangesAndSendChangeCommands() override; - -private: - QSize m_minimumSize; - QSize m_maximumSize; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.cpp deleted file mode 100644 index 3a03f7c9fb..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5capturepreviewnodeinstanceserver.h" -#include "servernodeinstance.h" - -#include <captureddatacommand.h> -#include <createscenecommand.h> -#include <nodeinstanceclientinterface.h> - -#include <QImage> -#include <QQuickView> - -#include <private/qquickdesignersupport_p.h> - -namespace QmlDesigner { - -namespace { - -QImage renderPreviewImage(ServerNodeInstance rootNodeInstance) -{ - rootNodeInstance.updateDirtyNodeRecursive(); - - QSize previewImageSize = rootNodeInstance.boundingRect().size().toSize(); - - QImage previewImage = rootNodeInstance.renderPreviewImage(previewImageSize); - - return previewImage; -} - -CapturedDataCommand::StateData collectStateData(ServerNodeInstance rootNodeInstance, - const QVector<ServerNodeInstance> &nodeInstances, - qint32 stateInstanceId) -{ - CapturedDataCommand::StateData stateData; - stateData.image = ImageContainer(stateInstanceId, - QmlDesigner::renderPreviewImage(rootNodeInstance), - stateInstanceId); - stateData.nodeId = stateInstanceId; - - for (const ServerNodeInstance &instance : nodeInstances) { - CapturedDataCommand::NodeData nodeData; - - nodeData.nodeId = instance.instanceId(); - nodeData.contentRect = instance.boundingRect(); - nodeData.sceneTransform = instance.sceneTransform(); - auto textProperty = instance.property("text"); - if (!textProperty.isNull() && instance.holdsGraphical()) - nodeData.properties.emplace_back(QString{"text"}, textProperty); - auto colorProperty = instance.property("color"); - if (!colorProperty.isNull()) - nodeData.properties.emplace_back(QString{"color"}, colorProperty); - - auto visibleProperty = instance.property("visible"); - if (!colorProperty.isNull()) - nodeData.properties.emplace_back(QString{"visible"}, visibleProperty); - - stateData.nodeData.push_back(std::move(nodeData)); - } - - return stateData; -} -} // namespace - -void Qt5CapturePreviewNodeInstanceServer::collectItemChangesAndSendChangeCommands() -{ - static bool inFunction = false; - - if (!rootNodeInstance().holdsGraphical()) - return; - - if (!inFunction) { - inFunction = true; - - QQuickDesignerSupport::polishItems(quickWindow()); - - QVector<CapturedDataCommand::StateData> stateDatas; - stateDatas.push_back(collectStateData(rootNodeInstance(), nodeInstances(), 0)); - - for (ServerNodeInstance stateInstance : rootNodeInstance().stateInstances()) { - stateInstance.activateState(); - stateDatas.push_back( - collectStateData(rootNodeInstance(), nodeInstances(), stateInstance.instanceId())); - stateInstance.deactivateState(); - } - - nodeInstanceClient()->capturedData(CapturedDataCommand{std::move(stateDatas)}); - - slowDownRenderTimer(); - inFunction = false; - } -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.h deleted file mode 100644 index bb5e9816a0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5capturepreviewnodeinstanceserver.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <qt5previewnodeinstanceserver.h> - -namespace QmlDesigner { - -class Qt5CapturePreviewNodeInstanceServer : public Qt5PreviewNodeInstanceServer -{ -public: - explicit Qt5CapturePreviewNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) - : Qt5PreviewNodeInstanceServer(nodeInstanceClient) - {} - -protected: - void collectItemChangesAndSendChangeCommands() override; - -private: -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp deleted file mode 100644 index 1021a56823..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.cpp +++ /dev/null @@ -1,2774 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5informationnodeinstanceserver.h" - -#include <QQuickItem> -#include <QQuickView> -#include <QDropEvent> -#include <QMimeData> - -#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 "update3dviewstatecommand.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 "changestatecommand.h" -#include "childrenchangedcommand.h" -#include "completecomponentcommand.h" -#include "componentcompletedcommand.h" -#include "createscenecommand.h" -#include "tokencommand.h" -#include "removesharedmemorycommand.h" -#include "objectnodeinstance.h" -#include "puppettocreatorcommand.h" -#include "inputeventcommand.h" -#include "view3dactioncommand.h" -#include "requestmodelnodepreviewimagecommand.h" -#include "changeauxiliarycommand.h" - -#include "dummycontextobject.h" -#include "../editor3d/generalhelper.h" -#include "../editor3d/mousearea3d.h" -#include "../editor3d/camerageometry.h" -#include "../editor3d/lightgeometry.h" -#include "../editor3d/gridgeometry.h" -#include "../editor3d/selectionboxgeometry.h" -#include "../editor3d/linegeometry.h" -#include "../editor3d/icongizmoimageprovider.h" - -#include <private/qquickdesignersupport_p.h> -#include <qmlprivategate.h> -#include <quickitemnodeinstance.h> - -#include <QVector3D> -#include <QQmlProperty> -#include <QOpenGLContext> -#include <QQuickView> -#include <QQmlContext> -#include <QQmlEngine> -#include <QtGui/qevent.h> -#include <QtGui/qguiapplication.h> -#include <QProcessEnvironment> - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include <QtQuick/private/qquickrendercontrol_p.h> -#endif - -#ifdef QUICK3D_MODULE -#include <QtQuick3D/private/qquick3dnode_p.h> -#include <QtQuick3D/private/qquick3dcamera_p.h> -#include <QtQuick3D/private/qquick3dabstractlight_p.h> -#include <QtQuick3D/private/qquick3dviewport_p.h> -#include <QtQuick3D/private/qquick3dscenerootnode_p.h> -#include <QtQuick3D/private/qquick3drepeater_p.h> -#include <QtQuick3D/private/qquick3dloader_p.h> -#include <QtQuick3D/private/qquick3dsceneenvironment_p.h> -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include "../editor3d/qt5compat/qquick3darealight_p.h" -#endif -#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0) -#include <private/qquick3druntimeloader_p.h> -#endif -#endif - -#ifdef QUICK3D_PARTICLES_MODULE -#include <QtQuick3DParticles/private/qquick3dparticle_p.h> -#include <QtQuick3DParticles/private/qquick3dparticleaffector_p.h> -#include <QtQuick3DParticles/private/qquick3dparticleemitter_p.h> -#include <QtQuick3DParticles/private/qquick3dparticleattractor_p.h> -#include <QtQuick3DParticles/private/qquick3dparticletrailemitter_p.h> -#endif - -#ifdef IMPORT_QUICK3D_ASSETS -#include <QtCore/qjsonobject.h> -#include <QtQuick3DAssetImport/private/qssgassetimportmanager_p.h> -#endif - -// Uncomment to display FPS counter on the lower left corner of edit 3D view -//#define FPS_COUNTER -#ifdef FPS_COUNTER -#include <QtCore/qelapsedtimer.h> -static QElapsedTimer *_fpsTimer = nullptr; -static int _frameCount = 0; -#endif - -namespace QmlDesigner { - -static QVariant objectToVariant(QObject *object) -{ - return QVariant::fromValue(object); -} - -static QImage nonVisualComponentPreviewImage() -{ - static double ratio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble(); - if (ratio == 1.) { - static const QImage image(":/qtquickplugin/images/non-visual-component.png"); - return image; - } else { - static const QImage image(":/qtquickplugin/images/non-visual-component@2x.png"); - return image; - } -} - -static bool imageHasContent(const QImage &image) -{ - // Check if any image pixel contains non-zero data - const uchar *pData = image.constBits(); - const qsizetype size = image.sizeInBytes(); - for (qsizetype i = 0; i < size; ++i) { - if (*(pData++) != 0) - return true; - } - return false; -} - -static QObjectList toObjectList(const QVariant &variantList) -{ - QObjectList objList; - if (!variantList.isNull()) { - const auto varList = variantList.value<QVariantList>(); - for (const auto &var : varList) { - QObject *obj = var.value<QObject *>(); - if (obj) - objList.append(obj); - } - } - return objList; -} - -static QList<PropertyName> toPropertyNameList(const QVariant &variantList) -{ - QList<PropertyName> propList; - if (!variantList.isNull()) { - const auto varList = variantList.value<QVariantList>(); - for (const auto &var : varList) { - PropertyName prop = var.toByteArray(); - if (!prop.isEmpty()) - propList.append(prop); - } - } - return propList; -} - -void Qt5InformationNodeInstanceServer::createAuxiliaryQuickView(const QUrl &url, - RenderViewData &viewData) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - viewData.window = new QQuickView(quickView()->engine(), quickView()); - viewData.window->setFormat(quickView()->format()); - QQuickDesignerSupport::createOpenGLContext(static_cast<QQuickView *>(viewData.window.data())); -#else - viewData.renderControl = new QQuickRenderControl; - viewData.window = new QQuickWindow(viewData.renderControl); - viewData.renderControl->initialize(); -#endif - QQmlComponent component(engine()); - component.loadUrl(url); - viewData.rootItem = qobject_cast<QQuickItem *>(component.create()); - - if (!viewData.rootItem) { - qWarning() << "Could not create view for: " << url.toString() << component.errors(); - return; - } - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QQuickDesignerSupport::setRootItem(static_cast<QQuickView *>(viewData.window.data()), viewData.rootItem); -#else - viewData.window->contentItem()->setSize(viewData.rootItem->size()); - viewData.window->setGeometry(0, 0, viewData.rootItem->width(), viewData.rootItem->height()); - viewData.rootItem->setParentItem(viewData.window->contentItem()); -#endif -} - -void Qt5InformationNodeInstanceServer::updateLockedAndHiddenStates(const QSet<ServerNodeInstance> &instances) -{ - if (!ViewConfig::isQuick3DMode()) - return; - - // We only want to update the topmost parents in the set - for (const auto &instance : instances) { - if (instance.isValid()) { - const auto parentInst = instance.parent(); - if (!parentInst.isValid() || !instances.contains(parentInst)) { - handleInstanceHidden(instance, instance.internalInstance()->isHiddenInEditor(), true); - handleInstanceLocked(instance, instance.internalInstance()->isLockedInEditor(), true); - } - } - } -} - -void Qt5InformationNodeInstanceServer::handleInputEvents() -{ - if (m_editView3DData.window) { - int angleDelta = 0; - for (int i = 0; i < m_pendingInputEventCommands.size(); ++i) { - const InputEventCommand &command = m_pendingInputEventCommands[i]; - if (command.type() == QEvent::Wheel) { - if (i < m_pendingInputEventCommands.size() - 1) { - // Peek at next command. If that is also a wheel with same button/modifiers - // state, skip this event and add the angle delta to the next one. - auto nextCommand = m_pendingInputEventCommands[i + 1]; - if (nextCommand.type() == QEvent::MouseMove - && nextCommand.button() == command.button() - && nextCommand.buttons() == command.buttons() - && nextCommand.modifiers() == command.modifiers()) { - angleDelta += command.angleDelta(); - continue; - } - } - QWheelEvent *we -#if (QT_VERSION >= QT_VERSION_CHECK(5, 12, 0)) - = new QWheelEvent(command.pos(), command.pos(), {0, 0}, - {0, angleDelta + command.angleDelta()}, - command.buttons(), command.modifiers(), Qt::NoScrollPhase, - false); -#else - = new QWheelEvent(command.pos(), command.pos(), {0, 0}, {0, command.angleDelta()}, - 0, Qt::Horizontal, command.buttons(), command.modifiers(), - Qt::NoScrollPhase, Qt::MouseEventNotSynthesized); -#endif - angleDelta = 0; - QGuiApplication::sendEvent(m_editView3DData.window, we); - } else if (command.type() == QEvent::KeyPress || command.type() == QEvent::KeyRelease) { - QKeyEvent *ke = new QKeyEvent(command.type(), command.key(), command.modifiers(), - QString(), command.autoRepeat(), command.count()); - QGuiApplication::sendEvent(m_editView3DData.window, ke); - } else { - if (command.type() == QEvent::MouseMove && i < m_pendingInputEventCommands.size() - 1) { - // Peek at next command. If that is also a move with only difference being - // the position, skip this event as it is pointless - auto nextCommand = m_pendingInputEventCommands[i + 1]; - if (nextCommand.type() == QEvent::MouseMove - && nextCommand.button() == command.button() - && nextCommand.buttons() == command.buttons() - && nextCommand.modifiers() == command.modifiers()) { - continue; - } - } - QMouseEvent me(command.type(), command.pos(), command.button(), command.buttons(), - command.modifiers()); - // We must use sendEvent in Qt 6, as using postEvent allows the associated position - // data stored internally in QMutableEventPoint to potentially be updated by system - // before the event is delivered. - QGuiApplication::sendEvent(m_editView3DData.window, &me); - - // Context menu requested - if (command.button() == Qt::RightButton && command.modifiers() == Qt::NoModifier) - getNodeAtPos(command.pos()); - } - } - - m_pendingInputEventCommands.clear(); - - render3DEditView(); - } -} - -void Qt5InformationNodeInstanceServer::resolveImportSupport() -{ -#ifdef IMPORT_QUICK3D_ASSETS - QSSGAssetImportManager importManager; - const QHash<QString, QStringList> supportedExtensions = importManager.getSupportedExtensions(); -#if (QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)) -#define AS_VARIANT_MAP(IT) IT.value().toVariantMap() - using PluginOptionMaps = QSSGAssetImportManager::PluginOptionMaps; -#else -#define AS_VARIANT_MAP(IT) IT.value() - using PluginOptionMaps = QHash<QString, QVariantMap>; -#endif // QT_VERSION >= 6.4.0 - - const PluginOptionMaps supportedOptions = importManager.getAllOptions(); - - QVariantMap supportMap; - - QVariantMap extMap; - auto itExt = supportedExtensions.constBegin(); - while (itExt != supportedExtensions.constEnd()) { - extMap.insert(itExt.key(), itExt.value()); - ++itExt; - } - - QVariantMap optMap; - auto itOpt = supportedOptions.constBegin(); - while (itOpt != supportedOptions.constEnd()) { - optMap.insert(itOpt.key(), AS_VARIANT_MAP(itOpt)); - ++itOpt; - } - - supportMap.insert("options", optMap); - supportMap.insert("extensions", extMap); - nodeInstanceClient()->handlePuppetToCreatorCommand( - {PuppetToCreatorCommand::Import3DSupport, QVariant(supportMap)}); - -#endif -} - -void Qt5InformationNodeInstanceServer::updateMaterialPreviewData( - const QVector<PropertyValueContainer> &valueChanges) -{ - for (const auto &container : valueChanges) { - if (container.instanceId() == 0) { - if (container.name() == "matPrevEnv") - m_materialPreviewData.env = container.value().toString(); - else if (container.name() == "matPrevEnvValue") - m_materialPreviewData.envValue = container.value().toString(); - else if (container.name() == "matPrevModel") - m_materialPreviewData.model = container.value().toString(); - } - } -} - -void Qt5InformationNodeInstanceServer::updateRotationBlocks( - [[maybe_unused]] const QVector<PropertyValueContainer> &valueChanges) -{ -#ifdef QUICK3D_MODULE - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) { - QSet<QQuick3DNode *> blockedNodes; - QSet<QQuick3DNode *> unblockedNodes; - const PropertyName rotBlocked = "rotBlocked"; - for (const auto &container : valueChanges) { - if (container.name() == rotBlocked - && container.auxiliaryDataType() == AuxiliaryDataType::NodeInstanceAuxiliary) { - ServerNodeInstance instance = instanceForId(container.instanceId()); - if (instance.isValid()) { - auto node = qobject_cast<QQuick3DNode *>(instance.internalObject()); - if (node) { - if (container.value().toBool()) - blockedNodes.insert(node); - else - unblockedNodes.insert(node); - } - } - } - } - helper->addRotationBlocks(blockedNodes); - helper->removeRotationBlocks(unblockedNodes); - } -#endif -} - -void Qt5InformationNodeInstanceServer::removeRotationBlocks( - [[maybe_unused]] const QVector<qint32> &instanceIds) -{ -#ifdef QUICK3D_MODULE - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) { - QSet<QQuick3DNode *> unblockedNodes; - for (const auto &id : instanceIds) { - ServerNodeInstance instance = instanceForId(id); - if (instance.isValid()) { - auto node = qobject_cast<QQuick3DNode *>(instance.internalObject()); - if (node) - unblockedNodes.insert(node); - } - } - helper->removeRotationBlocks(unblockedNodes); - } -#endif -} - -void Qt5InformationNodeInstanceServer::getNodeAtPos(const QPointF &pos) -{ -#ifdef QUICK3D_MODULE - // pick a Quick3DModel at view position - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (!helper) - return; - - QQmlProperty editViewProp(m_editView3DData.rootItem, "editView", context()); - QObject *obj = qvariant_cast<QObject *>(editViewProp.read()); - QQuick3DViewport *editView = qobject_cast<QQuick3DViewport *>(obj); - - // Non-model nodes with icon gizmos are also valid results - QVariant gizmoVar; - QMetaObject::invokeMethod(m_editView3DData.rootItem, "gizmoAt", Qt::DirectConnection, - Q_RETURN_ARG(QVariant, gizmoVar), - Q_ARG(QVariant, pos.x()), - Q_ARG(QVariant, pos.y())); - QObject *gizmoObj = qvariant_cast<QObject *>(gizmoVar); - qint32 instanceId = -1; - - if (gizmoObj && hasInstanceForObject(gizmoObj)) { - instanceId = instanceForObject(gizmoObj).instanceId(); - } else { - QQuick3DModel *hitModel = helper->pickViewAt(editView, pos.x(), pos.y()).objectHit(); - QObject *resolvedPick = helper->resolvePick(hitModel); - if (hasInstanceForObject(resolvedPick)) - instanceId = instanceForObject(resolvedPick).instanceId(); - } - - // Also get the intersection with an axis plane of the scene. - QVector3D pos3d; - if (editView) { - Internal::MouseArea3D ma; - ma.setView3D(editView); - ma.setEulerRotation({90, 0, 0}); // Default grid plane (XZ plane) - QVector3D planePos = ma.getMousePosInPlane(nullptr, pos); - const float limit = 10000000; // Remove extremes on nearly parallel plane - if (!qFuzzyCompare(planePos.z(), -1.f) && qAbs(planePos.x()) < limit && qAbs(planePos.y()) < limit) - pos3d = {planePos.x(), 0, planePos.y()}; - } - QVariantList data; - data.append(instanceId); - data.append(pos3d); - nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::NodeAtPos, - QVariant::fromValue(data)}); -#else - Q_UNUSED(pos) -#endif -} - -void Qt5InformationNodeInstanceServer::createEditView3D() -{ -#ifdef QUICK3D_MODULE - qmlRegisterRevision<QQuick3DNode, 1>("MouseArea3D", 1, 0); - qmlRegisterType<QmlDesigner::Internal::MouseArea3D>("MouseArea3D", 1, 0, "MouseArea3D"); - qmlRegisterUncreatableType<QmlDesigner::Internal::GeometryBase>("GeometryBase", 1, 0, "GeometryBase", - "Abstract Base Class"); - qmlRegisterType<QmlDesigner::Internal::CameraGeometry>("CameraGeometry", 1, 0, "CameraGeometry"); - qmlRegisterType<QmlDesigner::Internal::LightGeometry>("LightUtils", 1, 0, "LightGeometry"); - qmlRegisterType<QmlDesigner::Internal::GridGeometry>("GridGeometry", 1, 0, "GridGeometry"); - qmlRegisterType<QmlDesigner::Internal::SelectionBoxGeometry>("SelectionBoxGeometry", 1, 0, "SelectionBoxGeometry"); - qmlRegisterType<QmlDesigner::Internal::LineGeometry>("LineGeometry", 1, 0, "LineGeometry"); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - qmlRegisterType<QmlDesigner::Internal::QQuick3DAreaLight>("LightUtils", 1, 0, "AreaLight"); -#endif - - auto helper = new QmlDesigner::Internal::GeneralHelper(); - QObject::connect(helper, &QmlDesigner::Internal::GeneralHelper::toolStateChanged, - this, &Qt5InformationNodeInstanceServer::handleToolStateChanged); - engine()->rootContext()->setContextProperty("_generalHelper", helper); - engine()->addImageProvider(QLatin1String("IconGizmoImageProvider"), - new QmlDesigner::Internal::IconGizmoImageProvider); - m_3dHelper = helper; - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/EditView3D.qml"), m_editView3DData); -#else - createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt5/EditView3D.qml"), m_editView3DData); -#endif - if (m_editView3DData.rootItem) - helper->setParent(m_editView3DData.rootItem); -#endif -} - -#ifdef QUICK3D_PARTICLES_MODULE -void Qt5InformationNodeInstanceServer::resetParticleSystem() -{ - if (!m_targetParticleSystem) - return; - m_targetParticleSystem->reset(); -#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 2) - m_targetParticleSystem->setEditorTime(0); -#endif - if (m_particleAnimationDriver) - m_particleAnimationDriver->reset(); -} - -void Qt5InformationNodeInstanceServer::handleParticleSystemSelected(QQuick3DParticleSystem* targetParticleSystem) -{ - if (targetParticleSystem == m_targetParticleSystem) - return; - - // stop the previously selected from animating - resetParticleSystem(); - - m_targetParticleSystem = targetParticleSystem; - - if (m_editView3DData.rootItem) { - QQmlProperty systemProperty(m_editView3DData.rootItem, "activeParticleSystem", context()); - systemProperty.write(objectToVariant(m_targetParticleSystem)); - } - - if (!m_particleAnimationDriver) - return; - - // Ensure clean slate for newly selected system - resetParticleSystem(); - -#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 2) - QObject::disconnect(m_particleAnimationConnection); - m_particleAnimationConnection = connect(m_particleAnimationDriver, &AnimationDriver::advanced, [this] () { - if (m_targetParticleSystem) - m_targetParticleSystem->setEditorTime(m_particleAnimationDriver->elapsed()); - }); -#endif - if (m_particleAnimationPlaying && m_targetParticleSystem->visible()) - m_particleAnimationDriver->restart(); - QObject::connect(m_targetParticleSystem, &QQuick3DNode::visibleChanged, [this] () { - if (m_particleAnimationPlaying && m_targetParticleSystem->visible()) { - m_particleAnimationDriver->restart(); - } else { - m_particleAnimationDriver->reset(); - resetParticleSystem(); - } - }); - - const auto anim = animations(); - for (auto a : anim) - a->restart(); -} - -static QString baseProperty(const QString &property) -{ - int index = property.indexOf('.'); - if (index > 0) - return property.left(index); - return property; -} - -template <typename T> -static QQuick3DParticleSystem *systemProperty(QObject *object) -{ - return qobject_cast<T>(object) ? qobject_cast<T>(object)->system() : nullptr; -} - -static QQuick3DParticleSystem *getSystemOrSystemProperty(QObject *selectedObject) -{ - QQuick3DParticleSystem *system = nullptr; - system = qobject_cast<QQuick3DParticleSystem *>(selectedObject); - if (system) - return system; - system = systemProperty<QQuick3DParticle *>(selectedObject); - if (system) - return system; - system = systemProperty<QQuick3DParticleAffector *>(selectedObject); - if (system) - return system; - system = systemProperty<QQuick3DParticleEmitter *>(selectedObject); - if (system) - return system; - return nullptr; -} - -static QQuick3DParticleSystem *parentParticleSystem(QObject *selectedObject) -{ - auto *ps = getSystemOrSystemProperty(selectedObject); - if (ps) - return ps; - QObject *parent = selectedObject->parent(); - while (parent) { - ps = getSystemOrSystemProperty(parent); - if (ps) - return ps; - parent = parent->parent(); - } - return nullptr; -} - -void Qt5InformationNodeInstanceServer::handleParticleSystemDeselected() -{ - resetParticleSystem(); - - m_targetParticleSystem = nullptr; - - if (m_editView3DData.rootItem) { - QQmlProperty systemProperty(m_editView3DData.rootItem, "activeParticleSystem", context()); - systemProperty.write(objectToVariant(nullptr)); - } - - const auto anim = animations(); - int i = 0; - for (auto a : anim) { - a->stop(); - QQuickPropertyAnimation *panim = qobject_cast<QQuickPropertyAnimation *>(a); - if (panim && panim->target()) - panim->target()->setProperty(qPrintable(baseProperty(panim->property())), animationDefaultValue(i)); - i++; - } -} -#endif - -// The selection has changed in the edit view 3D. Empty list indicates selection is cleared. -void Qt5InformationNodeInstanceServer::handleSelectionChanged(const QVariant &objs) -{ -#ifdef QUICK3D_PARTICLES_MODULE - bool skipSystemDeselect = m_targetParticleSystem == nullptr; -#endif - QList<ServerNodeInstance> instanceList; - const QVariantList varObjs = objs.value<QVariantList>(); - for (const auto &object : varObjs) { - auto obj = object.value<QObject *>(); - if (obj) { - ServerNodeInstance instance = instanceForObject(obj); - // If instance is a View3D, make sure it is not locked - bool locked = false; - if (instance.isSubclassOf("QQuick3DViewport")) { - locked = instance.internalInstance()->isLockedInEditor(); - auto parentInst = instance.parent(); - while (!locked && parentInst.isValid()) { - locked = parentInst.internalInstance()->isLockedInEditor(); - parentInst = parentInst.parent(); - } - } - if (!locked) - instanceList << instance; -#ifdef QUICK3D_PARTICLES_MODULE - if (!skipSystemDeselect) { - auto particleSystem = parentParticleSystem(instance.internalObject()); - skipSystemDeselect = particleSystem == m_targetParticleSystem; - } -#endif - } - } - -#ifdef QUICK3D_PARTICLES_MODULE - if (m_targetParticleSystem && !skipSystemDeselect) - handleParticleSystemDeselected(); -#endif - - selectInstances(instanceList); - // Hold selection changes reflected back from designer for a bit - m_selectionChangeTimer.start(500); -} - -QVector<Qt5InformationNodeInstanceServer::InstancePropertyValueTriple> -Qt5InformationNodeInstanceServer::propertyToPropertyValueTriples( - const ServerNodeInstance &instance, - const PropertyName &propertyName, - const QVariant &variant) -{ - QVector<InstancePropertyValueTriple> result; - InstancePropertyValueTriple propTriple; - - if (variant.type() == QVariant::Vector3D) { - auto vector3d = variant.value<QVector3D>(); - - if (vector3d.isNull()) - return result; - - const PropertyName dot = propertyName.isEmpty() ? "" : "."; - propTriple.instance = instance; - propTriple.propertyName = propertyName + dot + PropertyName("x"); - propTriple.propertyValue = vector3d.x(); - result.append(propTriple); - propTriple.propertyName = propertyName + dot + PropertyName("y"); - propTriple.propertyValue = vector3d.y(); - result.append(propTriple); - propTriple.propertyName = propertyName + dot + PropertyName("z"); - propTriple.propertyValue = vector3d.z(); - result.append(propTriple); - } else { - propTriple.instance = instance; - propTriple.propertyName = propertyName; - propTriple.propertyValue = variant; - result.append(propTriple); - } - - return result; -} - -void Qt5InformationNodeInstanceServer::modifyVariantValue(const QObjectList &objects, - const QList<PropertyName> &propNames, ValuesModifiedCommand::TransactionOption option) -{ - struct PropNamePair { - PropertyName origPropName; - PropertyName targetPropName; - }; - - QList<PropNamePair> propNamePairs; - - // Position is a special case, because the position can be 'position.x 'or simply 'x'. - // We prefer 'x'. - for (const auto &propName : propNames) { - if (propName != "position") - propNamePairs.append({propName, propName}); - else - propNamePairs.append({propName, PropertyName{}}); - } - - if (!objects.isEmpty()) { - QVector<PropertyValueContainer> valueVector; - for (const auto listObj : objects) { - ServerNodeInstance instance = instanceForObject(listObj); - if (instance.isValid()) { - const qint32 instId = instance.instanceId(); - if (option == ValuesModifiedCommand::TransactionOption::Start) - instance.setModifiedFlag(true); - else if (option == ValuesModifiedCommand::TransactionOption::End) - instance.setModifiedFlag(false); - for (const auto &propNamePair : propNamePairs) { - // We do have to split vector3d props into foobar.x, foobar.y, foobar.z - const QVector<InstancePropertyValueTriple> triple - = propertyToPropertyValueTriples(instance, propNamePair.targetPropName, - listObj->property(propNamePair.origPropName)); - for (const auto &property : triple) { - const PropertyName propName = property.propertyName; - const QVariant propValue = property.propertyValue; - valueVector.append(PropertyValueContainer(instId, propName, - propValue, PropertyName())); - } - } - } - } - - if (!valueVector.isEmpty()) { - ValuesModifiedCommand command(valueVector); - command.transactionOption = option; - nodeInstanceClient()->valuesModified(command); - } - } -} - -void Qt5InformationNodeInstanceServer::handleObjectPropertyCommit(const QVariant &objects, - const QVariant &propNames) -{ - modifyVariantValue(toObjectList(objects), toPropertyNameList(propNames), - ValuesModifiedCommand::TransactionOption::End); - m_changedNodes.clear(); - m_changedProperties.clear(); - m_propertyChangeTimer.stop(); -} - -void Qt5InformationNodeInstanceServer::handleObjectPropertyChange(const QVariant &objects, - const QVariant &propNames) -{ - QObjectList objList = toObjectList(objects); - QList<PropertyName> propList = toPropertyNameList(propNames); - - bool nodeChanged = true; - if (objList.size() == m_changedNodes.size()) { - nodeChanged = false; - for (int i = 0; i < objList.size(); ++i) { - if (objList[i] != m_changedNodes[i]) { - nodeChanged = true; - break; - } - } - } - if (!nodeChanged && propList.size() == m_changedProperties.size()) { - for (int i = 0; i < propList.size(); ++i) { - if (propList[i] != m_changedProperties[i]) { - nodeChanged = true; - break; - } - } - } - - if (nodeChanged) { - if (!m_changedNodes.isEmpty()) { - // Nodes/properties changed, commit currently pending changes - modifyVariantValue(m_changedNodes, m_changedProperties, - ValuesModifiedCommand::TransactionOption::End); - m_changedNodes.clear(); - m_changedProperties.clear(); - m_propertyChangeTimer.stop(); - } - modifyVariantValue(objList, propList, ValuesModifiedCommand::TransactionOption::Start); - } else if (!m_propertyChangeTimer.isActive()) { - m_propertyChangeTimer.start(); - } - m_changedNodes = objList; - m_changedProperties = propList; -} - -void Qt5InformationNodeInstanceServer::handleActiveSceneChange() -{ -#ifdef QUICK3D_MODULE - ServerNodeInstance sceneInstance = active3DSceneInstance(); - const QString sceneId = sceneInstance.id(); - - QVariantMap toolStates; - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) - toolStates = helper->getToolStates(sceneId); - toolStates.insert("sceneInstanceId", QVariant::fromValue(sceneInstance.instanceId())); - - nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::ActiveSceneChanged, - toolStates}); - m_selectionChangeTimer.start(0); -#endif -} - -void Qt5InformationNodeInstanceServer::handleToolStateChanged(const QString &sceneId, - const QString &tool, - const QVariant &toolState) -{ - QVariantList data; - data << sceneId; - data << tool; - data << toolState; - nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::Edit3DToolState, - QVariant::fromValue(data)}); -} - -void Qt5InformationNodeInstanceServer::handleView3DSizeChange() -{ - QObject *view3D = sender(); - if (view3D == m_active3DView) - updateView3DRect(view3D); -} - -void Qt5InformationNodeInstanceServer::handleView3DDestroyed([[maybe_unused]] QObject *obj) -{ -#ifdef QUICK3D_MODULE - auto view = qobject_cast<QQuick3DViewport *>(obj); - m_view3Ds.remove(obj); - removeNode3D(view->scene()); - if (view && view == m_active3DView) - m_active3DView = nullptr; -#endif -} - -void Qt5InformationNodeInstanceServer::handleNode3DDestroyed([[maybe_unused]] QObject *obj) -{ -#ifdef QUICK3D_MODULE - if (qobject_cast<QQuick3DCamera *>(obj)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "releaseCameraGizmo", - Q_ARG(QVariant, objectToVariant(obj))); - } else if (qobject_cast<QQuick3DAbstractLight *>(obj)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "releaseLightGizmo", - Q_ARG(QVariant, objectToVariant(obj))); -#ifdef QUICK3D_PARTICLES_MODULE - } else if (qobject_cast<QQuick3DParticleSystem *>(obj)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "releaseParticleSystemGizmo", - Q_ARG(QVariant, objectToVariant(obj))); - } else if ((qobject_cast<QQuick3DParticleEmitter *>(obj) - || qobject_cast<QQuick3DParticleAttractor *>(obj)) - && !qobject_cast<QQuick3DParticleTrailEmitter *>(obj)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "releaseParticleEmitterGizmo", - Q_ARG(QVariant, objectToVariant(obj))); -#endif - } - removeNode3D(obj); -#endif -} - -void Qt5InformationNodeInstanceServer::updateView3DRect(QObject *view3D) -{ - QRectF viewPortrect(0., 0., 1000., 1000.); - if (view3D) { - viewPortrect = QRectF(0., 0., view3D->property("width").toDouble(), - view3D->property("height").toDouble()); - } - QQmlProperty viewPortProperty(m_editView3DData.rootItem, "viewPortRect", context()); - viewPortProperty.write(viewPortrect); -} - -void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D([[maybe_unused]] bool timerCall) -{ -#ifdef QUICK3D_MODULE - if (!m_editView3DSetupDone) - return; - - QVariant activeSceneVar = objectToVariant(m_active3DScene); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - // Active scene change handling on qml side is async, so a deleted importScene would crash - // editView when it updates next. Disable/enable edit view update synchronously to avoid this. - QMetaObject::invokeMethod(m_editView3DData.rootItem, "enableEditViewUpdate", - Q_ARG(QVariant, activeSceneVar)); -#endif - ServerNodeInstance sceneInstance = active3DSceneInstance(); - const QString sceneId = sceneInstance.id(); - - // In case of newly created scene node, QML item id is updated with separate command immediately - // after the creation of the node, so delay this update for a moment in case we get it. - // The changeId command should already be waiting to be handled, so we can use very short - // interval timer. If we haven't gotten the scene id by the time the timer triggers, we can - // assume scene node doesn't have an id. - if (m_active3DScene && !timerCall && sceneId.isEmpty()) { - m_activeSceneIdUpdateTimer.start(); - return; - } else { - m_activeSceneIdUpdateTimer.stop(); - } - - // We may have to substitute another scene to work around QTBUG-103316 - // The worked around issue is that if a material is used in multiple scenes, there is some - // kind of ownership for it in the first View3D that uses it, so if that view is not rendered - // first, the material will not be properly initialized for other views using it. - // To make materials work properly, we ensure that views are rendered at least once in the - // order they appear in the scene. - if (!m_priorityView3DsToRender.isEmpty()) { - QObject *sceneRoot = find3DSceneRoot(m_priorityView3DsToRender.first()); - if (sceneRoot) - activeSceneVar = objectToVariant(sceneRoot); - } - - QMetaObject::invokeMethod(m_editView3DData.rootItem, "setActiveScene", Qt::QueuedConnection, - Q_ARG(QVariant, activeSceneVar), - Q_ARG(QVariant, QVariant::fromValue(sceneId))); - - updateView3DRect(m_active3DView); - - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) { - helper->storeToolState(helper->globalStateId(), helper->lastSceneIdKey(), QVariant(sceneId), 0); - QVariantMap toolStates = helper->getToolStates(sceneId); - if (toolStates.contains("syncBackgroundColor")) { - bool sync = toolStates["syncBackgroundColor"].toBool(); - if (sync) { - QColor color = helper->sceneEnvironmentColor(sceneId); - View3DActionCommand cmd(View3DActionType::SelectBackgroundColor, - QVariant::fromValue(color)); - view3DAction(cmd); - } - } - } -#endif -} - -void Qt5InformationNodeInstanceServer::removeNode3D(QObject *node) -{ - m_3DSceneMap.remove(node); - const auto oldMap = m_3DSceneMap; - auto it = oldMap.constBegin(); - while (it != oldMap.constEnd()) { - if (it.value() == node) { - m_3DSceneMap.remove(it.key(), node); - break; - } - ++it; - } - if (node == m_active3DScene) { - m_active3DScene = nullptr; - m_active3DView = nullptr; - updateActiveSceneToEditView3D(); - } -} - -void Qt5InformationNodeInstanceServer::resolveSceneRoots() -{ -#ifdef QUICK3D_MODULE - if (!m_editView3DSetupDone) - return; - - const auto oldMap = m_3DSceneMap; - m_3DSceneMap.clear(); - auto it = oldMap.begin(); - bool updateActiveScene = !m_active3DScene; - while (it != oldMap.end()) { - QObject *node = it.value(); - QObject *newRoot = find3DSceneRoot(node); - QObject *oldRoot = it.key(); - if (!m_active3DScene || (newRoot != oldRoot && m_active3DScene == oldRoot)) { - m_active3DScene = newRoot; - updateActiveScene = true; - } - m_3DSceneMap.insert(newRoot, node); - - if (newRoot != oldRoot) { - if (qobject_cast<QQuick3DCamera *>(node)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateCameraGizmoScene", - Q_ARG(QVariant, objectToVariant(newRoot)), - Q_ARG(QVariant, objectToVariant(node))); - } else if (qobject_cast<QQuick3DAbstractLight *>(node)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateLightGizmoScene", - Q_ARG(QVariant, objectToVariant(newRoot)), - Q_ARG(QVariant, objectToVariant(node))); -#ifdef QUICK3D_PARTICLES_MODULE - } else if (qobject_cast<QQuick3DParticleSystem *>(node)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateParticleSystemGizmoScene", - Q_ARG(QVariant, objectToVariant(newRoot)), - Q_ARG(QVariant, objectToVariant(node))); - } else if ((qobject_cast<QQuick3DParticleEmitter *>(node) - || qobject_cast<QQuick3DParticleAttractor *>(node)) - && !qobject_cast<QQuick3DParticleTrailEmitter *>(node)) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateParticleEmitterGizmoScene", - Q_ARG(QVariant, objectToVariant(newRoot)), - Q_ARG(QVariant, objectToVariant(node))); -#endif - } - } - ++it; - } - if (updateActiveScene) { - m_active3DView = findView3DForSceneRoot(m_active3DScene); - updateActiveSceneToEditView3D(); - } -#endif -} - -ServerNodeInstance Qt5InformationNodeInstanceServer::active3DSceneInstance() const -{ - ServerNodeInstance sceneInstance; - if (hasInstanceForObject(m_active3DScene)) - sceneInstance = instanceForObject(m_active3DScene); - else if (hasInstanceForObject(m_active3DView)) - sceneInstance = instanceForObject(m_active3DView); - return sceneInstance; -} - -void Qt5InformationNodeInstanceServer::updateNodesRecursive(QQuickItem *item) -{ - const auto childItems = item->childItems(); - for (QQuickItem *childItem : childItems) - updateNodesRecursive(childItem); - - if (Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6()) { - if (item->flags() & QQuickItem::ItemHasContents) - item->update(); - } else { - QQuickDesignerSupport::updateDirtyNode(item); - } -} - -QQuickItem *Qt5InformationNodeInstanceServer::getContentItemForRendering(QQuickItem *rootItem) -{ - QQuickItem *contentItem = QQmlProperty::read(rootItem, "contentItem").value<QQuickItem *>(); - if (contentItem) { - if (!Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6()) - designerSupport()->refFromEffectItem(contentItem, false); - QmlDesigner::Internal::QmlPrivateGate::disableNativeTextRendering(contentItem); - } - return contentItem; -} - -void Qt5InformationNodeInstanceServer::render3DEditView(int count) -{ - m_need3DEditViewRender = qMax(count, m_need3DEditViewRender); - if (!m_render3DEditViewTimer.isActive()) - m_render3DEditViewTimer.start(0); -} - -// render the 3D edit view and send the result to creator process -void Qt5InformationNodeInstanceServer::doRender3DEditView() -{ - if (m_editView3DSetupDone) { - if (!m_editView3DData.contentItem) - m_editView3DData.contentItem = getContentItemForRendering(m_editView3DData.rootItem); - - QImage renderImage; - - updateNodesRecursive(m_editView3DData.contentItem); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { - renderImage = m_editView3DData.window->grabWindow(); - } else { - // Fake render loop signaling to update things like QML items as 3D textures - m_editView3DData.window->beforeSynchronizing(); - m_editView3DData.window->beforeRendering(); - - QSizeF size = qobject_cast<QQuickItem *>(m_editView3DData.contentItem)->size(); - QRectF renderRect(QPointF(0., 0.), size); - renderImage = designerSupport()->renderImageForItem(m_editView3DData.contentItem, - renderRect, size.toSize()); - - m_editView3DData.window->afterRendering(); - } -#else - renderImage = grabRenderControl(m_editView3DData); -#endif - - // There's no instance related to image, so instance id is -1. - // Key number is selected so that it is unlikely to conflict other ImageContainer use. - auto imgContainer = ImageContainer(-1, renderImage, 2100000000); - - // If we have only one or no render queued, send the result to the creator side. - // Otherwise, we'll hold on that until we have rendered all pending frames to ensure sent - // results are correct. - if (m_priorityView3DsToRender.isEmpty() && m_need3DEditViewRender <= 1) { - nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::Render3DView, - QVariant::fromValue(imgContainer)}); -#ifdef QUICK3D_PARTICLES_MODULE - if (m_need3DEditViewRender == 0 && ViewConfig::isParticleViewMode() - && m_particleAnimationDriver && m_particleAnimationDriver->isAnimating()) { - m_need3DEditViewRender = 1; - } -#endif - } - - if (!m_priorityView3DsToRender.isEmpty()) { - static int tryCounter = 0; - QObject *sceneRoot = find3DSceneRoot(m_priorityView3DsToRender.first()); - bool needAnotherRender = false; - if (sceneRoot) { - // Active scene is updated asynchronously, so verify we are actually rendering - // the correct priority scene - QObject *activeScene = QQmlProperty::read(m_editView3DData.rootItem, "activeScene").value<QObject *>(); - needAnotherRender = activeScene != sceneRoot; - } - - if (!needAnotherRender || ++tryCounter > 10) { - m_priorityView3DsToRender.removeFirst(); - updateActiveSceneToEditView3D(); - tryCounter = 0; - } - ++m_need3DEditViewRender; - } - - if (m_need3DEditViewRender > 0) { - // We queue another render even if the requested render count was one, because another - // render is needed to ensure gizmo geometries are properly updated. - // Note that while in theory this seems that we shouldn't need to send the image to - // creator side when m_need3DEditViewRender is one, we need to do it to ensure - // smooth operation when objects are moved via drag, which triggers new renders - // continueously. - m_render3DEditViewTimer.start(17); // 16.67ms = ~60fps, rounds up to 17 - --m_need3DEditViewRender; - } - -#ifdef FPS_COUNTER - // Force constant rendering for accurate fps count - if (!m_render3DEditViewTimer.isActive()) - m_render3DEditViewTimer.start(0); - ++_frameCount; - if (_fpsTimer->elapsed() > 1000) { - QQmlProperty fpsProperty(m_editView3DData.rootItem, "fps", context()); - fpsProperty.write(_frameCount); - _frameCount = 0; - _fpsTimer->start(); - } -#endif - } -} - -void Qt5InformationNodeInstanceServer::renderModelNodeImageView() -{ - if (!m_renderModelNodeImageViewTimer.isActive()) - m_renderModelNodeImageViewTimer.start(17); -} - -void Qt5InformationNodeInstanceServer::doRenderModelNodeImageView() -{ - // This crashes on Qt 6.0.x due to QtQuick3D issue, so the preview generation is disabled -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) || QT_VERSION >= QT_VERSION_CHECK(6, 1, 0) - if (!m_priorityView3DsToRender.isEmpty()) { - // Postpone any preview renders until we have rendered the priority views to ensure - // materials in material library are properly initialized - m_renderModelNodeImageViewTimer.start(17); - return; - } - - RequestModelNodePreviewImageCommand cmd = *m_modelNodePreviewImageCommands.begin(); - ServerNodeInstance instance; - if (cmd.renderItemId() >= 0) - instance = instanceForId(cmd.renderItemId()); - else - instance = instanceForId(cmd.instanceId()); - - if (instance.isSubclassOf("QQuick3DObject")) - doRenderModelNode3DImageView(cmd); - else if (instance.isSubclassOf("QQuickItem")) - doRenderModelNode2DImageView(cmd); - - m_modelNodePreviewImageCommands.remove(cmd); - if (!m_modelNodePreviewImageCommands.isEmpty()) - m_renderModelNodeImageViewTimer.start(17); -#endif -} - -void Qt5InformationNodeInstanceServer::doRenderModelNode3DImageView( - [[maybe_unused]] const RequestModelNodePreviewImageCommand &cmd) -{ -#ifdef QUICK3D_MODULE - if (m_modelNode3DImageViewData.rootItem) { - QMetaObject::invokeMethod(m_modelNode3DImageViewData.rootItem, "destroyView"); - if (!m_modelNode3DImageViewData.contentItem) - m_modelNode3DImageViewData.contentItem = getContentItemForRendering(m_modelNode3DImageViewData.rootItem); - - QImage renderImage; - if (m_modelNodePreviewImageCache.contains(cmd.componentPath())) { - renderImage = m_modelNodePreviewImageCache[cmd.componentPath()]; - } else { - bool createdFromComponent = false; - QObject *instanceObj = nullptr; - ServerNodeInstance instance = instanceForId(cmd.instanceId()); - if (!cmd.componentPath().isEmpty() - && instance.isSubclassOf("QQuick3DNode")) { - // Create a new instance for Node components, as using Nodes in multiple - // import scenes simultaneously isn't supported. And even if it was, we still - // wouldn't want the children of the Node to appear in the preview. - QQmlComponent component(engine()); - component.loadUrl(QUrl::fromLocalFile(cmd.componentPath())); - instanceObj = qobject_cast<QQuick3DObject *>(component.create()); - if (!instanceObj) { - qWarning() << "Could not create preview component: " << component.errors(); - return; - } - createdFromComponent = true; - } else { - instanceObj = instance.internalObject(); - } - QSize renderSize = cmd.size(); - if (Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6()) { - // Requested size is already adjusted for target pixel ratio, so we have to adjust - // back if ratio is not default for our window. - double ratio = m_modelNode3DImageViewData.window->devicePixelRatio(); - renderSize.setWidth(qRound(qreal(renderSize.width()) / ratio)); - renderSize.setHeight(qRound(qreal(renderSize.height()) / ratio)); - } -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - m_modelNode3DImageViewData.bufferDirty = m_modelNode3DImageViewData.bufferDirty - || m_modelNode3DImageViewData.rootItem->width() != renderSize.width() - || m_modelNode3DImageViewData.rootItem->height() != renderSize.height(); -#endif - - m_modelNode3DImageViewData.window->resize(renderSize); - m_modelNode3DImageViewData.rootItem->setSize(renderSize); - - if (createdFromComponent) { - QMetaObject::invokeMethod( - m_modelNode3DImageViewData.rootItem, "createViewForNode", - Q_ARG(QVariant, objectToVariant(instanceObj))); - } else { - QMetaObject::invokeMethod( - m_modelNode3DImageViewData.rootItem, "createViewForObject", - Q_ARG(QVariant, objectToVariant(instanceObj)), - Q_ARG(QVariant, m_materialPreviewData.env), - Q_ARG(QVariant, m_materialPreviewData.envValue), - Q_ARG(QVariant, m_materialPreviewData.model)); - } - - // Need to render twice, first render updates spatial nodes - for (int i = 0; i < 2; ++i) { - if (i == 1) - QMetaObject::invokeMethod(m_modelNode3DImageViewData.rootItem, "fitToViewPort" - , Qt::DirectConnection); - - updateNodesRecursive(m_modelNode3DImageViewData.contentItem); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { - renderImage = m_modelNode3DImageViewData.window->grabWindow(); - } else { - // Fake render loop signaling to update things like QML items as 3D textures - m_modelNode3DImageViewData.window->beforeSynchronizing(); - m_modelNode3DImageViewData.window->beforeRendering(); - - QSizeF size = qobject_cast<QQuickItem *>(m_modelNode3DImageViewData.contentItem)->size(); - QRectF renderRect(QPointF(0., 0.), size); - renderImage = designerSupport()->renderImageForItem(m_modelNode3DImageViewData.contentItem, - renderRect, size.toSize()); - m_modelNode3DImageViewData.window->afterRendering(); - } -#else - renderImage = grabRenderControl(m_modelNode3DImageViewData); -#endif - } - - QMetaObject::invokeMethod(m_modelNode3DImageViewData.rootItem, "destroyView"); - - if (createdFromComponent) { - // If component changes, puppet will need a reset anyway, so we can cache the image - m_modelNodePreviewImageCache.insert(cmd.componentPath(), - renderImage); - delete instanceObj; - } - } - // Key number is selected so that it is unlikely to conflict other ImageContainer use. - ImageContainer imgContainer(cmd.instanceId(), {}, 2100000001 + cmd.instanceId()); - imgContainer.setImage(renderImage); - - // send the rendered image to creator process - nodeInstanceClient()->handlePuppetToCreatorCommand( - {PuppetToCreatorCommand::RenderModelNodePreviewImage, - QVariant::fromValue(imgContainer)}); - } -#endif -} - -static QRectF itemBoundingRect(QQuickItem *item) -{ - QRectF itemRect; - if (item) { - itemRect = item->boundingRect(); - if (item->clip()) { - return itemRect; - } else { - const auto childItems = item->childItems(); - for (const auto &childItem : childItems) { - QRectF mappedRect = childItem->mapRectToItem(item, itemBoundingRect(childItem)); - // Sanity check for size - if (mappedRect.isValid() && (mappedRect.width() < 10000) && (mappedRect.height() < 10000)) - itemRect = itemRect.united(mappedRect); - } - } - } - return itemRect; -} - -void Qt5InformationNodeInstanceServer::doRenderModelNode2DImageView(const RequestModelNodePreviewImageCommand &cmd) -{ - if (m_modelNode2DImageViewData.rootItem) { - if (!m_modelNode2DImageViewData.contentItem) - m_modelNode2DImageViewData.contentItem = getContentItemForRendering(m_modelNode2DImageViewData.rootItem); - - // Key number is the same as in 3D case as they produce image for same purpose - auto imgContainer = ImageContainer(cmd.instanceId(), {}, 2100000001 + cmd.instanceId()); - QImage renderImage; - if (m_modelNodePreviewImageCache.contains(cmd.componentPath())) { - renderImage = m_modelNodePreviewImageCache[cmd.componentPath()]; - } else { - QQuickItem *instanceItem = nullptr; - - if (!cmd.componentPath().isEmpty()) { - QQmlComponent component(engine()); - component.loadUrl(QUrl::fromLocalFile(cmd.componentPath())); - instanceItem = qobject_cast<QQuickItem *>(component.create()); - if (!instanceItem) { - qWarning() << "Could not create preview component: " << component.errors(); - return; - } - } else { - qWarning() << "2D image preview is not supported for non-components."; - return; - } - - instanceItem->setParentItem(m_modelNode2DImageViewData.contentItem); - - // Some component may expect to always be shown at certain size, so their layouts may - // not support scaling, so let's always render at the default size if item has one and - // scale the resulting image instead. - QSize finalSize = cmd.size(); - QRectF renderRect = itemBoundingRect(instanceItem); - QSize renderSize = renderRect.size().toSize(); - if (renderSize.isEmpty()) { - renderSize = finalSize; - renderRect = QRectF(QPointF(0., 0.), QSizeF(renderSize)); - } - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - m_modelNode2DImageViewData.bufferDirty = m_modelNode2DImageViewData.bufferDirty - || m_modelNode2DImageViewData.rootItem->width() != renderSize.width() - || m_modelNode2DImageViewData.rootItem->height() != renderSize.height(); -#endif - - m_modelNode2DImageViewData.window->resize(renderSize); - m_modelNode2DImageViewData.rootItem->setSize(renderSize); - m_modelNode2DImageViewData.contentItem->setPosition(QPointF(-renderRect.x(), -renderRect.y())); - - updateNodesRecursive(m_modelNode2DImageViewData.contentItem); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { - renderImage = m_modelNode2DImageViewData.window->grabWindow(); - } else { - renderImage = designerSupport()->renderImageForItem(m_modelNode2DImageViewData.contentItem, - renderRect, renderSize); - } -#else - renderImage = grabRenderControl(m_modelNode2DImageViewData); -#endif - - if (!imageHasContent(renderImage)) - renderImage = nonVisualComponentPreviewImage(); - - if (renderSize != finalSize) - renderImage = renderImage.scaled(finalSize, Qt::KeepAspectRatio); - - delete instanceItem; - - // If component changes, puppet will need a reset anyway, so we can cache the image - m_modelNodePreviewImageCache.insert(cmd.componentPath(), renderImage); - } - - if (!renderImage.isNull()) { - imgContainer.setImage(renderImage); - - // send the rendered image to creator process - nodeInstanceClient()->handlePuppetToCreatorCommand({PuppetToCreatorCommand::RenderModelNodePreviewImage, - QVariant::fromValue(imgContainer)}); - } - } -} - -Qt5InformationNodeInstanceServer::Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) : - Qt5NodeInstanceServer(nodeInstanceClient) -{ - m_propertyChangeTimer.setInterval(100); - m_propertyChangeTimer.setSingleShot(true); - m_selectionChangeTimer.setSingleShot(true); - m_render3DEditViewTimer.setSingleShot(true); - m_inputEventTimer.setSingleShot(true); - m_renderModelNodeImageViewTimer.setSingleShot(true); - m_dynamicAddObjectTimer.setSingleShot(true); - m_activeSceneIdUpdateTimer.setInterval(20); - m_activeSceneIdUpdateTimer.setSingleShot(true); - -#ifdef FPS_COUNTER - if (!_fpsTimer) { - _fpsTimer = new QElapsedTimer; - _fpsTimer->start(); - } -#endif -#ifdef QUICK3D_PARTICLES_MODULE - if (ViewConfig::isParticleViewMode()) { - m_particleAnimationDriver = new AnimationDriver(this); - m_particleAnimationDriver->setInterval(17); - } -#endif -} - -Qt5InformationNodeInstanceServer::~Qt5InformationNodeInstanceServer() -{ - m_editView3DSetupDone = false; - - m_propertyChangeTimer.stop(); - m_selectionChangeTimer.stop(); - m_render3DEditViewTimer.stop(); - m_inputEventTimer.stop(); - m_renderModelNodeImageViewTimer.stop(); - m_dynamicAddObjectTimer.stop(); - m_activeSceneIdUpdateTimer.stop(); - - if (m_editView3DData.rootItem) - m_editView3DData.rootItem->disconnect(this); - - for (auto view : std::as_const(m_view3Ds)) - view->disconnect(); - for (auto node : std::as_const(m_3DSceneMap)) - node->disconnect(); - - if (m_editView3DData.rootItem) - QMetaObject::invokeMethod(m_editView3DData.rootItem, "aboutToShutDown", Qt::DirectConnection); - - if (!Internal::QuickItemNodeInstance::unifiedRenderPathOrQt6()) { - if (m_editView3DData.contentItem) - designerSupport()->derefFromEffectItem(m_editView3DData.contentItem); - if (m_modelNode3DImageViewData.contentItem) - designerSupport()->derefFromEffectItem(m_modelNode3DImageViewData.contentItem); - if (m_modelNode2DImageViewData.contentItem) - designerSupport()->derefFromEffectItem(m_modelNode2DImageViewData.contentItem); - } -} - -void Qt5InformationNodeInstanceServer::sendTokenBack() -{ - foreach (const TokenCommand &command, m_tokenList) - nodeInstanceClient()->token(command); - - m_tokenList.clear(); -} - -void Qt5InformationNodeInstanceServer::token(const TokenCommand &command) -{ - m_tokenList.append(command); - startRenderTimer(); -} - -bool Qt5InformationNodeInstanceServer::isDirtyRecursiveForNonInstanceItems(QQuickItem *item) const -{ - static QQuickDesignerSupport::DirtyType informationsDirty = QQuickDesignerSupport::DirtyType(QQuickDesignerSupport::TransformUpdateMask - | QQuickDesignerSupport::ContentUpdateMask - | QQuickDesignerSupport::Visible - | QQuickDesignerSupport::ZValue - | QQuickDesignerSupport::OpacityValue); - - if (QQuickDesignerSupport::isDirty(item, informationsDirty)) - return true; - - foreach (QQuickItem *childItem, item->childItems()) { - if (!hasInstanceForObject(childItem)) { - if (QQuickDesignerSupport::isDirty(childItem, informationsDirty)) - return true; - else if (isDirtyRecursiveForNonInstanceItems(childItem)) - return true; - } - } - - return false; -} - -bool Qt5InformationNodeInstanceServer::isDirtyRecursiveForParentInstances(QQuickItem *item) const -{ - if (QQuickDesignerSupport::isDirty(item, QQuickDesignerSupport::TransformUpdateMask)) - return true; - - QQuickItem *parentItem = item->parentItem(); - - if (parentItem) { - if (hasInstanceForObject(parentItem)) - return false; - - return isDirtyRecursiveForParentInstances(parentItem); - } - - return false; -} - -/* This method allows changing the selection from the puppet */ -void Qt5InformationNodeInstanceServer::selectInstances(const QList<ServerNodeInstance> &instanceList) -{ - nodeInstanceClient()->selectionChanged(createChangeSelectionCommand(instanceList)); -} - -/* This method allows changing property values from the puppet - * For performance reasons (and the undo stack) properties should always be modifed in 'bulks'. - */ -void Qt5InformationNodeInstanceServer::modifyProperties( - const QVector<NodeInstanceServer::InstancePropertyValueTriple> &properties) -{ - nodeInstanceClient()->valuesModified(createValuesModifiedCommand(properties)); -} - -QList<ServerNodeInstance> Qt5InformationNodeInstanceServer::createInstances( - const QVector<InstanceContainer> &container) -{ - const auto createdInstances = NodeInstanceServer::createInstances(container); - - if (m_editView3DSetupDone) { - add3DViewPorts(createdInstances); - add3DScenes(createdInstances); - createCameraAndLightGizmos(createdInstances); - } - - render3DEditView(); - - return createdInstances; -} - -void Qt5InformationNodeInstanceServer::initializeAuxiliaryViews() -{ -#ifdef QUICK3D_MODULE - if (ViewConfig::isQuick3DMode()) - createEditView3D(); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/ModelNode3DImageView.qml"), - m_modelNode3DImageViewData); -#else - createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt5/ModelNode3DImageView.qml"), - m_modelNode3DImageViewData); -#endif -#endif - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt6/ModelNode2DImageView.qml"), - m_modelNode2DImageViewData); -#else - createAuxiliaryQuickView(QUrl("qrc:/qtquickplugin/mockfiles/qt5/ModelNode2DImageView.qml"), - m_modelNode2DImageViewData); -#endif - m_modelNode2DImageViewData.window->setDefaultAlphaBuffer(true); - m_modelNode2DImageViewData.window->setColor(Qt::transparent); -} - -void Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout() -{ - modifyVariantValue(m_changedNodes, m_changedProperties, - ValuesModifiedCommand::TransactionOption::None); -} - -void Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout() -{ - changeSelection(m_lastSelectionChangeCommand); -} - -void Qt5InformationNodeInstanceServer::handleDynamicAddObjectTimeout() -{ - for (auto obj : std::as_const(m_dynamicObjectConstructors)) { -#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1) -#ifdef QUICK3D_MODULE - auto handleHiding = [this](QQuick3DNode *node) -> bool { - if (node && hasInstanceForObject(node)) { - ServerNodeInstance instance = instanceForObject(node); - handleInstanceHidden(instance, instance.internalInstance()->isHiddenInEditor(), - false); - return true; - } - return false; - }; - auto nodeObj = qobject_cast<QQuick3DNode *>(obj); - if (!handleHiding(nodeObj)) { - if (auto pickTarget = obj->property("_pickTarget").value<QQuick3DNode *>()) - handleHiding(pickTarget); - } -#endif -#else - auto handlePicking = [this](QObject *object) -> bool { - if (object && hasInstanceForObject(object)) { - ServerNodeInstance instance = instanceForObject(object); - handlePickTarget(instance); - return true; - } - return false; - }; - if (!handlePicking(obj)) { - if (auto pickTarget = obj->property("_pickTarget").value<QObject *>()) - handlePicking(pickTarget); - } -#endif - } - m_dynamicObjectConstructors.clear(); -} - -void Qt5InformationNodeInstanceServer::createCameraAndLightGizmos( - const QList<ServerNodeInstance> &instanceList) const -{ - QHash<QObject *, QObjectList> cameras; - QHash<QObject *, QObjectList> lights; - QHash<QObject *, QObjectList> particleSystems; - QHash<QObject *, QObjectList> particleEmitters; - - for (const ServerNodeInstance &instance : instanceList) { - if (instance.isSubclassOf("QQuick3DCamera")) { - cameras[find3DSceneRoot(instance)] << instance.internalObject(); - } else if (instance.isSubclassOf("QQuick3DAbstractLight")) { - lights[find3DSceneRoot(instance)] << instance.internalObject(); - } else if (instance.isSubclassOf("QQuick3DParticleSystem")) { - particleSystems[find3DSceneRoot(instance)] << instance.internalObject(); - } else if ((instance.isSubclassOf("QQuick3DParticleEmitter") - || instance.isSubclassOf("QQuick3DParticleAttractor")) - && !instance.isSubclassOf("QQuick3DParticleTrailEmitter")) { - particleEmitters[find3DSceneRoot(instance)] << instance.internalObject(); - } - } - - auto cameraIt = cameras.constBegin(); - while (cameraIt != cameras.constEnd()) { - const auto cameraObjs = cameraIt.value(); - for (auto &obj : cameraObjs) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "addCameraGizmo", - Q_ARG(QVariant, objectToVariant(cameraIt.key())), - Q_ARG(QVariant, objectToVariant(obj))); - } - ++cameraIt; - } - auto lightIt = lights.constBegin(); - while (lightIt != lights.constEnd()) { - const auto lightObjs = lightIt.value(); - for (auto &obj : lightObjs) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "addLightGizmo", - Q_ARG(QVariant, objectToVariant(lightIt.key())), - Q_ARG(QVariant, objectToVariant(obj))); - } - ++lightIt; - } - auto particleIt = particleSystems.constBegin(); - while (particleIt != particleSystems.constEnd()) { - const auto particleObjs = particleIt.value(); - for (auto &obj : particleObjs) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "addParticleSystemGizmo", - Q_ARG(QVariant, objectToVariant(particleIt.key())), - Q_ARG(QVariant, objectToVariant(obj))); - } - ++particleIt; - } - - auto emitterIt = particleEmitters.constBegin(); - while (emitterIt != particleEmitters.constEnd()) { - const auto emitterObjs = emitterIt.value(); - for (auto &obj : emitterObjs) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "addParticleEmitterGizmo", - Q_ARG(QVariant, objectToVariant(emitterIt.key())), - Q_ARG(QVariant, objectToVariant(obj))); - } - ++emitterIt; - } -} - -void Qt5InformationNodeInstanceServer::add3DViewPorts(const QList<ServerNodeInstance> &instanceList) -{ - for (const ServerNodeInstance &instance : instanceList) { - if (instance.isSubclassOf("QQuick3DViewport")) { - QObject *obj = instance.internalObject(); - if (!m_editView3DSetupDone) - m_priorityView3DsToRender.append(obj); // Workaround for quick3d bug QTBUG-103316 - if (!m_view3Ds.contains(obj)) { - m_view3Ds << obj; - QObject::connect(obj, SIGNAL(widthChanged()), this, SLOT(handleView3DSizeChange())); - QObject::connect(obj, SIGNAL(heightChanged()), this, SLOT(handleView3DSizeChange())); - QObject::connect(obj, &QObject::destroyed, - this, &Qt5InformationNodeInstanceServer::handleView3DDestroyed); - } - } - } -} - -void Qt5InformationNodeInstanceServer::add3DScenes(const QList<ServerNodeInstance> &instanceList) -{ - for (const ServerNodeInstance &instance : instanceList) { - if (instance.isSubclassOf("QQuick3DNode")) { - QObject *sceneRoot = find3DSceneRoot(instance); - QObject *obj = instance.internalObject(); - if (!m_3DSceneMap.contains(sceneRoot, obj)) { - m_3DSceneMap.insert(sceneRoot, obj); - QObject::connect(obj, &QObject::destroyed, - this, &Qt5InformationNodeInstanceServer::handleNode3DDestroyed); - } - } - } -} - -QObject *Qt5InformationNodeInstanceServer::findView3DForInstance( - [[maybe_unused]] const ServerNodeInstance &instance) const -{ -#ifdef QUICK3D_MODULE - if (!instance.isValid()) - return {}; - - // View3D of an instance is one of the following, in order of priority: - // - Any direct ancestor View3D of the instance - // - Any View3D that specifies the instance's scene as importScene - ServerNodeInstance checkInstance = instance; - while (checkInstance.isValid()) { - if (checkInstance.isSubclassOf("QQuick3DViewport")) - return checkInstance.internalObject(); - else - checkInstance = checkInstance.parent(); - } - - // If no ancestor View3D was found, check if the scene root is specified as importScene in - // some View3D. - QObject *sceneRoot = find3DSceneRoot(instance); - for (const auto &view3D : std::as_const(m_view3Ds)) { - auto view = qobject_cast<QQuick3DViewport *>(view3D); - if (view && sceneRoot == view->importScene()) - return view3D; - } -#endif - return {}; -} - -QObject *Qt5InformationNodeInstanceServer::findView3DForSceneRoot( - [[maybe_unused]] QObject *sceneRoot) const -{ -#ifdef QUICK3D_MODULE - if (!sceneRoot) - return {}; - - if (hasInstanceForObject(sceneRoot)) { - return findView3DForInstance(instanceForObject(sceneRoot)); - } else { - // No instance, so the scene root must be scene property of one of the views - for (const auto &view3D : std::as_const(m_view3Ds)) { - auto view = qobject_cast<QQuick3DViewport *>(view3D); - if (view && sceneRoot == view->scene()) - return view3D; - } - } -#endif - return {}; -} - -QObject *Qt5InformationNodeInstanceServer::find3DSceneRoot( - [[maybe_unused]] const ServerNodeInstance &instance) const -{ -#ifdef QUICK3D_MODULE - // The root of a 3D scene is any QQuick3DNode that doesn't have QQuick3DNode as parent. - // One exception is QQuick3DSceneRootNode that has only a single child QQuick3DNode (not - // a subclass of one, but exactly QQuick3DNode). In that case we consider the single child node - // to be the scene root (as QQuick3DSceneRootNode is not visible in the navigator scene graph). - - if (!instance.isValid()) - return nullptr; - - QQuick3DNode *childNode = nullptr; - auto countChildNodes = [&childNode](QQuick3DViewport *view) -> int { - QQuick3DNode *sceneNode = view->scene(); - QList<QQuick3DObject *> children = sceneNode->childItems(); - int nodeCount = 0; - for (const auto &child : children) { - auto nodeChild = qobject_cast<QQuick3DNode *>(child); - if (nodeChild) { - ++nodeCount; - childNode = nodeChild; - } - } - return nodeCount; - }; - - // In case of View3D is selected, the root scene is whatever is contained in View3D, or - // importScene, in case there is no content in View3D - QObject *obj = instance.internalObject(); - auto view = qobject_cast<QQuick3DViewport *>(obj); - if (view) { - int nodeCount = countChildNodes(view); - if (nodeCount == 0) - return view->importScene(); - else if (nodeCount == 1) - return childNode; - else - return view->scene(); - } - - ServerNodeInstance checkInstance = instance; - bool foundNode = checkInstance.isSubclassOf("QQuick3DNode"); - while (checkInstance.isValid()) { - ServerNodeInstance parentInstance = checkInstance.parent(); - if (parentInstance.isSubclassOf("QQuick3DViewport")) { - view = qobject_cast<QQuick3DViewport *>(parentInstance.internalObject()); - int nodeCount = countChildNodes(view); - if (nodeCount == 1) - return childNode; - else - return view->scene(); - } else if (parentInstance.isSubclassOf("QQuick3DNode")) { - foundNode = true; - checkInstance = parentInstance; - } else { - if (!foundNode) { - // We haven't found any node yet, continue the search - checkInstance = parentInstance; - } else { - return checkInstance.internalObject(); - } - } - } -#endif - return nullptr; -} - -QObject *Qt5InformationNodeInstanceServer::find3DSceneRoot([[maybe_unused]] QObject *obj) const -{ -#ifdef QUICK3D_MODULE - if (hasInstanceForObject(obj)) - return find3DSceneRoot(instanceForObject(obj)); - - // If there is no instance, obj could be a scene in a View3D - for (const auto &viewObj : std::as_const(m_view3Ds)) { - const auto view = qobject_cast<QQuick3DViewport *>(viewObj); - if (view && view->scene() == obj) - return obj; - } -#endif - // Some other non-instance object, assume it's not part of any scene - return nullptr; -} - -void Qt5InformationNodeInstanceServer::setup3DEditView( - [[maybe_unused]] const QList<ServerNodeInstance> &instanceList, - [[maybe_unused]] const CreateSceneCommand &command) -{ -#ifdef QUICK3D_MODULE - if (!m_editView3DData.rootItem) - return; - - ServerNodeInstance root = rootNodeInstance(); - - add3DViewPorts(instanceList); - add3DScenes(instanceList); - - QObject::connect(m_editView3DData.rootItem, SIGNAL(selectionChanged(QVariant)), - this, SLOT(handleSelectionChanged(QVariant))); - QObject::connect(m_editView3DData.rootItem, SIGNAL(commitObjectProperty(QVariant, QVariant)), - this, SLOT(handleObjectPropertyCommit(QVariant, QVariant))); - QObject::connect(m_editView3DData.rootItem, SIGNAL(changeObjectProperty(QVariant, QVariant)), - this, SLOT(handleObjectPropertyChange(QVariant, QVariant))); - QObject::connect(m_editView3DData.rootItem, SIGNAL(notifyActiveSceneChange()), - this, SLOT(handleActiveSceneChange())); - QObject::connect(&m_propertyChangeTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::handleObjectPropertyChangeTimeout); - QObject::connect(&m_selectionChangeTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::handleSelectionChangeTimeout); - QObject::connect(&m_render3DEditViewTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::doRender3DEditView); - QObject::connect(&m_inputEventTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::handleInputEvents); - QObject::connect(&m_dynamicAddObjectTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::handleDynamicAddObjectTimeout); - QObject::connect(&m_activeSceneIdUpdateTimer, &QTimer::timeout, this, [this]() { - Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D(true); - }); - - const QHash<QString, QVariantMap> &toolStates = command.edit3dToolStates; - QString lastSceneId; - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) { - auto it = toolStates.constBegin(); - while (it != toolStates.constEnd()) { - helper->initToolStates(it.key(), it.value()); - ++it; - } - if (toolStates.contains(helper->globalStateId())) { - if (toolStates[helper->globalStateId()].contains(helper->rootSizeKey())) { - QSize size = toolStates[helper->globalStateId()][helper->rootSizeKey()].value<QSize>(); - m_editView3DData.rootItem->setSize(size); - m_editView3DData.window->setGeometry(0, 0, size.width(), size.height()); - } - if (toolStates[helper->globalStateId()].contains(helper->lastSceneIdKey())) - lastSceneId = toolStates[helper->globalStateId()][helper->lastSceneIdKey()].toString(); - } - } - - // Find a scene to show - m_active3DScene = nullptr; - m_active3DView = nullptr; - if (!m_3DSceneMap.isEmpty()) { - // Restore the previous scene if possible - if (!lastSceneId.isEmpty()) { - const auto keys = m_3DSceneMap.uniqueKeys(); - for (const auto key : keys) { - m_active3DScene = key; - m_active3DView = findView3DForSceneRoot(m_active3DScene); - ServerNodeInstance sceneInstance = active3DSceneInstance(); - if (lastSceneId == sceneInstance.id()) - break; - } - } else { - m_active3DScene = m_3DSceneMap.begin().key(); - m_active3DView = findView3DForSceneRoot(m_active3DScene); - } - } - - m_editView3DSetupDone = true; - - if (toolStates.contains({})) { - // Update tool state to an existing no-scene state before updating the active scene to - // ensure the previous state is inherited properly in all cases. - QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateToolStates", Qt::QueuedConnection, - Q_ARG(QVariant, toolStates[{}]), - Q_ARG(QVariant, QVariant::fromValue(false))); - } - - updateActiveSceneToEditView3D(); - - createCameraAndLightGizmos(instanceList); - - if (!command.edit3dBackgroundColor.isEmpty()) { - View3DActionCommand backgroundColorCommand(View3DActionType::SelectBackgroundColor, - QVariant::fromValue( - command.edit3dBackgroundColor)); - view3DAction(backgroundColorCommand); - } - - if (command.edit3dGridColor.isValid()) { - View3DActionCommand backgroundColorCommand(View3DActionType::SelectGridColor, - QVariant::fromValue(command.edit3dGridColor)); - view3DAction(backgroundColorCommand); - } - - // Queue two renders to make sure icon gizmos update properly - render3DEditView(2); -#endif -} - -void Qt5InformationNodeInstanceServer::collectItemChangesAndSendChangeCommands() -{ - static bool inFunction = false; - if (!inFunction) { - inFunction = true; - - QQuickDesignerSupport::polishItems(quickWindow()); - - QSet<ServerNodeInstance> informationChangedInstanceSet; - QVector<InstancePropertyPair> propertyChangedList; - - if (quickWindow()) { - foreach (QQuickItem *item, allItems()) { - if (item && hasInstanceForObject(item)) { - ServerNodeInstance instance = instanceForObject(item); - - if (isDirtyRecursiveForNonInstanceItems(item)) - informationChangedInstanceSet.insert(instance); - else if (isDirtyRecursiveForParentInstances(item)) - informationChangedInstanceSet.insert(instance); - - if (QQuickDesignerSupport::isDirty(item, QQuickDesignerSupport::ParentChanged)) { - m_parentChangedSet.insert(instance); - informationChangedInstanceSet.insert(instance); - } - } - } - - foreach (const InstancePropertyPair& property, changedPropertyList()) { - const ServerNodeInstance instance = property.first; - if (instance.isValid()) { - if (property.second.contains("anchors")) - informationChangedInstanceSet.insert(instance); - - propertyChangedList.append(property); - } - } - - resetAllItems(); - clearChangedPropertyList(); - - sendTokenBack(); - - if (!informationChangedInstanceSet.isEmpty()) - nodeInstanceClient()->informationChanged( - createAllInformationChangedCommand(QtHelpers::toList(informationChangedInstanceSet))); - - if (!propertyChangedList.isEmpty()) - nodeInstanceClient()->valuesChanged(createValuesChangedCommand(propertyChangedList)); - - if (!m_parentChangedSet.isEmpty()) { - sendChildrenChangedCommand(QtHelpers::toList(m_parentChangedSet)); - updateLockedAndHiddenStates(m_parentChangedSet); - m_parentChangedSet.clear(); - } - - 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()) { - if (hasInstanceForId(container.instanceId())) { - ServerNodeInstance instance = instanceForId(container.instanceId()); - if (instance.isValid()) { - m_parentChangedSet.insert(instance); - } - } - } - - Qt5NodeInstanceServer::reparentInstances(command); - - if (m_editView3DSetupDone) - resolveSceneRoots(); - - // Make sure selection is in sync after all reparentings are done - m_selectionChangeTimer.start(0); -} - -void Qt5InformationNodeInstanceServer::clearScene(const ClearSceneCommand &command) -{ - Qt5NodeInstanceServer::clearScene(command); - - m_parentChangedSet.clear(); - m_completedComponentList.clear(); - m_dynamicObjectConstructors.clear(); -} - -void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &command) -{ - Qt5NodeInstanceServer::createScene(command); - - QList<ServerNodeInstance> instanceList; - for (const InstanceContainer &container : std::as_const(command.instances)) { - if (hasInstanceForId(container.instanceId())) { - 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)); - - if (ViewConfig::isQuick3DMode()) { - setup3DEditView(instanceList, command); - updateRotationBlocks(command.auxiliaryChanges); - updateMaterialPreviewData(command.auxiliaryChanges); - } - - QObject::connect(&m_renderModelNodeImageViewTimer, &QTimer::timeout, - this, &Qt5InformationNodeInstanceServer::doRenderModelNodeImageView); -#ifdef IMPORT_QUICK3D_ASSETS - QTimer::singleShot(0, this, &Qt5InformationNodeInstanceServer::resolveImportSupport); -#endif -} - -void Qt5InformationNodeInstanceServer::sendChildrenChangedCommand(const QList<ServerNodeInstance> &childList) -{ - QSet<ServerNodeInstance> parentSet; - QList<ServerNodeInstance> noParentList; - - foreach (const ServerNodeInstance &child, childList) { - if (child.isValid()) { - 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()) { - if (hasInstanceForId(instanceId)) { - ServerNodeInstance instance = instanceForId(instanceId); - if (instance.isValid()) { - instanceList.append(instance); - } - } - } - - m_completedComponentList.append(instanceList); - - nodeInstanceClient()->valuesChanged(createValuesChangedCommand(instanceList)); - nodeInstanceClient()->informationChanged(createAllInformationChangedCommand(instanceList, true)); -} - -void QmlDesigner::Qt5InformationNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command) -{ - if (command.typeName() == "Values") - ValuesChangedCommand::removeSharedMemorys(command.keyNumbers()); -} - -void Qt5InformationNodeInstanceServer::changeSelection(const ChangeSelectionCommand &command) -{ - if (!m_editView3DSetupDone) - return; - - m_lastSelectionChangeCommand = command; - if (m_selectionChangeTimer.isActive()) { - // If selection was recently changed by puppet, hold updating the selection for a bit to - // avoid selection flicker, especially in multiselect cases. - // Add additional time in case more commands are still coming through - m_selectionChangeTimer.start(500); - return; - } - - // Find a scene root of the selection to update active scene shown - const QVector<qint32> instanceIds = command.instanceIds(); - QVariantList selectedObjs; - QObject *firstSceneRoot = nullptr; - ServerNodeInstance firstInstance; -#ifdef QUICK3D_PARTICLES_MODULE - QList<QQuick3DParticleSystem *> selectedParticleSystems; -#endif - for (qint32 id : instanceIds) { - if (hasInstanceForId(id)) { - ServerNodeInstance instance = instanceForId(id); - QObject *sceneRoot = find3DSceneRoot(instance); - if (!firstSceneRoot && sceneRoot) { - firstSceneRoot = sceneRoot; - firstInstance = instance; - } - QObject *object = nullptr; - if (firstSceneRoot && sceneRoot == firstSceneRoot && instance.isSubclassOf("QQuick3DNode")) - object = instance.internalObject(); - -#ifdef QUICK3D_PARTICLES_MODULE - if (selectedParticleSystems.size() <= 1) { - auto particleSystem = qobject_cast<QQuick3DParticleSystem *>(instance.internalObject()); - if (!particleSystem) - particleSystem = parentParticleSystem(instance.internalObject()); - if (particleSystem && !selectedParticleSystems.contains(particleSystem)) - selectedParticleSystems.append(particleSystem); - } -#endif - auto isSelectableAsRoot = [&]() -> bool { -#ifdef QUICK3D_MODULE - if (qobject_cast<QQuick3DModel *>(object) - || qobject_cast<QQuick3DCamera *>(object) - || qobject_cast<QQuick3DAbstractLight *>(object) -#ifdef QUICK3D_PARTICLES_MODULE - || qobject_cast<QQuick3DParticleSystem *>(object) - || qobject_cast<QQuick3DParticleEmitter *>(object) - || qobject_cast<QQuick3DParticleAttractor *>(object) -#endif - ) { - return true; - } - // Node is a component if it has node children that have no instances - auto node = qobject_cast<QQuick3DNode *>(object); - if (node) { - const auto childItems = node->childItems(); - for (const auto &childItem : childItems) { - if (qobject_cast<QQuick3DNode *>(childItem) && !hasInstanceForObject(childItem)) - return true; - } - } -#endif - return false; - }; - if (object && (firstSceneRoot != object || isSelectableAsRoot())) - selectedObjs << objectToVariant(object); - } - } - -#ifdef QUICK3D_PARTICLES_MODULE - // We only support exactly one active particle systems at a time - if (selectedParticleSystems.size() == 1) - handleParticleSystemSelected(selectedParticleSystems[0]); - else - handleParticleSystemDeselected(); -#endif - - if (firstSceneRoot && m_active3DScene != firstSceneRoot) { - m_active3DScene = firstSceneRoot; - m_active3DView = findView3DForInstance(firstInstance); - updateActiveSceneToEditView3D(); - } - - // Ensure the UI has enough selection box items. If it doesn't yet have them, which can be the - // case when the first selection processed is a multiselection, we wait a bit as - // using the new boxes immediately leads to visual glitches. - int boxCount = m_editView3DData.rootItem->property("selectionBoxes").value<QVariantList>().size(); - if (boxCount < selectedObjs.size()) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "ensureSelectionBoxes", - Q_ARG(QVariant, QVariant::fromValue(selectedObjs.size()))); - m_selectionChangeTimer.start(0); - } else { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "selectObjects", - Q_ARG(QVariant, QVariant::fromValue(selectedObjs))); - } - - render3DEditView(2); -} - -void Qt5InformationNodeInstanceServer::setSceneEnvironmentColor(const PropertyValueContainer &container) -{ -#ifdef QUICK3D_MODULE - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (!helper || !hasInstanceForId(container.instanceId()) || !m_active3DView) - return; - - ServerNodeInstance sceneEnvInstance = instanceForId(container.instanceId()); - if (!sceneEnvInstance.isSubclassOf("QQuick3DSceneEnvironment")) - return; - - auto activeView = qobject_cast<QQuick3DViewport *>(m_active3DView); - if (!activeView) - return; - - QQuick3DSceneEnvironment *activeEnv = activeView->environment(); - if (activeEnv != sceneEnvInstance.internalObject()) - return; - - ServerNodeInstance activeSceneInstance = active3DSceneInstance(); - const QString sceneId = activeSceneInstance.id(); - - QColor color = container.value().value<QColor>(); - helper->setSceneEnvironmentColor(sceneId, color); - QVariantMap toolStates = helper->getToolStates(sceneId); - - if (toolStates.contains("syncBackgroundColor")) { - bool sync = toolStates["syncBackgroundColor"].toBool(); - if (sync) { - View3DActionCommand cmd(View3DActionType::SelectBackgroundColor, - QVariant::fromValue(color)); - view3DAction(cmd); - } - } -#else - Q_UNUSED(container) -#endif -} - -void Qt5InformationNodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command) -{ - bool hasDynamicProperties = false; - const QVector<PropertyValueContainer> values = command.valueChanges(); - for (const PropertyValueContainer &container : values) { - if (!container.isReflected()) { - hasDynamicProperties |= container.isDynamic(); - - if (container.name() == "clearColor") - setSceneEnvironmentColor(container); - - setInstancePropertyVariant(container); - } - } - - if (hasDynamicProperties) - refreshBindings(); - - startRenderTimer(); - - render3DEditView(); -} - -void Qt5InformationNodeInstanceServer::removeInstances(const RemoveInstancesCommand &command) -{ - int nodeCount = m_3DSceneMap.size(); - - removeRotationBlocks(command.instanceIds()); - - Qt5NodeInstanceServer::removeInstances(command); - - if (nodeCount != m_3DSceneMap.size()) { - // Some nodes were removed, which can cause scene root to change for nodes under View3D - // objects, so re-resolve scene roots. - resolveSceneRoots(); - } - - if (m_editView3DSetupDone && (!m_active3DScene || !m_active3DView)) { - if (!m_active3DScene && !m_3DSceneMap.isEmpty()) - m_active3DScene = m_3DSceneMap.begin().key(); - m_active3DView = findView3DForSceneRoot(m_active3DScene); - updateActiveSceneToEditView3D(); - } - render3DEditView(); -} - -void Qt5InformationNodeInstanceServer::inputEvent(const InputEventCommand &command) -{ - if (m_editView3DData.window) { - m_pendingInputEventCommands.append(command); - if (!m_inputEventTimer.isActive()) - m_inputEventTimer.start(0); - } -} - -void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &command) -{ - if (!m_editView3DSetupDone) - return; - - QVariantMap updatedToolState; - QVariantMap updatedViewState; - int renderCount = 1; - - switch (command.type()) { - case View3DActionType::MoveTool: - updatedToolState.insert("transformMode", 0); - break; - case View3DActionType::RotateTool: - updatedToolState.insert("transformMode", 1); - break; - case View3DActionType::ScaleTool: - updatedToolState.insert("transformMode", 2); - break; - case View3DActionType::FitToView: - QMetaObject::invokeMethod(m_editView3DData.rootItem, "fitToView"); - break; - case View3DActionType::AlignCamerasToView: - QMetaObject::invokeMethod(m_editView3DData.rootItem, "alignCamerasToView"); - break; - case View3DActionType::AlignViewToCamera: - QMetaObject::invokeMethod(m_editView3DData.rootItem, "alignViewToCamera"); - break; - case View3DActionType::SelectionModeToggle: - updatedToolState.insert("selectionMode", command.isEnabled() ? 1 : 0); - break; - case View3DActionType::CameraToggle: - updatedToolState.insert("usePerspective", command.isEnabled()); - // It can take a couple frames to properly update icon gizmo positions - renderCount = 2; - break; - case View3DActionType::OrientationToggle: - updatedToolState.insert("globalOrientation", command.isEnabled()); - break; - case View3DActionType::EditLightToggle: - updatedToolState.insert("showEditLight", command.isEnabled()); - break; - case View3DActionType::ShowGrid: - updatedToolState.insert("showGrid", command.isEnabled()); - break; - case View3DActionType::ShowSelectionBox: - updatedToolState.insert("showSelectionBox", command.isEnabled()); - break; - case View3DActionType::ShowIconGizmo: - updatedToolState.insert("showIconGizmo", command.isEnabled()); - break; - case View3DActionType::ShowCameraFrustum: - updatedToolState.insert("showCameraFrustum", command.isEnabled()); - break; - case View3DActionType::SyncBackgroundColor: - updatedToolState.insert("syncBackgroundColor", command.isEnabled()); - break; - case View3DActionType::SelectBackgroundColor: - updatedViewState.insert("selectBackgroundColor", command.value()); - break; - case View3DActionType::SelectGridColor: { - updatedViewState.insert("selectGridColor", command.value()); - break; - } -#ifdef QUICK3D_PARTICLES_MODULE - case View3DActionType::ShowParticleEmitter: - updatedToolState.insert("showParticleEmitter", command.isEnabled()); - break; - case View3DActionType::ParticlesPlay: - m_particleAnimationPlaying = command.isEnabled(); - updatedToolState.insert("particlePlay", command.isEnabled()); - if (m_particleAnimationPlaying) { - m_particleAnimationDriver->play(); - m_particleAnimationDriver->setSeekerEnabled(false); - m_particleAnimationDriver->setSeekerPosition(0); - } else { - m_particleAnimationDriver->pause(); - m_particleAnimationDriver->setSeekerEnabled(true); - } - break; - case View3DActionType::ParticlesRestart: - resetParticleSystem(); - if (m_particleAnimationPlaying) { - m_particleAnimationDriver->restart(); - m_particleAnimationDriver->setSeekerEnabled(false); - m_particleAnimationDriver->setSeekerPosition(0); - } - break; - case View3DActionType::ParticlesSeek: - m_particleAnimationDriver->setSeekerPosition(command.position()); - break; -#endif -#ifdef QUICK3D_MODULE - case View3DActionType::GetNodeAtPos: { - getNodeAtPos(command.value().toPointF()); - return; - } -#endif - - default: - break; - } - - if (!updatedToolState.isEmpty()) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateToolStates", - Q_ARG(QVariant, updatedToolState), - Q_ARG(QVariant, QVariant::fromValue(false))); - } - - if (!updatedViewState.isEmpty()) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateViewStates", - Q_ARG(QVariant, updatedViewState)); - } - - render3DEditView(renderCount); -} - -void Qt5InformationNodeInstanceServer::requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command) -{ - m_modelNodePreviewImageCommands.insert(command); - renderModelNodeImageView(); -} - -void Qt5InformationNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) -{ - updateRotationBlocks(command.auxiliaryChanges); - updateMaterialPreviewData(command.auxiliaryChanges); - Qt5NodeInstanceServer::changeAuxiliaryValues(command); - render3DEditView(); -} - -void Qt5InformationNodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &command) -{ - Qt5NodeInstanceServer::changePropertyBindings(command); - render3DEditView(); -} - -void Qt5InformationNodeInstanceServer::changeIds(const ChangeIdsCommand &command) -{ - Qt5NodeInstanceServer::changeIds(command); - -#ifdef QUICK3D_MODULE - if (m_editView3DSetupDone) { - ServerNodeInstance sceneInstance = active3DSceneInstance(); - if (m_activeSceneIdUpdateTimer.isActive()) { - const QString sceneId = sceneInstance.id(); - if (!sceneId.isEmpty()) - updateActiveSceneToEditView3D(); - } else { - qint32 sceneInstanceId = sceneInstance.instanceId(); - for (const auto &id : command.ids) { - if (sceneInstanceId == id.instanceId()) { - QMetaObject::invokeMethod(m_editView3DData.rootItem, "handleActiveSceneIdChange", - Qt::QueuedConnection, - Q_ARG(QVariant, QVariant(sceneInstance.id()))); - render3DEditView(); - break; - } - } - } - } -#endif -} - -void Qt5InformationNodeInstanceServer::changeState(const ChangeStateCommand &command) -{ - Qt5NodeInstanceServer::changeState(command); - - render3DEditView(); -} - -void Qt5InformationNodeInstanceServer::removeProperties(const RemovePropertiesCommand &command) -{ - Qt5NodeInstanceServer::removeProperties(command); - - render3DEditView(); -} - -void Qt5InformationNodeInstanceServer::handleInstanceLocked( - [[maybe_unused]] const ServerNodeInstance &instance, - [[maybe_unused]] bool enable, - [[maybe_unused]] bool checkAncestors) -{ -#ifdef QUICK3D_MODULE - if (!ViewConfig::isQuick3DMode()) - return; - - bool edit3dLocked = enable; - if (!edit3dLocked || checkAncestors) { - auto parentInst = instance.parent(); - while (!edit3dLocked && parentInst.isValid()) { - edit3dLocked = parentInst.internalInstance()->isLockedInEditor(); - parentInst = parentInst.parent(); - } - } - - QObject *obj = instance.internalObject(); - auto node = qobject_cast<QQuick3DNode *>(obj); - if (node) { - node->setProperty("_edit3dLocked", edit3dLocked); - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) - emit helper->lockedStateChanged(node); - } - const auto children = obj->children(); - for (auto child : children) { - if (hasInstanceForObject(child)) { - const ServerNodeInstance childInstance = instanceForObject(child); - if (childInstance.isValid()) { - auto objInstance = childInstance.internalInstance(); - // Don't override explicit lock on children - handleInstanceLocked(childInstance, edit3dLocked || objInstance->isLockedInEditor(), false); - } - } - } -#endif -} - -void Qt5InformationNodeInstanceServer::handleInstanceHidden( - [[maybe_unused]] const ServerNodeInstance &instance, - [[maybe_unused]] bool enable, - [[maybe_unused]] bool checkAncestors) -{ -#ifdef QUICK3D_MODULE - if (!ViewConfig::isQuick3DMode()) - return; - - bool edit3dHidden = enable; - if (!edit3dHidden || checkAncestors) { - // We do not care about hidden status of non-3D ancestor nodes, as the 3D scene - // can be considered a separate visual entity in the whole scene. - auto parentInst = instance.parent(); - while (!edit3dHidden && parentInst.isValid() && qobject_cast<QQuick3DNode *>(parentInst.internalObject())) { - edit3dHidden = parentInst.internalInstance()->isHiddenInEditor(); - parentInst = parentInst.parent(); - } - } - - auto node = qobject_cast<QQuick3DNode *>(instance.internalObject()); - if (node) { - bool isInstanceHidden = false; - auto getQuick3DInstanceAndHidden = [this, &isInstanceHidden](QQuick3DObject *obj) -> ServerNodeInstance { - if (hasInstanceForObject(obj)) { - const ServerNodeInstance instance = instanceForObject(obj); - if (instance.isValid() && qobject_cast<QQuick3DNode *>(instance.internalObject())) { - auto objInstance = instance.internalInstance(); - isInstanceHidden = objInstance->isHiddenInEditor(); - return instance; - } - } - return {}; - }; - // Always make sure the hide status is correct on the node tree from this point on, - // as changes in the node tree (reparenting, adding new nodes) can make the previously set - // hide status based on ancestor unreliable. - node->setProperty("_edit3dHidden", edit3dHidden); - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) - emit helper->hiddenStateChanged(node); -#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1) - if (auto model = qobject_cast<QQuick3DModel *>(node)) - model->setPickable(!edit3dHidden); // allow 3D objects to receive mouse clicks -#endif - const auto childItems = node->childItems(); - for (auto childItem : childItems) { - const ServerNodeInstance quick3dInstance = getQuick3DInstanceAndHidden(childItem); - if (quick3dInstance.isValid()) { - // Don't override explicit hide in children - handleInstanceHidden(quick3dInstance, edit3dHidden || isInstanceHidden, false); - } else { -#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1) - // Children of components do not have instances, but will still need to be pickable - std::function<void(QQuick3DNode *)> checkChildren; - checkChildren = [&](QQuick3DNode *checkNode) { - const auto childItems = checkNode->childItems(); - for (auto child : childItems) { - if (auto childNode = qobject_cast<QQuick3DNode *>(child)) - checkChildren(childNode); - } - if (auto checkModel = qobject_cast<QQuick3DModel *>(checkNode)) { - QVariant value; - if (!edit3dHidden) - value = QVariant::fromValue(node); - // Specify the actual pick target with dynamic property - checkModel->setProperty("_pickTarget", value); - checkModel->setPickable(!edit3dHidden); - } else { - auto checkRepeater = qobject_cast<QQuick3DRepeater *>(checkNode); - auto checkLoader = qobject_cast<QQuick3DLoader *>(checkNode); -#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0) - auto checkRunLoader = qobject_cast<QQuick3DRuntimeLoader *>(checkNode); - if (checkRepeater || checkLoader || checkRunLoader) { -#else - if (checkRepeater || checkLoader) { -#endif - // Repeaters/loaders may not yet have created their children, so we set - // _pickTarget on them and connect the notifier. - if (checkNode->property("_pickTarget").isNull()) { - if (checkRepeater) { - QObject::connect(checkRepeater, &QQuick3DRepeater::objectAdded, - this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); -#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0) - } else if (checkRunLoader) { - QObject::connect(checkRunLoader, &QQuick3DRuntimeLoader::statusChanged, - this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); -#endif - } else { - QObject::connect(checkLoader, &QQuick3DLoader::loaded, - this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); - } - } - checkNode->setProperty("_pickTarget", QVariant::fromValue(node)); - } - } - }; - if (auto childNode = qobject_cast<QQuick3DNode *>(childItem)) - checkChildren(childNode); -#endif - } - } - } -#endif -} - -void Qt5InformationNodeInstanceServer::handlePickTarget( - [[maybe_unused]] const ServerNodeInstance &instance) -{ -#if defined(QUICK3D_MODULE) && (QT_VERSION >= QT_VERSION_CHECK(6, 2, 1)) - // Picking is dependent on hidden status prior to global picking support (<6.2.1), so it is - // handled in handleInstanceHidden() method in those builds - - if (!ViewConfig::isQuick3DMode()) - return; - - QObject *obj = instance.internalObject(); - QList<QQuick3DObject *> childItems; - if (auto node = qobject_cast<QQuick3DNode *>(obj)) { - childItems = node->childItems(); - } else if (auto view = qobject_cast<QQuick3DViewport *>(obj)) { - // We only need to handle views that are components - // View is a component if its scene is not an instance and scene has node children that - // have no instances - QQuick3DNode *node = view->scene(); - if (node) { - if (hasInstanceForObject(node)) - return; - childItems = node->childItems(); - bool allHaveInstance = true; - for (const auto &childItem : childItems) { - if (qobject_cast<QQuick3DNode *>(childItem) && !hasInstanceForObject(childItem)) { - allHaveInstance = false; - break; - } - } - if (allHaveInstance) - return; - } - } else { - return; - } - - for (auto childItem : std::as_const(childItems)) { - if (!hasInstanceForObject(childItem)) { - // Children of components do not have instances, but will still need to be pickable - // and redirect their pick to the component - std::function<void(QQuick3DNode *)> checkChildren; - checkChildren = [&](QQuick3DNode *checkNode) { - const auto childItems = checkNode->childItems(); - for (auto child : childItems) { - if (auto childNode = qobject_cast<QQuick3DNode *>(child)) - checkChildren(childNode); - } - if (auto checkModel = qobject_cast<QQuick3DModel *>(checkNode)) { - // Specify the actual pick target with dynamic property - checkModel->setProperty("_pickTarget", QVariant::fromValue(obj)); - } else { - auto checkRepeater = qobject_cast<QQuick3DRepeater *>(checkNode); - auto checkLoader = qobject_cast<QQuick3DLoader *>(checkNode); -#if defined(QUICK3D_ASSET_UTILS_MODULE) - auto checkRunLoader = qobject_cast<QQuick3DRuntimeLoader *>(checkNode); - if (checkRepeater || checkLoader || checkRunLoader) { -#else - if (checkRepeater || checkLoader) { -#endif - // Repeaters/loaders may not yet have created their children, so we set - // _pickTarget on them and connect the notifier. - if (checkNode->property("_pickTarget").isNull()) { - if (checkRepeater) { - QObject::connect(checkRepeater, &QQuick3DRepeater::objectAdded, - this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); -#if defined(QUICK3D_ASSET_UTILS_MODULE) - } else if (checkRunLoader) { - QObject::connect(checkRunLoader, &QQuick3DRuntimeLoader::statusChanged, - this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); -#endif - } else { - QObject::connect(checkLoader, &QQuick3DLoader::loaded, - this, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); - } - } - checkNode->setProperty("_pickTarget", QVariant::fromValue(obj)); - } - } - }; - if (auto childNode = qobject_cast<QQuick3DNode *>(childItem)) - checkChildren(childNode); - } - } -#endif -} - -bool Qt5InformationNodeInstanceServer::isInformationServer() const -{ - return true; -} - -// This method should be connected to signals indicating a new object has been constructed outside -// normal scene creation. E.g. QQuick3DRepeater::objectAdded. -void Qt5InformationNodeInstanceServer::handleDynamicAddObject() -{ - m_dynamicObjectConstructors.insert(sender()); - m_dynamicAddObjectTimer.start(); -} - -// update 3D view size when it changes in creator side -void Qt5InformationNodeInstanceServer::update3DViewState( - [[maybe_unused]] const Update3dViewStateCommand &command) -{ -#ifdef QUICK3D_MODULE - if (command.type() == Update3dViewStateCommand::SizeChange) { - if (m_editView3DSetupDone) { - m_editView3DData.rootItem->setSize(command.size()); -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - m_editView3DData.window->contentItem()->setSize(m_editView3DData.rootItem->size()); - m_editView3DData.window->setGeometry(0, 0, m_editView3DData.rootItem->width(), - m_editView3DData.rootItem->height()); - m_editView3DData.bufferDirty = true; -#endif - auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper); - if (helper) - helper->storeToolState(helper->globalStateId(), helper->rootSizeKey(), QVariant(command.size()), 0); - // Queue two renders to make sure all gizmos update properly - render3DEditView(2); - } - } -#endif -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h deleted file mode 100644 index 2099c184d9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5informationnodeinstanceserver.h +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "qt5nodeinstanceserver.h" -#include "tokencommand.h" -#include "valueschangedcommand.h" -#include "changeselectioncommand.h" -#include "requestmodelnodepreviewimagecommand.h" -#include "propertybindingcontainer.h" -#include "propertyabstractcontainer.h" -#include "animationdriver.h" - -#ifdef QUICK3D_PARTICLES_MODULE -#include <QtQuick3DParticles/private/qquick3dparticlesystem_p.h> -#endif - -#include <QTimer> -#include <QElapsedTimer> -#include <QVariant> -#include <QPointer> -#include <QImage> -#include <QUrl> - -QT_BEGIN_NAMESPACE -class QDragMoveEvent; -QT_END_NAMESPACE - -namespace QmlDesigner { - -class Qt5InformationNodeInstanceServer : public Qt5NodeInstanceServer -{ - Q_OBJECT - -public: - explicit Qt5InformationNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); - ~Qt5InformationNodeInstanceServer() override; - - void reparentInstances(const ReparentInstancesCommand &command) override; - void clearScene(const ClearSceneCommand &command) override; - void update3DViewState(const Update3dViewStateCommand &command) override; - void createScene(const CreateSceneCommand &command) override; - void completeComponent(const CompleteComponentCommand &command) override; - void token(const TokenCommand &command) override; - void removeSharedMemory(const RemoveSharedMemoryCommand &command) override; - void changeSelection(const ChangeSelectionCommand &command) override; - void changePropertyValues(const ChangeValuesCommand &command) override; - void removeInstances(const RemoveInstancesCommand &command) override; - void inputEvent(const InputEventCommand &command) override; - void view3DAction(const View3DActionCommand &command) override; - void requestModelNodePreviewImage(const RequestModelNodePreviewImageCommand &command) override; - void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) override; - void changePropertyBindings(const ChangeBindingsCommand &command) override; - void changeIds(const ChangeIdsCommand &command) override; - void changeState(const ChangeStateCommand &command) override; - void removeProperties(const RemovePropertiesCommand &command) override; - - void handleInstanceLocked(const ServerNodeInstance &instance, bool enable, bool checkAncestors) override; - void handleInstanceHidden(const ServerNodeInstance &instance, bool enable, bool checkAncestors) override; - void handlePickTarget(const ServerNodeInstance &instance) override; - - bool isInformationServer() const override; - void handleDynamicAddObject(); - -private slots: - void handleSelectionChanged(const QVariant &objs); - void handleObjectPropertyCommit(const QVariant &objects, const QVariant &propNames); - void handleObjectPropertyChange(const QVariant &objects, const QVariant &propNames); - void handleActiveSceneChange(); - void handleToolStateChanged(const QString &sceneId, const QString &tool, - const QVariant &toolState); - void handleView3DSizeChange(); - void handleView3DDestroyed(QObject *obj); - void handleNode3DDestroyed(QObject *obj); - -protected: - void collectItemChangesAndSendChangeCommands() override; - void sendChildrenChangedCommand(const QList<ServerNodeInstance> &childList); - void sendTokenBack(); - bool isDirtyRecursiveForNonInstanceItems(QQuickItem *item) const; - bool isDirtyRecursiveForParentInstances(QQuickItem *item) const; - void selectInstances(const QList<ServerNodeInstance> &instanceList); - void modifyProperties(const QVector<InstancePropertyValueTriple> &properties); - QList<ServerNodeInstance> createInstances(const QVector<InstanceContainer> &container) override; - void initializeAuxiliaryViews() override; - -private: - void handleObjectPropertyChangeTimeout(); - void handleSelectionChangeTimeout(); - void handleDynamicAddObjectTimeout(); - void createEditView3D(); - void create3DPreviewView(); - void setup3DEditView(const QList<ServerNodeInstance> &instanceList, - const CreateSceneCommand &command); - void createCameraAndLightGizmos(const QList<ServerNodeInstance> &instanceList) const; - void add3DViewPorts(const QList<ServerNodeInstance> &instanceList); - void add3DScenes(const QList<ServerNodeInstance> &instanceList); - QObject *findView3DForInstance(const ServerNodeInstance &instance) const; - QObject *findView3DForSceneRoot(QObject *sceneRoot) const; - QObject *find3DSceneRoot(const ServerNodeInstance &instance) const; - QObject *find3DSceneRoot(QObject *obj) const; - QVector<InstancePropertyValueTriple> propertyToPropertyValueTriples( - const ServerNodeInstance &instance, - const PropertyName &propertyName, - const QVariant &variant); - void modifyVariantValue(const QObjectList &objects, - const QList<PropertyName> &propNames, - ValuesModifiedCommand::TransactionOption option); - void updateView3DRect(QObject *view3D); - void updateActiveSceneToEditView3D(bool timerCall = false); - void removeNode3D(QObject *node); - void resolveSceneRoots(); - ServerNodeInstance active3DSceneInstance() const; - void updateNodesRecursive(QQuickItem *item); - QQuickItem *getContentItemForRendering(QQuickItem *rootItem); - void render3DEditView(int count = 1); - void doRender3DEditView(); - void renderModelNodeImageView(); - void doRenderModelNodeImageView(); - void doRenderModelNode3DImageView(const RequestModelNodePreviewImageCommand &cmd); - void doRenderModelNode2DImageView(const RequestModelNodePreviewImageCommand &cmd); - void updateLockedAndHiddenStates(const QSet<ServerNodeInstance> &instances); - void handleInputEvents(); - void resolveImportSupport(); - void updateMaterialPreviewData(const QVector<PropertyValueContainer> &valueChanges); - void updateRotationBlocks(const QVector<PropertyValueContainer> &valueChanges); - void removeRotationBlocks(const QVector<qint32> &instanceIds); - void getNodeAtPos(const QPointF &pos); - - void createAuxiliaryQuickView(const QUrl &url, RenderViewData &viewData); -#ifdef QUICK3D_PARTICLES_MODULE - void handleParticleSystemSelected(QQuick3DParticleSystem* targetParticleSystem); - void resetParticleSystem(); - void handleParticleSystemDeselected(); -#endif - void setSceneEnvironmentColor(const PropertyValueContainer &container); - - RenderViewData m_editView3DData; - RenderViewData m_modelNode3DImageViewData; - RenderViewData m_modelNode2DImageViewData; - - bool m_editView3DSetupDone = false; - QSet<RequestModelNodePreviewImageCommand> m_modelNodePreviewImageCommands; - QHash<QString, QImage> m_modelNodePreviewImageCache; - QSet<QObject *> m_view3Ds; - QMultiHash<QObject *, QObject *> m_3DSceneMap; // key: scene root, value: node - QObject *m_active3DView = nullptr; - QList<QObject *> m_priorityView3DsToRender; - QObject *m_active3DScene = nullptr; - QSet<ServerNodeInstance> m_parentChangedSet; - QList<ServerNodeInstance> m_completedComponentList; - QList<TokenCommand> m_tokenList; - QTimer m_propertyChangeTimer; - QTimer m_selectionChangeTimer; - QTimer m_render3DEditViewTimer; - QTimer m_renderModelNodeImageViewTimer; - QTimer m_inputEventTimer; - QTimer m_dynamicAddObjectTimer; - QTimer m_activeSceneIdUpdateTimer; -#ifdef QUICK3D_PARTICLES_MODULE - bool m_particleAnimationPlaying = true; - AnimationDriver *m_particleAnimationDriver = nullptr; - QMetaObject::Connection m_particleAnimationConnection; - QQuick3DParticleSystem* m_targetParticleSystem = nullptr; -#endif - QObjectList m_changedNodes; - QList<PropertyName> m_changedProperties; - ChangeSelectionCommand m_lastSelectionChangeCommand; - QList<InputEventCommand> m_pendingInputEventCommands; - QObject *m_3dHelper = nullptr; - int m_need3DEditViewRender = 0; - QSet<QObject *> m_dynamicObjectConstructors; - - struct PreviewData { - QString env; - QString envValue; - QString model; - }; - PreviewData m_materialPreviewData; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp deleted file mode 100644 index bc0f782162..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.cpp +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5nodeinstanceclientproxy.h" - -#include <QCoreApplication> - -#include "capturenodeinstanceserverdispatcher.h" -#include "qt5captureimagenodeinstanceserver.h" -#include "qt5capturepreviewnodeinstanceserver.h" -#include "qt5informationnodeinstanceserver.h" -#include "qt5previewnodeinstanceserver.h" -#include "qt5rendernodeinstanceserver.h" -#include "qt5testnodeinstanceserver.h" -#include "quickitemnodeinstance.h" - -#if defined(Q_OS_UNIX) -#include <unistd.h> -#elif defined(Q_OS_WIN) -#include <windows.h> -#endif - -namespace QmlDesigner { -static void prioritizeDown() -{ -#if defined(Q_OS_UNIX) - nice(19); -#elif defined(Q_OS_WIN) - SetPriorityClass(GetCurrentProcess(), BELOW_NORMAL_PRIORITY_CLASS); -#endif -} - -Qt5NodeInstanceClientProxy::Qt5NodeInstanceClientProxy(QObject *parent) : - NodeInstanceClientProxy(parent) -{ - prioritizeDown(); - - const bool unifiedRenderPath = qEnvironmentVariableIsSet("QMLPUPPET_UNIFIED_RENDER_PATH"); - - if (unifiedRenderPath) - Internal::QuickItemNodeInstance::enableUnifiedRenderPath(true); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - else - DesignerSupport::activateDesignerWindowManager(); -#endif - - if (QCoreApplication::arguments().at(1) == QLatin1String("--readcapturedstream")) { - qputenv("DESIGNER_DONT_USE_SHARED_MEMORY", "1"); - setNodeInstanceServer(std::make_unique<Qt5TestNodeInstanceServer>(this)); - initializeCapturedStream(QCoreApplication::arguments().at(2)); - readDataStream(); - QCoreApplication::exit(); - } else if (QCoreApplication::arguments().at(2).contains(',')) { - const QStringList serverNames = QCoreApplication::arguments().at(2).split(','); - setNodeInstanceServer(std::make_unique<CaptureNodeInstanceServerDispatcher>(serverNames, this)); - initializeSocket(); - } else if (QCoreApplication::arguments().at(2) == QLatin1String("previewmode")) { - setNodeInstanceServer(std::make_unique<Qt5PreviewNodeInstanceServer>(this)); - initializeSocket(); - } else if (QCoreApplication::arguments().at(2) == QLatin1String("editormode")) { - ViewConfig::enableParticleView(true); - setNodeInstanceServer(std::make_unique<Qt5InformationNodeInstanceServer>(this)); - initializeSocket(); - } else if (QCoreApplication::arguments().at(2) == QLatin1String("rendermode")) { - setNodeInstanceServer(std::make_unique<Qt5RenderNodeInstanceServer>(this)); - initializeSocket(); - } else if (QCoreApplication::arguments().at(2) == QLatin1String("capturemode")) { - setNodeInstanceServer(std::make_unique<Qt5CapturePreviewNodeInstanceServer>(this)); - initializeSocket(); - } else if (QCoreApplication::arguments().at(2) == QLatin1String("captureiconmode")) { - setNodeInstanceServer(std::make_unique<Qt5CaptureImageNodeInstanceServer>(this)); - initializeSocket(); - } -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.h deleted file mode 100644 index ac5d888311..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceclientproxy.h +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "nodeinstanceclientproxy.h" - -namespace QmlDesigner { - -class Qt5NodeInstanceClientProxy : public NodeInstanceClientProxy -{ - Q_OBJECT -public: - explicit Qt5NodeInstanceClientProxy(QObject *parent = nullptr); -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp deleted file mode 100644 index c7bf859daa..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.cpp +++ /dev/null @@ -1,531 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5nodeinstanceserver.h" - -#include <QSurfaceFormat> - -#include <QQmlFileSelector> - -#include <QQuickItem> -#include <QQuickView> -#include <QQuickWindow> - -#include <private/qquickdesignersupport_p.h> -#include <addimportcontainer.h> -#include <createscenecommand.h> -#include <reparentinstancescommand.h> -#include <clearscenecommand.h> - -// Nanotrace headers are not exported to build dir at all if the feature is disabled, so -// runtime puppet build can't find them. -#if NANOTRACE_ENABLED -#include "nanotrace/nanotrace.h" -#else -#define NANOTRACE_SCOPE(cat, name) -#endif - -#include <QDebug> -#include <QOpenGLContext> - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -#include <QtGui/private/qrhi_p.h> -#include <QtQuick/private/qquickitem_p.h> -#include <QtQuick/private/qquickrendercontrol_p.h> -#include <QtQuick/private/qquickrendertarget_p.h> -#include <QtQuick/private/qquickwindow_p.h> -#include <QtQuick/private/qsgcontext_p.h> -#include <QtQuick/private/qsgrenderer_p.h> -#include <QtQuick/private/qsgrhilayer_p.h> -#else -#include <QtQuick/private/qquickitem_p.h> -#endif - -namespace QmlDesigner { - -Qt5NodeInstanceServer::Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) - : NodeInstanceServer(nodeInstanceClient) -{ - if (!ViewConfig::isParticleViewMode()) - QQuickDesignerSupport::activateDesignerMode(); -} - -Qt5NodeInstanceServer::~Qt5NodeInstanceServer() -{ - NodeInstanceServer::clearScene({}); - delete m_viewData.window.data(); -} - -QQuickView *Qt5NodeInstanceServer::quickView() const -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - return static_cast<QQuickView *>(m_viewData.window.data()); -#else - return nullptr; -#endif -} - -QQuickWindow *Qt5NodeInstanceServer::quickWindow() const -{ - return m_viewData.window.data(); -} - -void Qt5NodeInstanceServer::initializeView() -{ - Q_ASSERT(!quickWindow()); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - auto view = new QQuickView; - m_viewData.window = view; - /* enables grab window without show */ - QSurfaceFormat surfaceFormat = view->requestedFormat(); - surfaceFormat.setVersion(4, 1); - surfaceFormat.setProfile(QSurfaceFormat::CoreProfile); - QSurfaceFormat::setDefaultFormat(surfaceFormat); - view->setFormat(surfaceFormat); - - QQuickDesignerSupport::createOpenGLContext(view); - m_qmlEngine = view->engine(); -#else - m_viewData.renderControl = new QQuickRenderControl; - m_viewData.window = new QQuickWindow(m_viewData.renderControl); - m_viewData.renderControl->initialize(); - m_qmlEngine = new QQmlEngine; -#endif - - if (qEnvironmentVariableIsSet("QML_FILE_SELECTORS")) { - QQmlFileSelector *fileSelector = new QQmlFileSelector(engine(), engine()); - QStringList customSelectors = QString::fromUtf8(qgetenv("QML_FILE_SELECTORS")).split(','); - fileSelector->setExtraSelectors(customSelectors); - } - - initializeAuxiliaryViews(); -} - -QQmlView *Qt5NodeInstanceServer::declarativeView() const -{ - return nullptr; -} - -QQuickItem *Qt5NodeInstanceServer::rootItem() const -{ - return m_viewData.rootItem; -} - -void Qt5NodeInstanceServer::setRootItem(QQuickItem *item) -{ - m_viewData.rootItem = item; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QQuickDesignerSupport::setRootItem(quickView(), item); -#else - quickWindow()->setGeometry(0, 0, item->width(), item->height()); - // Insert an extra item above the root to adjust root item position to 0,0 to make entire - // item to be always rendered. - if (!m_viewData.contentItem) - m_viewData.contentItem = new QQuickItem(quickWindow()->contentItem()); - m_viewData.contentItem->setPosition(-item->position()); - item->setParentItem(m_viewData.contentItem); -#endif -} - -QQmlEngine *Qt5NodeInstanceServer::engine() const -{ - return m_qmlEngine; -} - -void Qt5NodeInstanceServer::resizeCanvasToRootItem() -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - m_viewData.bufferDirty = true; - if (m_viewData.contentItem) - m_viewData.contentItem->setPosition(-m_viewData.rootItem->position()); -#endif - quickWindow()->resize(rootNodeInstance().boundingRect().size().toSize()); - QQuickDesignerSupport::addDirty(rootNodeInstance().rootQuickItem(), QQuickDesignerSupport::Size); -} - -void Qt5NodeInstanceServer::resetAllItems() -{ - foreach (QQuickItem *item, allItems()) - QQuickDesignerSupport::resetDirty(item); -} - -void Qt5NodeInstanceServer::setupScene(const CreateSceneCommand &command) -{ - setupMockupTypes(command.mockupTypes); - setupFileUrl(command.fileUrl); - setupImports(command.imports); - setupDummyData(command.fileUrl); - - setupInstances(command); - resizeCanvasToRootItem(); -} - -QList<QQuickItem*> subItems(QQuickItem *parentItem) -{ - QList<QQuickItem*> itemList; - itemList.append(parentItem->childItems()); - - foreach (QQuickItem *childItem, parentItem->childItems()) - itemList.append(subItems(childItem)); - - return itemList; -} - -QList<QQuickItem*> Qt5NodeInstanceServer::allItems() const -{ - if (rootNodeInstance().isValid()) - return rootNodeInstance().allItemsRecursive(); - - return QList<QQuickItem*>(); -} - -bool Qt5NodeInstanceServer::rootIsRenderable3DObject() const -{ - return rootNodeInstance().isSubclassOf("QQuick3DNode") - || rootNodeInstance().isSubclassOf("QQuick3DMaterial"); -} - -bool Qt5NodeInstanceServer::initRhi([[maybe_unused]] RenderViewData &viewData) -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!viewData.renderControl) { - qWarning() << __FUNCTION__ << "Render control not created"; - return false; - } - - if (!viewData.rhi) { - QQuickRenderControlPrivate *rd = QQuickRenderControlPrivate::get(viewData.renderControl); - viewData.rhi = rd->rhi; - - if (!viewData.rhi) { - qWarning() << __FUNCTION__ << "Rhi is null"; - return false; - } - } - - auto cleanRhiResources = [&viewData]() { - // Releasing cached resources is a workaround for bug QTBUG-88761 - auto renderer = QQuickWindowPrivate::get(viewData.window)->renderer; - if (renderer) - renderer->releaseCachedResources(); - - if (viewData.rpDesc) { - viewData.rpDesc->deleteLater(); - viewData.rpDesc = nullptr; - } - if (viewData.texTarget) { - viewData.texTarget->deleteLater(); - viewData.texTarget = nullptr; - } - if (viewData.buffer) { - viewData.buffer->deleteLater(); - viewData.buffer = nullptr; - } - if (viewData.texture) { - viewData.texture->deleteLater(); - viewData.texture = nullptr; - } - }; - if (viewData.bufferDirty) - cleanRhiResources(); - - QSize size = viewData.window->size(); - if (size.isNull()) - size = QSize(2, 2); // Zero size buffer creation will fail, so make it some size always - - viewData.texture = viewData.rhi->newTexture(QRhiTexture::RGBA8, size, 1, - QRhiTexture::RenderTarget | QRhiTexture::UsedAsTransferSource); - if (!viewData.texture->create()) { - qWarning() << __FUNCTION__ << "QRhiTexture creation failed"; - cleanRhiResources(); - return false; - } - - viewData.buffer = viewData.rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, size, 1); - if (!viewData.buffer->create()) { - qWarning() << __FUNCTION__ << "Depth/stencil buffer creation failed"; - cleanRhiResources(); - return false; - } - - QRhiTextureRenderTargetDescription rtDesc(QRhiColorAttachment(viewData.texture)); - rtDesc.setDepthStencilBuffer(viewData.buffer); - viewData.texTarget = viewData.rhi->newTextureRenderTarget(rtDesc); - viewData.rpDesc = viewData.texTarget->newCompatibleRenderPassDescriptor(); - viewData.texTarget->setRenderPassDescriptor(viewData.rpDesc); - if (!viewData.texTarget->create()) { - qWarning() << __FUNCTION__ << "Texture render target creation failed"; - cleanRhiResources(); - return false; - } - - // redirect Qt Quick rendering into our texture - viewData.window->setRenderTarget(QQuickRenderTarget::fromRhiRenderTarget(viewData.texTarget)); - - viewData.bufferDirty = false; -#endif - return true; -} - -QImage Qt5NodeInstanceServer::grabRenderControl([[maybe_unused]] RenderViewData &viewData) -{ - NANOTRACE_SCOPE("Update", "GrabRenderControl"); - - QImage renderImage; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (viewData.bufferDirty && !initRhi(viewData)) - return renderImage; - - viewData.renderControl->polishItems(); - viewData.renderControl->beginFrame(); - viewData.renderControl->sync(); - viewData.renderControl->render(); - - bool readCompleted = false; - QRhiReadbackResult readResult; - readResult.completed = [&] { - readCompleted = true; - QImage wrapperImage(reinterpret_cast<const uchar *>(readResult.data.constData()), - readResult.pixelSize.width(), readResult.pixelSize.height(), - QImage::Format_RGBA8888_Premultiplied); - if (viewData.rhi->isYUpInFramebuffer()) - renderImage = wrapperImage.mirrored(); - else - renderImage = wrapperImage.copy(); - }; - QRhiResourceUpdateBatch *readbackBatch = viewData.rhi->nextResourceUpdateBatch(); - readbackBatch->readBackTexture(viewData.texture, &readResult); - - QQuickRenderControlPrivate *rd = QQuickRenderControlPrivate::get(viewData.renderControl); - rd->cb->resourceUpdate(readbackBatch); - - viewData.renderControl->endFrame(); -#endif - return renderImage; -} - -// This method simply renders the window without grabbing it -bool Qt5NodeInstanceServer::renderWindow() -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!m_viewData.rootItem || (m_viewData.bufferDirty && !initRhi(m_viewData))) - return false; - - m_viewData.renderControl->polishItems(); - m_viewData.renderControl->beginFrame(); - m_viewData.renderControl->sync(); - m_viewData.renderControl->render(); - m_viewData.renderControl->endFrame(); - return true; -#endif - return false; -} - -QImage Qt5NodeInstanceServer::grabWindow() -{ - if (m_viewData.rootItem) - return grabRenderControl(m_viewData); - return {}; -} - -static bool hasEffect(QQuickItem *item) -{ - QQuickItemPrivate *pItem = QQuickItemPrivate::get(item); - return pItem && pItem->layer() && pItem->layer()->enabled() && pItem->layer()->effect(); -} - -QQuickItem *Qt5NodeInstanceServer::parentEffectItem(QQuickItem *item) -{ - QQuickItem *parent = item->parentItem(); - while (parent) { - if (hasEffect(parent)) - return parent; - parent = parent->parentItem(); - } - return nullptr; -} - -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -static bool isEffectItem(QQuickItem *item, QQuickShaderEffectSource *sourceItem) -{ - QQuickItemPrivate *pItem = QQuickItemPrivate::get(sourceItem); - - if (!pItem || !pItem->layer()) - return false; - - const auto propName = pItem->layer()->name(); - - QQmlProperty prop(item, QString::fromLatin1(propName)); - if (!prop.isValid()) - return false; - - return prop.read().value<QQuickShaderEffectSource *>() == sourceItem; -} - -static bool isLayerEnabled(QQuickItemPrivate *item) -{ - return item && item->layer() && item->layer()->enabled(); -} -#endif // QT_VERSION check - -QImage Qt5NodeInstanceServer::grabItem([[maybe_unused]] QQuickItem *item) -{ - QImage renderImage; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!m_viewData.rootItem || (m_viewData.bufferDirty && !initRhi(m_viewData))) - return {}; - - QQuickItemPrivate *pItem = QQuickItemPrivate::get(item); - - const bool renderEffects = qEnvironmentVariableIsSet("QMLPUPPET_RENDER_EFFECTS"); - const bool smoothRendering = qEnvironmentVariableIsSet("QMLPUPPET_SMOOTH_RENDERING"); - - if (renderEffects) { - if (parentEffectItem(item)) - return renderImage; - - // Effects are actually implemented as a separate item we have to find first - if (hasEffect(item)) { - if (auto parent = item->parentItem()) { - const auto siblings = parent->childItems(); - for (auto sibling : siblings) { - if (isEffectItem(sibling, pItem->layer()->effectSource())) - return grabItem(sibling); - } - } - } - } - - if (!isLayerEnabled(pItem)) - pItem->refFromEffectItem(false); - - ServerNodeInstance instance; - if (hasInstanceForObject(item)) - instance = instanceForObject(item); - - const bool rootIs3DObject = rootIsRenderable3DObject(); - - // Setting layer enabled to false messes up the bounding rect. - // Therefore we calculate it upfront. - QRectF renderBoundingRect; - if (instance.isValid()) - renderBoundingRect = instance.boundingRect(); - else if (rootIs3DObject) - renderBoundingRect = item->boundingRect(); - else - renderBoundingRect = ServerNodeInstance::effectAdjustedBoundingRect(item); - - const int scaleFactor = (smoothRendering && !rootIs3DObject) ? 2 : 1; - - // Hide immediate children that have instances and are QQuickItems so we get only - // the parent item's content, as compositing is handled on creator side. - QSet<QQuickItem *> layerChildren; - - if (instance.isValid()) { //Not valid for effect - const auto childInstances = instance.childItems(); - for (const auto &childInstance : childInstances) { - QQuickItem *childItem = qobject_cast<QQuickItem *>(childInstance.internalObject()); - if (childItem) { - QQuickItemPrivate *pChild = QQuickItemPrivate::get(childItem); - if (pChild->layer() && pChild->layer()->enabled()) { - layerChildren.insert(childItem); - pChild->layer()->setEnabled(false); - } - pChild->refFromEffectItem(true); - } - } - } - - m_viewData.renderControl->polishItems(); - m_viewData.renderControl->beginFrame(); - m_viewData.renderControl->sync(); - - // Connection to afterRendering is necessary, as this needs to be done before - // call to endNextRhiFrame which happens inside QQuickRenderControl::render() - QMetaObject::Connection connection = QObject::connect(m_viewData.window.data(), - &QQuickWindow::afterRendering, - this, [&]() { - // To get only the single item, we need to make a layer out of it, which enables - // us to render it to a texture that we can grab to an image. - QSGRenderContext *rc = QQuickWindowPrivate::get(m_viewData.window.data())->context; - QSGLayer *layer = rc->sceneGraphContext()->createLayer(rc); - if (smoothRendering) - layer->setSamples(4); - layer->setItem(pItem->itemNode()); - - layer->setRect(QRectF(renderBoundingRect.x(), - renderBoundingRect.y() + renderBoundingRect.height(), - renderBoundingRect.width(), - -renderBoundingRect.height())); - - const QSize minSize = rc->sceneGraphContext()->minimumFBOSize(); - layer->setSize(QSize(qMax(minSize.width(), int(renderBoundingRect.width() * scaleFactor)), - qMax(minSize.height(), int(renderBoundingRect.height() * scaleFactor)))); - layer->scheduleUpdate(); - - if (layer->updateTexture()) - renderImage = layer->toImage().convertToFormat(QImage::Format_ARGB32); - else - qWarning() << __FUNCTION__ << "Failed to update layer texture"; - - delete layer; - layer = nullptr; - - renderImage.setDevicePixelRatio(scaleFactor); - }); - - m_viewData.renderControl->render(); - - QObject::disconnect(connection); - - m_viewData.renderControl->endFrame(); - - if (instance.isValid()) { //Not valid for effect - const auto childInstances = instance.childItems(); - - // Restore visibility of immediate children that have instances and are QQuickItems - for (const auto &childInstance : childInstances) { - QQuickItem *childItem = qobject_cast<QQuickItem *>(childInstance.internalObject()); - if (childItem) { - QQuickItemPrivate *pChild = QQuickItemPrivate::get(childItem); - pChild->derefFromEffectItem(true); - if (pChild->layer() && layerChildren.contains(childItem)) - pChild->layer()->setEnabled(true); - } - } - } - - if (!isLayerEnabled(pItem)) - pItem->derefFromEffectItem(false); -#endif - return renderImage; -} - -void Qt5NodeInstanceServer::refreshBindings() -{ - QQuickDesignerSupport::refreshExpressions(context()); -} - -QQuickDesignerSupport *Qt5NodeInstanceServer::designerSupport() -{ - return m_designerSupport.get(); -} - -void Qt5NodeInstanceServer::createScene(const CreateSceneCommand &command) -{ - NodeInstanceServer::createScene(command); -} - -void Qt5NodeInstanceServer::clearScene(const ClearSceneCommand &command) -{ - NodeInstanceServer::clearScene(command); -} - -void Qt5NodeInstanceServer::reparentInstances(const ReparentInstancesCommand &command) -{ - NodeInstanceServer::reparentInstances(command.reparentInstances()); - startRenderTimer(); -} - -} // QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.h deleted file mode 100644 index 046a0e61e5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5nodeinstanceserver.h +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtGlobal> -#include <QtQuick/qquickwindow.h> - -#include "nodeinstanceserver.h" - -QT_BEGIN_NAMESPACE -class QQuickItem; -class QQmlEngine; -class QQuickDesignerSupport; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -class QQuickRenderControl; -class QRhi; -class QRhiTexture; -class QRhiRenderBuffer; -class QRhiTextureRenderTarget; -class QRhiRenderPassDescriptor; -#endif -QT_END_NAMESPACE - -namespace QmlDesigner { - -class Qt5NodeInstanceServer : public NodeInstanceServer -{ - Q_OBJECT -public: - Qt5NodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); - ~Qt5NodeInstanceServer() override; - - QQuickView *quickView() const override; - QQuickWindow *quickWindow() const override; - QQmlView *declarativeView() const override; - QQuickItem *rootItem() const override; - void setRootItem(QQuickItem *item) override; - - QQmlEngine *engine() const override; - void refreshBindings() override; - - QQuickDesignerSupport *designerSupport(); - - void createScene(const CreateSceneCommand &command) override; - void clearScene(const ClearSceneCommand &command) override; - void reparentInstances(const ReparentInstancesCommand &command) override; - - QImage grabWindow() override; - QImage grabItem(QQuickItem *item) override; - bool renderWindow() override; - - static QQuickItem *parentEffectItem(QQuickItem *item); - -protected: - void initializeView() override; - void resizeCanvasToRootItem() override; - void resetAllItems(); - void setupScene(const CreateSceneCommand &command) override; - QList<QQuickItem*> allItems() const; - bool rootIsRenderable3DObject() const; - - struct RenderViewData { - QPointer<QQuickWindow> window = nullptr; - QQuickItem *rootItem = nullptr; - QQuickItem *contentItem = nullptr; -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - bool bufferDirty = true; - QQuickRenderControl *renderControl = nullptr; - QRhi *rhi = nullptr; - QRhiTexture *texture = nullptr; - QRhiRenderBuffer *buffer = nullptr; - QRhiTextureRenderTarget *texTarget = nullptr; - QRhiRenderPassDescriptor *rpDesc = nullptr; -#endif - }; - - virtual bool initRhi(RenderViewData &viewData); - virtual QImage grabRenderControl(RenderViewData &viewData); - -private: - RenderViewData m_viewData; - std::unique_ptr<QQuickDesignerSupport> m_designerSupport; - QQmlEngine *m_qmlEngine = nullptr; -}; - -} // QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp deleted file mode 100644 index 6f3fced1b7..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5previewnodeinstanceserver.h" - -#include "changepreviewimagesizecommand.h" -#include "createscenecommand.h" -#include "nodeinstanceclientinterface.h" -#include "removesharedmemorycommand.h" -#include "statepreviewimagechangedcommand.h" - -#include <QQuickView> -#include <QQuickItem> -#include <private/qquickdesignersupport_p.h> - -namespace QmlDesigner { - -Qt5PreviewNodeInstanceServer::Qt5PreviewNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) : - Qt5NodeInstanceServer(nodeInstanceClient) -{ - setSlowRenderTimerInterval(100000000); - setRenderTimerInterval(100); -} - -void Qt5PreviewNodeInstanceServer::createScene(const CreateSceneCommand &command) -{ - initializeView(); - registerFonts(command.resourceUrl); - setTranslationLanguage(command.language); - 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 (!rootNodeInstance().holdsGraphical()) - return; - - if (!inFunction && nodeInstanceClient()->bytesToWrite() < 10000) { - inFunction = true; - - QQuickDesignerSupport::polishItems(quickWindow()); - - QVector<ImageContainer> imageContainerVector; - imageContainerVector.append(ImageContainer(0, renderPreviewImage(), -1)); - - QList<ServerNodeInstance> stateInstances = rootNodeInstance().stateInstances(); - - const QList<ServerNodeInstance> groupInstances = allGroupStateInstances(); - - for (ServerNodeInstance instance : groupInstances) { - stateInstances.append(instance.stateInstances()); - } - - for (ServerNodeInstance instance : std::as_const(stateInstances)) { - instance.activateState(); - QImage previewImage = renderPreviewImage(); - if (!previewImage.isNull()) - imageContainerVector.append(ImageContainer(instance.instanceId(), - renderPreviewImage(), - instance.instanceId())); - instance.deactivateState(); - } - - nodeInstanceClient()->statePreviewImagesChanged( - StatePreviewImageChangedCommand(imageContainerVector)); - - slowDownRenderTimer(); - handleExtraRender(); - inFunction = false; - } -} - -void Qt5PreviewNodeInstanceServer::changeState(const ChangeStateCommand &/*command*/) -{ - -} - -QImage Qt5PreviewNodeInstanceServer::renderPreviewImage() -{ - // Ensure the state preview image is always clipped properly to root item dimensions - if (auto rootItem = qobject_cast<QQuickItem *>(rootNodeInstance().internalObject())) - rootItem->setClip(true); - - rootNodeInstance().updateDirtyNodeRecursive(); - - QRectF boundingRect = rootNodeInstance().boundingRect(); - - QSize previewImageSize = boundingRect.size().toSize(); - - if (m_previewSize.isValid() && !m_previewSize.isNull()) - previewImageSize.scale(m_previewSize, Qt::KeepAspectRatio); - - QImage previewImage = rootNodeInstance().renderPreviewImage(previewImageSize); - - return previewImage; -} - -void QmlDesigner::Qt5PreviewNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command) -{ - if (command.typeName() == "Image") - ImageContainer::removeSharedMemorys(command.keyNumbers()); -} - -void Qt5PreviewNodeInstanceServer::changePreviewImageSize( - const ChangePreviewImageSizeCommand &command) -{ - m_previewSize = command.size; - - collectItemChangesAndSendChangeCommands(); -} - -bool Qt5PreviewNodeInstanceServer::isPreviewServer() const -{ - return true; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.h deleted file mode 100644 index e4f860b6b6..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5previewnodeinstanceserver.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "qt5nodeinstanceserver.h" - -namespace QmlDesigner { - -class Qt5PreviewNodeInstanceServer : public Qt5NodeInstanceServer -{ - Q_OBJECT -public: - explicit Qt5PreviewNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); - - void createScene(const CreateSceneCommand &command) override; - void changeState(const ChangeStateCommand &command) override; - void removeSharedMemory(const RemoveSharedMemoryCommand &command) override; - void changePreviewImageSize(const ChangePreviewImageSizeCommand &command) override; - bool isPreviewServer() const override; - - QImage renderPreviewImage(); - -protected: - void collectItemChangesAndSendChangeCommands() override; - void startRenderTimer() override; - -private: - ServerNodeInstance m_currentState; - QSize m_previewSize{320, 320}; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp deleted file mode 100644 index 07212ec459..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.cpp +++ /dev/null @@ -1,195 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5rendernodeinstanceserver.h" - -#include <QQuickItem> -#include <QQuickView> - -#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 "changestatecommand.h" -#include "childrenchangedcommand.h" -#include "completecomponentcommand.h" -#include "componentcompletedcommand.h" -#include "createscenecommand.h" -#include "quickitemnodeinstance.h" -#include "removesharedmemorycommand.h" - -#include "dummycontextobject.h" - -#include <private/qquickdesignersupport_p.h> - -namespace QmlDesigner { - -Qt5RenderNodeInstanceServer::Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) : - Qt5NodeInstanceServer(nodeInstanceClient) -{ - Internal::QuickItemNodeInstance::createEffectItem(true); -} - -void Qt5RenderNodeInstanceServer::collectItemChangesAndSendChangeCommands() -{ - static bool inFunction = false; - if (!inFunction) { - inFunction = true; - - QQuickDesignerSupport::polishItems(quickWindow()); - - if (quickWindow() && nodeInstanceClient()->bytesToWrite() < 10000) { - bool windowDirty = false; - foreach (QQuickItem *item, allItems()) { - if (item) { - if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { - if (QQuickDesignerSupport::isDirty(item, QQuickDesignerSupport::AllMask)) { - windowDirty = true; - break; - } - } else { - if (hasInstanceForObject(item)) { - if (QQuickDesignerSupport::isDirty(item, QQuickDesignerSupport::ContentUpdateMask)) - m_dirtyInstanceSet.insert(instanceForObject(item)); - if (QQuickItem *effectParent = parentEffectItem(item)) { - if ((QQuickDesignerSupport::isDirty( - item, - QQuickDesignerSupport::DirtyType( - QQuickDesignerSupport::TransformUpdateMask - | QQuickDesignerSupport::Visible - | QQuickDesignerSupport::ContentUpdateMask))) - && hasInstanceForObject(effectParent)) { - m_dirtyInstanceSet.insert(instanceForObject(effectParent)); - } - } - } else if (DesignerSupport::isDirty( - item, - DesignerSupport::DirtyType( - DesignerSupport::AllMask - | DesignerSupport::ZValue - | DesignerSupport::OpacityValue - | DesignerSupport::Visible))) { - ServerNodeInstance ancestorInstance = findNodeInstanceForItem( - item->parentItem()); - if (ancestorInstance.isValid()) - m_dirtyInstanceSet.insert(ancestorInstance); - } - Internal::QuickItemNodeInstance::updateDirtyNode(item); - } - } - } - - if (Internal::QuickItemNodeInstance::unifiedRenderPath()) { - if (windowDirty) - nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand({rootNodeInstance()})); - } else { - if (!m_dirtyInstanceSet.isEmpty()) { - nodeInstanceClient()->pixmapChanged( - createPixmapChangedCommand(QtHelpers::toList(m_dirtyInstanceSet))); - m_dirtyInstanceSet.clear(); - } - } - - m_dirtyInstanceSet.clear(); - - resetAllItems(); - - slowDownRenderTimer(); - nodeInstanceClient()->flush(); - nodeInstanceClient()->synchronizeWithClientProcess(); - } - - if (rootIsRenderable3DObject() && rootNodeInstance().contentItem() - && !changedPropertyList().isEmpty() - && nodeInstanceClient()->bytesToWrite() < 10000) { - - Internal::QuickItemNodeInstance::updateDirtyNode(rootNodeInstance().contentItem()); - nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand({rootNodeInstance()})); - } - - clearChangedPropertyList(); - - inFunction = false; - } -} - -ServerNodeInstance Qt5RenderNodeInstanceServer::findNodeInstanceForItem(QQuickItem *item) const -{ - if (item) { - if (hasInstanceForObject(item)) - return instanceForObject(item); - else if (item->parentItem()) - return findNodeInstanceForItem(item->parentItem()); - } - - return ServerNodeInstance(); -} - -void Qt5RenderNodeInstanceServer::resizeCanvasToRootItem() -{ - Qt5NodeInstanceServer::resizeCanvasToRootItem(); - m_dirtyInstanceSet.insert(rootNodeInstance()); -} - - -void Qt5RenderNodeInstanceServer::createScene(const CreateSceneCommand &command) -{ - Qt5NodeInstanceServer::createScene(command); - - QList<ServerNodeInstance> instanceList; - for (const InstanceContainer &container : std::as_const(command.instances)) { - if (hasInstanceForId(container.instanceId())) { - ServerNodeInstance instance = instanceForId(container.instanceId()); - if (instance.isValid()) { - instanceList.append(instance); - } - } - } - - nodeInstanceClient()->pixmapChanged(createPixmapChangedCommand(instanceList)); -} - -void Qt5RenderNodeInstanceServer::clearScene(const ClearSceneCommand &command) -{ - Qt5NodeInstanceServer::clearScene(command); - - m_dirtyInstanceSet.clear(); -} - -void Qt5RenderNodeInstanceServer::completeComponent(const CompleteComponentCommand &command) -{ - Qt5NodeInstanceServer::completeComponent(command); - - const QVector<qint32> ids = command.instances(); - for (qint32 instanceId : ids) { - if (hasInstanceForId(instanceId)) { - ServerNodeInstance instance = instanceForId(instanceId); - if (instance.isValid()) - m_dirtyInstanceSet.insert(instance); - } - } -} - -void QmlDesigner::Qt5RenderNodeInstanceServer::removeSharedMemory(const QmlDesigner::RemoveSharedMemoryCommand &command) -{ - if (command.typeName() == "Image") - ImageContainer::removeSharedMemorys(command.keyNumbers()); -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.h deleted file mode 100644 index 13fdd7f8e5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5rendernodeinstanceserver.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "qt5nodeinstanceserver.h" - -namespace QmlDesigner { - -class Qt5RenderNodeInstanceServer : public Qt5NodeInstanceServer -{ - Q_OBJECT -public: - explicit Qt5RenderNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); - - void createScene(const CreateSceneCommand &command) override; - void clearScene(const ClearSceneCommand &command) override; - void completeComponent(const CompleteComponentCommand &command) override; - void removeSharedMemory(const RemoveSharedMemoryCommand &command) override; - -protected: - void collectItemChangesAndSendChangeCommands() override; - ServerNodeInstance findNodeInstanceForItem(QQuickItem *item) const; - void resizeCanvasToRootItem() override; - -private: - QSet<ServerNodeInstance> m_dirtyInstanceSet; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.cpp deleted file mode 100644 index ee0bc3ffdc..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.cpp +++ /dev/null @@ -1,344 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qt5testnodeinstanceserver.h" - -#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 "changestatecommand.h" -#include "childrenchangedcommand.h" -#include "completecomponentcommand.h" -#include "componentcompletedcommand.h" -#include "createscenecommand.h" -#include "tokencommand.h" -#include "removesharedmemorycommand.h" -#include "changeauxiliarycommand.h" -#include "changenodesourcecommand.h" - -#include "dummycontextobject.h" - -#include <QQuickItem> -#include <QQuickView> - -#include <private/qquickdesignersupport_p.h> - -namespace QmlDesigner { - -Qt5TestNodeInstanceServer::Qt5TestNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient) - : Qt5NodeInstanceServer(nodeInstanceClient) -{ -} - -void Qt5TestNodeInstanceServer::createInstances(const CreateInstancesCommand &command) -{ - createInstances(command.instances()); - - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::changeFileUrl(const ChangeFileUrlCommand &command) -{ - setupFileUrl(command.fileUrl); - - refreshBindings(); - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command) -{ - bool hasDynamicProperties = false; - foreach (const PropertyValueContainer &container, command.valueChanges()) { - hasDynamicProperties |= container.isDynamic(); - setInstancePropertyVariant(container); - } - - if (hasDynamicProperties) - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::changePropertyBindings(const ChangeBindingsCommand &command) -{ - bool hasDynamicProperties = false; - for (const PropertyBindingContainer &container : command.bindingChanges) { - hasDynamicProperties |= container.isDynamic(); - setInstancePropertyBinding(container); - } - - if (hasDynamicProperties) - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) -{ - for (const PropertyValueContainer &container : command.auxiliaryChanges) { - setInstanceAuxiliaryData(container); - } - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::changeIds(const ChangeIdsCommand &command) -{ - for (const IdContainer &container : command.ids) { - if (hasInstanceForId(container.instanceId())) - instanceForId(container.instanceId()).setId(container.id()); - } - - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::createScene(const CreateSceneCommand &command) -{ - Qt5NodeInstanceServer::createScene(command); - - stopRenderTimer(); - - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::clearScene(const ClearSceneCommand &command) -{ - Qt5NodeInstanceServer::clearScene(command); -} - -void Qt5TestNodeInstanceServer::changeSelection(const ChangeSelectionCommand &) -{ - -} - -void Qt5TestNodeInstanceServer::removeInstances(const RemoveInstancesCommand &command) -{ - ServerNodeInstance oldState = activeStateInstance(); - if (activeStateInstance().isValid()) - activeStateInstance().deactivateState(); - - foreach (qint32 instanceId, command.instanceIds()) { - removeInstanceRelationsip(instanceId); - } - - if (oldState.isValid()) - oldState.activateState(); - - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::removeProperties(const RemovePropertiesCommand &command) -{ - bool hasDynamicProperties = false; - foreach (const PropertyAbstractContainer &container, command.properties()) { - hasDynamicProperties |= container.isDynamic(); - resetInstanceProperty(container); - } - - if (hasDynamicProperties) - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::reparentInstances(const ReparentInstancesCommand &command) -{ - foreach (const ReparentContainer &container, command.reparentInstances()) { - if (hasInstanceForId(container.instanceId())) { - ServerNodeInstance instance = instanceForId(container.instanceId()); - if (instance.isValid()) { - instance.reparent(instanceForId(container.oldParentInstanceId()), container.oldParentProperty(), instanceForId(container.newParentInstanceId()), container.newParentProperty()); - } - } - } - - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::changeState(const ChangeStateCommand &command) -{ - if (hasInstanceForId(command.stateInstanceId())) { - if (activeStateInstance().isValid()) - activeStateInstance().deactivateState(); - ServerNodeInstance instance = instanceForId(command.stateInstanceId()); - instance.activateState(); - } else { - if (activeStateInstance().isValid()) - activeStateInstance().deactivateState(); - } - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::completeComponent(const CompleteComponentCommand &command) -{ - QList<ServerNodeInstance> instanceList; - - foreach (qint32 instanceId, command.instances()) { - if (hasInstanceForId(instanceId)) { - ServerNodeInstance instance = instanceForId(instanceId); - instance.doComponentComplete(); - instanceList.append(instance); - } - } - - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::changeNodeSource(const ChangeNodeSourceCommand &command) -{ - if (hasInstanceForId(command.instanceId())) { - ServerNodeInstance instance = instanceForId(command.instanceId()); - if (instance.isValid()) - instance.setNodeSource(command.nodeSource()); - } - - refreshBindings(); - - collectItemChangesAndSendChangeCommands(); -} - -void Qt5TestNodeInstanceServer::removeSharedMemory(const RemoveSharedMemoryCommand &command) -{ - if (command.typeName() == "Values") - ValuesChangedCommand::removeSharedMemorys(command.keyNumbers()); -} - -void QmlDesigner::Qt5TestNodeInstanceServer::collectItemChangesAndSendChangeCommands() -{ - QQuickDesignerSupport::polishItems(quickWindow()); - - QSet<ServerNodeInstance> informationChangedInstanceSet; - QVector<InstancePropertyPair> propertyChangedList; - QSet<ServerNodeInstance> parentChangedSet; - - if (quickWindow()) { - foreach (QQuickItem *item, allItems()) { - if (item && hasInstanceForObject(item)) { - ServerNodeInstance instance = instanceForObject(item); - - if (isDirtyRecursiveForNonInstanceItems(item)) - informationChangedInstanceSet.insert(instance); - - - if (QQuickDesignerSupport::isDirty(item, QQuickDesignerSupport::ParentChanged)) { - parentChangedSet.insert(instance); - informationChangedInstanceSet.insert(instance); - } - } - } - - foreach (const InstancePropertyPair& property, changedPropertyList()) { - const ServerNodeInstance instance = property.first; - if (instance.isValid()) { - if (property.second.contains("anchors")) - informationChangedInstanceSet.insert(instance); - - propertyChangedList.append(property); - } - } - - resetAllItems(); - clearChangedPropertyList(); - - if (!informationChangedInstanceSet.isEmpty()) { - InformationChangedCommand command - = createAllInformationChangedCommand(QtHelpers::toList(informationChangedInstanceSet)); - command.sort(); - nodeInstanceClient()->informationChanged(command); - } - if (!propertyChangedList.isEmpty()) { - ValuesChangedCommand command = createValuesChangedCommand(propertyChangedList); - command.sort(); - nodeInstanceClient()->valuesChanged(command); - } - - if (!parentChangedSet.isEmpty()) - sendChildrenChangedCommand(QtHelpers::toList(parentChangedSet)); - } -} - -void Qt5TestNodeInstanceServer::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) { - ChildrenChangedCommand command = createChildrenChangedCommand(parent, parent.childItems()); - command.sort(); - nodeInstanceClient()->childrenChanged(command); - } - - if (!noParentList.isEmpty()) { - ChildrenChangedCommand command = createChildrenChangedCommand(ServerNodeInstance(), noParentList); - command.sort(); - nodeInstanceClient()->childrenChanged(command); - } -} - -bool Qt5TestNodeInstanceServer::isDirtyRecursiveForNonInstanceItems(QQuickItem *item) const -{ - static QQuickDesignerSupport::DirtyType informationsDirty = QQuickDesignerSupport::DirtyType(QQuickDesignerSupport::TransformUpdateMask - | QQuickDesignerSupport::ContentUpdateMask - | QQuickDesignerSupport::Visible - | QQuickDesignerSupport::ZValue - | QQuickDesignerSupport::OpacityValue); - - if (QQuickDesignerSupport::isDirty(item, informationsDirty)) - return true; - - foreach (QQuickItem *childItem, item->childItems()) { - if (!hasInstanceForObject(childItem)) { - if (QQuickDesignerSupport::isDirty(childItem, informationsDirty)) - return true; - else if (isDirtyRecursiveForNonInstanceItems(childItem)) - return true; - } - } - - return false; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.h deleted file mode 100644 index ca5cf7b063..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/qt5testnodeinstanceserver.h +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "qt5nodeinstanceserver.h" - -namespace QmlDesigner { - -class Qt5TestNodeInstanceServer : public Qt5NodeInstanceServer -{ -public: - Qt5TestNodeInstanceServer(NodeInstanceClientInterface *nodeInstanceClient); - - - void createInstances(const CreateInstancesCommand &command) override; - void changeFileUrl(const ChangeFileUrlCommand &command) override; - void changePropertyValues(const ChangeValuesCommand &command) override; - void changePropertyBindings(const ChangeBindingsCommand &command) override; - void changeAuxiliaryValues(const ChangeAuxiliaryCommand &command) override; - void changeIds(const ChangeIdsCommand &command) override; - void createScene(const CreateSceneCommand &command) override; - void clearScene(const ClearSceneCommand &command) override; - void removeInstances(const RemoveInstancesCommand &command) override; - void removeProperties(const RemovePropertiesCommand &command) override; - void reparentInstances(const ReparentInstancesCommand &command) override; - void changeState(const ChangeStateCommand &command) override; - void completeComponent(const CompleteComponentCommand &command) override; - void changeNodeSource(const ChangeNodeSourceCommand &command) override; - void removeSharedMemory(const RemoveSharedMemoryCommand &command) override; - void changeSelection(const ChangeSelectionCommand &command) override; - - using Qt5NodeInstanceServer::createInstances; - -protected: - void collectItemChangesAndSendChangeCommands() override; - void sendChildrenChangedCommand(const QList<ServerNodeInstance> &childList); - bool isDirtyRecursiveForNonInstanceItems(QQuickItem *item) const; -}; - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dmaterialnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dmaterialnodeinstance.cpp deleted file mode 100644 index d518fa6ae5..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dmaterialnodeinstance.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "quick3dmaterialnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -Quick3DMaterialNodeInstance::Quick3DMaterialNodeInstance(QObject *node) - : Quick3DRenderableNodeInstance(node) -{ -} - -Quick3DMaterialNodeInstance::~Quick3DMaterialNodeInstance() -{ -} - -void Quick3DMaterialNodeInstance::invokeDummyViewCreate() const -{ - QMetaObject::invokeMethod(m_dummyRootView, "createViewForMaterial", - Q_ARG(QVariant, QVariant::fromValue(object())), - Q_ARG(QVariant, ""), - Q_ARG(QVariant, ""), - Q_ARG(QVariant, "")); -} - -Quick3DMaterialNodeInstance::Pointer Quick3DMaterialNodeInstance::create(QObject *object) -{ - Pointer instance(new Quick3DMaterialNodeInstance(object)); - instance->populateResetHashes(); - return instance; -} - -} // namespace Internal -} // namespace QmlDesigner - diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dmaterialnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dmaterialnodeinstance.h deleted file mode 100644 index 84edfc2ea0..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dmaterialnodeinstance.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtGlobal> - -#include "quick3drenderablenodeinstance.h" - -QT_FORWARD_DECLARE_CLASS(QQuick3DMaterial) - -namespace QmlDesigner { -namespace Internal { - -class Quick3DMaterialNodeInstance : public Quick3DRenderableNodeInstance -{ -public: - using Pointer = QSharedPointer<Quick3DMaterialNodeInstance>; - - ~Quick3DMaterialNodeInstance() override; - static Pointer create(QObject *objectToBeWrapped); - -protected: - explicit Quick3DMaterialNodeInstance(QObject *node); - void invokeDummyViewCreate() const override; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp deleted file mode 100644 index 95e4a8281b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "quick3dnodeinstance.h" -#include "qt5nodeinstanceserver.h" -#include "qt5informationnodeinstanceserver.h" - -#ifdef QUICK3D_MODULE -#include <private/qquick3dobject_p.h> -#include <private/qquick3dnode_p.h> -#include <private/qquick3dnode_p_p.h> -#include <private/qquick3drepeater_p.h> -#include <private/qquick3dloader_p.h> -#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0) -#include <private/qquick3druntimeloader_p.h> -#endif -#endif - -namespace QmlDesigner { -namespace Internal { - -Quick3DNodeInstance::Quick3DNodeInstance(QObject *node) - : Quick3DRenderableNodeInstance(node) -{ -} - -void Quick3DNodeInstance::invokeDummyViewCreate() const -{ - QMetaObject::invokeMethod(m_dummyRootView, "createViewForNode", - Q_ARG(QVariant, QVariant::fromValue(object()))); -} - -Quick3DNodeInstance::~Quick3DNodeInstance() -{ -} - -void Quick3DNodeInstance::initialize( - [[maybe_unused]] const ObjectNodeInstance::Pointer &objectNodeInstance, - [[maybe_unused]] InstanceContainer::NodeFlags flags) -{ -#ifdef QUICK3D_MODULE - QObject *obj = object(); - auto repObj = qobject_cast<QQuick3DRepeater *>(obj); - auto loadObj = qobject_cast<QQuick3DLoader *>(obj); -#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0) - auto runLoadObj = qobject_cast<QQuick3DRuntimeLoader *>(obj); - if (repObj || loadObj || runLoadObj) { -#else - if (repObj || loadObj) { -#endif - if (auto infoServer = qobject_cast<Qt5InformationNodeInstanceServer *>(nodeInstanceServer())) { - if (repObj) { - QObject::connect(repObj, &QQuick3DRepeater::objectAdded, - infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); -#if defined(QUICK3D_ASSET_UTILS_MODULE) && QT_VERSION > QT_VERSION_CHECK(6, 2, 0) - } else if (runLoadObj) { - QObject::connect(runLoadObj, &QQuick3DRuntimeLoader::statusChanged, - infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); -#endif - } else { - QObject::connect(loadObj, &QQuick3DLoader::loaded, - infoServer, &Qt5InformationNodeInstanceServer::handleDynamicAddObject); - } - } - } - - Quick3DRenderableNodeInstance::initialize(objectNodeInstance, flags); -#endif // QUICK3D_MODULE -} - -QQuick3DNode *Quick3DNodeInstance::quick3DNode() const -{ -#ifdef QUICK3D_MODULE - return qobject_cast<QQuick3DNode *>(object()); -#else - return nullptr; -#endif -} - -Quick3DNodeInstance::Pointer Quick3DNodeInstance::create(QObject *object) -{ - Pointer instance(new Quick3DNodeInstance(object)); - instance->populateResetHashes(); - return instance; -} - -void Quick3DNodeInstance::setHiddenInEditor(bool b) -{ - ObjectNodeInstance::setHiddenInEditor(b); -#ifdef QUICK3D_MODULE - QQuick3DNodePrivate *privateNode = QQuick3DNodePrivate::get(quick3DNode()); - if (privateNode) - privateNode->setIsHiddenInEditor(b); -#endif -} - -} // namespace Internal -} // namespace QmlDesigner - diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.h deleted file mode 100644 index b8120a9092..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dnodeinstance.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2019 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtGlobal> - -#include "quick3drenderablenodeinstance.h" - -QT_FORWARD_DECLARE_CLASS(QQuick3DNode) - -namespace QmlDesigner { -namespace Internal { - -class Quick3DNodeInstance : public Quick3DRenderableNodeInstance -{ -public: - using Pointer = QSharedPointer<Quick3DNodeInstance>; - - ~Quick3DNodeInstance() override; - static Pointer create(QObject *objectToBeWrapped); - void setHiddenInEditor(bool b) override; - void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance, - InstanceContainer::NodeFlags flags) override; - -protected: - explicit Quick3DNodeInstance(QObject *node); - void invokeDummyViewCreate() const override; - -private: - QQuick3DNode *quick3DNode() const; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3drenderablenodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3drenderablenodeinstance.cpp deleted file mode 100644 index 67741db5de..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3drenderablenodeinstance.cpp +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "quick3drenderablenodeinstance.h" -#include "qt5nodeinstanceserver.h" -#include "quickitemnodeinstance.h" -#include "../editor3d/generalhelper.h" - -#ifdef QUICK3D_MODULE -#include <private/qquick3dobject_p.h> -#include <private/qquickstategroup_p.h> -#endif - - -namespace QmlDesigner { -namespace Internal { - -const QRectF preview3dBoundingRect(0, 0, 640, 480); - -Quick3DRenderableNodeInstance::Quick3DRenderableNodeInstance(QObject *node) - : ObjectNodeInstance(node) -{ -} - -Quick3DRenderableNodeInstance::~Quick3DRenderableNodeInstance() -{ - delete m_dummyRootView; -} - -void Quick3DRenderableNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance, - InstanceContainer::NodeFlags flags) -{ -#ifdef QUICK3D_MODULE -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - // In case this is the scene root, we need to create a dummy View3D for the scene - // in preview puppets - if (instanceId() == 0 && (!nodeInstanceServer()->isInformationServer())) { - nodeInstanceServer()->quickWindow()->setDefaultAlphaBuffer(true); - nodeInstanceServer()->quickWindow()->setColor(Qt::transparent); - - auto helper = new QmlDesigner::Internal::GeneralHelper(); - engine()->rootContext()->setContextProperty("_generalHelper", helper); - - QQmlComponent component(engine()); - component.loadUrl(QUrl("qrc:/qtquickplugin/mockfiles/qt6/ModelNode3DImageView.qml")); - m_dummyRootView = qobject_cast<QQuickItem *>(component.create()); - - invokeDummyViewCreate(); - - nodeInstanceServer()->setRootItem(m_dummyRootView); - } -#endif // QT_VERSION -#endif // QUICK3D_MODULE - ObjectNodeInstance::initialize(objectNodeInstance, flags); -} - -QImage Quick3DRenderableNodeInstance::renderImage() const -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!isRootNodeInstance() || !m_dummyRootView) - return {}; - - QSize size = preview3dBoundingRect.size().toSize(); - nodeInstanceServer()->quickWindow()->resize(size); - m_dummyRootView->setSize(size); - - // Just render the window once to update spatial nodes - nodeInstanceServer()->renderWindow(); - - QMetaObject::invokeMethod(m_dummyRootView, "fitToViewPort", Qt::DirectConnection); - - QRectF renderBoundingRect = m_dummyRootView->boundingRect(); - QImage renderImage; - - if (QuickItemNodeInstance::unifiedRenderPath()) { - renderImage = nodeInstanceServer()->grabWindow(); - renderImage = renderImage.copy(renderBoundingRect.toRect()); - } else { - renderImage = nodeInstanceServer()->grabItem(m_dummyRootView); - } - - // When grabbing an offscreen window the device pixel ratio is 1 - renderImage.setDevicePixelRatio(1); - - return renderImage; -#endif - return {}; -} - -QImage Quick3DRenderableNodeInstance::renderPreviewImage( - [[maybe_unused]] const QSize &previewImageSize) const -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - if (!isRootNodeInstance() || !m_dummyRootView) - return {}; - - nodeInstanceServer()->quickWindow()->resize(previewImageSize); - m_dummyRootView->setSize(previewImageSize); - - // Just render the window once to update spatial nodes - nodeInstanceServer()->renderWindow(); - - QMetaObject::invokeMethod(m_dummyRootView, "fitToViewPort", Qt::DirectConnection); - - QRectF previewItemBoundingRect = boundingRect(); - - if (previewItemBoundingRect.isValid()) { - const QSize size = previewImageSize; - if (m_dummyRootView->isVisible()) { - QImage image; - image = nodeInstanceServer()->grabWindow(); - image = image.copy(previewItemBoundingRect.toRect()); - image = image.scaledToWidth(size.width()); - return image; - } else { - QImage transparentImage(size, QImage::Format_ARGB32_Premultiplied); - transparentImage.fill(Qt::transparent); - return transparentImage; - } - } -#endif - return {}; -} - -bool Quick3DRenderableNodeInstance::isRenderable() const -{ - return m_dummyRootView; -} - -bool Quick3DRenderableNodeInstance::hasContent() const -{ - return true; -} - -QRectF Quick3DRenderableNodeInstance::boundingRect() const -{ - //The information server has no m_dummyRootView therefore we use the hardcoded value - if (nodeInstanceServer()->isInformationServer()) - return preview3dBoundingRect; - - if (m_dummyRootView) - return m_dummyRootView->boundingRect(); - return ObjectNodeInstance::boundingRect(); -} - -QRectF Quick3DRenderableNodeInstance::contentItemBoundingBox() const -{ - return boundingRect(); -} - -QPointF Quick3DRenderableNodeInstance::position() const -{ - return QPointF(0, 0); -} - -QSizeF Quick3DRenderableNodeInstance::size() const -{ - return boundingRect().size(); -} - -QList<ServerNodeInstance> Quick3DRenderableNodeInstance::stateInstances() const -{ - QList<ServerNodeInstance> instanceList; -#ifdef QUICK3D_MODULE - if (auto obj3D = qobject_cast<QQuick3DObject *>(object())) { - const QList<QQuickState *> stateList = QQuick3DObjectPrivate::get(obj3D)->_states()->states(); - for (QQuickState *state : stateList) { - if (state && nodeInstanceServer()->hasInstanceForObject(state)) - instanceList.append(nodeInstanceServer()->instanceForObject(state)); - } - } -#endif - return instanceList; -} - -QQuickItem *Quick3DRenderableNodeInstance::contentItem() const -{ - return m_dummyRootView; -} - -void Quick3DRenderableNodeInstance::setPropertyVariant(const PropertyName &name, - const QVariant &value) -{ - if (m_dummyRootView && name == "isLibraryIcon") - QMetaObject::invokeMethod(m_dummyRootView, "setIconMode", Q_ARG(QVariant, value)); - ObjectNodeInstance::setPropertyVariant(name, value); -} - -Qt5NodeInstanceServer *Quick3DRenderableNodeInstance::qt5NodeInstanceServer() const -{ - return qobject_cast<Qt5NodeInstanceServer *>(nodeInstanceServer()); -} - -void Quick3DRenderableNodeInstance::invokeDummyViewCreate() const -{ -} - -} // namespace Internal -} // namespace QmlDesigner - diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3drenderablenodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3drenderablenodeinstance.h deleted file mode 100644 index 98fba654d8..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3drenderablenodeinstance.h +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2022 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtGlobal> - -#include "objectnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -class Quick3DRenderableNodeInstance : public ObjectNodeInstance -{ -public: - ~Quick3DRenderableNodeInstance() override; - void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance, - InstanceContainer::NodeFlags flags) override; - - QImage renderImage() const override; - QImage renderPreviewImage(const QSize &previewImageSize) const override; - - bool isRenderable() const override; - bool hasContent() const override; - QRectF boundingRect() const override; - QRectF contentItemBoundingBox() const override; - QPointF position() const override; - QSizeF size() const override; - - QList<ServerNodeInstance> stateInstances() const override; - - QQuickItem *contentItem() const override; - void setPropertyVariant(const PropertyName &name, const QVariant &value) override; - -protected: - explicit Quick3DRenderableNodeInstance(QObject *node); - Qt5NodeInstanceServer *qt5NodeInstanceServer() const; - virtual void invokeDummyViewCreate() const; - - QQuickItem *m_dummyRootView = nullptr; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dtexturenodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dtexturenodeinstance.cpp deleted file mode 100644 index 4e63e88d54..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dtexturenodeinstance.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "quick3dtexturenodeinstance.h" -#include <QQuickItem> -#include <QTimer> - -namespace QmlDesigner { -namespace Internal { - -Quick3DTextureNodeInstance::Quick3DTextureNodeInstance(QObject *object) - : ObjectNodeInstance(object) -{ -} - -Quick3DTextureNodeInstance::Pointer Quick3DTextureNodeInstance::create(QObject *object) -{ - Pointer instance(new Quick3DTextureNodeInstance(object)); - - QTimer::singleShot(0, [object](){ - // Texture will be upside down for unknown reason unless we force flip update at start - QVariant prop = object->property("flipV"); - QVariant prop2(!prop.toBool()); - object->setProperty("flipV", prop2); - object->setProperty("flipV", prop); - }); - - instance->populateResetHashes(); - return instance; -} - -void Quick3DTextureNodeInstance::setPropertyBinding(const PropertyName &name, - const QString &expression) -{ - ObjectNodeInstance::setPropertyBinding(name, expression); - - if (name == "sourceItem") { - bool targetNeed = true; - if (expression.isEmpty()) - targetNeed = false; - if (targetNeed != m_multiPassNeeded) { - m_multiPassNeeded = targetNeed; - if (targetNeed) - nodeInstanceServer()->incrementNeedsExtraRender(); - else - nodeInstanceServer()->decrementNeedsExtraRender(); - } - } -} - -void Quick3DTextureNodeInstance::resetProperty(const PropertyName &name) -{ - ObjectNodeInstance::resetProperty(name); - - if (name == "sourceItem") { - if (m_multiPassNeeded) { - m_multiPassNeeded = false; - nodeInstanceServer()->decrementNeedsExtraRender(); - } - } -} - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dtexturenodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dtexturenodeinstance.h deleted file mode 100644 index 77a3e32a2a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quick3dtexturenodeinstance.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2020 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "objectnodeinstance.h" - -namespace QmlDesigner { -namespace Internal { - -class Quick3DTextureNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<Quick3DTextureNodeInstance>; - using WeakPointer = QWeakPointer<Quick3DTextureNodeInstance>; - - static Pointer create(QObject *objectToBeWrapped); - - void setPropertyBinding(const PropertyName &name, const QString &expression) override; - void resetProperty(const PropertyName &name) override; - -protected: - Quick3DTextureNodeInstance(QObject *item); - -private: - void handleRedrawTimeout(); - - bool m_multiPassNeeded = false; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp deleted file mode 100644 index 918e147798..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.cpp +++ /dev/null @@ -1,1058 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "quickitemnodeinstance.h" -#include "qt5nodeinstanceserver.h" - -#include <qmlprivategate.h> - -#include <QtQuick/private/qquickitem_p.h> -#include <QtQuick/private/qquickshadereffectsource_p.h> - -#include <private/qquickdesignersupport_p.h> - -#include <QQmlProperty> -#include <QQmlExpression> -#include <QQuickView> -#include <cmath> - -#include <QHash> - -#include <QDebug> - -namespace QmlDesigner { -namespace Internal { - -bool QuickItemNodeInstance::s_createEffectItem = false; -bool QuickItemNodeInstance::s_unifiedRenderPath = false; - -QuickItemNodeInstance::QuickItemNodeInstance(QQuickItem *item) - : ObjectNodeInstance(item), - m_isResizable(true), - m_isMovable(true), - m_hasHeight(false), - m_hasWidth(false), - m_hasContent(true), - m_x(0.0), - m_y(0.0), - m_width(0.0), - m_height(0.0) -{ -} - -QuickItemNodeInstance::~QuickItemNodeInstance() -{ -} - -void QuickItemNodeInstance::handleObjectDeletion(QObject *object) -{ - auto item = qobject_cast<QQuickItem *>(object); - if (item && checkIfRefFromEffect(instanceId())) - designerSupport()->derefFromEffectItem(item); - - ObjectNodeInstance::handleObjectDeletion(object); -} - -static bool isContentItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer) -{ - - return item->parentItem() - && nodeInstanceServer->hasInstanceForObject(item->parentItem()) - && nodeInstanceServer->instanceForObject(item->parentItem()).internalInstance()->contentItem() == item; -} - -static QTransform transformForItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer) -{ - if (isContentItem(item, nodeInstanceServer)) - return QTransform(); - - QTransform toParentTransform = QQuickDesignerSupport::parentTransform(item); - if (item->parentItem() && !nodeInstanceServer->hasInstanceForObject(item->parentItem())) { - - return transformForItem(item->parentItem(), nodeInstanceServer) * toParentTransform; - } - - return toParentTransform; -} - -QTransform QuickItemNodeInstance::transform() const -{ if (quickItem()->parentItem()) - return QQuickDesignerSupport::parentTransform(quickItem()); - - return QTransform(); -} - - -QObject *QuickItemNodeInstance::parent() const -{ - if (!quickItem() || !quickItem()->parentItem()) - return nullptr; - - return quickItem()->parentItem(); -} - -QList<ServerNodeInstance> QuickItemNodeInstance::childItems() const -{ - QList<ServerNodeInstance> instanceList; - - foreach (QQuickItem *childItem, quickItem()->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; -} - -bool QuickItemNodeInstance::isMovable() const -{ - if (isRootNodeInstance()) - return false; - - return m_isMovable && quickItem() && quickItem()->parentItem(); -} - -void QuickItemNodeInstance::setMovable(bool movable) -{ - m_isMovable = movable; -} - -QuickItemNodeInstance::Pointer QuickItemNodeInstance::create(QObject *object) -{ - QQuickItem *quickItem = qobject_cast<QQuickItem*>(object); - - Q_ASSERT(quickItem); - - Pointer instance(new QuickItemNodeInstance(quickItem)); - - instance->setHasContent(anyItemHasContent(quickItem)); - quickItem->setFlag(QQuickItem::ItemHasContents, true); - - static_cast<QQmlParserStatus*>(quickItem)->classBegin(); - - instance->populateResetHashes(); - - return instance; -} - -void QuickItemNodeInstance::createEffectItem(bool createEffectItem) -{ - s_createEffectItem = createEffectItem; -} - -void QuickItemNodeInstance::enableUnifiedRenderPath(bool unifiedRenderPath) -{ - s_unifiedRenderPath = unifiedRenderPath; -} - -bool QuickItemNodeInstance::checkIfRefFromEffect([[maybe_unused]] qint32 id) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (s_unifiedRenderPath) - return false; - - return (s_createEffectItem || id == 0); -#else - return false; -#endif -} - -void QuickItemNodeInstance::initialize(const ObjectNodeInstance::Pointer &objectNodeInstance, - InstanceContainer::NodeFlags flags) -{ - - if (instanceId() == 0) - nodeInstanceServer()->setRootItem(quickItem()); - else - quickItem()->setParentItem(nodeInstanceServer()->rootItem()); - - if (quickItem()->window() && checkIfRefFromEffect(instanceId())) { - designerSupport()->refFromEffectItem(quickItem(), - !flags.testFlag( - InstanceContainer::ParentTakesOverRendering)); - } - - ObjectNodeInstance::initialize(objectNodeInstance, flags); -} - -QQuickItem *QuickItemNodeInstance::contentItem() const -{ - return m_contentItem.data(); -} - -bool QuickItemNodeInstance::hasContent() const -{ - if (m_hasContent) - return true; - - return childItemsHaveContent(quickItem()); -} - -void QuickItemNodeInstance::doComponentComplete() -{ - ObjectNodeInstance::doComponentComplete(); - - QmlPrivateGate::disableTextCursor(quickItem()); - - QmlPrivateGate::emitComponentComplete(quickItem()); - - QQmlProperty contentItemProperty(quickItem(), "contentItem", engine()); - if (contentItemProperty.isValid()) - m_contentItem = contentItemProperty.read().value<QQuickItem*>(); - - quickItem()->update(); -} - -static QList<QQuickItem *> allChildItemsRecursive(QQuickItem *parentItem) -{ - QList<QQuickItem *> itemList; - - itemList.append(parentItem->childItems()); - - foreach (QQuickItem *childItem, parentItem->childItems()) - itemList.append(allChildItemsRecursive(childItem)); - - return itemList; -} - -QList<QQuickItem *> QuickItemNodeInstance::allItemsRecursive() const -{ - QList<QQuickItem *> itemList; - - - if (quickItem()) { - if (quickItem()->parentItem()) - itemList.append(quickItem()->parentItem()); - - itemList.append(quickItem()); - itemList.append(allChildItemsRecursive(quickItem())); - } - - return itemList; -} - -QStringList QuickItemNodeInstance::allStates() const -{ - QStringList list; - - QList<QObject*> stateList = QQuickDesignerSupport::statesForItem(quickItem()); - for (QObject *state : stateList) { - QQmlProperty property(state, "name"); - if (property.isValid()) - list.append(property.read().toString()); - } - - return list; -} - -void QuickItemNodeInstance::updateDirtyNode([[maybe_unused]] QQuickItem *item) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (s_unifiedRenderPath) - return; - QQuickDesignerSupport::updateDirtyNode(item); -#endif -} - -bool QuickItemNodeInstance::unifiedRenderPath() -{ - return s_unifiedRenderPath; -} - -bool QuickItemNodeInstance::unifiedRenderPathOrQt6() -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - return true; -#else - return s_unifiedRenderPath; -#endif -} - -void QuickItemNodeInstance::setHiddenInEditor(bool hide) -{ - ObjectNodeInstance::setHiddenInEditor(hide); - if (s_unifiedRenderPath && !nodeInstanceServer()->isInformationServer()) { - QQmlProperty property(object(), "visible", context()); - - if (!property.isValid()) - return; - - bool visible = property.read().toBool(); - - if (hide && visible) { - setPropertyVariant("visible", false); - m_hidden = true; - } else if (!hide && !visible && m_hidden) { - setPropertyVariant("visible", true); - m_hidden = false; - } - } -} - -QRectF QuickItemNodeInstance::contentItemBoundingBox() const -{ - if (contentItem()) { - QTransform contentItemTransform = QQuickDesignerSupport::parentTransform(contentItem()); - return contentItemTransform.mapRect(contentItem()->boundingRect()); - } - - return QRectF(); -} - -static bool layerEnabledAndEffect(QQuickItem *item) -{ - QQuickItemPrivate *pItem = QQuickItemPrivate::get(item); - - if (pItem && pItem->layer() && pItem->layer()->enabled() && pItem->layer()->effect()) - return true; - - return false; -} - -QRectF QuickItemNodeInstance::boundingRect() const -{ - if (quickItem()) { - if (quickItem()->clip()) { - return quickItem()->boundingRect(); - } else if (layerEnabledAndEffect(quickItem())) { - return ServerNodeInstance::effectAdjustedBoundingRect(quickItem()); - } else { - QSize maximumSize(4000, 4000); - auto isValidSize = [maximumSize] (const QRectF& rect) { - QSize size = rect.size().toSize(); - return size.width() * size.height() <= maximumSize.width() * maximumSize.height(); - }; - - QRectF rect = boundingRectWithStepChilds(quickItem()); - if (isValidSize(rect)) - return rect; - else if (rect = quickItem()->boundingRect(); isValidSize(rect)) - return rect; - else - return QRectF(QPointF(0.0, 0.0), maximumSize); - } - } - - return QRectF(); -} - -static QTransform contentTransformForItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer) -{ - QTransform contentTransform; - if (item->parentItem() && !nodeInstanceServer->hasInstanceForObject(item->parentItem())) { - contentTransform = QQuickDesignerSupport::parentTransform(item->parentItem()); - return contentTransformForItem(item->parentItem(), nodeInstanceServer) * contentTransform; - } - - return contentTransform; -} - -QTransform QuickItemNodeInstance::contentTransform() const -{ - return contentTransformForItem(quickItem(), nodeInstanceServer()); -} - -QTransform QuickItemNodeInstance::sceneTransform() const -{ - return QQuickDesignerSupport::windowTransform(quickItem()); -} - -double QuickItemNodeInstance::opacity() const -{ - return quickItem()->opacity(); -} - -double QuickItemNodeInstance::rotation() const -{ - return quickItem()->rotation(); -} - -double QuickItemNodeInstance::scale() const -{ - return quickItem()->scale(); -} - -QPointF QuickItemNodeInstance::transformOriginPoint() const -{ - return quickItem()->transformOriginPoint(); -} - -double QuickItemNodeInstance::zValue() const -{ - return quickItem()->z(); -} - -QPointF QuickItemNodeInstance::position() const -{ - return quickItem()->position(); -} - -QSizeF QuickItemNodeInstance::size() const -{ - double width; - - if (QQuickDesignerSupport::isValidHeight(quickItem())) { // isValidHeight is QQuickItemPrivate::get(item)->widthValid - width = quickItem()->width(); - } else { - width = quickItem()->implicitWidth(); - } - - double height; - - if (QQuickDesignerSupport::isValidWidth(quickItem())) { // isValidWidth is QQuickItemPrivate::get(item)->heightValid - height = quickItem()->height(); - } else { - height = quickItem()->implicitHeight(); - } - - - return QSizeF(width, height); -} - -static QTransform contentItemTransformForItem(QQuickItem *item, NodeInstanceServer *nodeInstanceServer) -{ - QTransform toParentTransform = QQuickDesignerSupport::parentTransform(item); - if (item->parentItem() && !nodeInstanceServer->hasInstanceForObject(item->parentItem())) { - - return transformForItem(item->parentItem(), nodeInstanceServer) * toParentTransform; - } - - return toParentTransform; -} - -QTransform QuickItemNodeInstance::contentItemTransform() const -{ - if (contentItem()) - return contentItemTransformForItem(contentItem(), nodeInstanceServer()); - - return QTransform(); -} - -int QuickItemNodeInstance::penWidth() const -{ - return QQuickDesignerSupport::borderWidth(quickItem()); -} - -double QuickItemNodeInstance::x() const -{ - return m_x; -} - -double QuickItemNodeInstance::y() const -{ - return m_y; -} - -QImage QuickItemNodeInstance::renderImage() const -{ - if (s_unifiedRenderPath && !isRootNodeInstance()) - return {}; - - updateDirtyNodesRecursive(quickItem()); - - QRectF renderBoundingRect = boundingRect(); - QImage renderImage; - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QSize size = renderBoundingRect.size().toSize(); - static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble(); - size *= devicePixelRatio; - - if (s_unifiedRenderPath) { - renderImage = nodeInstanceServer()->quickWindow()->grabWindow(); - } else { - // Fake render loop signaling to update things like QML items as 3D textures - nodeInstanceServer()->quickWindow()->beforeSynchronizing(); - nodeInstanceServer()->quickWindow()->beforeRendering(); - - renderImage = designerSupport()->renderImageForItem(quickItem(), renderBoundingRect, size); - - nodeInstanceServer()->quickWindow()->afterRendering(); - } - renderImage.setDevicePixelRatio(devicePixelRatio); -#else - if (s_unifiedRenderPath) { - renderImage = nodeInstanceServer()->grabWindow(); - renderImage = renderImage.copy(renderBoundingRect.toRect()); - /* When grabbing an offscren window the device pixel ratio is 1 */ - renderImage.setDevicePixelRatio(1); - } else { - renderImage = nodeInstanceServer()->grabItem(quickItem()); - } - -#endif - - return renderImage; -} - -QImage QuickItemNodeInstance::renderPreviewImage(const QSize &previewImageSize) const -{ - QRectF previewItemBoundingRect = boundingRect(); - - if (previewItemBoundingRect.isValid() && quickItem()) { - static double devicePixelRatio = qgetenv("FORMEDITOR_DEVICE_PIXEL_RATIO").toDouble(); - const QSize size = previewImageSize * devicePixelRatio; - if (quickItem()->isVisible()) { - QImage image; -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - if (s_unifiedRenderPath) { - image = nodeInstanceServer()->quickWindow()->grabWindow(); - } else { - // Fake render loop signaling to update things like QML items as 3D textures - nodeInstanceServer()->quickWindow()->beforeSynchronizing(); - nodeInstanceServer()->quickWindow()->beforeRendering(); - - image = designerSupport()->renderImageForItem(quickItem(), - previewItemBoundingRect, - size); - - nodeInstanceServer()->quickWindow()->afterRendering(); - } -#else - image = nodeInstanceServer()->grabWindow(); - image = image.copy(previewItemBoundingRect.toRect()); -#endif - - image = image.scaledToWidth(size.width()); - - return image; - } else { - QImage transparentImage(size, QImage::Format_ARGB32_Premultiplied); - transparentImage.fill(Qt::transparent); - return transparentImage; - } - } - - return QImage(); -} - -QSharedPointer<QQuickItemGrabResult> QuickItemNodeInstance::createGrabResult() const -{ - return quickItem()->grabToImage(size().toSize()); -} - -void QuickItemNodeInstance::updateAllDirtyNodesRecursive() -{ - updateAllDirtyNodesRecursive(quickItem()); -} - -bool QuickItemNodeInstance::isQuickItem() const -{ - return true; -} - -bool QuickItemNodeInstance::isRenderable() const -{ - return quickItem() && (!s_unifiedRenderPath || isRootNodeInstance()); -} - -QList<ServerNodeInstance> QuickItemNodeInstance::stateInstances() const -{ - QList<ServerNodeInstance> instanceList; - QList<QObject*> stateList = QQuickDesignerSupport::statesForItem(quickItem()); - foreach (QObject *state, stateList) - { - if (state && nodeInstanceServer()->hasInstanceForObject(state)) - instanceList.append(nodeInstanceServer()->instanceForObject(state)); - } - - return instanceList; -} - -bool QuickItemNodeInstance::isResizable() const -{ - if (isRootNodeInstance()) - return false; - - return m_isResizable && quickItem() && quickItem()->parentItem(); -} - -void QuickItemNodeInstance::setResizable(bool resizable) -{ - m_isResizable = resizable; -} - -void QuickItemNodeInstance::setHasContent(bool hasContent) -{ - m_hasContent = hasContent; -} - -QQuickDesignerSupport *QuickItemNodeInstance::designerSupport() const -{ - return qt5NodeInstanceServer()->designerSupport(); -} - -Qt5NodeInstanceServer *QuickItemNodeInstance::qt5NodeInstanceServer() const -{ - return qobject_cast<Qt5NodeInstanceServer*>(nodeInstanceServer()); -} - -void QuickItemNodeInstance::updateDirtyNodesRecursive(QQuickItem *parentItem) const -{ - foreach (QQuickItem *childItem, parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem)) - updateDirtyNodesRecursive(childItem); - } - - QmlPrivateGate::disableNativeTextRendering(parentItem); -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QQuickDesignerSupport::updateDirtyNode(parentItem); -#endif -} - -void QuickItemNodeInstance::updateAllDirtyNodesRecursive(QQuickItem *parentItem) const -{ - const QList<QQuickItem *> children = parentItem->childItems(); - for (QQuickItem *childItem : children) - updateAllDirtyNodesRecursive(childItem); - - updateDirtyNode(parentItem); -} - -void QuickItemNodeInstance::setAllNodesDirtyRecursive([[maybe_unused]] QQuickItem *parentItem) const -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - const QList<QQuickItem *> children = parentItem->childItems(); - for (QQuickItem *childItem : children) - setAllNodesDirtyRecursive(childItem); - QQuickDesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content); -#endif -} - -static inline bool isRectangleSane(const QRectF &rect) -{ - return rect.isValid() && (rect.width() < 10000) && (rect.height() < 10000); -} - -static bool isEffectItem([[maybe_unused]] QQuickItem *item) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - return false; -#else - if (qobject_cast<QQuickShaderEffectSource *>(item)) - return true; - - const auto propName = "source"; - - QQmlProperty prop(item, QString::fromLatin1(propName)); - if (!prop.isValid()) - return false; - - QQuickShaderEffectSource *source = prop.read().value<QQuickShaderEffectSource *>(); - - if (source && source->sourceItem()) { - QQuickItemPrivate *pItem = QQuickItemPrivate::get(source->sourceItem()); - - if (pItem && pItem->layer() && pItem->layer()->enabled() && pItem->layer()->effect()) - return true; - } - - return false; -#endif -} - -QRectF QuickItemNodeInstance::boundingRectWithStepChilds(QQuickItem *parentItem) const -{ - QRectF boundingRect = parentItem->boundingRect(); - - boundingRect = boundingRect.united(QRectF(QPointF(0, 0), size())); - - for (QQuickItem *childItem : parentItem->childItems()) { - if (!nodeInstanceServer()->hasInstanceForObject(childItem) && !isEffectItem(childItem)) { - QRectF transformedRect = childItem->mapRectToItem(parentItem, - boundingRectWithStepChilds(childItem)); - if (isRectangleSane(transformedRect)) - boundingRect = boundingRect.united(transformedRect); - } - } - - if (boundingRect.isEmpty()) - QRectF{0, 0, 640, 480}; - - return boundingRect; -} - -void QuickItemNodeInstance::resetHorizontal() -{ - setPropertyVariant("x", m_x); - if (m_width > 0.0) { - setPropertyVariant("width", m_width); - } else { - setPropertyVariant("width", quickItem()->implicitWidth()); - } -} - -void QuickItemNodeInstance::resetVertical() -{ - setPropertyVariant("y", m_y); - if (m_height > 0.0) { - setPropertyVariant("height", m_height); - } else { - setPropertyVariant("height", quickItem()->implicitHeight()); - } -} - -QList<ServerNodeInstance> QuickItemNodeInstance::childItemsForChild(QQuickItem *item) const -{ - QList<ServerNodeInstance> instanceList; - - if (item) { - foreach (QQuickItem *childItem, item->childItems()) - { - if (childItem && nodeInstanceServer()->hasInstanceForObject(childItem)) { - instanceList.append(nodeInstanceServer()->instanceForObject(childItem)); - } else { - instanceList.append(childItemsForChild(childItem)); - } - } - } - return instanceList; -} - -static void repositioning(QQuickItem *item) -{ - if (!item) - return; - -// QQmlBasePositioner *positioner = qobject_cast<QQmlBasePositioner*>(item); -// if (positioner) -// positioner->rePositioning(); - - if (item->parentItem()) - repositioning(item->parentItem()); -} -void QuickItemNodeInstance::refresh() -{ - repositioning(quickItem()); -} - -bool QuickItemNodeInstance::anyItemHasContent(QQuickItem *quickItem) -{ - if (quickItem->flags().testFlag(QQuickItem::ItemHasContents)) - return true; - - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -bool QuickItemNodeInstance::childItemsHaveContent(QQuickItem *quickItem) -{ - foreach (QQuickItem *childItem, quickItem->childItems()) { - if (anyItemHasContent(childItem)) - return true; - } - - return false; -} - -static bool instanceIsValidLayoutable(const ObjectNodeInstance::Pointer &instance, const PropertyName &propertyName) -{ - return instance && instance->isLayoutable() && !instance->ignoredProperties().contains(propertyName); -} - -void QuickItemNodeInstance::reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) -{ - if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty)) { - setInLayoutable(false); - setMovable(true); - } - - markRepeaterParentDirty(); - - ObjectNodeInstance::reparent(oldParentInstance, oldParentProperty, newParentInstance, newParentProperty); - - if (!newParentInstance) - quickItem()->setParentItem(nullptr); - - if (instanceIsValidLayoutable(newParentInstance, newParentProperty)) { - setInLayoutable(true); - setMovable(false); - } - - if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty) && !instanceIsValidLayoutable(newParentInstance, newParentProperty)) { - if (!hasBindingForProperty("x")) - setPropertyVariant("x", x()); - - if (!hasBindingForProperty("y")) - setPropertyVariant("y", y()); - } - - if (quickItem()->parentItem()) { - refresh(); - - updateDirtyNode(quickItem()); - - if (instanceIsValidLayoutable(oldParentInstance, oldParentProperty)) - oldParentInstance->refreshLayoutable(); - - if (instanceIsValidLayoutable(newParentInstance, newParentProperty)) - newParentInstance->refreshLayoutable(); - } -} - -void QuickItemNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - if (ignoredProperties().contains(name)) - return; - - if (name == "state" && isRootNodeInstance()) - return; // states on the root item 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(); - - if (name == "layer.enabled" || name == "layer.effect") - setAllNodesDirtyRecursive(quickItem()); - - markRepeaterParentDirty(); - - ObjectNodeInstance::setPropertyVariant(name, value); - - refresh(); - - if (isInLayoutable()) - parentInstance()->refreshLayoutable(); -} - -void QuickItemNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - static QList<PropertyName> anchorsTargets = {"anchors.top", - "acnhors.bottom", - "anchors.left", - "achors.right"}; - if (ignoredProperties().contains(name)) - return; - - if (name == "state" && isRootNodeInstance()) - return; // states on the root item are only set by us - - if (name.startsWith("anchors.") && isRootNodeInstance()) - return; - - markRepeaterParentDirty(); - - if (anchorsTargets.contains(name)) { - //When resolving anchor targets we have to provide the root context the ids are defined in. - QmlPrivateGate::setPropertyBinding(object(), - context()->engine()->rootContext(), - name, - expression); - } else { - ObjectNodeInstance::setPropertyBinding(name, expression); - } - - refresh(); - - /* Evaluate properties of the root item in the context of the dummy context if they contain parent. - * This is done manually because we cannot "overwrite" the parent property - */ - - if (isRootNodeInstance() && expression.contains(QLatin1String("parent."))) { - QQmlExpression qmlContextExpression(context(), nodeInstanceServer()->dummyContextObject(), expression); - QVariant value = qmlContextExpression.evaluate(); - setPropertyVariant(name, value); - } - - if (isInLayoutable()) - parentInstance()->refreshLayoutable(); -} - -QVariant QuickItemNodeInstance::property(const PropertyName &name) const -{ - if (ignoredProperties().contains(name)) - return QVariant(); - - if (name == "visible") - return quickItem()->isVisible(); - - return ObjectNodeInstance::property(name); -} - -void QuickItemNodeInstance::resetProperty(const PropertyName &name) -{ - if (ignoredProperties().contains(name)) - return; - - 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; - - if (name == "layer.enabled" || name == "layer.effect") - setAllNodesDirtyRecursive(quickItem()); - - QQuickDesignerSupport::resetAnchor(quickItem(), QString::fromUtf8(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(); - } - - markRepeaterParentDirty(); - - ObjectNodeInstance::resetProperty(name); - - if (isInLayoutable()) - parentInstance()->refreshLayoutable(); -} - -bool QuickItemNodeInstance::isAnchoredByChildren() const -{ - return QQuickDesignerSupport::areChildrenAnchoredTo(quickItem(), quickItem()); -} - -bool QuickItemNodeInstance::hasAnchor(const PropertyName &name) const -{ - return QQuickDesignerSupport::hasAnchor(quickItem(), QString::fromUtf8(name)); -} - -static bool isValidAnchorName(const PropertyName &name) -{ - static PropertyNameList anchorNameList({"anchors.top", - "anchors.left", - "anchors.right", - "anchors.bottom", - "anchors.verticalCenter", - "anchors.horizontalCenter", - "anchors.fill", - "anchors.centerIn", - "anchors.baseline"}); - - return anchorNameList.contains(name); -} - -QPair<PropertyName, ServerNodeInstance> QuickItemNodeInstance::anchor(const PropertyName &name) const -{ - if (!isValidAnchorName(name) || !QQuickDesignerSupport::hasAnchor(quickItem(), QString::fromUtf8(name))) - return ObjectNodeInstance::anchor(name); - - QPair<QString, QObject*> nameObjectPair = - QQuickDesignerSupport::anchorLineTarget(quickItem(), QString::fromUtf8(name), context()); - - QObject *targetObject = nameObjectPair.second; - PropertyName targetName = nameObjectPair.first.toUtf8(); - - while (targetObject) { - if (nodeInstanceServer()->hasInstanceForObject(targetObject)) - return {targetName, nodeInstanceServer()->instanceForObject(targetObject)}; - else - targetObject = parentObject(targetObject); - } - - return ObjectNodeInstance::anchor(name); -} - -bool QuickItemNodeInstance::isAnchoredBySibling() const -{ - if (quickItem()->parentItem()) { - foreach (QQuickItem *siblingItem, quickItem()->parentItem()->childItems()) { // search in siblings for a anchor to this item - if (siblingItem) { - if (QQuickDesignerSupport::isAnchoredTo(siblingItem, quickItem())) - return true; - } - } - } - - return false; -} - - - -QQuickItem *QuickItemNodeInstance::quickItem() const -{ - if (object() == nullptr) - return nullptr; - - return static_cast<QQuickItem*>(object()); -} - -void QuickItemNodeInstance::markRepeaterParentDirty() const -{ - const qint32 id = instanceId(); - if (id <= 0 && !isValid()) - return; - - QQuickItem *item = quickItem(); - if (!item) - return; - - QQuickItem *parentItem = item->parentItem(); - if (!parentItem) - return; - - // If a Repeater instance was changed in any way, the parent must be marked dirty to rerender it - const QByteArray type("QQuickRepeater"); - if (ServerNodeInstance::isSubclassOf(item, type)) - QQuickDesignerSupport::addDirty(parentItem, QQuickDesignerSupport::Content); - - // Repeater's parent must also be dirtied when a child of a repeater was changed - if (ServerNodeInstance::isSubclassOf(parentItem, type)) { - QQuickItem *parentsParent = parentItem->parentItem(); - if (parentsParent) - QQuickDesignerSupport::addDirty(parentsParent, QQuickDesignerSupport::Content); - } -} - - - -} // namespace Internal -} // namespace QmlDesigner - diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h deleted file mode 100644 index 65d84fac65..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/quickitemnodeinstance.h +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QtGlobal> - -#include "objectnodeinstance.h" - -#include <QQuickItem> - -QT_BEGIN_NAMESPACE -class QQuickDesignerSupport; -QT_END_NAMESPACE - -namespace QmlDesigner { -namespace Internal { - -class QuickItemNodeInstance : public ObjectNodeInstance -{ -public: - using Pointer = QSharedPointer<QuickItemNodeInstance>; - using WeakPointer = QWeakPointer<QuickItemNodeInstance>; - - ~QuickItemNodeInstance() override; - void handleObjectDeletion(QObject *object) override; - - static Pointer create(QObject *objectToBeWrapped); - static void createEffectItem(bool createEffectItem); - static void enableUnifiedRenderPath(bool createEffectItem); - - void initialize(const ObjectNodeInstance::Pointer &objectNodeInstance, - InstanceContainer::NodeFlags flags) override; - - QQuickItem *contentItem() const override; - bool hasContent() const override; - - QRectF contentItemBoundingBox() const override; - QRectF boundingRect() const override; - QTransform contentTransform() const override; - QTransform sceneTransform() const override; - double opacity() const override; - double rotation() const override; - double scale() const override; - QPointF transformOriginPoint() const override; - double zValue() const override; - QPointF position() const override; - QSizeF size() const override; - QTransform transform() const override; - QTransform contentItemTransform() const override; - int penWidth() const override; - - QImage renderImage() const override; - QImage renderPreviewImage(const QSize &previewImageSize) const override; - - QSharedPointer<QQuickItemGrabResult> createGrabResult() const override; - - void updateAllDirtyNodesRecursive() override; - - - QObject *parent() const override; - QList<ServerNodeInstance> childItems() const override; - - void reparent(const ObjectNodeInstance::Pointer &oldParentInstance, const PropertyName &oldParentProperty, const ObjectNodeInstance::Pointer &newParentInstance, const PropertyName &newParentProperty) override; - - void setPropertyVariant(const PropertyName &name, const QVariant &value) override; - void setPropertyBinding(const PropertyName &name, const QString &expression) override; - QVariant property(const PropertyName &name) const override; - void resetProperty(const PropertyName &name) override; - - bool isAnchoredByChildren() const override; - bool hasAnchor(const PropertyName &name) const override; - QPair<PropertyName, ServerNodeInstance> anchor(const PropertyName &name) const override; - bool isAnchoredBySibling() const override; - bool isResizable() const override; - bool isMovable() const override; - bool isQuickItem() const override; - bool isRenderable() const override; - - QList<ServerNodeInstance> stateInstances() const override; - - void doComponentComplete() override; - - QList<QQuickItem*> allItemsRecursive() const override; - QStringList allStates() const override; - - static void updateDirtyNode(QQuickItem *item); - static bool unifiedRenderPath(); - static bool unifiedRenderPathOrQt6(); - - void setHiddenInEditor(bool b) override; - -protected: - explicit QuickItemNodeInstance(QQuickItem*); - QQuickItem *quickItem() const; - void setMovable(bool movable); - void setResizable(bool resizable); - void setHasContent(bool hasContent); - QQuickDesignerSupport *designerSupport() const; - Qt5NodeInstanceServer *qt5NodeInstanceServer() const; - void updateDirtyNodesRecursive(QQuickItem *parentItem) const; - void updateAllDirtyNodesRecursive(QQuickItem *parentItem) const; - void setAllNodesDirtyRecursive(QQuickItem *parentItem) const; - QRectF boundingRectWithStepChilds(QQuickItem *parentItem) const; - void resetHorizontal(); - void resetVertical(); - QList<ServerNodeInstance> childItemsForChild(QQuickItem *item) const; - void refresh(); - static bool anyItemHasContent(QQuickItem *quickItem); - static bool childItemsHaveContent(QQuickItem *quickItem); - - double x() const; - double y() const; - bool checkIfRefFromEffect(qint32 id); - void markRepeaterParentDirty() const; - -private: //variables - QPointer<QQuickItem> m_contentItem; - bool m_isResizable; - bool m_isMovable; - bool m_hasHeight; - bool m_hasWidth; - bool m_hasContent; - double m_x; - double m_y; - double m_width; - double m_height; - bool m_hidden = false; - static bool s_createEffectItem; - static bool s_unifiedRenderPath; -}; - -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp deleted file mode 100644 index 8ea0eaf806..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.cpp +++ /dev/null @@ -1,733 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "servernodeinstance.h" - -#include "objectnodeinstance.h" -#include "dummynodeinstance.h" -#include "componentnodeinstance.h" -#include "qmltransitionnodeinstance.h" -#include "qmlpropertychangesnodeinstance.h" -#include "behaviornodeinstance.h" -#include "qmlstatenodeinstance.h" -#include "anchorchangesnodeinstance.h" -#include "positionernodeinstance.h" -#include "layoutnodeinstance.h" -#include "debugoutputcommand.h" -#include "qt3dpresentationnodeinstance.h" - -#include "quickitemnodeinstance.h" -#include "quick3dmaterialnodeinstance.h" -#include "quick3dnodeinstance.h" -#include "quick3dtexturenodeinstance.h" - -#include "nodeinstanceserver.h" -#include "instancecontainer.h" - -#include <qmlprivategate.h> - -#include <QHash> -#include <QSet> -#include <QDebug> -#include <QQuickItem> - -#include <QQmlEngine> - -/*! - \class QmlDesigner::NodeInstance - \ingroup CoreInstance - \brief NodeInstance is a common handle for the actual object representation of a ModelNode. - - NodeInstance abstracts away the differences e.g. in terms of position and size - for QWidget, QGraphicsView, QLayout etc objects. Multiple NodeInstance objects can share - the pointer to the same instance object. The actual instance will be deleted when - the last NodeInstance object referencing to it is deleted. This can be disabled by - setDeleteHeldInstance(). - - \see QmlDesigner::NodeInstanceView -*/ - -namespace QmlDesigner { - -/*! -\brief Constructor - creates a invalid NodeInstance - - -\see NodeInstanceView -*/ -ServerNodeInstance::ServerNodeInstance() -{ -} - -/*! -\brief Destructor - -*/ -ServerNodeInstance::~ServerNodeInstance() -{ -} - -/*! -\brief Constructor - creates a valid NodeInstance - -*/ -ServerNodeInstance::ServerNodeInstance(const Internal::ObjectNodeInstance::Pointer &abstractInstance) - : m_nodeInstance(abstractInstance) -{ - -} - - -ServerNodeInstance::ServerNodeInstance(const ServerNodeInstance &other) - : m_nodeInstance(other.m_nodeInstance) -{ -} - -ServerNodeInstance &ServerNodeInstance::operator=(const ServerNodeInstance &other) -{ - m_nodeInstance = other.m_nodeInstance; - return *this; -} - -QImage ServerNodeInstance::renderImage() const -{ - return m_nodeInstance->renderImage(); -} - -QImage ServerNodeInstance::renderPreviewImage(const QSize &previewImageSize) const -{ - return m_nodeInstance->renderPreviewImage(previewImageSize); -} - -QSharedPointer<QQuickItemGrabResult> ServerNodeInstance::createGrabResult() const -{ - return m_nodeInstance->createGrabResult(); -} - -bool ServerNodeInstance::isRootNodeInstance() const -{ - return isValid() && m_nodeInstance->isRootNodeInstance(); -} - -bool ServerNodeInstance::isSubclassOf(QObject *object, const QByteArray &superTypeName) -{ - return Internal::QmlPrivateGate::isSubclassOf(object, superTypeName); -} - -QRectF ServerNodeInstance::effectAdjustedBoundingRect(QQuickItem *item) -{ - if (item) - return item->boundingRect().adjusted(-40, -40, 40, 40); - return {}; -} - -void ServerNodeInstance::setModifiedFlag(bool b) -{ - m_nodeInstance->setModifiedFlag(b); -} - -void ServerNodeInstance::setNodeSource(const QString &source) -{ - m_nodeInstance->setNodeSource(source); -} - -bool ServerNodeInstance::holdsGraphical() const -{ - return m_nodeInstance->isRenderable(); -} - -bool ServerNodeInstance::isComponentWrap() const -{ - return m_nodeInstance->isComponentWrap(); -} - -QQuickItem *ServerNodeInstance::contentItem() const -{ - return m_nodeInstance->contentItem(); -} - -void ServerNodeInstance::updateDirtyNodeRecursive() -{ - m_nodeInstance->updateAllDirtyNodesRecursive(); -} - -bool ServerNodeInstance::isSubclassOf(const QString &superTypeName) const -{ - return isSubclassOf(internalObject(), superTypeName.toUtf8()); -} - -/*! -\brief Creates a new NodeInstace for this NodeMetaInfo - -\param metaInfo MetaInfo for which a Instance should be created -\param context QQmlContext which should be used -\returns Internal Pointer of a NodeInstance -\see NodeMetaInfo -*/ -Internal::ObjectNodeInstance::Pointer ServerNodeInstance::createInstance(QObject *objectToBeWrapped) -{ - Internal::ObjectNodeInstance::Pointer instance; - - if (objectToBeWrapped == nullptr) - instance = Internal::DummyNodeInstance::create(); - else if (isSubclassOf(objectToBeWrapped, "Q3DSPresentationItem")) - instance = Internal::Qt3DPresentationNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuickBasePositioner")) - instance = Internal::PositionerNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuickLayout")) - instance = Internal::LayoutNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuickItem")) - instance = Internal::QuickItemNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuick3DTexture")) - instance = Internal::Quick3DTextureNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuick3DNode")) - instance = Internal::Quick3DNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuick3DMaterial")) - instance = Internal::Quick3DMaterialNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQmlComponent")) - instance = Internal::ComponentNodeInstance::create(objectToBeWrapped); - else if (objectToBeWrapped->inherits("QQmlAnchorChanges")) - instance = Internal::AnchorChangesNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuickPropertyChanges")) - instance = Internal::QmlPropertyChangesNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuickState")) - instance = Internal::QmlStateNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuickTransition")) - instance = Internal::QmlTransitionNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QQuickBehavior")) - instance = Internal::BehaviorNodeInstance::create(objectToBeWrapped); - else if (isSubclassOf(objectToBeWrapped, "QObject")) - instance = Internal::ObjectNodeInstance::create(objectToBeWrapped); - else - instance = Internal::DummyNodeInstance::create(); - - - return instance; -} - -QString static getErrorString(QQmlEngine *engine, const QString &componentPath) -{ - QQmlComponent component(engine, componentPath); - - QObject *o = component.create(nullptr); - delete o; - QString s; - for (const QQmlError &error : component.errors()) - s.append(error.toString()); - return s; -} - -bool isInPathList(const QStringList &pathList, const QString &componentPath) -{ - if (componentPath.indexOf("qml/QtQuick/Controls") > 0) - return true; - - return std::any_of(pathList.begin(), pathList.end(), [&](auto &&path) { - return componentPath.startsWith(path); - }); -} - -bool canBeCreatedAsPrimitive(const QStringList &pathList, - const InstanceContainer &instanceContainer, - QQmlContext *context, - QObject *&object) -{ - if (isInPathList(pathList, instanceContainer.componentPath())) { - object = Internal::ObjectNodeInstance::createPrimitive(QString::fromUtf8( - instanceContainer.type()), - instanceContainer.majorNumber(), - instanceContainer.minorNumber(), - context); - - if (object) - return true; - - } - return false; -} - -ServerNodeInstance ServerNodeInstance::create(NodeInstanceServer *nodeInstanceServer, - const InstanceContainer &instanceContainer, - ComponentWrap componentWrap) -{ - Q_ASSERT(instanceContainer.instanceId() != -1); - Q_ASSERT(nodeInstanceServer); - - QObject *object = nullptr; - if (componentWrap == WrapAsComponent) { - object = Internal::ObjectNodeInstance::createComponentWrap(instanceContainer.nodeSource(), nodeInstanceServer->importCode(), nodeInstanceServer->context()); - } else if (!instanceContainer.nodeSource().isEmpty()) { - object = Internal::ObjectNodeInstance::createCustomParserObject(instanceContainer.nodeSource(), nodeInstanceServer->importCode(), nodeInstanceServer->context()); - if (object == nullptr) - nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Custom parser object could not be created."), instanceContainer.instanceId()); - } else if (!instanceContainer.componentPath().isEmpty() - && !canBeCreatedAsPrimitive(nodeInstanceServer->engine()->importPathList(), - instanceContainer, nodeInstanceServer->context(), object)) { - object = Internal::ObjectNodeInstance::createComponent(instanceContainer.componentPath(), nodeInstanceServer->context()); - if (object == nullptr) { - object = Internal::ObjectNodeInstance::createPrimitive(QString::fromUtf8(instanceContainer.type()), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context()); - if (object == nullptr) { - const QString errors = getErrorString(nodeInstanceServer->engine(), instanceContainer.componentPath()); - const QString message = QString("Component with path %1 could not be created.\n\n").arg(instanceContainer.componentPath()); - nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, message + errors, instanceContainer.instanceId()); - } - } - } else if (!object) { - object = Internal::ObjectNodeInstance::createPrimitive(QString::fromUtf8(instanceContainer.type()), instanceContainer.majorNumber(), instanceContainer.minorNumber(), nodeInstanceServer->context()); - if (object == nullptr) - nodeInstanceServer->sendDebugOutput(DebugOutputCommand::ErrorType, QLatin1String("Item could not be created."), instanceContainer.instanceId()); - } - - if (object == nullptr) { - if (instanceContainer.metaType() == InstanceContainer::ItemMetaType) { //If we cannot instanciate the object but we know it has to be an Ttem, we create an Item instead. - object = Internal::ObjectNodeInstance::createPrimitive("QtQuick/Item", 2, 0, nodeInstanceServer->context()); - - if (object == nullptr) - object = new QQuickItem; - } else { - object = Internal::ObjectNodeInstance::createPrimitive("QtQml/QtObject", 2, 0, nodeInstanceServer->context()); - } - } - - Internal::QmlPrivateGate::getPropertyCache(object, nodeInstanceServer->engine()); - - ServerNodeInstance instance(createInstance(object)); - - instance.internalInstance()->setNodeInstanceServer(nodeInstanceServer); - - instance.internalInstance()->setInstanceId(instanceContainer.instanceId()); - - instance.internalInstance()->setComponentWrap(componentWrap == WrapAsComponent); - - instance.internalInstance()->initialize(instance.m_nodeInstance, instanceContainer.metaFlags()); - -#if QT_VERSION < QT_VERSION_CHECK(6, 2, 1) - // Handle hidden state to initialize pickable state - nodeInstanceServer->handleInstanceHidden(instance, false, false); -#else - nodeInstanceServer->handlePickTarget(instance); -#endif - - return instance; -} - -void ServerNodeInstance::reparent(const ServerNodeInstance &oldParentInstance, const PropertyName &oldParentProperty, const ServerNodeInstance &newParentInstance, const PropertyName &newParentProperty) -{ - m_nodeInstance->reparent(oldParentInstance.m_nodeInstance, oldParentProperty, newParentInstance.m_nodeInstance, newParentProperty); -} - -/*! -\brief Returns the parent NodeInstance of this NodeInstance. - - If there is not parent than the parent is invalid. - -\returns Parent NodeInstance. -*/ -ServerNodeInstance ServerNodeInstance::parent() const -{ - return m_nodeInstance->parentInstance(); -} - -bool ServerNodeInstance::hasParent() const -{ - return m_nodeInstance->parent(); -} - -bool ServerNodeInstance::isValid() const -{ - return m_nodeInstance && m_nodeInstance->isValid(); -} - - -/*! -\brief Returns if the NodeInstance is a QGraphicsItem. -\returns true if this NodeInstance is a QGraphicsItem -*/ -bool ServerNodeInstance::equalGraphicsItem(QGraphicsItem *item) const -{ - return m_nodeInstance->equalGraphicsItem(item); -} - -/*! -\brief Returns the bounding rect of the NodeInstance. -\returns QRectF of the NodeInstance -*/ -QRectF ServerNodeInstance::boundingRect() const -{ - QRectF boundingRect(m_nodeInstance->boundingRect()); - -// -// if (modelNode().isValid()) { // TODO implement recursiv stuff -// if (qFuzzyIsNull(boundingRect.width())) -// boundingRect.setWidth(nodeState().property("width").value().toDouble()); -// -// if (qFuzzyIsNull(boundingRect.height())) -// boundingRect.setHeight(nodeState().property("height").value().toDouble()); -// } - - return boundingRect; -} - -QRectF ServerNodeInstance::contentItemBoundingRect() const -{ - return m_nodeInstance->contentItemBoundingBox(); -} - -void ServerNodeInstance::setPropertyVariant(const PropertyName &name, const QVariant &value) -{ - m_nodeInstance->setPropertyVariant(name, value); - -} - -void ServerNodeInstance::setPropertyBinding(const PropertyName &name, const QString &expression) -{ - m_nodeInstance->setPropertyBinding(name, expression); -} - -void ServerNodeInstance::setHiddenInEditor(bool b) -{ - m_nodeInstance->setHiddenInEditor(b); - m_nodeInstance->nodeInstanceServer()->handleInstanceHidden(*this, b, true); -} - -void ServerNodeInstance::setLockedInEditor(bool b) -{ - m_nodeInstance->setLockedInEditor(b); - m_nodeInstance->nodeInstanceServer()->handleInstanceLocked(*this, b, true); -} - -void ServerNodeInstance::resetProperty(const PropertyName &name) -{ - m_nodeInstance->resetProperty(name); -} - -void ServerNodeInstance::refreshProperty(const PropertyName &name) -{ - m_nodeInstance->refreshProperty(name); -} - -void ServerNodeInstance::setId(const QString &id) -{ - m_nodeInstance->setId(id); -} - -/*! -\brief Returns the property value of the property of this NodeInstance. -\returns QVariant value -*/ -QVariant ServerNodeInstance::property(const PropertyName &name) const -{ - return m_nodeInstance->property(name); -} - -PropertyNameList ServerNodeInstance::propertyNames() const -{ - return m_nodeInstance->propertyNames(); -} - -bool ServerNodeInstance::hasBindingForProperty(const PropertyName &name, bool *hasChanged) const -{ - return m_nodeInstance->hasBindingForProperty(name, hasChanged); -} - -/*! -\brief Returns the property default value of the property of this NodeInstance. -\returns QVariant default value which is the reset value to -*/ -QVariant ServerNodeInstance::defaultValue(const PropertyName &name) const -{ - return m_nodeInstance->resetValue(name); -} - -/*! -\brief Returns the type of the property of this NodeInstance. -*/ -QString ServerNodeInstance::instanceType(const PropertyName &name) const -{ - return m_nodeInstance->instanceType(name); -} - -void ServerNodeInstance::makeInvalid() -{ - if (m_nodeInstance) - m_nodeInstance->destroy(); - m_nodeInstance.clear(); -} - -bool ServerNodeInstance::hasContent() const -{ - return m_nodeInstance->hasContent(); -} - -bool ServerNodeInstance::isResizable() const -{ - return m_nodeInstance->isResizable(); -} - -bool ServerNodeInstance::isMovable() const -{ - return m_nodeInstance->isMovable(); -} - -bool ServerNodeInstance::isInLayoutable() const -{ - return m_nodeInstance->isInLayoutable(); -} - -bool ServerNodeInstance::hasAnchor(const PropertyName &name) const -{ - return m_nodeInstance->hasAnchor(name); -} - -int ServerNodeInstance::penWidth() const -{ - return m_nodeInstance->penWidth(); -} - -bool ServerNodeInstance::isAnchoredBySibling() const -{ - return m_nodeInstance->isAnchoredBySibling(); -} - -bool ServerNodeInstance::isAnchoredByChildren() const -{ - return m_nodeInstance->isAnchoredByChildren(); -} - -QPair<PropertyName, ServerNodeInstance> ServerNodeInstance::anchor(const PropertyName &name) const -{ - return m_nodeInstance->anchor(name); -} - -QDebug operator <<(QDebug debug, const ServerNodeInstance &instance) -{ - if (instance.isValid()) { - debug.nospace() << "ServerNodeInstance(" - << instance.instanceId() << ", " - << instance.internalObject() << ", " - << instance.id() << ", " - << instance.parent() << ')'; - } else { - debug.nospace() << "ServerNodeInstance(invalid)"; - } - - return debug.space(); -} - -ServerNodeInstance::QHashValueType qHash(const ServerNodeInstance &instance) -{ - return ::qHash(instance.instanceId()); -} - -bool operator ==(const ServerNodeInstance &first, const ServerNodeInstance &second) -{ - return first.instanceId() == second.instanceId(); -} - -bool operator <(const ServerNodeInstance &first, const ServerNodeInstance &second) -{ - return first.instanceId() < second.instanceId(); -} - - -bool ServerNodeInstance::isWrappingThisObject(QObject *object) const -{ - return internalObject() && internalObject() == object; -} - -/*! -\brief Returns the position in parent coordiantes. -\returns QPointF of the position of the instance. -*/ -QPointF ServerNodeInstance::position() const -{ - return m_nodeInstance->position(); -} - -/*! -\brief Returns the size in local coordiantes. -\returns QSizeF of the size of the instance. -*/ -QSizeF ServerNodeInstance::size() const -{ - QSizeF instanceSize = m_nodeInstance->size(); - - return instanceSize; -} - -QTransform ServerNodeInstance::transform() const -{ - return m_nodeInstance->transform(); -} - -/*! -\brief Returns the transform matrix of the instance. -\returns QTransform of the instance. -*/ -QTransform ServerNodeInstance::customTransform() const -{ - return m_nodeInstance->customTransform(); -} - -QTransform ServerNodeInstance::sceneTransform() const -{ - return m_nodeInstance->sceneTransform(); -} - -QTransform ServerNodeInstance::contentTransform() const -{ - return m_nodeInstance->contentTransform(); -} - -QTransform ServerNodeInstance::contentItemTransform() const -{ - return m_nodeInstance->contentItemTransform(); -} - -double ServerNodeInstance::rotation() const -{ - return m_nodeInstance->rotation(); -} - -double ServerNodeInstance::scale() const -{ - return m_nodeInstance->scale(); -} - -QList<QGraphicsTransform *> ServerNodeInstance::transformations() const -{ - return m_nodeInstance->transformations(); -} - -QPointF ServerNodeInstance::transformOriginPoint() const -{ - return m_nodeInstance->transformOriginPoint(); -} - -double ServerNodeInstance::zValue() const -{ - return m_nodeInstance->zValue(); -} - -/*! -\brief Returns the opacity of the instance. -\returns 0.0 mean transparent and 1.0 opaque. -*/ -double ServerNodeInstance::opacity() const -{ - return m_nodeInstance->opacity(); -} - - -void ServerNodeInstance::setDeleteHeldInstance(bool deleteInstance) -{ - m_nodeInstance->setDeleteHeldInstance(deleteInstance); -} - - -void ServerNodeInstance::paintUpdate() -{ - m_nodeInstance->paintUpdate(); -} - -QObject *ServerNodeInstance::internalObject() const -{ - if (m_nodeInstance.isNull()) - return nullptr; - - return m_nodeInstance->object(); -} - -void ServerNodeInstance::activateState() -{ - m_nodeInstance->activateState(); -} - -void ServerNodeInstance::deactivateState() -{ - m_nodeInstance->deactivateState(); -} - -bool ServerNodeInstance::updateStateVariant(const ServerNodeInstance &target, const PropertyName &propertyName, const QVariant &value) -{ - return m_nodeInstance->updateStateVariant(target.internalInstance(), propertyName, value); -} - -bool ServerNodeInstance::updateStateBinding(const ServerNodeInstance &target, const PropertyName &propertyName, const QString &expression) -{ - return m_nodeInstance->updateStateBinding(target.internalInstance(), propertyName, expression); -} - -QVariant ServerNodeInstance::resetVariant(const PropertyName &propertyName) const -{ - return m_nodeInstance->resetValue(propertyName); -} - -bool ServerNodeInstance::resetStateProperty(const ServerNodeInstance &target, const PropertyName &propertyName, const QVariant &resetValue) -{ - return m_nodeInstance->resetStateProperty(target.internalInstance(), propertyName, resetValue); -} - -/*! - Makes types used in node instances known to the Qml engine. To be called once at initialization time. -*/ -void ServerNodeInstance::registerQmlTypes() -{ -// qmlRegisterType<QmlDesigner::Internal::QmlPropertyChangesObject>(); -} - -void ServerNodeInstance::doComponentComplete() -{ - m_nodeInstance->doComponentComplete(); -} - -QList<ServerNodeInstance> ServerNodeInstance::childItems() const -{ - return m_nodeInstance->childItems(); -} - -QQuickItem *ServerNodeInstance::rootQuickItem() const -{ - return qobject_cast<QQuickItem*>(internalObject()); -} - -QList<QQuickItem *> ServerNodeInstance::allItemsRecursive() const -{ - return m_nodeInstance->allItemsRecursive(); -} - -QString ServerNodeInstance::id() const -{ - if (isValid()) - return m_nodeInstance->id(); - - return {}; -} - -qint32 ServerNodeInstance::instanceId() const -{ - if (isValid()) - return m_nodeInstance->instanceId(); - - return -1; -} - -QList<ServerNodeInstance> ServerNodeInstance::stateInstances() const -{ - return m_nodeInstance->stateInstances(); -} - -QStringList ServerNodeInstance::allStates() const -{ - if (isValid()) - return m_nodeInstance->allStates(); - - return {}; -} - -Internal::ObjectNodeInstance::Pointer ServerNodeInstance::internalInstance() const -{ - return m_nodeInstance; -} - -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h deleted file mode 100644 index e60fceeea9..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/servernodeinstance.h +++ /dev/null @@ -1,217 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QSharedPointer> -#include <QHash> -#include <QRectF> - -#include <nodeinstanceserverinterface.h> -#include <propertyvaluecontainer.h> - -QT_BEGIN_NAMESPACE -class QPainter; -class QStyleOptionGraphicsItem; -class QQmlContext; -class QGraphicsItem; -class QGraphicsTransform; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)) -class QQuickItem; -class QQuickItemGrabResult; -#endif -QT_END_NAMESPACE - -namespace QmlDesigner { - -class NodeInstanceServer; -class Qt4NodeInstanceServer; -class Qt4PreviewNodeInstanceServer; -class Qt5NodeInstanceServer; -class Qt5PreviewNodeInstanceServer; -class Qt5TestNodeInstanceServer; -class InstanceContainer; - -namespace Internal { - class ObjectNodeInstance; - class QmlGraphicsItemNodeInstance; - class QmlPropertyChangesNodeInstance; - class GraphicsObjectNodeInstance; - class QmlStateNodeInstance; - class QuickItemNodeInstance; - class Quick3DNodeInstance; - class Quick3DTextureNodeInstance; -} - -class ServerNodeInstance -{ -public: -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) -using QHashValueType = uint; -#else -using QHashValueType = size_t; -#endif - - friend class NodeInstanceServer; - friend class Qt4NodeInstanceServer; - friend class Qt4PreviewNodeInstanceServer; - friend class Qt5InformationNodeInstanceServer; - friend class Qt5NodeInstanceServer; - friend class Qt5PreviewNodeInstanceServer; - friend class Qt5CapturePreviewNodeInstanceServer; - friend class Qt5TestNodeInstanceServer; - friend class QHash<qint32, ServerNodeInstance>; - friend QHashValueType qHash(const ServerNodeInstance &instance); - friend bool operator==(const ServerNodeInstance &first, const ServerNodeInstance &second); - friend QDebug operator<<(QDebug debug, const ServerNodeInstance &instance); - friend class NodeMetaInfo; - friend class QmlDesigner::Internal::QmlGraphicsItemNodeInstance; - friend class QmlDesigner::Internal::QuickItemNodeInstance; - friend class QmlDesigner::Internal::GraphicsObjectNodeInstance; - friend class QmlDesigner::Internal::ObjectNodeInstance; - friend class QmlDesigner::Internal::QmlPropertyChangesNodeInstance; - friend class QmlDesigner::Internal::QmlStateNodeInstance; - friend class QmlDesigner::Internal::Quick3DNodeInstance; - friend class QmlDesigner::Internal::Quick3DTextureNodeInstance; - -public: - enum ComponentWrap { - WrapAsComponent, - DoNotWrapAsComponent - }; - - ServerNodeInstance(); - ~ServerNodeInstance(); - ServerNodeInstance(const ServerNodeInstance &other); - ServerNodeInstance& operator=(const ServerNodeInstance &other); - - QImage renderImage() const; - QImage renderPreviewImage(const QSize &previewImageSize) const; - - QSharedPointer<QQuickItemGrabResult> createGrabResult() const; - - ServerNodeInstance parent() const; - bool hasParent() const; - - bool equalGraphicsItem(QGraphicsItem *item) const; - - QRectF boundingRect() const; - QRectF contentItemBoundingRect() const; - QPointF position() const; - QSizeF size() const; - QTransform transform() const; - QTransform customTransform() const; - QTransform sceneTransform() const; - QTransform contentTransform() const; - QTransform contentItemTransform() const; - double rotation() const; - double scale() const; - QList<QGraphicsTransform *> transformations() const; - QPointF transformOriginPoint() const; - double zValue() const; - - double opacity() const; - QVariant property(const PropertyName &name) const; - QVariant defaultValue(const PropertyName &name) const; - QString instanceType(const PropertyName &name) const; - PropertyNameList propertyNames() const; - - - bool hasBindingForProperty(const PropertyName &name, bool *hasChanged = nullptr) const; - - bool isValid() const; - void makeInvalid(); - bool hasContent() const; - bool isResizable() const; - bool isMovable() const; - bool isInLayoutable() const; - - bool isSubclassOf(const QString &superTypeName) const; - bool isRootNodeInstance() const; - - bool isWrappingThisObject(QObject *object) const; - - QVariant resetVariant(const PropertyName &name) const; - - bool hasAnchor(const PropertyName &name) const; - bool isAnchoredBySibling() const; - bool isAnchoredByChildren() const; - QPair<PropertyName, ServerNodeInstance> anchor(const PropertyName &name) const; - - int penWidth() const; - - static void registerQmlTypes(); - - void doComponentComplete(); - - QList<ServerNodeInstance> childItems() const; - - QQuickItem *rootQuickItem() const; - QList<QQuickItem *> allItemsRecursive() const; - - QString id() const; - qint32 instanceId() const; - - QSharedPointer<Internal::ObjectNodeInstance> internalInstance() const; - - QList<ServerNodeInstance> stateInstances() const; - QStringList allStates() const; - - static bool isSubclassOf(QObject *object, const QByteArray &superTypeName); - static QRectF effectAdjustedBoundingRect(QQuickItem *item); - - void setModifiedFlag(bool b); - void updateDirtyNodeRecursive(); - bool holdsGraphical() const; - - bool isComponentWrap() const; - - QQuickItem *contentItem() const; - -private: // functions - ServerNodeInstance(const QSharedPointer<Internal::ObjectNodeInstance> &abstractInstance); - - void setPropertyVariant(const PropertyName &name, const QVariant &value); - - void setPropertyBinding(const PropertyName &name, const QString &expression); - - void setHiddenInEditor(bool b); - void setLockedInEditor(bool b); - - void resetProperty(const PropertyName &name); - void refreshProperty(const PropertyName &name); - - void activateState(); - void deactivateState(); - void refreshState(); - - bool updateStateVariant(const ServerNodeInstance &target, const PropertyName &propertyName, const QVariant &value); - bool updateStateBinding(const ServerNodeInstance &target, const PropertyName &propertyName, const QString &expression); - bool resetStateProperty(const ServerNodeInstance &target, const PropertyName &propertyName, const QVariant &resetValue); - - static ServerNodeInstance create(NodeInstanceServer *nodeInstanceServer, const InstanceContainer &instanceContainer, ComponentWrap componentWrap); - - void setDeleteHeldInstance(bool deleteInstance); - void reparent(const ServerNodeInstance &oldParentInstance, const PropertyName &oldParentProperty, const ServerNodeInstance &newParentInstance, const PropertyName &newParentProperty); - - void setId(const QString &id); - - static QSharedPointer<Internal::ObjectNodeInstance> createInstance(QObject *objectToBeWrapped); - - void paintUpdate(); - - void setNodeSource(const QString &source); - - QObject *internalObject() const; // should be not used outside of the nodeinstances!!!! - -private: // variables - QSharedPointer<Internal::ObjectNodeInstance> m_nodeInstance; -}; - -ServerNodeInstance::QHashValueType qHash(const ServerNodeInstance &instance); -bool operator ==(const ServerNodeInstance &first, const ServerNodeInstance &second); -bool operator <(const ServerNodeInstance &first, const ServerNodeInstance &second); -QDebug operator <<(QDebug debug, const ServerNodeInstance &instance); -} - -Q_DECLARE_METATYPE(QmlDesigner::ServerNodeInstance) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/viewconfig.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/viewconfig.cpp deleted file mode 100644 index 39f108e49a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/viewconfig.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "viewconfig.h" -#include <QtGlobal> - -bool ViewConfig::isQuick3DMode() -{ - static bool mode3D = qEnvironmentVariableIsSet("QMLDESIGNER_QUICK3D_MODE"); - return mode3D; -} - -static bool particleViewEnabled = false; -void ViewConfig::enableParticleView(bool enable) -{ - particleViewEnabled = enable; -} - -bool ViewConfig::isParticleViewMode() -{ - static bool particleviewmode = !qEnvironmentVariableIsSet("QT_QUICK3D_DISABLE_PARTICLE_SYSTEMS"); - return particleviewmode && particleViewEnabled; -} diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/viewconfig.h b/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/viewconfig.h deleted file mode 100644 index 17e4df1a47..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/instances/viewconfig.h +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2021 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -class ViewConfig -{ -public: - static bool isQuick3DMode(); - static void enableParticleView(bool enable); - static bool isParticleViewMode(); -}; diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri deleted file mode 100644 index 0b364d32b3..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pri +++ /dev/null @@ -1,46 +0,0 @@ -QT += core gui widgets qml quick network -QT += core-private qml-private quick-private gui-private - -CONFIG += c++17 -win32:!mingw: QMAKE_CXXFLAGS += /std:c++17 - -DEFINES -= QT_CREATOR - -# This .pri file contains classes to enable a special multilanguage translator -MULTILANGUAGE_SUPPORT_PRI=$$(MULTILANGUAGE_SUPPORT_PRI) -!isEmpty(MULTILANGUAGE_SUPPORT_PRI) { - exists($$(MULTILANGUAGE_SUPPORT_PRI)): message(including \"$$(MULTILANGUAGE_SUPPORT_PRI)\") - else: error("MULTILANGUAGE_SUPPORT_PRI: \"$$(MULTILANGUAGE_SUPPORT_PRI)\" does not exist.") - include($$(MULTILANGUAGE_SUPPORT_PRI)) - DEFINES += MULTILANGUAGE_TRANSLATIONPROVIDER -} - -include (editor3d/editor3d.pri) -include (../instances/instances.pri) -include (instances/instances.pri) -include (../commands/commands.pri) -include (../container/container.pri) -include (../interfaces/interfaces.pri) -include (../types/types.pri) -include (../qmlprivategate/qmlprivategate.pri) -include (iconrenderer/iconrenderer.pri) -include (import3d/import3d.pri) - -SOURCES += $$PWD/qml2puppetmain.cpp -RESOURCES += $$PWD/../qmlpuppet.qrc - -versionAtLeast(QT_VERSION, 6.0.0): RESOURCES += $$PWD/../editor3d_qt6.qrc -else: RESOURCES += $$PWD/../editor3d_qt5.qrc - -DISTFILES += Info.plist - -unix:!openbsd:!osx: LIBS += -lrt # posix shared memory - -osx { - CONFIG -= app_bundle - QMAKE_LFLAGS += -Wl,-sectcreate,__TEXT,__info_plist,$$system_quote($$PWD/Info.plist) -} - -osx: target.path = $$INSTALL_LIBEXEC_PATH/qmldesigner -else: target.path = $$INSTALL_LIBEXEC_PATH -INSTALLS += target diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pro b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pro deleted file mode 100644 index 1457e8d10e..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppet.pro +++ /dev/null @@ -1,11 +0,0 @@ -TARGET = qml2puppet - -TEMPLATE = app -CONFIG += console - -build_all:!build_pass { - CONFIG -= build_all - CONFIG += release -} - -include(qml2puppet.pri) diff --git a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp b/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp deleted file mode 100644 index 2d7518b81b..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qml2puppet/qml2puppetmain.cpp +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "iconrenderer/iconrenderer.h" -#include "import3d/import3d.h" - -#include <qt5nodeinstanceclientproxy.h> -#ifdef MULTILANGUAGE_TRANSLATIONPROVIDER -#include <sqlitelibraryinitializer.h> -#endif - -#include <QQmlComponent> -#include <QQmlEngine> -#include <QDebug> -#include <QApplication> -#include <QStringList> -#include <QFileInfo> - -#include <iostream> -#include <stdio.h> -#include <stdlib.h> - -#ifdef ENABLE_QT_BREAKPAD -#include <qtsystemexceptionhandler.h> -#endif - -#if defined(ENABLE_CRASHPAD) && defined(Q_OS_WIN) -#define NOMINMAX -#include "client/crashpad_client.h" -#include "client/crash_report_database.h" -#include "client/settings.h" -#endif - -#ifdef Q_OS_WIN -#include <windows.h> -#endif - -namespace { -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) -void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) -{ - QByteArray localMsg = msg.toLocal8Bit(); - switch (type) { - case QtDebugMsg: - fprintf(stderr, - "Debug: %s (%s:%u, %s)\n", - localMsg.constData(), - context.file, - context.line, - context.function); - break; - case QtInfoMsg: - fprintf(stderr, - "Info: %s (%s:%u, %s)\n", - localMsg.constData(), - context.file, - context.line, - context.function); - break; - case QtWarningMsg: - fprintf(stderr, - "Warning: %s (%s:%u, %s)\n", - localMsg.constData(), - context.file, - context.line, - context.function); - break; - case QtCriticalMsg: - fprintf(stderr, - "Critical: %s (%s:%u, %s)\n", - localMsg.constData(), - context.file, - context.line, - context.function); - break; - case QtFatalMsg: - fprintf(stderr, - "Fatal: %s (%s:%u, %s)\n", - localMsg.constData(), - context.file, - context.line, - context.function); - abort(); - } -} -#endif - -#if defined(ENABLE_CRASHPAD) && defined(Q_OS_WIN) -bool startCrashpad() -{ - using namespace crashpad; - - // Cache directory that will store crashpad information and minidumps - base::FilePath database(L"crashpad_reports"); - base::FilePath handler(L"crashpad_handler.exe"); - - // URL used to submit minidumps to - std::string url(CRASHPAD_BACKEND_URL); - - // Optional annotations passed via --annotations to the handler - std::map<std::string, std::string> annotations; - annotations["qt-version"] = QT_VERSION_STR; - - // Optional arguments to pass to the handler - std::vector<std::string> arguments; - arguments.push_back("--no-rate-limit"); - - CrashpadClient *client = new CrashpadClient(); - bool success = client->StartHandler( - handler, - database, - database, - url, - annotations, - arguments, - /* restartable */ true, - /* asynchronous_start */ true - ); - // TODO: research using this method, should avoid creating a separate CrashpadClient for the - // puppet (needed only on windows according to docs). -// client->SetHandlerIPCPipe(L"\\\\.\\pipe\\qml2puppet"); - - return success; -} -#endif - -int internalMain(QGuiApplication *application) -{ - QCoreApplication::setOrganizationName("QtProject"); - QCoreApplication::setOrganizationDomain("qt-project.org"); - QCoreApplication::setApplicationName("Qml2Puppet"); - QCoreApplication::setApplicationVersion("1.0.0"); - - if (application->arguments().count() < 2 - || (application->arguments().at(1) == "--readcapturedstream" && application->arguments().count() < 3) - || (application->arguments().at(1) == "--rendericon" && application->arguments().count() < 5) - || (application->arguments().at(1) == "--import3dAsset" && application->arguments().count() < 6)) { - qDebug() << "Usage:\n"; - qDebug() << "--test"; - qDebug() << "--version"; - qDebug() << "--readcapturedstream <stream file> [control stream file]"; - qDebug() << "--rendericon <icon size> <icon file name> <icon source qml>"; - qDebug() << "--import3dAsset <source asset file name> <output dir> <id number> <import options JSON>"; - - return -1; - } - - if (application->arguments().at(1) == "--readcapturedstream" && application->arguments().count() > 2) { - QFileInfo inputStreamFileInfo(application->arguments().at(2)); - if (!inputStreamFileInfo.exists()) { - qDebug() << "Input stream does not exist:" << inputStreamFileInfo.absoluteFilePath(); - - return -1; - } - - if (application->arguments().count() > 3) { - QFileInfo controlStreamFileInfo(application->arguments().at(3)); - if (!controlStreamFileInfo.exists()) { - qDebug() << "Output stream does not exist:" << controlStreamFileInfo.absoluteFilePath(); - - return -1; - } - } - } - - if (application->arguments().count() == 2 && application->arguments().at(1) == "--test") { - qDebug() << QCoreApplication::applicationVersion(); - QQmlEngine engine; - - QQmlComponent component(&engine); - component.setData("import QtQuick 2.0\nItem {\n}\n", QUrl::fromLocalFile("test.qml")); - - QObject *object = component.create(); - - if (object) { - qDebug() << "Basic QtQuick 2.0 working..."; - } else { - qDebug() << "Basic QtQuick 2.0 not working..."; - qDebug() << component.errorString(); - } - delete object; - return 0; - } - - if (application->arguments().count() == 2 && application->arguments().at(1) == "--version") { - std::cout << 2; - return 0; - } - - if (application->arguments().at(1) != "--readcapturedstream" && application->arguments().count() < 4) { - qDebug() << "Wrong argument count: " << application->arguments().count(); - return -1; - } - - if (application->arguments().at(1) == "--rendericon") { - int size = application->arguments().at(2).toInt(); - QString iconFileName = application->arguments().at(3); - QString iconSource = application->arguments().at(4); - - IconRenderer *iconRenderer = new IconRenderer(size, iconFileName, iconSource); - iconRenderer->setupRender(); - - return application->exec(); - } - - if (application->arguments().at(1) == "--import3dAsset") { - QString sourceAsset = application->arguments().at(2); - QString outDir = application->arguments().at(3); - QString options = application->arguments().at(4); - - Import3D::import3D(sourceAsset, outDir, options); - - return application->exec(); - } - -#ifdef ENABLE_QT_BREAKPAD - const QString libexecPath = QCoreApplication::applicationDirPath() + '/' + RELATIVE_LIBEXEC_PATH; - QtSystemExceptionHandler systemExceptionHandler(libexecPath); -#endif - -#if defined(ENABLE_CRASHPAD) && defined(Q_OS_WIN) - /* startCrashpad(); */ -#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 - - if (application->arguments().at(1) == "--readcapturedstream") - return 0; - - return application->exec(); -} -} // namespace - -int main(int argc, char *argv[]) -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - qInstallMessageHandler(myMessageOutput); -#endif - // Since we always render text into an FBO, we need to globally disable - // subpixel antialiasing and instead use gray. - qputenv("QSG_DISTANCEFIELD_ANTIALIASING", "gray"); -#ifdef Q_OS_MACOS - qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true"); -#endif - - //If a style different from Desktop is set we have to use QGuiApplication - bool useGuiApplication = (!qEnvironmentVariableIsSet("QMLDESIGNER_FORCE_QAPPLICATION") - || qgetenv("QMLDESIGNER_FORCE_QAPPLICATION") != "true") - && qEnvironmentVariableIsSet("QT_QUICK_CONTROLS_STYLE") - && qgetenv("QT_QUICK_CONTROLS_STYLE") != "Desktop"; - -#ifdef MULTILANGUAGE_TRANSLATIONPROVIDER - Sqlite::LibraryInitializer::initialize(); -#endif - - if (useGuiApplication) { - QGuiApplication application(argc, argv); - return internalMain(&application); - } else { - QApplication application(argc, argv); - return internalMain(&application); - } -} diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp deleted file mode 100644 index 5d36ff8755..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.cpp +++ /dev/null @@ -1,624 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#include "qmlprivategate.h" - -#include <objectnodeinstance.h> -#include <nodeinstanceserver.h> - -#include <QQuickItem> -#include <QQmlComponent> -#include <QFileInfo> -#include <QProcessEnvironment> - -#include <private/qabstractfileengine_p.h> -#include <private/qfsfileengine_p.h> - -#include <private/qquickdesignersupport_p.h> -#include <private/qquickdesignersupportmetainfo_p.h> -#include <private/qquickdesignersupportitems_p.h> -#include <private/qquickdesignersupportproperties_p.h> -#include <private/qquickdesignersupportpropertychanges_p.h> -#include <private/qquickdesignersupportstates_p.h> -#include <private/qqmldata_p.h> -#include <private/qqmlcomponentattached_p.h> - -#include <private/qabstractanimation_p.h> -#include <private/qobject_p.h> -#include <private/qquickbehavior_p.h> -#include <private/qquicktext_p.h> -#include <private/qquicktextinput_p.h> -#include <private/qquicktextedit_p.h> -#include <private/qquicktransition_p.h> -#include <private/qquickloader_p.h> - -#include <private/qquickanimation_p.h> -#include <private/qqmlmetatype_p.h> -#include <private/qqmltimer_p.h> - -#ifdef QUICK3D_MODULE -#include <private/qquick3dobject_p.h> -#include <private/qquick3drepeater_p.h> -#endif - -namespace QmlDesigner { - -namespace Internal { - -namespace QmlPrivateGate { - -bool isPropertyBlackListed(const QmlDesigner::PropertyName &propertyName) -{ - return QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName); -} - -#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0)) && (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)) - -static void addToPropertyNameListIfNotBlackListed( - PropertyNameList *propertyNameList, const QQuickQQuickDesignerSupport::PropertyName &propertyName) -{ - if (!QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName)) - propertyNameList->append(propertyName); -} - -PropertyNameList allPropertyNamesInline(QObject *object, - const PropertyName &baseName = {}, - QObjectList *inspectedObjects = nullptr, - int depth = 0) -{ - QQuickQQuickDesignerSupport::PropertyNameList propertyNameList; - - QObjectList localObjectList; - - if (inspectedObjects == nullptr) - inspectedObjects = &localObjectList; - - if (depth > 2) - return propertyNameList; - - if (!inspectedObjects->contains(object)) - inspectedObjects->append(object); - - const QMetaObject *metaObject = object->metaObject(); - - QStringList deferredPropertyNames; - const int namesIndex = metaObject->indexOfClassInfo("DeferredPropertyNames"); - if (namesIndex != -1) { - QMetaClassInfo classInfo = metaObject->classInfo(namesIndex); - deferredPropertyNames = QString::fromUtf8(classInfo.value()).split(QLatin1Char(',')); - } - - for (int index = 0; index < metaObject->propertyCount(); ++index) { - QMetaProperty metaProperty = metaObject->property(index); - QQmlProperty declarativeProperty(object, QString::fromUtf8(metaProperty.name())); - if (declarativeProperty.isValid() - && declarativeProperty.propertyTypeCategory() == QQmlProperty::Object) { - if (declarativeProperty.name() != QLatin1String("parent") - && !deferredPropertyNames.contains(declarativeProperty.name())) { - QObject *childObject = QQmlMetaType::toQObject(declarativeProperty.read()); - if (childObject) - propertyNameList.append( - allPropertyNamesInline(childObject, - baseName - + QQuickQQuickDesignerSupport::PropertyName( - metaProperty.name()) - + '.', - inspectedObjects, - depth + 1)); - } - } else if (QQmlGadgetPtrWrapper *valueType - = QQmlGadgetPtrWrapper::instance(qmlEngine(object), metaProperty.userType())) { - valueType->setValue(metaProperty.read(object)); - propertyNameList.append(baseName - + QQuickQQuickDesignerSupport::PropertyName(metaProperty.name())); - propertyNameList.append( - allPropertyNamesInline(valueType, - baseName - + QQuickQQuickDesignerSupport::PropertyName(metaProperty.name()) - + '.', - inspectedObjects, - depth + 1)); - } else { - addToPropertyNameListIfNotBlackListed(&propertyNameList, - baseName - + QQuickQQuickDesignerSupport::PropertyName( - metaProperty.name())); - } - } - - return propertyNameList; -} -#endif - -PropertyNameList allPropertyNames(QObject *object) -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - return QQuickDesignerSupportProperties::allPropertyNames(object); -#elif QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - return allPropertyNamesInline(object); -#else - return QQuickDesignerSupportProperties::allPropertyNames(object); -#endif -} - -PropertyNameList propertyNameListForWritableProperties(QObject *object) -{ - return QQuickDesignerSupportProperties::propertyNameListForWritableProperties(object); -} - -void tweakObjects(QObject *object) -{ - QQuickDesignerSupportItems::tweakObjects(object); -} - -void createNewDynamicProperty(QObject *object, QQmlEngine *engine, const QString &name) -{ - QQuickDesignerSupportProperties::createNewDynamicProperty(object, engine, name); -} - -void registerNodeInstanceMetaObject(QObject *object, QQmlEngine *engine) -{ - QQuickDesignerSupportProperties::registerNodeInstanceMetaObject(object, engine); -} - -static bool isMetaObjectofType(const QMetaObject *metaObject, const QByteArray &type) -{ - if (metaObject) { - if (metaObject->className() == type) - return true; - - return isMetaObjectofType(metaObject->superClass(), type); - } - - return false; -} - -static bool isQuickStyleItem(QObject *object) -{ - if (object) - return isMetaObjectofType(object->metaObject(), "QQuickStyleItem"); - - return false; -} - -static bool isDelegateModel(QObject *object) -{ - if (object) - return isMetaObjectofType(object->metaObject(), "QQmlDelegateModel"); - - return false; -} - -// This is used in share/qtcreator/qml/qmlpuppet/qml2puppet/instances/objectnodeinstance.cpp -QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context) -{ -#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) - - QTypeRevision revision = QTypeRevision::zero(); - if (majorNumber > 0) - revision = QTypeRevision::fromVersion(majorNumber, minorNumber); - return QQuickDesignerSupportItems::createPrimitive(typeName, revision, context); -#else - return QQuickDesignerSupportItems::createPrimitive(typeName, majorNumber, minorNumber, context); -#endif -} - -static QString qmlDesignerRCPath() -{ - static const QString qmlDesignerRcPathsString = QString::fromLocal8Bit( - qgetenv("QMLDESIGNER_RC_PATHS")); - return qmlDesignerRcPathsString; -} - -QVariant fixResourcePaths(const QVariant &value) -{ - if (value.type() == QVariant::Url) - { - const QUrl url = value.toUrl(); - if (url.scheme() == QLatin1String("qrc")) { - const QString path = QLatin1String("qrc:") + url.path(); - if (!qmlDesignerRCPath().isEmpty()) { - const QStringList searchPaths = qmlDesignerRCPath().split(QLatin1Char(';')); - foreach (const QString &qrcPath, searchPaths) { - const QStringList qrcDefintion = qrcPath.split(QLatin1Char('=')); - if (qrcDefintion.count() == 2) { - QString fixedPath = path; - fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/')); - if (QFileInfo::exists(fixedPath)) { - fixedPath.replace(QLatin1String("//"), QLatin1String("/")); - fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/')); - return QUrl::fromLocalFile(fixedPath); - } - } - } - } - } - } - if (value.type() == QVariant::String) { - const QString str = value.toString(); - if (str.contains(QLatin1String("qrc:"))) { - if (!qmlDesignerRCPath().isEmpty()) { - const QStringList searchPaths = qmlDesignerRCPath().split(QLatin1Char(';')); - foreach (const QString &qrcPath, searchPaths) { - const QStringList qrcDefintion = qrcPath.split(QLatin1Char('=')); - if (qrcDefintion.count() == 2) { - QString fixedPath = str; - fixedPath.replace(QLatin1String("qrc:") + qrcDefintion.first(), qrcDefintion.last() + QLatin1Char('/')); - if (QFileInfo::exists(fixedPath)) { - fixedPath.replace(QLatin1String("//"), QLatin1String("/")); - fixedPath.replace(QLatin1Char('\\'), QLatin1Char('/')); - return QUrl::fromLocalFile(fixedPath); - } - } - } - } - } - } - return value; -} - -QObject *createComponent(const QUrl &componentUrl, QQmlContext *context) -{ - return QQuickDesignerSupportItems::createComponent(componentUrl, context); -} - -bool hasFullImplementedListInterface(const QQmlListReference &list) -{ - return list.isValid() && list.canCount() && list.canAt() && list.canAppend() && list.canClear(); -} - -void registerCustomData(QObject *object) -{ - QQuickDesignerSupportProperties::registerCustomData(object); -} - -QVariant getResetValue(QObject *object, const PropertyName &propertyName) -{ - if (propertyName == "Layout.rowSpan") - return 1; - else if (propertyName == "Layout.columnSpan") - return 1; - else if (propertyName == "Layout.fillHeight") - return false; - else if (propertyName == "Layout.fillWidth") - return false; - else - return QQuickDesignerSupportProperties::getResetValue(object, propertyName); -} - -static void setProperty(QObject *object, QQmlContext *context, const PropertyName &propertyName, const QVariant &value) -{ - QQmlProperty property(object, QString::fromUtf8(propertyName), context); - property.write(value); -} - -void doResetProperty(QObject *object, QQmlContext *context, const PropertyName &propertyName) -{ - if (propertyName == "Layout.rowSpan") - setProperty(object, context, propertyName, getResetValue(object, propertyName)); - else if (propertyName == "Layout.columnSpan") - setProperty(object, context, propertyName, getResetValue(object, propertyName)); - else if (propertyName == "Layout.fillHeight") - setProperty(object, context, propertyName, getResetValue(object, propertyName)); - else if (propertyName == "Layout.fillWidth") - setProperty(object, context, propertyName, getResetValue(object, propertyName)); - else - QQuickDesignerSupportProperties::doResetProperty(object, context, propertyName); -} - -bool hasValidResetBinding(QObject *object, const PropertyName &propertyName) -{ - if (propertyName == "Layout.rowSpan") - return true; - else if (propertyName == "Layout.columnSpan") - return true; - else if (propertyName == "Layout.fillHeight") - return true; - else if (propertyName == "Layout.fillWidth") - return true; - return QQuickDesignerSupportProperties::hasValidResetBinding(object, propertyName); -} - -bool hasBindingForProperty(QObject *object, QQmlContext *context, const PropertyName &propertyName, bool *hasChanged) -{ - return QQuickDesignerSupportProperties::hasBindingForProperty(object, context, propertyName, hasChanged); -} - -void setPropertyBinding(QObject *object, QQmlContext *context, const PropertyName &propertyName, const QString &expression) -{ - QQuickDesignerSupportProperties::setPropertyBinding(object, context, propertyName, expression); -} - -void emitComponentComplete(QObject *item) -{ - if (!item) - return; - - QQmlData *data = QQmlData::get(item); - if (data && data->context) { -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - QQmlComponentAttached *componentAttached = data->context->componentAttached; -#else - QQmlComponentAttached *componentAttached = data->context->componentAttacheds(); -#endif - while (componentAttached) { - if (componentAttached->parent()) - if (componentAttached->parent() == item) - emit componentAttached->completed(); - -#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) - componentAttached = componentAttached->next; -#else - componentAttached = componentAttached->next(); -#endif - } - } -} - -void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer) -{ - if (object) { - QQuickItem *item = qobject_cast<QQuickItem*>(object); - - if (item && QQuickDesignerSupport::isComponentComplete(item)) - return; -#ifdef QUICK3D_MODULE - auto obj3d = qobject_cast<QQuick3DRepeater *>(object); - if (obj3d && QQuick3DObjectPrivate::get(obj3d)->componentComplete) - return; -#endif - - if (!nodeInstanceServer->hasInstanceForObject(item)) - emitComponentComplete(object); - QList<QObject*> childList = object->children(); - - if (item) { - foreach (QQuickItem *childItem, item->childItems()) { - if (!childList.contains(childItem)) - childList.append(childItem); - } - } - - foreach (QObject *child, childList) { - if (!nodeInstanceServer->hasInstanceForObject(child)) - doComponentCompleteRecursive(child, nodeInstanceServer); - } - - if (!isQuickStyleItem(object) && !isDelegateModel(object)) { - if (item) { - static_cast<QQmlParserStatus *>(item)->componentComplete(); - } else { - QQmlParserStatus *qmlParserStatus = dynamic_cast<QQmlParserStatus *>(object); - if (qmlParserStatus) { - qmlParserStatus->componentComplete(); - auto *anim = dynamic_cast<QQuickAbstractAnimation *>(object); - if (anim && ViewConfig::isParticleViewMode()) { - nodeInstanceServer->addAnimation(anim); - anim->setEnableUserControl(); - anim->stop(); - } - } - } - } - } -} - - -void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const PropertyName &propertyName) -{ - QQuickDesignerSupportProperties::keepBindingFromGettingDeleted(object, context, propertyName); -} - -bool objectWasDeleted(QObject *object) -{ - return QQuickDesignerSupportItems::objectWasDeleted(object); -} - -void disableNativeTextRendering(QQuickItem *item) -{ - QQuickDesignerSupportItems::disableNativeTextRendering(item); -} - -void disableTextCursor(QQuickItem *item) -{ - QQuickDesignerSupportItems::disableTextCursor(item); -} - -void disableTransition(QObject *object) -{ - QQuickDesignerSupportItems::disableTransition(object); -} - -void disableBehaivour(QObject *object) -{ - QQuickDesignerSupportItems::disableBehaivour(object); -} - -void stopUnifiedTimer() -{ - QQuickDesignerSupportItems::stopUnifiedTimer(); -} - -bool isPropertyQObject(const QMetaProperty &metaProperty) -{ - return QQuickDesignerSupportProperties::isPropertyQObject(metaProperty); -} - -QObject *readQObjectProperty(const QMetaProperty &metaProperty, QObject *object) -{ - return QQuickDesignerSupportProperties::readQObjectProperty(metaProperty, object); -} - -namespace States { - -bool isStateActive(QObject *object, QQmlContext *context) -{ - - return QQuickDesignerSupportStates::isStateActive(object, context); -} - -void activateState(QObject *object, QQmlContext *context) -{ - QQuickDesignerSupportStates::activateState(object, context); -} - -void deactivateState(QObject *object) -{ - QQuickDesignerSupportStates::deactivateState(object); -} - -bool changeValueInRevertList(QObject *state, QObject *target, const PropertyName &propertyName, const QVariant &value) -{ - return QQuickDesignerSupportStates::changeValueInRevertList(state, target, propertyName, value); -} - -bool updateStateBinding(QObject *state, QObject *target, const PropertyName &propertyName, const QString &expression) -{ - return QQuickDesignerSupportStates::updateStateBinding(state, target, propertyName, expression); -} - -bool resetStateProperty(QObject *state, QObject *target, const PropertyName &propertyName, const QVariant &value) -{ - return QQuickDesignerSupportStates::resetStateProperty(state, target, propertyName, value); -} - -} //namespace States - -namespace PropertyChanges { - -void detachFromState(QObject *propertyChanges) -{ - return QQuickDesignerSupportPropertyChanges::detachFromState(propertyChanges); -} - -void attachToState(QObject *propertyChanges) -{ - return QQuickDesignerSupportPropertyChanges::attachToState(propertyChanges); -} - -QObject *targetObject(QObject *propertyChanges) -{ - return QQuickDesignerSupportPropertyChanges::targetObject(propertyChanges); -} - -void removeProperty(QObject *propertyChanges, const PropertyName &propertyName) -{ - QQuickDesignerSupportPropertyChanges::removeProperty(propertyChanges, propertyName); -} - -QVariant getProperty(QObject *propertyChanges, const PropertyName &propertyName) -{ - return QQuickDesignerSupportPropertyChanges::getProperty(propertyChanges, propertyName); -} - -void changeValue(QObject *propertyChanges, const PropertyName &propertyName, const QVariant &value) -{ - QQuickDesignerSupportPropertyChanges::changeValue(propertyChanges, propertyName, value); -} - -void changeExpression(QObject *propertyChanges, const PropertyName &propertyName, const QString &expression) -{ - QQuickDesignerSupportPropertyChanges::changeExpression(propertyChanges, propertyName, expression); -} - -QObject *stateObject(QObject *propertyChanges) -{ - return QQuickDesignerSupportPropertyChanges::stateObject(propertyChanges); -} - -bool isNormalProperty(const PropertyName &propertyName) -{ - return QQuickDesignerSupportPropertyChanges::isNormalProperty(propertyName); -} - -} // namespace PropertyChanges - -bool isSubclassOf(QObject *object, const QByteArray &superTypeName) -{ - return QQuickDesignerSupportMetaInfo::isSubclassOf(object, superTypeName); -} - -void getPropertyCache(QObject *object, QQmlEngine *engine) -{ -#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) - QQuickDesignerSupportProperties::getPropertyCache(object, engine); -#else - Q_UNUSED(engine); - QQuickDesignerSupportProperties::getPropertyCache(object); -#endif -} - -void registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &)) -{ - QQuickDesignerSupportMetaInfo::registerNotifyPropertyChangeCallBack(callback); -} - -ComponentCompleteDisabler::ComponentCompleteDisabler() -{ - QQuickDesignerSupport::disableComponentComplete(); -} - -ComponentCompleteDisabler::~ComponentCompleteDisabler() -{ - QQuickDesignerSupport::enableComponentComplete(); -} - -class QrcEngineHandler : public QAbstractFileEngineHandler -{ -public: - QAbstractFileEngine *create(const QString &fileName) const final; -}; - -QAbstractFileEngine *QrcEngineHandler::create(const QString &fileName) const -{ - if (fileName.startsWith(":/qt-project.org")) - return nullptr; - - if (fileName.startsWith(":/qtquickplugin")) - return nullptr; - - if (fileName.startsWith(":/")) { - const QStringList searchPaths = qmlDesignerRCPath().split(';'); - foreach (const QString &qrcPath, searchPaths) { - const QStringList qrcDefintion = qrcPath.split('='); - if (qrcDefintion.count() == 2) { - QString fixedPath = fileName; - fixedPath.replace(":" + qrcDefintion.first(), qrcDefintion.last() + '/'); - - if (fileName == fixedPath) - return nullptr; - - if (QFileInfo::exists(fixedPath)) { - fixedPath.replace("//", "/"); - fixedPath.replace('\\', '/'); - return new QFSFileEngine(fixedPath); - } - } - } - } - - return nullptr; -} - -static QrcEngineHandler* s_qrcEngineHandler = nullptr; - -class EngineHandlerDeleter -{ -public: - EngineHandlerDeleter() - {} - ~EngineHandlerDeleter() - { delete s_qrcEngineHandler; } -}; - -void registerFixResourcePathsForObjectCallBack() -{ - static EngineHandlerDeleter deleter; - - if (!s_qrcEngineHandler) - s_qrcEngineHandler = new QrcEngineHandler(); -} - -} // namespace QmlPrivateGate -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.h b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.h deleted file mode 100644 index 7ba9e1b2ce..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.h +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include "nodeinstanceglobal.h" - -#include <QObject> -#include <QString> -#include <QVariant> -#include <QQmlContext> -#include <QQmlListReference> -#include <QQuickItem> - -namespace QmlDesigner { - -class NodeInstanceServer; - -namespace Internal { - -class ObjectNodeInstance; -typedef QSharedPointer<ObjectNodeInstance> ObjectNodeInstancePointer; -typedef QWeakPointer<ObjectNodeInstance> ObjectNodeInstanceWeakPointer; - -namespace QmlPrivateGate { - -class ComponentCompleteDisabler -{ -public: -#if (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0)) - ComponentCompleteDisabler(); - - ~ComponentCompleteDisabler(); -#else - ComponentCompleteDisabler() - { - //nothing not available yet - } -#endif -}; - - void createNewDynamicProperty(QObject *object, QQmlEngine *engine, const QString &name); - void registerNodeInstanceMetaObject(QObject *object, QQmlEngine *engine); - QVariant fixResourcePaths(const QVariant &value); - QObject *createPrimitive(const QString &typeName, int majorNumber, int minorNumber, QQmlContext *context); - QObject *createComponent(const QUrl &componentUrl, QQmlContext *context); - void tweakObjects(QObject *object); - bool isPropertyBlackListed(const QmlDesigner::PropertyName &propertyName); - PropertyNameList propertyNameListForWritableProperties(QObject *object, - const PropertyName &baseName = PropertyName(), - QObjectList *inspectedObjects = nullptr); - PropertyNameList allPropertyNames(QObject *object); - bool hasFullImplementedListInterface(const QQmlListReference &list); - - void registerCustomData(QObject *object); - QVariant getResetValue(QObject *object, const PropertyName &propertyName); - void doResetProperty(QObject *object, QQmlContext *context, const PropertyName &propertyName); - bool hasValidResetBinding(QObject *object, const PropertyName &propertyName); - - bool hasBindingForProperty(QObject *object, QQmlContext *context, const PropertyName &propertyName, bool *hasChanged); - void setPropertyBinding(QObject *object, QQmlContext *context, const PropertyName &propertyName, const QString &expression); - void keepBindingFromGettingDeleted(QObject *object, QQmlContext *context, const PropertyName &propertyName); - - void emitComponentComplete(QObject *item); - void doComponentCompleteRecursive(QObject *object, NodeInstanceServer *nodeInstanceServer); - - bool objectWasDeleted(QObject *object); - void disableNativeTextRendering(QQuickItem *item); - void disableTextCursor(QQuickItem *item); - void disableTransition(QObject *object); - void disableBehaivour(QObject *object); - void stopUnifiedTimer(); - bool isPropertyQObject(const QMetaProperty &metaProperty); - QObject *readQObjectProperty(const QMetaProperty &metaProperty, QObject *object); - - namespace States { - - bool isStateActive(QObject *object, QQmlContext *context); - void activateState(QObject *object, QQmlContext *context); - void deactivateState(QObject *object); - bool changeValueInRevertList(QObject *state, QObject *target, const PropertyName &propertyName, const QVariant &value); - bool updateStateBinding(QObject *state, QObject *target, const PropertyName &propertyName, const QString &expression); - bool resetStateProperty(QObject *state, QObject *target, const PropertyName &propertyName, const QVariant &); - - } //namespace States - - namespace PropertyChanges { - - void detachFromState(QObject *propertyChanges); - void attachToState(QObject *propertyChanges); - QObject *targetObject(QObject *propertyChanges); - void removeProperty(QObject *propertyChanges, const PropertyName &propertyName); - QVariant getProperty(QObject *propertyChanges, const PropertyName &propertyName); - void changeValue(QObject *propertyChanges, const PropertyName &propertyName, const QVariant &value); - void changeExpression(QObject *propertyChanges, const PropertyName &propertyName, const QString &expression); - QObject *stateObject(QObject *propertyChanges); - bool isNormalProperty(const PropertyName &propertyName); - - } // namespace PropertyChanges - - - bool isSubclassOf(QObject *object, const QByteArray &superTypeName); - void getPropertyCache(QObject *object, QQmlEngine *engine); - - void registerNotifyPropertyChangeCallBack(void (*callback)(QObject *, const PropertyName &)); - - void registerFixResourcePathsForObjectCallBack(); - -} // namespace QmlPrivateGate -} // namespace Internal -} // namespace QmlDesigner diff --git a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri b/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri deleted file mode 100644 index 896ab52b00..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qmlprivategate/qmlprivategate.pri +++ /dev/null @@ -1,7 +0,0 @@ -INCLUDEPATH += $$PWD/ - -HEADERS += \ - $$PWD/qmlprivategate.h - -SOURCES += \ - $$PWD/qmlprivategate.cpp diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc b/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc deleted file mode 100644 index 162c955ac1..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet.qrc +++ /dev/null @@ -1,15 +0,0 @@ -<RCC> - <qresource prefix="/qtquickplugin"> - <file>images/template_image.png</file> - <file>html/welcome.html</file> - <file>images/webkit.png</file> - <file>images/non-visual-component.png</file> - <file>images/non-visual-component@2x.png</file> - <file>mockfiles/Window.qml</file> - <file>mockfiles/SwipeView.qml</file> - <file>mockfiles/GenericBackend.qml</file> - <file>mockfiles/Dialog.qml</file> - <file>mockfiles/ToolBarButton.qml</file> - <file>mockfiles/ToggleButton.qml</file> - </qresource> -</RCC> diff --git a/share/qtcreator/qml/qmlpuppet/qmlpuppet_utilities.pri b/share/qtcreator/qml/qmlpuppet/qmlpuppet_utilities.pri deleted file mode 100644 index 341550502a..0000000000 --- a/share/qtcreator/qml/qmlpuppet/qmlpuppet_utilities.pri +++ /dev/null @@ -1,31 +0,0 @@ -# Try to find location of Qt private headers (see README) -isEmpty(QT_PRIVATE_HEADERS) { - QT_PRIVATE_HEADERS = $$[QT_INSTALL_HEADERS] -} else { - INCLUDEPATH += \ - $${QT_PRIVATE_HEADERS} \ - $${QT_PRIVATE_HEADERS}/QtCore \ - $${QT_PRIVATE_HEADERS}/QtGui \ - $${QT_PRIVATE_HEADERS}/QtScript \ - $${QT_PRIVATE_HEADERS}/QtDeclarative -} - -defineTest(minQtVersion) { - maj = $$1 - min = $$2 - patch = $$3 - isEqual(QT_MAJOR_VERSION, $$maj) { - isEqual(QT_MINOR_VERSION, $$min) { - isEqual(QT_PATCH_VERSION, $$patch) { - return(true) - } - greaterThan(QT_PATCH_VERSION, $$patch) { - return(true) - } - } - greaterThan(QT_MINOR_VERSION, $$min) { - return(true) - } - } - return(false) -} diff --git a/share/qtcreator/qml/qmlpuppet/types/enumeration.h b/share/qtcreator/qml/qmlpuppet/types/enumeration.h deleted file mode 100644 index 85d353d80d..0000000000 --- a/share/qtcreator/qml/qmlpuppet/types/enumeration.h +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0 WITH Qt-GPL-exception-1.0 - -#pragma once - -#include <QByteArray> -#include <QDataStream> -#include <QMetaType> -#include <QVariant> - -#include <QString> -#include <QList> -#include <QtDebug> - -namespace QmlDesigner { - -using EnumerationName = QByteArray; - -class Enumeration -{ - friend bool operator ==(const Enumeration &first, const Enumeration &second); - friend bool operator <(const Enumeration &first, const Enumeration &second); - friend QDataStream &operator>>(QDataStream &in, Enumeration &enumeration); - -public: - Enumeration() = default; - Enumeration(const EnumerationName &enumerationName) - : m_enumerationName(enumerationName) - { - } - Enumeration(const QString &enumerationName) - : m_enumerationName(enumerationName.toUtf8()) - { - } - Enumeration(const QString &scope, const QString &name) - { - QString enumerationString = scope + QLatin1Char('.') + name; - m_enumerationName = enumerationString.toUtf8(); - } - - EnumerationName scope() const - { - return m_enumerationName.split('.').constFirst(); - } - EnumerationName name() const - { - return m_enumerationName.split('.').last(); - } - EnumerationName toEnumerationName() const - { - return m_enumerationName; - } - QString toString() const - { - return QString::fromUtf8(m_enumerationName); - } - QString nameToString() const - { - return QString::fromUtf8(name()); - } - -private: - EnumerationName m_enumerationName; -}; - -inline QDataStream &operator<<(QDataStream &out, const Enumeration &enumeration){ - out << enumeration.toEnumerationName(); - return out; -} - -inline QDataStream &operator>>(QDataStream &in, Enumeration &enumeration) -{ - in >> enumeration.m_enumerationName; - return in; -} - - -inline bool operator==(const Enumeration &first, const Enumeration &second) -{ - return first.m_enumerationName == second.m_enumerationName; -} - -inline bool operator<(const Enumeration &first, const Enumeration &second) -{ - return first.m_enumerationName < second.m_enumerationName; -} - -inline QDebug operator <<(QDebug debug, const Enumeration &enumeration) -{ - debug.nospace() << "Enumeration(" - << enumeration.toString() - << ")"; - return debug; -} - -} // namespace QmlDesigner - -Q_DECLARE_METATYPE(QmlDesigner::Enumeration) diff --git a/share/qtcreator/qml/qmlpuppet/types/types.pri b/share/qtcreator/qml/qmlpuppet/types/types.pri deleted file mode 100644 index e5f10bcbe4..0000000000 --- a/share/qtcreator/qml/qmlpuppet/types/types.pri +++ /dev/null @@ -1,3 +0,0 @@ -INCLUDEPATH += $$PWD/ - -HEADERS += $$PWD/enumeration.h |