Fix mimetype of media messages

This commit is contained in:
Nicolas Werner 2020-11-23 18:19:24 +01:00
parent c8fa40a2df
commit c2eea5cb55
2 changed files with 5 additions and 4 deletions

View file

@ -118,7 +118,7 @@ PreviewUploadOverlay::init()
void void
PreviewUploadOverlay::setLabels(const QString &type, const QString &mime, uint64_t upload_size) PreviewUploadOverlay::setLabels(const QString &type, const QString &mime, uint64_t upload_size)
{ {
if (mediaType_ == "image") { if (mediaType_.split('/')[0] == "image") {
if (!image_.loadFromData(data_)) { if (!image_.loadFromData(data_)) {
titleLabel_.setText(QString{tr(ERR_MSG)}.arg(type)); titleLabel_.setText(QString{tr(ERR_MSG)}.arg(type));
} else { } else {
@ -154,7 +154,7 @@ PreviewUploadOverlay::setPreview(const QImage &src, const QString &mime)
else else
titleLabel_.setText(QString{tr(ERR_MSG)}.arg(type)); titleLabel_.setText(QString{tr(ERR_MSG)}.arg(type));
mediaType_ = split[0]; mediaType_ = mime;
filePath_ = "clipboard." + type; filePath_ = "clipboard." + type;
image_.convertFromImage(src); image_.convertFromImage(src);
isImage_ = true; isImage_ = true;
@ -170,7 +170,7 @@ PreviewUploadOverlay::setPreview(const QByteArray data, const QString &mime)
auto const &type = split[1]; auto const &type = split[1];
data_ = data; data_ = data;
mediaType_ = split[0]; mediaType_ = mime;
filePath_ = "clipboard." + type; filePath_ = "clipboard." + type;
isImage_ = false; isImage_ = false;
@ -202,7 +202,7 @@ PreviewUploadOverlay::setPreview(const QString &path)
auto const &split = mime.name().split('/'); auto const &split = mime.name().split('/');
mediaType_ = split[0]; mediaType_ = mime.name();
filePath_ = file.fileName(); filePath_ = file.fileName();
isImage_ = false; isImage_ = false;

View file

@ -511,6 +511,7 @@ InputBar::showPreview(const QMimeData &source, QString path, const QStringList &
QSize dimensions; QSize dimensions;
QString blurhash; QString blurhash;
auto mimeClass = mime.split("/")[0]; auto mimeClass = mime.split("/")[0];
nhlog::ui()->debug("Mime: {}", mime.toStdString());
if (mimeClass == "image") { if (mimeClass == "image") {
QImage img = utils::readImage(&data); QImage img = utils::readImage(&data);