@@ -39,6 +39,7 @@ @interface AppDelegate ()
39
39
BOOL isOptionKeyPressed;
40
40
BOOL isCapacityWarning;
41
41
BOOL showParenthesis;
42
+ BOOL whiteText;
42
43
}
43
44
44
45
- (void )cacheBatteryIcon ;
@@ -124,10 +125,18 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
124
125
showParenthesis = [[NSUserDefaults standardUserDefaults ] boolForKey: @" parentheses" ];
125
126
parenthesisSubmenuItem.state = (showParenthesis) ? NSOnState : NSOffState ;
126
127
128
+ // Toggle Black & White Text
129
+ NSMenuItem *colorTextSubmenuItem = [[NSMenuItem alloc ] initWithTitle: NSLocalizedString(@" White Text Color" , @" White Text Color" ) action: @selector (toggleTextColor: ) keyEquivalent: @" " ];
130
+ [colorTextSubmenuItem setTag: kBTRMenuWhiteText ];
131
+ colorTextSubmenuItem.target = self;
132
+ whiteText = [[NSUserDefaults standardUserDefaults ] boolForKey: @" whiteText" ];
133
+ colorTextSubmenuItem.state = (whiteText) ? NSOnState : NSOffState ;
134
+
127
135
// Build the setting submenu
128
136
NSMenu *settingSubmenu = [[NSMenu alloc ] initWithTitle: @" Setting Menu" ];
129
137
[settingSubmenu addItem: advancedSubmenuItem];
130
138
[settingSubmenu addItem: parenthesisSubmenuItem];
139
+ [settingSubmenu addItem: colorTextSubmenuItem];
131
140
132
141
// Settings menu item
133
142
NSMenuItem *settingMenu = [[NSMenuItem alloc ] initWithTitle: NSLocalizedString(@" Settings" , @" Settings menuitem" ) action: nil keyEquivalent: @" " ];
@@ -363,11 +372,18 @@ - (void)setStatusBarImage:(NSImage *)image title:(NSString *)title
363
372
[self .statusItem setAlternateImage: [ImageFilter invertColor: image]];
364
373
365
374
// Title
366
- NSDictionary *attributedStyle = [NSDictionary dictionaryWithObjectsAndKeys:
367
- // Font
368
- [NSFont menuFontOfSize: 12 .0f ],
369
- NSFontAttributeName ,
370
- nil ];
375
+ NSMutableDictionary *attributedStyle = [NSMutableDictionary dictionaryWithObjectsAndKeys:
376
+ // Font
377
+ [NSFont menuFontOfSize: 12 .0f ],
378
+ NSFontAttributeName ,
379
+ nil ];
380
+
381
+ if (whiteText) {
382
+ [attributedStyle setObject: [NSColor whiteColor ] forKey: NSForegroundColorAttributeName ];
383
+ } else {
384
+ [attributedStyle setObject: [NSColor blackColor ] forKey: NSForegroundColorAttributeName ];
385
+ }
386
+
371
387
372
388
NSAttributedString *attributedTitle = [[NSAttributedString alloc ] initWithString: title attributes: attributedStyle];
373
389
self.statusItem .attributedTitle = attributedTitle;
@@ -572,6 +588,27 @@ - (void)toggleParenthesis:(id)sender
572
588
[self updateStatusItem ];
573
589
}
574
590
591
+ - (void )toggleTextColor : (id )sender {
592
+ NSMenuItem *item = sender;
593
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults ];
594
+
595
+ if ([defaults boolForKey: @" whiteText" ])
596
+ {
597
+ item.state = NSOffState ;
598
+ whiteText = NO ;
599
+ [defaults setBool: NO forKey: @" whiteText" ];
600
+ }
601
+ else
602
+ {
603
+ item.state = NSOnState ;
604
+ whiteText = YES ;
605
+ [defaults setBool: YES forKey: @" whiteText" ];
606
+ }
607
+ [defaults synchronize ];
608
+
609
+ [self updateStatusItem ];
610
+ }
611
+
575
612
- (void )notify : (NSString *)message
576
613
{
577
614
[self notify: @" Battery Time Remaining" message: message];
0 commit comments