Commit 87ae2bf1 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk

profile: photo selection

When creating a new Ring account MAC profile photo has been used
by default. This patch remove default profile photo.

Change-Id: I3ced48d7ab1ffa6b3dd940907c44ee2b96e0a40f
Reviewed-by: Andreas Traczyk's avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent f37b98fb
......@@ -318,7 +318,8 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_delete.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/qrcode.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_video.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/pending_contact_request.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_file_upload.png)
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_file_upload.png
${CMAKE_CURRENT_SOURCE_DIR}/data/light/ic_picture.png)
SET_SOURCE_FILES_PROPERTIES(${ring_ICONS} PROPERTIES
MACOSX_PACKAGE_LOCATION Resources)
......
ic_add.png

946 Bytes

ic_picture.png

404 Bytes

icons_add.png

322 Bytes

......@@ -52,6 +52,7 @@
__unsafe_unretained IBOutlet NSButton* historySwitch;
__unsafe_unretained IBOutlet NSButton* photoView;
__unsafe_unretained IBOutlet NSTextField* profileNameField;
__unsafe_unretained IBOutlet NSImageView* addProfilePhotoImage;
}
@end
......@@ -86,13 +87,19 @@
[photoView setWantsLayer: YES];
photoView.layer.cornerRadius = photoView.frame.size.width / 2;
photoView.layer.masksToBounds = YES;
[addProfilePhotoImage setWantsLayer: YES];
[addProfilePhotoImage setHidden:NO];
[photoView setBordered:YES];
if (auto pro = ProfileModel::instance().selectedProfile()) {
auto photo = GlobalInstances::pixmapManipulator().contactPhoto(pro->person(), {140,140});
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
[profileNameField setStringValue:pro->person()->formattedName().toNSString()];
if (pro->person() && pro->person()->photo().isValid()) {
auto photo = GlobalInstances::pixmapManipulator().contactPhoto(pro->person(), {140,140});
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
[addProfilePhotoImage setHidden:YES];
[photoView setBordered:NO];
}
}
}
- (void) dealloc
......@@ -207,15 +214,19 @@
{
if (auto outputImage = [picker outputImage]) {
[photoView setImage:outputImage];
} else
[photoView setImage:[NSImage imageNamed:@"default_user_icon"]];
if (auto pro = ProfileModel::instance().selectedProfile()) {
QPixmap p;
auto smallImg = [NSImage imageResize:[photoView image] newSize:{100,100}];
if (p.loadFromData(QByteArray::fromNSData([smallImg TIFFRepresentation]))) {
pro->person()->setPhoto(QVariant(p));
[addProfilePhotoImage setHidden:YES];
[photoView setBordered:NO];
if (auto pro = ProfileModel::instance().selectedProfile()) {
QPixmap p;
auto smallImg = [NSImage imageResize:outputImage newSize:{100,100}];
if (p.loadFromData(QByteArray::fromNSData([smallImg TIFFRepresentation]))) {
pro->person()->setPhoto(QVariant(p));
}
pro->save();
}
pro->save();
} else if (!photoView.image){
[addProfilePhotoImage setHidden:NO];
[photoView setBordered:YES];
}
}
......
......@@ -21,7 +21,6 @@
//Cocoa
#import <AddressBook/AddressBook.h>
//LRC
#import <accountmodel.h>
......
......@@ -19,7 +19,6 @@
#import "RingWizardLinkAccountVC.h"
//Cocoa
#import <AddressBook/AddressBook.h>
#import <Quartz/Quartz.h>
//Qt
......@@ -117,10 +116,6 @@
[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);
......
......@@ -21,7 +21,6 @@
//Cocoa
#import <AddressBook/AddressBook.h>
#import <Quartz/Quartz.h>
//Qt
......@@ -59,6 +58,7 @@
__unsafe_unretained IBOutlet NSSecureTextField* passwordRepeatField;
__unsafe_unretained IBOutlet NSImageView* passwordCheck;
__unsafe_unretained IBOutlet NSImageView* passwordRepeatCheck;
__unsafe_unretained IBOutlet NSImageView* addProfilePhotoImage;
__unsafe_unretained IBOutlet NSProgressIndicator* progressBar;
......@@ -112,18 +112,13 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
[registeredNameField setTag:BLOCKCHAIN_NAME_TAG];
[displayNameField setStringValue: NSFullUserName()];
[self controlTextDidChange:[NSNotification notificationWithName:@"PlaceHolder" object:displayNameField]];
NSData* imgData = [[[ABAddressBook sharedAddressBook] me] imageData];
if (imgData != nil) {
[photoView setImage:[[NSImage alloc] initWithData:imgData]];
} else
[photoView setImage:[NSImage imageNamed:@"default_user_icon"]];
[photoView setWantsLayer: YES];
photoView.layer.cornerRadius = photoView.frame.size.width / 2;
photoView.layer.masksToBounds = YES;
self.signUpBlockchainState = YES;
[self toggleSignupRing:nil];
[addProfilePhotoImage setWantsLayer: YES];
[photoView setBordered:YES];
[self display:creationView];
}
......@@ -156,9 +151,12 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
contextInfo:(void*) contextInfo
{
if (auto outputImage = [picker outputImage]) {
[photoView setBordered:NO];
[photoView setImage:outputImage];
} else {
[photoView setImage:[NSImage imageNamed:@"default_user_icon"]];
[addProfilePhotoImage setHidden:YES];
} else if(!photoView.image) {
[photoView setBordered:YES];
[addProfilePhotoImage setHidden:NO];
}
}
......@@ -238,12 +236,9 @@ NSInteger const ERROR_REPEAT_MISMATCH = -2;
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();
}
QModelIndex qIdx = AccountModel::instance().protocolModel()->selectionModel()->currentIndex();
......
......@@ -19,7 +19,6 @@
#import "RingWizardWC.h"
//Cocoa
#import <AddressBook/AddressBook.h>
#import <Quartz/Quartz.h>
......
This diff is collapsed.
This diff is collapsed.
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