Commit e4d61cb1 authored by Alexandre Lision's avatar Alexandre Lision

account: merge audio and video panel

AccVideoVC + AccAudioVC = AccMediaVC

Tuleap: #406
Change-Id: I757d66322975b9362e42cb313a6f50986591bef6
parent eccf8aed
......@@ -81,10 +81,8 @@ SET(ringclient_CONTROLLERS
src/PreferencesWC.h
src/AccGeneralVC.mm
src/AccGeneralVC.h
src/AccVideoVC.mm
src/AccVideoVC.h
src/AccAudioVC.mm
src/AccAudioVC.h
src/AccMediaVC.mm
src/AccMediaVC.h
src/AccRingVC.mm
src/AccRingVC.h
src/AccAdvancedVC.mm
......@@ -157,8 +155,7 @@ SET(ringclient_XIBS
GeneralPrefs
Accounts
AccGeneral
AccAudio
AccVideo
AccMedia
AccRing
AccAdvanced
AccSecurity
......
......@@ -23,6 +23,6 @@
#import "QNSTreeController.h"
@interface AccAudioVC : NSViewController <NSOutlineViewDelegate>
@interface AccMediaVC : NSViewController <NSOutlineViewDelegate>
@end
\ No newline at end of file
This diff is collapsed.
/*
* Copyright (C) 2015-2016 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.
*/
#import <Cocoa/Cocoa.h>
#import <account.h>
@interface AccVideoVC : NSViewController <NSOutlineViewDelegate>
@end
\ No newline at end of file
/*
* Copyright (C) 2015-2016 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.
*/
#define COLUMNID_STATE @"VideoStateColumn"
#define COLUMNID_CODECS @"VideoCodecsColumn"
#define COLUMNID_FREQ @"VideoFrequencyColumn"
#define COLUMNID_BITRATE @"VideoBitrateColumn"
#import "AccVideoVC.h"
#include <QtCore/QSortFilterProxyModel>
#import <audio/codecmodel.h>
#import <accountmodel.h>
#import <qitemselectionmodel.h>
#import "QNSTreeController.h"
@interface AccVideoVC ()
@property QNSTreeController *treeController;
@property (assign) IBOutlet NSOutlineView *codecsView;
@property (assign) IBOutlet NSView *videoPanelContainer;
@property (assign) IBOutlet NSButton *toggleVideoButton;
@end
@implementation AccVideoVC
@synthesize treeController;
@synthesize codecsView;
@synthesize videoPanelContainer;
@synthesize toggleVideoButton;
- (void)awakeFromNib
{
NSLog(@"INIT Video VC");
QObject::connect(AccountModel::instance().selectionModel(),
&QItemSelectionModel::currentChanged,
[=](const QModelIndex &current, const QModelIndex &previous) {
if(!current.isValid())
return;
[self loadAccount];
});
}
- (Account*) currentAccount
{
auto accIdx = AccountModel::instance().selectionModel()->currentIndex();
return AccountModel::instance().getAccountByModelIndex(accIdx);
}
- (void)loadAccount
{
auto account = [self currentAccount];
treeController = [[QNSTreeController alloc] initWithQModel:account->codecModel()->videoCodecs()];
[treeController setAvoidsEmptySelection:NO];
[treeController setChildrenKeyPath:@"children"];
[codecsView bind:@"content" toObject:treeController withKeyPath:@"arrangedObjects" options:nil];
[codecsView bind:@"sortDescriptors" toObject:treeController withKeyPath:@"sortDescriptors" options:nil];
[codecsView bind:@"selectionIndexPaths" toObject:treeController withKeyPath:@"selectionIndexPaths" options:nil];
[videoPanelContainer setHidden:!account->isVideoEnabled()];
[toggleVideoButton setState:account->isVideoEnabled()?NSOnState:NSOffState];
}
- (IBAction)toggleVideoEnabled:(id)sender {
[self currentAccount]->setVideoEnabled([sender state] == NSOnState);
[videoPanelContainer setHidden:![self currentAccount]->isVideoEnabled()];
}
- (IBAction)toggleCodec:(NSOutlineView*)sender {
NSInteger row = [sender clickedRow];
NSTableColumn *col = [sender tableColumnWithIdentifier:COLUMNID_STATE];
NSButtonCell *cell = [col dataCellForRow:row];
[self currentAccount]->codecModel()->videoCodecs()->setData([self currentAccount]->codecModel()->videoCodecs()->index(row, 0, QModelIndex()),
cell.state == NSOnState ? Qt::Unchecked : Qt::Checked, Qt::CheckStateRole);
}
- (IBAction)moveUp:(id)sender {
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
if(!qIdx.isValid())
return;
QMimeData* mime = [self currentAccount]->codecModel()->mimeData(QModelIndexList() << qIdx);
[self currentAccount]->codecModel()->dropMimeData(mime, Qt::MoveAction, qIdx.row() - 1, 0, QModelIndex());
}
}
- (IBAction)moveDown:(id)sender {
if([[treeController selectedNodes] count] > 0) {
QModelIndex qIdx = [treeController toQIdx:[treeController selectedNodes][0]];
if(!qIdx.isValid())
return;
QMimeData* mime = [self currentAccount]->codecModel()->mimeData(QModelIndexList() << qIdx);
[self currentAccount]->codecModel()->dropMimeData(mime, Qt::MoveAction, qIdx.row() + 1, 0, QModelIndex());
}
}
#pragma mark - NSOutlineViewDelegate methods
// -------------------------------------------------------------------------------
// shouldSelectItem:item
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item;
{
return YES;
}
// -------------------------------------------------------------------------------
// dataCellForTableColumn:tableColumn:item
// -------------------------------------------------------------------------------
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
NSCell *returnCell = [tableColumn dataCell];
if(item == nil)
return returnCell;
return returnCell;
}
// -------------------------------------------------------------------------------
// textShouldEndEditing:fieldEditor
// -------------------------------------------------------------------------------
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor
{
if ([[fieldEditor string] length] == 0)
{
// don't allow empty node names
return NO;
}
else
{
return YES;
}
}
// -------------------------------------------------------------------------------
// shouldEditTableColumn:tableColumn:item
//
// Decide to allow the edit of the given outline view "item".
// -------------------------------------------------------------------------------
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
return NO;
}
// -------------------------------------------------------------------------------
// outlineView:willDisplayCell:forTableColumn:item
// -------------------------------------------------------------------------------
- (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
QModelIndex qIdx = [treeController toQIdx:((NSTreeNode*)item)];
if(!qIdx.isValid())
return;
if([[tableColumn identifier] isEqualToString:COLUMNID_STATE]) {
[cell setState:[self currentAccount]->codecModel()->videoCodecs()->data(qIdx, Qt::CheckStateRole).value<BOOL>()?NSOnState:NSOffState];
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_CODECS])
{
cell.title = [self currentAccount]->codecModel()->videoCodecs()->data(qIdx, CodecModel::Role::NAME).toString().toNSString();
[cell setState:[self currentAccount]->codecModel()->videoCodecs()->data(qIdx, Qt::CheckStateRole).value<BOOL>()?NSOnState:NSOffState];
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_FREQ])
{
cell.title = [self currentAccount]->codecModel()->videoCodecs()->data(qIdx, CodecModel::Role::SAMPLERATE).toString().toNSString();
} else if ([[tableColumn identifier] isEqualToString:COLUMNID_BITRATE])
{
cell.title = [self currentAccount]->codecModel()->videoCodecs()->data(qIdx, CodecModel::Role::BITRATE).toString().toNSString();
}
}
// -------------------------------------------------------------------------------
// outlineViewSelectionDidChange:notification
// -------------------------------------------------------------------------------
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
// ask the tree controller for the current selection
}
@end
......@@ -32,8 +32,7 @@
#import "QNSTreeController.h"
#import "AccGeneralVC.h"
#import "AccAudioVC.h"
#import "AccVideoVC.h"
#import "AccMediaVC.h"
#import "AccAdvancedVC.h"
#import "AccSecurityVC.h"
#import "AccRingVC.h"
......@@ -57,8 +56,7 @@ public:
@property (assign) IBOutlet NSTabView *configPanels;
@property (retain) IBOutlet NSTabViewItem *generalTabItem;
@property (retain) IBOutlet NSTabViewItem *audioTabItem;
@property (retain) IBOutlet NSTabViewItem *videoTabItem;
@property (retain) IBOutlet NSTabViewItem *mediaTabItem;
@property (retain) IBOutlet NSTabViewItem *advancedTabItem;
@property (retain) IBOutlet NSTabViewItem *securityTabItem;
@property (retain) IBOutlet NSTabViewItem *ringTabItem;
......@@ -70,8 +68,7 @@ public:
@property AccRingVC* ringVC;
@property AccGeneralVC* generalVC;
@property AccAudioVC* audioVC;
@property AccVideoVC* videoVC;
@property AccMediaVC* audioVC;
@property AccAdvancedVC* advancedVC;
@property AccSecurityVC* securityVC;
......@@ -81,8 +78,7 @@ public:
@synthesize protocolList;
@synthesize configPanels;
@synthesize generalTabItem;
@synthesize audioTabItem;
@synthesize videoTabItem;
@synthesize mediaTabItem;
@synthesize advancedTabItem;
@synthesize securityTabItem;
@synthesize ringTabItem;
......@@ -122,15 +118,10 @@ public:
[[self.generalVC view] setBounds:[self.generalTabItem.view bounds]];
[self.generalTabItem setView:self.generalVC.view];
self.audioVC = [[AccAudioVC alloc] initWithNibName:@"AccAudio" bundle:nil];
[[self.audioVC view] setFrame:[self.audioTabItem.view frame]];
[[self.audioVC view] setBounds:[self.audioTabItem.view bounds]];
[self.audioTabItem setView:self.audioVC.view];
self.videoVC = [[AccVideoVC alloc] initWithNibName:@"AccVideo" bundle:nil];
[[self.videoVC view] setFrame:[self.videoTabItem.view frame]];
[[self.videoVC view] setBounds:[self.videoTabItem.view bounds]];
[self.videoTabItem setView:self.videoVC.view];
self.audioVC = [[AccMediaVC alloc] initWithNibName:@"AccMedia" bundle:nil];
[[self.audioVC view] setFrame:[self.mediaTabItem.view frame]];
[[self.audioVC view] setBounds:[self.mediaTabItem.view bounds]];
[self.mediaTabItem setView:self.audioVC.view];
self.advancedVC = [[AccAdvancedVC alloc] initWithNibName:@"AccAdvanced" bundle:nil];
[[self.advancedVC view] setFrame:[self.advancedTabItem.view frame]];
......@@ -196,10 +187,9 @@ public:
}
[configPanels insertTabViewItem:generalTabItem atIndex:0];
[configPanels insertTabViewItem:audioTabItem atIndex:1];
[configPanels insertTabViewItem:videoTabItem atIndex:2];
[configPanels insertTabViewItem:advancedTabItem atIndex:3];
[configPanels insertTabViewItem:securityTabItem atIndex:4];
[configPanels insertTabViewItem:mediaTabItem atIndex:1];
[configPanels insertTabViewItem:advancedTabItem atIndex:2];
[configPanels insertTabViewItem:securityTabItem atIndex:3];
}
- (void) setupIAXPanels
......@@ -210,8 +200,7 @@ public:
}
[configPanels insertTabViewItem:generalTabItem atIndex:0];
[configPanels insertTabViewItem:audioTabItem atIndex:1];
[configPanels insertTabViewItem:videoTabItem atIndex:2];
[configPanels insertTabViewItem:mediaTabItem atIndex:1];
}
- (void) setupRINGPanels
......@@ -222,9 +211,8 @@ public:
}
[configPanels insertTabViewItem:ringTabItem atIndex:0];
[configPanels insertTabViewItem:audioTabItem atIndex:1];
[configPanels insertTabViewItem:videoTabItem atIndex:2];
[configPanels insertTabViewItem:advancedTabItem atIndex:3];
[configPanels insertTabViewItem:mediaTabItem atIndex:1];
[configPanels insertTabViewItem:advancedTabItem atIndex:2];
}
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="7706" systemVersion="14F27" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="7706"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9532"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccountsVC">
......@@ -9,30 +9,29 @@
<outlet property="accountDetailsView" destination="Jki-s4-F1W" id="8zf-XP-bql"/>
<outlet property="accountsListView" destination="Dsf-ph-Qfe" id="uT8-nv-e0W"/>
<outlet property="advancedTabItem" destination="RT7-u6-bhe" id="eAT-ce-MyD"/>
<outlet property="audioTabItem" destination="hiU-GG-6Eg" id="D2g-nf-MQS"/>
<outlet property="configPanels" destination="Jki-s4-F1W" id="nY4-dc-CQg"/>
<outlet property="generalTabItem" destination="tPR-Ac-N5Y" id="39S-pz-1Xs"/>
<outlet property="mediaTabItem" destination="lxr-my-vH8" id="BhJ-cS-yVi"/>
<outlet property="protocolList" destination="rZv-qd-BGe" id="yU0-6C-Vt1"/>
<outlet property="ringTabItem" destination="1HC-kF-Jun" id="FJZ-2g-Y1i"/>
<outlet property="securityTabItem" destination="Vp5-yV-ScC" id="FDx-0T-3t9"/>
<outlet property="videoTabItem" destination="GIU-kn-D57" id="oH6-MT-bSN"/>
<outlet property="view" destination="Hz6-mo-xeY" id="eBn-rZ-84z"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView id="Hz6-mo-xeY">
<rect key="frame" x="0.0" y="0.0" width="944" height="635"/>
<rect key="frame" x="0.0" y="0.0" width="880" height="635"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<scrollView focusRingType="none" misplaced="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="USD-1t-wb3">
<rect key="frame" x="20" y="274" width="262" height="341"/>
<clipView key="contentView" misplaced="YES" id="fqt-7S-Xp4">
<rect key="frame" x="1" y="17" width="238" height="117"/>
<clipView key="contentView" id="fqt-7S-Xp4">
<rect key="frame" x="1" y="0.0" width="260" height="340"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<outlineView focusRingType="none" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" multipleSelection="NO" autosaveColumns="NO" headerView="0lm-pU-hrg" indentationPerLevel="16" outlineTableColumn="Ppv-dQ-Azf" id="Dsf-ph-Qfe">
<rect key="frame" x="0.0" y="0.0" width="318" height="19"/>
<rect key="frame" x="0.0" y="0.0" width="260" height="317"/>
<autoresizingMask key="autoresizingMask"/>
<size key="intercellSpacing" width="3" height="2"/>
<color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
......@@ -89,7 +88,7 @@
<constraint firstAttribute="width" constant="262" id="L7g-ZA-zfy"/>
</constraints>
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="2Jz-0X-Ltx">
<rect key="frame" x="1" y="117.97246444225311" width="238" height="16"/>
<rect key="frame" x="1" y="117" width="238" height="16"/>
<autoresizingMask key="autoresizingMask"/>
</scroller>
<scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="0TD-fd-ht6">
......@@ -97,7 +96,7 @@
<autoresizingMask key="autoresizingMask"/>
</scroller>
<tableHeaderView key="headerView" id="0lm-pU-hrg">
<rect key="frame" x="0.0" y="0.0" width="10000" height="17"/>
<rect key="frame" x="0.0" y="0.0" width="260" height="23"/>
<autoresizingMask key="autoresizingMask"/>
</tableHeaderView>
</scrollView>
......@@ -155,42 +154,36 @@
</connections>
</popUpButton>
<tabView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jki-s4-F1W">
<rect key="frame" x="283" y="11" width="648" height="610"/>
<rect key="frame" x="283" y="11" width="584" height="610"/>
<font key="font" metaFont="system"/>
<tabViewItems>
<tabViewItem label="General" identifier="1" id="tPR-Ac-N5Y">
<view key="view" id="8c3-Js-oxO">
<rect key="frame" x="10" y="33" width="628" height="564"/>
<rect key="frame" x="10" y="33" width="564" height="564"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Audio" identifier="2" id="hiU-GG-6Eg">
<view key="view" id="yYL-8c-xzR">
<rect key="frame" x="10" y="33" width="578" height="565"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Video" identifier="" id="GIU-kn-D57">
<view key="view" id="hD4-t0-Nbw">
<rect key="frame" x="10" y="33" width="578" height="565"/>
<tabViewItem label="Media" identifier="2" id="lxr-my-vH8">
<view key="view" id="p9F-kK-hRx">
<rect key="frame" x="10" y="33" width="564" height="564"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Advanced" identifier="" id="RT7-u6-bhe">
<view key="view" id="Pp4-JG-r1v">
<rect key="frame" x="10" y="33" width="578" height="565"/>
<rect key="frame" x="10" y="33" width="564" height="564"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Security" identifier="" id="Vp5-yV-ScC">
<view key="view" id="p3d-5C-tAZ">
<rect key="frame" x="10" y="33" width="578" height="565"/>
<rect key="frame" x="10" y="33" width="564" height="564"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
<tabViewItem label="Ring" identifier="" id="1HC-kF-Jun">
<view key="view" id="asB-J0-2bi">
<rect key="frame" x="10" y="33" width="578" height="565"/>
<rect key="frame" x="10" y="33" width="564" height="564"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
</view>
</tabViewItem>
......@@ -246,7 +239,7 @@
<constraint firstItem="rZv-qd-BGe" firstAttribute="leading" secondItem="zWn-Zy-Uau" secondAttribute="trailing" constant="8" id="y2z-JO-Y63"/>
<constraint firstItem="IqR-Q4-2bh" firstAttribute="leading" secondItem="dxk-Wh-H0B" secondAttribute="trailing" constant="12" id="yYZ-UL-F0F"/>
</constraints>
<point key="canvasLocation" x="542" y="304.5"/>
<point key="canvasLocation" x="510" y="304.5"/>
</customView>
</objects>
<resources>
......
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