From e1d7291f25055c06e7f58d8b0037010503418324 Mon Sep 17 00:00:00 2001 From: nds Date: Sat, 12 Sep 2015 15:28:17 +0300 Subject: [PATCH] Issue #960, 961 'CTRL+Z' buttons combination doesn't work --- src/ModuleBase/ModuleBase_IPropertyPanel.h | 3 +++ src/ModuleBase/ModuleBase_OperationFeature.cpp | 5 +++++ src/XGUI/XGUI_PropertyPanel.cpp | 6 ++++++ src/XGUI/XGUI_PropertyPanel.h | 3 +++ src/XGUI/XGUI_Workshop.cpp | 18 ++++++++++++++++++ 5 files changed, 35 insertions(+) diff --git a/src/ModuleBase/ModuleBase_IPropertyPanel.h b/src/ModuleBase/ModuleBase_IPropertyPanel.h index 516fdf3a6..c8c0f1721 100644 --- a/src/ModuleBase/ModuleBase_IPropertyPanel.h +++ b/src/ModuleBase/ModuleBase_IPropertyPanel.h @@ -48,6 +48,9 @@ public: /// \return State of editing mode flag bool isEditingMode() const { return myIsEditing; } + /// Set focus on the Ok button + virtual void setFocusOnOkButton() = 0; + /// Set Enable/Disable state of Cancel button /// \param theEnabled Enable/Disable state of Cancel button virtual void setCancelEnabled(bool theEnabled) = 0; diff --git a/src/ModuleBase/ModuleBase_OperationFeature.cpp b/src/ModuleBase/ModuleBase_OperationFeature.cpp index b82ee32ca..7c9c78248 100755 --- a/src/ModuleBase/ModuleBase_OperationFeature.cpp +++ b/src/ModuleBase/ModuleBase_OperationFeature.cpp @@ -352,4 +352,9 @@ void ModuleBase_OperationFeature::setPropertyPanel(ModuleBase_IPropertyPanel* th // 4. activate the first obligatory widget theProp->activateNextWidget(NULL); } + else { + // set focus on Ok button in order to operation manager could process Enter press + if (theProp) + theProp->setFocusOnOkButton(); + } } diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 888d96c3e..3efd40177 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -197,6 +197,12 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) } } +void XGUI_PropertyPanel::setFocusOnOkButton() +{ + QToolButton* anOkBtn = findChild(PROP_PANEL_OK); + anOkBtn->setFocus(); +} + void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled) { QToolButton* anCancelBtn = findChild(PROP_PANEL_CANCEL); diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 9ba7754ed..aba338e69 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -77,6 +77,9 @@ Q_OBJECT /// Activate the next from current widget in the property panel virtual void activateNextWidget(); + /// Set focus on the Ok button + virtual void setFocusOnOkButton(); + /// Set Enable/Disable state of Cancel button /// \param theEnabled Enable/Disable state of Cancel button virtual void setCancelEnabled(bool theEnabled); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 84cbda905..3a45b647f 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1009,6 +1009,13 @@ void XGUI_Workshop::showPropertyPanel() aViewAct->setEnabled(true); myPropertyPanel->show(); myPropertyPanel->raise(); + + // The next code is necessary to made the property panel the active window + // in order to operation manager could process key events of the panel. + // otherwise they are ignored. It happens only if the same(activateWindow) is + // not happend by property panel activation(e.g. resume operaion of Sketch) + myPropertyPanel->activateWindow(); + myPropertyPanel->setFocus(); } //****************************************************** @@ -1018,6 +1025,17 @@ void XGUI_Workshop::hidePropertyPanel() ///setEnabled(false); myPropertyPanel->hide(); + + // the property panel is active window of the desktop, when it is + // hidden, it is undefined which window becomes active. By this reason + // it is defined to perform the desktop as the active window. + // in SALOME mode, workstack made the PyConsole the active window, + // set the focus on it. As a result, shortcuts of the application, like + // are processed by this console. For example Undo actions. + // It is possible that this code is to be moved to NewGeom package + QMainWindow* aDesktop = isSalomeMode() ? salomeConnector()->desktop() : myMainWindow; + aDesktop->activateWindow(); + aDesktop->setFocus(); } //****************************************************** -- 2.39.2