fix: preferences panel icons wouldnt show on old macos versions

This commit is contained in:
lwouis
2024-10-12 11:03:40 +02:00
parent d46d90395c
commit 9258acf765
3 changed files with 10 additions and 3 deletions
+1
View File
@@ -53,6 +53,7 @@ They helped [localize the app](https://poeditor.com/join/project/8AOEZ0eAZE):
* Ameng
* Anders
* Andrew Vader
* antoon334
* Anurag Roy
* anushree b
* Arman
@@ -261,6 +261,7 @@ class LabelAndControl: NSObject {
}
if #available(macOS 11.0, *) {
if let preference = preference as? SfSymbolMacroPreference,
// each systemSymbolName has a different minimum macOS requirements; we need to make sure it exists
let symbolImage = NSImage(systemSymbolName: preference.symbolName, accessibilityDescription: nil) {
button.setImage(symbolImage, forSegment: i)
}
@@ -67,9 +67,14 @@ class PreferencesWindow: NSWindow, NSToolbarDelegate {
let item = NSToolbarItem(itemIdentifier: identifier)
item.label = label
if #available(macOS 11.0, *) {
item.image = NSImage(systemSymbolName: image, accessibilityDescription: nil)
} else {
item.image = NSImage.initTemplateCopy(image)
// each systemSymbolName has a different minimum macOS requirements; we need to make sure it exists
if let image = NSImage(systemSymbolName: image, accessibilityDescription: nil) {
item.image = image
}
}
// it seems that new instances of NSToolbarItems have their image set to a 1x1 image
if item.image == nil || item.image!.size == .init(width: 1, height: 1) {
item.image = NSImage.initTemplateCopy(id)
item.maxSize = .init(width: 22, height: 22)
}
item.target = self