Implemented save and restore function in AutoHideDockContainer

This commit is contained in:
Uwe Kindler 2022-10-26 11:17:05 +02:00
parent b2399bb279
commit 5199fa45d1

View File

@ -132,6 +132,15 @@ struct AutoHideDockContainerPrivate
ResizeHandle->setMaxResizeSize(ResizeHandle->orientation() == Qt::Horizontal ResizeHandle->setMaxResizeSize(ResizeHandle->orientation() == Qt::Horizontal
? Rect.width() : Rect.height()); ? Rect.width() : Rect.height());
} }
/**
* Convenience function to check, if this is an horizontal area
*/
bool isHorizontal() const
{
return isHorizontalArea(SideTabBarArea);
}
}; // struct AutoHideDockContainerPrivate }; // struct AutoHideDockContainerPrivate
@ -225,8 +234,6 @@ void CAutoHideDockContainer::updateSize()
} }
break; break;
} }
//resize(rect.width(), rect.height());
} }
//============================================================================ //============================================================================
@ -236,7 +243,6 @@ CAutoHideDockContainer::~CAutoHideDockContainer()
// Remove event filter in case there are any queued messages // Remove event filter in case there are any queued messages
qApp->removeEventFilter(this); qApp->removeEventFilter(this);
if (d->DockManager) if (d->DockManager)
{ {
parentContainer()->removeAutoHideWidget(this); parentContainer()->removeAutoHideWidget(this);
@ -327,41 +333,33 @@ void CAutoHideDockContainer::cleanupAndDelete()
void CAutoHideDockContainer::saveState(QXmlStreamWriter& s) void CAutoHideDockContainer::saveState(QXmlStreamWriter& s)
{ {
s.writeAttribute("SideTabBarArea", QString::number(sideTabBarArea())); s.writeAttribute("SideTabBarArea", QString::number(sideTabBarArea()));
QStringList Sizes; s.writeAttribute("Size", QString::number(d->isHorizontal() ? d->Size.height() : d->Size.width()));
// TODO implement auto hide dock container saving
/*for (auto Size : sizes())
{
Sizes << QString::number(Size);
}*/
s.writeAttribute("Sizes", Sizes.join(" "));
} }
//============================================================================ //============================================================================
bool CAutoHideDockContainer::restoreState(CDockingStateReader& s, bool Testing) bool CAutoHideDockContainer::restoreState(CDockingStateReader& s, bool Testing)
{ {
auto sSizes = s.attributes().value("Sizes").trimmed().toString(); bool ok;
ADS_PRINT("Sizes: " << sSizes); int Size = s.attributes().value("Size").toInt(&ok);
QTextStream TextStream(&sSizes); if (!ok)
QList<int> Sizes;
while (!TextStream.atEnd())
{
int value;
TextStream >> value;
Sizes.append(value);
}
// TODO implement restore state
/*if (Sizes.count() != count())
{ {
return false; return false;
} }
if (!Testing) if (Testing)
{ {
setSizes(Sizes); return true;
}*/ }
if (d->isHorizontal())
{
d->Size.setHeight(Size);
}
else
{
d->Size.setWidth(Size);
}
return true; return true;
} }