mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 12:38:48 +03:00
Simplify macOS checks for a null image
This commit is contained in:
parent
5da6ab0aec
commit
716c598f4a
2 changed files with 15 additions and 2 deletions
|
@ -80,6 +80,8 @@ private:
|
||||||
const QString &subtitle,
|
const QString &subtitle,
|
||||||
const QString &informativeText,
|
const QString &informativeText,
|
||||||
const QImage *bodyImage);
|
const QImage *bodyImage);
|
||||||
|
|
||||||
|
QImage *getImgOrNullptr(const QString &path);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Q_OS_WINDOWS)
|
#if defined(Q_OS_WINDOWS)
|
||||||
|
|
|
@ -41,7 +41,7 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
||||||
|
|
||||||
QImage *image = nullptr;
|
QImage *image = nullptr;
|
||||||
if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image)
|
if (mtx::accessors::msg_type(notification.event) == mtx::events::MessageType::Image)
|
||||||
image = new QImage{cacheImage(notification.event)};
|
image = getImgOrNullptr(cacheImage(notification.event));
|
||||||
|
|
||||||
const auto isEncrypted =
|
const auto isEncrypted =
|
||||||
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
|
||||||
|
@ -58,6 +58,17 @@ NotificationsManager::postNotification(const mtx::responses::Notification ¬if
|
||||||
const QString messageInfo =
|
const QString messageInfo =
|
||||||
(isReply ? tr("%1 replied to a message") : tr("%1 sent a message")).arg(sender);
|
(isReply ? tr("%1 replied to a message") : tr("%1 sent a message")).arg(sender);
|
||||||
objCxxPostNotification(
|
objCxxPostNotification(
|
||||||
room_name, messageInfo, formatNotification(notification), (image != nullptr && !image->isNull()) ? image : nullptr);
|
room_name, messageInfo, formatNotification(notification), image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QImage *
|
||||||
|
NotificationsManager::getImgOrNullptr(const QString &path)
|
||||||
|
{
|
||||||
|
auto img = new QImage{path};
|
||||||
|
if (img->isNull()) {
|
||||||
|
delete img;
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
return img;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue