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

Method saveWidgetSetting

app/src/DataModel/ProjectModel.cpp:1382–1403  ·  view source on GitHub ↗

* @brief Stages a single widget setting and marks the project dirty. QML callers pass JS * arrays/objects as QJSValue-wrapped variants, which QJsonValue::fromVariant silently * turns into null, so they are unwrapped first. */

Source from the content-addressed store, hash-verified

1380 * turns into null, so they are unwrapped first.
1381 */
1382void DataModel::ProjectModel::saveWidgetSetting(const QString& widgetId,
1383 const QString& key,
1384 const QVariant& value)
1385{
1386 if (AppState::instance().operationMode() != SerialStudio::ProjectFile)
1387 return;
1388
1389 auto normalized = value;
1390 if (normalized.userType() == qMetaTypeId<QJSValue>())
1391 normalized = normalized.value<QJSValue>().toVariant();
1392
1393 auto obj = m_widgetSettings.value(widgetId).toObject();
1394 const auto newValue = QJsonValue::fromVariant(normalized);
1395 if (obj.value(key) == newValue)
1396 return;
1397
1398 obj.insert(key, newValue);
1399 m_widgetSettings.insert(widgetId, obj);
1400
1401 setModified(true);
1402 Q_EMIT widgetSettingsChanged();
1403}
1404
1405/**
1406 * @brief Persists the external dashboard windows and prunes layouts of closed windows.

Callers 2

setWidgetSettingMethod · 0.80
saveLayoutMethod · 0.80

Calls 3

operationModeMethod · 0.80
toVariantMethod · 0.80
valueMethod · 0.45

Tested by

no test coverage detected