Helper function to get preferred delete key depending on platform
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Mod/Fem/App/FemConstraint.h>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Tools.h>
|
||||
|
||||
#include <Mod/Material/App/Exceptions.h>
|
||||
#include <Mod/Material/App/Materials.h>
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Tools.h>
|
||||
|
||||
#include <Mod/Material/App/MaterialLibrary.h>
|
||||
|
||||
@@ -90,11 +91,8 @@ MaterialSave::MaterialSave(const std::shared_ptr<Materials::Material>& 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);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/FeatureBoolean.h>
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/UnitsApi.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Mod/PartDesign/App/FeatureExtrude.h>
|
||||
#include <Mod/Part/Gui/ReferenceHighlighter.h>
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Mod/PartDesign/App/FeatureLoft.h>
|
||||
|
||||
#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);
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Widgets.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
@@ -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
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <Gui/CommandT.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Gui/Widgets.h>
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
@@ -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);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Selection/Selection.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Mod/PartDesign/App/Body.h>
|
||||
#include <Mod/PartDesign/App/FeatureAddSub.h>
|
||||
#include <Mod/PartDesign/App/FeatureTransformed.h>
|
||||
@@ -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);
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Selection/SelectionObject.h>
|
||||
#include <Gui/Tools.h>
|
||||
#include <Gui/Widgets.h>
|
||||
#include <Mod/Part/Gui/ViewProvider.h>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user