Skip to content
Snippets Groups Projects
Commit 81afce70 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk Committed by Andreas Traczyk
Browse files

UI: call view background


- update background for call view
- remove unused buttons

Change-Id: Ib63a7bcdf95ec893c9b8dc883b5db6b381a08559
Reviewed-by: default avatarAndreas Traczyk <andreas.traczyk@savoirfairelinux.com>
parent 194f21ec
No related branches found
No related tags found
No related merge requests found
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#import "AppDelegate.h" #import "AppDelegate.h"
#import "views/ITProgressIndicator.h" #import "views/ITProgressIndicator.h"
#import "views/CallView.h" #import "views/CallView.h"
#import "views/NSColor+RingTheme.h"
#import "delegates/ImageManipulationDelegate.h" #import "delegates/ImageManipulationDelegate.h"
#import "PersonLinkerVC.h" #import "PersonLinkerVC.h"
#import "ChatVC.h" #import "ChatVC.h"
...@@ -68,6 +69,8 @@ ...@@ -68,6 +69,8 @@
// Main container // Main container
@property (unsafe_unretained) IBOutlet NSSplitView* splitView; @property (unsafe_unretained) IBOutlet NSSplitView* splitView;
@property (unsafe_unretained) IBOutlet NSImageView* backgroundImage;
@property (unsafe_unretained) IBOutlet NSBox* bluerBackgroundEffect;
// Header info // Header info
@property (unsafe_unretained) IBOutlet NSView* headerContainer; @property (unsafe_unretained) IBOutlet NSView* headerContainer;
...@@ -97,11 +100,7 @@ ...@@ -97,11 +100,7 @@
@property (unsafe_unretained) IBOutlet NSView* advancedPanel; @property (unsafe_unretained) IBOutlet NSView* advancedPanel;
@property (unsafe_unretained) IBOutlet IconButton* advancedButton; @property (unsafe_unretained) IBOutlet IconButton* advancedButton;
@property (assign) IBOutlet NSLayoutConstraint* callRecordButtonMarginLeft;
// Join call panel
@property (unsafe_unretained) IBOutlet NSView* joinPanel;
@property (unsafe_unretained) IBOutlet NSButton* mergeCallsButton;
@property (strong) NSPopover* addToContactPopover; @property (strong) NSPopover* addToContactPopover;
@property (strong) NSPopover* brokerPopoverVC; @property (strong) NSPopover* brokerPopoverVC;
...@@ -116,6 +115,13 @@ ...@@ -116,6 +115,13 @@
@property (unsafe_unretained) IBOutlet NSView* outgoingPanel; @property (unsafe_unretained) IBOutlet NSView* outgoingPanel;
@property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator; @property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator;
// audio only view
@property (unsafe_unretained) IBOutlet NSView* audioCallView;
@property (unsafe_unretained) IBOutlet NSImageView* audioCallPhoto;
@property (unsafe_unretained) IBOutlet NSTextField* audioCallTime;
@property (unsafe_unretained) IBOutlet NSTextField* audioCallPersonLabel;
@property (unsafe_unretained) IBOutlet NSTextField* audioCallPersonId;
// Video // Video
@property (unsafe_unretained) IBOutlet CallView *videoView; @property (unsafe_unretained) IBOutlet CallView *videoView;
@property (unsafe_unretained) IBOutlet NSView *previewView; @property (unsafe_unretained) IBOutlet NSView *previewView;
...@@ -133,8 +139,9 @@ ...@@ -133,8 +139,9 @@
@synthesize personLabel, personPhoto, stateLabel, holdOnOffButton, hangUpButton, @synthesize personLabel, personPhoto, stateLabel, holdOnOffButton, hangUpButton,
recordOnOffButton, pickUpButton, chatButton, transferButton, addParticipantButton, timeSpentLabel, recordOnOffButton, pickUpButton, chatButton, transferButton, addParticipantButton, timeSpentLabel,
muteVideoButton, muteAudioButton, controlsPanel, advancedPanel, advancedButton, headerContainer, videoView, muteVideoButton, muteAudioButton, controlsPanel, advancedPanel, advancedButton, headerContainer, videoView,
incomingDisplayName, incomingPersonPhoto, previewView, splitView, loadingIndicator, ringingPanel, joinPanel, incomingDisplayName, incomingPersonPhoto, previewView, splitView, loadingIndicator, ringingPanel,
outgoingPanel, outgoingPersonLabel, outgoingStateLabel, outgoingPhoto, outgoingId; outgoingPanel, outgoingPersonLabel, outgoingStateLabel, outgoingPhoto, outgoingId,
callRecordButtonMarginLeft, audioCallView, audioCallPhoto, audioCallTime, audioCallPersonLabel, audioCallPersonId, backgroundImage, bluerBackgroundEffect;
@synthesize previewHolder; @synthesize previewHolder;
@synthesize videoHolder; @synthesize videoHolder;
...@@ -157,9 +164,9 @@ ...@@ -157,9 +164,9 @@
accountInfo_ = account; accountInfo_ = account;
[self.chatVC setConversationUid:convUid model:account->conversationModel.get()]; [self.chatVC setConversationUid:convUid model:account->conversationModel.get()];
auto currentCall = callModel->getCall(callUid_); auto currentCall = callModel->getCall(callUid_);
if(currentCall.isAudioOnly) { [muteVideoButton setHidden: currentCall.isAudioOnly ? YES: NO];
muteVideoButton.image = [NSImage imageNamed:@"ic_action_mute_video.png"]; callRecordButtonMarginLeft.constant = currentCall.isAudioOnly ? -40.0f: 10.0f;
} [previewView setHidden: YES];
videoView.callId = callUid; videoView.callId = callUid;
} }
...@@ -189,6 +196,10 @@ ...@@ -189,6 +196,10 @@
[self.videoView setCallDelegate:self]; [self.videoView setCallDelegate:self];
CGColor* color = [[[NSColor blackColor] colorWithAlphaComponent:0.2] CGColor]; CGColor* color = [[[NSColor blackColor] colorWithAlphaComponent:0.2] CGColor];
[headerContainer.layer setBackgroundColor:color]; [headerContainer.layer setBackgroundColor:color];
[bluerBackgroundEffect setWantsLayer:YES];
bluerBackgroundEffect.alphaValue = 0.6;
[audioCallView setWantsLayer:YES];
[audioCallView.layer setBackgroundColor: [[NSColor clearColor] CGColor]];
} }
-(void) updateDurationLabel -(void) updateDurationLabel
...@@ -200,7 +211,11 @@ ...@@ -200,7 +211,11 @@
if (callStatus != lrc::api::call::Status::ENDED && if (callStatus != lrc::api::call::Status::ENDED &&
callStatus != lrc::api::call::Status::TERMINATING && callStatus != lrc::api::call::Status::TERMINATING &&
callStatus != lrc::api::call::Status::INVALID) { callStatus != lrc::api::call::Status::INVALID) {
if(callModel->getCall(callUid_).isAudioOnly) {
[audioCallTime setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())];
} else {
[timeSpentLabel setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())]; [timeSpentLabel setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())];
}
return; return;
} }
} }
...@@ -211,6 +226,7 @@ ...@@ -211,6 +226,7 @@
[refreshDurationTimer invalidate]; [refreshDurationTimer invalidate];
refreshDurationTimer = nil; refreshDurationTimer = nil;
[timeSpentLabel setHidden:YES]; [timeSpentLabel setHidden:YES];
[audioCallView setHidden:YES];
} }
-(void) updateCall -(void) updateCall
...@@ -230,14 +246,17 @@ ...@@ -230,14 +246,17 @@
NSString* bestName = bestNameForConversation(*convIt, *accountInfo_->conversationModel); NSString* bestName = bestNameForConversation(*convIt, *accountInfo_->conversationModel);
[personLabel setStringValue:bestName]; [personLabel setStringValue:bestName];
[outgoingPersonLabel setStringValue:bestName]; [outgoingPersonLabel setStringValue:bestName];
[audioCallPersonLabel setStringValue:bestName];
NSString* ringID = bestIDForConversation(*convIt, *accountInfo_->conversationModel); NSString* ringID = bestIDForConversation(*convIt, *accountInfo_->conversationModel);
if([bestName isEqualToString:ringID]) { if([bestName isEqualToString:ringID]) {
ringID = @""; ringID = @"";
} }
[outgoingId setStringValue:ringID]; [outgoingId setStringValue:ringID];
[audioCallPersonId setStringValue:ringID];
} }
[timeSpentLabel setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())]; [timeSpentLabel setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())];
[audioCallTime setStringValue:@(callModel->getFormattedCallDuration(callUid_).c_str())];
if (refreshDurationTimer == nil) if (refreshDurationTimer == nil)
refreshDurationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 refreshDurationTimer = [NSTimer scheduledTimerWithTimeInterval:1.0
target:self target:self
...@@ -254,6 +273,7 @@ ...@@ -254,6 +273,7 @@
[controlsPanel setHidden:NO]; [controlsPanel setHidden:NO];
[headerContainer setHidden:NO]; [headerContainer setHidden:NO];
[chatButton setHidden:NO]; [chatButton setHidden:NO];
[self setBackground];
using Status = lrc::api::call::Status; using Status = lrc::api::call::Status;
switch (currentCall.status) { switch (currentCall.status) {
...@@ -285,10 +305,11 @@ ...@@ -285,10 +305,11 @@
case Status::INACTIVE: case Status::INACTIVE:
case Status::IN_PROGRESS: case Status::IN_PROGRESS:
// change constraints (uncollapse avatar) // change constraints (uncollapse avatar)
[self setupContactInfo:personPhoto]; if(currentCall.isAudioOnly) {
[timeSpentLabel setHidden:NO]; [self setUpAudioOnlyView];
[outgoingPhoto setHidden:YES]; } else {
[headerContainer setHidden:NO]; [self setUpVideoCallView];
}
break; break;
case Status::CONNECTED: case Status::CONNECTED:
break; break;
...@@ -303,15 +324,64 @@ ...@@ -303,15 +324,64 @@
} }
-(void) setupContactInfo:(NSImageView*)imageView -(void) setUpVideoCallView {
{ [self setupContactInfo:personPhoto];
[timeSpentLabel setHidden:NO];
[outgoingPhoto setHidden:YES];
[headerContainer setHidden:NO];
[previewView setHidden: NO];
[bluerBackgroundEffect setHidden:YES];
[bluerBackgroundEffect.layer setBackgroundFilters: nil];
[backgroundImage setHidden:YES];
}
-(void) setUpAudioOnlyView {
[audioCallView setHidden:NO];
[headerContainer setHidden:YES];
[audioCallPhoto setImage: [self getContactImageOfSize:120.0 withDefaultAvatar:YES]];
}
-(void) setBackground {
auto* convModel = accountInfo_->conversationModel.get(); auto* convModel = accountInfo_->conversationModel.get();
auto it = getConversationFromUid(convUid_, *convModel); auto it = getConversationFromUid(convUid_, *convModel);
if (it != convModel->allFilteredConversations().end()) { NSImage *image= [self getContactImageOfSize:120.0 withDefaultAvatar:NO];
if(image) {
CIFilter* bluerFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
[bluerFilter setDefaults];
[bluerFilter setValue:[NSNumber numberWithFloat: 30] forKey:@"inputRadius"];
[bluerBackgroundEffect.layer setBackgroundFilters:@[bluerFilter]];
[backgroundImage setImage: image];
[backgroundImage setHidden:NO];
} else {
// [bluerBackgroundEffect setHidden:YES];
[bluerBackgroundEffect.layer setBackgroundFilters:nil];
[bluerBackgroundEffect setFillColor:[NSColor ringDarkGrey]];
[backgroundImage setHidden:YES];
[backgroundImage setImage:nil];
// [videoView.layer setBackgroundColor:[[NSColor ringDarkGrey] CGColor]];
}
}
-(NSImage *) getContactImageOfSize: (double) size withDefaultAvatar:(BOOL) shouldDrawDefault {
auto* convModel = accountInfo_->conversationModel.get();
auto convIt = getConversationFromUid(convUid_, *convModel);
if (convIt == convModel->allFilteredConversations().end()) {
return nil;
}
if(shouldDrawDefault) {
auto& imgManip = reinterpret_cast<Interfaces::ImageManipulationDelegate&>(GlobalInstances::pixmapManipulator()); auto& imgManip = reinterpret_cast<Interfaces::ImageManipulationDelegate&>(GlobalInstances::pixmapManipulator());
QVariant photo = imgManip.conversationPhoto(*it, *accountInfo_, QSize(120, 120), NO); QVariant photo = imgManip.conversationPhoto(*convIt, *accountInfo_, QSize(size, size), NO);
[imageView setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))]; return QtMac::toNSImage(qvariant_cast<QPixmap>(photo));
} }
auto contact = accountInfo_->contactModel->getContact(convIt->participants[0]);
NSData *imageData = [[NSData alloc] initWithBase64EncodedString:@(contact.profileInfo.avatar.c_str()) options:NSDataBase64DecodingIgnoreUnknownCharacters];
return [[NSImage alloc] initWithData:imageData];
}
-(void) setupContactInfo:(NSImageView*)imageView
{
[imageView setImage: [self getContactImageOfSize:120.0 withDefaultAvatar:YES]];
} }
-(void) setupIncoming:(const std::string&) callId -(void) setupIncoming:(const std::string&) callId
...@@ -332,9 +402,7 @@ ...@@ -332,9 +402,7 @@
[headerContainer setHidden:YES]; [headerContainer setHidden:YES];
auto it = getConversationFromUid(convUid_, *convModel); auto it = getConversationFromUid(convUid_, *convModel);
if (it != convModel->allFilteredConversations().end()) { if (it != convModel->allFilteredConversations().end()) {
auto& imgManip = reinterpret_cast<Interfaces::ImageManipulationDelegate&>(GlobalInstances::pixmapManipulator()); [incomingPersonPhoto setImage: [self getContactImageOfSize:120.0 withDefaultAvatar:YES]];
QVariant photo = imgManip.conversationPhoto(*it, *accountInfo_);
[incomingPersonPhoto setImage:QtMac::toNSImage(qvariant_cast<QPixmap>(photo))];
[incomingDisplayName setStringValue:bestNameForConversation(*it, *convModel)]; [incomingDisplayName setStringValue:bestNameForConversation(*it, *convModel)];
} }
} }
...@@ -344,7 +412,6 @@ ...@@ -344,7 +412,6 @@
{ {
[videoView setShouldAcceptInteractions:YES]; [videoView setShouldAcceptInteractions:YES];
[self.chatButton setHidden:NO]; [self.chatButton setHidden:NO];
[joinPanel setHidden:YES];
[self.addParticipantButton setHidden:NO]; [self.addParticipantButton setHidden:NO];
[self.transferButton setHidden:YES]; [self.transferButton setHidden:YES];
} }
...@@ -563,30 +630,31 @@ ...@@ -563,30 +630,31 @@
QObject::disconnect(previewHolder.started); QObject::disconnect(previewHolder.started);
QObject::disconnect(self.messageConnection); QObject::disconnect(self.messageConnection);
[previewView.layer setContents:nil]; [previewView.layer setContents:nil];
[previewView setHidden: YES];
[videoView setLayer:[CALayer layer]]; [videoView setLayer:[CALayer layer]];
[videoView.layer setBackgroundColor:[[NSColor blackColor] CGColor]]; [videoView.layer setBackgroundColor:[[NSColor blackColor] CGColor]];
[_brokerPopoverVC performClose:self];
[self.addToContactPopover performClose:self];
[self.chatButton setHidden:YES]; [self.chatButton setHidden:YES];
[self.addParticipantButton setHidden:YES];
[self.transferButton setHidden:YES];
[self.qualityButton setHidden:YES];
[self.chatButton setPressed:NO]; [self.chatButton setPressed:NO];
[self.mergeCallsButton setState:NSOffState];
[self collapseRightView]; [self collapseRightView];
[personLabel setStringValue:@""]; [personLabel setStringValue:@""];
[timeSpentLabel setStringValue:@""]; [timeSpentLabel setStringValue:@""];
[stateLabel setStringValue:@""]; [stateLabel setStringValue:@""];
//audio view
[audioCallTime setStringValue:@""];
[audioCallPersonId setStringValue:@""];
[audioCallPersonLabel setStringValue:@""];
[audioCallView setHidden:YES];
[audioCallPhoto setImage:nil];
//background view
[bluerBackgroundEffect setHidden:NO];
[backgroundImage setHidden:NO];
[backgroundImage setImage:nil];
[bluerBackgroundEffect setBackgroundFilters:nil];
//outgoing view
[outgoingPersonLabel setStringValue:@""]; [outgoingPersonLabel setStringValue:@""];
[outgoingStateLabel setStringValue:@""]; [outgoingStateLabel setStringValue:@""];
[advancedButton setPressed:NO];
[advancedPanel setHidden:YES];
} }
-(void) setupCallView -(void) setupCallView
...@@ -833,15 +901,6 @@ ...@@ -833,15 +901,6 @@
} }
} }
/**
* Merge current call with its parent call
*/
- (IBAction)mergeCalls:(id)sender
{
// auto current = CallModel::instance().selectedCall();
// current->joinToParent();
}
#pragma mark - NSPopOverDelegate #pragma mark - NSPopOverDelegate
- (void)popoverWillClose:(NSNotification *)notification - (void)popoverWillClose:(NSNotification *)notification
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment