mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-01-12 16:20:25 +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;
|
using DockAreaLayout = CDockAreaLayout;
|
||||||
|
static constexpr DockWidgetAreas DefaultAllowedAreas = AllDockAreas;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -248,7 +249,7 @@ struct DockAreaWidgetPrivate
|
|||||||
CDockAreaTitleBar* TitleBar = nullptr;
|
CDockAreaTitleBar* TitleBar = nullptr;
|
||||||
CDockManager* DockManager = nullptr;
|
CDockManager* DockManager = nullptr;
|
||||||
bool UpdateTitleBarButtons = false;
|
bool UpdateTitleBarButtons = false;
|
||||||
DockWidgetAreas AllowedAreas = AllDockAreas;
|
DockWidgetAreas AllowedAreas = DefaultAllowedAreas;
|
||||||
bool HideSingleWidgetTitleBar = false;
|
bool HideSingleWidgetTitleBar = false;
|
||||||
QSize MinSizeHint;
|
QSize MinSizeHint;
|
||||||
|
|
||||||
@ -771,6 +772,13 @@ void CDockAreaWidget::saveState(QXmlStreamWriter& s) const
|
|||||||
auto CurrentDockWidget = currentDockWidget();
|
auto CurrentDockWidget = currentDockWidget();
|
||||||
QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : "";
|
QString Name = CurrentDockWidget ? CurrentDockWidget->objectName() : "";
|
||||||
s.writeAttribute("Current", Name);
|
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()
|
ADS_PRINT("CDockAreaWidget::saveState TabCount: " << d->ContentsLayout->count()
|
||||||
<< " Current: " << Name);
|
<< " Current: " << Name);
|
||||||
for (int i = 0; i < d->ContentsLayout->count(); ++i)
|
for (int i = 0; i < d->ContentsLayout->count(); ++i)
|
||||||
|
@ -942,6 +942,11 @@ bool DockContainerWidgetPrivate::restoreDockArea(CDockingStateReader& s,
|
|||||||
if (!Testing)
|
if (!Testing)
|
||||||
{
|
{
|
||||||
DockArea = new CDockAreaWidget(DockManager, _this);
|
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())
|
while (s.readNextStartElement())
|
||||||
|
Loading…
Reference in New Issue
Block a user