diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index 5f787ff..2cb2aa5 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -430,7 +430,9 @@ bool DockContainerWidgetPrivate::restoreDockArea(QDataStream& stream, qDebug() << "Dock Widget found - parent " << DockWidget->parent(); DockArea->addDockWidget(DockWidget); - DockWidget->toggleView(!Closed); + + DockArea->hide(); + DockWidget->setProperty("closed", Closed); DockWidget->setProperty("dirty", false); } @@ -444,9 +446,13 @@ bool DockContainerWidgetPrivate::restoreDockArea(QDataStream& stream, delete DockArea; DockArea = nullptr; } + else + { + DockArea->setProperty("currentIndex", CurrentIndex); + } CreatedWidget = DockArea; DockAreas.append(DockArea); - DockArea->setCurrentIndex(CurrentIndex); + //DockArea->setCurrentIndex(CurrentIndex); return true; } diff --git a/src/DockManager.cpp b/src/DockManager.cpp index fd8b142..3564bec 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "FloatingDockContainer.h" #include "DockOverlay.h" @@ -44,6 +45,7 @@ #include "ads_globals.h" #include "DockStateSerialization.h" #include "DockWidgetTitleBar.h" +#include "DockAreaWidget.h" namespace ads { @@ -199,9 +201,11 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version) // Delete remaining empty floating widgets int FloatingWidgetIndex = i - 1; int DeleteCount = FloatingWidgets.count() - FloatingWidgetIndex; + /*std::cout << "DeleteCount " << DeleteCount << " FloatingWidgets.count() " + << FloatingWidgets.count() << " FloatingWdgetIndex " << FloatingWidgetIndex << std::endl;*/ for (int i = 0; i < DeleteCount; ++i) { - FloatingWidgets[FloatingWidgetIndex]->deleteLater(); + FloatingWidgets[FloatingWidgetIndex + i]->deleteLater(); } return Result; @@ -335,17 +339,11 @@ bool CDockManager::restoreState(const QByteArray &state, int version) DockWidget->setProperty("dirty", true); } - //this->hide(); - QMainWindow* MainWindow = internal::findParent(this); - MainWindow->hide(); - QApplication::processEvents(); if (!d->restoreState(state, version)) { qDebug() << "restoreState: Error restoring state!!!!!!!"; return false; } - MainWindow->show(); - // this->show(); // All dock widgets, that have not been processed in the restore state // 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) { DockWidget->flagAsUnassigned(); } + else if (!DockWidget->property("closed").toBool()) + { + DockWidget->toggleView(true); + } + } + + for (auto DockContainer : d->Containers) + { + for (int i = 0; i < DockContainer->dockAreaCount(); ++i) + { + CDockAreaWidget* DockArea = DockContainer->dockArea(i); + int CurrentIndex = DockArea->property("currentIndex").toInt(); + if (CurrentIndex < DockArea->count() && DockArea->count() > 1 && CurrentIndex > -1) + { + DockArea->setCurrentIndex(CurrentIndex); + } + } } return true; diff --git a/src/DockWidget.h b/src/DockWidget.h index 532e7f6..5f170f1 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -39,6 +39,7 @@ class CDockWidgetTitleBar; class CDockManager; class CDockContainerWidget; class CDockAreaWidget; +struct DockContainerWidgetPrivate; /** * The QDockWidget class provides a widget that can be docked inside a @@ -56,6 +57,7 @@ protected: friend class CDockAreaWidget; friend class CFloatingDockContainer; friend class CDockManager; + friend class DockContainerWidgetPrivate; /** * Assigns the dock manager that manages this dock widget