Commit 849514f5 authored by Alexandre Lision's avatar Alexandre Lision Committed by gerrit2

profile: add default avatar when linking account

When linking an existing account to a new OSX client the profile vcard
was not populated with a photo, causing UI issues

Change-Id: I69057abbd44ed1f617bf847a2e2bbdc0ed716e72
Tuleap: #1144
parent 6200531f
......@@ -38,6 +38,7 @@
#import <person.h>
#import "Constants.h"
#import "views/NSImage+Extensions.h"
@interface RingWizardLinkAccountVC ()
......@@ -87,6 +88,10 @@
[self showLoading];
if (auto profile = ProfileModel::instance().selectedProfile()) {
profile->person()->setFormattedName([NSFullUserName() UTF8String]);
auto defaultAvatar = [NSImage imageResize:[NSImage imageNamed:@"default_user_icon"] newSize:{100,100}];
QPixmap pixMap;
pixMap.loadFromData(QByteArray::fromNSData([defaultAvatar TIFFRepresentation]));
profile->person()->setPhoto(QVariant(pixMap));
profile->save();
}
accountToCreate = AccountModel::instance().add(QString::fromNSString(NSFullUserName()), Account::Protocol::RING);
......
......@@ -131,6 +131,10 @@ NSInteger const NICKNAME_TAG = 1;
auto smallImg = [NSImage imageResize:[photoView image] newSize:{100,100}];
if (p.loadFromData(QByteArray::fromNSData([smallImg TIFFRepresentation]))) {
profile->person()->setPhoto(QVariant(p));
} else {
auto defaultAvatar = [NSImage imageResize:[NSImage imageNamed:@"default_user_icon"] newSize:{100,100}];
p.loadFromData(QByteArray::fromNSData([defaultAvatar TIFFRepresentation]));
profile->person()->setPhoto(QVariant(p));
}
profile->save();
}
......
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