ADD/StashFS: step-13: remove "Add to Stash" in ContextMenu in StashFileSource

This commit is contained in:
rich2014 2026-06-05 12:06:28 +08:00
commit edccfff2c2
2 changed files with 73 additions and 28 deletions

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="12"/>
<Version Value="13"/>
<PathDelim Value="\"/>
<General>
<Flags>
@ -50,7 +50,7 @@
</Target>
<SearchPaths>
<IncludeFiles Value="$(LazarusDir)\ide;$(ProjOutDir);..\sdk;..\units"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google;filesources\stash"/>
<UnitOutputDirectory Value="..\units\$(TargetCPU)-$(TargetOS)-$(LCLWidgetType)"/>
<SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType);$(fpcsrcdir)\packages\fcl-base\src"/>
</SearchPaths>
@ -97,7 +97,7 @@ end;"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(LazarusDir)\ide;$(ProjOutDir);..\sdk;..\units"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google;filesources\stash"/>
<UnitOutputDirectory Value="..\units\$(TargetCPU)-$(TargetOS)-$(LCLWidgetType)"/>
<SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType);$(fpcsrcdir)\packages\fcl-base\src"/>
</SearchPaths>
@ -140,7 +140,7 @@ end;"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(LazarusDir)\ide;$(ProjOutDir);..\sdk;..\units"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google;filesources\stash"/>
<UnitOutputDirectory Value="..\units\$(TargetCPU)-$(TargetOS)-$(LCLWidgetType)"/>
<SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType);$(fpcsrcdir)\packages\fcl-base\src"/>
</SearchPaths>
@ -229,7 +229,7 @@ end;"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(LazarusDir)\ide;$(ProjOutDir);..\sdk;..\units"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;..\components\DDetours\Source;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;..\components\DDetours\Source;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google;filesources\stash"/>
<UnitOutputDirectory Value="..\units\$(TargetCPU)-$(TargetOS)-$(LCLWidgetType)"/>
<SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType);$(fpcsrcdir)\packages\fcl-base\src"/>
</SearchPaths>
@ -326,7 +326,7 @@ end;"/>
</Item8>
<Item9>
<PackageName Value="LCL"/>
<MinVersion Major="4" Minor="0" Valid="True"/>
<MinVersion Major="4" Valid="True"/>
</Item9>
<Item10>
<PackageName Value="SynEdit"/>
@ -343,7 +343,7 @@ end;"/>
<PackageName Value="Image32"/>
</Item13>
</RequiredPackages>
<Units Count="303">
<Units Count="306">
<Unit0>
<Filename Value="doublecmd.lpr"/>
<IsPartOfProject Value="True"/>
@ -2190,6 +2190,22 @@ end;"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uDarwinFNKey"/>
</Unit302>
<Unit303>
<Filename Value="filesources\stash\ustashfilesource.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uStashFileSource"/>
</Unit303>
<Unit304>
<Filename Value="filesources\stash\ustashfilesourceoperation.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="uStashFileSourceOperation"/>
</Unit304>
<Unit305>
<Filename Value="filesources\stash\ustashfilesbackend.pas"/>
<IsPartOfProject Value="True"/>
<HasResources Value="True"/>
<UnitName Value="uStashFilesBackend"/>
</Unit305>
</Units>
</ProjectOptions>
<CompilerOptions>
@ -2200,7 +2216,7 @@ end;"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(LazarusDir)\ide;$(ProjOutDir);..\sdk;..\units"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google"/>
<OtherUnitFiles Value="platform;platform\$(SrcOS);platform\$(SrcOS)\$(TargetOS);..\sdk;frames;fileviews;filesources;filesources\filesystem;filesources\multiarchive;filesources\multilist;filesources\searchresult;filesources\tempfilesystem;filesources\vfs;filesources\wcxarchive;filesources\wfxplugin;filesources\winnet;platform\unix\glib;platform\unix\mime;filesources\gio;rpc;rpc\sys\$(SrcOS);rpc\sys;filesources\recyclebin;filesources\gio\trash;filesources\winnet\wsl;filesources\shellfolder;platform\win\winrt;filesources\gio\network;filesources\mounted;filesources\gio\google;filesources\stash"/>
<UnitOutputDirectory Value="..\units\$(TargetCPU)-$(TargetOS)-$(LCLWidgetType)"/>
<SrcPath Value="$(LazarusDir)\lcl;$(LazarusDir)\lcl\interfaces\$(LCLWidgetType);$(fpcsrcdir)\packages\fcl-base\src"/>
</SearchPaths>

View file

@ -285,6 +285,8 @@ begin
end;
function TStashFileSource.QueryContextMenu(AFiles: TFiles; var AMenu: TPopupMenu): Boolean;
var
index: Integer;
function hasValidPath: Boolean;
var
@ -301,34 +303,61 @@ function TStashFileSource.QueryContextMenu(AFiles: TFiles; var AMenu: TPopupMenu
end;
end;
var
menuItem: TMenuItem;
index: Integer;
procedure removeAddToStash;
var
item: TMenuItem;
begin
item:= AMenu.Items.Find( 'Add to Stash' );
if Assigned(item) then
AMenu.Items.Remove( item );
end;
procedure addRemoveStashItems;
var
item: TMenuItem;
begin
item:= TMenuItem.Create( AMenu );
item.Caption:= 'Remove Stash Items';
item.OnClick:= @self.removeAction;
item.Tag:= PtrInt( AFiles );
AMenu.Items.Insert(index, item);
inc( index );
end;
procedure addEmptyStash;
var
item: TMenuItem;
begin
item:= TMenuItem.Create( AMenu );
item.Caption:= 'Empty Stash';
item.OnClick:= @self.clearAction;
AMenu.Items.Insert(index, item);
inc( index );
end;
procedure addSeperator;
var
item: TMenuItem;
begin
item:= TMenuItem.Create( AMenu );
item.Caption:= '-';
AMenu.Items.Insert(index, item);
end;
begin
Result:= False;
index:= 0;
if hasValidPath then begin
menuItem:= TMenuItem.Create( AMenu );
menuItem.Caption:= 'Remove Shash Items';
menuItem.OnClick:= @self.removeAction;
menuItem.Tag:= PtrInt( AFiles );
AMenu.Items.Insert(index, menuItem);
inc( index );
end;
removeAddToStash;
if stashFilesBackend.count > 0 then begin
menuItem:= TMenuItem.Create( AMenu );
menuItem.Caption:= 'Empty Stash';
menuItem.OnClick:= @self.clearAction;
AMenu.Items.Insert(index, menuItem);
inc( index );
end;
if hasValidPath then
addRemoveStashItems;
if stashFilesBackend.count > 0 then
addEmptyStash;
if index > 0 then begin
menuItem:= TMenuItem.Create( AMenu );
menuItem.Caption:= '-';
AMenu.Items.Insert(index, menuItem);
addSeperator;
Result:= True;
end;
end;