From: vsr Date: Fri, 14 Jul 2017 09:45:31 +0000 (+0300) Subject: 0023467: Salome open modules (ie OpenTurns) in new window X-Git-Tag: V8_4_0a1~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cf1b28bc3aa48232f5774342ef5ac4db31623402;p=modules%2Fgui.git 0023467: Salome open modules (ie OpenTurns) in new window - Implement a workaround to prevent short-time "flickering" of a view window as a top-level window. --- diff --git a/src/SUIT/SUIT_Desktop.cxx b/src/SUIT/SUIT_Desktop.cxx index 7cc7706de..8617fa379 100755 --- a/src/SUIT/SUIT_Desktop.cxx +++ b/src/SUIT/SUIT_Desktop.cxx @@ -108,10 +108,16 @@ void SUIT_Desktop::closeEvent( QCloseEvent* e ) */ void SUIT_Desktop::childEvent( QChildEvent* e ) { - if ( e->type() == QEvent::ChildAdded && e->child()->isWidgetType() ) + if ( e->type() == QEvent::ChildAdded && e->child()->isWidgetType() ) { + // The following line is a workaround to avoid showing view window as a top-level window + // before re-parenting it to workstack (issue #23467). + // See SUIT_ViewWindow::setVisible() and SUIT_Desktop::customEvent(). + e->child()->setProperty("blockShow", true ); QApplication::postEvent( this, new ReparentEvent( QEvent::Type( Reparent ), e->child() ) ); - else + } + else { QtxMainWindow::childEvent( e ); + } } void SUIT_Desktop::customEvent( QEvent* e ) @@ -126,6 +132,10 @@ void SUIT_Desktop::customEvent( QEvent* e ) bool invis = wid->testAttribute( Qt::WA_WState_ExplicitShowHide ) && wid->testAttribute( Qt::WA_WState_Hidden ); + // The following line is a workaround to avoid showing view window as a top-level window + // before re-parenting it to workstack (issue #23467). + // See SUIT_ViewWindow::setVisible() and SUIT_Desktop::childEvent(). + wid->setProperty("blockShow", false); addWindow( wid ); wid->setVisible( !invis ); } diff --git a/src/SUIT/SUIT_ViewWindow.cxx b/src/SUIT/SUIT_ViewWindow.cxx index 6bc8af07c..0a4023576 100755 --- a/src/SUIT/SUIT_ViewWindow.cxx +++ b/src/SUIT/SUIT_ViewWindow.cxx @@ -542,3 +542,15 @@ void SUIT_ViewWindow::synchronizeView( SUIT_ViewWindow* viewWindow, int id ) } } } + +void SUIT_ViewWindow::setVisible( bool on ) +{ + // This is a workaround to avoid showing view window as a top-level window + // before re-parenting it to workstack (issue #23467). + // See SUIT_Desktop::childEvent(). + QApplication::sendPostedEvents( 0, QEvent::ChildRemoved ); + QApplication::sendPostedEvents( 0, QEvent::ChildAdded ); + QApplication::sendPostedEvents( 0, QEvent::ChildPolished ); + if ( !property( "blockShow" ).toBool() ) + QMainWindow::setVisible( on ); +} diff --git a/src/SUIT/SUIT_ViewWindow.h b/src/SUIT/SUIT_ViewWindow.h index fd717f617..7d6047e37 100755 --- a/src/SUIT/SUIT_ViewWindow.h +++ b/src/SUIT/SUIT_ViewWindow.h @@ -76,6 +76,7 @@ public: public slots: virtual void onDumpView(); + void setVisible( bool ); signals: void tryClosing( SUIT_ViewWindow* );