From 3c9738b4e68feced06d2544043f01d7d2dcca8f1 Mon Sep 17 00:00:00 2001 From: nds Date: Wed, 3 Feb 2016 09:32:57 +0300 Subject: [PATCH] #1133 Del in old GEOM --- src/XGUI/XGUI_OperationMgr.cpp | 20 +++++++++++++++++--- src/XGUI/XGUI_OperationMgr.h | 8 ++++++++ src/XGUI/XGUI_Workshop.cpp | 3 +++ 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 0f622a24c..533bb6adc 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -48,11 +48,14 @@ public: } ~XGUI_ShortCutListener() {} + /// Switch on short cut listener + void setActive(const bool theIsActive) { myIsActive = theIsActive; } + /// Redefinition of virtual function to process Delete key release virtual bool eventFilter(QObject *theObject, QEvent *theEvent) { bool isAccepted = false; - if (theEvent->type() == QEvent::KeyRelease) { + if (myIsActive && theEvent->type() == QEvent::KeyRelease) { QKeyEvent* aKeyEvent = dynamic_cast(theEvent); if(aKeyEvent) { switch (aKeyEvent->key()) { @@ -69,6 +72,7 @@ public: private: XGUI_OperationMgr* myOperationMgr; /// processor for key event + bool myIsActive; /// boolean state whether the event filter perform own signal processing }; XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent, @@ -78,13 +82,23 @@ XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent, /// we need to install filter to the application in order to react to 'Delete' key button /// this key can not be a short cut for a corresponded action because we need to set /// the actions priority - XGUI_ShortCutListener* aShortCutListener = new XGUI_ShortCutListener(theParent, this); + myShortCutListener = new XGUI_ShortCutListener(theParent, this); } XGUI_OperationMgr::~XGUI_OperationMgr() { } +void XGUI_OperationMgr::activate() +{ + myShortCutListener->setActive(true); +} + +void XGUI_OperationMgr::deactivate() +{ + myShortCutListener->setActive(false); +} + ModuleBase_Operation* XGUI_OperationMgr::currentOperation() const { return myOperations.count() > 0 ? myOperations.last() : 0; @@ -652,7 +666,7 @@ bool XGUI_OperationMgr::onProcessDelete(QObject* theObject) /// processing delete by workshop XGUI_ObjectsBrowser* aBrowser = workshop()->objectBrowser(); QWidget* aViewPort = myWorkshop->viewer()->activeViewPort(); - // property panel childe object is processed to process delete performed on Apply button of PP + // property panel child object is processed to process delete performed on Apply button of PP if (isChildObject(theObject, aBrowser) || isChildObject(theObject, aViewPort) || isPPChildObject) diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 1b3450397..7a62ddbe3 100755 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -20,6 +20,7 @@ class QKeyEvent; class ModuleBase_IWorkshop; class XGUI_Workshop; +class XGUI_ShortCutListener; /**\class XGUI_OperationMgr * \ingroup GUI @@ -42,6 +43,11 @@ Q_OBJECT /// Destructor virtual ~XGUI_OperationMgr(); + /// Switch on short cut listener + void activate(); + /// Switch off short cut listener + void deactivate(); + /// Set reference to workshop /// \param theWorkshop reference to workshop void setWorkshop(ModuleBase_IWorkshop* theWorkshop) @@ -219,6 +225,8 @@ private: /// Current workshop ModuleBase_IWorkshop* myWorkshop; + + XGUI_ShortCutListener* myShortCutListener; }; #endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index d2782f2ff..071d698bb 100755 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -242,6 +242,7 @@ void XGUI_Workshop::activateModule() QIntList aModes; module()->activeSelectionModes(aModes); aDisplayer->activateObjects(aModes, aDisplayed); + myOperationMgr->activate(); } void XGUI_Workshop::deactivateModule() @@ -259,6 +260,8 @@ void XGUI_Workshop::deactivateModule() XGUI_Displayer* aDisplayer = displayer(); QObjectPtrList aDisplayed = aDisplayer->displayedObjects(); aDisplayer->deactivateObjects(aDisplayed, true); + + myOperationMgr->deactivate(); } //****************************************************** -- 2.39.2