Welcome message

This commit is contained in:
relikd
2019-08-11 12:45:06 +02:00
parent c717487b0e
commit b081564eca
12 changed files with 74 additions and 30 deletions

View File

@@ -27,6 +27,7 @@
#import "UserPrefs.h"
#import "BarMenu.h"
#import "AppHook.h"
#import "NSView+Ext.h"
@interface BarStatusItem()
@property (strong) BarMenu *barMenu;
@@ -45,8 +46,8 @@
self.statusItem = [NSStatusBar.systemStatusBar statusItemWithLength:NSVariableStatusItemLength];
self.statusItem.highlightMode = YES;
self.unreadCountTotal = 0;
[self updateBarIcon];
[self asyncReloadUnreadCount];
self.statusItem.image = [NSImage imageNamed:RSSImageMenuBarIconActive];
self.statusItem.image.template = YES;
// Add empty menu (will be populated once opened)
self.statusItem.menu = [[NSMenu alloc] initWithTitle:@"M"];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainMenuWillOpen) name:NSMenuDidBeginTrackingNotification object:self.statusItem.menu];
@@ -126,6 +127,26 @@
});
}
/// Show popover with a brief notice that baRSS is running in the menu bar
- (void)showWelcomeMessage {
NSString *title = [NSString stringWithFormat:NSLocalizedString(@"Welcome to %@", nil), [UserPrefs appName]];
NSString *message = NSLocalizedString(@"There's no application window.\nEverything is up there.", nil);
NSTextField *head = [[NSView label:title] bold];
NSTextField *body = [[NSView label:message] small];
const CGFloat pad = 12;
CGFloat icon = NSHeight(head.frame) + PAD_S + NSHeight(body.frame);
CGFloat dx = pad + icon + PAD_L; // where text begins
NSPopover *pop = [NSView popover:NSMakeSize(dx + NSMaxWidth(head, body) + pad, icon + 2 * pad)];
NSView *content = pop.contentViewController.view;
[[NSView imageView:NSImageNameApplicationIcon size:icon] placeIn:content x:pad y:pad];
[head placeIn:content x:dx yTop:pad];
[body placeIn:content x:dx y:pad];
[pop showRelativeToRect:NSZeroRect ofView:self.statusItem.button preferredEdge:NSRectEdgeMaxY];
}
#pragma mark - Main Menu Handling