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.";
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