| 284 | }; |
| 285 | |
| 286 | void applySplitterSizes(const LayoutNode& node, const QVector<DockWidget*>& widgets) { |
| 287 | if (node.size_ratios.size() != widgets.size() || widgets.isEmpty()) { |
| 288 | return; |
| 289 | } |
| 290 | auto* splitter = ads::internal::findParent<ads::CDockSplitter*>(widgets.back()); |
| 291 | if (splitter == nullptr) { |
| 292 | return; |
| 293 | } |
| 294 | |
| 295 | // Express the saved ratios as large relative weights instead of scaling them by |
| 296 | // the widgets' *current* pixel sizes. During layout restore the docker is not |
| 297 | // laid out at its final size yet — TabbedPlotWidget builds a brand-new PlotDocker |
| 298 | // per tab and restores into it before it is shown — so widget->width()/height() |
| 299 | // report placeholder geometry that distorts the proportions (and the splitter |
| 300 | // later "grows" to fit, pulling the split toward 50/50). QSplitter::setSizes only |
| 301 | // stores relative weights: when the splitter is first laid out it shrinks these |
| 302 | // oversized hints to fit, distributing space proportionally, so a large common |
| 303 | // scale reproduces the saved ratios exactly regardless of when the dock area |
| 304 | // becomes visible. |
| 305 | constexpr double kRelativeScale = 1'000'000.0; |
| 306 | QList<int> sizes; |
| 307 | for (double ratio : node.size_ratios) { |
| 308 | sizes.push_back(std::max(1, static_cast<int>(ratio * kRelativeScale))); |
| 309 | } |
| 310 | splitter->setSizes(sizes); |
| 311 | } |
| 312 | |
| 313 | void restoreNode( |
| 314 | const LayoutNode& node, DockWidget* widget, RestorePlotPool& pool, |
no test coverage detected