Salome HOME
Issue #960, 961 'CTRL+Z' buttons combination doesn't work
authornds <nds@opencascade.com>
Sat, 12 Sep 2015 12:28:17 +0000 (15:28 +0300)
committernds <nds@opencascade.com>
Sat, 12 Sep 2015 12:28:17 +0000 (15:28 +0300)
src/ModuleBase/ModuleBase_IPropertyPanel.h
src/ModuleBase/ModuleBase_OperationFeature.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index 516fdf3a6430e374fae22b2c022e58e6cb2dc8b0..c8c0f17215af55092aa3e6c2247a1677ac39490d 100644 (file)
@@ -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;
index b82ee32ca4ef056b7af8a11aa846692ef8c808c4..7c9c78248c62baea80df69542059700ff46cb584 100755 (executable)
@@ -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();
+  }
 }
index 888d96c3e4a28b94ce7def47fad9efaec95da831..3efd40177b3e2040b2408a64fc1880886867f106 100644 (file)
@@ -197,6 +197,12 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
   }
 }
 
+void XGUI_PropertyPanel::setFocusOnOkButton()
+{
+  QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
+  anOkBtn->setFocus();
+}
+
 void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
 {
   QToolButton* anCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
index 9ba7754edaca4a4ae7ee9d2ee048fca2c6237f03..aba338e6970823b7a7748d8e17bdc5dd0e6fd772 100644 (file)
@@ -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);
index 84cbda90551f8c23f60403aa6ea4cfa55bd591c9..3a45b647fc5bea4bcee24752cd7358754bc3d358 100644 (file)
@@ -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()
   ///<! Do not allow to show empty property panel
   aViewAct->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();
 }
 
 //******************************************************