@@ -16,9 +16,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
1616 var windowController : SideNotesWindowController ?
1717 var onboardingWindowController : OnboardingWindowController ?
1818 var settingsWindowController : SettingsWindowController ?
19+ var statusItem : NSStatusItem ?
1920
2021 func applicationDidFinishLaunching( _ notification: Notification ) {
2122 updateDockIconVisibility ( )
23+ setupMenuBar ( )
2224
2325 windowController = SideNotesWindowController ( )
2426
@@ -108,4 +110,50 @@ class AppDelegate: NSObject, NSApplicationDelegate {
108110 }
109111 }
110112 }
113+
114+ private func setupMenuBar( ) {
115+ statusItem = NSStatusBar . system. statusItem ( withLength: NSStatusItem . squareLength)
116+
117+ if let button = statusItem? . button {
118+ button. image = NSImage ( systemSymbolName: " note.text " , accessibilityDescription: " Open Sidenotes " )
119+ }
120+
121+ let menu = NSMenu ( )
122+
123+ menu. addItem ( NSMenuItem (
124+ title: " Toggle Window " ,
125+ action: #selector( toggleWindow) ,
126+ keyEquivalent: " "
127+ ) )
128+
129+ menu. addItem ( NSMenuItem . separator ( ) )
130+
131+ menu. addItem ( NSMenuItem (
132+ title: " Settings... " ,
133+ action: #selector( openSettings) ,
134+ keyEquivalent: " , "
135+ ) )
136+
137+ menu. addItem ( NSMenuItem . separator ( ) )
138+
139+ menu. addItem ( NSMenuItem (
140+ title: " Quit Sidenotes " ,
141+ action: #selector( quitApp) ,
142+ keyEquivalent: " q "
143+ ) )
144+
145+ statusItem? . menu = menu
146+ }
147+
148+ @objc private func toggleWindow( ) {
149+ windowController? . toggleWindow ( )
150+ }
151+
152+ @objc private func openSettings( ) {
153+ showSettings ( )
154+ }
155+
156+ @objc private func quitApp( ) {
157+ NSApplication . shared. terminate ( nil )
158+ }
111159}
0 commit comments