Skip to content

Commit

Permalink
Merge conflict #64
Browse files Browse the repository at this point in the history
  • Loading branch information
codler committed Jun 22, 2013
2 parents ef14d97 + 723ba5b commit 03bda33
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
1 change: 1 addition & 0 deletions Battery Time Remaining/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#define kBTRMenuEnergySaverSetting 10
#define kBTRMenuUpdater 11
#define kBTRMenuQuitKey 12
#define kBTRMenuWhiteText 13

#endif

Expand Down
49 changes: 43 additions & 6 deletions Battery Time Remaining/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ @interface AppDelegate ()
BOOL isCapacityWarning;
BOOL showParenthesis;
BOOL showFahrenheit;
BOOL whiteText;
}

- (void)cacheBatteryIcon;
Expand Down Expand Up @@ -136,11 +137,19 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
showFahrenheit = [[NSUserDefaults standardUserDefaults] boolForKey:@"fahrenheit"];
fahrenheitSubmenuItem.state = (showFahrenheit) ? NSOnState : NSOffState;

// Toggle Black & White Text
NSMenuItem *colorTextSubmenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"White Text Color", @"White Text Color") action:@selector(toggleTextColor:) keyEquivalent:@""];
[colorTextSubmenuItem setTag:kBTRMenuWhiteText];
colorTextSubmenuItem.target = self;
whiteText = [[NSUserDefaults standardUserDefaults] boolForKey:@"whiteText"];
colorTextSubmenuItem.state = (whiteText) ? NSOnState : NSOffState;

// Build the setting submenu
NSMenu *settingSubmenu = [[NSMenu alloc] initWithTitle:@"Setting Menu"];
[settingSubmenu addItem:advancedSubmenuItem];
[settingSubmenu addItem:parenthesisSubmenuItem];
[settingSubmenu addItem:fahrenheitSubmenuItem];
[settingSubmenu addItem:colorTextSubmenuItem];

// Settings menu item
NSMenuItem *settingMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"Settings menuitem") action:nil keyEquivalent:@""];
Expand Down Expand Up @@ -433,11 +442,18 @@ - (void)setStatusBarImage:(NSImage *)image title:(NSString *)title
[self.statusItem setAlternateImage:[ImageFilter invertColor:image]];

// Title
NSDictionary *attributedStyle = [NSDictionary dictionaryWithObjectsAndKeys:
// Font
[NSFont menuFontOfSize:12.0f],
NSFontAttributeName,
nil];
NSMutableDictionary *attributedStyle = [NSMutableDictionary dictionaryWithObjectsAndKeys:
// Font
[NSFont menuFontOfSize:12.0f],
NSFontAttributeName,
nil];

if(whiteText) {
[attributedStyle setObject:[NSColor whiteColor] forKey:NSForegroundColorAttributeName];
} else {
[attributedStyle setObject:[NSColor blackColor] forKey:NSForegroundColorAttributeName];
}


NSAttributedString *attributedTitle = [[NSAttributedString alloc] initWithString:title attributes:attributedStyle];
self.statusItem.attributedTitle = attributedTitle;
Expand Down Expand Up @@ -664,6 +680,27 @@ - (void)toggleFahrenheit:(id)sender
[self updateStatusItem];
}

- (void)toggleTextColor:(id)sender {
NSMenuItem *item = sender;
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

if ([defaults boolForKey:@"whiteText"])
{
item.state = NSOffState;
whiteText = NO;
[defaults setBool:NO forKey:@"whiteText"];
}
else
{
item.state = NSOnState;
whiteText = YES;
[defaults setBool:YES forKey:@"whiteText"];
}
[defaults synchronize];

[self updateStatusItem];
}

- (void)notify:(NSString *)message
{
[self notify:@"Battery Time Remaining" message:message];
Expand Down Expand Up @@ -839,4 +876,4 @@ - (void)menuDidClose:(NSMenu *)menu
optionKeyPressedTimer = nil;
}

@end
@end

0 comments on commit 03bda33

Please sign in to comment.