Cleaned up code for status bar and status bar menu

This commit is contained in:
Robert McGovern 2021-05-31 22:42:01 +01:00
parent 86effa4e2f
commit 4a18277a3a
1 changed files with 19 additions and 19 deletions

View File

@ -219,28 +219,28 @@ BOOL appRunning = NO;
- (void) showStatusBarItem: (BOOL) show {
if (show) {
// if (statusBarItem == nil) {
statusBarItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
statusBarItem.button.title = @"🎫"; //RMCG
statusBarItem.button.title = @"🎫"; //RMCG change to something more appropriate
[statusBarItem setMenu:[self makeStatusBarMenu]];
} else {
[NSStatusBar.systemStatusBar removeStatusItem:statusBarItem];
}
}
// optional create a menu for the button
- (NSMenu *) makeStatusBarMenu {
NSMenu * statusBarMenu = [[NSMenu alloc] init];
[statusBarMenu setTitle:@"QuietUnrar Menu"];
NSMenuItem * preferencesMenuItem = [[NSMenuItem alloc] initWithTitle:@"Show Preferences" action:@selector(showPreferencesWindow) keyEquivalent:@""];
[statusBarMenu addItem:preferencesMenuItem];
NSMenuItem * showDockItem = [[NSMenuItem alloc] initWithTitle:@"Show Dock" action:@selector(showPreferencesWindow) keyEquivalent:@""];
[statusBarMenu addItem:showDockItem];
// NSMenuItem * showDockItem = [[NSMenuItem alloc] initWithTitle:@"Show Dock " action:@selector(showPreferencesWindow) keyEquivalent:@""];
// [statusBarMenu addItem:showDockItem];
//
NSMenuItem * quitMenuItem = [[NSMenuItem alloc] initWithTitle:@"Quit QuietUnrar" action:@selector(quit) keyEquivalent:@""];
[statusBarMenu addItem:quitMenuItem];
[statusBarItem setMenu:statusBarMenu];
// }
} else {
[NSStatusBar.systemStatusBar removeStatusItem:statusBarItem];
}
return statusBarMenu;
}
- (void) showPreferencesWindow {