diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index fc1fba78a3..a2136170e3 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -63,6 +63,7 @@ #include "MergeDocuments.h" #include "Navigation/NavigationStyle.h" #include "Placement.h" +#include "Tools.h" #include "Transform.h" #include "View3DInventor.h" #include "View3DInventorViewer.h" @@ -1320,11 +1321,7 @@ StdCmdDelete::StdCmdDelete() sWhatsThis = "Std_Delete"; sStatusTip = QT_TR_NOOP("Deletes the selected objects"); sPixmap = "edit-delete"; -#ifdef FC_OS_MACOSX - sAccel = "Backspace"; -#else - sAccel = keySequenceToAccel(QKeySequence::Delete); -#endif + sAccel = keySequenceToAccel(QtTools::deleteKeySequence()); eType = ForEdit; } diff --git a/src/Gui/Tools.h b/src/Gui/Tools.h index 06aa07ae6e..29f5741a68 100644 --- a/src/Gui/Tools.h +++ b/src/Gui/Tools.h @@ -47,6 +47,13 @@ public: uint searchkey = (ke->modifiers() | ke->key()) & ~(Qt::KeypadModifier | Qt::GroupSwitchModifier); return ks == QKeySequence(searchkey); } + static QKeySequence::StandardKey deleteKeySequence() { +#ifdef FC_OS_MACOSX + return QKeySequence::Backspace; +#else + return QKeySequence::Delete; +#endif + } }; } // namespace Gui diff --git a/src/Mod/Fem/Gui/TaskFemConstraint.cpp b/src/Mod/Fem/Gui/TaskFemConstraint.cpp index 814619a0cc..097236c79e 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraint.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraint.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include @@ -192,11 +193,7 @@ 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); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - deleteAction->setShortcut(QKeySequence(shortcut)); - } + deleteAction->setShortcut(Gui::QtTools::deleteKeySequence()); // 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 90062f96ec..558562f614 100644 --- a/src/Mod/Material/Gui/Array2D.cpp +++ b/src/Mod/Material/Gui/Array2D.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -76,11 +77,8 @@ Array2D::Array2D(const QString& propertyName, connect(ui->tableView, &QWidget::customContextMenuRequested, this, &Array2D::onContextMenu); _deleteAction.setText(tr("Delete row")); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - _deleteAction.setShortcut(QKeySequence(shortcut)); - } + _deleteAction.setShortcut(Gui::QtTools::deleteKeySequence()); + 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 14add39627..8651cb8344 100644 --- a/src/Mod/Material/Gui/MaterialSave.cpp +++ b/src/Mod/Material/Gui/MaterialSave.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include @@ -90,11 +91,8 @@ MaterialSave::MaterialSave(const std::shared_ptr& material, &MaterialSave::onContextMenu); _deleteAction.setText(tr("Delete")); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - _deleteAction.setShortcut(QKeySequence(shortcut)); - } + _deleteAction.setShortcut(Gui::QtTools::deleteKeySequence()); + 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 19f19a47ab..bfc43ff794 100644 --- a/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskBooleanParameters.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -84,15 +85,11 @@ TaskBooleanParameters::TaskBooleanParameters(ViewProviderBoolean* BooleanView, Q // Create context menu QAction* action = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - action->setShortcut(QKeySequence(shortcut)); - } + action->setShortcut(Gui::QtTools::deleteKeySequence()); // display shortcut behind the context menu entry action->setShortcutVisibleInContextMenu(true); - + ui->listWidgetBodies->addAction(action); connect(action, &QAction::triggered, this, &TaskBooleanParameters::onBodyDeleted); ui->listWidgetBodies->setContextMenuPolicy(Qt::ActionsContextMenu); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index e9466efe63..12bb0c3790 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -305,11 +305,8 @@ 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); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - deleteAction->setShortcut(QKeySequence(shortcut)); - } + deleteAction->setShortcut(Gui::QtTools::deleteKeySequence()); + // display shortcut behind the context menu entry deleteAction->setShortcutVisibleInContextMenu(true); parentList->addAction(deleteAction); diff --git a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp index 8cba881348..6257ab9392 100644 --- a/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskExtrudeParameters.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -174,11 +175,8 @@ void TaskExtrudeParameters::setupDialog() translateModeList(index); unselectShapeFaceAction = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - unselectShapeFaceAction->setShortcut(QKeySequence(shortcut)); - } + unselectShapeFaceAction->setShortcut(Gui::QtTools::deleteKeySequence()); + // 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 7867643b29..97810cf47d 100644 --- a/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskLoftParameters.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include "ui_TaskLoftParameters.h" @@ -72,11 +73,8 @@ TaskLoftParameters::TaskLoftParameters(ViewProviderLoft* LoftView, bool /*newObj // Create context menu QAction* remove = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - remove->setShortcut(QKeySequence(shortcut)); - } + remove->setShortcut(Gui::QtTools::deleteKeySequence()); + // display shortcut behind the context menu entry remove->setShortcutVisibleInContextMenu(true); ui->listWidgetReferences->addAction(remove); diff --git a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp index 258d58464c..9486bf6aec 100644 --- a/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPipeParameters.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -86,11 +87,7 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe* PipeView, bool /*newObj // Create context menu QAction* remove = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - remove->setShortcut(QKeySequence(shortcut)); - } + remove->setShortcut(Gui::QtTools::deleteKeySequence()); remove->setShortcutContext(Qt::WidgetShortcut); // display shortcut behind the context menu entry @@ -609,11 +606,7 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, // Create context menu QAction* remove = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - remove->setShortcut(QKeySequence(shortcut)); - } + remove->setShortcut(Gui::QtTools::deleteKeySequence()); remove->setShortcutContext(Qt::WidgetShortcut); // display shortcut behind the context menu entry @@ -901,11 +894,7 @@ TaskPipeScaling::TaskPipeScaling(ViewProviderPipe* PipeView, bool /*newObj*/, QW // Create context menu QAction* remove = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - remove->setShortcut(QKeySequence(shortcut)); - } + remove->setShortcut(Gui::QtTools::deleteKeySequence()); remove->setShortcutContext(Qt::WidgetShortcut); // display shortcut behind the context menu entry diff --git a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp index 626bc4cf31..50dd8664c1 100644 --- a/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp +++ b/src/Mod/PartDesign/Gui/TaskShapeBinder.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -128,11 +129,7 @@ void TaskShapeBinder::setupContextMenu() { // Create context menu QAction* remove = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - remove->setShortcut(QKeySequence(shortcut)); - } + remove->setShortcut(Gui::QtTools::deleteKeySequence()); remove->setShortcutContext(Qt::WidgetShortcut); // display shortcut behind the context menu entry remove->setShortcutVisibleInContextMenu(true); diff --git a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp index b426bba314..2ed2e16f28 100644 --- a/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskTransformedParameters.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -102,11 +103,8 @@ void TaskTransformedParameters::setupUI() // Create context menu auto action = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - action->setShortcut(QKeySequence(shortcut)); - } + action->setShortcut(Gui::QtTools::deleteKeySequence()); + // 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 4b0b2b99ff..75d68ad0d2 100644 --- a/src/Mod/Surface/Gui/TaskSections.cpp +++ b/src/Mod/Surface/Gui/TaskSections.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -281,11 +282,8 @@ SectionsPanel::SectionsPanel(ViewProviderSections* vp, Surface::Sections* obj) // Create context menu QAction* action = new QAction(tr("Remove"), this); - { - auto& rcCmdMgr = Gui::Application::Instance->commandManager(); - auto shortcut = rcCmdMgr.getCommandByName("Std_Delete")->getShortcut(); - action->setShortcut(QKeySequence(shortcut)); - } + action->setShortcut(Gui::QtTools::deleteKeySequence()); + ui->listSections->addAction(action); connect(action, &QAction::triggered, this, &SectionsPanel::onDeleteEdge); ui->listSections->setContextMenuPolicy(Qt::ActionsContextMenu);