Add and default to icon type in notifiations

master
Simon Stürz 2022-06-03 08:29:09 +02:00
parent f233b312fc
commit f9ba57eb6d
2 changed files with 14 additions and 13 deletions

View File

@ -283,12 +283,19 @@ void IntegrationPluginKodi::executeAction(ThingActionInfo *info)
int commandId = -1; int commandId = -1;
if (action.actionTypeId() == kodiNotifyActionTypeId) { if (action.actionTypeId() == kodiNotifyActionTypeId) {
QString notificationType = action.param(kodiNotifyActionTypeParamTypeId).value().toString();
QUrl notificationUrl = thing->setting(kodiSettingsNotificationCustomIconUrlParamTypeId).toUrl(); QUrl notificationUrl = thing->setting(kodiSettingsNotificationCustomIconUrlParamTypeId).toUrl();
QString imageString; QString imageString;
if (thing->setting(kodiSettingsNotificationUseCustomIconParamTypeId).toBool()) { if (notificationType == "icon") {
if (!notificationUrl.isEmpty() && notificationUrl.isValid()) {
imageString = notificationUrl.toString(); imageString = notificationUrl.toString();
} else { } else {
imageString = action.param(kodiNotifyActionTypeParamTypeId).value().toString(); // No valid icon url configured. Let's fallback to info
imageString = "info";
}
} else {
// info, warning, error
imageString = notificationType;
} }
commandId = kodi->showNotification( commandId = kodi->showNotification(
@ -421,9 +428,9 @@ void IntegrationPluginKodi::onConnectionChanged(bool connected)
} }
} }
QUrl notificationUrl = thing->setting(kodiSettingsNotificationCustomIconUrlParamTypeId).toUrl();
QString imageString; QString imageString;
if (thing->setting(kodiSettingsNotificationUseCustomIconParamTypeId).toBool()) { QUrl notificationUrl = thing->setting(kodiSettingsNotificationCustomIconUrlParamTypeId).toUrl();
if (!notificationUrl.isEmpty() && notificationUrl.isValid()) {
imageString = notificationUrl.toString(); imageString = notificationUrl.toString();
} else { } else {
imageString = "info"; imageString = "info";

View File

@ -52,13 +52,6 @@
"type": "QString", "type": "QString",
"defaultValue": "https://downloads.nymea.io/nymea-icons/kodi-notification/nymea-logo.png" "defaultValue": "https://downloads.nymea.io/nymea-icons/kodi-notification/nymea-logo.png"
}, },
{
"id": "2c534f37-e1c2-4762-8e38-1718306739f1",
"name": "notificationUseCustomIcon",
"displayName": "Use notification icon",
"type": "bool",
"defaultValue": true
},
{ {
"id": "55133408-794a-4c32-a7f1-f59e83e6eae7", "id": "55133408-794a-4c32-a7f1-f59e83e6eae7",
"name": "notificationDuration", "name": "notificationDuration",
@ -263,8 +256,9 @@
"name": "type", "name": "type",
"displayName": "type", "displayName": "type",
"type": "QString", "type": "QString",
"defaultValue": "info", "defaultValue": "icon",
"allowedValues": [ "allowedValues": [
"icon",
"info", "info",
"warning", "warning",
"error" "error"