From 4e0e38789c4cfa73b7c2f11e26e84da7e9cbc211 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 27 Feb 2015 19:06:41 +0300 Subject: [PATCH] Key_Delete shortcut for both delete action - 1. workshop, 2. partset module. --- src/PartSet/PartSet_Module.cpp | 9 +++++++++ src/PartSet/PartSet_Module.h | 2 ++ src/XGUI/XGUI_ContextMenuMgr.cpp | 3 +++ src/XGUI/XGUI_OperationMgr.cpp | 6 +++++- src/XGUI/XGUI_OperationMgr.h | 2 ++ src/XGUI/XGUI_Workshop.cpp | 4 +++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 2c90b65a8..d31bf8f7c 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -94,6 +94,7 @@ PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop) XGUI_OperationMgr* anOpMgr = aWorkshop->operationMgr(); connect(anOpMgr, SIGNAL(keyEnterReleased()), this, SLOT(onEnterReleased())); + connect(anOpMgr, SIGNAL(keyDeleteReleased()), this, SLOT(onDeleteObjects())); connect(anOpMgr, SIGNAL(operationActivatedByPreselection()), this, SLOT(onOperationActivatedByPreselection())); @@ -390,6 +391,14 @@ void PartSet_Module::onEnterReleased() myRestartingMode = RM_EmptyFeatureUsed; } +void PartSet_Module::onDeleteObjects() +{ + ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); + if (PartSet_SketcherMgr::isSketchOperation(anOperation) || + PartSet_SketcherMgr::isNestedSketchOperation(anOperation)) + deleteObjects(); +} + void PartSet_Module::onOperationActivatedByPreselection() { ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 07125530f..2bf2f44b0 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -123,6 +123,8 @@ protected slots: /// It commits the operation of it is can be committed void onOperationActivatedByPreselection(); + //! Delete features + void onDeleteObjects(); protected: /// Register validators for this module diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 8072aa81d..a1940fee8 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -48,7 +48,10 @@ void XGUI_ContextMenuMgr::createActions() addAction("DEACTIVATE_PART_CMD", aAction); aAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this); + myWorkshop->mainWindow()->addAction(aAction); addAction("DELETE_CMD", aAction); + aAction->setShortcut(Qt::Key_Delete); + aAction->setShortcutContext(Qt::ApplicationShortcut); aAction = new QAction(QIcon(":pictures/eye_pencil.png"), tr("Show"), this); addAction("SHOW_CMD", aAction); diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 007019a64..e767d7f96 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -300,7 +300,11 @@ bool XGUI_OperationMgr::onKeyReleased(QKeyEvent* theEvent) emit keyEnterReleased(); commitOperation(); } - break; + break; + case Qt::Key_Delete: { // the delete button is occupied by the workshop Delete action, + // so this button process is realized here + emit keyDeleteReleased(); + } default: isAccepted = false; break; diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 525123137..609d8fde4 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -135,6 +135,8 @@ signals: /// Signal is emitted after the key released click. void keyEnterReleased(); + /// Signal is emitted after the key delete released click. + void keyDeleteReleased(); protected: /// Commits the current operatin if it is valid diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 9f5a0083d..20d803ca5 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1289,8 +1289,10 @@ void XGUI_Workshop::activatePart(ResultPartPtr theFeature) //************************************************************** void XGUI_Workshop::deleteObjects(const QObjectPtrList& theList) { - QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow; + if (!isActiveOperationAborted()) + return; + QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow; std::set aRefFeatures; foreach (ObjectPtr aObj, theList) { -- 2.39.2