Using SFSymbols where possible instead of custom icons

This commit is contained in:
Michael Starke
2021-02-03 20:29:57 +01:00
parent d0f8c3eafb
commit fa1094632e

View File

@@ -28,18 +28,20 @@
@implementation MPIconHelper @implementation MPIconHelper
+ (NSImage *)icon:(MPIconType)type { + (NSImage *)icon:(MPIconType)type {
if (@available(macOS 11.0, *)) {
static NSDictionary *symbols; static NSDictionary *symbols;
if(!symbols) { if(!symbols) {
symbols = MPIconHelper.availableSymbolNames; symbols = MPIconHelper.availableSymbolNames;
} }
if([symbols.allKeys containsObject:@(type)]) { if([symbols.allKeys containsObject:@(type)]) {
NSString *imageName = symbols[@(type)]; NSString *imageName = symbols[@(type)];
NSImage *image = [NSImage imageWithSystemSymbolName:imageName accessibilityDescription:nil]; NSImage *image = [NSImage imageWithSystemSymbolName:imageName accessibilityDescription:nil];
if(image) { if(image) {
return image; return image;
} }
} }
}
static NSDictionary *icons; static NSDictionary *icons;
@@ -105,84 +107,84 @@
symbolNames = @{ symbolNames = @{
@(MPIconPassword) : @"ellipsis.rectangle", @(MPIconPassword) : @"ellipsis.rectangle",
@(MPIconPackageNetwork) : @"globe", @(MPIconPackageNetwork) : @"globe",
@(MPIconWarning): @"exclamationmark.circle", @(MPIconWarning) : @"exclamationmark.triangle",
@(MPIconServer): @"macpro.gen3.server", @(MPIconServer) : @"server.rack",
@(MPIconKlipper): @"paperclip", @(MPIconKlipper) : @"pin",
@(MPIconLanguages) : @"mouth", @(MPIconLanguages) : @"mouth",
@(MPIconBlockDevice): @"06_BlockDeviceTemplate", @(MPIconBlockDevice) : @"gearshape.2",
@(MPIconNotepad): @"07_NotepadTemplate", @(MPIconNotepad) : @"note.text",
@(MPIconSocket): @"08_SocketTemplate", @(MPIconSocket) : @"rectangle.connected.to.line.below",
@(MPIconIdentity): @"09_IdentityTemplate", @(MPIconIdentity) : @"person.crop.square.fill.and.at.rectangle",
@(MPIconContact): @"10_ContactTemplate", @(MPIconContact) : @"at",
@(MPIconCamera): @"11_CameraTemplate", @(MPIconCamera) : @"camera",
@(MPIconRemote): @"12_RemoteTemplate", @(MPIconRemote) : @"icloud.fill",
@(MPIconKeys) : @"key", @(MPIconKeys) : @"key",
@(MPIconBattery): @"14_BatteryTemplate", @(MPIconBattery) : @"bolt.fill.batteryblock",
@(MPIconScanner): @"15_ScannerTemplate", @(MPIconScanner) : @"scanner",
@(MPIconBrowser): @"16_BrowserTemplate", @(MPIconBrowser) : @"safari",
@(MPIconCDRom): @"17_CDRomTemplate", @(MPIconCDRom) : @"opticaldisc",
@(MPIconDisplay): @"18_DisplayTemplate", @(MPIconDisplay) : @"display",
@(MPIconEmail): @"19_EmailTemplate", @(MPIconEmail) : @"envelope",
@(MPIconMisc): @"20_MiscTemplate", @(MPIconMisc) : @"ellipsis.circle",
@(MPIconOrganizer): @"21_OrganizerTemplate", @(MPIconOrganizer) : @"list.number",
@(MPIconASCII): @"22_ASCIITemplate", @(MPIconASCII) : @"doc.text",
@(MPIconIcons): @"23_IconsTemplate", @(MPIconIcons) : @"square.grid.3x3.fill.square",
@(MPIconEstablishedConnection): @"24_EstablishedConnectionTemplate", @(MPIconEstablishedConnection) : @"bolt",
@(MPIconMailFolder): @"25_MailFolderTemplate", @(MPIconMailFolder) : @"tray.full",
@(MPIconFileSave): @"26_FileSaveTemplate", @(MPIconFileSave) : @"square.and.arrow.down",
@(MPIconNFSUnmount) :@"27_NFSUnmountTemplate", @(MPIconNFSUnmount) : @"externaldrive.connected.to.line.below",
@(MPIconQuickTime) : @"28_QuickTimeTemplate", @(MPIconQuickTime) : @"film",
@(MPIconSecureTerminal) : @"29_SecureTerminalTemplate", @(MPIconSecureTerminal) : @"terminal",
@(MPIconTerminal) : @"30_TerminalTemplate", @(MPIconTerminal) : @"terminal",
@(MPIconPrint) : @"31_PrintTemplate", @(MPIconPrint) : @"printer",
@(MPIconFileSystemView) : @"32_FileSystemViewTemplate", @(MPIconFileSystemView) : @"square.grid.2x2",
@(MPIconRun) : @"33_RunTemplate", @(MPIconRun) : @"figure.walk.diamond",
@(MPIconConfigure) : @"34_ConfigureTemplate", @(MPIconConfigure) : @"slider.vertical.3",
@(MPIconBrowserWindow) : @"35_BrowserWindowTemplate", @(MPIconBrowserWindow) : @"macwindow",
@(MPIconArchive) : @"36_ArchiveTemplate", @(MPIconArchive) : @"doc.zipper",
@(MPIconPercentage) : @"37_PercentageTemplate", @(MPIconPercentage) : @"percent",
@(MPIconSambaUnmount) : @"38_SambaUnmountTemplate", @(MPIconSambaUnmount) : @"externaldrive.badge.xmark",
@(MPIconHistory) : @"39_HistoryTemplate", @(MPIconHistory) : @"clock.arrow.circlepath",
@(MPIconFindMail) : @"40_FindMailTemplate", @(MPIconFindMail) : @"mail.and.text.magnifyingglass",
@(MPIconVector) : @"41_VectorTemplate", @(MPIconVector) : @"skew",
@(MPIconMemory) : @"42_MemoryTemplate", @(MPIconMemory) : @"memorychip",
@(MPIconTrash): @"43_TrashTemplate", @(MPIconTrash) : @"trash",
@(MPIconNotes) : @"44_NotesTemplate", @(MPIconNotes) : @"note.text",
@(MPIconCancel) : @"45_CancelTemplate", @(MPIconCancel) : @"xmark.circle",
@(MPIconHelp) : @"46_HelpTemplate", @(MPIconHelp) : @"questionmark.circle.fill",
@(MPIconPackage) : @"47_PackageTemplate", @(MPIconPackage) : @"shippingbox",
@(MPIconFolder): @"48_FolderTemplate", @(MPIconFolder) : @"folder",
@(MPIconFolderOpen) : @"49_FolderOpenTemplate", @(MPIconFolderOpen) : @"folder",
@(MPIconFolderTar) : @"50_FolderTarTemplate", @(MPIconFolderTar) : @"archivebox",
@(MPIconDecrypted) : @"51_DecryptedTemplate", @(MPIconDecrypted) : @"lock.open",
@(MPIconEncrypted) : @"52_EncryptedTemplate", @(MPIconEncrypted) : @"lock",
@(MPIconApply) : @"53_ApplyTemplate", @(MPIconApply) : @"checkmark.square",
@(MPIconSignature) : @"54_SignatureTemplate", @(MPIconSignature) : @"signature",
@(MPIconThumbnail) : @"55_ThumbnailTemplate", @(MPIconThumbnail) : @"photo",
@(MPIconAddressBook) : @"56_AddressBookTemplate", @(MPIconAddressBook) : @"rectangle.stack.person.crop",
@(MPIconTextView) : @"57_TextViewTemplate", @(MPIconTextView) : @"text.justifyleft",
@(MPIconSecureAccount) : @"58_SecureAccountTemplate", @(MPIconSecureAccount) : @"person.fill.viewfinder",
@(MPIconDevelopment) : @"59_DevelopmentTemplate", @(MPIconDevelopment) : @"hammer",
@(MPIconHome) : @"60_HomeTemplate", @(MPIconHome) : @"house",
@(MPIconServices) : @"61_ServicesTemplate", @(MPIconServices) : @"star",
@(MPIconTux) : @"62_TuxTemplate", @(MPIconTux) : @"ladybug",
@(MPIconFeather) : @"63_FeatherTemplate", @(MPIconFeather) : @"lightbulb",
@(MPIconApple) : @"64_AppleTemplate", @(MPIconApple) : @"applelogo",
@(MPIconWiki) : @"65_WikiTemplate", @(MPIconWiki) : @"w.circle",
@(MPIconMoney) : @"66_MoneyTemplate", @(MPIconMoney) : @"dollarsign.circle",
@(MPIconCertificat) : @"67_CertificatTemplate", @(MPIconCertificat) : @"signature", // FIXME: find better icon
@(MPIconPhone): @"68_PhoneTemplate", @(MPIconPhone) : @"iphone",
/* Custom */ /* Custom */
@(MPIconInfo): @"sidebar.trailing", @(MPIconSidebar) : @"sidebar.trailing",
@(MPIconAddFolder): @"addFolderTemplate", @(MPIconAddFolder) : @"folder.badge.plus",
@(MPIconHardDisk): @"harddiskTemplate", @(MPIconHardDisk) : @"internaldrive",
@(MPIconCreated): @"createdTemplate", @(MPIconCreated) : @"staroflife", // FIXME: find better icon
@(MPIconAddEntry): @"addEntryTemplate", @(MPIconAddEntry) : @"ellipsis.rectangle", // FIXME: find better icon
@(MPIconContextTriangle): @"contextTriangleTemplate", @(MPIconContextTriangle) : @"arrowtriangle.down.fill",
@(MPIconKeyboard): @"keyboardTemplate", @(MPIconKeyboard) : @"keyboard",
@(MPIconExpiredEntry): NSImageNameCaution, @(MPIconExpiredEntry) : @"exclamationmark.octagon.fill",
@(MPIconExpiredGroup): NSImageNameCaution @(MPIconExpiredGroup) : @"exclamationmark.octagon.fill"
}; };
}); });