Changed store and restore functioality to save the current dock widget name of an dock area instead of the current index because if some dock widgets are missing when loading the configuration, the dock index might be wrong

This commit is contained in:
Uwe Kindler
2018-11-01 08:52:14 +01:00
parent 5e6c82b68d
commit 3f5697554a
4 changed files with 31 additions and 18 deletions

View File

@@ -269,15 +269,12 @@ bool DockManagerPrivate::restoreState(const QByteArray &state, int version)
for (int i = 0; i < DockContainer->dockAreaCount(); ++i)
{
CDockAreaWidget* DockArea = DockContainer->dockArea(i);
int CurrentIndex = DockArea->property("currentIndex").toInt();
int DockWidgetCount = DockArea->dockWidgetsCount();
if (CurrentIndex < DockWidgetCount && DockWidgetCount > 1 && CurrentIndex > -1)
QString DockWidgetName = DockArea->property("currentDockWidget").toString();
CDockWidget* DockWidget = _this->findDockWidget(DockWidgetName);
std::cout << "restore DockWIdgetName " << DockWidget->objectName().toStdString() << std::endl;
if (!DockWidget->isClosed())
{
auto DockWidget = DockArea->dockWidget(CurrentIndex);
if (!DockWidget->isClosed())
{
DockArea->setCurrentIndex(CurrentIndex);
}
DockArea->internalSetCurrentDockWidget(DockWidget);
}
}
}