]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #143 highlight active restored
authorsbh <sergey.belash@opencascade.com>
Mon, 27 Oct 2014 12:11:11 +0000 (15:11 +0300)
committersbh <sergey.belash@opencascade.com>
Mon, 27 Oct 2014 12:11:11 +0000 (15:11 +0300)
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_Operation.cpp
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index e2b934ee6de130eff7fab5672b876f9a0daf21e6..dde892d224818d1606bbbf003c74fb512e192081 100644 (file)
@@ -39,9 +39,8 @@ void ModuleBase_ModelWidget::enableFocusProcessing()
 {
   QList<QWidget*> aMyControls = getControls();
   foreach(QWidget*  eachControl, aMyControls) {
-    if(!myFocusInWidgets.contains(eachControl)) {
-      enableFocusProcessing(eachControl);
-    }
+    eachControl->setFocusPolicy(Qt::StrongFocus);
+    eachControl->installEventFilter(this);
   }
 }
 
@@ -92,20 +91,15 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
 }
 
-void ModuleBase_ModelWidget::enableFocusProcessing(QWidget* theWidget)
-{
-  theWidget->setFocusPolicy(Qt::StrongFocus);
-  theWidget->installEventFilter(this);
-  myFocusInWidgets.append(theWidget);
-}
-
 bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
 {
   QWidget* aWidget = qobject_cast<QWidget*>(theObject);
-  if (theEvent->type() == QEvent::MouseButtonRelease && 
-      myFocusInWidgets.contains(aWidget)) {
-    emit focusInWidget(this);
+  if (theEvent->type() == QEvent::FocusIn) {
+    if (getControls().contains(aWidget)) {
+      emit focusInWidget(this);
+    }
   } 
   // pass the event on to the parent class
+
   return QObject::eventFilter(theObject, theEvent);
 }
index 9f2f6f4555698d9c6b0dc6de3eea83087baa749a..48a650e325ac23ca16c74a8ec4f932f672039ca5 100644 (file)
@@ -139,10 +139,6 @@ signals:
 
   void updateObject(ObjectPtr theObj) const;
 
- private:
-  /// Let the widget process FocusIn events
-  void enableFocusProcessing(QWidget* theWidget);
-
  protected:
   std::string myAttributeID; /// the attribute name of the model feature
   std::string myParentId;    /// name of parent
@@ -151,10 +147,6 @@ signals:
   bool myIsComputedDefault; /// Value should be computed on execute,
   /// like radius for circle's constraint (can not be zero)
   bool myIsObligatory;      /// Non-obligatory widget is valid even if it is not initialized
-
- private:
-   /// Contains a list of widgets that may accept focus
-   QList<QWidget*> myFocusInWidgets;
 };
 
 #endif
index 19876df75612ffd5f5b1d2ee36c8a92ed17e45c8..36bc9f6f3cc2fca75a21fcc5bc9911a018728a66 100644 (file)
@@ -187,8 +187,8 @@ void ModuleBase_Operation::start()
 void ModuleBase_Operation::resume()
 {
   if (myPropertyPanel)
-    connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), this,
-            SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+    connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+            this,            SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
   emit resumed();
 }
 
index 93a35bdc99599051253912b42ee3b206a441962c..9f6a706cfb418d9c8b7d368440be2e1d8b3cc487 100644 (file)
@@ -23,7 +23,8 @@
 #endif
 
 XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
-    : ModuleBase_IPropertyPanel(theParent), myActiveWidget(0)
+    : ModuleBase_IPropertyPanel(theParent), 
+    myActiveWidget(NULL)
 {
   this->setWindowTitle(tr("Property Panel"));
   QAction* aViewAct = this->toggleViewAction();
@@ -71,6 +72,7 @@ void XGUI_PropertyPanel::cleanContent()
 {
   myWidgets.clear();
   qDeleteAll(myCustomWidget->children());
+  myActiveWidget = NULL;
 }
 
 void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets)
@@ -87,7 +89,7 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
     connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
             SLOT(activateNextWidget(ModuleBase_ModelWidget*)));
     connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
-            this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
+            this, SLOT(activateWidget(ModuleBase_ModelWidget*)));
 
     ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
     if (aPointWidget)
@@ -121,20 +123,17 @@ QWidget* XGUI_PropertyPanel::contentWidget()
 
 void XGUI_PropertyPanel::updateContentWidget(FeaturePtr theFeature)
 {
-  int aS = myWidgets.size();
   foreach(ModuleBase_ModelWidget* eachWidget, myWidgets)
   {
     eachWidget->setFeature(theFeature);
     eachWidget->restoreValue();
   }
-  // the repaint is used here to immediatelly react in GUI to the values change.
+  // the repaint is used here to immediately react in GUI to the values change.
   repaint();
 }
 
-
 void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
 {
-  QObject* aSender = sender();
   ModuleBase_ModelWidget* aNextWidget = 0;
   QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
   bool isFoundWidget = false;
@@ -146,8 +145,11 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget)
     }
     isFoundWidget = (*anIt) == theWidget;
   }
-  myActiveWidget = aNextWidget;
-  emit widgetActivated(myActiveWidget);
+  // Normaly focusTo is enough to activate widget
+  // here is a special case on mouse click in the viewer
+  if(aNextWidget == NULL) {
+    activateWidget(NULL);
+  }
 }
 
 void XGUI_PropertyPanel::activateNextWidget()
@@ -160,3 +162,15 @@ void XGUI_PropertyPanel::setAcceptEnabled(bool isEnabled)
   QPushButton* anOkBtn = findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
   anOkBtn->setEnabled(isEnabled);
 }
+
+void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
+{
+  if(myActiveWidget) {
+    myActiveWidget->setHighlighted(false);
+  }
+  if(theWidget) {
+    theWidget->setHighlighted(true);
+  }
+  myActiveWidget = theWidget;
+  emit widgetActivated(theWidget);
+}
index b29d51579e9c1a238a8bfc365baae90eb11343e0..ebd529d11056c439f61df3f0353d807501862ea7 100644 (file)
@@ -51,12 +51,19 @@ Q_OBJECT
   // Enables / disables "ok" ("accept") button
   void setAcceptEnabled(bool);
 
-signals:
+ protected slots:
+  // Makes the given widget active, highlights it and removes
+  // highlighting from the previous active widget
+  // emits widgetActivated(theWidget) signal
+  void activateWidget(ModuleBase_ModelWidget* theWidget);
+
+ signals:
   /// Signal about the point 2d set to the feature
   /// \param the feature
   /// \param the attribute of the feature
   void storedPoint2D(ObjectPtr theFeature, const std::string& theAttribute);
 
+
  private:
   QWidget* myCustomWidget;
   QList<ModuleBase_ModelWidget*> myWidgets;
index 8ca4729a3f373e5765c1b5a69a41dba3a796862b..14730f7745d4eac97f3e8c230aae5d54e90eb160 100644 (file)
@@ -1011,10 +1011,6 @@ void XGUI_Workshop::createDockWidgets()
   connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
   connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
           SLOT(onKeyReleased(QKeyEvent*)));
-  //connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)), myOperationMgr,
-  //        SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
-  //connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)), myPropertyPanel,
-  //        SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
   connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
           SLOT(setAcceptEnabled(bool)));