ADD: Show status overlay icons for OneDrive

This commit is contained in:
Alexander Koblov 2021-06-15 23:07:46 +03:00
commit 0e8e7d590a
17 changed files with 349 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 851 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 479 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 880 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 581 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 274 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
id="svg2"
height="24"
width="24"
version="1.2"
sodipodi:docname="process-completed.svg"
inkscape:export-filename="x:\onedrive\24x24\emblems\emblem-cloud-local.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview20"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="36.375"
inkscape:cx="11.051546"
inkscape:cy="12"
inkscape:window-width="2560"
inkscape:window-height="1361"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<defs
id="defs4">
<linearGradient
id="linearGradient4011">
<stop
offset="0"
style="stop-color:#ffffff;stop-opacity:1"
id="stop4013" />
<stop
offset="0.507761"
style="stop-color:#ffffff;stop-opacity:0.23529412"
id="stop4015-3" />
<stop
offset="0.83456558"
style="stop-color:#ffffff;stop-opacity:0.15686275"
id="stop4017-2" />
<stop
offset="1"
style="stop-color:#ffffff;stop-opacity:0.39215687"
id="stop4019" />
</linearGradient>
<linearGradient
id="linearGradient27416-1-5">
<stop
offset="0"
style="stop-color:#9bdb4d;stop-opacity:1"
id="stop27420-2-2" />
<stop
offset="1"
style="stop-color:#68b723;stop-opacity:1"
id="stop27422-3-2" />
</linearGradient>
<linearGradient
gradientTransform="matrix(0.5135135,0,0,0.5135135,-24.83614,-1.0212801)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient4011"
id="linearGradient12398-3"
y2="44.340794"
x2="71.204407"
y1="6.2375584"
x1="71.204407" />
<linearGradient
gradientTransform="matrix(0.8047894,0,0,0.60165743,-1628.8199,-1928.0804)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient27416-1-5"
id="linearGradient11527-6-5"
y2="3241.9966"
x2="2035.1652"
y1="3208.0737"
x1="2035.1652" />
</defs>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.98999999;fill:#d2d2d2;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999982;marker:none;enable-background:accumulate"
id="path2555-7-8-5-0-9"
d="M 12,1.4999999 C 6.2064599,1.4999999 1.4999999,6.2064599 1.4999999,12 1.4999999,17.79354 6.2064599,22.5 12,22.5 17.79354,22.5 22.50001,17.79354 22.5,12 22.5,6.2064599 17.79354,1.4999999 12,1.4999999 Z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:none;stroke:#206b00;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="path2555-7-8-5-1"
d="M 12,1.4999999 C 6.2064599,1.4999999 1.4999999,6.2064599 1.4999999,12 1.4999999,17.79354 6.2064599,22.5 12,22.5 17.79354,22.5 22.50001,17.79354 22.5,12 22.5,6.2064599 17.79354,1.4999999 12,1.4999999 Z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.84323651;marker:none;enable-background:accumulate"
id="path2922-6-6-0-9-7"
d="m 15.98656,7.6243199 2.01342,1.81209 -6.76511,8.9395901 -5.2348901,-4.51006 1.73154,-2.29531 3.0604001,2.65772 z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:none;stroke:url(#linearGradient12398-3);stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="path8655-6-0-9-5-0"
d="m 21.49999,11.99966 c 0,5.24688 -4.25361,9.50034 -9.49988,9.50034 -5.2467501,0 -9.5001101,-4.25351 -9.5001101,-9.50034 0,-5.2466301 4.25336,-9.4996601 9.5001101,-9.4996601 5.24627,0 9.49988,4.25303 9.49988,9.4996601 z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#206b00;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.84323651;marker:none;enable-background:accumulate"
id="path2922-6-6-0-9-4-2"
d="m 15.98656,6.6246799 2.01342,1.81209 -6.76511,8.9395901 -5.2348901,-4.51006 1.73154,-2.29531 3.0604001,2.65772 z" />
</svg>

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="479pt"
viewBox="0 -88 479.60456 479"
width="479pt"
version="1.1"
id="svg6"
sodipodi:docname="emblem-cloud-online.svg"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs10" />
<sodipodi:namedview
id="namedview8"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="pt"
showgrid="false"
inkscape:zoom="1.3669102"
inkscape:cx="318.96755"
inkscape:cy="319.33334"
inkscape:window-width="2560"
inkscape:window-height="1361"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg6" />
<path
d="m383.605469 120.3125c-5.851563.003906-11.6875.585938-17.425781 1.746094-4.324219-21.582032-18.304688-39.992188-37.929688-49.957032-19.628906-9.964843-42.742188-10.386718-62.71875-1.140624-18.078125-49.792969-73.101562-75.507813-122.898438-57.425782-49.796874 18.078125-75.507812 73.101563-57.429687 122.898438-43.621094 1.378906-78.078125 37.480468-77.421875 81.121094.652344 43.636718 36.179688 78.691406 79.824219 78.757812h296c48.601562 0 88-39.398438 88-88 0-48.597656-39.398438-88-88-88zm0 0"
fill="#000000"
id="path2"
style="fill:#d2d2d2;fill-opacity:1;stroke:#3cc1f4;stroke-opacity:1;stroke-width:20.02524195;stroke-miterlimit:4;stroke-dasharray:none" />
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
id="svg2"
height="24"
width="24"
version="1.2"
sodipodi:docname="process-completed2.svg"
inkscape:version="1.1 (c68e22c387, 2021-05-23)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<sodipodi:namedview
id="namedview20"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
showgrid="false"
inkscape:zoom="36.375"
inkscape:cx="11.986254"
inkscape:cy="12"
inkscape:window-width="2560"
inkscape:window-height="1361"
inkscape:window-x="-9"
inkscape:window-y="-9"
inkscape:window-maximized="1"
inkscape:current-layer="svg2" />
<defs
id="defs4">
<linearGradient
id="linearGradient4011">
<stop
offset="0"
style="stop-color:#ffffff;stop-opacity:1"
id="stop4013" />
<stop
offset="0.507761"
style="stop-color:#ffffff;stop-opacity:0.23529412"
id="stop4015-3" />
<stop
offset="0.83456558"
style="stop-color:#ffffff;stop-opacity:0.15686275"
id="stop4017-2" />
<stop
offset="1"
style="stop-color:#ffffff;stop-opacity:0.39215687"
id="stop4019" />
</linearGradient>
<linearGradient
id="linearGradient27416-1-5">
<stop
offset="0"
style="stop-color:#9bdb4d;stop-opacity:1"
id="stop27420-2-2" />
<stop
offset="1"
style="stop-color:#68b723;stop-opacity:1"
id="stop27422-3-2" />
</linearGradient>
<linearGradient
gradientTransform="matrix(0.5135135,0,0,0.5135135,-24.83614,-1.0212801)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient4011"
id="linearGradient12398-3"
y2="44.340794"
x2="71.204407"
y1="6.2375584"
x1="71.204407" />
<linearGradient
gradientTransform="matrix(0.8047894,0,0,0.60165743,-1628.8199,-1928.0804)"
gradientUnits="userSpaceOnUse"
xlink:href="#linearGradient27416-1-5"
id="linearGradient11527-6-5"
y2="3241.9966"
x2="2035.1652"
y1="3208.0737"
x1="2035.1652" />
</defs>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.98999999;fill:url(#linearGradient11527-6-5);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.99999982;marker:none;enable-background:accumulate"
id="path2555-7-8-5-0-9"
d="M 12,1.4999999 C 6.2064599,1.4999999 1.4999999,6.2064599 1.4999999,12 1.4999999,17.79354 6.2064599,22.5 12,22.5 17.79354,22.5 22.50001,17.79354 22.5,12 22.5,6.2064599 17.79354,1.4999999 12,1.4999999 Z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:none;stroke:#206b00;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="path2555-7-8-5-1"
d="M 12,1.4999999 C 6.2064599,1.4999999 1.4999999,6.2064599 1.4999999,12 1.4999999,17.79354 6.2064599,22.5 12,22.5 17.79354,22.5 22.50001,17.79354 22.5,12 22.5,6.2064599 17.79354,1.4999999 12,1.4999999 Z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.84323651;marker:none;enable-background:accumulate"
id="path2922-6-6-0-9-7"
d="m 15.98656,7.6243199 2.01342,1.81209 -6.76511,8.9395901 -5.2348901,-4.51006 1.73154,-2.29531 3.0604001,2.65772 z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:0.5;fill:none;stroke:url(#linearGradient12398-3);stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none;enable-background:accumulate"
id="path8655-6-0-9-5-0"
d="m 21.49999,11.99966 c 0,5.24688 -4.25361,9.50034 -9.49988,9.50034 -5.2467501,0 -9.5001101,-4.25351 -9.5001101,-9.50034 0,-5.2466301 4.25336,-9.4996601 9.5001101,-9.4996601 5.24627,0 9.49988,4.25303 9.49988,9.4996601 z" />
<path
style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.84323651;marker:none;enable-background:accumulate"
id="path2922-6-6-0-9-4-2"
d="m 15.98656,6.6246799 2.01342,1.81209 -6.76511,8.9395901 -5.2348901,-4.51006 1.73154,-2.29531 3.0604001,2.65772 z" />
</svg>

After

Width:  |  Height:  |  Size: 5.2 KiB

View file

@ -115,6 +115,10 @@ type
{$IF DEFINED(MSWINDOWS)}
FSysImgList : THandle;
FiSysDirIconID : PtrInt;
FiEmblemPinned: PtrInt;
FiEmblemOnline: PtrInt;
FiEmblemOffline: PtrInt;
FOneDrivePath: String;
{$ELSEIF DEFINED(DARWIN)}
FUseSystemTheme: Boolean;
{$ELSEIF DEFINED(UNIX)}
@ -346,7 +350,7 @@ uses
{$ENDIF}
{$IFDEF MSWINDOWS}
, CommCtrl, ShellAPI, Windows, DCFileAttributes, uBitmap, uGdiPlus,
IntfGraphics, uShlObjAdditional
IntfGraphics, uShlObjAdditional, uShellFolder
{$ELSE}
, StrUtils, Types, DCBasicTypes
{$ENDIF}
@ -1480,6 +1484,13 @@ begin
FiDefaultIconID:=CheckAddThemePixmap('unknown');
{$IF DEFINED(MSWINDOWS)}
FiSysDirIconID := GetSystemFolderIcon;
if (Win32MajorVersion >= 10) then
begin
FiEmblemPinned:= CheckAddThemePixmap('emblem-cloud-pinned', I);
FiEmblemOnline:= CheckAddThemePixmap('emblem-cloud-online', I);
FiEmblemOffline:= CheckAddThemePixmap('emblem-cloud-offline', I);
GetKnownFolderPath(FOLDERID_SkyDrive, FOneDrivePath);
end;
{$ENDIF}
{$IF DEFINED(MSWINDOWS) or DEFINED(DARWIN)}
FiDirIconID := -1;
@ -1787,13 +1798,20 @@ begin
end
{$IF DEFINED(MSWINDOWS) OR DEFINED(RabbitVCS)}
else
// Windows XP doesn't draw link overlay icon for soft links (don't know about Vista or 7).
if DirectAccess then
begin
if AFile.IconOverlayID >= SystemIconIndexStart then
Result:= DrawBitmap(AFile.IconOverlayID
{$IFDEF RabbitVCS} - SystemIconIndexStart {$ENDIF},
Canvas, X, Y);
Canvas, X, Y)
{$IF DEFINED(MSWINDOWS)}
// Special case for OneDrive
else if AFile.IconOverlayID > 0 then
begin
I:= gIconsSize div 2;
Result:= DrawBitmap(AFile.IconOverlayID, Canvas, X, Y + I, I, I);
end;
{$ENDIF}
end;
{$ENDIF}
;
@ -2064,10 +2082,33 @@ end;
{$IF DEFINED(MSWINDOWS)}
function TPixMapManager.GetIconOverlayByFile(AFile: TFile; DirectAccess: Boolean): PtrInt;
begin
if DirectAccess then
Result:= SHGetOverlayIconIndex(AFile.Path, AFile.Name) + SystemIconIndexStart
if not DirectAccess then Exit(-1);
Result:= SHGetOverlayIconIndex(AFile.Path, AFile.Name);
if Result >= 0 then begin
Result += SystemIconIndexStart;
end
// Special case for OneDrive
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 if IsInPath(FOneDrivePath, AFile.Path, True, True) then
begin
Result:= SHGetStorePropertyValue(AFile.FullPath, PKEY_StorageProviderState);
case Result of
1:
Result:= FiEmblemOnline;
2:
Result:= FiEmblemOffline;
else
Result:= 0;
end;
end;
end
else
Result:= -1;
Result:= 0;
end;
{$ELSEIF DEFINED(RabbitVCS)}
function TPixMapManager.GetIconOverlayByFile(AFile: TFile; DirectAccess: Boolean): PtrInt;

