scale toasty only if bigger than 128px
This commit is contained in:
parent
ec69ce843e
commit
c31cfa784f
|
@ -36,8 +36,8 @@ class SNORE_EXPORT SnoreBackend : public SnorePlugin
|
|||
public:
|
||||
SnoreBackend(const QString &name, bool canCloseNotification, bool supportsRichtext, bool canUpdateNotifications = false);
|
||||
virtual ~SnoreBackend();
|
||||
virtual bool initialize(SnoreCore *snore);
|
||||
virtual bool deinitialize();
|
||||
virtual bool initialize(SnoreCore *snore) override;
|
||||
virtual bool deinitialize() override;
|
||||
|
||||
void requestCloseNotification(Snore::Notification notification, Notification::CloseReasons reason);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "toasty.h"
|
||||
|
||||
#include <QtNetwork>
|
||||
#include <QImage>
|
||||
|
||||
Q_EXPORT_PLUGIN2(libsnore_secondary_backend_toasty, Toasty)
|
||||
|
||||
|
@ -11,6 +12,11 @@ Toasty::Toasty():
|
|||
{
|
||||
}
|
||||
|
||||
Toasty::~Toasty()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Toasty::slotNotify(Notification notification)
|
||||
{
|
||||
QString id = value("DEVICEID").toString();
|
||||
|
@ -33,7 +39,12 @@ void Toasty::slotNotify(Notification notification)
|
|||
mp->append(app);
|
||||
|
||||
QHttpPart icon;
|
||||
Icon sIcon(notification.icon().scaled(QSize(127, 127)));
|
||||
|
||||
Icon sIcon = notification.icon();
|
||||
QSize iconSize = notification.icon().image().size();
|
||||
if (iconSize.height() > 128 || iconSize.width() > 128 ) {
|
||||
sIcon = sIcon.scaled(QSize(128, 128));
|
||||
}
|
||||
icon.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QString("form-data; name=\"image\"; filename=\"%1\"").arg(sIcon.localUrl())));
|
||||
icon.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
|
||||
QFile *file = new QFile(sIcon.localUrl());
|
||||
|
|
|
@ -12,11 +12,12 @@ class Toasty : public Snore::SnoreSecondaryBackend
|
|||
Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0")
|
||||
public:
|
||||
Toasty();
|
||||
virtual bool initialize(Snore::SnoreCore *snore);
|
||||
virtual bool deinitialize();
|
||||
~Toasty();
|
||||
virtual bool initialize(Snore::SnoreCore *snore) override;
|
||||
virtual bool deinitialize() override;
|
||||
|
||||
public slots:
|
||||
virtual void slotNotify(Snore::Notification notification);
|
||||
virtual void slotNotify(Snore::Notification notification) override;
|
||||
|
||||
private slots:
|
||||
void slotRequestFinished();
|
||||
|
|
Loading…
Reference in New Issue