Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 1 | /* |
Alexandre Lision | 4dfcafc | 2015-08-20 12:43:23 -0400 | [diff] [blame] | 2 | * Copyright (C) 2015 Savoir-faire Linux Inc. |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 18 | */ |
| 19 | #import "CurrentCallVC.h" |
| 20 | |
| 21 | #import <QuartzCore/QuartzCore.h> |
| 22 | |
| 23 | #import <call.h> |
| 24 | #import <callmodel.h> |
| 25 | #import <useractionmodel.h> |
| 26 | #import <contactmethod.h> |
| 27 | #import <qabstractitemmodel.h> |
| 28 | #import <QItemSelectionModel> |
| 29 | #import <QItemSelection> |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 30 | #import <video/previewmanager.h> |
| 31 | #import <video/renderer.h> |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 32 | #import <media/text.h> |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 33 | #import <person.h> |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 34 | |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 35 | #import "views/ITProgressIndicator.h" |
Alexandre Lision | 74dd47f | 2015-04-14 13:47:42 -0400 | [diff] [blame] | 36 | #import "views/CallView.h" |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 37 | #import "PersonLinkerVC.h" |
Alexandre Lision | 16d9c0a | 2015-08-10 12:05:15 -0400 | [diff] [blame] | 38 | #import "ChatVC.h" |
Alexandre Lision | 74dd47f | 2015-04-14 13:47:42 -0400 | [diff] [blame] | 39 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 40 | @interface RendererConnectionsHolder : NSObject |
| 41 | |
| 42 | @property QMetaObject::Connection frameUpdated; |
| 43 | @property QMetaObject::Connection started; |
| 44 | @property QMetaObject::Connection stopped; |
| 45 | |
| 46 | @end |
| 47 | |
| 48 | @implementation RendererConnectionsHolder |
| 49 | |
| 50 | @end |
| 51 | |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 52 | @interface CurrentCallVC () <NSPopoverDelegate, ContactLinkedDelegate> |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 53 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 54 | @property (unsafe_unretained) IBOutlet NSTextField *personLabel; |
| 55 | @property (unsafe_unretained) IBOutlet NSTextField *stateLabel; |
| 56 | @property (unsafe_unretained) IBOutlet NSButton *holdOnOffButton; |
| 57 | @property (unsafe_unretained) IBOutlet NSButton *hangUpButton; |
| 58 | @property (unsafe_unretained) IBOutlet NSButton *recordOnOffButton; |
| 59 | @property (unsafe_unretained) IBOutlet NSButton *pickUpButton; |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 60 | @property (unsafe_unretained) IBOutlet NSButton *muteAudioButton; |
| 61 | @property (unsafe_unretained) IBOutlet NSButton *muteVideoButton; |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 62 | @property (unsafe_unretained) IBOutlet NSButton *addContactButton; |
Alexandre Lision | a1eee3c | 2015-08-10 13:44:51 -0400 | [diff] [blame] | 63 | @property (unsafe_unretained) IBOutlet NSView *headerContainer; |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 64 | @property (unsafe_unretained) IBOutlet NSButton *qualityButton; |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 65 | |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 66 | @property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator; |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 67 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 68 | @property (unsafe_unretained) IBOutlet NSTextField *timeSpentLabel; |
| 69 | @property (unsafe_unretained) IBOutlet NSView *controlsPanel; |
| 70 | @property (unsafe_unretained) IBOutlet NSSplitView *splitView; |
| 71 | @property (unsafe_unretained) IBOutlet NSButton *chatButton; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 72 | |
Alexandre Lision | f23ec5a | 2015-07-16 11:24:06 -0400 | [diff] [blame] | 73 | @property (strong) IBOutlet NSPopover *qualityPopOver; |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 74 | @property (strong) NSPopover* addToContactPopover; |
Alexandre Lision | 16d9c0a | 2015-08-10 12:05:15 -0400 | [diff] [blame] | 75 | @property (strong) IBOutlet ChatVC *chatVC; |
Alexandre Lision | f23ec5a | 2015-07-16 11:24:06 -0400 | [diff] [blame] | 76 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 77 | @property QHash<int, NSButton*> actionHash; |
| 78 | |
| 79 | // Video |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 80 | @property (unsafe_unretained) IBOutlet CallView *videoView; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 81 | @property CALayer* videoLayer; |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 82 | @property (unsafe_unretained) IBOutlet NSView *previewView; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 83 | @property CALayer* previewLayer; |
| 84 | |
| 85 | @property RendererConnectionsHolder* previewHolder; |
| 86 | @property RendererConnectionsHolder* videoHolder; |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 87 | @property QMetaObject::Connection videoStarted; |
Alexandre Lision | b65c027 | 2015-07-22 15:51:29 -0400 | [diff] [blame] | 88 | @property QMetaObject::Connection messageConnection; |
| 89 | @property QMetaObject::Connection mediaAddedConnection; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 90 | |
| 91 | @end |
| 92 | |
| 93 | @implementation CurrentCallVC |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 94 | @synthesize personLabel, actionHash, stateLabel, holdOnOffButton, hangUpButton, |
| 95 | recordOnOffButton, pickUpButton, chatButton, timeSpentLabel, |
Alexandre Lision | a1eee3c | 2015-08-10 13:44:51 -0400 | [diff] [blame] | 96 | muteVideoButton, muteAudioButton, controlsPanel, headerContainer, videoView, videoLayer, previewLayer, previewView, splitView, loadingIndicator; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 97 | |
| 98 | @synthesize previewHolder; |
| 99 | @synthesize videoHolder; |
| 100 | |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 101 | - (void) updateAllActions |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 102 | { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 103 | for(int i = 0 ; i <= CallModel::instance().userActionModel()->rowCount() ; i++) { |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 104 | [self updateActionAtIndex:i]; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | - (void) updateActionAtIndex:(int) row |
| 109 | { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 110 | const QModelIndex& idx = CallModel::instance().userActionModel()->index(row,0); |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 111 | UserActionModel::Action action = qvariant_cast<UserActionModel::Action>(idx.data(UserActionModel::Role::ACTION)); |
| 112 | NSButton* a = actionHash[(int) action]; |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 113 | if (a) { |
| 114 | [a setHidden:!(idx.flags() & Qt::ItemIsEnabled)]; |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 115 | [a setState:(idx.data(Qt::CheckStateRole) == Qt::Checked) ? NSOnState : NSOffState]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 116 | } |
| 117 | } |
| 118 | |
| 119 | -(void) updateCall |
| 120 | { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 121 | QModelIndex callIdx = CallModel::instance().selectionModel()->currentIndex(); |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 122 | if (!callIdx.isValid()) { |
| 123 | return; |
| 124 | } |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 125 | [personLabel setStringValue:callIdx.data(Qt::DisplayRole).toString().toNSString()]; |
| 126 | [timeSpentLabel setStringValue:callIdx.data((int)Call::Role::Length).toString().toNSString()]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 127 | |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 128 | auto contactmethod = qvariant_cast<Call*>(callIdx.data(static_cast<int>(Call::Role::Object)))->peerContactMethod(); |
| 129 | BOOL shouldShow = (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()); |
| 130 | [self.addContactButton setHidden:!shouldShow]; |
| 131 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 132 | Call::State state = callIdx.data((int)Call::Role::State).value<Call::State>(); |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 133 | |
| 134 | // Default values for this views |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 135 | [loadingIndicator setHidden:YES]; |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 136 | [self.qualityButton setHidden:YES]; |
| 137 | [self.chatButton setHidden:YES]; |
| 138 | [videoView setShouldAcceptInteractions:NO]; |
| 139 | |
| 140 | |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 141 | [stateLabel setStringValue:callIdx.data((int)Call::Role::HumanStateName).toString().toNSString()]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 142 | switch (state) { |
Alexandre Lision | e6dbf09 | 2015-04-11 17:19:35 -0400 | [diff] [blame] | 143 | case Call::State::DIALING: |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 144 | [loadingIndicator setHidden:NO]; |
Alexandre Lision | e6dbf09 | 2015-04-11 17:19:35 -0400 | [diff] [blame] | 145 | break; |
| 146 | case Call::State::NEW: |
Alexandre Lision | e6dbf09 | 2015-04-11 17:19:35 -0400 | [diff] [blame] | 147 | break; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 148 | case Call::State::INITIALIZATION: |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 149 | [loadingIndicator setHidden:NO]; |
| 150 | break; |
| 151 | case Call::State::CONNECTED: |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 152 | [loadingIndicator setHidden:NO]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 153 | break; |
| 154 | case Call::State::RINGING: |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 155 | break; |
| 156 | case Call::State::CURRENT: |
Alexandre Lision | 74dd47f | 2015-04-14 13:47:42 -0400 | [diff] [blame] | 157 | [videoView setShouldAcceptInteractions:YES]; |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 158 | [self.chatButton setHidden:NO]; |
| 159 | [self.qualityButton setHidden:NO]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 160 | break; |
| 161 | case Call::State::HOLD: |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 162 | break; |
| 163 | case Call::State::BUSY: |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 164 | break; |
| 165 | case Call::State::OVER: |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 166 | case Call::State::FAILURE: |
Alexandre Lision | a1eee3c | 2015-08-10 13:44:51 -0400 | [diff] [blame] | 167 | if(self.splitView.isInFullScreenMode) |
| 168 | [self.splitView exitFullScreenModeWithOptions:nil]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 169 | break; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 170 | } |
| 171 | |
| 172 | } |
| 173 | |
| 174 | - (void)awakeFromNib |
| 175 | { |
| 176 | NSLog(@"INIT CurrentCall VC"); |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 177 | [self.view setWantsLayer:YES]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 178 | [self.view setLayer:[CALayer layer]]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 179 | |
| 180 | [controlsPanel setWantsLayer:YES]; |
| 181 | [controlsPanel setLayer:[CALayer layer]]; |
| 182 | [controlsPanel.layer setZPosition:2.0]; |
| 183 | [controlsPanel.layer setBackgroundColor:[NSColor whiteColor].CGColor]; |
| 184 | |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 185 | actionHash[ (int)UserActionModel::Action::ACCEPT] = pickUpButton; |
| 186 | actionHash[ (int)UserActionModel::Action::HOLD ] = holdOnOffButton; |
| 187 | actionHash[ (int)UserActionModel::Action::RECORD] = recordOnOffButton; |
| 188 | actionHash[ (int)UserActionModel::Action::HANGUP] = hangUpButton; |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 189 | actionHash[ (int)UserActionModel::Action::MUTE_AUDIO] = muteAudioButton; |
| 190 | actionHash[ (int)UserActionModel::Action::MUTE_VIDEO] = muteVideoButton; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 191 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 192 | videoLayer = [CALayer layer]; |
| 193 | [videoView setWantsLayer:YES]; |
| 194 | [videoView setLayer:videoLayer]; |
| 195 | [videoView.layer setBackgroundColor:[NSColor blackColor].CGColor]; |
| 196 | [videoView.layer setFrame:videoView.frame]; |
| 197 | [videoView.layer setContentsGravity:kCAGravityResizeAspect]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 198 | |
| 199 | previewLayer = [CALayer layer]; |
| 200 | [previewView setWantsLayer:YES]; |
| 201 | [previewView setLayer:previewLayer]; |
| 202 | [previewLayer setBackgroundColor:[NSColor blackColor].CGColor]; |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 203 | [previewLayer setContentsGravity:kCAGravityResizeAspectFill]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 204 | [previewLayer setFrame:previewView.frame]; |
| 205 | |
| 206 | [controlsPanel setWantsLayer:YES]; |
| 207 | [controlsPanel setLayer:[CALayer layer]]; |
| 208 | [controlsPanel.layer setBackgroundColor:[NSColor clearColor].CGColor]; |
| 209 | [controlsPanel.layer setFrame:controlsPanel.frame]; |
| 210 | |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 211 | previewHolder = [[RendererConnectionsHolder alloc] init]; |
| 212 | videoHolder = [[RendererConnectionsHolder alloc] init]; |
| 213 | |
Alexandre Lision | f47a256 | 2015-06-15 15:48:29 -0400 | [diff] [blame] | 214 | [loadingIndicator setColor:[NSColor whiteColor]]; |
| 215 | [loadingIndicator setNumberOfLines:100]; |
| 216 | [loadingIndicator setWidthOfLine:2]; |
| 217 | [loadingIndicator setLengthOfLine:2]; |
| 218 | [loadingIndicator setInnerMargin:30]; |
| 219 | |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 220 | [self.qualityPopOver setDelegate:self]; |
Alexandre Lision | a1eee3c | 2015-08-10 13:44:51 -0400 | [diff] [blame] | 221 | [self.videoView setCallDelegate:self]; |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 222 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 223 | [self connect]; |
| 224 | } |
| 225 | |
| 226 | - (void) connect |
| 227 | { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 228 | QObject::connect(CallModel::instance().selectionModel(), |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 229 | &QItemSelectionModel::currentChanged, |
| 230 | [=](const QModelIndex ¤t, const QModelIndex &previous) { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 231 | if(!current.isValid()) { |
| 232 | [self animateOut]; |
| 233 | return; |
| 234 | } |
Alexandre Lision | bb5dbcd | 2015-07-09 16:36:47 -0400 | [diff] [blame] | 235 | |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 236 | auto call = CallModel::instance().getCall(current); |
Alexandre Lision | bb5dbcd | 2015-07-09 16:36:47 -0400 | [diff] [blame] | 237 | if (call->state() == Call::State::HOLD) { |
| 238 | call << Call::Action::HOLD; |
| 239 | } |
| 240 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 241 | [self collapseRightView]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 242 | [self updateCall]; |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 243 | [self updateAllActions]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 244 | [self animateOut]; |
| 245 | }); |
| 246 | |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 247 | QObject::connect(CallModel::instance().userActionModel(), |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 248 | &QAbstractItemModel::dataChanged, |
| 249 | [=](const QModelIndex &topLeft, const QModelIndex &bottomRight) { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 250 | const int first(topLeft.row()),last(bottomRight.row()); |
| 251 | for(int i = first; i <= last;i++) { |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 252 | [self updateActionAtIndex:i]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 253 | } |
| 254 | }); |
| 255 | |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 256 | QObject::connect(&CallModel::instance(), |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 257 | &CallModel::callStateChanged, |
| 258 | [self](Call* c, Call::State state) { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 259 | [self updateCall]; |
| 260 | }); |
| 261 | } |
| 262 | |
Alexandre Lision | b65c027 | 2015-07-22 15:51:29 -0400 | [diff] [blame] | 263 | - (void) monitorIncomingTextMessages:(Media::Text*) media |
| 264 | { |
| 265 | /* connect to incoming chat messages to open the chat view */ |
| 266 | QObject::disconnect(self.messageConnection); |
| 267 | self.messageConnection = QObject::connect(media, |
| 268 | &Media::Text::messageReceived, |
| 269 | [self] (const QMap<QString,QString>& m) { |
| 270 | if([[self splitView] isSubviewCollapsed:[[[self splitView] subviews] objectAtIndex: 1]]) |
| 271 | [self uncollapseRightView]; |
| 272 | }); |
| 273 | } |
| 274 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 275 | -(void) connectVideoSignals |
| 276 | { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 277 | QModelIndex idx = CallModel::instance().selectionModel()->currentIndex(); |
| 278 | Call* call = CallModel::instance().getCall(idx); |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 279 | self.videoStarted = QObject::connect(call, |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 280 | &Call::videoStarted, |
| 281 | [=](Video::Renderer* renderer) { |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 282 | NSLog(@"Video started!"); |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 283 | [self connectVideoRenderer:renderer]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 284 | }); |
| 285 | |
| 286 | if(call->videoRenderer()) |
| 287 | { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 288 | [self connectVideoRenderer:call->videoRenderer()]; |
| 289 | } |
| 290 | |
| 291 | [self connectPreviewRenderer]; |
| 292 | |
| 293 | } |
| 294 | |
| 295 | -(void) connectPreviewRenderer |
| 296 | { |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 297 | QObject::disconnect(previewHolder.frameUpdated); |
| 298 | QObject::disconnect(previewHolder.stopped); |
| 299 | QObject::disconnect(previewHolder.started); |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 300 | previewHolder.started = QObject::connect(&Video::PreviewManager::instance(), |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 301 | &Video::PreviewManager::previewStarted, |
| 302 | [=](Video::Renderer* renderer) { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 303 | QObject::disconnect(previewHolder.frameUpdated); |
| 304 | previewHolder.frameUpdated = QObject::connect(renderer, |
| 305 | &Video::Renderer::frameUpdated, |
| 306 | [=]() { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 307 | [self renderer:Video::PreviewManager::instance().previewRenderer() |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 308 | renderFrameForView:previewView]; |
| 309 | }); |
| 310 | }); |
| 311 | |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 312 | previewHolder.stopped = QObject::connect(&Video::PreviewManager::instance(), |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 313 | &Video::PreviewManager::previewStopped, |
| 314 | [=](Video::Renderer* renderer) { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 315 | QObject::disconnect(previewHolder.frameUpdated); |
| 316 | [previewView.layer setContents:nil]; |
| 317 | }); |
| 318 | |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 319 | previewHolder.frameUpdated = QObject::connect(Video::PreviewManager::instance().previewRenderer(), |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 320 | &Video::Renderer::frameUpdated, |
| 321 | [=]() { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 322 | [self renderer:Video::PreviewManager::instance().previewRenderer() |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 323 | renderFrameForView:previewView]; |
| 324 | }); |
| 325 | } |
| 326 | |
| 327 | -(void) connectVideoRenderer: (Video::Renderer*)renderer |
| 328 | { |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 329 | QObject::disconnect(videoHolder.frameUpdated); |
| 330 | QObject::disconnect(videoHolder.started); |
| 331 | QObject::disconnect(videoHolder.stopped); |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 332 | videoHolder.frameUpdated = QObject::connect(renderer, |
| 333 | &Video::Renderer::frameUpdated, |
| 334 | [=]() { |
| 335 | [self renderer:renderer renderFrameForView:videoView]; |
| 336 | }); |
| 337 | |
| 338 | videoHolder.started = QObject::connect(renderer, |
| 339 | &Video::Renderer::started, |
| 340 | [=]() { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 341 | QObject::disconnect(videoHolder.frameUpdated); |
| 342 | videoHolder.frameUpdated = QObject::connect(renderer, |
| 343 | &Video::Renderer::frameUpdated, |
| 344 | [=]() { |
| 345 | [self renderer:renderer renderFrameForView:videoView]; |
| 346 | }); |
| 347 | }); |
| 348 | |
| 349 | videoHolder.stopped = QObject::connect(renderer, |
| 350 | &Video::Renderer::stopped, |
| 351 | [=]() { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 352 | QObject::disconnect(videoHolder.frameUpdated); |
| 353 | [videoView.layer setContents:nil]; |
| 354 | }); |
| 355 | } |
| 356 | |
| 357 | -(void) renderer: (Video::Renderer*)renderer renderFrameForView:(NSView*) view |
| 358 | { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 359 | QSize res = renderer->size(); |
| 360 | |
Alexandre Lision | 6731e13 | 2015-10-14 14:29:06 -0400 | [diff] [blame] | 361 | auto frame_ptr = renderer->currentFrame(); |
| 362 | auto frame_data = frame_ptr.ptr; |
| 363 | if (!frame_data) |
| 364 | return; |
| 365 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 366 | |
| 367 | CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); |
Alexandre Lision | 6731e13 | 2015-10-14 14:29:06 -0400 | [diff] [blame] | 368 | CGContextRef newContext = CGBitmapContextCreate(frame_data, |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 369 | res.width(), |
| 370 | res.height(), |
| 371 | 8, |
| 372 | 4*res.width(), |
| 373 | colorSpace, |
| 374 | kCGImageAlphaPremultipliedLast); |
| 375 | |
| 376 | |
| 377 | CGImageRef newImage = CGBitmapContextCreateImage(newContext); |
| 378 | |
| 379 | /*We release some components*/ |
| 380 | CGContextRelease(newContext); |
| 381 | CGColorSpaceRelease(colorSpace); |
| 382 | |
| 383 | [CATransaction begin]; |
| 384 | view.layer.contents = (__bridge id)newImage; |
| 385 | [CATransaction commit]; |
| 386 | |
| 387 | CFRelease(newImage); |
| 388 | } |
| 389 | |
| 390 | - (void) initFrame |
| 391 | { |
| 392 | [self.view setFrame:self.view.superview.bounds]; |
| 393 | [self.view setHidden:YES]; |
| 394 | self.view.layer.position = self.view.frame.origin; |
Alexandre Lision | bb5dbcd | 2015-07-09 16:36:47 -0400 | [diff] [blame] | 395 | [self collapseRightView]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | # pragma private IN/OUT animations |
| 399 | |
| 400 | -(void) animateIn |
| 401 | { |
| 402 | NSLog(@"animateIn"); |
| 403 | CGRect frame = CGRectOffset(self.view.superview.bounds, -self.view.superview.bounds.size.width, 0); |
| 404 | [self.view setHidden:NO]; |
| 405 | |
| 406 | [CATransaction begin]; |
| 407 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; |
| 408 | [animation setFromValue:[NSValue valueWithPoint:frame.origin]]; |
| 409 | [animation setToValue:[NSValue valueWithPoint:self.view.superview.bounds.origin]]; |
| 410 | [animation setDuration:0.2f]; |
| 411 | [animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]]; |
| 412 | [CATransaction setCompletionBlock:^{ |
Alexandre Lision | a1eee3c | 2015-08-10 13:44:51 -0400 | [diff] [blame] | 413 | |
| 414 | // when call comes in we want to show the controls/header |
| 415 | [self mouseIsMoving:YES]; |
| 416 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 417 | [self connectVideoSignals]; |
Alexandre Lision | b65c027 | 2015-07-22 15:51:29 -0400 | [diff] [blame] | 418 | /* check if text media is already present */ |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 419 | if(!CallModel::instance().selectedCall()) |
Alexandre Lision | 4dfcafc | 2015-08-20 12:43:23 -0400 | [diff] [blame] | 420 | return; |
Alexandre Lision | 21666f3 | 2015-09-22 17:04:36 -0400 | [diff] [blame] | 421 | |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 422 | QObject::connect(CallModel::instance().selectedCall(), |
Alexandre Lision | 21666f3 | 2015-09-22 17:04:36 -0400 | [diff] [blame] | 423 | &Call::changed, |
| 424 | [=]() { |
| 425 | [self updateCall]; |
| 426 | }); |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 427 | if (CallModel::instance().selectedCall()->hasMedia(Media::Media::Type::TEXT, Media::Media::Direction::IN)) { |
| 428 | Media::Text *text = CallModel::instance().selectedCall()->firstMedia<Media::Text>(Media::Media::Direction::IN); |
Alexandre Lision | b65c027 | 2015-07-22 15:51:29 -0400 | [diff] [blame] | 429 | [self monitorIncomingTextMessages:text]; |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 430 | } else if (CallModel::instance().selectedCall()->hasMedia(Media::Media::Type::TEXT, Media::Media::Direction::OUT)) { |
| 431 | Media::Text *text = CallModel::instance().selectedCall()->firstMedia<Media::Text>(Media::Media::Direction::OUT); |
Alexandre Lision | b65c027 | 2015-07-22 15:51:29 -0400 | [diff] [blame] | 432 | [self monitorIncomingTextMessages:text]; |
| 433 | } else { |
| 434 | /* monitor media for messaging text messaging */ |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 435 | self.mediaAddedConnection = QObject::connect(CallModel::instance().selectedCall(), |
Alexandre Lision | b65c027 | 2015-07-22 15:51:29 -0400 | [diff] [blame] | 436 | &Call::mediaAdded, |
| 437 | [self] (Media::Media* media) { |
| 438 | if (media->type() == Media::Media::Type::TEXT) { [self monitorIncomingTextMessages:(Media::Text*)media]; |
| 439 | QObject::disconnect(self.mediaAddedConnection); |
| 440 | } |
| 441 | }); |
| 442 | } |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 443 | }]; |
| 444 | [self.view.layer addAnimation:animation forKey:animation.keyPath]; |
| 445 | |
| 446 | [CATransaction commit]; |
| 447 | } |
| 448 | |
| 449 | -(void) cleanUp |
| 450 | { |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 451 | QObject::disconnect(videoHolder.frameUpdated); |
| 452 | QObject::disconnect(videoHolder.started); |
| 453 | QObject::disconnect(videoHolder.stopped); |
| 454 | QObject::disconnect(previewHolder.frameUpdated); |
| 455 | QObject::disconnect(previewHolder.stopped); |
| 456 | QObject::disconnect(previewHolder.started); |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 457 | [videoView.layer setContents:nil]; |
| 458 | [previewView.layer setContents:nil]; |
| 459 | } |
| 460 | |
| 461 | -(void) animateOut |
| 462 | { |
| 463 | NSLog(@"animateOut"); |
| 464 | if(self.view.frame.origin.x < 0) { |
| 465 | NSLog(@"Already hidden"); |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 466 | if (CallModel::instance().selectionModel()->currentIndex().isValid()) { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 467 | [self animateIn]; |
| 468 | } |
| 469 | return; |
| 470 | } |
| 471 | |
| 472 | CGRect frame = CGRectOffset(self.view.frame, -self.view.frame.size.width, 0); |
| 473 | [CATransaction begin]; |
| 474 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"position"]; |
| 475 | [animation setFromValue:[NSValue valueWithPoint:self.view.frame.origin]]; |
| 476 | [animation setToValue:[NSValue valueWithPoint:frame.origin]]; |
| 477 | [animation setDuration:0.2f]; |
| 478 | [animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]]; |
| 479 | |
| 480 | [CATransaction setCompletionBlock:^{ |
| 481 | [self.view setHidden:YES]; |
Alexandre Lision | ef6333a | 2015-03-24 12:30:31 -0400 | [diff] [blame] | 482 | // first make sure everything is disconnected |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 483 | [self cleanUp]; |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 484 | if (CallModel::instance().selectionModel()->currentIndex().isValid()) { |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 485 | [self animateIn]; |
| 486 | } |
| 487 | }]; |
| 488 | [self.view.layer addAnimation:animation forKey:animation.keyPath]; |
Alexandre Lision | a1c6d75 | 2015-06-23 12:27:38 -0400 | [diff] [blame] | 489 | |
| 490 | [self.view.layer setPosition:frame.origin]; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 491 | [CATransaction commit]; |
| 492 | } |
| 493 | |
| 494 | /** |
| 495 | * Debug purpose |
| 496 | */ |
| 497 | -(void) dumpFrame:(CGRect) frame WithName:(NSString*) name |
| 498 | { |
| 499 | NSLog(@"frame %@ : %f %f %f %f \n\n",name ,frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); |
| 500 | } |
| 501 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 502 | -(void)collapseRightView |
| 503 | { |
| 504 | NSView *right = [[splitView subviews] objectAtIndex:1]; |
| 505 | NSView *left = [[splitView subviews] objectAtIndex:0]; |
| 506 | NSRect leftFrame = [left frame]; |
| 507 | [right setHidden:YES]; |
| 508 | [splitView display]; |
| 509 | } |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 510 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 511 | -(void)uncollapseRightView |
| 512 | { |
| 513 | NSView *left = [[splitView subviews] objectAtIndex:0]; |
| 514 | NSView *right = [[splitView subviews] objectAtIndex:1]; |
| 515 | [right setHidden:NO]; |
| 516 | |
| 517 | CGFloat dividerThickness = [splitView dividerThickness]; |
| 518 | |
| 519 | // get the different frames |
| 520 | NSRect leftFrame = [left frame]; |
| 521 | NSRect rightFrame = [right frame]; |
| 522 | |
| 523 | leftFrame.size.width = (leftFrame.size.width - rightFrame.size.width - dividerThickness); |
| 524 | rightFrame.origin.x = leftFrame.size.width + dividerThickness; |
| 525 | [left setFrameSize:leftFrame.size]; |
| 526 | [right setFrame:rightFrame]; |
| 527 | [splitView display]; |
Alexandre Lision | 16d9c0a | 2015-08-10 12:05:15 -0400 | [diff] [blame] | 528 | |
| 529 | [self.chatVC takeFocus]; |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 530 | } |
| 531 | |
| 532 | |
| 533 | #pragma mark - Button methods |
| 534 | |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 535 | - (IBAction)addToContact:(NSButton*) sender { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 536 | auto contactmethod = CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex())->peerContactMethod(); |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 537 | |
| 538 | if (self.addToContactPopover != nullptr) { |
| 539 | [self.addToContactPopover performClose:self]; |
| 540 | self.addToContactPopover = NULL; |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 541 | [self.addContactButton setState:NSOffState]; |
| 542 | |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 543 | } else if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) { |
| 544 | auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil]; |
| 545 | [editorVC setMethodToLink:contactmethod]; |
| 546 | [editorVC setContactLinkedDelegate:self]; |
| 547 | self.addToContactPopover = [[NSPopover alloc] init]; |
| 548 | [self.addToContactPopover setContentSize:editorVC.view.frame.size]; |
| 549 | [self.addToContactPopover setContentViewController:editorVC]; |
| 550 | [self.addToContactPopover setAnimates:YES]; |
| 551 | [self.addToContactPopover setBehavior:NSPopoverBehaviorTransient]; |
| 552 | [self.addToContactPopover setDelegate:self]; |
| 553 | |
| 554 | [self.addToContactPopover showRelativeToRect:sender.bounds ofView:sender preferredEdge:NSMaxXEdge]; |
| 555 | } |
| 556 | } |
| 557 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 558 | - (IBAction)hangUp:(id)sender { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 559 | CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex()) << Call::Action::REFUSE; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | - (IBAction)accept:(id)sender { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 563 | CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex()) << Call::Action::ACCEPT; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | - (IBAction)toggleRecording:(id)sender { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 567 | CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex()) << Call::Action::RECORD_AUDIO; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 568 | } |
| 569 | |
| 570 | - (IBAction)toggleHold:(id)sender { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 571 | CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex()) << Call::Action::HOLD; |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 572 | } |
| 573 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 574 | -(IBAction)toggleChat:(id)sender; |
| 575 | { |
| 576 | BOOL rightViewCollapsed = [[self splitView] isSubviewCollapsed:[[[self splitView] subviews] objectAtIndex: 1]]; |
| 577 | if (rightViewCollapsed) { |
| 578 | [self uncollapseRightView]; |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 579 | CallModel::instance().getCall(CallModel::instance().selectionModel()->currentIndex())->addOutgoingMedia<Media::Text>(); |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 580 | } else { |
| 581 | [self collapseRightView]; |
| 582 | } |
| 583 | [chatButton setState:rightViewCollapsed]; |
| 584 | } |
| 585 | |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 586 | - (IBAction)muteAudio:(id)sender |
| 587 | { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 588 | UserActionModel* uam = CallModel::instance().userActionModel(); |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 589 | uam << UserActionModel::Action::MUTE_AUDIO; |
| 590 | } |
| 591 | |
| 592 | - (IBAction)muteVideo:(id)sender |
| 593 | { |
Alexandre Lision | d3aa3ad | 2015-10-23 14:28:41 -0400 | [diff] [blame^] | 594 | UserActionModel* uam = CallModel::instance().userActionModel(); |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 595 | uam << UserActionModel::Action::MUTE_VIDEO; |
| 596 | } |
Alexandre Lision | f23ec5a | 2015-07-16 11:24:06 -0400 | [diff] [blame] | 597 | - (IBAction)displayQualityPopUp:(id)sender { |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 598 | |
Alexandre Lision | f23ec5a | 2015-07-16 11:24:06 -0400 | [diff] [blame] | 599 | [self.qualityPopOver showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge]; |
| 600 | } |
Alexandre Lision | d18fa27 | 2015-06-15 11:18:03 -0400 | [diff] [blame] | 601 | |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 602 | #pragma mark - NSPopOverDelegate |
| 603 | |
Alexandre Lision | 266fca0 | 2015-09-28 14:47:05 -0400 | [diff] [blame] | 604 | - (void)popoverWillClose:(NSNotification *)notification |
| 605 | { |
| 606 | [self.qualityButton setState:NSOffState]; |
| 607 | [self.addContactButton setState:NSOffState]; |
| 608 | } |
| 609 | |
Alexandre Lision | 2db8f47 | 2015-07-22 15:05:46 -0400 | [diff] [blame] | 610 | - (void)popoverDidClose:(NSNotification *)notification |
| 611 | { |
| 612 | if (self.addToContactPopover != nullptr) { |
| 613 | [self.addToContactPopover performClose:self]; |
| 614 | self.addToContactPopover = NULL; |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | #pragma mark - ContactLinkedDelegate |
| 619 | |
| 620 | - (void)contactLinked |
| 621 | { |
| 622 | if (self.addToContactPopover != nullptr) { |
| 623 | [self.addToContactPopover performClose:self]; |
| 624 | self.addToContactPopover = NULL; |
| 625 | } |
| 626 | } |
| 627 | |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 628 | #pragma mark - NSSplitViewDelegate |
| 629 | |
| 630 | /* Return YES if the subview should be collapsed because the user has double-clicked on an adjacent divider. If a split view has a delegate, and the delegate responds to this message, it will be sent once for the subview before a divider when the user double-clicks on that divider, and again for the subview after the divider, but only if the delegate returned YES when sent -splitView:canCollapseSubview: for the subview in question. When the delegate indicates that both subviews should be collapsed NSSplitView's behavior is undefined. |
| 631 | */ |
| 632 | - (BOOL)splitView:(NSSplitView *)splitView shouldCollapseSubview:(NSView *)subview forDoubleClickOnDividerAtIndex:(NSInteger)dividerIndex; |
| 633 | { |
| 634 | NSView* rightView = [[splitView subviews] objectAtIndex:1]; |
| 635 | return ([subview isEqual:rightView]); |
| 636 | } |
| 637 | |
| 638 | |
| 639 | - (BOOL)splitView:(NSSplitView *)splitView canCollapseSubview:(NSView *)subview; |
| 640 | { |
| 641 | NSView* rightView = [[splitView subviews] objectAtIndex:1]; |
| 642 | return ([subview isEqual:rightView]); |
| 643 | } |
| 644 | |
| 645 | |
Alexandre Lision | a1eee3c | 2015-08-10 13:44:51 -0400 | [diff] [blame] | 646 | # pragma mark - CallnDelegate |
Alexandre Lision | 58cab67 | 2015-06-09 15:25:40 -0400 | [diff] [blame] | 647 | |
| 648 | - (void) callShouldToggleFullScreen |
| 649 | { |
| 650 | if(self.splitView.isInFullScreenMode) |
| 651 | [self.splitView exitFullScreenModeWithOptions:nil]; |
| 652 | else { |
| 653 | NSApplicationPresentationOptions options = NSApplicationPresentationDefault +NSApplicationPresentationAutoHideDock + |
| 654 | NSApplicationPresentationAutoHideMenuBar + NSApplicationPresentationAutoHideToolbar; |
| 655 | NSDictionary *opts = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:options], |
| 656 | NSFullScreenModeApplicationPresentationOptions, nil]; |
| 657 | |
| 658 | [self.splitView enterFullScreenMode:[NSScreen mainScreen] withOptions:opts]; |
| 659 | } |
| 660 | } |
| 661 | |
Alexandre Lision | a1eee3c | 2015-08-10 13:44:51 -0400 | [diff] [blame] | 662 | -(void) mouseIsMoving:(BOOL) move |
| 663 | { |
| 664 | [[controlsPanel animator] setAlphaValue:move]; // fade out |
| 665 | [[headerContainer animator] setAlphaValue:move]; |
| 666 | } |
| 667 | |
Alexandre Lision | c514805 | 2015-03-04 15:10:35 -0500 | [diff] [blame] | 668 | @end |