From fdfb9fd2c601ec1314f1795b760985afcb0e7daa Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Mon, 23 Sep 2024 17:53:39 +0200 Subject: [PATCH] Reuse Std_Delete shortcut instead of hardcoding Delete (#16682) * Reuse Std_Delete shortcut in TaskBooleanParameters * Reuse Std_Delete shortcut in TaskDressUpParameters * Reuse Std_Delete shortcut in TaskLoftParameters * Reuse Std_Delete shortcut in TaskPipeParameters * Reuse Std_Delete shortcut in TaskSapeBinder * Reuse Std_Delete shortcut in TaskTransformedParameters * Reuse Std_Delete shortcut in TaskExtrudeParameters * Reuse Std_Delete shortcut in TaskSections * Reuse Std_Delete shortcut in MaterialSave * Reuse Std_Delete shortcut in Array2D * Reuse Std_Delete shortcut in TaskFemConstraint * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/Fem/Gui/TaskFemConstraint.cpp | 6 +++++- src/Mod/Material/Gui/Array2D.cpp | 8 +++++++- src/Mod/Material/Gui/MaterialSave.cpp | 8 +++++++- .../PartDesign/Gui/TaskBooleanParameters.cpp | 6 +++++- .../PartDesign/Gui/TaskDressUpParameters.cpp | 6 +++++- .../PartDesign/Gui/TaskExtrudeParameters.cpp | 6 +++++- src/Mod/PartDesign/Gui/TaskLoftParameters.cpp | 6 +++++- src/Mod/PartDesign/Gui/TaskPipeParameters.cpp | 18 +++++++++++++++--- src/Mod/PartDesign/Gui/TaskShapeBinder.cpp | 6 +++++- .../Gui/TaskTransformedParameters.cpp | 6 +++++- src/Mod/Surface/Gui/TaskSections.cpp | 6 +++++- 11 files changed, 69 insertions(+), 13 deletions(-) diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.cpp b/src/Mod/Fem/Gui/TaskFemConstraint.cpp index 308088b66b..4f4e717e51 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraint.cpp @@ -168,7 +168,11 @@ void TaskFemConstraint::createDeleteAction(QListWidget* parentList) // creates a context menu, a shortcut for it and connects it to a slot function deleteAction = new QAction(tr("Delete"), this); - deleteAction->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + deleteAction->setShortcut(QKeySequence(shortcut)); + } #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry deleteAction->setShortcutVisibleInContextMenu(true); diff --git a/src/Mod/Material/Gui/Array2D.cpp b/src/Mod/Material/Gui/Array2D.cpp index 86804981d5..e2fdfb9860 100644 --- a/src/Mod/Material/Gui/Array2D.cpp +++ b/src/Mod/Material/Gui/Array2D.cpp @@ -25,6 +25,8 @@ #include #endif +#include +#include #include #include @@ -74,7 +76,11 @@ Array2D::Array2D(const QString& propertyName, connect(ui->tableView, &QWidget::customContextMenuRequested, this, &Array2D::onContextMenu); _deleteAction.setText(tr("Delete row")); - _deleteAction.setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + _deleteAction.setShortcut(QKeySequence(shortcut)); + } connect(&_deleteAction, &QAction::triggered, this, &Array2D::onDelete); ui->tableView->addAction(&_deleteAction); diff --git a/src/Mod/Material/Gui/MaterialSave.cpp b/src/Mod/Material/Gui/MaterialSave.cpp index 3bf75d9d46..cc82affc6a 100644 --- a/src/Mod/Material/Gui/MaterialSave.cpp +++ b/src/Mod/Material/Gui/MaterialSave.cpp @@ -26,6 +26,8 @@ #include #endif +#include +#include #include #include @@ -87,7 +89,11 @@ MaterialSave::MaterialSave(const std::shared_ptr& material, &MaterialSave::onContextMenu); _deleteAction.setText(tr("Delete")); - _deleteAction.setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + _deleteAction.setShortcut(QKeySequence(shortcut)); + } connect(&_deleteAction, &QAction::triggered, this, &MaterialSave::onDelete); ui->treeMaterials->addAction(&_deleteAction); diff --git a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp index bfa1b30273..0f3689e1d6 100644 --- a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp @@ -84,7 +84,11 @@ TaskBooleanParameters::TaskBooleanParameters(ViewProviderBoolean* BooleanView, Q // Create context menu QAction* action = new QAction(tr("Remove"), this); - action->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + action->setShortcut(QKeySequence(shortcut)); + } #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry action->setShortcutVisibleInContextMenu(true); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index a4827254cd..1aac210017 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -291,7 +291,11 @@ void TaskDressUpParameters::createDeleteAction(QListWidget* parentList) // creates a context menu, a shortcut for it and connects it to a slot function deleteAction = new QAction(tr("Remove"), this); - deleteAction->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + deleteAction->setShortcut(QKeySequence(shortcut)); + } #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry deleteAction->setShortcutVisibleInContextMenu(true); diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index 4b2ffdc46f..a4c1674505 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -174,7 +174,11 @@ void TaskExtrudeParameters::setupDialog() translateModeList(index); unselectShapeFaceAction = new QAction(tr("Remove"), this); - unselectShapeFaceAction->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + unselectShapeFaceAction->setShortcut(QKeySequence(shortcut)); + } #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry unselectShapeFaceAction->setShortcutVisibleInContextMenu(true); diff --git a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp index 046417abf3..0bcb1b1eb4 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -72,7 +72,11 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft* LoftView, bool /*newObj // Create context menu QAction* remove = new QAction(tr("Remove"), this); - remove->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + remove->setShortcut(QKeySequence(shortcut)); + } #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry remove->setShortcutVisibleInContextMenu(true); diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index b794a8d78d..3f7034e83d 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -86,7 +86,11 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe* PipeView, bool /*newObj // Create context menu QAction* remove = new QAction(tr("Remove"), this); - remove->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + remove->setShortcut(QKeySequence(shortcut)); + } remove->setShortcutContext(Qt::WidgetShortcut); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry @@ -605,7 +609,11 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, // Create context menu QAction* remove = new QAction(tr("Remove"), this); - remove->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + remove->setShortcut(QKeySequence(shortcut)); + } remove->setShortcutContext(Qt::WidgetShortcut); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry @@ -894,7 +902,11 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW // Create context menu QAction* remove = new QAction(tr("Remove"), this); - remove->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + remove->setShortcut(QKeySequence(shortcut)); + } remove->setShortcutContext(Qt::WidgetShortcut); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry diff --git a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp index eb969ce942..25d35426b4 100644 --- a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp @@ -128,7 +128,11 @@ void TaskShapeBinder::setupContextMenu() { // Create context menu QAction* remove = new QAction(tr("Remove"), this); - remove->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + remove->setShortcut(QKeySequence(shortcut)); + } remove->setShortcutContext(Qt::WidgetShortcut); #if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) // display shortcut behind the context menu entry diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index 0e11ca2596..57c7f2b9ba 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -102,7 +102,11 @@ void TaskTransformedParameters::setupUI() // Create context menu auto action = new QAction(tr("Remove"), this); - action->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + action->setShortcut(QKeySequence(shortcut)); + } // display shortcut behind the context menu entry action->setShortcutVisibleInContextMenu(true); ui->listWidgetFeatures->addAction(action); diff --git a/src/Mod/Surface/Gui/TaskSections.cpp b/src/Mod/Surface/Gui/TaskSections.cpp index b8f6d856f7..c91a0fad96 100644 --- a/src/Mod/Surface/Gui/TaskSections.cpp +++ b/src/Mod/Surface/Gui/TaskSections.cpp @@ -279,7 +279,11 @@ SectionsPanel::SectionsPanel(ViewProviderSections* vp, Surface::Sections* obj) // Create context menu QAction* action = new QAction(tr("Remove"), this); - action->setShortcut(QKeySequence::Delete); + { + auto& rcCmdMgr = Gui::Application::Instance->commandManager(); + auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); + action->setShortcut(QKeySequence(shortcut)); + } ui->listSections->addAction(action); connect(action, &QAction::triggered, this, &SectionsPanel::onDeleteEdge); ui->listSections->setContextMenuPolicy(Qt::ActionsContextMenu);