* @brief Constructs the Dashboard, wires reset signals and loads persisted settings. */
| 148 | * @brief Constructs the Dashboard, wires reset signals and loads persisted settings. |
| 149 | */ |
| 150 | UI::Dashboard::Dashboard() |
| 151 | : m_points(kDefaultPlotPoints) |
| 152 | , m_widgetCount(0) |
| 153 | , m_updateRequired(false) |
| 154 | , m_showActionPanel(true) |
| 155 | , m_terminalEnabled(false) |
| 156 | , m_notificationLogEnabled(false) |
| 157 | , m_clockEnabled(false) |
| 158 | , m_stopwatchEnabled(false) |
| 159 | , m_autoHideToolbar(false) |
| 160 | , m_persistSettings(true) |
| 161 | , m_autoLayoutMargin(0) |
| 162 | , m_autoLayoutSpacing(-1) |
| 163 | , m_updateRetryInProgress(false) |
| 164 | , m_layoutValid(false) |
| 165 | , m_streamAvailable(false) |
| 166 | , m_plotTimeRange(10.0) |
| 167 | , m_plotDisplayTimeSec(0) |
| 168 | , m_pltXAxis(kDefaultPlotPoints) |
| 169 | , m_multipltXAxis(kDefaultPlotPoints) |
| 170 | { |
| 171 | // clang-format off |
| 172 | connect(&CSV::Player::instance(), &CSV::Player::openChanged, this, [=, this] { resetData(true); }, Qt::QueuedConnection); |
| 173 | connect(&MDF4::Player::instance(), &MDF4::Player::openChanged, this, [=, this] { resetData(true); }, Qt::QueuedConnection); |
| 174 | connect(&IO::ConnectionManager::instance(), &IO::ConnectionManager::connectedChanged, this, [=, this] { |
| 175 | if (!IO::ConnectionManager::instance().isConnected()) |
| 176 | resetData(true); |
| 177 | }, Qt::QueuedConnection); |
| 178 | connect(&AppState::instance(), &AppState::projectFileChanged, this, [=, this] { resetData(); }, Qt::QueuedConnection); |
| 179 | connect(&DataModel::FrameBuilder::instance(), &DataModel::FrameBuilder::jsonFileMapChanged, this, [this] { |
| 180 | m_sourceRawFrames.clear(); |
| 181 | m_datasetReferences.clear(); |
| 182 | m_valuePushes.clear(); |
| 183 | m_plotClocks.clear(); |
| 184 | }, Qt::QueuedConnection); |
| 185 | connect(&AppState::instance(), &AppState::operationModeChanged, this, [=, this] { |
| 186 | const auto mode = AppState::instance().operationMode(); |
| 187 | if (mode == SerialStudio::ProjectFile) { |
| 188 | const int project_pts = DataModel::ProjectModel::instance().pointCount(); |
| 189 | if (project_pts > 0 && m_points != project_pts) { |
| 190 | m_points = project_pts; |
| 191 | Q_EMIT pointsChanged(); |
| 192 | } |
| 193 | |
| 194 | const double project_range = DataModel::ProjectModel::instance().plotTimeRange(); |
| 195 | if (project_range > 0 && !qFuzzyCompare(m_plotTimeRange, project_range)) { |
| 196 | m_plotTimeRange = project_range; |
| 197 | Q_EMIT plotTimeRangeChanged(); |
| 198 | } |
| 199 | } else { |
| 200 | if (m_points != kDefaultPlotPoints) { |
| 201 | m_points = kDefaultPlotPoints; |
| 202 | Q_EMIT pointsChanged(); |
| 203 | } |
| 204 | |
| 205 | const double saved |
| 206 | = qMax(0.001, SerialStudio::toDouble(m_settings.value("Dashboard/PlotTimeRange", 10.0))); |
| 207 | if (!qFuzzyCompare(m_plotTimeRange, saved)) { |
nothing calls this directly
no test coverage detected