Commit 88071912 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

Contact Request: remove confirmation window

Remove window with peer's information when sending contact request

Change-Id: Ib850b465bc07c67a2fe4638e220f5dc6af44f6e2
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 4f403b68
......@@ -166,8 +166,6 @@ SET(ringclient_CONTROLLERS
src/ContactRequestsListVC.mm
src/ContactRequestVC.h
src/ContactRequestVC.mm
src/SendContactRequestWC.h
src/SendContactRequestWC.mm
src/AccBannedContactsVC.h
src/AccBannedContactsVC.mm
src/MessagesVC.h
......@@ -257,7 +255,6 @@ SET(ringclient_XIBS
AccountMenuItemView
ContactRequestList
ContactRequest
SendContactRequest
AccBannedContacts
)
......
......@@ -39,7 +39,6 @@
#import "QNSTreeController.h"
#import "INDSequentialTextSelectionManager.h"
#import "delegates/ImageManipulationDelegate.h"
#import "SendContactRequestWC.h"
#import "PhoneDirectoryModel.h"
#import "account.h"
#import "AvailableAccountModel.h"
......@@ -56,7 +55,6 @@
QMetaObject::Connection contactMethodChanged;
ContactMethod* selectedContactMethod;
SendContactRequestWC* sendRequestWC;
__unsafe_unretained IBOutlet NSView* sendPanel;
__unsafe_unretained IBOutlet NSTextField* conversationTitle;
......@@ -157,12 +155,18 @@
messagesViewVC.delegate = nil;
}
- (IBAction)openSendContactRequestWindow:(id)sender
- (IBAction)sendContactRequest:(id)sender
{
if(auto cm = contactMethods.at([contactMethodsPopupButton indexOfSelectedItem])) {
sendRequestWC = [[SendContactRequestWC alloc] initWithWindowNibName:@"SendContactRequest"];
sendRequestWC.contactMethod = cm;
[sendRequestWC.window makeKeyAndOrderFront:sendRequestWC.window];
auto cm = contactMethods.at([contactMethodsPopupButton indexOfSelectedItem]);
if(cm) {
if(cm->account() == nullptr) {
cm->setAccount([self chosenAccount]);
}
if(cm->account() == nullptr) {
return;
}
cm->account()->sendContactRequest(cm);
}
}
......
/*
* 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
......@@ -291,12 +291,12 @@
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="isI-We-3h9">
<button toolTip="Send Contact Request " verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="isI-We-3h9">
<rect key="frame" x="711" y="537" width="73" height="32"/>
<constraints>
<constraint firstAttribute="width" priority="250" id="J5j-bs-Mgk"/>
</constraints>
<buttonCell key="cell" type="push" title="Invite" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="9su-fU-MPG">
<buttonCell key="cell" type="push" title="Invite" bezelStyle="rounded" alignment="center" borderStyle="border" toolTip="Send Contact Request" 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">
......@@ -304,7 +304,7 @@ Gw
</string>
</buttonCell>
<connections>
<action selector="openSendContactRequestWindow:" target="-2" id="Elh-XT-zVB"/>
<action selector="sendContactRequest:" target="-2" id="aZD-AA-2JW"/>
</connections>
</button>
</subviews>
......
......@@ -145,11 +145,3 @@
/* 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";
/* Default contact request msg*/
"Hi %@. Please add me to your contact list." = "Hi %@. Please add me to your contact list.";
<?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" customObjectInstantitationMethod="direct">
<dependencies>
<development version="7000" identifier="xcode"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11762"/>
<capability name="box content view" minToolsVersion="7.0"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="SendContactRequestWC">
<connections>
<outlet property="infoLabel" destination="5FJ-Wn-4xp" id="Hud-Ip-Pgg"/>
<outlet property="photoView" destination="ocR-gO-HgE" id="bFc-rK-w9M"/>
<outlet property="ringID" destination="EPZ-LA-Em7" id="8be-FD-fpY"/>
<outlet property="userName" destination="0xe-LA-1ai" id="AmK-qx-Ej1"/>
<outlet property="window" destination="F0z-JX-Cv5" id="gIp-Ho-8D9"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<window allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="F0z-JX-Cv5">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
<rect key="contentRect" x="600" y="400" width="480" height="148"/>
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
<view key="contentView" wantsLayer="YES" id="se5-gp-TjO">
<rect key="frame" x="0.0" y="0.0" width="480" height="148"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<box boxType="custom" borderType="none" cornerRadius="4" title="Box" translatesAutoresizingMaskIntoConstraints="NO" id="bEt-lG-i4k">
<rect key="frame" x="0.0" y="0.0" width="480" height="148"/>
<view key="contentView" id="CUO-ev-BzY">
<rect key="frame" x="0.0" y="0.0" width="480" height="148"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="100" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="0xe-LA-1ai" userLabel="Name">
<rect key="frame" x="80" y="118" width="380" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="wqv-Ku-Z2c"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" placeholderString="Name" drawsBackground="YES" id="viY-KH-vgk">
<font key="font" metaFont="system" size="18"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" tag="200" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="EPZ-LA-Em7" userLabel="RingID">
<rect key="frame" x="80" y="88" width="380" height="20"/>
<constraints>
<constraint firstAttribute="height" constant="20" id="Rnh-uW-7Ex"/>
</constraints>
<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" placeholderString="" drawsBackground="YES" id="qe1-No-NMj">
<font key="font" metaFont="system"/>
<color key="textColor" name="secondaryLabelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" allowsCharacterPickerTouchBarItem="NO" translatesAutoresizingMaskIntoConstraints="NO" id="5FJ-Wn-4xp">
<rect key="frame" x="18" y="61" width="444" height="17"/>
<textFieldCell key="cell" sendsActionOnEndEditing="YES" alignment="center" title="Send invitation in order to be able contact the person" id="bx7-J5-IAB">
<font key="font" metaFont="system"/>
<color key="textColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<imageView horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="ocR-gO-HgE">
<rect key="frame" x="20" y="98" width="40" height="40"/>
<constraints>
<constraint firstAttribute="width" constant="40" id="K87-m9-EpE"/>
<constraint firstAttribute="height" constant="40" id="cle-76-3x3"/>
</constraints>
<imageCell key="cell" refusesFirstResponder="YES" alignment="left" imageScaling="proportionallyDown" image="default_user_icon" id="jMf-G8-fTP"/>
</imageView>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Eb1-hd-QEj">
<rect key="frame" x="395" y="13" width="71" height="32"/>
<buttonCell key="cell" type="push" title="Send" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="t4h-PW-vyg">
<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="sendContactRequest:" target="-2" id="9Pj-Lt-Qcw"/>
<binding destination="-2" name="hidden" keyPath="self.hideButtons" id="Fiw-gS-21q"/>
</connections>
</button>
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="eAa-6Q-qZ8">
<rect key="frame" x="305" y="13" width="82" height="32"/>
<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="32u-uV-JVI">
<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="cancelPressed:" target="-2" id="dlH-Vs-Y43"/>
<binding destination="-2" name="hidden" keyPath="self.hideButtons" id="Afa-76-ACW"/>
</connections>
</button>
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="j3C-Jr-A0B">
<rect key="frame" x="403" y="13" width="55" height="32"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="push" title="Ok" bezelStyle="rounded" alignment="center" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="wzl-Qv-0sU">
<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="cancelPressed:" target="-2" id="Zv2-Pn-p8K"/>
<binding destination="-2" name="hidden" keyPath="self.hideButtons" id="OdD-jI-RNW">
<dictionary key="options">
<string key="NSValueTransformerName">NSNegateBoolean</string>
</dictionary>
</binding>
</connections>
</button>
</subviews>
<constraints>
<constraint firstItem="5FJ-Wn-4xp" firstAttribute="top" secondItem="EPZ-LA-Em7" secondAttribute="bottom" constant="10" id="4Sm-k0-hBO"/>
<constraint firstAttribute="trailing" secondItem="EPZ-LA-Em7" secondAttribute="trailing" constant="20" id="767-Hx-gDa"/>
<constraint firstAttribute="trailing" secondItem="0xe-LA-1ai" secondAttribute="trailing" constant="20" id="83k-FO-dBA"/>
<constraint firstItem="0xe-LA-1ai" firstAttribute="top" secondItem="CUO-ev-BzY" secondAttribute="top" constant="10" id="AJJ-5U-EKe"/>
<constraint firstItem="5FJ-Wn-4xp" firstAttribute="leading" secondItem="CUO-ev-BzY" secondAttribute="leading" constant="20" id="B3t-kd-M7W"/>
<constraint firstItem="0xe-LA-1ai" firstAttribute="leading" secondItem="ocR-gO-HgE" secondAttribute="trailing" constant="20" id="Euv-vO-PZV"/>
<constraint firstItem="eAa-6Q-qZ8" firstAttribute="top" secondItem="5FJ-Wn-4xp" secondAttribute="bottom" constant="20" id="GeU-mF-yMU"/>
<constraint firstItem="ocR-gO-HgE" firstAttribute="leading" secondItem="CUO-ev-BzY" secondAttribute="leading" constant="20" id="PMA-o7-BrX"/>
<constraint firstAttribute="bottom" secondItem="Eb1-hd-QEj" secondAttribute="bottom" constant="20" id="Qyx-Qp-FX9"/>
<constraint firstAttribute="trailing" secondItem="5FJ-Wn-4xp" secondAttribute="trailing" constant="20" id="T5d-Gh-rkw"/>
<constraint firstItem="EPZ-LA-Em7" firstAttribute="leading" secondItem="ocR-gO-HgE" secondAttribute="trailing" constant="20" id="Vu7-Cp-I0M"/>
<constraint firstAttribute="bottom" secondItem="eAa-6Q-qZ8" secondAttribute="bottom" constant="20" id="abm-oV-tI5"/>
<constraint firstItem="Eb1-hd-QEj" firstAttribute="leading" secondItem="eAa-6Q-qZ8" secondAttribute="trailing" constant="20" id="cYW-ZW-rnm"/>
<constraint firstAttribute="trailing" secondItem="Eb1-hd-QEj" secondAttribute="trailing" constant="20" id="ePn-Mw-Xj1"/>
<constraint firstItem="EPZ-LA-Em7" firstAttribute="top" secondItem="0xe-LA-1ai" secondAttribute="bottom" constant="10" id="yKJ-Q7-Grb"/>
<constraint firstItem="ocR-gO-HgE" firstAttribute="top" secondItem="CUO-ev-BzY" secondAttribute="top" constant="10" id="yov-nE-Zbu"/>
</constraints>
</view>
</box>
</subviews>
<constraints>
<constraint firstItem="bEt-lG-i4k" firstAttribute="top" secondItem="se5-gp-TjO" secondAttribute="top" id="1MD-p9-Lb3"/>
<constraint firstItem="bEt-lG-i4k" firstAttribute="leading" secondItem="se5-gp-TjO" secondAttribute="leading" id="OFX-cp-t3f"/>
<constraint firstAttribute="trailing" secondItem="bEt-lG-i4k" secondAttribute="trailing" id="OxY-Uw-Uxy"/>
<constraint firstAttribute="bottom" secondItem="bEt-lG-i4k" secondAttribute="bottom" id="Q67-Sn-LSD"/>
</constraints>
</view>
<connections>
<outlet property="delegate" destination="-2" id="0bl-1N-AYu"/>
</connections>
</window>
<userDefaultsController representsSharedInstance="YES" id="chh-gN-KjI"/>
</objects>
<resources>
<image name="default_user_icon" width="96" height="96"/>
</resources>
</document>
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