Simplify image loading

This commit is contained in:
Loren Burkholder 2021-03-02 20:35:03 -05:00 committed by Nicolas Werner
parent 95a26edad2
commit 41737ac22c
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9
3 changed files with 6 additions and 16 deletions

View file

@ -39,9 +39,9 @@ NotificationsManager::postNotification(const mtx::responses::Notification &notif
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 &notif
room_name, messageInfo, formatNotification(notification), image);
}
}
QImage *
NotificationsManager::getImgOrNullptr(const QString &path)
{
if (QFile::exists(path))
return nullptr;
return new QImage{path};
}