feat: support for .icns icons
This commit is contained in:
@@ -45,7 +45,7 @@ There are a few ways to modify the menu structure:
|
||||
|
||||
#### Menu Icon
|
||||
|
||||
A subdirectory can have a custom icon if the folder contains an image file named `icon.X` (where `X` is one of: `svg`, `png`, `jpg`, `jpeg`, `gif`, `ico`).
|
||||
A subdirectory can have a custom icon if the folder contains an image file named `icon.X` (where `X` is one of: `svg`, `png`, `jpg`, `jpeg`, `gif`, `ico`, `icns`).
|
||||
|
||||
#### Sort Order
|
||||
|
||||
|
||||
@@ -299,19 +299,18 @@ struct Entry {
|
||||
}
|
||||
|
||||
func icon() -> NSImage? {
|
||||
guard isDir else {
|
||||
return nil
|
||||
}
|
||||
var img: NSImage? = nil
|
||||
for ext in ["svg", "png", "jpg", "jpeg", "gif", "ico"] {
|
||||
let iconPath = self.url.appendingPathComponent("icon." + ext)
|
||||
if FileManager.default.fileExists(atPath: iconPath.path) {
|
||||
img = NSImage(contentsOf: iconPath)
|
||||
break
|
||||
if isDir {
|
||||
for ext in ["svg", "png", "jpg", "jpeg", "gif", "ico", "icns"] {
|
||||
let iconPath = self.url.appendingPathComponent("icon." + ext)
|
||||
if FileManager.default.fileExists(atPath: iconPath.path) {
|
||||
img = NSImage(contentsOf: iconPath)
|
||||
break
|
||||
}
|
||||
}
|
||||
if img == nil {
|
||||
img = NSImage(named: NSImage.folderName)
|
||||
}
|
||||
}
|
||||
if img == nil {
|
||||
img = NSImage(named: NSImage.folderName)
|
||||
}
|
||||
img?.size = NSMakeSize(16, 16)
|
||||
return img
|
||||
|
||||
Reference in New Issue
Block a user