feat: add custom svg status bar icon
This commit is contained in:
1 parent
1cc6e68c70
commit
8965fb4209
4 files changed
+73
-8
No files matched your search
@@ -0,0 +1,10 @@
|
||||
<svg width="72" height="72" viewBox="0 0 72 72" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<title>OpenLess Status Icon</title>
|
||||
<rect x="6" y="6" width="60" height="60" rx="18" fill="white" fill-opacity="0.92"/>
|
||||
<rect x="6.75" y="6.75" width="58.5" height="58.5" rx="17.25" stroke="#111827" stroke-opacity="0.10" stroke-width="1.5"/>
|
||||
<path d="M51.2 18.2C47.1 14.4 41.7 12 35.8 12C22.7 12 12 22.7 12 35.8C12 48.9 22.7 59.6 35.8 59.6C45.2 59.6 53.4 54.1 57.2 46.2" stroke="#111827" stroke-width="8.8" stroke-linecap="round"/>
|
||||
<path d="M49 36H63" stroke="#2F80FF" stroke-width="7" stroke-linecap="round"/>
|
||||
<path d="M28.5 28.2V43.8" stroke="#111827" stroke-width="3.2" stroke-linecap="round"/>
|
||||
<path d="M35.8 24.8V47.2" stroke="#111827" stroke-width="3.2" stroke-linecap="round"/>
|
||||
<path d="M43.1 30.4V41.6" stroke="#111827" stroke-width="3.2" stroke-linecap="round"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 891 B |
@@ -10,15 +10,13 @@ final class MenuBarController {
|
||||
|
||||
init(coordinator: DictationCoordinator) {
|
||||
self.coordinator = coordinator
|
||||
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||
statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.squareLength)
|
||||
if let button = statusItem.button {
|
||||
if let image = NSImage(systemSymbolName: "mic.circle", accessibilityDescription: "OpenLess") {
|
||||
image.isTemplate = true
|
||||
button.image = image
|
||||
} else {
|
||||
button.title = "OL"
|
||||
}
|
||||
button.toolTip = "OpenLess — 点击菜单选择模式 / 退出"
|
||||
button.image = StatusBarIcon.image()
|
||||
button.imageScaling = .scaleProportionallyDown
|
||||
button.imagePosition = .imageOnly
|
||||
button.toolTip = "OpenLess — 点击菜单选择模式 / 退出"
|
||||
button.setAccessibilityLabel("OpenLess")
|
||||
}
|
||||
actions = MenuActions(coordinator: coordinator)
|
||||
statusItem.menu = buildMenu()
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
import AppKit
|
||||
|
||||
enum StatusBarIcon {
|
||||
static func image() -> NSImage {
|
||||
if let url = Bundle.main.url(forResource: "OpenLessStatusIcon", withExtension: "svg"),
|
||||
let image = NSImage(contentsOf: url) {
|
||||
image.size = NSSize(width: 18, height: 18)
|
||||
image.isTemplate = false
|
||||
return image
|
||||
}
|
||||
return fallbackImage()
|
||||
}
|
||||
|
||||
private static func fallbackImage() -> NSImage {
|
||||
let size = NSSize(width: 18, height: 18)
|
||||
let image = NSImage(size: size)
|
||||
image.lockFocus()
|
||||
defer { image.unlockFocus() }
|
||||
|
||||
NSColor.clear.setFill()
|
||||
NSRect(origin: .zero, size: size).fill()
|
||||
|
||||
let dark = NSColor(calibratedRed: 0.07, green: 0.09, blue: 0.12, alpha: 1)
|
||||
let blue = NSColor(calibratedRed: 0.18, green: 0.50, blue: 1.0, alpha: 1)
|
||||
let plate = NSBezierPath(roundedRect: NSRect(x: 1.7, y: 1.7, width: 14.6, height: 14.6), xRadius: 4.3, yRadius: 4.3)
|
||||
NSColor.white.withAlphaComponent(0.92).setFill()
|
||||
plate.fill()
|
||||
dark.withAlphaComponent(0.10).setStroke()
|
||||
plate.lineWidth = 0.45
|
||||
plate.stroke()
|
||||
|
||||
let ring = NSBezierPath()
|
||||
ring.lineWidth = 2.2
|
||||
ring.lineCapStyle = .round
|
||||
ring.appendArc(
|
||||
withCenter: NSPoint(x: 8.5, y: 9),
|
||||
radius: 6.1,
|
||||
startAngle: 42,
|
||||
endAngle: 330,
|
||||
clockwise: false
|
||||
)
|
||||
dark.setStroke()
|
||||
ring.stroke()
|
||||
|
||||
let dash = NSBezierPath()
|
||||
dash.lineWidth = 2.1
|
||||
dash.lineCapStyle = .round
|
||||
dash.move(to: NSPoint(x: 12.4, y: 9))
|
||||
dash.line(to: NSPoint(x: 16.1, y: 9))
|
||||
blue.setStroke()
|
||||
dash.stroke()
|
||||
|
||||
image.isTemplate = false
|
||||
return image
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ rm -rf "${APP_DIR}"
|
||||
mkdir -p "${BIN_DIR}" "${RES_DIR}"
|
||||
cp "${BIN_SRC}" "${BIN_DIR}/${APP_NAME}"
|
||||
cp "Resources/AppIcon.icns" "${RES_DIR}/AppIcon.icns"
|
||||
cp "Resources/StatusBar/OpenLessStatusIcon.svg" "${RES_DIR}/OpenLessStatusIcon.svg"
|
||||
|
||||
cat > "${APP_DIR}/Contents/Info.plist" <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
Reference in new issue
Block a user