mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-17 20:08:28 +00:00
add action button icons
This commit is contained in:
parent
ce13224302
commit
724eb72b94
5 changed files with 44 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <QDebug>
|
||||
#include <QPainter>
|
||||
#include <QStandardPaths>
|
||||
#include <QSvgRenderer>
|
||||
|
||||
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<ToastButton> 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"<actions>";
|
||||
for (const auto &action : actions) {
|
||||
std::wstring wLabel = action.label.toStdWString();
|
||||
std::wstring wArg = action.argument.toStdWString();
|
||||
wActions += L"<action content=\"" + wLabel + L"\" arguments=\"" + wArg + L"\"/>";
|
||||
std::wstring wIcon = action.icon.toStdWString();
|
||||
qDebug() << "toast icon action" << wIcon;
|
||||
wActions +=
|
||||
L"<action content=\"" + wLabel + L"\" arguments=\"" + wArg + L"\" imageUri=\"" + wIcon + L"\"/>";
|
||||
}
|
||||
wActions += L"</actions>";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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<QUrl>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <QDebug>
|
||||
#include <QObject>
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
|
||||
#include "Constants.hpp"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue