]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #18876 (Tuleap): Hide sketcher pop-up messages on deactivation of a main window
authorvsv <vsv@opencascade.com>
Mon, 6 Apr 2020 16:49:07 +0000 (19:49 +0300)
committervsv <vsv@opencascade.com>
Mon, 6 Apr 2020 16:49:07 +0000 (19:49 +0300)
src/PartSet/PartSet_WidgetSketchLabel.cpp
src/PartSet/PartSet_WidgetSketchLabel.h

index 099f6800b3ca864548074b3c71021d9eef0b357f..cd11fabee5f4b58c7a01f1fec4e5eee027f01ebf 100644 (file)
@@ -561,6 +561,10 @@ bool PartSet_WidgetSketchLabel::fillSketchPlaneBySelection(const ModuleBase_View
 
 void PartSet_WidgetSketchLabel::activateCustom()
 {
+  QWidget* aTopWidget = window();
+  if (aTopWidget)
+    aTopWidget->installEventFilter(this);
+
   PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
   if (aModule) {
     bool isBlocked = myAutoConstraints->blockSignals(true);
@@ -597,6 +601,16 @@ void PartSet_WidgetSketchLabel::showEvent(QShowEvent* theEvent)
   QTimer::singleShot(10, this, SLOT(onShowPanel()));
 }
 
+void PartSet_WidgetSketchLabel::hideEvent(QHideEvent* theEvent)
+{
+  ModuleBase_WidgetValidated::hideEvent(theEvent);
+  if (myPartSetMessage->isVisible())
+    myPartSetMessage->hide();
+  if (mySizeMessage->isVisible())
+    mySizeMessage->hide();
+}
+
+
 void PartSet_WidgetSketchLabel::onShowPanel()
 {
   //if (mySizeOfViewWidget->isVisible()) {
@@ -617,6 +631,10 @@ void PartSet_WidgetSketchLabel::onShowPanel()
 
 void PartSet_WidgetSketchLabel::deactivate()
 {
+  QWidget* aTopWidget = window();
+  if (aTopWidget)
+    aTopWidget->removeEventFilter(this);
+
   if (myTmpPlane.get()) {
     setSketchPlane(myTmpPlane);
     myTmpPlane.reset();
@@ -851,3 +869,19 @@ void PartSet_WidgetSketchLabel::onShowDOF()
     Events_Loop::loop()->flush(anEvent);
   }
 }
+
+bool PartSet_WidgetSketchLabel::eventFilter(QObject* theObj, QEvent* theEvent)
+{
+  if (theObj == window()) {
+    int aType = theEvent->type();
+    if ((aType == QEvent::Hide) || (aType == QEvent::WindowDeactivate)) {
+      if (myPartSetMessage->isVisible())
+        myPartSetMessage->hide();
+      if (mySizeMessage->isVisible())
+        mySizeMessage->hide();
+    }
+    else if ((aType == QEvent::Show) || (aType == QEvent::WindowActivate))
+      onShowPanel();
+  }
+  return ModuleBase_WidgetValidated::eventFilter(theObj, theEvent);
+}
\ No newline at end of file
index 64dbdb81785448db8d9081fae94cf31ae22573bc..635332dc9ab74f8834fdf7c2bde361e7bce536db 100644 (file)
@@ -202,9 +202,15 @@ protected:
   /// \param thePrs a presentation
   bool fillSketchPlaneBySelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs);
 
-
+  /// Redefinition of a virtual function
   virtual void showEvent(QShowEvent* theEvent);
 
+  /// Redefinition of a virtual function
+  virtual void hideEvent(QHideEvent* theEvent);
+
+  /// Redefinition of a virtual function
+  virtual bool eventFilter(QObject* theObj, QEvent* theEvent);
+
 private slots:
   /// A slot called on set sketch plane view
   void onSetPlaneView();