diff --git a/CMakeLists.txt b/CMakeLists.txt index 9360a1bb2374b60594dc700288aa8055dc4882e9..8cfc88500f376bbe9d2ec116988eab1c08ca6109 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -167,6 +167,8 @@ SET(ringclient_CONTROLLERS src/AddSIPAccountVC.h src/AccountSettingsVC.mm src/AccountSettingsVC.h + src/LeaveMessageVC.mm + src/LeaveMessageVC.h ) SET(ringclient_BACKENDS @@ -261,6 +263,7 @@ SET(ringclient_XIBS MessageCells AddSIPAccountVC AccountSettings + LeaveMessageVC ) # Icons @@ -269,6 +272,10 @@ SET(myApp_ICON ${CMAKE_CURRENT_SOURCE_DIR}/data/appicon.icns) SET_SOURCE_FILES_PROPERTIES(${myApp_ICON} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) SET(ring_ICONS +${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_audio_file.png +${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_exit.png +${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_stoprecord.png +${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_audio.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_audio.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_folder.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_block.png diff --git a/data/dark/ic_audio_file.png b/data/dark/ic_audio_file.png new file mode 100644 index 0000000000000000000000000000000000000000..6130da1025bad9198cfcf4a3109349a611d8bbbd Binary files /dev/null and b/data/dark/ic_audio_file.png differ diff --git a/data/dark/ic_exit.png b/data/dark/ic_exit.png new file mode 100644 index 0000000000000000000000000000000000000000..4139f44e2b97c0d21fd7ccd02d502a3be43c73fe Binary files /dev/null and b/data/dark/ic_exit.png differ diff --git a/data/dark/ic_stoprecord.png b/data/dark/ic_stoprecord.png new file mode 100644 index 0000000000000000000000000000000000000000..085d7e14ffd4ee8f590aa617c97a95a49f09a405 Binary files /dev/null and b/data/dark/ic_stoprecord.png differ diff --git a/src/AppDelegate.mm b/src/AppDelegate.mm index cee31395d2564a4c0b29ca0b7458eb0faab71a63..134a457cb880e355890148c7a428ba8ab77ea8f4 100644 --- a/src/AppDelegate.mm +++ b/src/AppDelegate.mm @@ -319,7 +319,7 @@ static void ReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNet - (void) showMainWindow { if(self.ringWindowController == nil) { - self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow" bundle: nil accountModel:&lrc->getAccountModel() dataTransferModel:&lrc->getDataTransferModel() behaviourController:&lrc->getBehaviorController()]; + self.ringWindowController = [[RingWindowController alloc] initWithWindowNibName:@"RingWindow" bundle: nil accountModel:&lrc->getAccountModel() dataTransferModel:&lrc->getDataTransferModel() behaviourController:&lrc->getBehaviorController() avModel: &lrc->getAVModel()]; } [[NSApplication sharedApplication] removeWindowsItem:self.wizard.window]; [self.ringWindowController.window makeKeyAndOrderFront:self]; diff --git a/src/ConversationVC.h b/src/ConversationVC.h index c56b100912f5a51d86319569d5ed5f37a1f96249..c6e5860ec5e457a8039bba65f402af772018c1e2 100644 --- a/src/ConversationVC.h +++ b/src/ConversationVC.h @@ -18,12 +18,19 @@ */ #import -#import -#import +#import +namespace lrc { + namespace api { + class AVModel; + class ConversationModel; + } +} @class RingWindowController; +@class LeaveMessageVC; +@protocol LeaveMessageDelegate; -@interface ConversationVC : NSViewController +@interface ConversationVC : NSViewController -(void) initFrame; -(void) showWithAnimation:(BOOL)animate; @@ -31,6 +38,9 @@ - (void) setConversationUid:(const std::string)convUid model:(lrc::api::ConversationModel*)model; -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow; +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow aVModel:(lrc::api::AVModel*) avModel; +- (void) presentLeaveMessageView; + +-(NSViewController*) getMessagesView; @end diff --git a/src/ConversationVC.mm b/src/ConversationVC.mm index 9d2fe89c1d7a8554fcfeeda983047ae8eb4eda35..f787e15ce118e7ffa40a0d738e72a7dd74381d68 100644 --- a/src/ConversationVC.mm +++ b/src/ConversationVC.mm @@ -36,8 +36,12 @@ #import "utils.h" #import "RingWindowController.h" #import "NSString+Extensions.h" +#import "LeaveMessageVC.h" +#import +#import +#import "LeaveMessageVC.h" -@interface ConversationVC () { +@interface ConversationVC () { __unsafe_unretained IBOutlet NSTextField* conversationTitle; __unsafe_unretained IBOutlet NSTextField *conversationID; @@ -46,6 +50,7 @@ __unsafe_unretained IBOutlet NSButton* sentContactRequestButton; IBOutlet MessagesVC* messagesViewVC; + LeaveMessageVC* leaveMessageVC; IBOutlet NSLayoutConstraint *titleCenteredConstraint; IBOutlet NSLayoutConstraint* titleTopConstraint; @@ -55,6 +60,7 @@ lrc::api::ConversationModel* convModel_; RingWindowController* delegate; + NSMutableArray* leaveMessageConversations; // All those connections are needed to invalidate cached conversation as pointer // may not be referencing the same conversation anymore @@ -69,15 +75,26 @@ NSInteger const SEND_PANEL_MAX_HEIGHT = 120; @implementation ConversationVC -- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow +- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil delegate:(RingWindowController*) mainWindow aVModel:(lrc::api::AVModel*) avModel { if (self = [self initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { delegate = mainWindow; + leaveMessageVC = [[LeaveMessageVC alloc] initWithNibName:@"LeaveMessageVC" bundle:nil]; + [[leaveMessageVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; + [self.view addSubview:[leaveMessageVC view] positioned:NSWindowAbove relativeTo:nil]; + [leaveMessageVC initFrame]; + [leaveMessageVC setAVModel: avModel]; + leaveMessageConversations = [[NSMutableArray alloc] init]; + leaveMessageVC.delegate = self; } return self; } +-(NSViewController*) getMessagesView { + return messagesViewVC; +} + -(void) clearData { cachedConv_ = nil; convUid_ = ""; @@ -120,6 +137,11 @@ NSInteger const SEND_PANEL_MAX_HEIGHT = 120; if (convUid_.empty() || convModel_ == nil) return; + if([leaveMessageConversations containsObject:@(convUid_.c_str())]) { + [leaveMessageVC setConversationUID: convUid_ conversationModel: convModel_]; + } else { + [leaveMessageVC hide]; + } // Signals tracking changes in conversation list, we need them as cached conversation can be invalid // after a reordering. @@ -247,5 +269,13 @@ NSInteger const SEND_PANEL_MAX_HEIGHT = 120; [CATransaction commit]; } +- (void) presentLeaveMessageView { + [leaveMessageVC setConversationUID: convUid_ conversationModel: convModel_]; + [leaveMessageConversations addObject:@(convUid_.c_str())]; +} + +-(void) messageCompleted { + [leaveMessageConversations removeObject:@(convUid_.c_str())]; +} @end diff --git a/src/LeaveMessageVC.h b/src/LeaveMessageVC.h new file mode 100644 index 0000000000000000000000000000000000000000..3ef6561d24b1bb9b956a2617b5b2511670ce11cb --- /dev/null +++ b/src/LeaveMessageVC.h @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2018 Savoir-faire Linux Inc. + * Author: Kateryna Kostiuk + * + * 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 +#import + +namespace lrc { + namespace api { + class AVModel; + class ConversationModel; + } +} + +@protocol LeaveMessageDelegate + +-(void) messageCompleted; + +@end + +@interface LeaveMessageVC : NSViewController + +@property (retain, nonatomic) id delegate; + +-(void)setConversationUID:(const std::string) convUid conversationModel:(lrc::api::ConversationModel*) convModel; +-(void) hide; +-(void) initFrame; +-(void) setAVModel: (const lrc::api::AVModel*) avmodel; + +@end + diff --git a/src/LeaveMessageVC.mm b/src/LeaveMessageVC.mm new file mode 100644 index 0000000000000000000000000000000000000000..c35fcfcfb9e37d9e481994e139f045c59b496b6c --- /dev/null +++ b/src/LeaveMessageVC.mm @@ -0,0 +1,203 @@ +/* + * Copyright (C) 2018 Savoir-faire Linux Inc. + * Author: Kateryna Kostiuk + * + * 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 "LeaveMessageVC.h" +#import "views/NSColor+RingTheme.h" +#import "utils.h" + +//lrc +#import +#import + +#import +#import "delegates/ImageManipulationDelegate.h" + +//Qt +#import +#import +#import + +@interface LeaveMessageVC () { + __unsafe_unretained IBOutlet NSImageView* personPhoto; + __unsafe_unretained IBOutlet NSTextField* infoLabel; + __unsafe_unretained IBOutlet NSBox* timerBox; + __unsafe_unretained IBOutlet NSTextField* timerLabel; + __unsafe_unretained IBOutlet NSBox* sendBox; + __unsafe_unretained IBOutlet NSTextField* sendFilename; + __unsafe_unretained IBOutlet NSButton* recordButton; +} + +@end + +@implementation LeaveMessageVC + +bool isRecording = false; +int recordingTime = 0; +NSTimer* refreshDurationTimer; +lrc::api::AVModel* avModel; +std::string fileName; +NSMutableDictionary *filesToSend; +std::string conversationUid; +lrc::api::ConversationModel* conversationModel; + +- (void)loadView { + [super loadView]; + [personPhoto setWantsLayer:YES]; + personPhoto.layer.masksToBounds =true; + personPhoto.layer.cornerRadius = personPhoto.frame.size.width * 0.5; + filesToSend = [[NSMutableDictionary alloc] init]; +} + +-(void) setAVModel: (lrc::api::AVModel*) avmodel { + avModel = avmodel; +} + +-(void) initFrame { + [self.view setFrame:self.view.superview.bounds]; + [self.view setHidden:YES]; + self.view.layer.position = self.view.frame.origin; +} + +- (IBAction)cancel:(id)sender { + [self exit]; +} + +- (IBAction)recordMessage:(NSButton *)sender { + if (!isRecording) { + [self clearData]; + std::string file_name = avModel->startLocalRecorder(true); + if (file_name.empty()) { + return; + } + filesToSend[@(conversationUid.c_str())] = @(file_name.c_str()); + isRecording = true; + recordButton.image = [NSImage imageNamed:@"ic_stoprecord.png"]; + [timerBox setHidden:NO]; + if (refreshDurationTimer == nil) + refreshDurationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 + target:self + selector:@selector(updateDurationLabel) + userInfo:nil + repeats:YES]; + } else { + avModel->stopLocalRecorder([filesToSend[@(conversationUid.c_str())] UTF8String]); + isRecording = false; + recordButton.image = [NSImage imageNamed:@"ic_action_audio.png"]; + [refreshDurationTimer invalidate]; + refreshDurationTimer = nil; + [timerBox setHidden:YES]; + [sendBox setHidden: NO]; + [sendFilename setStringValue:[self timeFormatted: recordingTime]]; + } +} + +- (IBAction)sendMessage:(NSButton *)sender { + NSArray* pathURL = [filesToSend[@(conversationUid.c_str())] componentsSeparatedByString: @"/"]; + if([pathURL count] < 1) { + return; + } + NSString* name = [pathURL objectAtIndex: [pathURL count] - 1]; + conversationModel->sendFile(conversationUid, [filesToSend[@(conversationUid.c_str())] UTF8String], [name UTF8String]); + [filesToSend removeObjectForKey: @(conversationUid.c_str())]; + [self exit]; +} + +- (void) exit { + [self clearData]; + [self hide]; + [self.delegate messageCompleted]; +} + +- (void)clearData { + recordButton.image = [NSImage imageNamed:@"ic_action_audio.png"]; + recordingTime = 0; + [timerLabel setStringValue: [self timeFormatted: recordingTime]]; + isRecording = false; + [timerBox setHidden:YES]; + [sendBox setHidden: YES]; + [refreshDurationTimer invalidate]; + refreshDurationTimer = nil; + [sendFilename setStringValue:@""]; + [filesToSend removeObjectForKey: @(conversationUid.c_str())]; +} + +- (void)viewWillHide { + recordButton.image = [NSImage imageNamed:@"ic_action_audio.png"]; + if(filesToSend[@(conversationUid.c_str())]) { + [sendFilename setStringValue:[self timeFormatted: recordingTime]]; + [sendBox setHidden: NO]; + } else { + [sendFilename setStringValue:@""]; + [sendBox setHidden: YES]; + } + recordingTime = 0; + [timerLabel setStringValue: [self timeFormatted: recordingTime]]; + isRecording = false; + [timerBox setHidden:YES]; + [refreshDurationTimer invalidate]; + refreshDurationTimer = nil; +} + +-(void) hide { + if(self.view.frame.origin.x < 0) { + return; + } + [self viewWillHide]; + [self.view setHidden:YES]; +} + +-(void) show { + if(self.view.frame.origin.x < 0) { + return; + } + [self.view setHidden:NO]; +} + +-(void)setConversationUID:(std::string) convUid conversationModel:(lrc::api::ConversationModel*) convModel { + conversationUid = convUid; + conversationModel = convModel; + [self updateView]; +} + +-(void) updateView { + auto it = getConversationFromUid(conversationUid, *conversationModel); + if (it != conversationModel->allFilteredConversations().end()) { + auto& imgManip = reinterpret_cast(GlobalInstances::pixmapManipulator()); + QVariant photo = imgManip.conversationPhoto(*it, conversationModel->owner, QSize(120, 120), NO); + [personPhoto setImage:QtMac::toNSImage(qvariant_cast(photo))]; + NSString *name = bestNameForConversation(*it, *conversationModel); + [infoLabel setStringValue:name]; + } + [self show]; +} + +-(void) updateDurationLabel +{ + recordingTime++; + [timerLabel setStringValue: [self timeFormatted: recordingTime]]; +} + +- (NSString *)timeFormatted:(int)totalSeconds +{ + int seconds = totalSeconds % 60; + int minutes = (totalSeconds / 60) % 60; + return [NSString stringWithFormat:@"%02d:%02d",minutes, seconds]; +} + +@end diff --git a/src/LrcModelsProtocol.h b/src/LrcModelsProtocol.h index f75848e3a3aa20d6691ddf2eb27825eabe64a695..662f134cfca62662f2df6f7727367425ee6d8c1c 100644 --- a/src/LrcModelsProtocol.h +++ b/src/LrcModelsProtocol.h @@ -22,6 +22,7 @@ namespace lrc { class DataTransferModel; class NewAccountModel; class BehaviorController; + class AVModel; } } @@ -30,9 +31,11 @@ namespace lrc { -(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil dataTransferModel:(const lrc::api::DataTransferModel*) dataTransferModel; -(id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountmodel:(const lrc::api::NewAccountModel*) accountModel; -(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(const lrc::api::NewAccountModel*)accountModel dataTransferModel:(const lrc::api::DataTransferModel*)dataTransferModel behaviourController:(const lrc::api::BehaviorController*) behaviorController; +-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:(const lrc::api::NewAccountModel*)accountModel dataTransferModel:(const lrc::api::DataTransferModel*)dataTransferModel behaviourController:(const lrc::api::BehaviorController*) behaviorController avModel: (const lrc::api::AVModel*)avModel; @property lrc::api::DataTransferModel* dataTransferModel; @property lrc::api::NewAccountModel* accountModel; @property lrc::api::BehaviorController* behaviorController; +@property lrc::api::AVModel* avModel; @end diff --git a/src/MessagesVC.mm b/src/MessagesVC.mm index 90360b57f52b5a35d2072f4dc883d00b5d4766f2..79ebee9d0b0fd95ac3630fe149e82ed8071875cb 100644 --- a/src/MessagesVC.mm +++ b/src/MessagesVC.mm @@ -50,7 +50,6 @@ std::string convUid_; lrc::api::ConversationModel* convModel_; const lrc::api::conversation::Info* cachedConv_; - QMetaObject::Connection newInteractionSignal_; // Both are needed to invalidate cached conversation as pointer @@ -790,6 +789,24 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { return [dateFormatter stringFromDate:msgTime]; } +- (void) updateSendMessageHeight { + NSAttributedString *msgAttString = messageField.attributedStringValue; + NSRect frame = NSMakeRect(0, 0, messageField.frame.size.width, msgAttString.size.height); + NSTextView *tv = [[NSTextView alloc] initWithFrame:frame]; + [[tv textStorage] setAttributedString:msgAttString]; + [tv sizeToFit]; + CGFloat height = tv.frame.size.height + MEESAGE_MARGIN * 2; + CGFloat newHeight = MIN(SEND_PANEL_MAX_HEIGHT, MAX(SEND_PANEL_DEFAULT_HEIGHT, height)); + if(messagesBottomMargin.constant == newHeight) { + return; + } + messagesBottomMargin.constant = newHeight; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.05 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ + [self scrollToBottom]; + sendPanelHeight.constant = newHeight; + }); +} + #pragma mark - NSTableViewDataSource - (NSInteger)numberOfRowsInTableView:(NSTableView *)tableView @@ -877,39 +894,12 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible]) { [[QLPreviewPanel sharedPreviewPanel] orderOut:nil]; } else { - [[QLPreviewPanel sharedPreviewPanel] updateController]; - [QLPreviewPanel sharedPreviewPanel].dataSource = self; - [[QLPreviewPanel sharedPreviewPanel] setAnimationBehavior:NSWindowAnimationBehaviorDocumentWindow]; - [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:nil]; + dispatch_async(dispatch_get_main_queue(), ^{ + [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront:self]; + }); } } -- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel { - return 1; -} - -- (id )previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index { - return [NSURL fileURLWithPath:previewImage]; -} - -- (void) updateSendMessageHeight { - NSAttributedString *msgAttString = messageField.attributedStringValue; - NSRect frame = NSMakeRect(0, 0, messageField.frame.size.width, msgAttString.size.height); - NSTextView *tv = [[NSTextView alloc] initWithFrame:frame]; - [[tv textStorage] setAttributedString:msgAttString]; - [tv sizeToFit]; - CGFloat height = tv.frame.size.height + MEESAGE_MARGIN * 2; - CGFloat newHeight = MIN(SEND_PANEL_MAX_HEIGHT, MAX(SEND_PANEL_DEFAULT_HEIGHT, height)); - if(messagesBottomMargin.constant == newHeight) { - return; - } - messagesBottomMargin.constant = newHeight; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.05 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ - [self scrollToBottom]; - sendPanelHeight.constant = newHeight; - }); -} - - (IBAction)sendMessage:(id)sender { NSString* text = self.message; if (text && text.length > 0) { @@ -971,4 +961,28 @@ typedef NS_ENUM(NSInteger, MessageSequencing) { [self updateSendMessageHeight]; } +#pragma mark - QLPreviewPanelDataSource + +-(void)beginPreviewPanelControl:(QLPreviewPanel *)panel +{ + panel.dataSource = self; +} + +- (void)endPreviewPanelControl:(QLPreviewPanel *)panel { + panel.dataSource = nil; +} + +-(BOOL)acceptsPreviewPanelControl:(QLPreviewPanel *)panel +{ + return YES; +} + +- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel { + return 1; +} + +- (id )previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index { + return [NSURL fileURLWithPath:previewImage]; +} + @end diff --git a/src/RingWindowController.mm b/src/RingWindowController.mm index 971622e4f0c8c714410e17b273caa32793a8ebbf..dbfd097263b70e99b239c108bf246416ae681bec 100644 --- a/src/RingWindowController.mm +++ b/src/RingWindowController.mm @@ -59,6 +59,7 @@ typedef NS_ENUM(NSInteger, ViewState) { SHOW_CONVERSATION_SCREEN, SHOW_CALL_SCREEN, SHOW_SETTINGS_SCREEN, + LEAVE_MESSAGE, }; @interface RingWindowController () @@ -87,24 +88,20 @@ typedef NS_ENUM(NSInteger, ViewState) { ConversationVC* conversationVC; AccountSettingsVC* settingsVC; - // toolbar menu items IBOutlet ChooseAccountVC* chooseAccountVC; } -static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier"; -NSString* const kChangeAccountToolBarItemIdentifier = @"ChangeAccountToolBarItemIdentifier"; -NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemIdentifier"; - -@synthesize dataTransferModel, accountModel, behaviorController; +@synthesize dataTransferModel, accountModel, behaviorController, avModel; @synthesize wizard; --(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:( lrc::api::NewAccountModel*)accountModel dataTransferModel:( lrc::api::DataTransferModel*)dataTransferModel behaviourController:( lrc::api::BehaviorController*) behaviorController +-(id) initWithWindowNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil accountModel:( lrc::api::NewAccountModel*)accountModel dataTransferModel:( lrc::api::DataTransferModel*)dataTransferModel behaviourController:( lrc::api::BehaviorController*) behaviorController avModel: (lrc::api::AVModel*)avModel { if (self = [self initWithWindowNibName:nibNameOrNil]) { self.accountModel = accountModel; self.dataTransferModel = dataTransferModel; self.behaviorController = behaviorController; + self.avModel = avModel; } return self; } @@ -165,6 +162,10 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI [smartViewVC.view setHidden: YES]; [settingsVC show]; break; + case LEAVE_MESSAGE: + [conversationVC showWithAnimation: false]; + [currentCallVC hideWithAnimation: false]; + [conversationVC presentLeaveMessageView]; default: break; } @@ -178,12 +179,9 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI currentCallVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil]; currentCallVC.delegate = self; - conversationVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil delegate:self]; - // toolbar items - //chooseAccountVC = [[ChooseAccountVC alloc] initWithNibName:@"ChooseAccount" bundle:nil model:self.accountModel delegate:self]; + conversationVC = [[ConversationVC alloc] initWithNibName:@"Conversation" bundle:nil delegate:self aVModel:self.avModel]; [chooseAccountVC updateWithDelegate: self andModel:self.accountModel]; settingsVC = [[AccountSettingsVC alloc] initWithNibName:@"AccountSettings" bundle:nil accountmodel:self.accountModel]; - //[self.window.contentView addSubview:[chooseAccountVC view]]; [callView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [[currentCallVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [[conversationVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; @@ -219,6 +217,11 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI } NSToolbar *tb = [[self window] toolbar]; [tb setAllowsUserCustomization:NO]; + + //add messages view controller to responders chain + NSResponder * viewNextResponder = [self nextResponder]; + [self setNextResponder: [conversationVC getMessagesView]]; + [[conversationVC getMessagesView] setNextResponder: viewNextResponder]; } - (void) connect @@ -266,6 +269,15 @@ NSString* const kOpenAccountToolBarItemIdentifier = @"OpenAccountToolBarItemI [smartViewVC selectConversation: convInfo model:accInfo.conversationModel.get()]; [self changeViewTo:SHOW_CONVERSATION_SCREEN]; }); + QObject::connect(self.behaviorController, + &lrc::api::BehaviorController::showLeaveMessageView, + [self](const std::string& accountId, + const lrc::api::conversation::Info& convInfo){ + auto& accInfo = self.accountModel->getAccountInfo(accountId); + [conversationVC setConversationUid:convInfo.uid model:accInfo.conversationModel.get()]; + [smartViewVC selectConversation: convInfo model:accInfo.conversationModel.get()]; + [self changeViewTo:LEAVE_MESSAGE]; + }); } /** diff --git a/ui/Base.lproj/LeaveMessageVC.xib b/ui/Base.lproj/LeaveMessageVC.xib new file mode 100644 index 0000000000000000000000000000000000000000..783ba042fbf833730d134f152cbfc4bbe8cb56fc --- /dev/null +++ b/ui/Base.lproj/LeaveMessageVC.xib @@ -0,0 +1,257 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +