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 { - (void) showStatusBarItem: (BOOL) show {
if (show) { if (show) {
// if (statusBarItem == nil) {
statusBarItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength]; 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]; NSMenu * statusBarMenu = [[NSMenu alloc] init];
[statusBarMenu setTitle:@"QuietUnrar Menu"]; [statusBarMenu setTitle:@"QuietUnrar Menu"];
NSMenuItem * preferencesMenuItem = [[NSMenuItem alloc] initWithTitle:@"Show Preferences" action:@selector(showPreferencesWindow) keyEquivalent:@""]; NSMenuItem * preferencesMenuItem = [[NSMenuItem alloc] initWithTitle:@"Show Preferences" action:@selector(showPreferencesWindow) keyEquivalent:@""];
[statusBarMenu addItem:preferencesMenuItem]; [statusBarMenu addItem:preferencesMenuItem];
NSMenuItem * showDockItem = [[NSMenuItem alloc] initWithTitle:@"Show Dock" action:@selector(showPreferencesWindow) keyEquivalent:@""]; // NSMenuItem * showDockItem = [[NSMenuItem alloc] initWithTitle:@"Show Dock " action:@selector(showPreferencesWindow) keyEquivalent:@""];
[statusBarMenu addItem:showDockItem]; // [statusBarMenu addItem:showDockItem];
//
NSMenuItem * quitMenuItem = [[NSMenuItem alloc] initWithTitle:@"Quit QuietUnrar" action:@selector(quit) keyEquivalent:@""]; NSMenuItem * quitMenuItem = [[NSMenuItem alloc] initWithTitle:@"Quit QuietUnrar" action:@selector(quit) keyEquivalent:@""];
[statusBarMenu addItem:quitMenuItem]; [statusBarMenu addItem:quitMenuItem];
[statusBarItem setMenu:statusBarMenu]; return statusBarMenu;
// }
} else {
[NSStatusBar.systemStatusBar removeStatusItem:statusBarItem];
}
} }
- (void) showPreferencesWindow { - (void) showPreferencesWindow {