mirror of
https://github.com/status-im/snorenotify.git
synced 2025-02-17 02:46:23 +00:00
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:
|
public:
|
||||||
SnoreBackend(const QString &name, bool canCloseNotification, bool supportsRichtext, bool canUpdateNotifications = false);
|
SnoreBackend(const QString &name, bool canCloseNotification, bool supportsRichtext, bool canUpdateNotifications = false);
|
||||||
virtual ~SnoreBackend();
|
virtual ~SnoreBackend();
|
||||||
virtual bool initialize(SnoreCore *snore);
|
virtual bool initialize(SnoreCore *snore) override;
|
||||||
virtual bool deinitialize();
|
virtual bool deinitialize() override;
|
||||||
|
|
||||||
void requestCloseNotification(Snore::Notification notification, Notification::CloseReasons reason);
|
void requestCloseNotification(Snore::Notification notification, Notification::CloseReasons reason);
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "toasty.h"
|
#include "toasty.h"
|
||||||
|
|
||||||
#include <QtNetwork>
|
#include <QtNetwork>
|
||||||
|
#include <QImage>
|
||||||
|
|
||||||
Q_EXPORT_PLUGIN2(libsnore_secondary_backend_toasty, Toasty)
|
Q_EXPORT_PLUGIN2(libsnore_secondary_backend_toasty, Toasty)
|
||||||
|
|
||||||
@ -11,6 +12,11 @@ Toasty::Toasty():
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Toasty::~Toasty()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void Toasty::slotNotify(Notification notification)
|
void Toasty::slotNotify(Notification notification)
|
||||||
{
|
{
|
||||||
QString id = value("DEVICEID").toString();
|
QString id = value("DEVICEID").toString();
|
||||||
@ -33,7 +39,12 @@ void Toasty::slotNotify(Notification notification)
|
|||||||
mp->append(app);
|
mp->append(app);
|
||||||
|
|
||||||
QHttpPart icon;
|
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::ContentDispositionHeader, QVariant(QString("form-data; name=\"image\"; filename=\"%1\"").arg(sIcon.localUrl())));
|
||||||
icon.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
|
icon.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/png"));
|
||||||
QFile *file = new QFile(sIcon.localUrl());
|
QFile *file = new QFile(sIcon.localUrl());
|
||||||
|
@ -12,11 +12,12 @@ class Toasty : public Snore::SnoreSecondaryBackend
|
|||||||
Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0")
|
Q_PLUGIN_METADATA(IID "org.Snore.SecondaryNotificationBackend/1.0")
|
||||||
public:
|
public:
|
||||||
Toasty();
|
Toasty();
|
||||||
virtual bool initialize(Snore::SnoreCore *snore);
|
~Toasty();
|
||||||
virtual bool deinitialize();
|
virtual bool initialize(Snore::SnoreCore *snore) override;
|
||||||
|
virtual bool deinitialize() override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void slotNotify(Snore::Notification notification);
|
virtual void slotNotify(Snore::Notification notification) override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotRequestFinished();
|
void slotRequestFinished();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user