mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
Simplify image loading
This commit is contained in:
parent
95a26edad2
commit
41737ac22c
3 changed files with 6 additions and 16 deletions
|
@ -79,9 +79,7 @@ private:
|
|||
void objCxxPostNotification(const QString &title,
|
||||
const QString &subtitle,
|
||||
const QString &informativeText,
|
||||
const QImage *bodyImage);
|
||||
|
||||
QImage *getImgOrNullptr(const QString &path);
|
||||
const QImage &bodyImage);
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WINDOWS)
|
||||
|
|
|
@ -39,9 +39,9 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
|||
cache::displayName(QString::fromStdString(notification.room_id),
|
||||
QString::fromStdString(mtx::accessors::sender(notification.event)));
|
||||
|
||||
QImage *image = nullptr;
|
||||
QImage image;
|
||||
if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image)
|
||||
image = getImgOrNullptr(cacheImage(notification.event));
|
||||
image = QImage{cacheImage(notification.event)};
|
||||
|
||||
const auto isEncrypted =
|
||||
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||
|
@ -61,11 +61,3 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
|||
room_name, messageInfo, formatNotification(notification), image);
|
||||
}
|
||||
}
|
||||
|
||||
QImage *
|
||||
NotificationsManager::getImgOrNullptr(const QString &path)
|
||||
{
|
||||
if (QFile::exists(path))
|
||||
return nullptr;
|
||||
return new QImage{path};
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ void
|
|||
NotificationsManager::objCxxPostNotification(const QString &title,
|
||||
const QString &subtitle,
|
||||
const QString &informativeText,
|
||||
const QImage *bodyImage)
|
||||
const QImage &bodyImage)
|
||||
{
|
||||
|
||||
NSUserNotification *notif = [[NSUserNotification alloc] init];
|
||||
|
@ -29,8 +29,8 @@ NotificationsManager::objCxxPostNotification(const QString &title,
|
|||
notif.informativeText = informativeText.toNSString();
|
||||
notif.soundName = NSUserNotificationDefaultSoundName;
|
||||
|
||||
if (bodyImage != nullptr)
|
||||
notif.contentImage = [[NSImage alloc] initWithCGImage: bodyImage->toCGImage() size: NSZeroSize];
|
||||
if (!bodyImage.isNull())
|
||||
notif.contentImage = [[NSImage alloc] initWithCGImage: bodyImage.toCGImage() size: NSZeroSize];
|
||||
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notif];
|
||||
[notif autorelease];
|
||||
|
|
Loading…
Reference in a new issue