mirror of
https://github.com/doublecmd/doublecmd.git
synced 2026-06-21 09:58:13 +00:00
ADD: Parameter "confirmation" to cm_Copy, cm_Rename, cm_Delete to enable/disable confirmation dialog.
This commit is contained in:
parent
f602180571
commit
3ad27e2e4e
3 changed files with 127 additions and 27 deletions
|
|
@ -63,7 +63,30 @@
|
|||
<tr>
|
||||
<td><tt><div align="left"><a name="cm_Copy">cm_Copy</a></div>
|
||||
<div align="right">F5</div></tt></td>
|
||||
<td>Copy items from source to target</td>
|
||||
<td>Copy items from source to target<br>
|
||||
<br>
|
||||
<table width=100% cellpadding=5>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
<th>Value</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign=top>
|
||||
<tr>
|
||||
<td><tt>confirmation</tt></td>
|
||||
<td><tt>1/true/on/yes</tt></td>
|
||||
<td>shows confirmation dialog (default)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><tt>0/false/off/no</tt></td>
|
||||
<td>does not show a confirmation dialog</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt><div align="left"><a name="cm_CopyFullNamesToClip">cm_CopyFullNamesToClip</a></div>
|
||||
|
|
@ -107,6 +130,16 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody valign=top>
|
||||
<tr>
|
||||
<td><tt>confirmation</tt></td>
|
||||
<td><tt>1/true/on/yes</tt></td>
|
||||
<td>shows confirmation dialog (default)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><tt>0/false/off/no</tt></td>
|
||||
<td>does not show a confirmation dialog (be careful!)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt>trashcan</tt></td>
|
||||
<td><tt>1/true/on/yes</tt></td>
|
||||
|
|
@ -431,7 +464,30 @@
|
|||
<tr>
|
||||
<td><tt><div align="left"><a name="cm_Rename">cm_Rename</a></div>
|
||||
<div align="right">F6</div></tt></td>
|
||||
<td>Rename or move items</td>
|
||||
<td>Rename or move items<br>
|
||||
<br>
|
||||
<table width=100% cellpadding=5>
|
||||
<thead align=left>
|
||||
<tr>
|
||||
<th>Parameter</th>
|
||||
<th>Value</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody valign=top>
|
||||
<tr>
|
||||
<td><tt>confirmation</tt></td>
|
||||
<td><tt>1/true/on/yes</tt></td>
|
||||
<td>shows confirmation dialog (default)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><tt>0/false/off/no</tt></td>
|
||||
<td>does not show a confirmation dialog</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><tt><div align="left"><a name="cm_RenameOnly">cm_RenameOnly</a></div>
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ type
|
|||
}
|
||||
function GetParamValue(const Params: array of String; Key: String; out Value: String): Boolean;
|
||||
function GetParamValue(const Param: String; Key: String; out Value: String): Boolean;
|
||||
function GetParamBoolValue(const Param: String; Key: String; out BoolValue: Boolean): Boolean;
|
||||
{en
|
||||
If StrValue matches any value that can be translated into boolean then
|
||||
it returns @true and sets Value appropriately. Otherwise returns @false.
|
||||
|
|
@ -392,6 +393,14 @@ begin
|
|||
Result := False;
|
||||
end;
|
||||
|
||||
function GetParamBoolValue(const Param: String; Key: String; out BoolValue: Boolean): Boolean;
|
||||
var
|
||||
sValue: String;
|
||||
begin
|
||||
Result := GetParamValue(Param, Key, sValue) and
|
||||
GetBoolValue(sValue, BoolValue);
|
||||
end;
|
||||
|
||||
function GetBoolValue(StrValue: string; out BoolValue: Boolean): Boolean;
|
||||
begin
|
||||
StrValue := upcase(StrValue);
|
||||
|
|
|
|||
|
|
@ -1273,9 +1273,23 @@ begin
|
|||
frmMain.ActiveFrame.ExecuteCommand('cm_EditPath', Params);
|
||||
end;
|
||||
|
||||
// Parameters:
|
||||
// confirmation=
|
||||
// 1/true - show confirmation
|
||||
// 0/false - don't show confirmation
|
||||
procedure TMainCommands.cm_Copy(const Params: array of string);
|
||||
var
|
||||
Param: String;
|
||||
bConfirmation, BoolValue: Boolean;
|
||||
begin
|
||||
if frmMain.CopyFiles(frmMain.NotActiveFrame.CurrentPath, True) then
|
||||
bConfirmation := True;
|
||||
for Param in Params do
|
||||
begin
|
||||
if GetParamBoolValue(Param, 'confirmation', BoolValue) then
|
||||
bConfirmation := BoolValue;
|
||||
end;
|
||||
|
||||
if frmMain.CopyFiles(frmMain.NotActiveFrame.CurrentPath, bConfirmation) then
|
||||
frmMain.ActiveFrame.UnselectAllFiles;
|
||||
end;
|
||||
|
||||
|
|
@ -1285,9 +1299,23 @@ begin
|
|||
frmMain.ActiveFrame.UnselectAllFiles;
|
||||
end;
|
||||
|
||||
// Parameters:
|
||||
// confirmation=
|
||||
// 1/true - show confirmation
|
||||
// 0/false - don't show confirmation
|
||||
procedure TMainCommands.cm_Rename(const Params: array of string);
|
||||
var
|
||||
Param: String;
|
||||
bConfirmation, BoolValue: Boolean;
|
||||
begin
|
||||
if frmMain.MoveFiles(frmMain.NotActiveFrame.CurrentPath, True) then
|
||||
bConfirmation := True;
|
||||
for Param in Params do
|
||||
begin
|
||||
if GetParamBoolValue(Param, 'confirmation', BoolValue) then
|
||||
bConfirmation := BoolValue;
|
||||
end;
|
||||
|
||||
if frmMain.MoveFiles(frmMain.NotActiveFrame.CurrentPath, bConfirmation) then
|
||||
frmMain.ActiveFrame.UnselectAllFiles;
|
||||
end;
|
||||
|
||||
|
|
@ -1345,6 +1373,9 @@ end;
|
|||
// 0/false - delete directly
|
||||
// setting - if gUseTrash then delete to trash, otherwise delete directly
|
||||
// reversesetting - if gUseTrash then delete directly, otherwise delete to trash
|
||||
// confirmation=
|
||||
// 1/true - show confirmation
|
||||
// 0/false - don't show confirmation
|
||||
//
|
||||
// Deprecated:
|
||||
// "recycle" - delete to trash can
|
||||
|
|
@ -1358,6 +1389,7 @@ var
|
|||
MsgDelSel, MsgDelFlDr : string;
|
||||
Operation: TFileSourceOperation;
|
||||
bRecycle: Boolean;
|
||||
bConfirmation: Boolean;
|
||||
Param, ParamTrashCan: String;
|
||||
BoolValue: Boolean;
|
||||
begin
|
||||
|
|
@ -1370,6 +1402,7 @@ begin
|
|||
end;
|
||||
|
||||
bRecycle := gUseTrash;
|
||||
bConfirmation := True;
|
||||
|
||||
for Param in Params do
|
||||
begin
|
||||
|
|
@ -1389,7 +1422,9 @@ begin
|
|||
bRecycle := not gUseTrash
|
||||
else if GetBoolValue(ParamTrashCan, BoolValue) then
|
||||
bRecycle := BoolValue;
|
||||
end;
|
||||
end
|
||||
else if GetParamBoolValue(Param, 'confirmation', BoolValue) then
|
||||
bConfirmation := BoolValue;
|
||||
end;
|
||||
|
||||
if bRecycle then
|
||||
|
|
@ -1415,30 +1450,30 @@ begin
|
|||
|
||||
if Assigned(theFilesToDelete) then
|
||||
try
|
||||
if theFilesToDelete.Count = 0 then
|
||||
Exit;
|
||||
|
||||
if QuestionDlg('', frmMain.GetFileDlgStr(MsgDelSel,MsgDelFlDr,theFilesToDelete),
|
||||
mtConfirmation, [mrYes, mrNo], 0) <> mrYes then Exit;
|
||||
|
||||
Operation := FileSource.CreateDeleteOperation(theFilesToDelete);
|
||||
|
||||
if Assigned(Operation) then
|
||||
if (theFilesToDelete.Count > 0) and
|
||||
((not bConfirmation) or
|
||||
(QuestionDlg('', frmMain.GetFileDlgStr(MsgDelSel,MsgDelFlDr,theFilesToDelete),
|
||||
mtConfirmation, [mrYes, mrNo], 0) = mrYes)) then
|
||||
begin
|
||||
// Special case for filesystem - 'recycle' parameter.
|
||||
if Operation is TFileSystemDeleteOperation then
|
||||
with Operation as TFileSystemDeleteOperation do
|
||||
begin
|
||||
// 30.04.2009 - передаем параметр корзины в поток.
|
||||
Recycle := bRecycle;
|
||||
end;
|
||||
Operation := FileSource.CreateDeleteOperation(theFilesToDelete);
|
||||
|
||||
// Start operation.
|
||||
OperationsManager.AddOperation(Operation);
|
||||
end
|
||||
else
|
||||
begin
|
||||
msgWarning(rsMsgNotImplemented);
|
||||
if Assigned(Operation) then
|
||||
begin
|
||||
// Special case for filesystem - 'recycle' parameter.
|
||||
if Operation is TFileSystemDeleteOperation then
|
||||
with Operation as TFileSystemDeleteOperation do
|
||||
begin
|
||||
// 30.04.2009 - передаем параметр корзины в поток.
|
||||
Recycle := bRecycle;
|
||||
end;
|
||||
|
||||
// Start operation.
|
||||
OperationsManager.AddOperation(Operation);
|
||||
end
|
||||
else
|
||||
begin
|
||||
msgWarning(rsMsgNotImplemented);
|
||||
end;
|
||||
end;
|
||||
|
||||
finally
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue