diff --git a/syncthing/STApplication.m b/syncthing/STApplication.m index 67aaa7a..52f0aed 100644 --- a/syncthing/STApplication.m +++ b/syncthing/STApplication.m @@ -214,6 +214,12 @@ // TODO: need a more generic approach for opening windows - (IBAction)clickedPreferences:(NSMenuItem *)sender { + if (_preferencesWindow != nil) { + [NSApp activateIgnoringOtherApps:YES]; + [_preferencesWindow.window makeKeyAndOrderFront:self]; + return; + } + _preferencesWindow = [[STPreferencesWindowController alloc] init]; [_preferencesWindow showWindow:nil]; [[NSNotificationCenter defaultCenter] addObserver:self @@ -223,12 +229,18 @@ } - (IBAction)clickedAbout:(NSMenuItem *)sender { - _aboutWindow = [[STAboutWindowController alloc] init]; - [_aboutWindow showWindow:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(aboutWillClose:) - name:NSWindowWillCloseNotification - object:[_aboutWindow window]]; + if (_aboutWindow != nil) { + [NSApp activateIgnoringOtherApps:YES]; + [_aboutWindow.window makeKeyAndOrderFront:self]; + return; + } + + _aboutWindow = [[STAboutWindowController alloc] init]; + [_aboutWindow showWindow:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(aboutWillClose:) + name:NSWindowWillCloseNotification + object:[_aboutWindow window]]; } // TODO: need a more generic approach for closing windows