View file

@ -72,6 +72,8 @@ const
SIID_DRIVENET = 9;
SIID_ZIPFILE = 105;
PKEY_StorageProviderState: PROPERTYKEY = (fmtid: '{E77E90DF-6271-4F5B-834F-2DD1F245DDA4}'; pid: 3);
type
TSHStockIconInfo = record
cbSize: DWORD;
@ -84,6 +86,7 @@ type
function SHGetSystemImageList(iImageList: Integer): HIMAGELIST;
function SHGetStockIconInfo(siid: Int32; uFlags: UINT; out psii: TSHStockIconInfo): Boolean;
function SHChangeIconDialog(hOwner: HWND; var FileName: String; var IconIndex: Integer): Boolean;
function SHGetStorePropertyValue(const FileName: String; const Key: PROPERTYKEY): Integer;
function SHGetOverlayIconIndex(const sFilePath, sFileName: String): Integer;
function SHGetInfoTip(const sFilePath, sFileName: String): String;
function SHFileIsLinkToFolder(const FileName: String; out LinkTarget: String): Boolean;
@ -106,6 +109,11 @@ implementation
uses
SysUtils, JwaShlGuid, ComObj, LazUTF8, DCOSUtils;
var
SHGetPropertyStoreFromParsingName: function(pszPath: PCWSTR; const pbc: IBindCtx;
flags: GETPROPERTYSTOREFLAGS;
const riid: TIID; out ppv): HRESULT; stdcall;
function SHGetImageListFallback(iImageList: Integer; const riid: TGUID; var ImageList: HIMAGELIST): HRESULT; stdcall;
var
FileInfo: TSHFileInfoW;
@ -183,6 +191,19 @@ begin
end;
end;
function SHGetStorePropertyValue(const FileName: String; const Key: PROPERTYKEY): Integer;
var
AValue: Variant;
AStorage: IPropertyStore;
begin
if Succeeded(SHGetPropertyStoreFromParsingName(PWideChar(UTF8Decode(FileName)), nil, GPS_DEFAULT, IPropertyStore, AStorage)) then
begin
if Succeeded(AStorage.GetValue(@Key, TPROPVARIANT(AValue))) then
Exit(AValue);
end;
Result:= -1;
end;
function SHGetOverlayIconIndex(const sFilePath, sFileName: String): Integer;
var
Folder,
@ -310,4 +331,8 @@ begin
if not Succeeded(Result) then OleErrorUTF8(Result);
end;
initialization
SHGetPropertyStoreFromParsingName:= GetProcAddress(GetModuleHandle('shell32.dll'),
'SHGetPropertyStoreFromParsingName');
end. { ShlObjAdditional }