feat: svg status icon
This commit is contained in:
3
res/status.svg
Normal file
3
res/status.svg
Normal file
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000">
|
||||
<path id="_x2318_" d="M335,335m-145,0a145,145,0,1,1,145,-145v620a145,145,0,1,1,-145,-145h620a145,145,0,1,1,-145,145v-620a145,145,0,1,1,145,145Z" stroke="black" stroke-width="90" fill="none"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 263 B |
@@ -20,12 +20,22 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSMenuDelegate {
|
||||
|
||||
private func initStatusIcon() {
|
||||
self.statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||
self.statusItem.button?.title = "⌘"
|
||||
// self.statusItem.button?.image = NSImage.statusIcon
|
||||
if let img = statusIcon() {
|
||||
self.statusItem.button?.image = img
|
||||
} else {
|
||||
self.statusItem.button?.title = "⌘" // cant load svg (<10.15)
|
||||
}
|
||||
self.statusItem.menu = NSMenu(title: resolvedStorageURL().path)
|
||||
self.statusItem.menu?.delegate = self
|
||||
}
|
||||
|
||||
private func statusIcon() -> NSImage? {
|
||||
let img = NSImage(contentsOf: resFile("status", "svg"))
|
||||
img?.isTemplate = true
|
||||
img?.size = NSMakeSize(14, 14)
|
||||
return img
|
||||
}
|
||||
|
||||
func menuDidClose(_ menu: NSMenu) {
|
||||
if menu == self.statusItem.menu {
|
||||
self.statusItem.menu = NSMenu(title: menu.title)
|
||||
|
||||
Reference in New Issue
Block a user