Commit 266fca0e authored by Alexandre Lision's avatar Alexandre Lision

ui: update in-call actions

- use new button theme for call controls buttons.
- add an icon for recording
- gide buttons when available instead of disabling them

Issue: #79400
Change-Id: I712467b8f7b7fe16317f4283ae9d4f91bc8b9203
parent 6da08a80
...@@ -182,6 +182,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_mute_audio.png ...@@ -182,6 +182,7 @@ ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_mute_audio.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_chat.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_chat.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_search.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_search.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_quality.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_quality.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_action_record.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_received.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_received.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_missed.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_missed.png
${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_made.png ${CMAKE_CURRENT_SOURCE_DIR}/data/dark/ic_call_made.png
......
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
@property (unsafe_unretained) IBOutlet NSButton *muteVideoButton; @property (unsafe_unretained) IBOutlet NSButton *muteVideoButton;
@property (unsafe_unretained) IBOutlet NSButton *addContactButton; @property (unsafe_unretained) IBOutlet NSButton *addContactButton;
@property (unsafe_unretained) IBOutlet NSView *headerContainer; @property (unsafe_unretained) IBOutlet NSView *headerContainer;
@property (unsafe_unretained) IBOutlet NSButton *qualityButton;
@property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator; @property (unsafe_unretained) IBOutlet ITProgressIndicator *loadingIndicator;
...@@ -109,18 +110,9 @@ ...@@ -109,18 +110,9 @@
const QModelIndex& idx = CallModel::instance()->userActionModel()->index(row,0); const QModelIndex& idx = CallModel::instance()->userActionModel()->index(row,0);
UserActionModel::Action action = qvariant_cast<UserActionModel::Action>(idx.data(UserActionModel::Role::ACTION)); UserActionModel::Action action = qvariant_cast<UserActionModel::Action>(idx.data(UserActionModel::Role::ACTION));
NSButton* a = actionHash[(int) action]; NSButton* a = actionHash[(int) action];
if (a != nil) { if (a) {
[a setEnabled:(idx.flags() & Qt::ItemIsEnabled)]; [a setHidden:!(idx.flags() & Qt::ItemIsEnabled)];
[a setState:(idx.data(Qt::CheckStateRole) == Qt::Checked) ? NSOnState : NSOffState]; [a setState:(idx.data(Qt::CheckStateRole) == Qt::Checked) ? NSOnState : NSOffState];
if(action == UserActionModel::Action::HOLD) {
NSString* imgName = (a.state == NSOnState ? @"ic_action_holdoff" : @"ic_action_hold");
[a setImage:[NSImage imageNamed:imgName]];
}
if(action == UserActionModel::Action::RECORD) {
[a setTitle:(a.state == NSOnState ? @"Record off" : @"Record")];
}
} }
} }
...@@ -138,7 +130,14 @@ ...@@ -138,7 +130,14 @@
[self.addContactButton setHidden:!shouldShow]; [self.addContactButton setHidden:!shouldShow];
Call::State state = callIdx.data((int)Call::Role::State).value<Call::State>(); Call::State state = callIdx.data((int)Call::Role::State).value<Call::State>();
// Default values for this views
[loadingIndicator setHidden:YES]; [loadingIndicator setHidden:YES];
[self.qualityButton setHidden:YES];
[self.chatButton setHidden:YES];
[videoView setShouldAcceptInteractions:NO];
[stateLabel setStringValue:callIdx.data((int)Call::Role::HumanStateName).toString().toNSString()]; [stateLabel setStringValue:callIdx.data((int)Call::Role::HumanStateName).toString().toNSString()];
switch (state) { switch (state) {
case Call::State::DIALING: case Call::State::DIALING:
...@@ -147,33 +146,27 @@ ...@@ -147,33 +146,27 @@
case Call::State::NEW: case Call::State::NEW:
break; break;
case Call::State::INITIALIZATION: case Call::State::INITIALIZATION:
[videoView setShouldAcceptInteractions:NO];
[loadingIndicator setHidden:NO]; [loadingIndicator setHidden:NO];
break; break;
case Call::State::CONNECTED: case Call::State::CONNECTED:
[videoView setShouldAcceptInteractions:NO];
[loadingIndicator setHidden:NO]; [loadingIndicator setHidden:NO];
break; break;
case Call::State::RINGING: case Call::State::RINGING:
[videoView setShouldAcceptInteractions:NO];
break; break;
case Call::State::CURRENT: case Call::State::CURRENT:
[videoView setShouldAcceptInteractions:YES]; [videoView setShouldAcceptInteractions:YES];
[self.chatButton setHidden:NO];
[self.qualityButton setHidden:NO];
break; break;
case Call::State::HOLD: case Call::State::HOLD:
[videoView setShouldAcceptInteractions:NO];
break; break;
case Call::State::BUSY: case Call::State::BUSY:
[videoView setShouldAcceptInteractions:NO];
break; break;
case Call::State::OVER: case Call::State::OVER:
[videoView setShouldAcceptInteractions:NO]; case Call::State::FAILURE:
if(self.splitView.isInFullScreenMode) if(self.splitView.isInFullScreenMode)
[self.splitView exitFullScreenModeWithOptions:nil]; [self.splitView exitFullScreenModeWithOptions:nil];
break; break;
case Call::State::FAILURE:
[videoView setShouldAcceptInteractions:NO];
break;
} }
} }
...@@ -224,6 +217,7 @@ ...@@ -224,6 +217,7 @@
[loadingIndicator setLengthOfLine:2]; [loadingIndicator setLengthOfLine:2];
[loadingIndicator setInnerMargin:30]; [loadingIndicator setInnerMargin:30];
[self.qualityPopOver setDelegate:self];
[self.videoView setCallDelegate:self]; [self.videoView setCallDelegate:self];
[self connect]; [self connect];
...@@ -541,6 +535,8 @@ ...@@ -541,6 +535,8 @@
if (self.addToContactPopover != nullptr) { if (self.addToContactPopover != nullptr) {
[self.addToContactPopover performClose:self]; [self.addToContactPopover performClose:self];
self.addToContactPopover = NULL; self.addToContactPopover = NULL;
[self.addContactButton setState:NSOffState];
} else if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) { } else if (!contactmethod->contact() || contactmethod->contact()->isPlaceHolder()) {
auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil]; auto* editorVC = [[PersonLinkerVC alloc] initWithNibName:@"PersonLinker" bundle:nil];
[editorVC setMethodToLink:contactmethod]; [editorVC setMethodToLink:contactmethod];
...@@ -596,11 +592,18 @@ ...@@ -596,11 +592,18 @@
uam << UserActionModel::Action::MUTE_VIDEO; uam << UserActionModel::Action::MUTE_VIDEO;
} }
- (IBAction)displayQualityPopUp:(id)sender { - (IBAction)displayQualityPopUp:(id)sender {
[self.qualityPopOver showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge]; [self.qualityPopOver showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxXEdge];
} }
#pragma mark - NSPopOverDelegate #pragma mark - NSPopOverDelegate
- (void)popoverWillClose:(NSNotification *)notification
{
[self.qualityButton setState:NSOffState];
[self.addContactButton setState:NSOffState];
}
- (void)popoverDidClose:(NSNotification *)notification - (void)popoverDidClose:(NSNotification *)notification
{ {
if (self.addToContactPopover != nullptr) { if (self.addToContactPopover != nullptr) {
......
...@@ -16,21 +16,40 @@ ...@@ -16,21 +16,40 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/ */
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@interface IconButton : NSButton @interface IconButton : NSButton
@property (nonatomic) BOOL mouseDown; @property (nonatomic) BOOL mouseDown;
/* /*
* This properties can be overriden in IB in User Defined Runtime Attributes * This properties can be overriden in IB in User Defined Runtime Attributes
* By default this values will be initialized in awakeFromNib with: * By default this values will be initialized in awakeFromNib
* bgColor -> [NSColor ringBlue] */
* cornerRadius to view frame width / 2 (circle)
/*
* Background color of the button
* default value : [NSColor ringBlue]
*/ */
@property (nonatomic, strong) NSColor* bgColor; @property (nonatomic, strong) NSColor* bgColor;
/*
* Background color of the button when highlighted
* default value : view frame width / 2 (circle)
*/
@property (nonatomic, strong) NSColor* highlightColor;
/*
* Background color of the button when highlighted
* default value : view frame width / 2 (circle)
*/
@property (nonatomic, strong) NSNumber* cornerRadius; @property (nonatomic, strong) NSNumber* cornerRadius;
/*
* Padding
* default value : 5.0
*/
@property CGFloat imageInsets;
@end @end
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#import "NSColor+RingTheme.h" #import "NSColor+RingTheme.h"
@implementation IconButton @implementation IconButton
-(void) awakeFromNib { -(void) awakeFromNib {
...@@ -32,6 +31,9 @@ ...@@ -32,6 +31,9 @@
if (!self.cornerRadius) { if (!self.cornerRadius) {
self.cornerRadius = @(NSWidth(self.frame) / 2); self.cornerRadius = @(NSWidth(self.frame) / 2);
} }
if (self.imageInsets == 0)
self.imageInsets = 5.0f;
} }
- (void)drawRect:(NSRect)dirtyRect - (void)drawRect:(NSRect)dirtyRect
...@@ -42,8 +44,14 @@ ...@@ -42,8 +44,14 @@
NSColor* backgroundStrokeColor5; NSColor* backgroundStrokeColor5;
if (self.mouseDown || self.state == NSOnState) { if (self.mouseDown || self.state == NSOnState) {
backgroundColor6 = [self.bgColor darkenColorByValue:0.3]; if (self.highlightColor) {
backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.4]; backgroundColor6 = self.highlightColor;
backgroundStrokeColor5 = [self.highlightColor darkenColorByValue:0.1];
} else {
backgroundColor6 = [self.bgColor darkenColorByValue:0.3];
backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.4];
}
} else { } else {
backgroundColor6 = self.bgColor; backgroundColor6 = self.bgColor;
backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.1]; backgroundStrokeColor5 = [self.bgColor darkenColorByValue:0.1];
...@@ -52,13 +60,10 @@ ...@@ -52,13 +60,10 @@
//// Subframes //// Subframes
NSRect group = NSMakeRect(NSMinX(dirtyRect) + floor(NSWidth(dirtyRect) * 0.03333) + 0.5, NSMinY(dirtyRect) + floor(NSHeight(dirtyRect) * 0.03333) + 0.5, floor(NSWidth(dirtyRect) * 0.96667) - floor(NSWidth(dirtyRect) * 0.03333), floor(NSHeight(dirtyRect) * 0.96667) - floor(NSHeight(dirtyRect) * 0.03333)); NSRect group = NSMakeRect(NSMinX(dirtyRect) + floor(NSWidth(dirtyRect) * 0.03333) + 0.5, NSMinY(dirtyRect) + floor(NSHeight(dirtyRect) * 0.03333) + 0.5, floor(NSWidth(dirtyRect) * 0.96667) - floor(NSWidth(dirtyRect) * 0.03333), floor(NSHeight(dirtyRect) * 0.96667) - floor(NSHeight(dirtyRect) * 0.03333));
//// Group //// Group
{ {
//// Oval Drawing //// Oval Drawing
// NSBezierPath* ovalPath = [NSBezierPath bezierPathWithOvalInRect: NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5))]; NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5)) xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(NSMinX(group) + floor(NSWidth(group) * 0.00000 + 0.5), NSMinY(group) + floor(NSHeight(group) * 0.00000 + 0.5), floor(NSWidth(group) * 1.00000 + 0.5) - floor(NSWidth(group) * 0.00000 + 0.5), floor(NSHeight(group) * 1.00000 + 0.5) - floor(NSHeight(group) * 0.00000 + 0.5)) xRadius:[self.cornerRadius floatValue] yRadius:[self.cornerRadius floatValue]];
[backgroundColor6 setFill]; [backgroundColor6 setFill];
[ovalPath fill]; [ovalPath fill];
...@@ -72,7 +77,8 @@ NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(NSMi ...@@ -72,7 +77,8 @@ NSBezierPath* ovalPath = [NSBezierPath bezierPathWithRoundedRect:NSMakeRect(NSMi
[path addClip]; [path addClip];
[self setImagePosition:NSImageOnly]; [self setImagePosition:NSImageOnly];
auto rect2 = NSInsetRect(dirtyRect, 5, 5); auto rect2 = NSInsetRect(dirtyRect, self.imageInsets, self.imageInsets);
[[NSColor image:self.image tintedWithColor:[NSColor whiteColor]] [[NSColor image:self.image tintedWithColor:[NSColor whiteColor]]
drawInRect:rect2 drawInRect:rect2
......
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