Salome HOME
Copyright update 2022
[modules/gui.git] / src / SUIT / SUIT_Desktop.cxx
old mode 100755 (executable)
new mode 100644 (file)
index a6ace94..6058b18
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -84,6 +84,9 @@ bool SUIT_Desktop::event( QEvent* e )
   case QEvent::WindowDeactivate:
     emit deactivated();
     break;
+ /*case QEvent::Move:
+    emit moved();
+    break;*/
   default:
     break;
   }
@@ -105,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 )
@@ -123,8 +132,12 @@ 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->setShown( !invis );
+    wid->setVisible( !invis );
   }
 }
 
@@ -216,3 +229,11 @@ void SUIT_Desktop::emitMessage( const QString& theMessage )
 {
   emit message( theMessage );
 }
+
+/*!
+  Activate window (default implementation just sets focus to the window.
+*/
+void SUIT_Desktop::setActiveWindow(SUIT_ViewWindow* wnd)
+{
+  if (wnd) wnd->setFocus();
+}