kodi: use nymea icon for notifications and make it configurable in the settings
parent
1f411c2244
commit
4f6b6938f7
|
|
@ -42,19 +42,7 @@
|
|||
|
||||
IntegrationPluginKodi::IntegrationPluginKodi()
|
||||
{
|
||||
// Q_INIT_RESOURCE(images);
|
||||
// QFile file(":/images/nymea-logo.png");
|
||||
// if (!file.open(QIODevice::ReadOnly)) {
|
||||
// qCWarning(dcKodi) << "could not open" << file.fileName();
|
||||
// return;
|
||||
// }
|
||||
|
||||
// QByteArray nymeaLogoByteArray = file.readAll();
|
||||
// if (nymeaLogoByteArray.isEmpty()) {
|
||||
// qCWarning(dcKodi) << "could not read" << file.fileName();
|
||||
// return;
|
||||
// }
|
||||
// m_logo = nymeaLogoByteArray;
|
||||
}
|
||||
|
||||
IntegrationPluginKodi::~IntegrationPluginKodi()
|
||||
|
|
@ -295,11 +283,19 @@ void IntegrationPluginKodi::executeAction(ThingActionInfo *info)
|
|||
|
||||
int commandId = -1;
|
||||
if (action.actionTypeId() == kodiNotifyActionTypeId) {
|
||||
QUrl notificationUrl = thing->setting(kodiSettingsNotificationCustomIconUrlParamTypeId).toUrl();
|
||||
QString imageString;
|
||||
if (thing->setting(kodiSettingsNotificationUseCustomIconParamTypeId).toBool()) {
|
||||
imageString = notificationUrl.toString();
|
||||
} else {
|
||||
imageString = action.param(kodiNotifyActionTypeParamTypeId).value().toString();
|
||||
}
|
||||
|
||||
commandId = kodi->showNotification(
|
||||
action.param(kodiNotifyActionTitleParamTypeId).value().toString(),
|
||||
action.param(kodiNotifyActionBodyParamTypeId).value().toString(),
|
||||
8000,
|
||||
action.param(kodiNotifyActionTypeParamTypeId).value().toString());
|
||||
thing->setting(kodiSettingsNotificationDurationParamTypeId).toUInt(),
|
||||
imageString);
|
||||
} else if (action.actionTypeId() == kodiVolumeActionTypeId) {
|
||||
commandId = kodi->setVolume(action.param(kodiVolumeActionVolumeParamTypeId).value().toInt());
|
||||
} else if (action.actionTypeId() == kodiMuteActionTypeId) {
|
||||
|
|
@ -425,8 +421,15 @@ void IntegrationPluginKodi::onConnectionChanged(bool connected)
|
|||
}
|
||||
}
|
||||
|
||||
kodi->showNotification("nymea", tr("Connected"), 2000, "info");
|
||||
QUrl notificationUrl = thing->setting(kodiSettingsNotificationCustomIconUrlParamTypeId).toUrl();
|
||||
QString imageString;
|
||||
if (thing->setting(kodiSettingsNotificationUseCustomIconParamTypeId).toBool()) {
|
||||
imageString = notificationUrl.toString();
|
||||
} else {
|
||||
imageString = "info";
|
||||
}
|
||||
|
||||
kodi->showNotification("nymea", tr("Connected"), 2000, imageString);
|
||||
thing->setStateValue(kodiConnectedStateTypeId, kodi->connected());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,31 @@
|
|||
"type": "QString"
|
||||
}
|
||||
],
|
||||
"settingsTypes": [
|
||||
{
|
||||
"id": "4a2e939a-dc9c-4885-8fd5-4b102f91483f",
|
||||
"name": "notificationCustomIconUrl",
|
||||
"displayName": "Notification icon URL",
|
||||
"type": "QString",
|
||||
"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",
|
||||
"name": "notificationDuration",
|
||||
"displayName": "Notification display times",
|
||||
"type": "uint",
|
||||
"minValue": 1500,
|
||||
"unit": "MilliSeconds",
|
||||
"defaultValue": 8000
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "09dfbd40-c97c-4a20-9ecd-f80e389a4864",
|
||||
|
|
|
|||
|
|
@ -238,13 +238,13 @@ int Kodi::setRepeat(const QString &repeat)
|
|||
return m_jsonHandler->sendData("Player.SetRepeat", params);
|
||||
}
|
||||
|
||||
int Kodi::showNotification(const QString &title, const QString &message, const int &displayTime, const QString ¬ificationType)
|
||||
int Kodi::showNotification(const QString &title, const QString &message, const int &displayTime, const QString &image)
|
||||
{
|
||||
QVariantMap params;
|
||||
params.insert("title", title);
|
||||
params.insert("message", message);
|
||||
params.insert("displaytime", displayTime);
|
||||
params.insert("image", notificationType);
|
||||
params.insert("image", image);
|
||||
|
||||
return m_jsonHandler->sendData("GUI.ShowNotification", params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public:
|
|||
int setRepeat(const QString &repeat);
|
||||
|
||||
// actions
|
||||
int showNotification(const QString &title, const QString &message, const int &displayTime, const QString ¬ificationType);
|
||||
int showNotification(const QString &title, const QString &message, const int &displayTime, const QString &image);
|
||||
int navigate(const QString &to);
|
||||
int systemCommand(const QString &command);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue