diff --git a/Linphone/core/notifier/AbstractNotificationBackend.hpp b/Linphone/core/notifier/AbstractNotificationBackend.hpp index 779bcfbf7..f93e7dc03 100644 --- a/Linphone/core/notifier/AbstractNotificationBackend.hpp +++ b/Linphone/core/notifier/AbstractNotificationBackend.hpp @@ -9,9 +9,11 @@ struct ToastButton { QString label; QString argument; - ToastButton(QString title, QString arg) { - label = title; - argument = arg; + QString icon; + ToastButton(QString label, QString arg, QString icon = QString()) { + this->label = label; + this->argument = arg; + this->icon = icon; } }; diff --git a/Linphone/core/notifier/WindowsNotificationBackend.cpp b/Linphone/core/notifier/WindowsNotificationBackend.cpp index 84a9cc693..ad8a968a7 100644 --- a/Linphone/core/notifier/WindowsNotificationBackend.cpp +++ b/Linphone/core/notifier/WindowsNotificationBackend.cpp @@ -6,6 +6,7 @@ #include "core/call/CallGui.hpp" #include "core/chat/ChatGui.hpp" #include "core/event-filter/LockEventFilter.hpp" +#include "tool/Constants.hpp" #include "tool/Utils.hpp" #ifdef Q_OS_WIN @@ -15,6 +16,9 @@ #endif #include +#include +#include +#include using namespace Microsoft::WRL; using namespace ABI::Windows::UI::Notifications; @@ -37,6 +41,29 @@ void NotificationBackend::flushPendingNotifications() { mPendingNotifications.clear(); } +QString getIconAsPng(const QString &imagePath, const QSize &size = QSize(64, 64)) { + // Convertit "image://internal/phone-disconnect.svg" en ":/data/image/phone-disconnect.svg" + QString resourcePath = imagePath; + if (imagePath.startsWith("image://internal/")) + resourcePath = ":/data/image/" + imagePath.mid(QString("image://internal/").length()); + + QSvgRenderer renderer(resourcePath); + if (!renderer.isValid()) return QString(); + + QImage image(size, QImage::Format_ARGB32_Premultiplied); + image.fill(Qt::transparent); + QPainter painter(&image); + renderer.render(&painter); + painter.end(); + + QString outPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/linphone_" + + QFileInfo(resourcePath).baseName() + ".png"; + + if (!QFile::exists(outPath)) image.save(outPath, "PNG"); + + return outPath; +} + void NotificationBackend::sendMessageNotification(QVariantMap data) { IToastNotifier *notifier = nullptr; @@ -131,16 +158,22 @@ void NotificationBackend::sendCallNotification(QVariantMap data) { // Incoming call auto callDescription = tr("incoming_call").toStdWString(); + QList actions; - actions.append(ToastButton(tr("accept_button"), "accept")); - actions.append(ToastButton(tr("decline_button"), "decline")); + QString declineIcon = getIconAsPng(Utils::getAppIcon("endCall").toString()); + QString acceptIcon = getIconAsPng(Utils::getAppIcon("phone").toString()); + actions.append(ToastButton(tr("accept_button"), "accept", acceptIcon)); + actions.append(ToastButton(tr("decline_button"), "decline", declineIcon)); std::wstring wActions; if (!actions.isEmpty()) { wActions += L""; for (const auto &action : actions) { std::wstring wLabel = action.label.toStdWString(); std::wstring wArg = action.argument.toStdWString(); - wActions += L""; + std::wstring wIcon = action.icon.toStdWString(); + qDebug() << "toast icon action" << wIcon; + wActions += + L""; } wActions += L""; } diff --git a/Linphone/tool/Constants.hpp b/Linphone/tool/Constants.hpp index c9f858a4d..a7bd204c2 100644 --- a/Linphone/tool/Constants.hpp +++ b/Linphone/tool/Constants.hpp @@ -129,6 +129,7 @@ public: static constexpr char LinphoneDomain[] = "sip.linphone.org"; // Use for checking if config are a Linphone static constexpr char WindowIconPath[] = ":/data/image/logo.svg"; + static constexpr char AppIconsPath[] = ":/data/image/"; static constexpr char ApplicationMinimalQtVersion[] = "6.10.0"; static constexpr char DefaultConferenceURI[] = "sip:conference-factory@sip.linphone.org"; // Default for a Linphone account diff --git a/Linphone/tool/Utils.cpp b/Linphone/tool/Utils.cpp index 659d6d5d8..e4f4f5b34 100644 --- a/Linphone/tool/Utils.cpp +++ b/Linphone/tool/Utils.cpp @@ -1811,6 +1811,7 @@ QUrl Utils::getAppIcon(const QString &iconName) { QQmlComponent component(App::getInstance()->mEngine, QUrl("qrc:/qt/qml/Linphone/view/Style/AppIcons.qml")); appIconsSingleton = component.create(); } + return QQmlProperty::read(appIconsSingleton, iconName).value(); } diff --git a/Linphone/tool/Utils.hpp b/Linphone/tool/Utils.hpp index f3747dfb2..1af9b2a1a 100644 --- a/Linphone/tool/Utils.hpp +++ b/Linphone/tool/Utils.hpp @@ -23,6 +23,7 @@ #include #include +#include #include #include "Constants.hpp"