2
0
Эх сурвалжийг харах

ADD: Capability to use 48x48 icons in the file list

Alexander Koblov 10 жил өмнө
parent
commit
33da2c958f

+ 1 - 0
src/frames/foptionsicons.lfm

@@ -40,6 +40,7 @@ inherited frmOptionsIcons: TfrmOptionsIcons
         '16x16'
         '22x22'
         '32x32'
+        '48x48'
       )
       OnChange = cbIconsSizeChange
       Style = csDropDownList

+ 2 - 0
src/frames/foptionsicons.pas

@@ -78,6 +78,7 @@ begin
     0: iSize:= 16;
     1: iSize:= 22;
     2: iSize:= 32;
+    3: iSize:= 48;
   end;
   bmpTemp:= PixmapManager.GetDefaultDriveIcon(iSize, pnlIconExample.Color);
   imgIconExample.Picture.Bitmap.Assign(bmpTemp);
@@ -144,6 +145,7 @@ begin
     0: SelectedIconsSize := 16;
     1: SelectedIconsSize := 22;
     2: SelectedIconsSize := 32;
+    3: SelectedIconsSize := 48;
   else SelectedIconsSize := gIconsSizeNew;
   end;
 

+ 9 - 11
src/platform/upixmapmanager.pas

@@ -1170,7 +1170,6 @@ var
   systemVersion: SInt32;
 {$ELSEIF DEFINED(MSWINDOWS)}
 var
-  FileInfo : TSHFileInfoW;
   iIconSize : Integer;
 {$ENDIF}
 begin
@@ -1189,16 +1188,13 @@ begin
   CreateIconTheme;
 
   {$IFDEF MSWINDOWS}
-  if gIconsSize = 16 then
-    iIconSize := SHGFI_SMALLICON
-  else
-    iIconSize := SHGFI_LARGEICON;
+  case gIconsSize of
+    16: iIconSize := SHIL_SMALL;
+    32: iIconSize := SHIL_LARGE;
+    else iIconSize := SHIL_EXTRALARGE;
+  end;
 
-  FSysImgList := SHGetFileInfoW(PWideChar(UTF8Decode(mbGetCurrentDir)),
-                                0,
-                                FileInfo,
-                                SizeOf(FileInfo),
-                                SHGFI_SYSICONINDEX or iIconSize);
+  FSysImgList := SHGetSystemImageList(iIconSize);
   {$ENDIF}
 
   FPixmapsLock := syncobjs.TCriticalSection.Create;
@@ -1311,6 +1307,8 @@ begin
   // load emblems
   if gIconsSize = 22 then
     I:= 16
+  else if gIconsSize = 48 then
+    I:= 22
   else
     I:= gIconsSize div 2;
   FiEmblemLinkID:= CheckAddThemePixmap('emblem-symbolic-link', I);
@@ -1545,7 +1543,7 @@ begin
       else
         TrySetSize(gIconsSize, gIconsSize);
 
-      if (Height in [16, 32]) and (cx = Width) and (cy = Height) then
+      if (Height in [16, 32, 48]) and (cx = Width) and (cy = Height) then
         // for transparent
         ImageList_Draw(FSysImgList, iIndex - SystemIconIndexStart, Canvas.Handle, X, Y, ILD_TRANSPARENT)
       else

+ 41 - 0
src/platform/win/ushlobjadditional.pas

@@ -28,6 +28,9 @@ const
    { User canceled the current action }
    COPYENGINE_E_USER_CANCELLED: HRESULT = HRESULT($80270000);
 
+const
+  IID_IImageList: TGUID = '{46EB5926-582E-4017-9FDF-E8998DAA0950}';
+
 { IShellIconOverlay Interface }
 {
    Used to return the icon overlay index or its icon index for an IShellFolder object,
@@ -62,6 +65,7 @@ type
       function GetOverlayIconIndex(pidl : PItemIDList; var IconIndex : Integer) : HResult; stdcall;
    end; { IShellIconOverlay }
 
+function SHGetSystemImageList(iImageList: Integer): HIMAGELIST;
 function SHChangeIconDialog(hOwner: HWND; var FileName: UTF8String; var IconIndex: Integer): Boolean;
 function SHGetOverlayIconIndex(const sFilePath, sFileName: UTF8String): Integer;
 function SHGetInfoTip(const sFilePath, sFileName: UTF8String): UTF8String;
@@ -81,6 +85,43 @@ implementation
 uses
   SysUtils, ShellApi, JwaShlGuid, ComObj;
 
+function SHGetImageListFallback(iImageList: Integer; const riid: TGUID; var ImageList: HIMAGELIST): HRESULT; stdcall;
+var
+  FileInfo: TSHFileInfoW;
+  Flags: UINT = SHGFI_SYSICONINDEX;
+begin
+  if not IsEqualGUID(riid, IID_IImageList) then Exit(E_NOINTERFACE);
+  case iImageList of
+  SHIL_LARGE,
+  SHIL_EXTRALARGE:
+    Flags:= Flags or SHGFI_LARGEICON;
+  SHIL_SMALL:
+    Flags:= Flags or SHGFI_SMALLICON;
+  end;
+  ZeroMemory(@FileInfo, SizeOf(TSHFileInfoW));
+  ImageList:= SHGetFileInfoW('', 0, FileInfo, SizeOf(FileInfo), Flags);
+  if ImageList <> 0 then Exit(S_OK) else Exit(E_FAIL);
+end;
+
+function SHGetSystemImageList(iImageList: Integer): HIMAGELIST;
+var
+  ShellHandle: THandle;
+  SHGetImageList: function(iImageList: Integer; const riid: TGUID; var ImageList: HIMAGELIST): HRESULT; stdcall;
+begin
+  Result:= 0;
+  ShellHandle:= GetModuleHandle(Shell32);
+  if (ShellHandle <> 0) then
+  begin
+    @SHGetImageList:= GetProcAddress(ShellHandle, 'SHGetImageList');
+    if @SHGetImageList = nil then
+    begin
+      @SHGetImageList:= GetProcAddress(ShellHandle, PAnsiChar(727));
+      if @SHGetImageList = nil then SHGetImageList:= @SHGetImageListFallback;
+    end;
+    SHGetImageList(iImageList, IID_IImageList, Result);
+  end;
+end;
+
 function SHChangeIconDialog(hOwner: HWND; var FileName: UTF8String; var IconIndex: Integer): Boolean;
 type
   TSHChangeIconProcW = function(Wnd: HWND; szFileName: PWideChar; Reserved: Integer;