Commit 54187a23 authored by Alexandre Lision's avatar Alexandre Lision

wizard: add photo selection

Allow the user to define a photo that will be sent as a public
profile when making a call.
Remove menu entry 'Setup Ring' showing the wizard in top menu bar

Tuleap: #530
Change-Id: I5fdd82000b72008563eb61fae61a4ee1eb406c65
parent 43e91bc6
......@@ -18,21 +18,33 @@
*/
#import "RingWizardWC.h"
//Cocoa
#import <AddressBook/AddressBook.h>
#import <Quartz/Quartz.h>
//Qt
#import <QUrl>
#import <QPixmap>
//LRC
#import <accountmodel.h>
#import <protocolmodel.h>
#import <profilemodel.h>
#import <QItemSelectionModel>
#import <account.h>
#import <certificate.h>
#import <profilemodel.h>
#import <profile.h>
#import <person.h>
#import "AppDelegate.h"
#import "Constants.h"
#import "views/NSColor+RingTheme.h"
@implementation RingWizardWC {
__unsafe_unretained IBOutlet NSButton* photoView;
__unsafe_unretained IBOutlet NSTextField* nicknameField;
__unsafe_unretained IBOutlet NSProgressIndicator* progressBar;
__unsafe_unretained IBOutlet NSTextField* indicationLabel;
......@@ -66,18 +78,24 @@ NSInteger const NICKNAME_TAG = 1;
if(![appDelegate checkForRingAccount]) {
accountToCreate = AccountModel::instance().add(QString::fromNSString(NSFullUserName()), Account::Protocol::RING);
[nicknameField setStringValue:NSFullUserName()];
[self controlTextDidChange:[NSNotification notificationWithName:@"PlaceHolder" object:nicknameField]];
} else {
[indicationLabel setStringValue:NSLocalizedString(@"Ring is already ready to work",
@"Display message to user")];
auto accList = AccountModel::instance().getAccountsByProtocol(Account::Protocol::RING);
[self displayHash:accList[0]->username().toNSString()];
}
[caListPathControl setDelegate:self];
[certificatePathControl setDelegate:self];
[pvkPathControl setDelegate:self];
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;
}
- (void) displayHash:(NSString* ) hash
......@@ -99,8 +117,27 @@ NSInteger const NICKNAME_TAG = 1;
[createButton setAction:@selector(goToApp:)];
}
- (IBAction) editPhoto:(id)sender
{
auto pictureTaker = [IKPictureTaker pictureTaker];
[pictureTaker beginPictureTakerSheetForWindow:self.window
withDelegate:self
didEndSelector:@selector(pictureTakerDidEnd:returnCode:contextInfo:)
contextInfo:nil];
}
- (void) pictureTakerDidEnd:(IKPictureTaker *) picker
returnCode:(NSInteger) code
contextInfo:(void*) contextInfo
{
if (auto outputImage = [picker outputImage]) {
[photoView setImage:outputImage];
} else
[photoView setImage:[NSImage imageNamed:@"default_user_icon"]];
}
- (IBAction)shareRingID:(id)sender {
NSSharingServicePicker* sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:[NSArray arrayWithObject:[nicknameField stringValue]]];
auto sharingServicePicker = [[NSSharingServicePicker alloc] initWithItems:[NSArray arrayWithObject:[nicknameField stringValue]]];
[sharingServicePicker showRelativeToRect:[sender bounds]
ofView:sender
preferredEdge:NSMinYEdge];
......@@ -111,10 +148,20 @@ NSInteger const NICKNAME_TAG = 1;
[nicknameField setHidden:YES];
[progressBar setHidden:NO];
[createButton setHidden:YES];
[photoView setHidden:YES];
[progressBar startAnimation:nil];
[indicationLabel setStringValue:NSLocalizedString(@"Just a moment...",
@"Indication for user")];
if (auto profile = ProfileModel::instance().selectedProfile()) {
profile->person()->setFormattedName([[nicknameField stringValue] UTF8String]);
QPixmap p;
if (p.loadFromData(QByteArray::fromNSData([[photoView image] TIFFRepresentation]))) {
profile->person()->setPhoto(QVariant(p));
}
profile->save();
}
QModelIndex qIdx = AccountModel::instance().protocolModel()->selectionModel()->currentIndex();
[self setCallback];
......@@ -217,9 +264,7 @@ NSInteger const NICKNAME_TAG = 1;
[self->certificatePathControl setURL:fileURL];
accountToCreate->setTlsCertificate([[fileURL path] UTF8String]);
auto cert = accountToCreate->tlsCertificate();
if (cert) {
if (auto cert = accountToCreate->tlsCertificate()) {
[pvkContainer setHidden:!cert->requirePrivateKey()];
} else {
[pvkContainer setHidden:YES];
......
......@@ -32,8 +32,10 @@
#import <recentmodel.h>
#import <categorizedhistorymodel.h>
#import <localhistorycollection.h>
#import <localprofilecollection.h>
#import <numbercategorymodel.h>
#import <callmodel.h>
#import <profilemodel.h>
#import "backends/AddressBookBackend.h"
#import "delegates/ImageManipulationDelegate.h"
......@@ -73,8 +75,11 @@ int main(int argc, const char *argv[]) {
NumberCategoryModel::instance().addCategory("home", QVariant());
GlobalInstances::setPixmapManipulator(std::unique_ptr<Interfaces::ImageManipulationDelegate>(new Interfaces::ImageManipulationDelegate()));
PersonModel::instance().addCollection<AddressBookBackend>(LoadOptions::FORCE_ENABLED);
RecentModel::instance(); // Make sure RecentModel is initialized before showing UI
ProfileModel::instance().addCollection<LocalProfileCollection>(LoadOptions::FORCE_ENABLED);
return NSApplicationMain(argc, argv);
}
......@@ -10,7 +10,7 @@
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<menu title="AMainMenu" systemMenu="main" id="29">
<items>
<menuItem title="Ring" id="56">
......@@ -22,12 +22,6 @@
<action selector="orderFrontStandardAboutPanel:" target="-2" id="142"/>
</connections>
</menuItem>
<menuItem title="Setup Ring" id="589">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="showWizard:" target="494" id="591"/>
</connections>
</menuItem>
<menuItem title="Check for Update..." id="593">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
......
......@@ -12,6 +12,7 @@
<outlet property="indicationLabel" destination="PZB-UI-B3R" id="t79-DV-rKR"/>
<outlet property="nicknameField" destination="Phj-na-SP1" id="e9d-3N-z9N"/>
<outlet property="passwordField" destination="1nU-BV-LdG" id="1fI-Xa-L9w"/>
<outlet property="photoView" destination="j82-Gu-ek3" id="elk-di-sz5"/>
<outlet property="progressBar" destination="nRx-qJ-VIe" id="qJ2-ra-GkK"/>
<outlet property="pvkContainer" destination="he3-z9-OHD" id="rmf-aA-Lv6"/>
<outlet property="pvkPathControl" destination="Wk1-nk-8ES" id="Sb9-e1-mDQ"/>
......@@ -25,28 +26,22 @@
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" oneShot="NO" showsToolbarButton="NO" animationBehavior="default" id="4LP-GX-BkH">
<windowStyleMask key="styleMask" titled="YES" closable="YES" texturedBackground="YES"/>
<rect key="contentRect" x="599" y="440" width="480" height="182"/>
<rect key="contentRect" x="599" y="440" width="541" height="230"/>
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1050"/>
<view key="contentView" id="Wgr-xH-z0G">
<rect key="frame" x="0.0" y="0.0" width="480" height="182"/>
<rect key="frame" x="0.0" y="0.0" width="541" height="230"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="rAn-Kv-PgL">
<rect key="frame" x="126" y="143" width="229" height="36"/>
<rect key="frame" x="156" y="191" width="229" height="36"/>
<textFieldCell key="cell" controlSize="mini" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Welcome to Ring" id="uqu-uh-Wao">
<font key="font" metaFont="system" size="30"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<progressIndicator hidden="YES" wantsLayer="YES" maxValue="100" indeterminate="YES" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="nRx-qJ-VIe">
<rect key="frame" x="192" y="60" width="96" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="96" id="EN6-qO-gH1"/>
</constraints>
</progressIndicator>
<button hidden="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hKA-b6-heE">
<rect key="frame" x="306" y="17" width="80" height="29"/>
<button hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hKA-b6-heE">
<rect key="frame" x="388" y="17" width="59" height="29"/>
<buttonCell key="cell" type="bevel" title="Share" bezelStyle="regularSquare" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Kwr-LJ-K8C">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
......@@ -56,7 +51,7 @@
</connections>
</button>
<button toolTip="Choose custom certificates" horizontalHuggingPriority="750" verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="aZl-bU-psB">
<rect key="frame" x="342" y="62" width="39" height="38"/>
<rect key="frame" x="372" y="43" width="39" height="38"/>
<buttonCell key="cell" type="round" bezelStyle="circular" image="NSAddTemplate" imagePosition="only" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="b1Z-dE-vrA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
......@@ -66,7 +61,7 @@
</connections>
</button>
<button translatesAutoresizingMaskIntoConstraints="NO" id="rC1-mU-Scu">
<rect key="frame" x="390" y="17" width="72" height="29"/>
<rect key="frame" x="451" y="17" width="72" height="29"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="68" id="3Oi-R8-jmQ"/>
</constraints>
......@@ -82,7 +77,7 @@ DQ
</connections>
</button>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="5sr-Hf-NCo">
<rect key="frame" x="361" y="139" width="45" height="45"/>
<rect key="frame" x="391" y="187" width="45" height="45"/>
<constraints>
<constraint firstAttribute="height" constant="45" id="0pw-aW-wnD"/>
<constraint firstAttribute="width" constant="45" id="YAW-t1-WU2"/>
......@@ -90,7 +85,7 @@ DQ
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="symbol_blue" id="UZZ-KL-7Bo"/>
</imageView>
<textField verticalHuggingPriority="750" ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Phj-na-SP1">
<rect key="frame" x="140" y="73" width="200" height="22"/>
<rect key="frame" x="169" y="52" width="200" height="22"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="200" id="LZg-nv-YRi"/>
</constraints>
......@@ -103,8 +98,8 @@ DQ
<outlet property="delegate" destination="-2" id="K7L-Rf-9i7"/>
</connections>
</textField>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PZB-UI-B3R">
<rect key="frame" x="68" y="105" width="344" height="17"/>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" ambiguous="YES" misplaced="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="PZB-UI-B3R">
<rect key="frame" x="97" y="82" width="344" height="17"/>
<constraints>
<constraint firstAttribute="width" constant="340" id="NMy-6k-0aA"/>
</constraints>
......@@ -114,22 +109,43 @@ DQ
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="j82-Gu-ek3">
<rect key="frame" x="234" y="113" width="70" height="70"/>
<constraints>
<constraint firstAttribute="width" constant="70" id="BLY-d2-DRE"/>
<constraint firstAttribute="height" constant="70" id="Pz4-0U-1rr"/>
</constraints>
<buttonCell key="cell" type="square" bezelStyle="shadowlessSquare" imagePosition="only" alignment="center" focusRingType="none" imageScaling="proportionallyUpOrDown" inset="2" id="6Ec-uO-BLA">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<action selector="editPhoto:" target="-2" id="49O-OV-Gjy"/>
</connections>
</button>
<progressIndicator hidden="YES" wantsLayer="YES" maxValue="100" indeterminate="YES" style="spinning" translatesAutoresizingMaskIntoConstraints="NO" id="nRx-qJ-VIe">
<rect key="frame" x="222" y="107" width="96" height="32"/>
<constraints>
<constraint firstAttribute="width" constant="96" id="EN6-qO-gH1"/>
</constraints>
</progressIndicator>
</subviews>
<constraints>
<constraint firstAttribute="trailing" secondItem="rC1-mU-Scu" secondAttribute="trailing" constant="20" id="02s-v0-sLn"/>
<constraint firstItem="nRx-qJ-VIe" firstAttribute="centerX" secondItem="Wgr-xH-z0G" secondAttribute="centerX" id="A8C-8W-rR8"/>
<constraint firstItem="Phj-na-SP1" firstAttribute="centerX" secondItem="Wgr-xH-z0G" secondAttribute="centerX" id="AGC-ga-ZNS"/>
<constraint firstItem="PZB-UI-B3R" firstAttribute="centerX" secondItem="Wgr-xH-z0G" secondAttribute="centerX" id="LQU-R8-GHo"/>
<constraint firstItem="aZl-bU-psB" firstAttribute="leading" secondItem="Phj-na-SP1" secondAttribute="trailing" constant="8" id="PCb-NY-cPw"/>
<constraint firstItem="Phj-na-SP1" firstAttribute="centerX" secondItem="Wgr-xH-z0G" secondAttribute="centerX" constant="-1.5" id="AGC-ga-ZNS"/>
<constraint firstItem="j82-Gu-ek3" firstAttribute="top" secondItem="rAn-Kv-PgL" secondAttribute="bottom" constant="8" id="Hg6-1X-5p2"/>
<constraint firstItem="PZB-UI-B3R" firstAttribute="centerX" secondItem="Wgr-xH-z0G" secondAttribute="centerX" constant="-1.5" id="LQU-R8-GHo"/>
<constraint firstItem="aZl-bU-psB" firstAttribute="leading" secondItem="Phj-na-SP1" secondAttribute="trailing" constant="9" id="PCb-NY-cPw"/>
<constraint firstItem="5sr-Hf-NCo" firstAttribute="leading" secondItem="rAn-Kv-PgL" secondAttribute="trailing" constant="8" id="RGk-1T-khu"/>
<constraint firstItem="rC1-mU-Scu" firstAttribute="leading" secondItem="hKA-b6-heE" secondAttribute="trailing" constant="8" id="RUS-zV-JtN"/>
<constraint firstItem="rAn-Kv-PgL" firstAttribute="top" secondItem="Wgr-xH-z0G" secondAttribute="top" constant="3" id="RdR-vl-146"/>
<constraint firstItem="j82-Gu-ek3" firstAttribute="centerX" secondItem="Wgr-xH-z0G" secondAttribute="centerX" constant="-1.5" id="Rqt-O8-CYB"/>
<constraint firstAttribute="bottom" secondItem="hKA-b6-heE" secondAttribute="bottom" constant="20" id="TGf-Kl-MPP"/>
<constraint firstItem="aZl-bU-psB" firstAttribute="centerY" secondItem="Phj-na-SP1" secondAttribute="centerY" id="YbA-a2-VNl"/>
<constraint firstItem="nRx-qJ-VIe" firstAttribute="top" secondItem="PZB-UI-B3R" secondAttribute="bottom" constant="13" id="c9C-z2-sGu"/>
<constraint firstItem="aZl-bU-psB" firstAttribute="centerY" secondItem="Phj-na-SP1" secondAttribute="centerY" constant="-2" id="YbA-a2-VNl"/>
<constraint firstAttribute="bottom" secondItem="rC1-mU-Scu" secondAttribute="bottom" constant="20" id="dbf-vQ-Wby"/>
<constraint firstItem="Phj-na-SP1" firstAttribute="top" secondItem="PZB-UI-B3R" secondAttribute="bottom" constant="11" id="dnt-aZ-NN3"/>
<constraint firstItem="PZB-UI-B3R" firstAttribute="top" secondItem="rAn-Kv-PgL" secondAttribute="bottom" constant="21" id="gTm-YN-3Nr"/>
<constraint firstItem="Phj-na-SP1" firstAttribute="top" secondItem="PZB-UI-B3R" secondAttribute="bottom" constant="8" id="dnt-aZ-NN3"/>
<constraint firstItem="nRx-qJ-VIe" firstAttribute="centerY" secondItem="Wgr-xH-z0G" secondAttribute="centerY" constant="-8" id="fMz-zP-sqF"/>
<constraint firstItem="5sr-Hf-NCo" firstAttribute="centerY" secondItem="rAn-Kv-PgL" secondAttribute="centerY" id="gZH-uP-MDP"/>
<constraint firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="5sr-Hf-NCo" secondAttribute="trailing" constant="8" id="heg-Vm-b50"/>
<constraint firstItem="rAn-Kv-PgL" firstAttribute="centerX" secondItem="Wgr-xH-z0G" secondAttribute="centerX" id="zQB-dF-MQ4"/>
......@@ -138,7 +154,7 @@ DQ
<connections>
<outlet property="delegate" destination="-2" id="cKX-Z2-yDq"/>
</connections>
<point key="canvasLocation" x="589" y="-131"/>
<point key="canvasLocation" x="619.5" y="-107"/>
</window>
<customView identifier="ChooseCerts" id="ftV-Pr-W0i">
<rect key="frame" x="0.0" y="0.0" width="531" height="172"/>
......
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