From 11aec65967cbe44da5c1c81779fe6767f7a61a7f Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Mon, 17 Aug 2020 23:50:37 +0200 Subject: [PATCH] Properly persist the AllowedAreas state of CDockAreaWidget --- src/DockAreaWidget.cpp | 10 +++++++++- src/DockContainerWidget.cpp | 5 +++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/DockAreaWidget.cpp b/src/DockAreaWidget.cpp index 01acfa6..dad429d 100644 --- a/src/DockAreaWidget.cpp +++ b/src/DockAreaWidget.cpp @@ -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) diff --git a/src/DockContainerWidget.cpp b/src/DockContainerWidget.cpp index e0bc72c..c3eecf6 100644 --- a/src/DockContainerWidget.cpp +++ b/src/DockContainerWidget.cpp @@ -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())