| 1284 | } |
| 1285 | |
| 1286 | void MacroActionVariableEdit::UpdateSegmentVariableValue() |
| 1287 | { |
| 1288 | if (!_entryData || |
| 1289 | !(_entryData->_action == |
| 1290 | MacroActionVariable::Action::SET_CONDITION_VALUE || |
| 1291 | _entryData->_action == |
| 1292 | MacroActionVariable::Action::SET_ACTION_VALUE)) { |
| 1293 | return; |
| 1294 | } |
| 1295 | |
| 1296 | auto m = _entryData->GetMacro(); |
| 1297 | if (!m) { |
| 1298 | return; |
| 1299 | } |
| 1300 | |
| 1301 | int index = _entryData->GetSegmentIndexValue(); |
| 1302 | if (index < 0) { |
| 1303 | SetSegmentValueError(obs_module_text( |
| 1304 | "AdvSceneSwitcher.action.variable.invalidSelection")); |
| 1305 | const QSignalBlocker b(_segmentIdx); |
| 1306 | _segmentIdx->SetValue(0); |
| 1307 | return; |
| 1308 | } |
| 1309 | |
| 1310 | std::shared_ptr<MacroSegment> segment; |
| 1311 | if (_entryData->_action == |
| 1312 | MacroActionVariable::Action::SET_ACTION_VALUE) { |
| 1313 | const auto &actions = m->Actions(); |
| 1314 | if (index < (int)actions.size()) { |
| 1315 | segment = actions.at(index); |
| 1316 | } |
| 1317 | } else if (_entryData->_action == |
| 1318 | MacroActionVariable::Action::SET_CONDITION_VALUE) { |
| 1319 | const auto &conditions = m->Conditions(); |
| 1320 | if (index < (int)conditions.size()) { |
| 1321 | segment = conditions.at(index); |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | if (!segment) { |
| 1326 | SetSegmentValueError(obs_module_text( |
| 1327 | "AdvSceneSwitcher.action.variable.invalidSelection")); |
| 1328 | return; |
| 1329 | } |
| 1330 | |
| 1331 | if (!SupportsVariableValue(segment.get())) { |
| 1332 | std::string type; |
| 1333 | QString fmt; |
| 1334 | |
| 1335 | if (_entryData->_action == |
| 1336 | MacroActionVariable::Action::SET_ACTION_VALUE) { |
| 1337 | type = MacroActionFactory::GetActionName( |
| 1338 | segment->GetId()); |
| 1339 | fmt = QString(obs_module_text( |
| 1340 | "AdvSceneSwitcher.action.variable.actionNoVariableSupport")); |
| 1341 | } else if (_entryData->_action == |
| 1342 | MacroActionVariable::Action::SET_CONDITION_VALUE) { |
| 1343 | type = MacroConditionFactory::GetConditionName( |
nothing calls this directly
no test coverage detected