From: vsv Date: Mon, 6 Apr 2020 16:49:07 +0000 (+0300) Subject: Issue #18876 (Tuleap): Hide sketcher pop-up messages on deactivation of a main window X-Git-Tag: V9_5_0b1~60 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=78dbd6fff17a73305f4db8277dfe104c16e9be83;p=modules%2Fshaper.git Issue #18876 (Tuleap): Hide sketcher pop-up messages on deactivation of a main window --- diff --git a/src/PartSet/PartSet_WidgetSketchLabel.cpp b/src/PartSet/PartSet_WidgetSketchLabel.cpp index 099f6800b..cd11fabee 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.cpp +++ b/src/PartSet/PartSet_WidgetSketchLabel.cpp @@ -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(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 diff --git a/src/PartSet/PartSet_WidgetSketchLabel.h b/src/PartSet/PartSet_WidgetSketchLabel.h index 64dbdb817..635332dc9 100644 --- a/src/PartSet/PartSet_WidgetSketchLabel.h +++ b/src/PartSet/PartSet_WidgetSketchLabel.h @@ -202,9 +202,15 @@ protected: /// \param thePrs a presentation bool fillSketchPlaneBySelection(const std::shared_ptr& 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();