kodi: use nymea icon for notifications and make it configurable in the settings
This commit is contained in:
parent
1f411c2244
commit
4f6b6938f7
@ -42,19 +42,7 @@
|
|||||||
|
|
||||||
IntegrationPluginKodi::IntegrationPluginKodi()
|
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()
|
IntegrationPluginKodi::~IntegrationPluginKodi()
|
||||||
@ -295,11 +283,19 @@ void IntegrationPluginKodi::executeAction(ThingActionInfo *info)
|
|||||||
|
|
||||||
int commandId = -1;
|
int commandId = -1;
|
||||||
if (action.actionTypeId() == kodiNotifyActionTypeId) {
|
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(
|
commandId = kodi->showNotification(
|
||||||
action.param(kodiNotifyActionTitleParamTypeId).value().toString(),
|
action.param(kodiNotifyActionTitleParamTypeId).value().toString(),
|
||||||
action.param(kodiNotifyActionBodyParamTypeId).value().toString(),
|
action.param(kodiNotifyActionBodyParamTypeId).value().toString(),
|
||||||
8000,
|
thing->setting(kodiSettingsNotificationDurationParamTypeId).toUInt(),
|
||||||
action.param(kodiNotifyActionTypeParamTypeId).value().toString());
|
imageString);
|
||||||
} else if (action.actionTypeId() == kodiVolumeActionTypeId) {
|
} else if (action.actionTypeId() == kodiVolumeActionTypeId) {
|
||||||
commandId = kodi->setVolume(action.param(kodiVolumeActionVolumeParamTypeId).value().toInt());
|
commandId = kodi->setVolume(action.param(kodiVolumeActionVolumeParamTypeId).value().toInt());
|
||||||
} else if (action.actionTypeId() == kodiMuteActionTypeId) {
|
} 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());
|
thing->setStateValue(kodiConnectedStateTypeId, kodi->connected());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,6 +44,31 @@
|
|||||||
"type": "QString"
|
"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": [
|
"stateTypes": [
|
||||||
{
|
{
|
||||||
"id": "09dfbd40-c97c-4a20-9ecd-f80e389a4864",
|
"id": "09dfbd40-c97c-4a20-9ecd-f80e389a4864",
|
||||||
|
|||||||
@ -238,13 +238,13 @@ int Kodi::setRepeat(const QString &repeat)
|
|||||||
return m_jsonHandler->sendData("Player.SetRepeat", params);
|
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;
|
QVariantMap params;
|
||||||
params.insert("title", title);
|
params.insert("title", title);
|
||||||
params.insert("message", message);
|
params.insert("message", message);
|
||||||
params.insert("displaytime", displayTime);
|
params.insert("displaytime", displayTime);
|
||||||
params.insert("image", notificationType);
|
params.insert("image", image);
|
||||||
|
|
||||||
return m_jsonHandler->sendData("GUI.ShowNotification", params);
|
return m_jsonHandler->sendData("GUI.ShowNotification", params);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public:
|
|||||||
int setRepeat(const QString &repeat);
|
int setRepeat(const QString &repeat);
|
||||||
|
|
||||||
// actions
|
// 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 navigate(const QString &to);
|
||||||
int systemCommand(const QString &command);
|
int systemCommand(const QString &command);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user