Allow hiding the menu bar icon

closes #40
This commit is contained in:
Grishka
2023-09-26 05:18:12 +03:00
parent 0c1a158c32
commit a43d812950
2 changed files with 7 additions and 1 deletions

View File

@@ -23,6 +23,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
statusItem=NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength) statusItem=NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
statusItem?.button?.image=NSImage(named: "MenuBarIcon") statusItem?.button?.image=NSImage(named: "MenuBarIcon")
statusItem?.menu=menu statusItem?.menu=menu
statusItem?.behavior = .removalAllowed
let nc=UNUserNotificationCenter.current() let nc=UNUserNotificationCenter.current()
nc.requestAuthorization(options: [.alert, .sound]) { granted, err in nc.requestAuthorization(options: [.alert, .sound]) { granted, err in
@@ -39,6 +40,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
NearbyConnectionManager.shared.mainAppDelegate=self NearbyConnectionManager.shared.mainAppDelegate=self
NearbyConnectionManager.shared.becomeVisible() NearbyConnectionManager.shared.becomeVisible()
} }
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
statusItem?.isVisible=true
return true
}
func applicationWillTerminate(_ aNotification: Notification) { func applicationWillTerminate(_ aNotification: Notification) {
UNUserNotificationCenter.current().removeAllDeliveredNotifications() UNUserNotificationCenter.current().removeAllDeliveredNotifications()

View File

@@ -349,7 +349,7 @@ class InboundNearbyConnection: NearbyConnection{
currentState = .receivingFiles currentState = .receivingFiles
try sendTransferSetupFrame(frame) try sendTransferSetupFrame(frame)
}catch{ }catch{
print("Error \(error)") lastError=error
protocolError() protocolError()
} }
} }