kdeui: save and load notification pixmaps in the default QImageWriter format

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2022-09-20 15:14:01 +03:00
parent aaa643765c
commit 73557bd107

View file

@ -17,6 +17,7 @@
*/ */
#include <QWidget> #include <QWidget>
#include <QImageWriter>
#include <QBuffer> #include <QBuffer>
#include "knotificationmanager_p.h" #include "knotificationmanager_p.h"
@ -32,6 +33,8 @@
typedef QHash<QString,QString> Dict; typedef QHash<QString,QString> Dict;
static const QByteArray imageFormat = QImageWriter::defaultImageFormat();
struct KNotificationManager::Private struct KNotificationManager::Private
{ {
QHash<int , KNotification*> notifications; QHash<int , KNotification*> notifications;
@ -112,7 +115,7 @@ bool KNotificationManager::notify( KNotification* n, const QPixmap &pix,
QByteArray pixmapData; QByteArray pixmapData;
QBuffer buffer(&pixmapData); QBuffer buffer(&pixmapData);
buffer.open(QIODevice::WriteOnly); buffer.open(QIODevice::WriteOnly);
pix.save(&buffer, "PNG"); pix.save(&buffer, imageFormat);
QVariantList contextList; QVariantList contextList;
typedef QPair<QString,QString> Context; typedef QPair<QString,QString> Context;
@ -147,7 +150,7 @@ void KNotificationManager::update(KNotification * n, int id)
if(!n->pixmap().isNull()) { if(!n->pixmap().isNull()) {
QBuffer buffer(&pixmapData); QBuffer buffer(&pixmapData);
buffer.open(QIODevice::WriteOnly); buffer.open(QIODevice::WriteOnly);
n->pixmap().save(&buffer, "PNG"); n->pixmap().save(&buffer, imageFormat);
} }
d->knotify->update(id, n->title(), n->text(), pixmapData , n->actions() ); d->knotify->update(id, n->title(), n->text(), pixmapData , n->actions() );