Skip to content

Commit a22926a

Browse files
fix(linux): notification icon
1 parent c4b0b6e commit a22926a

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/tray_linux.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
#include <QCursor>
1515
#include <QDBusInterface>
1616
#include <QDBusReply>
17+
#include <QFileInfo>
1718
#include <QIcon>
1819
#include <QMenu>
1920
#include <QSystemTrayIcon>
21+
#include <QUrl>
2022
#include <QVariantMap>
2123

2224
namespace {
@@ -164,7 +166,14 @@ extern "C" {
164166
if (!text.isEmpty()) {
165167
const QString title = tray->notification_title != nullptr ? QString::fromUtf8(tray->notification_title) : QString();
166168
const char *icon_path = tray->notification_icon != nullptr ? tray->notification_icon : tray->icon;
167-
const QString icon = icon_path != nullptr ? QString::fromUtf8(icon_path) : QString();
169+
QString icon;
170+
if (icon_path != nullptr) {
171+
icon = QUrl::fromLocalFile(QFileInfo(QString::fromUtf8(icon_path)).absoluteFilePath()).toString();
172+
}
173+
QVariantMap hints;
174+
if (!icon.isEmpty()) {
175+
hints[QStringLiteral("image-path")] = icon;
176+
}
168177
if (tray->notification_cb != nullptr) {
169178
void (*cb)() = tray->notification_cb;
170179
QObject::connect(g_tray_icon, &QSystemTrayIcon::messageClicked, [cb]() {
@@ -185,7 +194,7 @@ extern "C" {
185194
title,
186195
text,
187196
QStringList(),
188-
QVariantMap(),
197+
hints,
189198
5000
190199
);
191200
if (reply.isValid()) {

0 commit comments

Comments
 (0)