mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2024-12-25 07:31:33 +08:00
Properly persist the AllowedAreas state of CDockAreaWidget
This commit is contained in:
parent
edc799bc54
commit
11aec65967
@ -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)
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user