Use GBytesIcon with GNotification

GFileIcon is not supported by xdg-desktop-portal
This commit is contained in:
Ilya Fedin 2022-11-26 05:55:49 +04:00 committed by John Preston
parent d6ed23b3dd
commit ace363f432

View file

@ -691,7 +691,25 @@ void NotificationData::setImage(const QString &imagePath) {
}
if (_notification) {
_notification->set_icon(Gio::Icon::create(imagePath.toStdString()));
const auto imageData = [&] {
QFile f(imagePath);
if (f.open(QIODevice::ReadOnly)) {
return f.readAll();
}
return QByteArray();
}();
if (imageData.isEmpty()) {
return;
}
const auto imageBytes = Glib::Bytes::create(
imageData.constData(),
imageData.size());
_notification->set_icon(
Glib::wrap(g_bytes_icon_new(imageBytes->gobj())));
return;
}