]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Key_Delete shortcut for both delete action - 1. workshop, 2. partset module.
authornds <natalia.donis@opencascade.com>
Fri, 27 Feb 2015 16:06:41 +0000 (19:06 +0300)
committernds <natalia.donis@opencascade.com>
Fri, 27 Feb 2015 16:06:41 +0000 (19:06 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/XGUI/XGUI_ContextMenuMgr.cpp
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_Workshop.cpp

index 2c90b65a8d20c421ea28829492e1be55a238288b..d31bf8f7c65fa5894e17120e87272916c46ac7ca 100644 (file)
@@ -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();
index 07125530f9ea00c00383507b4959a2ff9ef43f24..2bf2f44b063fc17a8c866b96d4d874e1754bafbf 100644 (file)
@@ -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
index 8072aa81d21853732f448c98ff3ce121dd08e953..a1940fee8bcb1f359a9fa1850e457be8df96c8e2 100644 (file)
@@ -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);
index 007019a64b15e5180adb6ba7836cbaffb2b2ae03..e767d7f964c053723c057983372d8a552c0685b7 100644 (file)
@@ -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;
index 5251231378bb3830e2aaf1f31d1f0ca878c30708..609d8fde4a6c0bf99a3ab7557ed1da3938544222 100644 (file)
@@ -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
index 9f5a0083ddfbbc457964cf667cf9937a01b90346..20d803ca5170a61238aebadb767f11bfad763d4d 100644 (file)
@@ -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<FeaturePtr> aRefFeatures;
   foreach (ObjectPtr aObj, theList)
   {