| 2008 | } // namespace |
| 2009 | |
| 2010 | void MainWindow::setLegendStatus(LegendStatus position) { |
| 2011 | legend_status_ = position; |
| 2012 | // Track the "current position" used by the icon while hidden, so |
| 2013 | // right-click → show restores the user's last corner. |
| 2014 | if (position != LegendStatus::kHidden) { |
| 2015 | previous_legend_corner_ = position; |
| 2016 | } |
| 2017 | QSettings().setValue(QStringLiteral("MainWindow.legendStatus"), static_cast<int>(legend_status_)); |
| 2018 | if (button_legend_ != nullptr) { |
| 2019 | const bool visible = (position != LegendStatus::kHidden); |
| 2020 | button_legend_->setChecked(visible); |
| 2021 | button_legend_->setIconPath(legendCornerIcon(visible ? position : previous_legend_corner_)); |
| 2022 | } |
| 2023 | forEachPlot([this](PlotWidget* plot) { applyLegendStatus(plot); }); |
| 2024 | } |
| 2025 | |
| 2026 | void MainWindow::applyLegendStatus(PlotWidget* plot) { |
| 2027 | if (plot == nullptr) { |
nothing calls this directly
no test coverage detected