forked from qt-creator/qt-creator
QmlDesigner: Break dependency to View3DActionCommand
The node instance view and his commands should be not called directly from other views. There are special classes QmlItem which can do it but every change should go through the model. Change-Id: I734e5538d7f6ecb07d736912f647c5eb92dc7631 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -8,19 +8,12 @@
|
||||
|
||||
namespace QmlDesigner {
|
||||
|
||||
View3DActionCommand::View3DActionCommand(Type type, const QVariant &value)
|
||||
View3DActionCommand::View3DActionCommand(View3DActionType type, const QVariant &value)
|
||||
: m_type(type)
|
||||
, m_value(value)
|
||||
{
|
||||
}
|
||||
|
||||
View3DActionCommand::View3DActionCommand(int pos)
|
||||
: m_type(ParticlesSeek)
|
||||
, m_value(pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool View3DActionCommand::isEnabled() const
|
||||
{
|
||||
return m_value.toBool();
|
||||
@@ -31,7 +24,7 @@ QVariant View3DActionCommand::value() const
|
||||
return m_value;
|
||||
}
|
||||
|
||||
View3DActionCommand::Type View3DActionCommand::type() const
|
||||
View3DActionType View3DActionCommand::type() const
|
||||
{
|
||||
return m_type;
|
||||
}
|
||||
@@ -51,19 +44,15 @@ int View3DActionCommand::position() const
|
||||
QDataStream &operator<<(QDataStream &out, const View3DActionCommand &command)
|
||||
{
|
||||
out << command.value();
|
||||
out << qint32(command.type());
|
||||
out << command.type();
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
QDataStream &operator>>(QDataStream &in, View3DActionCommand &command)
|
||||
{
|
||||
QVariant value;
|
||||
qint32 type;
|
||||
in >> value;
|
||||
in >> type;
|
||||
command.m_value = value;
|
||||
command.m_type = View3DActionCommand::Type(type);
|
||||
in >> command.m_value;
|
||||
in >> command.m_type;
|
||||
|
||||
return in;
|
||||
}
|
||||
@@ -75,4 +64,16 @@ QDebug operator<<(QDebug debug, const View3DActionCommand &command)
|
||||
<< 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
|
||||
|
@@ -3,6 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nodeinstanceglobal.h>
|
||||
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
|
||||
@@ -14,60 +16,25 @@ class View3DActionCommand
|
||||
friend QDebug operator<<(QDebug debug, const View3DActionCommand &command);
|
||||
|
||||
public:
|
||||
enum Type { 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
|
||||
};
|
||||
|
||||
View3DActionCommand(Type type, const QVariant &value);
|
||||
View3DActionCommand(View3DActionType type, const QVariant &value);
|
||||
|
||||
View3DActionCommand() = default;
|
||||
|
||||
bool isEnabled() const;
|
||||
QVariant value() const;
|
||||
Type type() const;
|
||||
View3DActionType type() const;
|
||||
int position() const;
|
||||
|
||||
private:
|
||||
Type m_type = Empty;
|
||||
View3DActionType m_type = View3DActionType::Empty;
|
||||
QVariant m_value;
|
||||
|
||||
protected:
|
||||
View3DActionCommand(int pos);
|
||||
};
|
||||
|
||||
class View3DSeekActionCommand : public View3DActionCommand
|
||||
{
|
||||
public:
|
||||
View3DSeekActionCommand(int pos) : View3DActionCommand(pos) {}
|
||||
};
|
||||
|
||||
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
|
||||
|
||||
|
@@ -22,4 +22,32 @@ enum class AuxiliaryDataType {
|
||||
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
|
||||
};
|
||||
}
|
||||
|
@@ -903,7 +903,7 @@ void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D([[maybe_unu
|
||||
bool sync = toolStates["syncBackgroundColor"].toBool();
|
||||
if (sync) {
|
||||
QColor color = helper->sceneEnvironmentColor(sceneId);
|
||||
View3DActionCommand cmd(View3DActionCommand::SelectBackgroundColor,
|
||||
View3DActionCommand cmd(View3DActionType::SelectBackgroundColor,
|
||||
QVariant::fromValue(color));
|
||||
view3DAction(cmd);
|
||||
}
|
||||
@@ -1910,13 +1910,14 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(
|
||||
createCameraAndLightGizmos(instanceList);
|
||||
|
||||
if (!command.edit3dBackgroundColor.isEmpty()) {
|
||||
View3DActionCommand backgroundColorCommand(View3DActionCommand::SelectBackgroundColor,
|
||||
QVariant::fromValue(command.edit3dBackgroundColor));
|
||||
View3DActionCommand backgroundColorCommand(View3DActionType::SelectBackgroundColor,
|
||||
QVariant::fromValue(
|
||||
command.edit3dBackgroundColor));
|
||||
view3DAction(backgroundColorCommand);
|
||||
}
|
||||
|
||||
if (command.edit3dGridColor.isValid()) {
|
||||
View3DActionCommand backgroundColorCommand(View3DActionCommand::SelectGridColor,
|
||||
View3DActionCommand backgroundColorCommand(View3DActionType::SelectGridColor,
|
||||
QVariant::fromValue(command.edit3dGridColor));
|
||||
view3DAction(backgroundColorCommand);
|
||||
}
|
||||
@@ -2242,7 +2243,8 @@ void Qt5InformationNodeInstanceServer::setSceneEnvironmentColor(const PropertyVa
|
||||
if (toolStates.contains("syncBackgroundColor")) {
|
||||
bool sync = toolStates["syncBackgroundColor"].toBool();
|
||||
if (sync) {
|
||||
View3DActionCommand cmd(View3DActionCommand::SelectBackgroundColor, QVariant::fromValue(color));
|
||||
View3DActionCommand cmd(View3DActionType::SelectBackgroundColor,
|
||||
QVariant::fromValue(color));
|
||||
view3DAction(cmd);
|
||||
}
|
||||
}
|
||||
@@ -2316,65 +2318,65 @@ void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &c
|
||||
int renderCount = 1;
|
||||
|
||||
switch (command.type()) {
|
||||
case View3DActionCommand::MoveTool:
|
||||
case View3DActionType::MoveTool:
|
||||
updatedToolState.insert("transformMode", 0);
|
||||
break;
|
||||
case View3DActionCommand::RotateTool:
|
||||
case View3DActionType::RotateTool:
|
||||
updatedToolState.insert("transformMode", 1);
|
||||
break;
|
||||
case View3DActionCommand::ScaleTool:
|
||||
case View3DActionType::ScaleTool:
|
||||
updatedToolState.insert("transformMode", 2);
|
||||
break;
|
||||
case View3DActionCommand::FitToView:
|
||||
case View3DActionType::FitToView:
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "fitToView");
|
||||
break;
|
||||
case View3DActionCommand::AlignCamerasToView:
|
||||
case View3DActionType::AlignCamerasToView:
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "alignCamerasToView");
|
||||
break;
|
||||
case View3DActionCommand::AlignViewToCamera:
|
||||
case View3DActionType::AlignViewToCamera:
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "alignViewToCamera");
|
||||
break;
|
||||
case View3DActionCommand::SelectionModeToggle:
|
||||
case View3DActionType::SelectionModeToggle:
|
||||
updatedToolState.insert("selectionMode", command.isEnabled() ? 1 : 0);
|
||||
break;
|
||||
case View3DActionCommand::CameraToggle:
|
||||
case View3DActionType::CameraToggle:
|
||||
updatedToolState.insert("usePerspective", command.isEnabled());
|
||||
// It can take a couple frames to properly update icon gizmo positions
|
||||
renderCount = 2;
|
||||
break;
|
||||
case View3DActionCommand::OrientationToggle:
|
||||
case View3DActionType::OrientationToggle:
|
||||
updatedToolState.insert("globalOrientation", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::EditLightToggle:
|
||||
case View3DActionType::EditLightToggle:
|
||||
updatedToolState.insert("showEditLight", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::ShowGrid:
|
||||
case View3DActionType::ShowGrid:
|
||||
updatedToolState.insert("showGrid", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::ShowSelectionBox:
|
||||
case View3DActionType::ShowSelectionBox:
|
||||
updatedToolState.insert("showSelectionBox", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::ShowIconGizmo:
|
||||
case View3DActionType::ShowIconGizmo:
|
||||
updatedToolState.insert("showIconGizmo", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::ShowCameraFrustum:
|
||||
case View3DActionType::ShowCameraFrustum:
|
||||
updatedToolState.insert("showCameraFrustum", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::SyncBackgroundColor:
|
||||
case View3DActionType::SyncBackgroundColor:
|
||||
updatedToolState.insert("syncBackgroundColor", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::SelectBackgroundColor:
|
||||
case View3DActionType::SelectBackgroundColor:
|
||||
updatedViewState.insert("selectBackgroundColor", command.value());
|
||||
break;
|
||||
case View3DActionCommand::SelectGridColor: {
|
||||
case View3DActionType::SelectGridColor: {
|
||||
updatedViewState.insert("selectGridColor", command.value());
|
||||
break;
|
||||
}
|
||||
#ifdef QUICK3D_PARTICLES_MODULE
|
||||
case View3DActionCommand::ShowParticleEmitter:
|
||||
case View3DActionType::ShowParticleEmitter:
|
||||
updatedToolState.insert("showParticleEmitter", command.isEnabled());
|
||||
break;
|
||||
case View3DActionCommand::ParticlesPlay:
|
||||
case View3DActionType::ParticlesPlay:
|
||||
m_particleAnimationPlaying = command.isEnabled();
|
||||
updatedToolState.insert("particlePlay", command.isEnabled());
|
||||
if (m_particleAnimationPlaying) {
|
||||
@@ -2386,7 +2388,7 @@ void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &c
|
||||
m_particleAnimationDriver->setSeekerEnabled(true);
|
||||
}
|
||||
break;
|
||||
case View3DActionCommand::ParticlesRestart:
|
||||
case View3DActionType::ParticlesRestart:
|
||||
resetParticleSystem();
|
||||
if (m_particleAnimationPlaying) {
|
||||
m_particleAnimationDriver->restart();
|
||||
@@ -2394,12 +2396,12 @@ void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &c
|
||||
m_particleAnimationDriver->setSeekerPosition(0);
|
||||
}
|
||||
break;
|
||||
case View3DActionCommand::ParticlesSeek:
|
||||
m_particleAnimationDriver->setSeekerPosition(static_cast<const View3DSeekActionCommand &>(command).position());
|
||||
case View3DActionType::ParticlesSeek:
|
||||
m_particleAnimationDriver->setSeekerPosition(command.position());
|
||||
break;
|
||||
#endif
|
||||
#ifdef QUICK3D_MODULE
|
||||
case View3DActionCommand::GetNodeAtPos: {
|
||||
case View3DActionType::GetNodeAtPos: {
|
||||
getNodeAtPos(command.value().toPointF());
|
||||
return;
|
||||
}
|
||||
|
@@ -10,13 +10,15 @@
|
||||
|
||||
using namespace QmlDesigner;
|
||||
|
||||
void BackgroundColorSelection::showBackgroundColorSelectionWidget(QWidget *parent, const QByteArray &key,
|
||||
View3DActionCommand::Type cmdType)
|
||||
void BackgroundColorSelection::showBackgroundColorSelectionWidget(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType)
|
||||
{
|
||||
if (m_dialog)
|
||||
return;
|
||||
|
||||
m_dialog = BackgroundColorSelection::createColorDialog(parent, key, cmdType);
|
||||
m_dialog = BackgroundColorSelection::createColorDialog(parent, key, view, actionType);
|
||||
QTC_ASSERT(m_dialog, return);
|
||||
|
||||
QObject::connect(m_dialog, &QWidget::destroyed, m_dialog, [&]() {
|
||||
@@ -24,8 +26,10 @@ void BackgroundColorSelection::showBackgroundColorSelectionWidget(QWidget *paren
|
||||
});
|
||||
}
|
||||
|
||||
QColorDialog *BackgroundColorSelection::createColorDialog(QWidget *parent, const QByteArray &key,
|
||||
View3DActionCommand::Type cmdType)
|
||||
QColorDialog *BackgroundColorSelection::createColorDialog(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType)
|
||||
{
|
||||
auto dialog = new QColorDialog(parent);
|
||||
|
||||
@@ -36,17 +40,20 @@ QColorDialog *BackgroundColorSelection::createColorDialog(QWidget *parent, const
|
||||
|
||||
dialog->show();
|
||||
|
||||
QObject::connect(dialog, &QColorDialog::currentColorChanged, dialog, [cmdType](const QColor &color) {
|
||||
Edit3DViewConfig::set(cmdType, color);
|
||||
});
|
||||
QObject::connect(dialog,
|
||||
&QColorDialog::currentColorChanged,
|
||||
dialog,
|
||||
[actionType, view](const QColor &color) {
|
||||
Edit3DViewConfig::set(view, actionType, color);
|
||||
});
|
||||
|
||||
QObject::connect(dialog, &QColorDialog::colorSelected, dialog, [key](const QColor &color) {
|
||||
Edit3DViewConfig::save(key, color);
|
||||
});
|
||||
|
||||
if (Edit3DViewConfig::isValid(oldColorConfig)) {
|
||||
QObject::connect(dialog, &QColorDialog::rejected, dialog, [cmdType, oldColorConfig]() {
|
||||
Edit3DViewConfig::set(cmdType, oldColorConfig);
|
||||
QObject::connect(dialog, &QColorDialog::rejected, dialog, [actionType, oldColorConfig, view]() {
|
||||
Edit3DViewConfig::set(view, actionType, oldColorConfig);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -3,12 +3,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nodeinstanceglobal.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <view3dactioncommand.h>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QColorDialog)
|
||||
|
||||
namespace QmlDesigner {
|
||||
class AbstractView;
|
||||
|
||||
class BackgroundColorSelection : public QObject
|
||||
{
|
||||
@@ -19,12 +21,16 @@ public:
|
||||
: QObject{parent}
|
||||
{}
|
||||
|
||||
static void showBackgroundColorSelectionWidget(QWidget *parent, const QByteArray &key,
|
||||
View3DActionCommand::Type cmdType);
|
||||
static void showBackgroundColorSelectionWidget(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType);
|
||||
|
||||
private:
|
||||
static QColorDialog *createColorDialog(QWidget *parent, const QByteArray &key,
|
||||
View3DActionCommand::Type cmdType);
|
||||
static QColorDialog *createColorDialog(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType);
|
||||
|
||||
inline static QColorDialog *m_dialog = nullptr;
|
||||
};
|
||||
|
@@ -18,30 +18,37 @@ namespace QmlDesigner {
|
||||
|
||||
Edit3DActionTemplate::Edit3DActionTemplate(const QString &description,
|
||||
SelectionContextOperation action,
|
||||
View3DActionCommand::Type type)
|
||||
: DefaultAction(description),
|
||||
m_action(action),
|
||||
m_type(type)
|
||||
{ }
|
||||
AbstractView *view,
|
||||
View3DActionType type)
|
||||
: DefaultAction(description)
|
||||
, m_action(action)
|
||||
, m_view(view)
|
||||
, m_type(type)
|
||||
{}
|
||||
|
||||
void Edit3DActionTemplate::actionTriggered(bool b)
|
||||
{
|
||||
if (m_type != View3DActionCommand::Empty && m_type != View3DActionCommand::SelectBackgroundColor
|
||||
&& m_type != View3DActionCommand::SelectGridColor) {
|
||||
auto view = QmlDesignerPlugin::instance()->viewManager().nodeInstanceView();
|
||||
View3DActionCommand cmd(m_type, b);
|
||||
view->view3DAction(cmd);
|
||||
if (m_type != View3DActionType::Empty && m_type != View3DActionType::SelectBackgroundColor
|
||||
&& m_type != View3DActionType::SelectGridColor) {
|
||||
m_view->emitView3DAction(m_type, b);
|
||||
}
|
||||
|
||||
if (m_action)
|
||||
m_action(m_selectionContext);
|
||||
}
|
||||
|
||||
Edit3DAction::Edit3DAction(const QByteArray &menuId, View3DActionCommand::Type type,
|
||||
const QString &description, const QKeySequence &key, bool checkable,
|
||||
bool checked, const QIcon &iconOff, const QIcon &iconOn,
|
||||
SelectionContextOperation selectionAction, const QString &toolTip)
|
||||
: AbstractAction(new Edit3DActionTemplate(description, selectionAction, type))
|
||||
Edit3DAction::Edit3DAction(const QByteArray &menuId,
|
||||
View3DActionType type,
|
||||
const QString &description,
|
||||
const QKeySequence &key,
|
||||
bool checkable,
|
||||
bool checked,
|
||||
const QIcon &iconOff,
|
||||
const QIcon &iconOn,
|
||||
AbstractView *view,
|
||||
SelectionContextOperation selectionAction,
|
||||
const QString &toolTip)
|
||||
: AbstractAction(new Edit3DActionTemplate(description, selectionAction, view, type))
|
||||
, m_menuId(menuId)
|
||||
{
|
||||
action()->setShortcut(key);
|
||||
@@ -81,12 +88,17 @@ bool Edit3DAction::isEnabled(const SelectionContext &selectionContext) const
|
||||
return isVisible(selectionContext);
|
||||
}
|
||||
|
||||
Edit3DCameraAction::Edit3DCameraAction(const QByteArray &menuId, View3DActionCommand::Type type,
|
||||
const QString &description, const QKeySequence &key,
|
||||
bool checkable, bool checked, const QIcon &iconOff,
|
||||
Edit3DCameraAction::Edit3DCameraAction(const QByteArray &menuId,
|
||||
View3DActionType type,
|
||||
const QString &description,
|
||||
const QKeySequence &key,
|
||||
bool checkable,
|
||||
bool checked,
|
||||
const QIcon &iconOff,
|
||||
const QIcon &iconOn,
|
||||
AbstractView *view,
|
||||
SelectionContextOperation selectionAction)
|
||||
: Edit3DAction(menuId, type, description, key, checkable, checked, iconOff, iconOn, selectionAction)
|
||||
: Edit3DAction(menuId, type, description, key, checkable, checked, iconOff, iconOn, view, selectionAction)
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -2,8 +2,6 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||
#pragma once
|
||||
|
||||
#include "view3dactioncommand.h"
|
||||
|
||||
#include <abstractaction.h>
|
||||
|
||||
#include <QAction>
|
||||
@@ -15,23 +13,31 @@ using SelectionContextOperation = std::function<void(const SelectionContext &)>;
|
||||
|
||||
class Edit3DActionTemplate : public DefaultAction
|
||||
{
|
||||
|
||||
public:
|
||||
Edit3DActionTemplate(const QString &description, SelectionContextOperation action,
|
||||
View3DActionCommand::Type type);
|
||||
Edit3DActionTemplate(const QString &description,
|
||||
SelectionContextOperation action,
|
||||
AbstractView *view,
|
||||
View3DActionType type);
|
||||
|
||||
void actionTriggered(bool b) override;
|
||||
|
||||
SelectionContextOperation m_action;
|
||||
View3DActionCommand::Type m_type;
|
||||
AbstractView *m_view;
|
||||
View3DActionType m_type;
|
||||
};
|
||||
|
||||
class Edit3DAction : public AbstractAction
|
||||
{
|
||||
public:
|
||||
Edit3DAction(const QByteArray &menuId, View3DActionCommand::Type type,
|
||||
const QString &description, const QKeySequence &key, bool checkable, bool checked,
|
||||
const QIcon &iconOff, const QIcon &iconOn,
|
||||
Edit3DAction(const QByteArray &menuId,
|
||||
View3DActionType type,
|
||||
const QString &description,
|
||||
const QKeySequence &key,
|
||||
bool checkable,
|
||||
bool checked,
|
||||
const QIcon &iconOff,
|
||||
const QIcon &iconOn,
|
||||
AbstractView *view,
|
||||
SelectionContextOperation selectionAction = nullptr,
|
||||
const QString &toolTip = {});
|
||||
|
||||
@@ -63,10 +69,17 @@ private:
|
||||
class Edit3DCameraAction : public Edit3DAction
|
||||
{
|
||||
public:
|
||||
Edit3DCameraAction(const QByteArray &menuId, View3DActionCommand::Type type,
|
||||
const QString &description, const QKeySequence &key, bool checkable, bool checked,
|
||||
const QIcon &iconOff, const QIcon &iconOn,
|
||||
Edit3DCameraAction(const QByteArray &menuId,
|
||||
View3DActionType type,
|
||||
const QString &description,
|
||||
const QKeySequence &key,
|
||||
bool checkable,
|
||||
bool checked,
|
||||
const QIcon &iconOff,
|
||||
const QIcon &iconOn,
|
||||
AbstractView *view,
|
||||
SelectionContextOperation selectionAction = nullptr);
|
||||
|
||||
protected:
|
||||
bool isEnabled(const SelectionContext &selectionContext) const override;
|
||||
};
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include "backgroundcolorselection.h"
|
||||
#include "metainfo.h"
|
||||
#include "seekerslider.h"
|
||||
#include "view3dactioncommand.h"
|
||||
#include "nodehints.h"
|
||||
|
||||
#include <auxiliarydataproperties.h>
|
||||
@@ -327,14 +326,21 @@ Edit3DAction *Edit3DView::createSelectBackgrounColorAction()
|
||||
BackgroundColorSelection::showBackgroundColorSelectionWidget(
|
||||
edit3DWidget(),
|
||||
DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR,
|
||||
View3DActionCommand::SelectBackgroundColor);
|
||||
this,
|
||||
View3DActionType::SelectBackgroundColor);
|
||||
};
|
||||
|
||||
return new Edit3DAction(
|
||||
Constants::EDIT3D_EDIT_SELECT_BACKGROUND_COLOR, View3DActionCommand::SelectBackgroundColor,
|
||||
description,
|
||||
{}, false, false, {}, {}, operation,
|
||||
tooltip);
|
||||
return new Edit3DAction(Constants::EDIT3D_EDIT_SELECT_BACKGROUND_COLOR,
|
||||
View3DActionType::SelectBackgroundColor,
|
||||
description,
|
||||
{},
|
||||
false,
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
operation,
|
||||
tooltip);
|
||||
}
|
||||
|
||||
Edit3DAction *Edit3DView::createGridColorSelectionAction()
|
||||
@@ -347,13 +353,21 @@ Edit3DAction *Edit3DView::createGridColorSelectionAction()
|
||||
BackgroundColorSelection::showBackgroundColorSelectionWidget(
|
||||
edit3DWidget(),
|
||||
DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR,
|
||||
View3DActionCommand::SelectGridColor);
|
||||
this,
|
||||
View3DActionType::SelectGridColor);
|
||||
};
|
||||
|
||||
return new Edit3DAction(
|
||||
Constants::EDIT3D_EDIT_SELECT_GRID_COLOR, View3DActionCommand::SelectGridColor,
|
||||
description, {}, false, false, {}, {}, operation,
|
||||
tooltip);
|
||||
return new Edit3DAction(Constants::EDIT3D_EDIT_SELECT_GRID_COLOR,
|
||||
View3DActionType::SelectGridColor,
|
||||
description,
|
||||
{},
|
||||
false,
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
operation,
|
||||
tooltip);
|
||||
}
|
||||
|
||||
Edit3DAction *Edit3DView::createResetColorAction()
|
||||
@@ -363,21 +377,27 @@ Edit3DAction *Edit3DView::createResetColorAction()
|
||||
"Reset the background color and the color of the "
|
||||
"grid lines of the 3D Editor to the default valus.");
|
||||
|
||||
auto operation = [](const SelectionContext &) {
|
||||
auto operation = [&](const SelectionContext &) {
|
||||
QList<QColor> bgColors = {QRgb(0x222222), QRgb(0x999999)};
|
||||
Edit3DViewConfig::set(View3DActionCommand::SelectBackgroundColor, bgColors);
|
||||
Edit3DViewConfig::set(this, View3DActionType::SelectBackgroundColor, bgColors);
|
||||
Edit3DViewConfig::save(DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR, bgColors);
|
||||
|
||||
QColor gridColor{0xaaaaaa};
|
||||
Edit3DViewConfig::set(View3DActionCommand::SelectGridColor, gridColor);
|
||||
Edit3DViewConfig::set(this, View3DActionType::SelectGridColor, gridColor);
|
||||
Edit3DViewConfig::save(DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR, gridColor);
|
||||
};
|
||||
|
||||
return new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_RESET_BACKGROUND_COLOR, View3DActionCommand::ResetBackgroundColor,
|
||||
description,
|
||||
{}, false, false, {}, {}, operation,
|
||||
tooltip);
|
||||
return new Edit3DAction(QmlDesigner::Constants::EDIT3D_EDIT_RESET_BACKGROUND_COLOR,
|
||||
View3DActionType::ResetBackgroundColor,
|
||||
description,
|
||||
{},
|
||||
false,
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
operation,
|
||||
tooltip);
|
||||
}
|
||||
|
||||
Edit3DAction *Edit3DView::createSyncBackgroundColorAction()
|
||||
@@ -388,108 +408,206 @@ Edit3DAction *Edit3DView::createSyncBackgroundColorAction()
|
||||
"Sets the 3D Editor to use the Scene Environment "
|
||||
"color as background color.");
|
||||
|
||||
return new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SYNC_BACKGROUND_COLOR, View3DActionCommand::SyncBackgroundColor,
|
||||
description,
|
||||
{}, true, false, {}, {}, {},
|
||||
tooltip);
|
||||
return new Edit3DAction(QmlDesigner::Constants::EDIT3D_EDIT_SYNC_BACKGROUND_COLOR,
|
||||
View3DActionType::SyncBackgroundColor,
|
||||
description,
|
||||
{},
|
||||
true,
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
{},
|
||||
tooltip);
|
||||
}
|
||||
|
||||
void Edit3DView::createEdit3DActions()
|
||||
{
|
||||
m_selectionModeAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_SELECTION_MODE, View3DActionCommand::SelectionModeToggle,
|
||||
QCoreApplication::translate("SelectionModeToggleAction", "Toggle Group/Single Selection Mode"),
|
||||
QKeySequence(Qt::Key_Q), true, false, Icons::EDIT3D_SELECTION_MODE_OFF.icon(),
|
||||
Icons::EDIT3D_SELECTION_MODE_ON.icon());
|
||||
m_selectionModeAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_SELECTION_MODE,
|
||||
View3DActionType::SelectionModeToggle,
|
||||
QCoreApplication::translate("SelectionModeToggleAction", "Toggle Group/Single Selection Mode"),
|
||||
QKeySequence(Qt::Key_Q),
|
||||
true,
|
||||
false,
|
||||
Icons::EDIT3D_SELECTION_MODE_OFF.icon(),
|
||||
Icons::EDIT3D_SELECTION_MODE_ON.icon(),
|
||||
this);
|
||||
|
||||
m_moveToolAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_MOVE_TOOL, View3DActionCommand::MoveTool,
|
||||
QCoreApplication::translate("MoveToolAction", "Activate Move Tool"),
|
||||
QKeySequence(Qt::Key_W), true, true, Icons::EDIT3D_MOVE_TOOL_OFF.icon(),
|
||||
Icons::EDIT3D_MOVE_TOOL_ON.icon());
|
||||
m_moveToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_MOVE_TOOL,
|
||||
View3DActionType::MoveTool,
|
||||
QCoreApplication::translate("MoveToolAction",
|
||||
"Activate Move Tool"),
|
||||
QKeySequence(Qt::Key_W),
|
||||
true,
|
||||
true,
|
||||
Icons::EDIT3D_MOVE_TOOL_OFF.icon(),
|
||||
Icons::EDIT3D_MOVE_TOOL_ON.icon(),
|
||||
this);
|
||||
|
||||
m_rotateToolAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_ROTATE_TOOL, View3DActionCommand::RotateTool,
|
||||
QCoreApplication::translate("RotateToolAction", "Activate Rotate Tool"),
|
||||
QKeySequence(Qt::Key_E), true, false, Icons::EDIT3D_ROTATE_TOOL_OFF.icon(),
|
||||
Icons::EDIT3D_ROTATE_TOOL_ON.icon());
|
||||
m_rotateToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_ROTATE_TOOL,
|
||||
View3DActionType::RotateTool,
|
||||
QCoreApplication::translate("RotateToolAction",
|
||||
"Activate Rotate Tool"),
|
||||
QKeySequence(Qt::Key_E),
|
||||
true,
|
||||
false,
|
||||
Icons::EDIT3D_ROTATE_TOOL_OFF.icon(),
|
||||
Icons::EDIT3D_ROTATE_TOOL_ON.icon(),
|
||||
this);
|
||||
|
||||
m_scaleToolAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_SCALE_TOOL, View3DActionCommand::ScaleTool,
|
||||
QCoreApplication::translate("ScaleToolAction", "Activate Scale Tool"),
|
||||
QKeySequence(Qt::Key_R), true, false, Icons::EDIT3D_SCALE_TOOL_OFF.icon(),
|
||||
Icons::EDIT3D_SCALE_TOOL_ON.icon());
|
||||
m_scaleToolAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_SCALE_TOOL,
|
||||
View3DActionType::ScaleTool,
|
||||
QCoreApplication::translate("ScaleToolAction",
|
||||
"Activate Scale Tool"),
|
||||
QKeySequence(Qt::Key_R),
|
||||
true,
|
||||
false,
|
||||
Icons::EDIT3D_SCALE_TOOL_OFF.icon(),
|
||||
Icons::EDIT3D_SCALE_TOOL_ON.icon(),
|
||||
this);
|
||||
|
||||
m_fitAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_FIT_SELECTED, View3DActionCommand::FitToView,
|
||||
QCoreApplication::translate("FitToViewAction", "Fit Selected Object to View"),
|
||||
QKeySequence(Qt::Key_F), false, false, Icons::EDIT3D_FIT_SELECTED_OFF.icon(), {});
|
||||
m_fitAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_FIT_SELECTED,
|
||||
View3DActionType::FitToView,
|
||||
QCoreApplication::translate("FitToViewAction",
|
||||
"Fit Selected Object to View"),
|
||||
QKeySequence(Qt::Key_F),
|
||||
false,
|
||||
false,
|
||||
Icons::EDIT3D_FIT_SELECTED_OFF.icon(),
|
||||
{},
|
||||
this);
|
||||
|
||||
m_alignCamerasAction = new Edit3DCameraAction(
|
||||
QmlDesigner::Constants::EDIT3D_ALIGN_CAMERAS, View3DActionCommand::AlignCamerasToView,
|
||||
QCoreApplication::translate("AlignCamerasToViewAction", "Align Selected Cameras to View"),
|
||||
QKeySequence(), false, false, Icons::EDIT3D_ALIGN_CAMERA_ON.icon(), {});
|
||||
QmlDesigner::Constants::EDIT3D_ALIGN_CAMERAS,
|
||||
View3DActionType::AlignCamerasToView,
|
||||
QCoreApplication::translate("AlignCamerasToViewAction", "Align Selected Cameras to View"),
|
||||
QKeySequence(),
|
||||
false,
|
||||
false,
|
||||
Icons::EDIT3D_ALIGN_CAMERA_ON.icon(),
|
||||
{},
|
||||
this);
|
||||
|
||||
m_alignViewAction = new Edit3DCameraAction(
|
||||
QmlDesigner::Constants::EDIT3D_ALIGN_VIEW, View3DActionCommand::AlignViewToCamera,
|
||||
QCoreApplication::translate("AlignCamerasToViewAction", "Align View to Selected Camera"),
|
||||
QKeySequence(), false, false, Icons::EDIT3D_ALIGN_VIEW_ON.icon(), {});
|
||||
QmlDesigner::Constants::EDIT3D_ALIGN_VIEW,
|
||||
View3DActionType::AlignViewToCamera,
|
||||
QCoreApplication::translate("AlignCamerasToViewAction", "Align View to Selected Camera"),
|
||||
QKeySequence(),
|
||||
false,
|
||||
false,
|
||||
Icons::EDIT3D_ALIGN_VIEW_ON.icon(),
|
||||
{},
|
||||
this);
|
||||
|
||||
m_cameraModeAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_CAMERA, View3DActionCommand::CameraToggle,
|
||||
QCoreApplication::translate("CameraToggleAction", "Toggle Perspective/Orthographic Edit Camera"),
|
||||
QKeySequence(Qt::Key_T), true, false, Icons::EDIT3D_EDIT_CAMERA_OFF.icon(),
|
||||
Icons::EDIT3D_EDIT_CAMERA_ON.icon());
|
||||
m_cameraModeAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_CAMERA,
|
||||
View3DActionType::CameraToggle,
|
||||
QCoreApplication::translate("CameraToggleAction",
|
||||
"Toggle Perspective/Orthographic Edit Camera"),
|
||||
QKeySequence(Qt::Key_T),
|
||||
true,
|
||||
false,
|
||||
Icons::EDIT3D_EDIT_CAMERA_OFF.icon(),
|
||||
Icons::EDIT3D_EDIT_CAMERA_ON.icon(),
|
||||
this);
|
||||
|
||||
m_orientationModeAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_ORIENTATION, View3DActionCommand::OrientationToggle,
|
||||
QCoreApplication::translate("OrientationToggleAction", "Toggle Global/Local Orientation"),
|
||||
QKeySequence(Qt::Key_Y), true, false, Icons::EDIT3D_ORIENTATION_OFF.icon(),
|
||||
Icons::EDIT3D_ORIENTATION_ON.icon());
|
||||
m_orientationModeAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_ORIENTATION,
|
||||
View3DActionType::OrientationToggle,
|
||||
QCoreApplication::translate("OrientationToggleAction", "Toggle Global/Local Orientation"),
|
||||
QKeySequence(Qt::Key_Y),
|
||||
true,
|
||||
false,
|
||||
Icons::EDIT3D_ORIENTATION_OFF.icon(),
|
||||
Icons::EDIT3D_ORIENTATION_ON.icon(),
|
||||
this);
|
||||
|
||||
m_editLightAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_LIGHT, View3DActionCommand::EditLightToggle,
|
||||
QCoreApplication::translate("EditLightToggleAction", "Toggle Edit Light On/Off"),
|
||||
QKeySequence(Qt::Key_U), true, false, Icons::EDIT3D_LIGHT_OFF.icon(),
|
||||
Icons::EDIT3D_LIGHT_ON.icon());
|
||||
m_editLightAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_EDIT_LIGHT,
|
||||
View3DActionType::EditLightToggle,
|
||||
QCoreApplication::translate("EditLightToggleAction",
|
||||
"Toggle Edit Light On/Off"),
|
||||
QKeySequence(Qt::Key_U),
|
||||
true,
|
||||
false,
|
||||
Icons::EDIT3D_LIGHT_OFF.icon(),
|
||||
Icons::EDIT3D_LIGHT_ON.icon(),
|
||||
this);
|
||||
|
||||
m_showGridAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_GRID, View3DActionCommand::ShowGrid,
|
||||
QCoreApplication::translate("ShowGridAction", "Show Grid"),
|
||||
QKeySequence(Qt::Key_G), true, true, {}, {}, nullptr,
|
||||
QCoreApplication::translate("ShowGridAction", "Toggle the visibility of the helper grid."));
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_GRID,
|
||||
View3DActionType::ShowGrid,
|
||||
QCoreApplication::translate("ShowGridAction", "Show Grid"),
|
||||
QKeySequence(Qt::Key_G),
|
||||
true,
|
||||
true,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
nullptr,
|
||||
QCoreApplication::translate("ShowGridAction", "Toggle the visibility of the helper grid."));
|
||||
|
||||
m_showSelectionBoxAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_SELECTION_BOX, View3DActionCommand::ShowSelectionBox,
|
||||
QCoreApplication::translate("ShowSelectionBoxAction", "Show Selection Boxes"),
|
||||
QKeySequence(Qt::Key_S), true, true, {}, {}, nullptr,
|
||||
QCoreApplication::translate("ShowSelectionBoxAction", "Toggle the visibility of selection boxes."));
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_SELECTION_BOX,
|
||||
View3DActionType::ShowSelectionBox,
|
||||
QCoreApplication::translate("ShowSelectionBoxAction", "Show Selection Boxes"),
|
||||
QKeySequence(Qt::Key_S),
|
||||
true,
|
||||
true,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
nullptr,
|
||||
QCoreApplication::translate("ShowSelectionBoxAction",
|
||||
"Toggle the visibility of selection boxes."));
|
||||
|
||||
m_showIconGizmoAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_ICON_GIZMO, View3DActionCommand::ShowIconGizmo,
|
||||
QCoreApplication::translate("ShowIconGizmoAction", "Show Icon Gizmos"),
|
||||
QKeySequence(Qt::Key_I), true, true, {}, {}, nullptr,
|
||||
QCoreApplication::translate("ShowIconGizmoAction", "Toggle the visibility of icon gizmos, such as light and camera icons."));
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_ICON_GIZMO,
|
||||
View3DActionType::ShowIconGizmo,
|
||||
QCoreApplication::translate("ShowIconGizmoAction", "Show Icon Gizmos"),
|
||||
QKeySequence(Qt::Key_I),
|
||||
true,
|
||||
true,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
nullptr,
|
||||
QCoreApplication::translate(
|
||||
"ShowIconGizmoAction",
|
||||
"Toggle the visibility of icon gizmos, such as light and camera icons."));
|
||||
|
||||
m_showCameraFrustumAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_CAMERA_FRUSTUM, View3DActionCommand::ShowCameraFrustum,
|
||||
QCoreApplication::translate("ShowCameraFrustumAction", "Always Show Camera Frustums"),
|
||||
QKeySequence(Qt::Key_C), true, false, {}, {}, nullptr,
|
||||
QCoreApplication::translate("ShowCameraFrustumAction", "Toggle between always showing the camera frustum visualization and only showing it when the camera is selected."));
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_CAMERA_FRUSTUM,
|
||||
View3DActionType::ShowCameraFrustum,
|
||||
QCoreApplication::translate("ShowCameraFrustumAction", "Always Show Camera Frustums"),
|
||||
QKeySequence(Qt::Key_C),
|
||||
true,
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
nullptr,
|
||||
QCoreApplication::translate(
|
||||
"ShowCameraFrustumAction",
|
||||
"Toggle between always showing the camera frustum visualization and only showing it "
|
||||
"when the camera is selected."));
|
||||
|
||||
m_showParticleEmitterAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_PARTICLE_EMITTER, View3DActionCommand::ShowParticleEmitter,
|
||||
QCoreApplication::translate("ShowParticleEmitterAction", "Always Show Particle Emitters And Attractors"),
|
||||
QKeySequence(Qt::Key_M), true, false, {}, {}, nullptr,
|
||||
QCoreApplication::translate("ShowParticleEmitterAction", "Toggle between always showing the particle emitter and attractor visualizations and only showing them when the emitter or attractor is selected."));
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_SHOW_PARTICLE_EMITTER,
|
||||
View3DActionType::ShowParticleEmitter,
|
||||
QCoreApplication::translate("ShowParticleEmitterAction",
|
||||
"Always Show Particle Emitters And Attractors"),
|
||||
QKeySequence(Qt::Key_M),
|
||||
true,
|
||||
false,
|
||||
{},
|
||||
{},
|
||||
this,
|
||||
nullptr,
|
||||
QCoreApplication::translate(
|
||||
"ShowParticleEmitterAction",
|
||||
"Toggle between always showing the particle emitter and attractor visualizations and "
|
||||
"only showing them when the emitter or attractor is selected."));
|
||||
|
||||
SelectionContextOperation resetTrigger = [this](const SelectionContext &) {
|
||||
m_particlesPlayAction->action()->setEnabled(particlemode);
|
||||
@@ -518,33 +636,51 @@ void Edit3DView::createEdit3DActions()
|
||||
m_seeker->setEnabled(!m_particlesPlayAction->action()->isChecked());
|
||||
};
|
||||
|
||||
m_particleViewModeAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_PARTICLE_MODE, View3DActionCommand::Edit3DParticleModeToggle,
|
||||
QCoreApplication::translate("ParticleViewModeAction", "Toggle particle animation On/Off"),
|
||||
QKeySequence(Qt::Key_V), true, false, Icons::EDIT3D_PARTICLE_OFF.icon(),
|
||||
Icons::EDIT3D_PARTICLE_ON.icon(), particlesTrigger);
|
||||
m_particleViewModeAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_PARTICLE_MODE,
|
||||
View3DActionType::Edit3DParticleModeToggle,
|
||||
QCoreApplication::translate("ParticleViewModeAction", "Toggle particle animation On/Off"),
|
||||
QKeySequence(Qt::Key_V),
|
||||
true,
|
||||
false,
|
||||
Icons::EDIT3D_PARTICLE_OFF.icon(),
|
||||
Icons::EDIT3D_PARTICLE_ON.icon(),
|
||||
this,
|
||||
particlesTrigger);
|
||||
particlemode = false;
|
||||
m_particlesPlayAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_PARTICLES_PLAY, View3DActionCommand::ParticlesPlay,
|
||||
QCoreApplication::translate("ParticlesPlayAction", "Play Particles"),
|
||||
QKeySequence(Qt::Key_Comma), true, true, Icons::EDIT3D_PARTICLE_PLAY.icon(),
|
||||
Icons::EDIT3D_PARTICLE_PAUSE.icon(), particlesPlayTrigger);
|
||||
m_particlesRestartAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_PARTICLES_RESTART, View3DActionCommand::ParticlesRestart,
|
||||
QCoreApplication::translate("ParticlesRestartAction", "Restart Particles"),
|
||||
QKeySequence(Qt::Key_Slash), false, false, Icons::EDIT3D_PARTICLE_RESTART.icon(),
|
||||
Icons::EDIT3D_PARTICLE_RESTART.icon());
|
||||
m_particlesPlayAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_PARTICLES_PLAY,
|
||||
View3DActionType::ParticlesPlay,
|
||||
QCoreApplication::translate("ParticlesPlayAction",
|
||||
"Play Particles"),
|
||||
QKeySequence(Qt::Key_Comma),
|
||||
true,
|
||||
true,
|
||||
Icons::EDIT3D_PARTICLE_PLAY.icon(),
|
||||
Icons::EDIT3D_PARTICLE_PAUSE.icon(),
|
||||
this,
|
||||
particlesPlayTrigger);
|
||||
m_particlesRestartAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_PARTICLES_RESTART,
|
||||
View3DActionType::ParticlesRestart,
|
||||
QCoreApplication::translate("ParticlesRestartAction", "Restart Particles"),
|
||||
QKeySequence(Qt::Key_Slash),
|
||||
false,
|
||||
false,
|
||||
Icons::EDIT3D_PARTICLE_RESTART.icon(),
|
||||
Icons::EDIT3D_PARTICLE_RESTART.icon(),
|
||||
this);
|
||||
m_particlesPlayAction->action()->setEnabled(particlemode);
|
||||
m_particlesRestartAction->action()->setEnabled(particlemode);
|
||||
m_resetAction
|
||||
= new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_RESET_VIEW, View3DActionCommand::Empty,
|
||||
QCoreApplication::translate("ResetView", "Reset View"),
|
||||
QKeySequence(Qt::Key_P), false, false, Utils::Icons::RESET_TOOLBAR.icon(), {},
|
||||
resetTrigger);
|
||||
m_resetAction = new Edit3DAction(QmlDesigner::Constants::EDIT3D_RESET_VIEW,
|
||||
View3DActionType::Empty,
|
||||
QCoreApplication::translate("ResetView", "Reset View"),
|
||||
QKeySequence(Qt::Key_P),
|
||||
false,
|
||||
false,
|
||||
Utils::Icons::RESET_TOOLBAR.icon(),
|
||||
{},
|
||||
this,
|
||||
resetTrigger);
|
||||
|
||||
SelectionContextOperation visibilityTogglesTrigger = [this](const SelectionContext &) {
|
||||
if (!edit3DWidget()->visibilityTogglesMenu())
|
||||
@@ -564,10 +700,16 @@ void Edit3DView::createEdit3DActions()
|
||||
};
|
||||
|
||||
m_visibilityTogglesAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_VISIBILITY_TOGGLES, View3DActionCommand::Empty,
|
||||
QCoreApplication::translate("VisibilityTogglesAction", "Visibility Toggles"),
|
||||
QKeySequence(), false, false, Utils::Icons::EYE_OPEN_TOOLBAR.icon(),
|
||||
{}, visibilityTogglesTrigger);
|
||||
QmlDesigner::Constants::EDIT3D_VISIBILITY_TOGGLES,
|
||||
View3DActionType::Empty,
|
||||
QCoreApplication::translate("VisibilityTogglesAction", "Visibility Toggles"),
|
||||
QKeySequence(),
|
||||
false,
|
||||
false,
|
||||
Utils::Icons::EYE_OPEN_TOOLBAR.icon(),
|
||||
{},
|
||||
this,
|
||||
visibilityTogglesTrigger);
|
||||
|
||||
SelectionContextOperation backgroundColorActionsTrigger = [this](const SelectionContext &) {
|
||||
if (!edit3DWidget()->backgroundColorMenu())
|
||||
@@ -587,10 +729,16 @@ void Edit3DView::createEdit3DActions()
|
||||
};
|
||||
|
||||
m_backgrondColorMenuAction = new Edit3DAction(
|
||||
QmlDesigner::Constants::EDIT3D_BACKGROUND_COLOR_ACTIONS, View3DActionCommand::Empty,
|
||||
QmlDesigner::Constants::EDIT3D_BACKGROUND_COLOR_ACTIONS,
|
||||
View3DActionType::Empty,
|
||||
QCoreApplication::translate("BackgroundColorMenuActions", "Background Color Actions"),
|
||||
QKeySequence(), false, false, Icons::COLOR_PALETTE.icon(),
|
||||
{}, backgroundColorActionsTrigger);
|
||||
QKeySequence(),
|
||||
false,
|
||||
false,
|
||||
Icons::COLOR_PALETTE.icon(),
|
||||
{},
|
||||
this,
|
||||
backgroundColorActionsTrigger);
|
||||
|
||||
m_leftActions << m_selectionModeAction;
|
||||
m_leftActions << nullptr; // Null indicates separator
|
||||
@@ -685,7 +833,7 @@ void Edit3DView::dropMaterial(const ModelNode &matNode, const QPointF &pos)
|
||||
{
|
||||
m_nodeAtPosReqType = NodeAtPosReqType::MaterialDrop;
|
||||
m_droppedMaterial = matNode;
|
||||
QmlDesignerPlugin::instance()->viewManager().nodeInstanceView()->view3DAction({View3DActionCommand::GetNodeAtPos, pos});
|
||||
emitView3DAction(View3DActionType::GetNodeAtPos, pos);
|
||||
}
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -3,8 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <view3dactioncommand.h>
|
||||
|
||||
#include <nodeinstanceview.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
|
||||
@@ -30,17 +28,17 @@ public:
|
||||
});
|
||||
}
|
||||
|
||||
static void set(View3DActionCommand::Type type, const QList<QColor> &colorConfig)
|
||||
static void set(AbstractView *view, View3DActionType type, const QList<QColor> &colorConfig)
|
||||
{
|
||||
if (colorConfig.size() == 1)
|
||||
set(type, colorConfig.at(0));
|
||||
set(view, type, colorConfig.at(0));
|
||||
else
|
||||
setVariant(type, QVariant::fromValue(colorConfig));
|
||||
setVariant(view, type, QVariant::fromValue(colorConfig));
|
||||
}
|
||||
|
||||
static void set(View3DActionCommand::Type type, const QColor &color)
|
||||
static void set(AbstractView *view, View3DActionType type, const QColor &color)
|
||||
{
|
||||
setVariant(type, QVariant::fromValue(color));
|
||||
setVariant(view, type, QVariant::fromValue(color));
|
||||
}
|
||||
|
||||
static void save(const QByteArray &key, const QList<QColor> &colorConfig)
|
||||
@@ -60,11 +58,9 @@ public:
|
||||
static bool isValid(const QList<QColor> &colorConfig) { return !colorConfig.isEmpty(); }
|
||||
|
||||
private:
|
||||
static void setVariant(View3DActionCommand::Type type, const QVariant &colorConfig)
|
||||
static void setVariant(AbstractView *view, View3DActionType type, const QVariant &colorConfig)
|
||||
{
|
||||
auto view = QmlDesignerPlugin::instance()->viewManager().nodeInstanceView();
|
||||
View3DActionCommand cmd(type, colorConfig);
|
||||
view->view3DAction(cmd);
|
||||
view->emitView3DAction(type, colorConfig);
|
||||
}
|
||||
|
||||
static void saveVariant(const QByteArray &key, const QVariant &colorConfig)
|
||||
|
@@ -130,9 +130,8 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view)
|
||||
view->setSeeker(seeker);
|
||||
seeker->setToolTip(QLatin1String("Seek particle system time when paused."));
|
||||
|
||||
QObject::connect(seeker, &SeekerSlider::positionChanged, [seeker](){
|
||||
QmlDesignerPlugin::instance()->viewManager().nodeInstanceView()
|
||||
->view3DAction(View3DSeekActionCommand(seeker->position()));
|
||||
QObject::connect(seeker, &SeekerSlider::positionChanged, [seeker, view]() {
|
||||
view->emitView3DAction(View3DActionType::ParticlesSeek, seeker->position());
|
||||
});
|
||||
|
||||
// Onboarding label contains instructions for new users how to get 3D content into the project
|
||||
|
@@ -140,7 +140,7 @@ bool DesignDocument::loadInFileComponent(const ModelNode &componentNode)
|
||||
return true;
|
||||
}
|
||||
|
||||
AbstractView *DesignDocument::view() const
|
||||
const AbstractView *DesignDocument::view() const
|
||||
{
|
||||
return viewManager().nodeInstanceView();
|
||||
}
|
||||
|
@@ -120,7 +120,7 @@ private: // functions
|
||||
|
||||
bool loadInFileComponent(const ModelNode &componentNode);
|
||||
|
||||
AbstractView *view() const;
|
||||
const AbstractView *view() const;
|
||||
|
||||
std::unique_ptr<Model> createInFileComponentModel();
|
||||
|
||||
|
@@ -146,6 +146,7 @@ public:
|
||||
void emitModelNodelPreviewPixmapChanged(const ModelNode &node, const QPixmap &pixmap);
|
||||
void emitImport3DSupportChanged(const QVariantMap &supportMap);
|
||||
void emitNodeAtPosResult(const ModelNode &modelNode);
|
||||
void emitView3DAction(View3DActionType type, const QVariant &value);
|
||||
|
||||
void sendTokenToInstances(const QString &token, int number, const QVector<ModelNode> &nodeVector);
|
||||
|
||||
@@ -216,6 +217,8 @@ public:
|
||||
virtual void nodeAtPosReady(const ModelNode &modelNode);
|
||||
virtual void modelNodePreviewPixmapChanged(const ModelNode &node, const QPixmap &pixmap);
|
||||
|
||||
virtual void view3DAction(View3DActionType type, const QVariant &value);
|
||||
|
||||
virtual void dragStarted(QMimeData *mimeData);
|
||||
virtual void dragEnded();
|
||||
|
||||
|
@@ -127,7 +127,7 @@ public:
|
||||
const QList<ModelNode> &lastSelectedNodeList) override;
|
||||
|
||||
void sendInputEvent(QInputEvent *e) const;
|
||||
void view3DAction(const View3DActionCommand &command);
|
||||
void view3DAction(View3DActionType type, const QVariant &value) override;
|
||||
void requestModelNodePreviewImage(const ModelNode &node, const ModelNode &renderNode);
|
||||
void edit3DViewResized(const QSize &size) const;
|
||||
|
||||
|
@@ -66,7 +66,7 @@ public:
|
||||
void pushInFileComponentOnCrumbleBar(const ModelNode &modelNode);
|
||||
void nextFileIsCalledInternally();
|
||||
|
||||
NodeInstanceView *nodeInstanceView() const;
|
||||
const NodeInstanceView *nodeInstanceView() const;
|
||||
|
||||
void exportAsImage();
|
||||
void reformatFileUsingTextEditorView();
|
||||
|
@@ -1759,9 +1759,9 @@ void NodeInstanceView::sendInputEvent(QInputEvent *e) const
|
||||
m_nodeInstanceServer->inputEvent(InputEventCommand(e));
|
||||
}
|
||||
|
||||
void NodeInstanceView::view3DAction(const View3DActionCommand &command)
|
||||
void NodeInstanceView::view3DAction(View3DActionType type, const QVariant &value)
|
||||
{
|
||||
m_nodeInstanceServer->view3DAction(command);
|
||||
m_nodeInstanceServer->view3DAction({type, value});
|
||||
}
|
||||
|
||||
void NodeInstanceView::requestModelNodePreviewImage(const ModelNode &node, const ModelNode &renderNode)
|
||||
|
@@ -395,6 +395,8 @@ void AbstractView::modelNodePreviewPixmapChanged(const ModelNode & /*node*/, con
|
||||
{
|
||||
}
|
||||
|
||||
void AbstractView::view3DAction(View3DActionType, const QVariant &) {}
|
||||
|
||||
void AbstractView::dragStarted(QMimeData * /*mimeData*/) {}
|
||||
void AbstractView::dragEnded() {}
|
||||
|
||||
@@ -787,6 +789,12 @@ void AbstractView::emitNodeAtPosResult(const ModelNode &modelNode)
|
||||
model()->d->notifyNodeAtPosResult(modelNode);
|
||||
}
|
||||
|
||||
void AbstractView::emitView3DAction(View3DActionType type, const QVariant &value)
|
||||
{
|
||||
if (model())
|
||||
model()->d->notifyView3DAction(type, value);
|
||||
}
|
||||
|
||||
void AbstractView::emitRewriterEndTransaction()
|
||||
{
|
||||
if (model())
|
||||
|
@@ -576,6 +576,11 @@ void ModelPrivate::notifyNodeAtPosResult(const ModelNode &modelNode)
|
||||
notifyInstanceChanges([&](AbstractView *view) { view->nodeAtPosReady(modelNode); });
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyView3DAction(View3DActionType type, const QVariant &value)
|
||||
{
|
||||
notifyNormalViewsLast([&](AbstractView *view) { view->view3DAction(type, value); });
|
||||
}
|
||||
|
||||
void ModelPrivate::notifyDragStarted(QMimeData *mimeData)
|
||||
{
|
||||
notifyInstanceChanges([&](AbstractView *view) { view->dragStarted(mimeData); });
|
||||
|
@@ -171,6 +171,7 @@ public:
|
||||
void notifyModelNodePreviewPixmapChanged(const ModelNode &node, const QPixmap &pixmap);
|
||||
void notifyImport3DSupportChanged(const QVariantMap &supportMap);
|
||||
void notifyNodeAtPosResult(const ModelNode &modelNode);
|
||||
void notifyView3DAction(View3DActionType type, const QVariant &value);
|
||||
|
||||
void notifyDragStarted(QMimeData *mimeData);
|
||||
void notifyDragEnded();
|
||||
|
@@ -361,7 +361,7 @@ void ViewManager::nextFileIsCalledInternally()
|
||||
crumbleBar()->nextFileIsCalledInternally();
|
||||
}
|
||||
|
||||
NodeInstanceView *ViewManager::nodeInstanceView() const
|
||||
const NodeInstanceView *ViewManager::nodeInstanceView() const
|
||||
{
|
||||
return &d->nodeInstanceView;
|
||||
}
|
||||
|
Reference in New Issue
Block a user