Commit 60970856 authored by Anthony Léonard's avatar Anthony Léonard

remove add contact popover

This panel is removed to improve ease of use and because contacts with
multiple contact methods are not supported very well. With this
simplification, adding a contact is now a single click action.

Change-Id: Id15289a844b0c9c0d467e5e8491fd7713f0d1aab
Reviewed-by: default avatarOlivier Soldano <olivier.soldano@savoirfairelinux.com>
parent 66e239bd
......@@ -39,6 +39,8 @@
#import <media/text.h>
#import <person.h>
#import <globalinstances.h>
#import <personmodel.h>
#import <peerprofilecollection.h>
#import "AppDelegate.h"
#import "views/ITProgressIndicator.h"
......@@ -641,21 +643,40 @@
- (IBAction)addToContact:(NSButton*) sender {
auto contactmethod = CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex())->peerContactMethod();
if (self.addToContactPopover != nullptr) {
[self.addToContactPopover performClose:self];
self.addToContactPopover = NULL;
} else if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) {
auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
[editorVC setMethodToLink:contactmethod];
[editorVC setContactLinkedDelegate:self];
self.addToContactPopover = [[NSPopover alloc] init];
[self.addToContactPopover setContentSize:editorVC.view.frame.size];
[self.addToContactPopover setContentViewController:editorVC];
[self.addToContactPopover setAnimates:YES];
[self.addToContactPopover setBehavior:NSPopoverBehaviorTransient];
[self.addToContactPopover setDelegate:self];
[self.addToContactPopover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSMaxXEdge];
// TODO: Uncomment to reuse contact name editing popover
// if (self.addToContactPopover != nullptr) {
// [self.addToContactPopover performClose:self];
// self.addToContactPopover = NULL;
// } else if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) {
// auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
// [editorVC setMethodToLink:contactmethod];
// [editorVC setContactLinkedDelegate:self];
// self.addToContactPopover = [[NSPopover alloc] init];
// [self.addToContactPopover setContentSize:editorVC.view.frame.size];
// [self.addToContactPopover setContentViewController:editorVC];
// [self.addToContactPopover setAnimates:YES];
// [self.addToContactPopover setBehavior:NSPopoverBehaviorTransient];
// [self.addToContactPopover setDelegate:self];
//
// [self.addToContactPopover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSMaxXEdge];
// }
auto* newPerson = new Person();
newPerson->setFormattedName(contactmethod->bestName());
Person::ContactMethods numbers;
numbers << contactmethod;
newPerson->setContactMethods(numbers);
contactmethod->setPerson(newPerson);
auto personCollections = PersonModel::instance().collections();
CollectionInterface *peerProfileCollection = nil;
foreach(auto collection, personCollections) {
if(dynamic_cast<PeerProfileCollection*>(collection))
peerProfileCollection = collection;
}
if(peerProfileCollection) {
PersonModel::instance().addNewPerson(newPerson, peerProfileCollection);
}
[videoView setCallDelegate:nil];
......
......@@ -30,6 +30,8 @@
#import <person.h>
#import <contactmethod.h>
#import <globalinstances.h>
#import <personmodel.h>
#import <peerprofilecollection.h>
#import "QNSTreeController.h"
#import "PersonLinkerVC.h"
......@@ -256,21 +258,40 @@ NSInteger const PHOTO_TAG = 400;
}
}
if (addToContactPopover != nullptr) {
[addToContactPopover performClose:self];
addToContactPopover = NULL;
} else if (contactmethod) {
auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
[editorVC setMethodToLink:contactmethod];
[editorVC setContactLinkedDelegate:self];
addToContactPopover = [[NSPopover alloc] init];
[addToContactPopover setContentSize:editorVC.view.frame.size];
[addToContactPopover setContentViewController:editorVC];
[addToContactPopover setAnimates:YES];
[addToContactPopover setBehavior:NSPopoverBehaviorTransient];
[addToContactPopover setDelegate:self];
[addToContactPopover showRelativeToRect:[historyView frameOfOutlineCellAtRow:[historyView selectedRow]] ofView:historyView preferredEdge:NSMaxXEdge];
// TODO: Uncomment to reuse contact name editing popover
// if (addToContactPopover != nullptr) {
// [addToContactPopover performClose:self];
// addToContactPopover = NULL;
// } else if (contactmethod) {
// auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
// [editorVC setMethodToLink:contactmethod];
// [editorVC setContactLinkedDelegate:self];
// addToContactPopover = [[NSPopover alloc] init];
// [addToContactPopover setContentSize:editorVC.view.frame.size];
// [addToContactPopover setContentViewController:editorVC];
// [addToContactPopover setAnimates:YES];
// [addToContactPopover setBehavior:NSPopoverBehaviorTransient];
// [addToContactPopover setDelegate:self];
//
// [addToContactPopover showRelativeToRect:[historyView frameOfOutlineCellAtRow:[historyView selectedRow]] ofView:historyView preferredEdge:NSMaxXEdge];
// }
auto* newPerson = new Person();
newPerson->setFormattedName(contactmethod->bestName());
Person::ContactMethods numbers;
numbers << contactmethod;
newPerson->setContactMethods(numbers);
contactmethod->setPerson(newPerson);
auto personCollections = PersonModel::instance().collections();
CollectionInterface *peerProfileCollection = nil;
foreach(auto collection, personCollections) {
if(dynamic_cast<PeerProfileCollection*>(collection))
peerProfileCollection = collection;
}
if(peerProfileCollection) {
PersonModel::instance().addNewPerson(newPerson, peerProfileCollection);
}
}
......
......@@ -39,6 +39,8 @@
#import <globalinstances.h>
#import <phonedirectorymodel.h>
#import <AvailableAccountModel.h>
#import <personmodel.h>
#import <peerprofilecollection.h>
#import "QNSTreeController.h"
#import "delegates/ImageManipulationDelegate.h"
......@@ -461,22 +463,41 @@ NSInteger const PRESENCE_TAG = 800;
if (contactmethod.isEmpty())
return;
if (addToContactPopover != nullptr) {
[addToContactPopover performClose:self];
addToContactPopover = NULL;
} else if (contactmethod.first()) {
auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
[editorVC setMethodToLink:contactmethod.first()];
[editorVC setContactLinkedDelegate:self];
addToContactPopover = [[NSPopover alloc] init];
[addToContactPopover setContentSize:editorVC.view.frame.size];
[addToContactPopover setContentViewController:editorVC];
[addToContactPopover setAnimates:YES];
[addToContactPopover setBehavior:NSPopoverBehaviorTransient];
[addToContactPopover setDelegate:self];
[addToContactPopover showRelativeToRect:[smartView frameOfCellAtColumn:0 row:[smartView selectedRow]]
ofView:smartView preferredEdge:NSMaxXEdge];
// TODO: Uncomment to reuse contact name editing popover
// if (addToContactPopover != nullptr) {
// [addToContactPopover performClose:self];
// addToContactPopover = NULL;
// } else if (contactmethod.first()) {
// auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
// [editorVC setMethodToLink:contactmethod.first()];
// [editorVC setContactLinkedDelegate:self];
// addToContactPopover = [[NSPopover alloc] init];
// [addToContactPopover setContentSize:editorVC.view.frame.size];
// [addToContactPopover setContentViewController:editorVC];
// [addToContactPopover setAnimates:YES];
// [addToContactPopover setBehavior:NSPopoverBehaviorTransient];
// [addToContactPopover setDelegate:self];
//
// [addToContactPopover showRelativeToRect:[smartView frameOfCellAtColumn:0 row:[smartView selectedRow]]
// ofView:smartView preferredEdge:NSMaxXEdge];
// }
auto* newPerson = new Person();
newPerson->setFormattedName(contactmethod.first()->bestName());
Person::ContactMethods numbers;
numbers << contactmethod.first();
newPerson->setContactMethods(numbers);
contactmethod.first()->setPerson(newPerson);
auto personCollections = PersonModel::instance().collections();
CollectionInterface *peerProfileCollection = nil;
foreach(auto collection, personCollections) {
if(dynamic_cast<PeerProfileCollection*>(collection))
peerProfileCollection = collection;
}
if(peerProfileCollection) {
PersonModel::instance().addNewPerson(newPerson, peerProfileCollection);
}
}
......
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