From: vsv Date: Mon, 12 Oct 2015 16:54:24 +0000 (+0300) Subject: Issue #1055: Close of property panel is abort of current operation X-Git-Tag: V_1.4.0_demo2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=4c5d32479cf8f4a5aafd8335e16cb82faa7526f6;p=modules%2Fshaper.git Issue #1055: Close of property panel is abort of current operation --- diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index ab7695723..fdabd150c 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -9,6 +9,7 @@ #include #include +#include //#include #include #include @@ -31,11 +32,12 @@ #include #endif -XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent) +XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr) : ModuleBase_IPropertyPanel(theParent), myActiveWidget(NULL), myPreselectionWidget(NULL), - myPanelPage(NULL) + myPanelPage(NULL), + myOperationMgr(theMgr) { this->setWindowTitle(tr("Property Panel")); QAction* aViewAct = this->toggleViewAction(); @@ -256,3 +258,17 @@ void XGUI_PropertyPanel::setPreselectionWidget(ModuleBase_ModelWidget* theWidget { myPreselectionWidget = theWidget; } + + +void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent) +{ + ModuleBase_Operation* aOp = myOperationMgr->currentOperation(); + if (aOp) { + if (myOperationMgr->canStopOperation(aOp)) { + myOperationMgr->abortOperation(aOp); + theEvent->accept(); + } else + theEvent->ignore(); + } else + ModuleBase_IPropertyPanel::closeEvent(theEvent); +} \ No newline at end of file diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 083242fd1..0b158921e 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -22,6 +22,7 @@ class QKeyEvent; class QGridLayout; class ModuleBase_PageBase; class ModuleBase_PageWidget; +class XGUI_OperationMgr; /// Internal name of property panel widget const static char* PROP_PANEL = "property_panel_dock"; @@ -46,7 +47,7 @@ Q_OBJECT /// Constructor /// \param theParent is a parent of the property panel - XGUI_PropertyPanel(QWidget* theParent); + XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr); virtual ~XGUI_PropertyPanel(); @@ -100,7 +101,10 @@ Q_OBJECT /// Sets widget processed by preselection virtual void setPreselectionWidget(ModuleBase_ModelWidget* theWidget); - public slots: + /// Returns operation manager + XGUI_OperationMgr* operationMgr() const { return myOperationMgr; } + +public slots: /// \brief Update all widgets in property panel with values from the given feature /// \param theFeature a Feature to update values in widgets @@ -115,6 +119,10 @@ Q_OBJECT virtual void activateWidget(ModuleBase_ModelWidget* theWidget); protected: + /// A method called on the property panel closed + /// \param theEvent a close event + void closeEvent(QCloseEvent* theEvent); + /// A header widget QWidget* myHeaderWidget; @@ -126,6 +134,8 @@ Q_OBJECT ModuleBase_ModelWidget* myActiveWidget; /// Currently widget processed by preselection ModuleBase_ModelWidget* myPreselectionWidget; + + XGUI_OperationMgr* myOperationMgr; }; #endif /* XGUI_PROPERTYPANEL_H_ */ diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 70257c785..912a0ef4b 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -994,7 +994,7 @@ void XGUI_Workshop::createDockWidgets() QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow; QDockWidget* aObjDock = createObjectBrowser(aDesktop); aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock); - myPropertyPanel = new XGUI_PropertyPanel(aDesktop); + myPropertyPanel = new XGUI_PropertyPanel(aDesktop, myOperationMgr); myPropertyPanel->setupActions(myActionsMgr); myPropertyPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);