Skip to content

Commit

Permalink
Fix previous merge commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
codler committed Jun 22, 2013
1 parent 320849b commit ef14d97
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Battery Time Remaining/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
#define kBTRMenuSetting 6
#define kBTRMenuAdvanced 7
#define kBTRMenuParenthesis 8
#define kBTRMenuEnergySaverSetting 9
#define kBTRMenuUpdater 10
#define kBTRMenuQuitKey 11
#define kBTRMenuFahrenheit 12
#define kBTRMenuFahrenheit 9
#define kBTRMenuEnergySaverSetting 10
#define kBTRMenuUpdater 11
#define kBTRMenuQuitKey 12

#endif

Expand Down
32 changes: 21 additions & 11 deletions Battery Time Remaining/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ @interface AppDelegate ()
BOOL isOptionKeyPressed;
BOOL isCapacityWarning;
BOOL showParenthesis;
BOOL displayFahrenheit;
BOOL showFahrenheit;
}

- (void)cacheBatteryIcon;
Expand Down Expand Up @@ -130,17 +130,17 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
parenthesisSubmenuItem.state = (showParenthesis) ? NSOnState : NSOffState;

// Display in Fahrenheit menu item
NSMenuItem *displayFahrenheitSubmenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Display temperature in degrees Fahrenheit", @"Display temperature in Fahrenheit setting") action:@selector(toggleFahrenheit:) keyEquivalent:@""];
[displayFahrenheitSubmenuItem setTag:kBTRMenuFahrenheit];
displayFahrenheitSubmenuItem.target = self;
displayFahrenheit = [[NSUserDefaults standardUserDefaults] boolForKey:@"fahrenheit"];
displayFahrenheitSubmenuItem.state = (displayFahrenheit) ? NSOnState : NSOffState;
NSMenuItem *fahrenheitSubmenuItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Display temperature in Fahrenheit", @"Display temperature in Fahrenheit setting") action:@selector(toggleFahrenheit:) keyEquivalent:@""];
[fahrenheitSubmenuItem setTag:kBTRMenuFahrenheit];
fahrenheitSubmenuItem.target = self;
showFahrenheit = [[NSUserDefaults standardUserDefaults] boolForKey:@"fahrenheit"];
fahrenheitSubmenuItem.state = (showFahrenheit) ? NSOnState : NSOffState;

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

// Settings menu item
NSMenuItem *settingMenu = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Settings", @"Settings menuitem") action:nil keyEquivalent:@""];
Expand Down Expand Up @@ -387,12 +387,22 @@ - (void)updateStatusItemMenu
unpluggedTimerCount / 3600,
unpluggedTimerCount % 3600 / 60];

// Temperature
NSString *fahrenheitTranslated;
if (showFahrenheit) {
fahrenheitTranslated = [NSString stringWithFormat:NSLocalizedString(@"Temperature: %.1f°F", @"Advanced battery info menuitem"), [self convertCelsiusToFahrenheit:[temperature doubleValue]]];
}
else
{
fahrenheitTranslated = [NSString stringWithFormat:NSLocalizedString(@"Temperature: %.1f°C", @"Advanced battery info menuitem"), [temperature doubleValue]];
}

// Each item in array will be a row in menu
NSArray *advancedBatteryInfoTexts = [NSArray arrayWithObjects:
[NSString stringWithFormat:NSLocalizedString(@"Cycle count: %ld", @"Advanced battery info menuitem"), [cycleCount integerValue]],
[NSString stringWithFormat:NSLocalizedString(@"Power usage: %.2f Watt", @"Advanced battery info menuitem"), [watt doubleValue]],
timeSinceUnpluggedTranslated,
(displayFahrenheit) ? [NSString stringWithFormat:NSLocalizedString(@"Temperature: %.1f°F", @"Advanced battery info menuitem"), [self convertCelsiusToFahrenheit:[temperature doubleValue]]] : [NSString stringWithFormat:NSLocalizedString(@"Temperature: %.1f°C", @"Advanced battery info menuitem"), [temperature doubleValue]],
fahrenheitTranslated,
nil];

NSDictionary *advancedAttributedStyle = [NSDictionary dictionaryWithObjectsAndKeys:
Expand Down Expand Up @@ -640,13 +650,13 @@ - (void)toggleFahrenheit:(id)sender
if ([defaults boolForKey:@"fahrenheit"])
{
item.state = NSOffState;
displayFahrenheit = NO;
showFahrenheit = NO;
[defaults setBool:NO forKey:@"fahrenheit"];
}
else
{
item.state = NSOnState;
displayFahrenheit = YES;
showFahrenheit = YES;
[defaults setBool:YES forKey:@"fahrenheit"];
}
[defaults synchronize];
Expand Down Expand Up @@ -829,4 +839,4 @@ - (void)menuDidClose:(NSMenu *)menu
optionKeyPressedTimer = nil;
}

@end
@end
Binary file modified Battery Time Remaining/de.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/en.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/es.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/fr.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/it.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/ko.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/nl.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/pl.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/pt.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/ru.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/sk.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/sv.lproj/Localizable.strings
Binary file not shown.
Binary file modified Battery Time Remaining/zh-Hans.lproj/Localizable.strings
Binary file not shown.

0 comments on commit ef14d97

Please sign in to comment.