Properly persist the AllowedAreas state of CDockAreaWidget

This commit is contained in:
Uwe Kindler 2020-08-17 23:50:37 +02:00
parent edc799bc54
commit 11aec65967
2 changed files with 14 additions and 1 deletions

View File

@ -235,6 +235,7 @@ public:
using DockAreaLayout = CDockAreaLayout;
static constexpr DockWidgetAreas DefaultAllowedAreas = AllDockAreas;
/**
@ -248,7 +249,7 @@ struct DockAreaWidgetPrivate
CDockAreaTitleBar* TitleBar = nullptr;
CDockManager* DockManager = nullptr;
bool UpdateTitleBarButtons = false;
DockWidgetAreas AllowedAreas = AllDockAreas;
DockWidgetAreas AllowedAreas = DefaultAllowedAreas;
bool HideSingleWidgetTitleBar = false;
QSize MinSizeHint;
@ -771,6 +772,13 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
auto CurrentDockWidget = currentDockWidget();
QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : "";
s.writeAttribute("Current", Name);
auto AllowedAreas = allowedAreas();
// To keep the saved XML data small, we only save the allowed areas if
// the value is different from the default value
if (AllowedAreas != DefaultAllowedAreas)
{
s.writeAttribute("AllowedAreas", QString::number(AllowedAreas, 16));
}
ADS_PRINT("CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
<< " Current: " << Name);
for (int i = 0; i < d->ContentsLayout->count(); ++i)

View File

@ -942,6 +942,11 @@ bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
if (!Testing)
{
DockArea = new CDockAreaWidget(DockManager, _this);
const auto AllowedAreasAttribute = s.attributes().value("AllowedAreas");
if (!AllowedAreasAttribute.isEmpty())
{
DockArea->setAllowedAreas((DockWidgetArea)AllowedAreasAttribute.toInt(nullptr, 16));
}
}
while (s.readNextStartElement())