@@ -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 ;
@@ -767,6 +772,32 @@ void CDockManager::showEvent(QShowEvent *event)
767772 d->UninitializedFloatingWidgets .clear ();
768773}
769774
775+ void CDockManager::restoreHiddenFloatingWidgets ()
776+ {
777+ // Restore floating widgets that were hidden upon hideManagerAndFloatingWidgets
778+ for (auto FloatingWidget : d->HiddenFloatingWidgets )
779+ {
780+ bool hasDockWidgetVisible = false ;
781+
782+ // Needed to prevent CFloatingDockContainer being shown empty
783+ // Could make sense to move this to CFloatingDockContainer::showEvent(QShowEvent *event)
784+ // if experiencing CFloatingDockContainer being shown empty in other situations, but let's keep
785+ // it here for now to make sure changes to fix Issue #380 does not impact existing behaviours
786+ for ( auto dockWidget : FloatingWidget->dockWidgets () )
787+ {
788+ if ( dockWidget->toggleViewAction ()->isChecked () )
789+ {
790+ dockWidget->toggleView (true );
791+ hasDockWidgetVisible = true ;
792+ }
793+ }
794+
795+ if ( hasDockWidgetVisible )
796+ FloatingWidget->show ();
797+ }
798+
799+ d->HiddenFloatingWidgets .clear ();
800+ }
770801
771802// ============================================================================
772803CDockAreaWidget* CDockManager::addDockWidget (DockWidgetArea area,
@@ -1097,6 +1128,38 @@ void CDockManager::setDockWidgetFocused(CDockWidget* DockWidget)
10971128 }
10981129}
10991130
1131+ // ===========================================================================
1132+ void CDockManager::hideManagerAndFloatingWidgets ()
1133+ {
1134+ hide ();
1135+
1136+ d->HiddenFloatingWidgets .clear ();
1137+ // Hide updates of floating widgets from user
1138+ for (auto FloatingWidget : d->FloatingWidgets )
1139+ {
1140+ if ( FloatingWidget->isVisible () )
1141+ {
1142+ QList<CDockWidget*> VisibleWidgets;
1143+ for ( auto dockWidget : FloatingWidget->dockWidgets () )
1144+ {
1145+ if ( dockWidget->toggleViewAction ()->isChecked () )
1146+ VisibleWidgets.push_back ( dockWidget );
1147+ }
1148+
1149+ // save as floating widget to be shown when CDockManager will be shown back
1150+ d->HiddenFloatingWidgets .push_back ( FloatingWidget );
1151+ FloatingWidget->hide ();
1152+
1153+ // hidding floating widget automatically marked contained CDockWidgets as hidden
1154+ // but they must remain marked as visible as we want them to be restored visible
1155+ // when CDockManager will be shown back
1156+ for ( auto dockWidget : VisibleWidgets )
1157+ {
1158+ dockWidget->toggleViewAction ()->setChecked (true );
1159+ }
1160+ }
1161+ }
1162+ }
11001163
11011164// ===========================================================================
11021165CDockWidget* CDockManager::focusedDockWidget () const
0 commit comments