| 1455 | } |
| 1456 | |
| 1457 | QJsonObject MainWindow::buildControlDevicesSnapshot() const |
| 1458 | { |
| 1459 | auto stringArray = [](const QStringList& values) { |
| 1460 | QJsonArray array; |
| 1461 | for (const QString& value : values) |
| 1462 | array.append(value); |
| 1463 | return array; |
| 1464 | }; |
| 1465 | |
| 1466 | auto buttonBindings = [](const QString& prefix, int buttonCount) { |
| 1467 | static const char* kActionNames[] = {"tap", "double_tap", "hold"}; |
| 1468 | QJsonArray bindings; |
| 1469 | auto& settings = AppSettings::instance(); |
| 1470 | for (int button = 1; button <= buttonCount; ++button) { |
| 1471 | for (int action = 0; action < 3; ++action) { |
| 1472 | const QString key = QString("%1Btn%2Action%3").arg(prefix).arg(button).arg(action); |
| 1473 | const QString mappedAction = settings.value(key, "None").toString(); |
| 1474 | if (mappedAction == QStringLiteral("None")) |
| 1475 | continue; |
| 1476 | QJsonObject obj; |
| 1477 | obj["button"] = button; |
| 1478 | obj["gesture"] = kActionNames[action]; |
| 1479 | obj["action"] = mappedAction; |
| 1480 | bindings.append(obj); |
| 1481 | } |
| 1482 | } |
| 1483 | return bindings; |
| 1484 | }; |
| 1485 | |
| 1486 | auto addTarget = [this](QJsonObject* obj) { |
| 1487 | if (m_activeSliceId >= 0) |
| 1488 | (*obj)["target_slice_id"] = m_activeSliceId; |
| 1489 | else |
| 1490 | (*obj)["target_slice_id"] = QJsonValue(); |
| 1491 | (*obj)["target_scope"] = "active_slice"; |
| 1492 | }; |
| 1493 | |
| 1494 | auto flexWheelModeName = [](FlexWheelMode mode) { |
| 1495 | switch (mode) { |
| 1496 | case FlexWheelMode::Frequency: return QStringLiteral("Frequency"); |
| 1497 | case FlexWheelMode::Volume: return QStringLiteral("Volume"); |
| 1498 | case FlexWheelMode::Power: return QStringLiteral("Power"); |
| 1499 | case FlexWheelMode::Rit: return QStringLiteral("Rit"); |
| 1500 | case FlexWheelMode::Xit: return QStringLiteral("Xit"); |
| 1501 | case FlexWheelMode::SliceAudio: |
| 1502 | return QStringLiteral("SliceAudio"); |
| 1503 | case FlexWheelMode::HeadphoneVolume: |
| 1504 | return QStringLiteral("HeadphoneVolume"); |
| 1505 | case FlexWheelMode::AgcT: return QStringLiteral("AgcT"); |
| 1506 | case FlexWheelMode::Apf: return QStringLiteral("Apf"); |
| 1507 | case FlexWheelMode::CwSpeed: return QStringLiteral("CwSpeed"); |
| 1508 | } |
| 1509 | return QStringLiteral("Unknown"); |
| 1510 | }; |
| 1511 | |
| 1512 | const bool activeSliceAvailable = activeSlice() != nullptr; |
| 1513 | QJsonArray devices; |
| 1514 | int activeDeviceCount = 0; |
nothing calls this directly
no test coverage detected