FIX: OneDrive sync status icon overlays not showing (fixes #474)

This commit is contained in:
Alexander Koblov 2025-03-24 23:56:25 +03:00
commit 5cedc12d24

View file

@ -125,7 +125,7 @@ type
FiEmblemOnline: PtrInt;
FiEmblemOffline: PtrInt;
FiShortcutIconID: PtrInt;
FOneDrivePath: String;
FOneDrivePath: TStringList;
{$ELSEIF DEFINED(DARWIN)}
FUseSystemTheme: Boolean;
{$ELSEIF DEFINED(UNIX) AND NOT DEFINED(HAIKU)}
@ -1656,6 +1656,9 @@ begin
end;
FSysImgList := SHGetSystemImageList(iIconSize);
FOneDrivePath := TStringList.Create;
FOneDrivePath.CaseSensitive := FileNameCaseSensitive;
{$ENDIF}
{$IF DEFINED(MSWINDOWS) and DEFINED(LCLQT5)}
@ -1702,6 +1705,7 @@ begin
end;
{$IF DEFINED(MSWINDOWS)}
FOneDrivePath.Free;
ImageList_Destroy(FSysImgList);
{$ELSEIF DEFINED(UNIX) AND NOT (DEFINED(DARWIN) OR DEFINED(HAIKU))}
for I := 0 to FExtToMimeIconName.HashTable.Count - 1 do
@ -1788,7 +1792,21 @@ begin
FiEmblemPinned:= CheckAddThemePixmap('emblem-cloud-pinned', I);
FiEmblemOnline:= CheckAddThemePixmap('emblem-cloud-online', I);
FiEmblemOffline:= CheckAddThemePixmap('emblem-cloud-offline', I);
GetKnownFolderPath(FOLDERID_SkyDrive, FOneDrivePath);
// Microsoft OneDrive folders
if GetKnownFolderPath(FOLDERID_SkyDrive, sPixMap) then
begin
if (Length(sPixMap) > 0) then FOneDrivePath.Add(sPixMap);
end;
sPixMap:= mbGetEnvironmentVariable('OneDriveConsumer');
if (Length(sPixMap) > 0) and (FOneDrivePath.IndexOf(sPixMap) < 0) then
begin
FOneDrivePath.Add(sPixMap);
end;
sPixMap:= mbGetEnvironmentVariable('OneDriveCommercial');
if (Length(sPixMap) > 0) and (FOneDrivePath.IndexOf(sPixMap) < 0) then
begin
FOneDrivePath.Add(sPixMap);
end;
end;
FiShortcutIconID := -1;
if gShowIcons > sim_standart then
@ -2446,6 +2464,8 @@ begin
end;
function TPixMapManager.GetIconOverlayByFile(AFile: TFile; DirectAccess: Boolean): PtrInt;
var
Index: Integer;
begin
if not DirectAccess then Exit(-1);
Result:= SHGetOverlayIconIndex(AFile.Path, AFile.Name);
@ -2453,25 +2473,33 @@ begin
Result += SystemIconIndexStart;
end
// Special case for OneDrive
else if (Win32MajorVersion >= 10) and IsInPath(FOneDrivePath, AFile.Path, True, True) then
else if (Win32MajorVersion >= 10) then
begin
if AFile.Attributes and FILE_ATTRIBUTE_PINNED <> 0 then
Result:= FiEmblemPinned
else if AFile.Attributes and FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS <> 0 then
Result:= FiEmblemOnline
else begin
Result:= SHGetStorePropertyValue(AFile.FullPath, PKEY_StorageProviderState);
case Result of
1:
Result:= FiEmblemOnline;
2:
Result:= FiEmblemOffline;
3:
Result:= FiEmblemPinned;
else
Result:= 0;
for Index:= 0 to FOneDrivePath.Count - 1 do
begin
if IsInPath(FOneDrivePath[Index], AFile.Path, True, True) then
begin
if AFile.Attributes and FILE_ATTRIBUTE_PINNED <> 0 then
Result:= FiEmblemPinned
else if AFile.Attributes and FILE_ATTRIBUTE_RECALL_ON_DATA_ACCESS <> 0 then
Result:= FiEmblemOnline
else begin
Result:= SHGetStorePropertyValue(AFile.FullPath, PKEY_StorageProviderState);
case Result of
1:
Result:= FiEmblemOnline;
2:
Result:= FiEmblemOffline;
3:
Result:= FiEmblemPinned;
else
Result:= 0;
end;
end;
Exit;
end;
end;
Result:= 0;
end
else
Result:= 0;