@@ -98,6 +98,7 @@ struct DockManagerPrivate
9898{
9999 CDockManager* _this;
100100 QList<CFloatingDockContainer*> FloatingWidgets;
101+ QList<CFloatingDockContainer*> HiddenFloatingWidgets;
101102 QList<CDockContainerWidget*> Containers;
102103 CDockOverlay* ContainerOverlay;
103104 CDockOverlay* DockAreaOverlay;
@@ -755,6 +756,10 @@ CFloatingDockContainer* CDockManager::addDockWidgetFloating(CDockWidget* Dockwid
755756void CDockManager::showEvent (QShowEvent *event)
756757{
757758 Super::showEvent (event);
759+
760+ // Fix Issue #380
761+ restoreHiddenFloatingWidgets ();
762+
758763 if (d->UninitializedFloatingWidgets .empty ())
759764 {
760765 return ;
@@ -772,6 +777,32 @@ void CDockManager::showEvent(QShowEvent *event)
772777 d->UninitializedFloatingWidgets .clear ();
773778}
774779
780+ void CDockManager::restoreHiddenFloatingWidgets ()
781+ {
782+ // Restore floating widgets that were hidden upon hideManagerAndFloatingWidgets
783+ for (auto FloatingWidget : d->HiddenFloatingWidgets )
784+ {
785+ bool hasDockWidgetVisible = false ;
786+
787+ // Needed to prevent CFloatingDockContainer being shown empty
788+ // Could make sense to move this to CFloatingDockContainer::showEvent(QShowEvent *event)
789+ // if experiencing CFloatingDockContainer being shown empty in other situations, but let's keep
790+ // it here for now to make sure changes to fix Issue #380 does not impact existing behaviours
791+ for ( auto dockWidget : FloatingWidget->dockWidgets () )
792+ {
793+ if ( dockWidget->toggleViewAction ()->isChecked () )
794+ {
795+ dockWidget->toggleView (true );
796+ hasDockWidgetVisible = true ;
797+ }
798+ }
799+
800+ if ( hasDockWidgetVisible )
801+ FloatingWidget->show ();
802+ }
803+
804+ d->HiddenFloatingWidgets .clear ();
805+ }
775806
776807// ============================================================================
777808CDockAreaWidget* CDockManager::addDockWidget (DockWidgetArea area,
@@ -1102,6 +1133,38 @@ void CDockManager::setDockWidgetFocused(CDockWidget* DockWidget)
11021133 }
11031134}
11041135
1136+ // ===========================================================================
1137+ void CDockManager::hideManagerAndFloatingWidgets ()
1138+ {
1139+ hide ();
1140+
1141+ d->HiddenFloatingWidgets .clear ();
1142+ // Hide updates of floating widgets from user
1143+ for (auto FloatingWidget : d->FloatingWidgets )
1144+ {
1145+ if ( FloatingWidget->isVisible () )
1146+ {
1147+ QList<CDockWidget*> VisibleWidgets;
1148+ for ( auto dockWidget : FloatingWidget->dockWidgets () )
1149+ {
1150+ if ( dockWidget->toggleViewAction ()->isChecked () )
1151+ VisibleWidgets.push_back ( dockWidget );
1152+ }
1153+
1154+ // save as floating widget to be shown when CDockManager will be shown back
1155+ d->HiddenFloatingWidgets .push_back ( FloatingWidget );
1156+ FloatingWidget->hide ();
1157+
1158+ // hidding floating widget automatically marked contained CDockWidgets as hidden
1159+ // but they must remain marked as visible as we want them to be restored visible
1160+ // when CDockManager will be shown back
1161+ for ( auto dockWidget : VisibleWidgets )
1162+ {
1163+ dockWidget->toggleViewAction ()->setChecked (true );
1164+ }
1165+ }
1166+ }
1167+ }
11051168
11061169// ===========================================================================
11071170CDockWidget* CDockManager::focusedDockWidget () const
0 commit comments