Migration of CEC-config and have default actions

This commit is contained in:
LordGrey 2023-11-15 23:20:53 +01:00
parent 1e0852c785
commit e319db7de0
2 changed files with 53 additions and 1 deletions

View File

@ -21,7 +21,21 @@
"enableAttempts": 6,
"enableAttemptsInterval": 15
},
"cecEvents": {
"actions": [
{
"action": "Suspend",
"cec_event": "standby"
},
{
"action": "Resume",
"cec_event": "set stream path"
}
],
"enable": false
},
"color": {
"imageToLedMappingType": "multicolor_mean",
"channelAdjustment": [

View File

@ -894,6 +894,44 @@ bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
Debug(_log, "LED-Device records migrated");
}
}
if (config.contains("cecEvents"))
{
bool isCECEnabled {false};
if (config.contains("grabberV4L2"))
{
QJsonObject newGrabberV4L2Config = config["grabberV4L2"].toObject();
if (newGrabberV4L2Config.contains("cecDetection"))
{
isCECEnabled = newGrabberV4L2Config.value("cecDetection").toBool(false);
newGrabberV4L2Config.remove("cecDetection");
config["grabberV4L2"] = newGrabberV4L2Config;
QJsonObject newGCecEventsConfig = config["cecEvents"].toObject();
newGCecEventsConfig["enable"] = isCECEnabled;
if (!newGCecEventsConfig.contains("actions"))
{
QJsonObject action1
{
{"action", "Suspend"},
{"cec_event", "standby"}
};
QJsonObject action2
{
{"action", "Resume"},
{"cec_event", "set stream path"}
};
QJsonArray actions { action1, action2 };
newGCecEventsConfig.insert("actions",actions);
}
config["cecEvents"] = newGCecEventsConfig;
migrated = true;
Debug(_log, "CEC configuration records migrated");
}
}
}
}
}
}