3737#include < QDebug>
3838#include < QFile>
3939#include < QApplication>
40+ #include < QAction>
4041
4142#include " FloatingDockContainer.h"
4243#include " DockOverlay.h"
4344#include " DockWidget.h"
4445#include " ads_globals.h"
4546#include " DockStateSerialization.h"
4647#include " DockWidgetTitleBar.h"
48+ #include " DockAreaWidget.h"
4749
4850namespace ads
4951{
@@ -199,9 +201,11 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
199201 // Delete remaining empty floating widgets
200202 int FloatingWidgetIndex = i - 1 ;
201203 int DeleteCount = FloatingWidgets.count () - FloatingWidgetIndex;
204+ /* std::cout << "DeleteCount " << DeleteCount << " FloatingWidgets.count() "
205+ << FloatingWidgets.count() << " FloatingWdgetIndex " << FloatingWidgetIndex << std::endl;*/
202206 for (int i = 0 ; i < DeleteCount; ++i)
203207 {
204- FloatingWidgets[FloatingWidgetIndex]->deleteLater ();
208+ FloatingWidgets[FloatingWidgetIndex + i ]->deleteLater ();
205209 }
206210
207211 return Result;
@@ -335,17 +339,11 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
335339 DockWidget->setProperty (" dirty" , true );
336340 }
337341
338- // this->hide();
339- QMainWindow* MainWindow = internal::findParent<QMainWindow*>(this );
340- MainWindow->hide ();
341- QApplication::processEvents ();
342342 if (!d->restoreState (state, version))
343343 {
344344 qDebug () << " restoreState: Error restoring state!!!!!!!" ;
345345 return false ;
346346 }
347- MainWindow->show ();
348- // this->show();
349347
350348 // All dock widgets, that have not been processed in the restore state
351349 // function are invisible to the user now and have no assigned dock area
@@ -357,6 +355,23 @@ bool CDockManager::restoreState(const QByteArray &state, int version)
357355 {
358356 DockWidget->flagAsUnassigned ();
359357 }
358+ else if (!DockWidget->property (" closed" ).toBool ())
359+ {
360+ DockWidget->toggleView (true );
361+ }
362+ }
363+
364+ for (auto DockContainer : d->Containers )
365+ {
366+ for (int i = 0 ; i < DockContainer->dockAreaCount (); ++i)
367+ {
368+ CDockAreaWidget* DockArea = DockContainer->dockArea (i);
369+ int CurrentIndex = DockArea->property (" currentIndex" ).toInt ();
370+ if (CurrentIndex < DockArea->count () && DockArea->count () > 1 && CurrentIndex > -1 )
371+ {
372+ DockArea->setCurrentIndex (CurrentIndex);
373+ }
374+ }
360375 }
361376
362377 return true ;
0 commit comments