Skip to content

Commit a3ff1ae

Browse files
author
Uwe Kindler
committed
Fixed restore procedure and deletion of floating widgts
1 parent 17dff82 commit a3ff1ae

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

src/DockContainerWidget.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,9 @@ bool DockContainerWidgetPrivate::restoreDockArea(QDataStream& stream,
430430

431431
qDebug() << "Dock Widget found - parent " << DockWidget->parent();
432432
DockArea->addDockWidget(DockWidget);
433-
DockWidget->toggleView(!Closed);
433+
434+
DockArea->hide();
435+
DockWidget->setProperty("closed", Closed);
434436
DockWidget->setProperty("dirty", false);
435437
}
436438

@@ -444,9 +446,13 @@ bool DockContainerWidgetPrivate::restoreDockArea(QDataStream& stream,
444446
delete DockArea;
445447
DockArea = nullptr;
446448
}
449+
else
450+
{
451+
DockArea->setProperty("currentIndex", CurrentIndex);
452+
}
447453
CreatedWidget = DockArea;
448454
DockAreas.append(DockArea);
449-
DockArea->setCurrentIndex(CurrentIndex);
455+
//DockArea->setCurrentIndex(CurrentIndex);
450456
return true;
451457
}
452458

src/DockManager.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
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

4850
namespace 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;

src/DockWidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class CDockWidgetTitleBar;
3939
class CDockManager;
4040
class CDockContainerWidget;
4141
class CDockAreaWidget;
42+
struct DockContainerWidgetPrivate;
4243

4344
/**
4445
* The QDockWidget class provides a widget that can be docked inside a
@@ -56,6 +57,7 @@ class CDockWidget : public QFrame
5657
friend class CDockAreaWidget;
5758
friend class CFloatingDockContainer;
5859
friend class CDockManager;
60+
friend class DockContainerWidgetPrivate;
5961

6062
/**
6163
* Assigns the dock manager that manages this dock widget

0 commit comments

Comments
 (0)