diff --git a/Qdesktop/QDAppDelegate.h b/Qdesktop/QDAppDelegate.h index 7ed6a1c..12a6c5c 100644 --- a/Qdesktop/QDAppDelegate.h +++ b/Qdesktop/QDAppDelegate.h @@ -21,6 +21,7 @@ @property (weak) IBOutlet NSTextField *urlField; @property (weak) IBOutlet NSTextField *intervalTextField; @property (weak) IBOutlet NSButton *regularReloadCheckbox; +@property (weak) IBOutlet NSButton *interactWhenLaunchesCheckbox; #pragma mark IBActions - (IBAction)toggleBackground:(id)sender; diff --git a/Qdesktop/QDAppDelegate.m b/Qdesktop/QDAppDelegate.m index 54eddf5..c6aa7a7 100644 --- a/Qdesktop/QDAppDelegate.m +++ b/Qdesktop/QDAppDelegate.m @@ -16,6 +16,8 @@ static NSString *const qDefaultReloadRegularlyKey = @"update-regularly"; static NSString *const qDefaultIntervalKey = @"interval"; static const int qDefaultIntervalValue = 15; +static NSString *const qDefaultInteractWhenLaunchesKey = @"interact-when-launches"; +static const BOOL qDefaultInteractWhenLaunchesValue = NO; @interface QDAppDelegate () @@ -25,6 +27,7 @@ @interface QDAppDelegate () @property BOOL reloadRegularly; @property NSInteger interval; @property NSTimer *timer; +@property BOOL interactWhenLaunches; @end @@ -103,9 +106,9 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { [self resetTimer]; -#ifndef DEBUG - [self toggleBackground:self]; -#endif + if (!self.interactWhenLaunches) { + [self toggleBackground:self]; + } } #pragma mark Private @@ -137,12 +140,17 @@ - (void)setDefaultsIfNecessary { if ([self.userDefaults objectForKey:qDefaultIntervalKey] == nil) { [self.userDefaults setInteger:qDefaultIntervalValue forKey:qDefaultIntervalKey]; } + + if ([self.userDefaults objectForKey:qDefaultInteractWhenLaunchesKey] == nil) { + [self.userDefaults setBool:qDefaultInteractWhenLaunchesValue forKey:qDefaultInteractWhenLaunchesKey]; + } } - (void)readDefaults { self.url = [NSURL URLWithString:[self.userDefaults objectForKey:qDefaultUrlKey]]; self.reloadRegularly = [self.userDefaults boolForKey:qDefaultReloadRegularlyKey]; self.interval = [self.userDefaults integerForKey:qDefaultIntervalKey]; + self.interactWhenLaunches = [self.userDefaults boolForKey:qDefaultInteractWhenLaunchesKey]; } - (void)storeNewDefaults { @@ -157,6 +165,12 @@ - (void)storeNewDefaults { self.interval = self.intervalTextField.integerValue; [self.userDefaults setInteger:self.interval forKey:qDefaultIntervalKey]; + + self.interactWhenLaunches = NO; + if (self.interactWhenLaunchesCheckbox.state == NSOnState) { + self.interactWhenLaunches = YES; + } + [self.userDefaults setBool:self.interactWhenLaunches forKey:qDefaultInteractWhenLaunchesKey]; } - (void)syncPrefsUiElements { @@ -168,6 +182,11 @@ - (void)syncPrefsUiElements { } self.intervalTextField.integerValue = self.interval; + + self.interactWhenLaunchesCheckbox.state = NSOffState; + if (self.interactWhenLaunches) { + self.interactWhenLaunchesCheckbox.state = NSOnState; + } } - (void)resetTimer { diff --git a/Qdesktop/en.lproj/MainMenu.xib b/Qdesktop/en.lproj/MainMenu.xib index 871304d..4b63798 100644 --- a/Qdesktop/en.lproj/MainMenu.xib +++ b/Qdesktop/en.lproj/MainMenu.xib @@ -385,6 +385,7 @@ + @@ -420,10 +421,22 @@ - + + + + + + + + + + + NSNegateBoolean + + @@ -483,16 +496,16 @@ - + - + - + @@ -501,7 +514,7 @@ - + @@ -544,7 +557,7 @@ Gw + - + @@ -564,7 +588,7 @@ Gw - + @@ -610,18 +634,22 @@ Gw - - - - - + + + + + + + + +