| 3942 | } |
| 3943 | |
| 3944 | bool MainWindow::xmlLoadState(const QDomDocument& state_document) { |
| 3945 | const QDomElement root = state_document.documentElement(); |
| 3946 | if (root.isNull() || root.tagName() != QStringLiteral("root")) { |
| 3947 | qCWarning(lcMain) << "No <root> element found at the top-level of the XML document"; |
| 3948 | return false; |
| 3949 | } |
| 3950 | |
| 3951 | QDomElement main_tabbed_widget; |
| 3952 | for (auto tabbed = root.firstChildElement(QStringLiteral("tabbed_widget")); !tabbed.isNull(); |
| 3953 | tabbed = tabbed.nextSiblingElement(QStringLiteral("tabbed_widget"))) { |
| 3954 | if (main_tabbed_widget.isNull()) { |
| 3955 | main_tabbed_widget = tabbed; |
| 3956 | } |
| 3957 | if (tabbed.attribute(QStringLiteral("parent")) == QStringLiteral("main_window")) { |
| 3958 | main_tabbed_widget = tabbed; |
| 3959 | break; |
| 3960 | } |
| 3961 | } |
| 3962 | if (main_tabbed_widget.isNull()) { |
| 3963 | qCWarning(lcMain) << "No <tabbed_widget> element found in XML document"; |
| 3964 | return false; |
| 3965 | } |
| 3966 | |
| 3967 | const bool loaded = ui_->tabbedPlotWidget->xmlLoadState(main_tabbed_widget); |
| 3968 | if (!loaded) { |
| 3969 | return false; |
| 3970 | } |
| 3971 | wireExistingPlots(); |
| 3972 | |
| 3973 | // The global toolbar toggles are no longer read from the layout/undo document |
| 3974 | // (see xmlSaveState) — they are app-wide QSettings preferences. Freshly loaded |
| 3975 | // plots still adopt the CURRENT global toggle state below, so a restored |
| 3976 | // layout stays visually consistent with the rest of the app without the |
| 3977 | // document dictating the toggle positions. |
| 3978 | forEachPlot([this](PlotWidget* plot) { applyGlobalToggles(plot); }); |
| 3979 | applyShowPointsTo2DWidgets(); |
| 3980 | return true; |
| 3981 | } |
| 3982 | |
| 3983 | void MainWindow::pushInitialUndoState() { |
| 3984 | undo_states_.clear(); |