]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
0023467: Salome open modules (ie OpenTurns) in new window
authorvsr <vsr@opencascade.com>
Fri, 14 Jul 2017 09:45:31 +0000 (12:45 +0300)
committervsr <vsr@opencascade.com>
Fri, 14 Jul 2017 09:45:31 +0000 (12:45 +0300)
- Implement a workaround to prevent short-time "flickering" of a view window as a top-level window.

src/SUIT/SUIT_Desktop.cxx
src/SUIT/SUIT_ViewWindow.cxx
src/SUIT/SUIT_ViewWindow.h

index 7cc7706dedef0eb7c6615ea9c2dfca2e3faeda56..8617fa37993efc82de3dabbe4ceab11e591c7cf7 100755 (executable)
@@ -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 );
   }
index 6bc8af07c566165449526f79e05e2c665be1fcb1..0a40235768c90dc2d25424a90919714d9b031921 100755 (executable)
@@ -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 );
+}
index fd717f617adeb8e96a33fac802e7b8c7391028f6..7d6047e37c01e7e9de8c8324e79d100a863ac394 100755 (executable)
@@ -76,6 +76,7 @@ public:
 
 public slots:
   virtual void      onDumpView();
+  void              setVisible( bool );
 
 signals:
   void              tryClosing( SUIT_ViewWindow* );