From 78dbd6fff17a73305f4db8277dfe104c16e9be83 Mon Sep 17 00:00:00 2001 From: vsv Date: Mon, 6 Apr 2020 19:49:07 +0300 Subject: [PATCH] Issue #18876 (Tuleap): Hide sketcher pop-up messages on deactivation of a main window --- src/PartSet/PartSet_WidgetSketchLabel.cpp | 34 +++++++++++++++++++++++ src/PartSet/PartSet_WidgetSketchLabel.h | 8 +++++- 2 files changed, 41 insertions(+), 1 deletion(-) 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(); -- 2.30.2