updates plug with all sorts of awesome improvements
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
import AppKit
|
||||
|
||||
/// The menu bar icon with Show, Hide and Quit.
|
||||
/// The menu bar icon with Show, Hide, Help and Quit.
|
||||
@MainActor
|
||||
final class StatusMenu: NSObject {
|
||||
private let item = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
|
||||
private let show: () -> Void
|
||||
private let hide: () -> Void
|
||||
private let help: () -> Void
|
||||
|
||||
init(show: @escaping () -> Void, hide: @escaping () -> Void) {
|
||||
init(show: @escaping () -> Void, hide: @escaping () -> Void, help: @escaping () -> Void) {
|
||||
self.show = show
|
||||
self.hide = hide
|
||||
self.help = help
|
||||
super.init()
|
||||
let image = NSImage(systemSymbolName: "note.text", accessibilityDescription: "Plak")
|
||||
image?.isTemplate = true
|
||||
item.button?.image = image
|
||||
let menu = NSMenu()
|
||||
menu.addItem(withTitle: "Show Plak", action: #selector(showPlak), keyEquivalent: "p").target = self
|
||||
menu.addItem(withTitle: "Show Plak", action: #selector(showPlak), keyEquivalent: "n").target = self
|
||||
menu.addItem(withTitle: "Hide Plak", action: #selector(hidePlak), keyEquivalent: "").target = self
|
||||
menu.addItem(.separator())
|
||||
menu.addItem(withTitle: "Plak Help", action: #selector(plakHelp), keyEquivalent: "").target = self
|
||||
menu.addItem(.separator())
|
||||
menu.addItem(withTitle: "Quit Plak", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
||||
item.menu = menu
|
||||
}
|
||||
@@ -29,4 +33,8 @@ final class StatusMenu: NSObject {
|
||||
@objc private func hidePlak() {
|
||||
hide()
|
||||
}
|
||||
|
||||
@objc private func plakHelp() {
|
||||
help()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user