Commit a9e5c71d authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

contact request: ui for pending list

This commit changes UI for pending contact request list. It adds
peer photo, peer name and message for contact request. (for now it shows
default message)

Tuleap: #1553
Change-Id: I22f58456eb583eefe04f9288ab926c93247b17d9
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 7ba242ec
......@@ -196,7 +196,9 @@ SET(ringclient_VIEWS
src/views/IMTableCellView.h
src/views/IMTableCellView.mm
src/views/AccountMenuItemView.h
src/views/AccountMenuItemView.mm)
src/views/AccountMenuItemView.mm
src/views/ContactRequestCellView.h
src/views/ContactRequestCellView.mm)
SET(ringclient_OTHERS
src/main.mm
......
......@@ -19,15 +19,22 @@
//Qt
#import <QItemSelectionModel>
#import <QSize>
#import <QtMacExtras/qmacfunctions.h>
#import <QPixmap>
//LRC
#import <account.h>
#import <availableAccountModel.h>
#import <contactRequest.h>
#import <pendingContactRequestModel.h>
#import <globalinstances.h>
#import <contactmethod.h>
#import "ContactRequestsListVC.h"
#import "QNSTreeController.h"
#import <interfaces/pixmapmanipulatori.h>
#import "views/ContactRequestCellView.h"
@interface ContactRequestsListVC ()
......@@ -50,6 +57,10 @@ typedef NS_ENUM(NSInteger, ContactAction) {
NSInteger const TAG_NAME = 100;
NSInteger const TAG_RINGID = 200;
NSInteger const TAG_PHOTO = 300;
NSString* defaultMsg = @"Hello, I would like invite you";
- (void)awakeFromNib
{
......@@ -62,6 +73,7 @@ NSInteger const TAG_RINGID = 200;
[contactRequestView bind:@"content" toObject:requestsTreeController withKeyPath:@"arrangedObjects" options:nil];
[contactRequestView bind:@"sortDescriptors" toObject:requestsTreeController withKeyPath:@"sortDescriptors" options:nil];
[contactRequestView bind:@"selectionIndexPaths" toObject:requestsTreeController withKeyPath:@"selectionIndexPaths" options:nil];
contactRequestView.selectionHighlightStyle = NSTableViewSelectionHighlightStyleNone;
[noRequestsLabel setHidden:[contactRequestView numberOfRows]>0];
}
......@@ -118,20 +130,47 @@ NSInteger const TAG_RINGID = 200;
- (NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSTableView* result = [outlineView makeViewWithIdentifier:@"ContactRequestView" owner:self];
ContactRequestCellView* result;
result = [outlineView makeViewWithIdentifier:@"ContactRequestView" owner:self];
QModelIndex qIdx = [self.requestsTreeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid()) {
return result;
}
Account* chosenAccount = [self chosenAccount];
[result setup];
NSTextField* nameLabel = [result viewWithTag:TAG_NAME];
NSTextField* ringIDLabel = [result viewWithTag:TAG_RINGID];
NSImageView* photoView = [result viewWithTag:TAG_PHOTO];
NSString* localizedTitle = [NSString stringWithFormat:
NSLocalizedString(@"Hi %@. Please add me to your contact list.", @"Default contact request msg"), [self nameForAccount:[self chosenAccount]]];
[result.msgView setString:localizedTitle];
ContactRequest* contactRequest = qvariant_cast<ContactRequest*>(qIdx.data((int)Ring::Role::Object));
Person* person = contactRequest->peer();
if(!person) {
Account* chosenAccount = [self chosenAccount];
NSString* ringID = chosenAccount->pendingContactRequestModel()->data(qIdx,Qt::DisplayRole).toString().toNSString();
[nameLabel setStringValue:ringID];
return result;
}
NSString* ringID = chosenAccount->pendingContactRequestModel()->data(qIdx,Qt::DisplayRole).toString().toNSString();
QVariant photo = GlobalInstances::pixmapManipulator().contactPhoto(person, {100,100});
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
NSString* idString = person->phoneNumbers()[0]->getBestId().toNSString();
if(person->formattedName() != nil && person->formattedName().length()>0) {
NSString* name = person->formattedName().toNSString();
[nameLabel setStringValue:name];
if(![person->formattedName().toNSString() isEqualToString:idString]){
NSString* formattedID = [NSString stringWithFormat:@"%@%@%@",@"(",idString, @")"];
[ringIDLabel setStringValue:formattedID];
}
return result;
}
[nameLabel setStringValue:idString];
[nameLabel setStringValue:ringID];
[ringIDLabel setStringValue:ringID];
return result;
}
......@@ -141,4 +180,15 @@ NSInteger const TAG_RINGID = 200;
return index.data(static_cast<int>(Account::Role::Object)).value<Account*>();
}
-(NSString*) nameForAccount:(Account*) account {
auto name = account->registeredName();
NSString* userNameString = nullptr;
if (!name.isNull() && !name.isEmpty()) {
userNameString = name.toNSString();
} else {
userNameString = account->username().toNSString();
}
return userNameString;
}
@end
/*
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import <Cocoa/Cocoa.h>
@interface ContactRequestCellView : NSTableCellView
@property (nonatomic, strong) IBOutlet NSTextView* msgView;
- (void) setup;
@end
/*
* Copyright (C) 2015-2017 Savoir-faire Linux Inc.
* Author: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#import "ContactRequestCellView.h"
@implementation ContactRequestCellView
@synthesize msgView;
- (void) setup
{
[self.msgView setWantsLayer:YES];
self.msgView.layer.cornerRadius = 5.0f;
}
@end
This diff is collapsed.
......@@ -151,3 +151,5 @@
/* Error shown to user */
"Could not find contact to send request" = "Could not find contact to send request";
/* Default contact request msg*/
"Hi %@. Please add me to your contact list." = "Hi %@. Please add me to your contact list.";
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