QmlDesigner: Add toggle button for 3D split view

The button and puppet communication is added for split view toggle.

Task-number: QDS-10921
Change-Id: I4322dfff6772eec493a2f3ce1722cdefb69bc490
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Miikka Heikkinen
2023-10-12 11:35:57 +03:00
parent 12aeed97b3
commit 87695e368b
6 changed files with 33 additions and 1 deletions

View File

@@ -46,7 +46,8 @@ enum class View3DActionType {
ParticlesSeek, ParticlesSeek,
SyncEnvBackground, SyncEnvBackground,
GetNodeAtPos, GetNodeAtPos,
SetBakeLightsView3D SetBakeLightsView3D,
SplitViewToggle
}; };
constexpr bool isNanotraceEnabled() constexpr bool isNanotraceEnabled()

View File

@@ -121,6 +121,7 @@ void Edit3DView::updateActiveScene3D(const QVariantMap &sceneState)
const QString particleEmitterKey = QStringLiteral("showParticleEmitter"); const QString particleEmitterKey = QStringLiteral("showParticleEmitter");
const QString particlesPlayKey = QStringLiteral("particlePlay"); const QString particlesPlayKey = QStringLiteral("particlePlay");
const QString syncEnvBgKey = QStringLiteral("syncEnvBackground"); const QString syncEnvBgKey = QStringLiteral("syncEnvBackground");
const QString splitViewKey = QStringLiteral("splitView");
if (sceneState.contains(sceneKey)) { if (sceneState.contains(sceneKey)) {
qint32 newActiveScene = sceneState[sceneKey].value<qint32>(); qint32 newActiveScene = sceneState[sceneKey].value<qint32>();
@@ -191,6 +192,11 @@ void Edit3DView::updateActiveScene3D(const QVariantMap &sceneState)
else else
m_particlesPlayAction->action()->setChecked(true); m_particlesPlayAction->action()->setChecked(true);
if (sceneState.contains(splitViewKey))
m_splitViewAction->action()->setChecked(sceneState[splitViewKey].toBool());
else
m_splitViewAction->action()->setChecked(false);
// Syncing background color only makes sense for children of View3D instances // Syncing background color only makes sense for children of View3D instances
bool syncValue = false; bool syncValue = false;
bool syncEnabled = false; bool syncEnabled = false;
@@ -1015,6 +1021,17 @@ void Edit3DView::createEdit3DActions()
this, this,
snapConfigTrigger); snapConfigTrigger);
m_splitViewAction = std::make_unique<Edit3DAction>(
QmlDesigner::Constants::EDIT3D_SPLIT_VIEW,
View3DActionType::SplitViewToggle,
QCoreApplication::translate("SplitViewToggleAction",
"Toggle Split View On/Off"),
QKeySequence(Qt::Key_4),
true,
false,
toolbarIcon(DesignerIcons::ScaleToolIcon), // TODO Placeholder, needs proper icon
this);
m_leftActions << m_selectionModeAction.get(); m_leftActions << m_selectionModeAction.get();
m_leftActions << nullptr; // Null indicates separator m_leftActions << nullptr; // Null indicates separator
m_leftActions << nullptr; // Second null after separator indicates an exclusive group m_leftActions << nullptr; // Second null after separator indicates an exclusive group
@@ -1036,6 +1053,7 @@ void Edit3DView::createEdit3DActions()
m_leftActions << nullptr; m_leftActions << nullptr;
m_leftActions << m_visibilityTogglesAction.get(); m_leftActions << m_visibilityTogglesAction.get();
m_leftActions << m_backgroundColorMenuAction.get(); m_leftActions << m_backgroundColorMenuAction.get();
m_leftActions << m_splitViewAction.get();
m_rightActions << m_particleViewModeAction.get(); m_rightActions << m_particleViewModeAction.get();
m_rightActions << m_particlesPlayAction.get(); m_rightActions << m_particlesPlayAction.get();

View File

@@ -139,6 +139,7 @@ private:
std::unique_ptr<Edit3DAction> m_selectBackgroundColorAction; std::unique_ptr<Edit3DAction> m_selectBackgroundColorAction;
std::unique_ptr<Edit3DAction> m_selectGridColorAction; std::unique_ptr<Edit3DAction> m_selectGridColorAction;
std::unique_ptr<Edit3DAction> m_resetColorAction; std::unique_ptr<Edit3DAction> m_resetColorAction;
std::unique_ptr<Edit3DAction> m_splitViewAction;
// View3DActionType::Empty actions // View3DActionType::Empty actions
std::unique_ptr<Edit3DAction> m_resetAction; std::unique_ptr<Edit3DAction> m_resetAction;

View File

@@ -62,6 +62,7 @@ const char EDIT3D_PARTICLE_MODE[] = "QmlDesigner.Editor3D.ParticleViewModeTo
const char EDIT3D_PARTICLES_PLAY[] = "QmlDesigner.Editor3D.ParticlesPlay"; const char EDIT3D_PARTICLES_PLAY[] = "QmlDesigner.Editor3D.ParticlesPlay";
const char EDIT3D_PARTICLES_SEEKER[] = "QmlDesigner.Editor3D.ParticlesSeeker"; const char EDIT3D_PARTICLES_SEEKER[] = "QmlDesigner.Editor3D.ParticlesSeeker";
const char EDIT3D_PARTICLES_RESTART[] = "QmlDesigner.Editor3D.ParticlesRestart"; const char EDIT3D_PARTICLES_RESTART[] = "QmlDesigner.Editor3D.ParticlesRestart";
const char EDIT3D_SPLIT_VIEW[] = "QmlDesigner.Editor3D.SplitViewToggle";
const char EDIT3D_VISIBILITY_TOGGLES[] = "QmlDesigner.Editor3D.VisibilityToggles"; const char EDIT3D_VISIBILITY_TOGGLES[] = "QmlDesigner.Editor3D.VisibilityToggles";
const char EDIT3D_BACKGROUND_COLOR_ACTIONS[] = "QmlDesigner.Editor3D.BackgroundColorActions"; const char EDIT3D_BACKGROUND_COLOR_ACTIONS[] = "QmlDesigner.Editor3D.BackgroundColorActions";
const char EDIT3D_BAKE_LIGHTS[] = "QmlDesigner.Editor3D.BakeLights"; const char EDIT3D_BAKE_LIGHTS[] = "QmlDesigner.Editor3D.BakeLights";

View File

@@ -28,6 +28,7 @@ Item {
property color backgroundGradientColorEnd: "#999999" property color backgroundGradientColorEnd: "#999999"
property color gridColor: "#cccccc" property color gridColor: "#cccccc"
property bool syncEnvBackground: false property bool syncEnvBackground: false
property bool splitView: false
enum SelectionMode { Item, Group } enum SelectionMode { Item, Group }
enum TransformMode { Move, Rotate, Scale } enum TransformMode { Move, Rotate, Scale }
@@ -65,6 +66,7 @@ Item {
onShowParticleEmitterChanged: _generalHelper.storeToolState(sceneId, "showParticleEmitter", showParticleEmitter); onShowParticleEmitterChanged: _generalHelper.storeToolState(sceneId, "showParticleEmitter", showParticleEmitter);
onSelectionModeChanged: _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode); onSelectionModeChanged: _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode);
onTransformModeChanged: _generalHelper.storeToolState(sceneId, "transformMode", transformMode); onTransformModeChanged: _generalHelper.storeToolState(sceneId, "transformMode", transformMode);
onSplitViewChanged: _generalHelper.storeToolState(sceneId, "splitView", splitView)
onActiveSceneChanged: updateActiveScene() onActiveSceneChanged: updateActiveScene()
@@ -294,6 +296,11 @@ Item {
cameraControl.restoreCameraState(toolStates.editCamState); cameraControl.restoreCameraState(toolStates.editCamState);
else if (resetToDefault) else if (resetToDefault)
cameraControl.restoreDefaultState(); cameraControl.restoreDefaultState();
if ("splitView" in toolStates)
splitView = toolStates.splitView;
else if (resetToDefault)
splitView = false;
} }
function storeCurrentToolStates() function storeCurrentToolStates()
@@ -309,6 +316,7 @@ Item {
_generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation) _generalHelper.storeToolState(sceneId, "globalOrientation", globalOrientation)
_generalHelper.storeToolState(sceneId, "selectionMode", selectionMode); _generalHelper.storeToolState(sceneId, "selectionMode", selectionMode);
_generalHelper.storeToolState(sceneId, "transformMode", transformMode); _generalHelper.storeToolState(sceneId, "transformMode", transformMode);
_generalHelper.storeToolState(sceneId, "splitView", splitView)
cameraControl.storeCameraState(0); cameraControl.storeCameraState(0);
} }

View File

@@ -2497,6 +2497,9 @@ void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &c
return; return;
} }
#endif #endif
case View3DActionType::SplitViewToggle:
updatedToolState.insert("splitView", command.isEnabled());
break;
default: default:
break; break;