MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / syncUiDriverFromSource0

Method syncUiDriverFromSource0

app/src/IO/ConnectionManager.cpp:1125–1154  ·  view source on GitHub ↗

* @brief Applies source[0]'s busType and connectionSettings to the matching UI-config driver; * unsaved projects (empty json path) are skipped so API-configured hardware settings aren't * clobbered. */

Source from the content-addressed store, hash-verified

1123 * clobbered.
1124 */
1125void IO::ConnectionManager::syncUiDriverFromSource0()
1126{
1127 const auto opMode = AppState::instance().operationMode();
1128 const auto& model = DataModel::ProjectModel::instance();
1129 const auto& srcs = model.sources();
1130
1131 if (opMode != SerialStudio::ProjectFile || srcs.size() != 1)
1132 return;
1133
1134 if (model.jsonFilePath().isEmpty())
1135 return;
1136
1137 const auto& src = srcs[0];
1138 const auto newType = static_cast<SerialStudio::BusType>(src.busType);
1139
1140 m_syncingFromProject = true;
1141
1142 if (m_busType != newType) {
1143 m_busType = newType;
1144 m_settings.setValue("IOManager/busType", static_cast<int>(newType));
1145 Q_EMIT busTypeChanged();
1146 }
1147
1148 HAL_Driver* uiDriver = uiDriverForBusType(newType);
1149 if (uiDriver && !src.connectionSettings.isEmpty())
1150 uiDriver->applyConnectionSettings(src.connectionSettings);
1151
1152 m_syncingFromProject = false;
1153 Q_EMIT driverChanged();
1154}
1155
1156/**
1157 * @brief Connects a DeviceManager's output signals to ConnectionManager's routing slots; the hops

Callers

nothing calls this directly

Calls 4

operationModeMethod · 0.80
isEmptyMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected