Toolbars improvements, use SF Symbols when possible

This commit is contained in:
Damiano Galassi committed 2024-07-19 06:53:22 +02:00
1 parent d59f73bcb0
commit 94c083565f
6 files changed
+72 -32

No files matched your search

+6 -2
View File
@@ -7,7 +7,7 @@
import Cocoa
private extension NSToolbarItem.Identifier {
extension NSToolbarItem.Identifier {
static let queueAdd: NSToolbarItem.Identifier = NSToolbarItem.Identifier(rawValue: "QueueAdd")
static let queueSettings: NSToolbarItem.Identifier = NSToolbarItem.Identifier(rawValue: "QueueSettings")
static let queueStartStop: NSToolbarItem.Identifier = NSToolbarItem.Identifier(rawValue: "QueueStartStop")
@@ -22,18 +22,21 @@ class QueueToolbarDelegate: NSObject, NSToolbarDelegate {
label: NSLocalizedString("Add Item", comment: "Toolbar"),
toolTip: NSLocalizedString("Add an item to the queue", comment: "Toolbar"),
image: "NSAddTemplate",
symbolName: "plus",
action: #selector(QueueController.open(_:)))
} else if itemIdentifier == .queueSettings {
return ButtonToolbarItem(itemIdentifier: itemIdentifier,
label: NSLocalizedString("Settings", comment: "Toolbar"),
toolTip: NSLocalizedString("Show/Hide settings", comment: "Toolbar"),
image: "NSActionTemplate",
symbolName: "ellipsis.circle",
action: #selector(QueueController.toggleOptions(_:)))
} else if itemIdentifier == .queueStartStop {
return ButtonToolbarItem(itemIdentifier: itemIdentifier,
label: NSLocalizedString("Start", comment: "Toolbar"),
toolTip: NSLocalizedString("Start/Stop queue", comment: "Toolbar"),
image: "playBackTemplate",
symbolName: "play.fill",
action: #selector(QueueController.toggleStartStop(_:)))
}
@@ -52,9 +55,10 @@ class QueueToolbarDelegate: NSObject, NSToolbarDelegate {
guard let item = toolbar.items.first(where: { $0.itemIdentifier == .queueStartStop }) else { return }
if working {
item.setSymbol(symbolName: "stop.fill", fallbackName: "stopTemplate")
item.image = NSImage(named: "stopTemplate")
} else {
item.image = NSImage(named: "playBackTemplate")
item.setSymbol(symbolName: "play.fill", fallbackName: "playBackTemplate")
}
}
}