From c55ce478df804b1587b4e3b722bf5283fd79c2db Mon Sep 17 00:00:00 2001 From: Mauro Persano Date: Wed, 25 Jan 2023 16:07:26 -0300 Subject: [PATCH] Serialize dock overlayed geometries Otherwise the size of auto-hidden dock widgets won't get restored. --- src/LayoutSaver.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/LayoutSaver.cpp b/src/LayoutSaver.cpp index bb63ed05..4b82f29d 100644 --- a/src/LayoutSaver.cpp +++ b/src/LayoutSaver.cpp @@ -977,10 +977,24 @@ void LayoutSaver::Position::scaleSizes(const ScalingInfo &scalingInfo) scalingInfo.applyFactorsTo(/*by-ref*/ lastFloatingGeometry); } +static QVariantList overlayedGeometriesToList(const QHash &geometries) +{ + QVariantList result; + result.reserve(geometries.size()); + for (auto it = geometries.cbegin(), end = geometries.cend(); it != end; ++it) { + QVariantMap map; + map.insert(QStringLiteral("location"), static_cast(it.key())); + map.insert(QStringLiteral("rect"), Layouting::rectToMap(it.value())); + result.push_back(map); + } + return result; +} + QVariantMap LayoutSaver::Position::toVariantMap() const { QVariantMap map; map.insert(QStringLiteral("lastFloatingGeometry"), Layouting::rectToMap(lastFloatingGeometry)); + map.insert(QStringLiteral("lastOverlayedGeometries"), overlayedGeometriesToList(lastOverlayedGeometries)); map.insert(QStringLiteral("tabIndex"), tabIndex); map.insert(QStringLiteral("wasFloating"), wasFloating); map.insert(QStringLiteral("placeholders"), toVariantList(placeholders)); @@ -988,9 +1002,22 @@ QVariantMap LayoutSaver::Position::toVariantMap() const return map; } +static QHash listToOverlayedGeometries(const QVariantList &list) +{ + QHash result; + for (const QVariant &v : list) { + const auto map = v.toMap(); + const auto location = static_cast(map.value(QStringLiteral("location")).toInt()); + const auto rect = Layouting::mapToRect(map.value(QStringLiteral("rect")).toMap()); + result.insert(location, rect); + } + return result; +} + void LayoutSaver::Position::fromVariantMap(const QVariantMap &map) { lastFloatingGeometry = Layouting::mapToRect(map.value(QStringLiteral("lastFloatingGeometry")).toMap()); + lastOverlayedGeometries = listToOverlayedGeometries(map.value(QStringLiteral("lastOverlayedGeometries")).toList()); tabIndex = map.value(QStringLiteral("tabIndex")).toInt(); wasFloating = map.value(QStringLiteral("wasFloating")).toBool(); placeholders = fromVariantList(map.value(QStringLiteral("placeholders")).toList());