Fixed restore procedure and deletion of floating widgts

This commit is contained in:
Uwe Kindler
2017-03-28 22:38:47 +02:00
parent 17dff82d12
commit a3ff1ae8ee
3 changed files with 32 additions and 9 deletions

View File

@@ -37,6 +37,7 @@
#include <QDebug>
#include <QFile>
#include <QApplication>
#include <QAction>
#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<QMainWindow*>(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;