Commit 0ba1bafc authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Anthony Léonard

contact request: send invitation

This patch adds new window that displays photo, contact's name(if exists)
and RingID or user name. From this window user could send contact request
to the peer.

Tuleap: #1593
Change-Id: I19adee0c10bfb5391db430881331fc9fd02f127a
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent c1907fd9
......@@ -164,6 +164,8 @@ SET(ringclient_CONTROLLERS
src/ContactRequestsListVC.mm
src/ContactRequestVC.h
src/ContactRequestVC.mm
src/SendContactRequestWC.h
src/SendContactRequestWC.mm
)
SET(ringclient_BACKENDS
......@@ -242,6 +244,7 @@ SET(ringclient_XIBS
AccountMenuItemView
ContactRequestList
ContactRequest
SendContactRequest
)
# Icons
......
......@@ -39,6 +39,11 @@
#import "QNSTreeController.h"
#import "INDSequentialTextSelectionManager.h"
#import "delegates/ImageManipulationDelegate.h"
#import "SendContactRequestWC.h"
#import "PhoneDirectoryModel.h"
#import "account.h"
#import "AvailableAccountModel.h"
#import <QuartzCore/QuartzCore.h>
......@@ -51,6 +56,7 @@
QNSTreeController* treeController;
QMetaObject::Connection contactMethodChanged;
ContactMethod* selectedContactMethod;
SendContactRequestWC* sendRequestWC;
__unsafe_unretained IBOutlet NSView* sendPanel;
__unsafe_unretained IBOutlet NSTextField* conversationTitle;
......@@ -143,6 +149,15 @@
RecentModel::instance().selectionModel()->clearCurrentIndex();
}
- (IBAction)openSendContactRequestWindow:(id)sender
{
if(auto cm = contactMethods.at([contactMethodsPopupButton indexOfSelectedItem])) {
sendRequestWC = [[SendContactRequestWC alloc] initWithWindowNibName:@"SendContactRequest"];
sendRequestWC.contactMethod = cm;
[sendRequestWC.window makeKeyAndOrderFront:sendRequestWC.window];
}
}
# pragma mark private IN/OUT animations
-(void) animateIn
......
/*
* 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 SendContactRequestWC : NSWindowController
@property BOOL hideButtons;
@property ContactMethod* contactMethod;
@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.
*/
//Qt
#import <QSize>
#import <QtMacExtras/qmacfunctions.h>
#import <QPixmap>
//LRC
#import <account.h>
#import <person.h>
#import <contactmethod.h>
#import <availableAccountModel.h>
#import <contactRequest.h>
#import <globalinstances.h>
#import <recentmodel.h>
#import "Constants.h"
#import "views/NSImage+Extensions.h"
#import "delegates/ImageManipulationDelegate.h"
#import "SendContactRequestWC.h"
@interface SendContactRequestWC () {
__unsafe_unretained IBOutlet NSTextField* userName;
__unsafe_unretained IBOutlet NSTextField* ringID;
__unsafe_unretained IBOutlet NSTextField* infoLabel;
__unsafe_unretained IBOutlet NSImageView* photoView;
}
@end
@implementation SendContactRequestWC
NSString* const sendingErrorMsg = @"An error happened, contact request has not been sent";
NSString* const findContactErrorMsg = @"Could not find contact to send request";
- (void)windowDidLoad {
[super windowDidLoad];
self.hideButtons = false;
if(!self.contactMethod) {
[self findContactError];
return;
}
auto photo = GlobalInstances::pixmapManipulator().callPhoto(self.contactMethod, {100,100});
[photoView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
[userName setStringValue:self.contactMethod->bestName().toNSString()];
[ringID setStringValue:self.contactMethod->bestId().toNSString()];
}
-(IBAction) sendContactRequest:(id)sender
{
if(self.contactMethod->account() == nullptr) {
self.contactMethod->setAccount([self chosenAccount]);
}
if(self.contactMethod->account() == nullptr) {
return;
}
if (self.contactMethod->account()->sendContactRequest(self.contactMethod)) {
[self close];
return;
} else {
[self sendRequestError];
}
}
- (IBAction) cancelPressed:(id)sender
{
[self close];
}
-(Account* ) chosenAccount
{
QModelIndex index = AvailableAccountModel::instance().selectionModel()->currentIndex();
if(!index.isValid())
return nil;
return index.data(static_cast<int>(Account::Role::Object)).value<Account*>();
}
-(void)sendRequestError
{
self.hideButtons = true;
NSString* error = NSLocalizedString(sendingErrorMsg, @"Error shown to user");
[infoLabel setStringValue:sendingErrorMsg];
}
-(void) findContactError
{
self.hideButtons = true;
NSString* error = NSLocalizedString(findContactErrorMsg, @"Error shown to user");
[infoLabel setStringValue:error];
}
@end
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11201" systemVersion="15G1004" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11762" systemVersion="16D30a" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="system font weights other than Regular or Bold" minToolsVersion="7.0"/>
</dependencies>
<objects>
......@@ -64,7 +65,7 @@
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" id="ro7-HT-yYC"/>
</imageView>
<customView ambiguous="YES" misplaced="YES" translatesAutoresizingMaskIntoConstraints="NO" id="70Z-up-big" customClass="NSTextView">
<customView ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="70Z-up-big" customClass="NSTextView">
<rect key="frame" x="58" y="10" width="636" height="40"/>
</customView>
</subviews>
......@@ -160,7 +161,7 @@
</connections>
</button>
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="xdB-aI-PSs" userLabel="CMs Popup menu">
<rect key="frame" x="626" y="541" width="155" height="26"/>
<rect key="frame" x="560" y="541" width="155" height="26"/>
<constraints>
<constraint firstAttribute="height" constant="21" id="ESK-Wb-Nis"/>
<constraint firstAttribute="width" constant="150" id="Er6-l6-0VP"/>
......@@ -255,9 +256,9 @@
</constraints>
</customView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ucx-6g-eJw">
<rect key="frame" x="197" y="544" width="404" height="21"/>
<rect key="frame" x="240" y="544" width="318" height="21"/>
<constraints>
<constraint firstAttribute="width" constant="400" id="209-bx-oHM"/>
<constraint firstAttribute="width" constant="314" id="209-bx-oHM"/>
</constraints>
<textFieldCell key="cell" lineBreakMode="truncatingTail" selectable="YES" sendsActionOnEndEditing="YES" alignment="center" placeholderString="Title" id="HnC-1N-RmR">
<font key="font" metaFont="system" size="18"/>
......@@ -265,20 +266,35 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="isI-We-3h9">
<rect key="frame" x="711" y="537" width="73" height="32"/>
<buttonCell key="cell" type="push" title="Invite" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="9su-fU-MPG">
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<string key="keyEquivalent" base64-UTF8="YES">
Gw
</string>
</buttonCell>
<connections>
<action selector="openSendContactRequestWindow:" target="-2" id="Elh-XT-zVB"/>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="ucx-6g-eJw" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="21" id="32s-Wp-DE1"/>
<constraint firstAttribute="trailing" secondItem="xdB-aI-PSs" secondAttribute="trailing" constant="20" id="3kG-22-sad"/>
<constraint firstAttribute="bottom" secondItem="Rth-di-Tls" secondAttribute="bottom" id="9nL-Hs-Oak"/>
<constraint firstItem="isI-We-3h9" firstAttribute="centerY" secondItem="xdB-aI-PSs" secondAttribute="centerY" id="BCb-ak-jKj"/>
<constraint firstItem="ucx-6g-eJw" firstAttribute="centerY" secondItem="ooq-vs-Xt1" secondAttribute="centerY" id="FKf-ZM-iWf"/>
<constraint firstItem="isI-We-3h9" firstAttribute="leading" secondItem="xdB-aI-PSs" secondAttribute="trailing" constant="5" id="HVj-YS-lLB"/>
<constraint firstItem="Rth-di-Tls" firstAttribute="leading" secondItem="EJD-f8-Xqd" secondAttribute="leading" id="Ijp-QX-Dkw"/>
<constraint firstItem="ucx-6g-eJw" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="Pd6-AZ-mue"/>
<constraint firstItem="Uqj-Xr-xl5" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="Tzd-wA-uMM"/>
<constraint firstItem="xdB-aI-PSs" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="ucx-6g-eJw" secondAttribute="trailing" constant="5" id="U7E-ud-cgV"/>
<constraint firstItem="EJD-f8-Xqd" firstAttribute="centerX" secondItem="Hz6-mo-xeY" secondAttribute="centerX" id="bvr-Gv-Sgb"/>
<constraint firstItem="ooq-vs-Xt1" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" constant="20" id="cQe-IU-Fcd"/>
<constraint firstItem="ooq-vs-Xt1" firstAttribute="top" secondItem="Hz6-mo-xeY" secondAttribute="top" constant="12" id="gkR-53-qs5"/>
<constraint firstAttribute="trailing" secondItem="Rth-di-Tls" secondAttribute="trailing" id="iT0-rG-86d"/>
<constraint firstAttribute="trailing" secondItem="isI-We-3h9" secondAttribute="trailing" constant="20" id="jTq-JG-e2r"/>
<constraint firstItem="xdB-aI-PSs" firstAttribute="leading" relation="greaterThanOrEqual" secondItem="ucx-6g-eJw" secondAttribute="trailing" constant="5" id="kPo-6r-kdR"/>
<constraint firstItem="EJD-f8-Xqd" firstAttribute="top" secondItem="ooq-vs-Xt1" secondAttribute="bottom" constant="1" id="mJI-DZ-n2l"/>
<constraint firstItem="Rth-di-Tls" firstAttribute="trailing" secondItem="EJD-f8-Xqd" secondAttribute="trailing" id="mga-Tu-Ikb"/>
<constraint firstItem="Rth-di-Tls" firstAttribute="leading" secondItem="Hz6-mo-xeY" secondAttribute="leading" id="qz7-sE-9Ml"/>
......
......@@ -145,3 +145,9 @@
/* Error shown to user */
"You have to migrate your account before exporting" = "You have to migrate your account before exporting";
/* Error shown to user */
"An error happened, contact request has not been sent" = "An error happened, contact request has not been sent";
/* Error shown to user */
"Could not find contact to send request" = "Could not find contact to send request";
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