Verified Commit 1bc3559a authored by Jonah Brüchert's avatar Jonah Brüchert 🌳

Scale photos to a screen adapted size

parent e0f24ab2
Pipeline #16149 passed with stage
in 5 minutes and 18 seconds
......@@ -21,6 +21,7 @@
#include "declarativeaddressee.h"
#include <KContacts/Picture>
#include <QFile>
#include <QGuiApplication>
#include "imppmodel.h"
#include "phonesmodel.h"
......@@ -58,7 +59,11 @@ void Addressee::setPhoto(QImage &data)
// Scale the photo down to make sure contacts are not taking too
// long time to load their photos
QSize size(200, 200);
constexpr int unscaledWidth = 200;
qreal scaleFactor = dynamic_cast<QGuiApplication *>(QCoreApplication::instance())->devicePixelRatio();
auto avatarSize = int(unscaledWidth * scaleFactor);
QSize size(avatarSize, avatarSize);
photo.setData(data.scaled(size, Qt::KeepAspectRatio, Qt::SmoothTransformation));
m_addressee.setPhoto(photo);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment