Commit c514805c authored by Alexandre Lision's avatar Alexandre Lision Committed by Alexandre Lision

ui: add call screen interface

- in/out animation
- switch calls in conversation tree
- basic controls over call: accept/hangup/hold
- video

Refs #67611

Change-Id: I1d302d2539cb473e27ea469781b72f44963eb0a0
parent f5fc479f
......@@ -38,6 +38,7 @@ SET(ringclient_SRCS
AccAdvancedVC.mm
AccSecurityVC.mm
AccountsVC.mm
CurrentCallVC.mm
AudioPrefsVC.mm
VideoPrefsVC.mm
GeneralPrefsVC.mm
......@@ -47,6 +48,7 @@ SET(ringclient_SRCS
SET(ringclient_FORMS
MainMenu.xib
RingWindow.xib
CurrentCall.xib
GeneralPrefs.xib
Accounts.xib
AccGeneral.xib
......@@ -62,6 +64,7 @@ SET(ringclient_FORMS
SET(ringclient_HDRS
AppDelegate.h
RingWindowController.h
CurrentCallVC.h
ConversationsViewController.h
PreferencesViewController.h
AccGeneralVC.h
......
......@@ -34,12 +34,9 @@
#import "QNSTreeController.h"
@interface ConversationsViewController : NSViewController <NSOutlineViewDelegate> {
NSOutlineView *conversationsView;
}
@property QNSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *conversationsView;
}
@end
#endif // CONVERSATIONSVC_H
\ No newline at end of file
#endif // CONVERSATIONSVC_H
......@@ -30,29 +30,30 @@
#import "ConversationsViewController.h"
#import <callmodel.h>
#import <QtCore/qitemselectionmodel.h>
#import "CurrentCallVC.h"
#define COLUMNID_CONVERSATIONS @"ConversationsColumn" // the single column name in our outline view
@interface ConversationsViewController ()
@property CurrentCallVC* currentVC;
@property (assign) IBOutlet NSView *currentCallView;
@property QNSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *conversationsView;
@end
@implementation ConversationsViewController
@synthesize conversationsView;
@synthesize treeController;
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder]) {
NSLog(@"INIT Conversations VC");
}
return self;
}
@synthesize currentVC;
@synthesize currentCallView;
- (void)awakeFromNib
{
NSLog(@"awakeFromNib");
NSLog(@"INIT Conversations VC");
treeController = [[QNSTreeController alloc] initWithQModel:CallModel::instance()];
......@@ -65,6 +66,24 @@
NSInteger idx = [conversationsView columnWithIdentifier:COLUMNID_CONVERSATIONS];
[[[[self.conversationsView tableColumns] objectAtIndex:idx] headerCell] setStringValue:@"Conversations"];
QObject::connect(CallModel::instance(),
&QAbstractItemModel::dataChanged,
[=](const QModelIndex &topLeft, const QModelIndex &bottomRight) {
NSLog(@"data changed for call tree %d, %d", topLeft.row(), bottomRight.row());
[conversationsView reloadDataForRowIndexes:
[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(topLeft.row(), bottomRight.row() + 1)]
columnIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, conversationsView.tableColumns.count)]];
});
currentVC = [[CurrentCallVC alloc] initWithNibName:@"CurrentCall" bundle:nil];
[currentCallView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[[currentVC view] setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[currentCallView addSubview:[self.currentVC view]];
[currentVC initFrame];
}
#pragma mark - NSOutlineViewDelegate methods
......@@ -83,24 +102,8 @@
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSCell *returnCell = [tableColumn dataCell];
if(item == nil)
return returnCell;
if ([[tableColumn identifier] isEqualToString:COLUMNID_CONVERSATIONS])
{
NSIndexPath* idx = ((NSTreeNode*)item).indexPath;
NSUInteger myArray[[idx length]];
[idx getIndexes:myArray];
NSLog(@"dataCellForTableColumn, indexPath: %lu", (unsigned long)myArray[0]);
QModelIndex qIdx = CallModel::instance()->index(myArray[0], 0);
QVariant test = CallModel::instance()->data(qIdx, Qt::DisplayRole);
}
return returnCell;
}
......@@ -160,7 +163,13 @@
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
// ask the tree controller for the current selection
NSLog(@"outlineViewSelectionDidChange!!");
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
//Update details view by changing selection
CallModel::instance()->selectionModel()->setCurrentIndex(qIdx, QItemSelectionModel::ClearAndSelect);
} else {
CallModel::instance()->selectionModel()->clearCurrentIndex();
}
}
......
This diff is collapsed.
/*
* Copyright (C) 2004-2015 Savoir-Faire Linux Inc.
* Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Additional permission under GNU GPL version 3 section 7:
*
* If you modify this program, or any covered work, by linking or
* combining it with the OpenSSL project's OpenSSL library (or a
* modified version of that library), containing parts covered by the
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
* grants you additional permission to convey the resulting work.
* Corresponding Source for a non-source form of such a combination
* shall include the source code for the parts of OpenSSL used as well
* as that of the covered work.
*/
#ifndef CURRENTCALLVC_H
#define CURRENTCALLVC_H
#import <Cocoa/Cocoa.h>
class Call;
@interface CurrentCallVC : NSViewController {
}
- (void) initFrame;
@end
#endif // CURRENTCALLVC_H
\ No newline at end of file
This diff is collapsed.
......@@ -31,16 +31,11 @@
#define HISTORYVIEWCONTROLLER_H
#import <Cocoa/Cocoa.h>
#import "QNSTreeController.h"
@interface HistoryViewController : NSViewController <NSOutlineViewDelegate> {
NSOutlineView *historyView;
}
@property NSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *historyView;
@end
#endif // HISTORYVIEWCONTROLLER_H
\ No newline at end of file
#endif // HISTORYVIEWCONTROLLER_H
......@@ -30,21 +30,31 @@
#import "HistoryViewController.h"
#import <historymodel.h>
#import <callmodel.h>
#import <call.h>
#import <contactmethod.h>
#define COLUMNID_HISTORY @"HistoryColumn" // the single column name in our outline view
#import "MinimalHistoryBackend.h"
#import "QNSTreeController.h"
#define COLUMNID_DAY @"DayColumn" // the single column name in our outline view
#define COLUMNID_CONTACTMETHOD @"ContactMethodColumn" // the single column name in our outline view
#define COLUMNID_DATE @"DateColumn" // the single column name in our outline view
@implementation HistoryViewController
@interface HistoryViewController()
@synthesize treeController;
@property NSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *historyView;
@end
@implementation HistoryViewController
@synthesize treeController;
@synthesize historyView;
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder]) {
NSLog(@"INIT HVC");
......@@ -52,29 +62,41 @@
return self;
}
- (void)awakeFromNib
{
NSLog(@"awakeFromNib");
treeController = [[QNSTreeController alloc] initWithQModel:HistoryModel::instance()];
[treeController setAvoidsEmptySelection:NO];
[treeController setChildrenKeyPath:@"children"];
[self.historyView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[self.historyView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[self.historyView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
[historyView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[historyView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[historyView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
[historyView setTarget:self];
[historyView setDoubleAction:@selector(placeCall:)];
NSInteger idx = [historyView columnWithIdentifier:COLUMNID_HISTORY];
NSInteger idx = [historyView columnWithIdentifier:COLUMNID_DAY];
[[[[self.historyView tableColumns] objectAtIndex:idx] headerCell] setStringValue:@"Name"];
//HistoryModel::instance()->addBackend(new MinimalHistoryBackend(nil),
// LoadOptions::FORCE_ENABLED);
HistoryModel::instance()->addCollection<MinimalHistoryBackend>(LoadOptions::FORCE_ENABLED);
}
- (void)placeCall:(id)sender
{
if([[treeController selectedNodes] count] > 0) {
Call* c = CallModel::instance()->dialingCall();
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
QVariant var = HistoryModel::instance()->data(qIdx, (int)Call::Role::ContactMethod);
ContactMethod* m = qvariant_cast<ContactMethod*>(var);
if(m){
Call* c = CallModel::instance()->dialingCall();
c->setDialNumber(m);
c << Call::Action::ACCEPT;
}
}
}
#pragma mark - NSOutlineViewDelegate methods
// -------------------------------------------------------------------------------
......@@ -91,24 +113,8 @@
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSCell *returnCell = [tableColumn dataCell];
if(item == nil)
return returnCell;
if ([[tableColumn identifier] isEqualToString:COLUMNID_HISTORY])
{
NSIndexPath* idx = ((NSTreeNode*)item).indexPath;
NSUInteger myArray[[idx length]];
[idx getIndexes:myArray];
//NSLog(@"dataCellForTableColumn, indexPath: %d", myArray[0]);
QModelIndex qIdx = HistoryModel::instance()->index(myArray[0], 0);
QVariant test = HistoryModel::instance()->data(qIdx, Qt::DisplayRole);
}
return returnCell;
}
......@@ -143,22 +149,19 @@
// -------------------------------------------------------------------------------
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if ([[tableColumn identifier] isEqualToString:COLUMNID_HISTORY])
{
NSIndexPath* idx = ((NSTreeNode*)item).indexPath;
NSUInteger myArray[[idx length]];
[idx getIndexes:myArray];
//NSLog(@"array:%@", idx);
QModelIndex qIdx;
if(idx.length == 2)
qIdx = HistoryModel::instance()->index(myArray[1], 0, HistoryModel::instance()->index(myArray[0], 0));
else
qIdx = HistoryModel::instance()->index(myArray[0], 0);
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return;
if(qIdx.isValid())
cell.title = HistoryModel::instance()->data(qIdx, Qt::DisplayRole).toString().toNSString();
if ([[tableColumn identifier] isEqualToString:COLUMNID_DAY])
{
cell.title = HistoryModel::instance()->data(qIdx, Qt::DisplayRole).toString().toNSString();
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_CONTACTMETHOD])
{
cell.title = HistoryModel::instance()->data(qIdx, (int)Call::Role::Number).toString().toNSString();
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_DATE])
{
cell.title = HistoryModel::instance()->data(qIdx, (int)Call::Role::FormattedDate).toString().toNSString();
}
}
......
......@@ -73,10 +73,7 @@ static NSString* const kDonePrefsIdentifer = @"DonePrefsIdentifer";
animation.toValue = [NSValue valueWithPoint:self.view.frame.origin];
animation.duration = 0.3f;
[animation setTimingFunction:[CAMediaTimingFunction functionWithControlPoints:.7 :0.9 :1 :1]];
[self.view.layer addAnimation:animation forKey:animation.keyPath];
self.view.layer.position = frame.origin;
}
- (void) close
......
This diff is collapsed.
......@@ -34,7 +34,7 @@
#import "HistoryViewController.h"
#import "PreferencesViewController.h"
@interface RingWindowController : NSWindowController {
@interface RingWindowController : NSWindowController <NSToolbarDelegate>{
IBOutlet NSView *currentView;
}
@property (nonatomic, assign) NSViewController *myCurrentViewController;
......
......@@ -37,28 +37,20 @@
@interface RingWindowController ()
@property NSSearchField* callField;
@end
@implementation RingWindowController
@synthesize callField;
static NSString* const kSearchViewIdentifier = @"SearchViewIdentifier";
static NSString* const kPreferencesIdentifier = @"PreferencesIdentifier";
static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier";
- (void)windowDidLoad {
[super windowDidLoad];
[self connectSlots];
}
- (void) connectSlots
{
CallModel* callModel_ = CallModel::instance();
QObject::connect(callModel_, &CallModel::callStateChanged, [](Call*, Call::State) {
NSLog(@"callStateChanged");
});
QObject::connect(callModel_, &CallModel::incomingCall, [] (Call*) {
NSLog(@"incomingCall");
});
[self displayMainToolBar];
}
- (IBAction)openPreferences:(id)sender
......@@ -122,11 +114,19 @@
if(self.myCurrentViewController != nil)
{
[self.preferencesViewController close];
[self.window setToolbar:nil];
[self displayMainToolBar];
self.preferencesViewController = nil;
}
}
-(void) displayMainToolBar
{
NSToolbar* tb = [[NSToolbar alloc] initWithIdentifier: @"MainToolbar"];
[tb setDisplayMode:NSToolbarDisplayModeIconAndLabel];
[tb setDelegate: self];
[self.window setToolbar: tb];
}
// FIXME: This is sick, NSWindowController is catching my selectors
- (void)displayGeneral:(NSToolbarItem *)sender {
[self.preferencesViewController displayGeneral:sender];
......@@ -149,4 +149,82 @@
}
#pragma NSToolbar Delegate
-(NSToolbarItem *)toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString *)itemIdentifier willBeInsertedIntoToolbar:(BOOL)flag
{
NSToolbarItem* item = nil;
if ([itemIdentifier isEqualToString: kSearchViewIdentifier]) {
item = [[NSToolbarItem alloc] initWithItemIdentifier: kSearchViewIdentifier];
callField = [[NSSearchField alloc] initWithFrame:NSMakeRect(0,0,400,21)];
[[callField cell] setSearchButtonCell:nil];
[callField setToolTip:@"Call"];
//[callField setAlignment:NSCenterTextAlignment];
[item setView:callField];
}
if ([itemIdentifier isEqualToString: kCallButtonIdentifer]) {
item = [[NSToolbarItem alloc] initWithItemIdentifier: kCallButtonIdentifer];
NSButton *callButton = [[NSButton alloc] initWithFrame:NSMakeRect(0,0,80,30)];
[callButton setButtonType:NSMomentaryLightButton]; //Set what type button You want
[callButton setBezelStyle:NSRoundedBezelStyle]; //Set what style You want]
[callButton setBordered:YES];
[callButton setTitle:@"Call"];
[item setView:callButton];
[item setAction:@selector(placeCall:)];
}
if ([itemIdentifier isEqualToString: kPreferencesIdentifier]) {
item = [[NSToolbarItem alloc] initWithItemIdentifier: kPreferencesIdentifier];
[item setImage: [NSImage imageNamed: @"NSAdvanced"]];
[item setLabel: @"Settings"];
[item setAction:@selector(openPreferences:)];
}
return item;
}
- (IBAction)placeCall:(id)sender
{
Call* c = CallModel::instance()->dialingCall();
c->setDialNumber(QString::fromNSString([callField stringValue]));
c << Call::Action::ACCEPT;
}
-(NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
return [NSArray arrayWithObjects:
NSToolbarSpaceItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
NSToolbarSpaceItemIdentifier,
NSToolbarSpaceItemIdentifier,
kSearchViewIdentifier,
kCallButtonIdentifer,
NSToolbarFlexibleSpaceItemIdentifier,
kPreferencesIdentifier,
nil];
}
-(NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:
kSearchViewIdentifier,
kCallButtonIdentifer,
kPreferencesIdentifier,
nil];
}
-(NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
{
return nil;
}
@end
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