From f145c2a41a312d51b995393f404d7100b4437c97 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Thu, 8 Jun 2023 00:32:02 +0200 Subject: [PATCH] Fix notification images --- src/dbus/NhekoDBusApi.cpp | 21 +++++++++------------ src/notifications/Manager.h | 7 ------- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/src/dbus/NhekoDBusApi.cpp b/src/dbus/NhekoDBusApi.cpp index a613b610..6b481941 100644 --- a/src/dbus/NhekoDBusApi.cpp +++ b/src/dbus/NhekoDBusApi.cpp @@ -190,20 +190,17 @@ operator<<(QDBusArgument &arg, const QImage &image) return arg; } - QImage i = image.height() > 100 || image.width() > 100 - ? image.scaledToHeight(100, Qt::SmoothTransformation) - : image; - i = std::move(i).convertToFormat(QImage::Format_RGBA8888); + QImage i = image.height() > 100 || image.width() > 100 + ? image.scaledToHeight(100, Qt::SmoothTransformation) + : image; + bool hasAlpha = i.hasAlphaChannel(); + i = std::move(i).convertToFormat(hasAlpha ? QImage::Format_RGBA8888 : QImage::Format_RGB888); + int channels = hasAlpha ? 4 : 3; + QByteArray arr(reinterpret_cast(i.bits()), static_cast(i.sizeInBytes())); arg.beginStructure(); - arg << i.width(); - arg << i.height(); - arg << i.bytesPerLine(); - arg << i.hasAlphaChannel(); - int channels = i.hasAlphaChannel() ? 4 : 3; - arg << i.depth() / channels; - arg << channels; - arg << QByteArray(reinterpret_cast(i.bits()), static_cast(i.sizeInBytes())); + arg << i.width() << i.height() << (int)i.bytesPerLine() << i.hasAlphaChannel() + << i.depth() / channels << channels << arr; arg.endStructure(); return arg; diff --git a/src/notifications/Manager.h b/src/notifications/Manager.h index bc37dbd8..7686d78e 100644 --- a/src/notifications/Manager.h +++ b/src/notifications/Manager.h @@ -111,10 +111,3 @@ private: // Only populated on Linux atm QMap notificationIds; }; - -#if defined(NHEKO_DBUS_SYS) -QDBusArgument & -operator<<(QDBusArgument &arg, const QImage &image); -const QDBusArgument & -operator>>(const QDBusArgument &arg, QImage &); -#endif