瀏覽代碼

UPD: improve Icons for the Folders with special ext on macOS

rich2014 2 月之前
父節點
當前提交
ed9e9882fe
共有 1 個文件被更改,包括 12 次插入5 次删除
  1. 12 5
      src/platform/unix/darwin/umydarwin.pas

+ 12 - 5
src/platform/unix/darwin/umydarwin.pas

@@ -36,7 +36,7 @@ interface
 uses
   Classes, SysUtils, UnixType,
   InterfaceBase, Menus, Controls, Forms,
-  uFileProperty, uFileSourceProperty, uDisplayFile, uFileView, uColumnsFileView,
+  uFileProperty, uDisplayFile, uFileView, uColumnsFileView,
   uLng,
   Cocoa_Extra, MacOSAll, CocoaAll, QuickLookUI,
   CocoaUtils, CocoaInt, CocoaPrivate, CocoaConst, CocoaMenus,
@@ -212,6 +212,9 @@ implementation
 uses
   DynLibs;
 
+var
+  ICON_SPECIAL_FOLDER_EXT: NSString;
+
 procedure onMainMenuCreate( menu: NSMenu );
 var
   lclForm: TObject;
@@ -711,6 +714,7 @@ begin
   HasMountURL:= Assigned(NetFSMountURLSync) or Assigned(FSMountServerVolumeSync);
   MacosServiceMenuHelper:= TMacosServiceMenuHelper.Create;
   DarwinFileViewDrawHelper:= TDarwinFileViewDrawHelper.Create;
+  ICON_SPECIAL_FOLDER_EXT:= NSSTR( '.app;.fcpbundle;.fcpxmld;.musiclibrary;.imovielibrary;.tvlibrary;.photoslibrary;.theater;' );
 end;
 
 procedure Finalize;
@@ -949,17 +953,20 @@ begin
   Result:= (pFinderInfo^.finderFlags and kHasCustomIcon) <> 0;
 end;
 
-function isExtUniqueIcon( const path: String ): Boolean;
+function hasSpecialFolderExt( const path: String ): Boolean;
+var
+  ext: NSString;
 begin
   Result:= False;
-  if path.EndsWith('.app') or path.EndsWith('.fcpbundle') or path.EndsWith('.fcpxmld') then
-    Result:= True;
+  ext:= StringToNSString(path).pathExtension;
+  ext:= NSSTR('.').stringByAppendingString(ext).stringByAppendingString(NSSTR(';'));
+  Result:= ICON_SPECIAL_FOLDER_EXT.containsString( ext );
 end;
 
 function getMacOSFileUniqueIcon( const path: String ): NSImage;
 begin
   Result:= nil;
-  if hasUniqueIcon(path) or isExtUniqueIcon(path) then
+  if hasUniqueIcon(path) or hasSpecialFolderExt(path) then
     Result:= NSWorkspace.sharedWorkspace.iconForFile( StringToNSString(path) );
 end;