mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-28 10:02:14 +00:00
UPD: Change recycle parameter to cm_Delete to be of form "trashcan=".
This commit is contained in:
parent
7acff0c647
commit
ea6eb9c00d
6 changed files with 138 additions and 24 deletions
|
|
@ -854,7 +854,7 @@ end;
|
|||
procedure TfrmMain.btnF8Click(Sender: TObject);
|
||||
begin
|
||||
if GetKeyShiftStateEx * KeyModifiersShortcut = [ssShift] then
|
||||
Commands.cm_Delete(['recyclesettingrev'])
|
||||
Commands.cm_Delete(['trashcan=reversesetting'])
|
||||
else
|
||||
Commands.cm_Delete([]);
|
||||
end;
|
||||
|
|
@ -4778,4 +4778,4 @@ initialization
|
|||
TFormCommands.RegisterCommandsForm(TfrmMain, HotkeysCategory, @rsHotkeyCategoryMain);
|
||||
|
||||
end.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -767,13 +767,19 @@ procedure TfrmOptionsHotkeys.AddDeleteWithShiftHotkey;
|
|||
ShiftState: TShiftState;
|
||||
TextShortcut: String;
|
||||
NewParams: array of String;
|
||||
HasTrashCan: Boolean;
|
||||
TrashStr: String;
|
||||
TrashBool: Boolean;
|
||||
begin
|
||||
for i := 0 to Hotkeys.Count - 1 do
|
||||
begin
|
||||
if Hotkeys[i].Command = 'cm_Delete' then
|
||||
begin
|
||||
// Reverse trashcan parameter.
|
||||
NewParams := Copy(Hotkeys[i].Params);
|
||||
if ContainsOneOf(NewParams, ['recycle', 'norecycle']) then
|
||||
HasTrashCan := GetParamValue(NewParams, 'trashcan', TrashStr);
|
||||
if ContainsOneOf(NewParams, ['recycle', 'norecycle']) or
|
||||
(HasTrashCan and GetBoolValue(TrashStr, TrashBool)) then
|
||||
begin
|
||||
MessageDlg(rsOptHotkeysCannotAddShortcut,
|
||||
Format(rsOptHotkeysDeleteShortcutWrongParams, [Hotkeys[i].Shortcut]),
|
||||
|
|
@ -781,11 +787,20 @@ procedure TfrmOptionsHotkeys.AddDeleteWithShiftHotkey;
|
|||
Exit;
|
||||
end
|
||||
else if Contains(NewParams, 'recyclesettingrev') then
|
||||
ReplaceString(NewParams, 'recyclesettingrev', 'recyclesetting')
|
||||
begin
|
||||
DeleteString(NewParams, 'recyclesettingrev');
|
||||
TrashStr := 'setting';
|
||||
end
|
||||
else if Contains(NewParams, 'recyclesetting') then
|
||||
ReplaceString(NewParams, 'recyclesetting', 'recyclesettingrev')
|
||||
begin
|
||||
DeleteString(NewParams, 'recyclesetting');
|
||||
TrashStr := 'reversesetting';
|
||||
end
|
||||
else if HasTrashCan and (TrashStr = 'reversesetting') then
|
||||
TrashStr := 'setting'
|
||||
else
|
||||
AddString(NewParams, 'recyclesettingrev');
|
||||
TrashStr := 'reversesetting';
|
||||
SetValue(NewParams, 'trashcan', TrashStr);
|
||||
|
||||
Shortcut := TextToShortCutEx(Hotkeys[i].Shortcut);
|
||||
ShiftState := ShortcutToShiftEx(Shortcut);
|
||||
|
|
|
|||
|
|
@ -429,7 +429,8 @@ function Compare(const Array1, Array2: array of String): Boolean;
|
|||
function CopyArray(const anArray: array of String): TDynamicStringArray;
|
||||
function ContainsOneOf(const ArrayToSearch, StringsToSearch: array of String): Boolean;
|
||||
function Contains(const ArrayToSearch: array of String; const StringToSearch: String): Boolean;
|
||||
procedure ReplaceString(var anArray: array of String; const sToReplace: String; sReplaceWith: String);
|
||||
procedure DeleteString(var anArray: TDynamicStringArray; const Index: Integer);
|
||||
procedure DeleteString(var anArray: TDynamicStringArray; const sToDelete: String);
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -1825,13 +1826,27 @@ begin
|
|||
Result := False;
|
||||
end;
|
||||
|
||||
procedure ReplaceString(var anArray: array of String; const sToReplace: String; sReplaceWith: String);
|
||||
procedure DeleteString(var anArray: TDynamicStringArray; const Index: Integer);
|
||||
var
|
||||
Len: Integer;
|
||||
i: Integer;
|
||||
begin
|
||||
Len := Length(anArray);
|
||||
for i := Index + 1 to Len - 1 do
|
||||
anArray[i - 1] := anArray[i];
|
||||
SetLength(anArray, Len - 1);
|
||||
end;
|
||||
|
||||
procedure DeleteString(var anArray: TDynamicStringArray; const sToDelete: String);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
for i := Low(anArray) to High(anArray) do
|
||||
if anArray[i] = sToReplace then
|
||||
anArray[i] := sReplaceWith;
|
||||
if anArray[i] = sToDelete then
|
||||
begin
|
||||
DeleteString(anArray, i);
|
||||
Exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
-------------------------------------------------------------------------
|
||||
Implements custom commands for a component
|
||||
|
||||
Copyright (C) 2011 Przemyslaw Nagay (cobines@gmail.com)
|
||||
Copyright (C) 2011-2012 Przemyslaw Nagay (cobines@gmail.com)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -27,7 +27,7 @@ unit uFormCommands;
|
|||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, StringHashList, ActnList;
|
||||
Classes, SysUtils, StringHashList, ActnList, uTypes;
|
||||
|
||||
type
|
||||
TCommandFuncResult = (cfrSuccess, cfrDisabled, cfrNotFound);
|
||||
|
|
@ -142,6 +142,16 @@ type
|
|||
@returns(@true if the key was found, @false if it was not found)
|
||||
}
|
||||
function GetParamValue(const Params: array of String; Key: String; out Value: String): Boolean;
|
||||
function GetParamValue(const Param: String; Key: String; out Value: String): Boolean;
|
||||
{en
|
||||
If StrValue matches any value that can be translated into boolean then
|
||||
it returns @true and sets Value appropriately. Otherwise returns @false.
|
||||
}
|
||||
function GetBoolValue(StrValue: string; out BoolValue: Boolean): Boolean;
|
||||
{en
|
||||
Replaces old value of Key or adds a new Key=NewValue string to the array.
|
||||
}
|
||||
procedure SetValue(var anArray: TDynamicStringArray; Key, NewValue: String);
|
||||
|
||||
implementation
|
||||
|
||||
|
|
@ -374,5 +384,55 @@ begin
|
|||
Result := False;
|
||||
end;
|
||||
|
||||
function GetParamValue(const Param: String; Key: String; out Value: String): Boolean;
|
||||
begin
|
||||
Key := Key + '=';
|
||||
if StrBegins(Param, Key) then
|
||||
begin
|
||||
Value := Copy(Param, Length(Key) + 1, MaxInt);
|
||||
Exit(True);
|
||||
end;
|
||||
Value := '';
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
function GetBoolValue(StrValue: string; out BoolValue: Boolean): Boolean;
|
||||
begin
|
||||
StrValue := upcase(StrValue);
|
||||
if (StrValue = 'TRUE') or
|
||||
(StrValue = 'YES') or
|
||||
(StrValue = 'ON') or
|
||||
(StrValue = '1') then
|
||||
begin
|
||||
BoolValue := True;
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
if (StrValue = 'FALSE') or
|
||||
(StrValue = 'NO') or
|
||||
(StrValue = 'OFF') or
|
||||
(StrValue = '0') then
|
||||
begin
|
||||
BoolValue := False;
|
||||
Result := True;
|
||||
end
|
||||
else
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
procedure SetValue(var anArray: TDynamicStringArray; Key, NewValue: String);
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Key := Key + '=';
|
||||
for i := Low(anArray) to High(anArray) do
|
||||
if StrBegins(anArray[i], Key) then
|
||||
begin
|
||||
anArray[i] := Key + NewValue;
|
||||
Exit;
|
||||
end;
|
||||
AddString(anArray, Key + NewValue);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ begin
|
|||
AddIfNotExists('F6','cm_Rename',[]);
|
||||
AddIfNotExists('F7','cm_MakeDir',[]);
|
||||
AddIfNotExists(['F8','',
|
||||
'Shift+F8','recyclesettingrev',''], 'cm_Delete');
|
||||
'Shift+F8','trashcan=reversesetting',''], 'cm_Delete');
|
||||
AddIfNotExists('F9','cm_RunTerm',[]);
|
||||
AddIfNotExists('Ctrl+7','cm_ShowCmdLineHistory',[]);
|
||||
AddIfNotExists('Ctrl+D','cm_DirHotList',[]);
|
||||
|
|
@ -455,7 +455,7 @@ begin
|
|||
with HMControl.Hotkeys do
|
||||
begin
|
||||
AddIfNotExists(['Del','',
|
||||
'Shift+Del','recyclesettingrev',''], 'cm_Delete');
|
||||
'Shift+Del','trashcan=reversesetting',''], 'cm_Delete');
|
||||
AddIfNotExists('Ctrl+A','cm_MarkMarkAll',[]);
|
||||
AddIfNotExists('Ctrl+C','cm_CopyToClipboard',[]);
|
||||
AddIfNotExists('Ctrl+V','cm_PasteFromClipboard',[]);
|
||||
|
|
|
|||
|
|
@ -1340,19 +1340,26 @@ begin
|
|||
end;
|
||||
|
||||
// Parameters:
|
||||
// trashcan=
|
||||
// 1/true - delete to trash can
|
||||
// 0/false - delete directly
|
||||
// setting - if gUseTrash then delete to trash, otherwise delete directly
|
||||
// reversesetting - if gUseTrash then delete directly, otherwise delete to trash
|
||||
//
|
||||
// Deprecated:
|
||||
// "recycle" - delete to trash can
|
||||
// "norecycle" - delete directly
|
||||
// "recyclesetting" - if gUseTrash then delete to trash, otherwise delete directly
|
||||
// "recyclesettingrev" - if gUseTrash then delete directly, otherwise delete to trash
|
||||
// no parameter - depends on gUseTrash
|
||||
procedure TMainCommands.cm_Delete(const Params: array of string);
|
||||
var
|
||||
theFilesToDelete: TFiles;
|
||||
// 12.05.2009 - if delete to trash, then show another messages
|
||||
MsgDelSel, MsgDelFlDr : string;
|
||||
Operation: TFileSourceOperation;
|
||||
bRecycle: Boolean = False;
|
||||
Param: String;
|
||||
bRecycle: Boolean;
|
||||
Param, ParamTrashCan: String;
|
||||
BoolValue: Boolean;
|
||||
begin
|
||||
with frmMain.ActiveFrame do
|
||||
begin
|
||||
|
|
@ -1362,16 +1369,33 @@ begin
|
|||
Exit;
|
||||
end;
|
||||
|
||||
Param := GetDefaultParam(Params);
|
||||
if (((gUseTrash = True) and ((Param = '') or (Param = 'recyclesetting'))) or
|
||||
((gUseTrash = False) and (Param = 'recyclesettingrev')) or
|
||||
(Param = 'recycle')) and
|
||||
FileSource.IsClass(TFileSystemFileSource) and
|
||||
mbCheckTrash(CurrentPath) then
|
||||
bRecycle := gUseTrash;
|
||||
|
||||
for Param in Params do
|
||||
begin
|
||||
bRecycle := True;
|
||||
if Param = 'recycle' then
|
||||
bRecycle := True
|
||||
else if Param = 'norecycle' then
|
||||
bRecycle := False
|
||||
else if Param = 'recyclesetting' then
|
||||
bRecycle := gUseTrash
|
||||
else if Param = 'recyclesettingrev' then
|
||||
bRecycle := not gUseTrash
|
||||
else if GetParamValue(Param, 'trashcan', ParamTrashCan) then
|
||||
begin
|
||||
if ParamTrashCan = 'setting' then
|
||||
bRecycle := gUseTrash
|
||||
else if ParamTrashCan = 'reversesetting' then
|
||||
bRecycle := not gUseTrash
|
||||
else if GetBoolValue(ParamTrashCan, BoolValue) then
|
||||
bRecycle := BoolValue;
|
||||
end;
|
||||
end;
|
||||
|
||||
if bRecycle then
|
||||
bRecycle := FileSource.IsClass(TFileSystemFileSource) and
|
||||
mbCheckTrash(CurrentPath);
|
||||
|
||||
// 12.05.2009
|
||||
// Showing delete dialog: to trash or to /dev/null :)
|
||||
If bRecycle then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue