forked from qt-creator/qt-creator
QmlDesigner: Register 3D edit view actions properly to ActionManager
Also fix one FormEditor action that specified its shortcut incorrectly. Change-Id: Ieac988ff17c5ceee07a15ef0a31ab409829609a4 Fixes: QDS-1841 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -195,54 +195,54 @@ void Edit3DView::createEdit3DActions()
|
|||||||
{
|
{
|
||||||
m_selectionModeAction
|
m_selectionModeAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DSelectionModeToggle", View3DActionCommand::SelectionModeToggle,
|
QmlDesigner::Constants::EDIT3D_SELECTION_MODE, View3DActionCommand::SelectionModeToggle,
|
||||||
QCoreApplication::translate("SelectionModeToggleAction", "Toggle Group/Single Selection Mode"),
|
QCoreApplication::translate("SelectionModeToggleAction", "Toggle Group/Single Selection Mode"),
|
||||||
QKeySequence(Qt::Key_Q), true, false, Icons::EDIT3D_SELECTION_MODE_OFF.icon(),
|
QKeySequence(Qt::Key_Q), true, false, Icons::EDIT3D_SELECTION_MODE_OFF.icon(),
|
||||||
Icons::EDIT3D_SELECTION_MODE_ON.icon());
|
Icons::EDIT3D_SELECTION_MODE_ON.icon());
|
||||||
|
|
||||||
m_moveToolAction
|
m_moveToolAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DMoveTool", View3DActionCommand::MoveTool,
|
QmlDesigner::Constants::EDIT3D_MOVE_TOOL, View3DActionCommand::MoveTool,
|
||||||
QCoreApplication::translate("MoveToolAction", "Activate Move Tool"),
|
QCoreApplication::translate("MoveToolAction", "Activate Move Tool"),
|
||||||
QKeySequence(Qt::Key_W), true, true, Icons::EDIT3D_MOVE_TOOL_OFF.icon(),
|
QKeySequence(Qt::Key_W), true, true, Icons::EDIT3D_MOVE_TOOL_OFF.icon(),
|
||||||
Icons::EDIT3D_MOVE_TOOL_ON.icon());
|
Icons::EDIT3D_MOVE_TOOL_ON.icon());
|
||||||
|
|
||||||
m_rotateToolAction
|
m_rotateToolAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DRotateTool", View3DActionCommand::RotateTool,
|
QmlDesigner::Constants::EDIT3D_ROTATE_TOOL, View3DActionCommand::RotateTool,
|
||||||
QCoreApplication::translate("RotateToolAction", "Activate Rotate Tool"),
|
QCoreApplication::translate("RotateToolAction", "Activate Rotate Tool"),
|
||||||
QKeySequence(Qt::Key_E), true, false, Icons::EDIT3D_ROTATE_TOOL_OFF.icon(),
|
QKeySequence(Qt::Key_E), true, false, Icons::EDIT3D_ROTATE_TOOL_OFF.icon(),
|
||||||
Icons::EDIT3D_ROTATE_TOOL_ON.icon());
|
Icons::EDIT3D_ROTATE_TOOL_ON.icon());
|
||||||
|
|
||||||
m_scaleToolAction
|
m_scaleToolAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DScaleTool", View3DActionCommand::ScaleTool,
|
QmlDesigner::Constants::EDIT3D_SCALE_TOOL, View3DActionCommand::ScaleTool,
|
||||||
QCoreApplication::translate("ScaleToolAction", "Activate Scale Tool"),
|
QCoreApplication::translate("ScaleToolAction", "Activate Scale Tool"),
|
||||||
QKeySequence(Qt::Key_R), true, false, Icons::EDIT3D_SCALE_TOOL_OFF.icon(),
|
QKeySequence(Qt::Key_R), true, false, Icons::EDIT3D_SCALE_TOOL_OFF.icon(),
|
||||||
Icons::EDIT3D_SCALE_TOOL_ON.icon());
|
Icons::EDIT3D_SCALE_TOOL_ON.icon());
|
||||||
|
|
||||||
m_fitAction = new Edit3DAction(
|
m_fitAction = new Edit3DAction(
|
||||||
"Edit3DFitToView", View3DActionCommand::FitToView,
|
QmlDesigner::Constants::EDIT3D_FIT_SELECTED, View3DActionCommand::FitToView,
|
||||||
QCoreApplication::translate("FitToViewAction", "Fit Selected Object to View"),
|
QCoreApplication::translate("FitToViewAction", "Fit Selected Object to View"),
|
||||||
QKeySequence(Qt::Key_F), false, false, Icons::EDIT3D_FIT_SELECTED_OFF.icon(), {});
|
QKeySequence(Qt::Key_F), false, false, Icons::EDIT3D_FIT_SELECTED_OFF.icon(), {});
|
||||||
|
|
||||||
m_cameraModeAction
|
m_cameraModeAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DCameraToggle", View3DActionCommand::CameraToggle,
|
QmlDesigner::Constants::EDIT3D_EDIT_CAMERA, View3DActionCommand::CameraToggle,
|
||||||
QCoreApplication::translate("CameraToggleAction", "Toggle Perspective/Orthographic Edit Camera"),
|
QCoreApplication::translate("CameraToggleAction", "Toggle Perspective/Orthographic Edit Camera"),
|
||||||
QKeySequence(Qt::Key_T), true, false, Icons::EDIT3D_EDIT_CAMERA_OFF.icon(),
|
QKeySequence(Qt::Key_T), true, false, Icons::EDIT3D_EDIT_CAMERA_OFF.icon(),
|
||||||
Icons::EDIT3D_EDIT_CAMERA_ON.icon());
|
Icons::EDIT3D_EDIT_CAMERA_ON.icon());
|
||||||
|
|
||||||
m_orientationModeAction
|
m_orientationModeAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DOrientationToggle", View3DActionCommand::OrientationToggle,
|
QmlDesigner::Constants::EDIT3D_ORIENTATION, View3DActionCommand::OrientationToggle,
|
||||||
QCoreApplication::translate("OrientationToggleAction", "Toggle Global/Local Orientation"),
|
QCoreApplication::translate("OrientationToggleAction", "Toggle Global/Local Orientation"),
|
||||||
QKeySequence(Qt::Key_Y), true, false, Icons::EDIT3D_ORIENTATION_OFF.icon(),
|
QKeySequence(Qt::Key_Y), true, false, Icons::EDIT3D_ORIENTATION_OFF.icon(),
|
||||||
Icons::EDIT3D_ORIENTATION_ON.icon());
|
Icons::EDIT3D_ORIENTATION_ON.icon());
|
||||||
|
|
||||||
m_editLightAction
|
m_editLightAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DEditLightToggle", View3DActionCommand::EditLightToggle,
|
QmlDesigner::Constants::EDIT3D_EDIT_LIGHT, View3DActionCommand::EditLightToggle,
|
||||||
QCoreApplication::translate("EditLightToggleAction", "Toggle Edit Light On/Off"),
|
QCoreApplication::translate("EditLightToggleAction", "Toggle Edit Light On/Off"),
|
||||||
QKeySequence(Qt::Key_U), true, false, Icons::EDIT3D_LIGHT_OFF.icon(),
|
QKeySequence(Qt::Key_U), true, false, Icons::EDIT3D_LIGHT_OFF.icon(),
|
||||||
Icons::EDIT3D_LIGHT_ON.icon());
|
Icons::EDIT3D_LIGHT_ON.icon());
|
||||||
@@ -253,7 +253,7 @@ void Edit3DView::createEdit3DActions()
|
|||||||
};
|
};
|
||||||
m_resetAction
|
m_resetAction
|
||||||
= new Edit3DAction(
|
= new Edit3DAction(
|
||||||
"Edit3DResetView", View3DActionCommand::Empty,
|
QmlDesigner::Constants::EDIT3D_RESET_VIEW, View3DActionCommand::Empty,
|
||||||
QCoreApplication::translate("ResetView", "Reset View"),
|
QCoreApplication::translate("ResetView", "Reset View"),
|
||||||
QKeySequence(Qt::Key_P), false, false, Utils::Icons::RESET_TOOLBAR.icon(), {},
|
QKeySequence(Qt::Key_P), false, false, Utils::Icons::RESET_TOOLBAR.icon(), {},
|
||||||
resetTrigger);
|
resetTrigger);
|
||||||
@@ -272,20 +272,6 @@ void Edit3DView::createEdit3DActions()
|
|||||||
m_leftActions << m_editLightAction;
|
m_leftActions << m_editLightAction;
|
||||||
|
|
||||||
m_rightActions << m_resetAction;
|
m_rightActions << m_resetAction;
|
||||||
|
|
||||||
// TODO: Registering actions to action manager causes conflicting shortcuts in form editor.
|
|
||||||
// Registration commented out until UX defines non-conflicting shortcuts.
|
|
||||||
// Also, actions creation needs to be somehow triggered before action manager registers
|
|
||||||
// actions to creator.
|
|
||||||
// DesignerActionManager &actionManager = QmlDesignerPlugin::instance()->designerActionManager();
|
|
||||||
// for (auto action : qAsConst(m_leftActions)) {
|
|
||||||
// if (action)
|
|
||||||
// actionManager.addDesignerAction(action);
|
|
||||||
// }
|
|
||||||
// for (auto action : qAsConst(m_rightActions)) {
|
|
||||||
// if (action)
|
|
||||||
// actionManager.addDesignerAction(action);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<Edit3DAction *> Edit3DView::leftActions() const
|
QVector<Edit3DAction *> Edit3DView::leftActions() const
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
#include "qmldesignerconstants.h"
|
#include "qmldesignerconstants.h"
|
||||||
#include "viewmanager.h"
|
#include "viewmanager.h"
|
||||||
|
|
||||||
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/actionmanager/command.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
#include <toolbox.h>
|
#include <toolbox.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
@@ -62,7 +64,7 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
|||||||
|
|
||||||
// Iterate through view actions. A null action indicates a separator and a second null action
|
// Iterate through view actions. A null action indicates a separator and a second null action
|
||||||
// after separator indicates an exclusive group.
|
// after separator indicates an exclusive group.
|
||||||
auto addActionsToToolBox = [this](const QVector<Edit3DAction *> &actions, bool left) {
|
auto addActionsToToolBox = [this, &context](const QVector<Edit3DAction *> &actions, bool left) {
|
||||||
bool previousWasSeparator = true;
|
bool previousWasSeparator = true;
|
||||||
QActionGroup *group = nullptr;
|
QActionGroup *group = nullptr;
|
||||||
for (auto action : actions) {
|
for (auto action : actions) {
|
||||||
@@ -75,6 +77,14 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
|||||||
else
|
else
|
||||||
m_toolBox->addRightSideAction(action->action());
|
m_toolBox->addRightSideAction(action->action());
|
||||||
previousWasSeparator = false;
|
previousWasSeparator = false;
|
||||||
|
|
||||||
|
// Register action as creator command to make it configurable
|
||||||
|
Core::Command *command = Core::ActionManager::registerAction(
|
||||||
|
action->action(), action->menuId().data(), context);
|
||||||
|
command->setDefaultKeySequence(action->action()->shortcut());
|
||||||
|
command->augmentActionWithShortcutToolTip(action->action());
|
||||||
|
// Clear action shortcut so it doesn't conflict with command's override action
|
||||||
|
action->action()->setShortcut({});
|
||||||
} else {
|
} else {
|
||||||
if (previousWasSeparator) {
|
if (previousWasSeparator) {
|
||||||
group = new QActionGroup(this);
|
group = new QActionGroup(this);
|
||||||
@@ -89,7 +99,6 @@ Edit3DWidget::Edit3DWidget(Edit3DView *view) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
addActionsToToolBox(view->leftActions(), true);
|
addActionsToToolBox(view->leftActions(), true);
|
||||||
addActionsToToolBox(view->rightActions(), false);
|
addActionsToToolBox(view->rightActions(), false);
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ FormEditorWidget::FormEditorWidget(FormEditorView *view) :
|
|||||||
auto layoutActionGroup = new QActionGroup(this);
|
auto layoutActionGroup = new QActionGroup(this);
|
||||||
layoutActionGroup->setExclusive(true);
|
layoutActionGroup->setExclusive(true);
|
||||||
|
|
||||||
m_noSnappingAction = layoutActionGroup->addAction(tr("No snapping (T)."));
|
m_noSnappingAction = layoutActionGroup->addAction(tr("No snapping."));
|
||||||
m_noSnappingAction->setShortcut(Qt::Key_T);
|
|
||||||
m_noSnappingAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
m_noSnappingAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
m_noSnappingAction->setCheckable(true);
|
m_noSnappingAction->setCheckable(true);
|
||||||
m_noSnappingAction->setChecked(true);
|
m_noSnappingAction->setChecked(true);
|
||||||
|
|||||||
@@ -54,6 +54,15 @@ const char FORMEDITOR_SNAPPING[] = "QmlDesigner.FormEditor.Snapping";
|
|||||||
const char FORMEDITOR_NO_SNAPPING[] = "QmlDesigner.FormEditor.NoSnapping";
|
const char FORMEDITOR_NO_SNAPPING[] = "QmlDesigner.FormEditor.NoSnapping";
|
||||||
const char FORMEDITOR_NO_SNAPPING_AND_ANCHORING[] = "QmlDesigner.FormEditor.NoSnappingAndAnchoring";
|
const char FORMEDITOR_NO_SNAPPING_AND_ANCHORING[] = "QmlDesigner.FormEditor.NoSnappingAndAnchoring";
|
||||||
const char FORMEDITOR_NO_SHOW_BOUNDING_RECTANGLE[] = "QmlDesigner.FormEditor.ShowBoundingRectangle";
|
const char FORMEDITOR_NO_SHOW_BOUNDING_RECTANGLE[] = "QmlDesigner.FormEditor.ShowBoundingRectangle";
|
||||||
|
const char EDIT3D_SELECTION_MODE[] = "QmlDesigner.Editor3D.SelectionModeToggle";
|
||||||
|
const char EDIT3D_MOVE_TOOL[] = "QmlDesigner.Editor3D.MoveTool";
|
||||||
|
const char EDIT3D_ROTATE_TOOL[] = "QmlDesigner.Editor3D.RotateTool";
|
||||||
|
const char EDIT3D_SCALE_TOOL[] = "QmlDesigner.Editor3D.ScaleTool";
|
||||||
|
const char EDIT3D_FIT_SELECTED[] = "QmlDesigner.Editor3D.FitSelected";
|
||||||
|
const char EDIT3D_EDIT_CAMERA[] = "QmlDesigner.Editor3D.EditCameraToggle";
|
||||||
|
const char EDIT3D_ORIENTATION[] = "QmlDesigner.Editor3D.OrientationToggle";
|
||||||
|
const char EDIT3D_EDIT_LIGHT[] = "QmlDesigner.Editor3D.EditLightToggle";
|
||||||
|
const char EDIT3D_RESET_VIEW[] = "QmlDesigner.Editor3D.ResetView";
|
||||||
|
|
||||||
const char QML_DESIGNER_SUBFOLDER[] = "/designer/";
|
const char QML_DESIGNER_SUBFOLDER[] = "/designer/";
|
||||||
const char QUICK_3D_ASSETS_FOLDER[] = "/Quick3DAssets";
|
const char QUICK_3D_ASSETS_FOLDER[] = "/Quick3DAssets";
|
||||||
|
|||||||
Reference in New Issue
Block a user