Skip to content

Commit 11aec65

Browse files
Properly persist the AllowedAreas state of CDockAreaWidget
1 parent edc799b commit 11aec65

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/DockAreaWidget.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class CDockAreaLayout
235235

236236

237237
using DockAreaLayout = CDockAreaLayout;
238+
static constexpr DockWidgetAreas DefaultAllowedAreas = AllDockAreas;
238239

239240

240241
/**
@@ -248,7 +249,7 @@ struct DockAreaWidgetPrivate
248249
CDockAreaTitleBar* TitleBar = nullptr;
249250
CDockManager* DockManager = nullptr;
250251
bool UpdateTitleBarButtons = false;
251-
DockWidgetAreas AllowedAreas = AllDockAreas;
252+
DockWidgetAreas AllowedAreas = DefaultAllowedAreas;
252253
bool HideSingleWidgetTitleBar = false;
253254
QSize MinSizeHint;
254255

@@ -771,6 +772,13 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
771772
auto CurrentDockWidget = currentDockWidget();
772773
QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : "";
773774
s.writeAttribute("Current", Name);
775+
auto AllowedAreas = allowedAreas();
776+
// To keep the saved XML data small, we only save the allowed areas if
777+
// the value is different from the default value
778+
if (AllowedAreas != DefaultAllowedAreas)
779+
{
780+
s.writeAttribute("AllowedAreas", QString::number(AllowedAreas, 16));
781+
}
774782
ADS_PRINT("CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
775783
<< " Current: " << Name);
776784
for (int i = 0; i < d->ContentsLayout->count(); ++i)

src/DockContainerWidget.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,11 @@ bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
942942
if (!Testing)
943943
{
944944
DockArea = new CDockAreaWidget(DockManager, _this);
945+
const auto AllowedAreasAttribute = s.attributes().value("AllowedAreas");
946+
if (!AllowedAreasAttribute.isEmpty())
947+
{
948+
DockArea->setAllowedAreas((DockWidgetArea)AllowedAreasAttribute.toInt(nullptr, 16));
949+
}
945950
}
946951

947952
while (s.readNextStartElement())

0 commit comments

Comments
 (0)