ADD/StashFS: step-25: add cm_RemoveFromStash/cm_EmptyStash

This commit is contained in:
rich2014 2026-06-08 19:42:44 +08:00
commit f08d3af019
5 changed files with 62 additions and 23 deletions

View file

@ -39,8 +39,6 @@ type
procedure onFileSystemEvent(var params: TFileSourceEventParams);
procedure onStashChanged(Sender: TObject);
procedure reload; overload;
procedure removeAction(Sender: TObject);
procedure clearAction(Sender: TObject);
public
constructor Create; override; overload;
destructor Destroy; override;
@ -79,6 +77,11 @@ type
procedure AddSearchPath( const startPath: String; paths: TStringList); override;
end;
var
stashActionAddToStash: TBasicAction;
stashActionRemoveFromStash: TBasicAction;
stashActionEmptyStash: TBasicAction;
implementation
uses
@ -201,20 +204,6 @@ begin
self.Reload( self.GetRootDir );
end;
procedure TStashFileSource.removeAction(Sender: TObject);
var
item: TMenuItem absolute Sender;
files: TFiles;
begin
files:= TFiles( item.Tag );
stashFilesBackend.removePaths( files );
end;
procedure TStashFileSource.clearAction(Sender: TObject);
begin
stashFilesBackend.clear;
end;
constructor TStashFileSource.Create;
begin
Inherited Create;
@ -450,9 +439,7 @@ var
item: TMenuItem;
begin
item:= TMenuItem.Create( AMenu );
item.Caption:= 'Remove Stash Items';
item.OnClick:= @self.removeAction;
item.Tag:= PtrInt( AFiles );
item.Action:= stashActionRemoveFromStash;
AMenu.Items.Insert(index, item);
inc( index );
end;
@ -462,8 +449,7 @@ var
item: TMenuItem;
begin
item:= TMenuItem.Create( AMenu );
item.Caption:= 'Empty Stash';
item.OnClick:= @self.clearAction;
item.Action:= stashActionEmptyStash;
AMenu.Items.Insert(index, item);
inc( index );
end;

View file

@ -2893,6 +2893,18 @@ object frmMain: TfrmMain
Caption = 'Open Stash'
OnExecute = actExecute
end
object actRemoveFromStash: TAction
Tag = 4
Category = 'File Operations'
Caption = 'Remove Stash Items'
OnExecute = actExecute
end
object actEmptyStash: TAction
Tag = 4
Category = 'File Operations'
Caption = 'Empty Stash'
OnExecute = actExecute
end
end
object pmHotList: TPopupMenu
Images = imgLstDirectoryHotlist

View file

@ -267,6 +267,8 @@
{"hash":10715029,"name":"tfrmmain.actsetsortmode.caption","sourcebytes":[83,101,116,32,83,111,114,116,32,77,111,100,101],"value":"Set Sort Mode"},
{"hash":86036264,"name":"tfrmmain.actaddtostash.caption","sourcebytes":[65,100,100,32,116,111,32,83,116,97,115,104],"value":"Add to Stash"},
{"hash":6278744,"name":"tfrmmain.actopenstash.caption","sourcebytes":[79,112,101,110,32,83,116,97,115,104],"value":"Open Stash"},
{"hash":145114643,"name":"tfrmmain.actremovefromstash.caption","sourcebytes":[82,101,109,111,118,101,32,83,116,97,115,104,32,73,116,101,109,115],"value":"Remove Stash Items"},
{"hash":186052392,"name":"tfrmmain.actemptystash.caption","sourcebytes":[69,109,112,116,121,32,83,116,97,115,104],"value":"Empty Stash"},
{"hash":310020,"name":"tfrmmain.tbedit.caption","sourcebytes":[69,100,105,116],"value":"Edit"},
{"hash":78392485,"name":"tfrmmain.tbdelete.caption","sourcebytes":[68,101,108,101,116,101],"value":"Delete"},
{"hash":1140,"name":"tfrmmain.tbchangedir.caption","sourcebytes":[67,68],"value":"CD"},

