Commit 1154eb3c authored by Alexandre Lision's avatar Alexandre Lision

preferences: hide some advanced settings

Refs #66840

Change-Id: Ibcbe5c39d83372972d4df0e151ede6229fe5f590
parent 33df4533
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccGeneralVC">
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="13F34" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6751" systemVersion="14C1510" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6751"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="AccRingVC">
......
......@@ -13,8 +13,12 @@
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
<customView wantsLayer="YES" focusRingType="none" translatesAutoresizingMaskIntoConstraints="NO" id="tP7-RI-Nc4">
<rect key="frame" x="0.0" y="0.0" width="817" height="506"/>
<point key="canvasLocation" x="338.5" y="195"/>
<rect key="frame" x="0.0" y="0.0" width="700" height="500"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="500" id="GrH-eh-xjo"/>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="700" id="hH2-R5-frs"/>
</constraints>
<point key="canvasLocation" x="412.5" y="157.5"/>
</customView>
</objects>
</document>
......@@ -40,9 +40,12 @@
@interface PreferencesViewController ()
@property NSButton* toggleAdvancedSettings;
@end
@implementation PreferencesViewController
@synthesize toggleAdvancedSettings;
static NSString* const kProfilePrefsIdentifier = @"ProfilesPrefsIdentifier";
static NSString* const kGeneralPrefsIdentifier = @"GeneralPrefsIdentifier";
......@@ -50,6 +53,7 @@ static NSString* const kAudioPrefsIdentifer = @"AudioPrefsIdentifer";
static NSString* const kAncragePrefsIdentifer = @"AncragePrefsIdentifer";
static NSString* const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
static NSString* const kDonePrefsIdentifer = @"DonePrefsIdentifer";
static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
-(void)loadView
{
......@@ -172,12 +176,16 @@ static NSString* const kDonePrefsIdentifer = @"DonePrefsIdentifer";
[item setAction:@selector(displayAudio:)];
}
// if ([itemIdentifier isEqualToString: kAncragePrefsIdentifer]) {
// item = [[NSToolbarItem alloc] initWithItemIdentifier: kAncragePrefsIdentifer];
// [item setImage: [NSImage imageNamed: @"ancrage"]];
// [item setLabel: @"Ancrage"];
// [item setAction:@selector(displayAncrage:)];
// }
if ([itemIdentifier isEqualToString: kPowerSettingsIdentifer]) {
item = [[NSToolbarItem alloc] initWithItemIdentifier: kPowerSettingsIdentifer];
toggleAdvancedSettings = [[NSButton alloc] initWithFrame:NSMakeRect(0,0,20,20)];
[toggleAdvancedSettings setButtonType:NSSwitchButton];
[toggleAdvancedSettings setTitle:@""];
[toggleAdvancedSettings setState:[[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"]];
[item setLabel:@"Show Advanced"];
[item setView:toggleAdvancedSettings];
[item setAction:@selector(togglePowerSettings:)];
}
if ([itemIdentifier isEqualToString: kDonePrefsIdentifer]) {
item = [[NSToolbarItem alloc] initWithItemIdentifier: kDonePrefsIdentifer];
......@@ -194,33 +202,45 @@ static NSString* const kDonePrefsIdentifer = @"DonePrefsIdentifer";
}
return item;
}
-(NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar
{
return [NSArray arrayWithObjects:
NSToolbarSpaceItemIdentifier,
NSToolbarFlexibleSpaceItemIdentifier,
kProfilePrefsIdentifier,
kGeneralPrefsIdentifier,
kAudioPrefsIdentifer,
kVideoPrefsIdentifer,
// kAncragePrefsIdentifer,
NSToolbarFlexibleSpaceItemIdentifier,
kDonePrefsIdentifer,
nil];
NSMutableArray* items = [NSMutableArray arrayWithObjects:
kPowerSettingsIdentifer,
NSToolbarFlexibleSpaceItemIdentifier,
kGeneralPrefsIdentifier,
kAudioPrefsIdentifer,
kVideoPrefsIdentifer,
// kAncragePrefsIdentifer,
NSToolbarFlexibleSpaceItemIdentifier,
kDonePrefsIdentifer,
nil];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"]) {
[items insertObject:NSToolbarSpaceItemIdentifier atIndex:5];
[items insertObject:kProfilePrefsIdentifier atIndex:2];
} else
[items insertObject:NSToolbarSpaceItemIdentifier atIndex:5];
return items;
}
-(NSArray *)toolbarSelectableItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:
kProfilePrefsIdentifier,
kGeneralPrefsIdentifier,
kAudioPrefsIdentifer,
// kAncragePrefsIdentifer,
kVideoPrefsIdentifer,
nil];
NSMutableArray* items = [NSMutableArray arrayWithObjects:
kPowerSettingsIdentifer,
kGeneralPrefsIdentifier,
kAudioPrefsIdentifer,
kVideoPrefsIdentifer,
nil];
if([[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"])
[items insertObject:kProfilePrefsIdentifier atIndex:1];
return items;
}
-(NSArray *)toolbarAllowedItemIdentifiers:(NSToolbar*)toolbar
......
......@@ -54,15 +54,13 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier";
- (IBAction)openPreferences:(id)sender
{
if(self.preferencesViewController != nil)
if(self.preferencesViewController != nil) {
[self closePreferences:nil];
return;
}
NSToolbar* tb = [[NSToolbar alloc] initWithIdentifier: @"PreferencesToolbar"];
self.preferencesViewController = [[PreferencesViewController alloc] initWithNibName:@"PreferencesScreen" bundle:nil];
self.myCurrentViewController = self.preferencesViewController;
NSLayoutConstraint* test = [NSLayoutConstraint constraintWithItem:self.preferencesViewController.view
......@@ -147,6 +145,17 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier";
[self.preferencesViewController displayAccounts:sender];
}
- (void)togglePowerSettings:(id)sender
{
BOOL advanced = [[NSUserDefaults standardUserDefaults] boolForKey:@"show_advanced"];
[[NSUserDefaults standardUserDefaults] setBool:!advanced forKey:@"show_advanced"];
[[NSUserDefaults standardUserDefaults] synchronize];
NSToolbar* tb = [[NSToolbar alloc] initWithIdentifier: @"PreferencesToolbar"];
[tb setDelegate: self.preferencesViewController];
[self.preferencesViewController displayGeneral:nil];
[self.window setToolbar:tb];
}
#pragma NSToolbar Delegate
......
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