diff --git a/CHANGELOG.md b/CHANGELOG.md index be3cfa5e3..e1c849626 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Fixed - Fix using only username in URI handlers. - Chat flickering on load. +- Portait thumbnails. - Color of busy indicator when the chat is loading. - Incoming ephemerals weren't removed without reloading chat rooms. - Update SDK to 5.2.42 diff --git a/linphone-app/src/components/content/ContentModel.cpp b/linphone-app/src/components/content/ContentModel.cpp index ff332826e..995e9ab2c 100644 --- a/linphone-app/src/components/content/ContentModel.cpp +++ b/linphone-app/src/components/content/ContentModel.cpp @@ -184,33 +184,38 @@ void ContentModel::createThumbnail (const bool& force) { QPainter painter(&image); painter.drawImage(0, 0, originalImage); //-------------------- - QImage thumbnail = image.scaled( - Constants::ThumbnailImageFileWidth, Constants::ThumbnailImageFileHeight, - Qt::KeepAspectRatio, Qt::SmoothTransformation - ); - - if (rotation != 0) { - QTransform transform; - if (rotation == 3 || rotation == 4) - transform.rotate(180); - else if (rotation == 5 || rotation == 6) - transform.rotate(90); - else if (rotation == 7 || rotation == 8) - transform.rotate(-90); - thumbnail = thumbnail.transformed(transform); - if (rotation == 2 || rotation == 4 || rotation == 5 || rotation == 7) - thumbnail = thumbnail.mirrored(true, false); - } - QString uuid = QUuid::createUuid().toString(); - id = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2)); - - if (!thumbnail.save(QString::fromStdString(Paths::getThumbnailsDirPath()) + id , "jpg", 100)) { - qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(path); - }else{ - appdata.mData[path] = id; - mAppData.mData[path] = id; - if(mChatMessageModel) - mChatMessageModel->getChatMessage()->setAppdata(appdata.toString().toStdString()); + double factor = image.width() / (double)image.height(); + if(factor < 0.2 || factor > 5){ + qInfo() << QStringLiteral("Cannot create thumbnails because size factor (%1) is too low/much of: `%2`.").arg(factor).arg(path); + }else { + QImage thumbnail = image.scaled( + Constants::ThumbnailImageFileWidth, Constants::ThumbnailImageFileHeight, + Qt::KeepAspectRatio, Qt::SmoothTransformation + ); + + if (rotation != 0) { + QTransform transform; + if (rotation == 3 || rotation == 4) + transform.rotate(180); + else if (rotation == 5 || rotation == 6) + transform.rotate(90); + else if (rotation == 7 || rotation == 8) + transform.rotate(-90); + thumbnail = thumbnail.transformed(transform); + if (rotation == 2 || rotation == 4 || rotation == 5 || rotation == 7) + thumbnail = thumbnail.mirrored(true, false); + } + QString uuid = QUuid::createUuid().toString(); + id = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2)); + + if (!thumbnail.save(QString::fromStdString(Paths::getThumbnailsDirPath()) + id , "jpg", 100)) { + qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(path); + }else{ + appdata.mData[path] = id; + mAppData.mData[path] = id; + if(mChatMessageModel) + mChatMessageModel->getChatMessage()->setAppdata(appdata.toString().toStdString()); + } } } }