Commit cfec2c95 authored by Alexandre Lision's avatar Alexandre Lision Committed by gerrit2

contacts: fix photo rendering

There were two issues here:

- photos were not stored inline in vcards (I saw it though but it is no longer
the case). We need to access the field imageData to retrieve it.

- defaultUserPhoto was not displaying properly the fallback image

Refs #75128

Change-Id: Ia3cd297d160e78c850068cc3add91458c27930d9
parent 58cab671
......@@ -38,6 +38,7 @@
#import <QtWidgets/QApplication>
#import <QtCore/QStandardPaths>
#import <QTimer>
#import <QPixmap>
#import <QtGlobal>
//Ring
......@@ -202,14 +203,21 @@ void AddressBookBackend::asyncLoad(int startingPoint)
for (int i = startingPoint; i < endPoint; ++i) {
Person* person = new Person(QByteArray::fromNSData(((ABPerson*)[everyone objectAtIndex:i]).vCardRepresentation),
ABPerson* abPerson = ((ABPerson*)[everyone objectAtIndex:i]);
Person* person = new Person(QByteArray::fromNSData(abPerson.vCardRepresentation),
Person::Encoding::vCard,
this);
if(abPerson.imageData)
person->setPhoto(QVariant(QPixmap::fromImage(QImage::fromData(QByteArray::fromNSData((abPerson.imageData))))));
if([person->formattedName().toNSString() isEqualToString:@""] &&
[person->secondName().toNSString() isEqualToString:@""] &&
[person->firstName().toNSString() isEqualToString:@""]) {
continue;
}
person->setCollection(this);
editor<Person>()->addExisting(person);
......
......@@ -137,9 +137,10 @@ QPixmap ImageManipulationDelegate::drawDefaultUserPixmap(const QSize& size, bool
CGImageRef ImageManipulationDelegate::resizeCGImage(CGImageRef image, const QSize& size) {
// create context, keeping original image properties
CGColorSpaceRef colorspace = CGImageGetColorSpace(image);
CGContextRef context = CGBitmapContextCreate(NULL, size.width(), size.height(),
CGImageGetBitsPerComponent(image),
CGImageGetBytesPerRow(image),
size.width() * CGImageGetBitsPerComponent(image),
colorspace,
CGImageGetAlphaInfo(image));
CGColorSpaceRelease(colorspace);
......
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