preferences: hide some advanced settings
Refs #66840
Change-Id: Ibcbe5c39d83372972d4df0e151ede6229fe5f590
diff --git a/AccGeneral.xib b/AccGeneral.xib
index d01a127..4e8f516 100644
--- a/AccGeneral.xib
+++ b/AccGeneral.xib
@@ -1,7 +1,8 @@
<?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">
diff --git a/AccRing.xib b/AccRing.xib
index f29b09d..82eebdb 100644
--- a/AccRing.xib
+++ b/AccRing.xib
@@ -1,8 +1,7 @@
<?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">
diff --git a/PreferencesScreen.xib b/PreferencesScreen.xib
index 18a6038..8bd4000 100644
--- a/PreferencesScreen.xib
+++ b/PreferencesScreen.xib
@@ -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>
diff --git a/PreferencesViewController.mm b/PreferencesViewController.mm
index f2bdde3..4feaa01 100644
--- a/PreferencesViewController.mm
+++ b/PreferencesViewController.mm
@@ -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 kAncragePrefsIdentifer = @"AncragePrefsIdentifer";
static NSString* const kVideoPrefsIdentifer = @"VideoPrefsIdentifer";
static NSString* const kDonePrefsIdentifer = @"DonePrefsIdentifer";
+static NSString* const kPowerSettingsIdentifer = @"PowerSettingsIdentifer";
-(void)loadView
{
@@ -172,12 +176,16 @@
[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 @@
}
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
diff --git a/RingWindowController.mm b/RingWindowController.mm
index 3ab4e4d..64cf7fa 100644
--- a/RingWindowController.mm
+++ b/RingWindowController.mm
@@ -54,15 +54,13 @@
- (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 @@
[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