View file

@ -75,6 +75,8 @@ type
TfrmMain = class(TAloneForm, IFormCommands)
actAddPlugin: TAction;
actAddToStash: TAction;
actEmptyStash: TAction;
actRemoveFromStash: TAction;
actOpenStash: TAction;
actMainFontZoomOut: TAction;
actMainFontZoomIn: TAction;
@ -961,10 +963,12 @@ implementation
{$R *.lfm}
uses
Themes, uFileProcs, uShellContextMenu, fTreeViewMenu, uSearchResultFileSource,
Themes, uFileProcs, uShellContextMenu, fTreeViewMenu,
Math, LCLIntf, Dialogs, uGlobs, uLng, uMasks, fCopyMoveDlg, uQuickViewPanel,
uShowMsg, uDCUtils, uLog, uGlobsPaths, LCLProc, uOSUtils, uPixMapManager, LazUTF8,
uDragDropEx, uKeyboard, uLocalFileSource, uFileSystemFileSource, fViewOperations, uMultiListFileSource,
uDragDropEx, uKeyboard,
uLocalFileSource, uFileSystemFileSource, uSearchResultFileSource, uStashFileSource,
fViewOperations, uMultiListFileSource,
uFileSourceOperationTypes, uFileSourceCopyOperation, uFileSourceMoveOperation,
uFileSourceProperty, uFileSourceExecuteOperation, uArchiveFileSource, uThumbFileView,
uShellExecute, fSymLink, fHardLink, uExceptions, uUniqueInstance, Clipbrd, ShellCtrls,
@ -1113,6 +1117,13 @@ procedure TfrmMain.FormCreate(Sender: TObject);
);
end;
procedure setStashAction;
begin
stashActionAddToStash:= actAddToStash;
stashActionRemoveFromStash:= actRemoveFromStash;
stashActionEmptyStash:= actEmptyStash;
end;
var
HMMainForm: THMForm;
I: Integer;
@ -1124,6 +1135,8 @@ begin
Application.OnEndSession := @AppEndSession;
Application.OnQueryEndSession := @AppQueryEndSession;
setStashAction;
{$IF DEFINED(DARWIN)}
// in LCL's DARWIN implements, there is no way but to Use LCL's method of dropping files
// from external applications

View file

@ -385,6 +385,8 @@ type
procedure cm_LoadList(const Params: array of string);
procedure cm_SetSortMode(const Params: array of string);
procedure cm_AddToStash(const {%H-}Params: array of string);
procedure cm_RemoveFromStash(const {%H-}Params: array of string);
procedure cm_EmptyStash(const {%H-}Params: array of string);
// Internal commands
procedure cm_ExecuteToolbarItem(const Params: array of string);
@ -5732,12 +5734,36 @@ end;
procedure TMainCommands.cm_AddToStash(const Params: array of string);
var
fs: IFileSource;
files: TFiles;
begin
fs:= frmMain.ActiveFrame.FileSource;
if fs.IsClass(TStashFileSource) then
Exit;
if NOT (fspDirectAccess in fs.Properties) then
Exit;
files:= frmMain.ActiveFrame.CloneSelectedOrActiveFiles;
stashFilesBackend.addPaths( files );
files.Free;
end;
procedure TMainCommands.cm_RemoveFromStash(const Params: array of string);
var
fs: IFileSource;
files: TFiles;
begin
fs:= frmMain.ActiveFrame.FileSource;
if NOT fs.IsClass(TStashFileSource) then
Exit;
files:= frmMain.ActiveFrame.CloneSelectedOrActiveFiles;
stashFilesBackend.removePaths( files );
files.Free;
end;
procedure TMainCommands.cm_EmptyStash(const Params: array of string);
begin
stashFilesBackend.clear;
end;
end.