Skip to content
Snippets Groups Projects
Commit cfec2c95 authored by Alexandre Lision's avatar Alexandre Lision Committed by gerrit2
Browse files

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
Branches
Tags
No related merge requests found
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#import <QtWidgets/QApplication> #import <QtWidgets/QApplication>
#import <QtCore/QStandardPaths> #import <QtCore/QStandardPaths>
#import <QTimer> #import <QTimer>
#import <QPixmap>
#import <QtGlobal> #import <QtGlobal>
//Ring //Ring
...@@ -202,14 +203,21 @@ void AddressBookBackend::asyncLoad(int startingPoint) ...@@ -202,14 +203,21 @@ void AddressBookBackend::asyncLoad(int startingPoint)
for (int i = startingPoint; i < endPoint; ++i) { 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, Person::Encoding::vCard,
this); this);
if(abPerson.imageData)
person->setPhoto(QVariant(QPixmap::fromImage(QImage::fromData(QByteArray::fromNSData((abPerson.imageData))))));
if([person->formattedName().toNSString() isEqualToString:@""] && if([person->formattedName().toNSString() isEqualToString:@""] &&
[person->secondName().toNSString() isEqualToString:@""] && [person->secondName().toNSString() isEqualToString:@""] &&
[person->firstName().toNSString() isEqualToString:@""]) { [person->firstName().toNSString() isEqualToString:@""]) {
continue; continue;
} }
person->setCollection(this); person->setCollection(this);
editor<Person>()->addExisting(person); editor<Person>()->addExisting(person);
......
...@@ -137,9 +137,10 @@ QPixmap ImageManipulationDelegate::drawDefaultUserPixmap(const QSize& size, bool ...@@ -137,9 +137,10 @@ QPixmap ImageManipulationDelegate::drawDefaultUserPixmap(const QSize& size, bool
CGImageRef ImageManipulationDelegate::resizeCGImage(CGImageRef image, const QSize& size) { CGImageRef ImageManipulationDelegate::resizeCGImage(CGImageRef image, const QSize& size) {
// create context, keeping original image properties // create context, keeping original image properties
CGColorSpaceRef colorspace = CGImageGetColorSpace(image); CGColorSpaceRef colorspace = CGImageGetColorSpace(image);
CGContextRef context = CGBitmapContextCreate(NULL, size.width(), size.height(), CGContextRef context = CGBitmapContextCreate(NULL, size.width(), size.height(),
CGImageGetBitsPerComponent(image), CGImageGetBitsPerComponent(image),
CGImageGetBytesPerRow(image), size.width() * CGImageGetBitsPerComponent(image),
colorspace, colorspace,
CGImageGetAlphaInfo(image)); CGImageGetAlphaInfo(image));
CGColorSpaceRelease(colorspace); CGColorSpaceRelease(colorspace);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment