mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-11-15 13:15:43 +08:00
Fixed restore procedure and deletion of floating widgts
This commit is contained in:
parent
17dff82d12
commit
a3ff1ae8ee
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user