浏览代码

Bug fix: Confirmation of copy&paste transfers between panels was incorrectly controlled by drag&drop confirmation preference option

Source commit: fcf68007904647a6804928d52f1ec9fa8f4d6308
Martin Prikryl 7 年之前
父节点
当前提交
da0c1d456c

+ 6 - 5
source/components/UnixDirView.cpp

@@ -409,7 +409,7 @@ bool __fastcall TUnixDirView::PasteFromClipBoard(UnicodeString TargetPath)
       TargetPath = PathName;
     }
 
-    PerformItemDragDropOperation(NULL, DROPEFFECT_COPY);
+    PerformItemDragDropOperation(NULL, DROPEFFECT_COPY, true);
     if (OnDDExecuted != NULL)
     {
       OnDDExecuted(this, DROPEFFECT_COPY);
@@ -419,8 +419,8 @@ bool __fastcall TUnixDirView::PasteFromClipBoard(UnicodeString TargetPath)
   return Result;
 }
 //---------------------------------------------------------------------------
-void __fastcall TUnixDirView::PerformItemDragDropOperation(TListItem * Item,
-  int Effect)
+void __fastcall TUnixDirView::PerformItemDragDropOperation(
+  TListItem * Item, int Effect, bool Paste)
 {
 #ifndef DESIGN_ONLY
   if (OnDDFileOperation)
@@ -444,13 +444,14 @@ void __fastcall TUnixDirView::PerformItemDragDropOperation(TListItem * Item,
       }
 
       bool DoFileOperation = true;
-      OnDDFileOperation(this, Effect, SourceDirectory, TargetDirectory,
-        DoFileOperation);
+      OnDDFileOperation(
+        this, Effect, SourceDirectory, TargetDirectory, Paste, DoFileOperation);
     }
   }
 #else
   DebugUsedParam(Item);
   DebugUsedParam(Effect);
+  DebugUsedParam(Paste);
 #endif
 }
 //---------------------------------------------------------------------------

+ 1 - 1
source/components/UnixDirView.h

@@ -64,7 +64,7 @@ protected:
   virtual bool __fastcall ItemMatchesFilter(TListItem * Item, const TFileFilter &Filter);
   virtual Word __fastcall ItemOverlayIndexes(TListItem * Item);
   virtual void __fastcall LoadFiles();
-  virtual void __fastcall PerformItemDragDropOperation(TListItem * Item, int Effect);
+  virtual void __fastcall PerformItemDragDropOperation(TListItem * Item, int Effect, bool Paste);
   virtual void __fastcall SetAddParentDir(bool Value);
   virtual void __fastcall SetItemImageIndex(TListItem * Item, int Index);
   virtual void __fastcall SetPath(UnicodeString Value);

+ 2 - 2
source/components/UnixDriveView.cpp

@@ -555,8 +555,8 @@ void __fastcall TCustomUnixDriveView::PerformDragDropFileOperation(
       TargetDirectory = NodeData(Node)->Directory;
 
       bool DoFileOperation = true;
-      OnDDFileOperation(this, Effect, SourceDirectory, TargetDirectory,
-        DoFileOperation);
+      OnDDFileOperation(
+        this, Effect, SourceDirectory, TargetDirectory, false, DoFileOperation);
     }
   }
 }

+ 11 - 9
source/forms/CustomScpExplorer.cpp

@@ -7747,7 +7747,7 @@ bool __fastcall TCustomScpExplorerForm::DraggingAllFilesFromDirView(TOperationSi
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RemoteFileControlDragDropFileOperation(
-  TObject * Sender, int Effect, UnicodeString TargetPath, bool ForceQueue)
+  TObject * Sender, int Effect, UnicodeString TargetPath, bool ForceQueue, bool DragDrop)
 {
   TFileOperation Operation;
 
@@ -7781,15 +7781,15 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDragDropFileOperation(
       Param.TargetDirectory = TargetPath;
       // upload, no temp dirs
       Param.Temp = false;
-      Param.DragDrop = true;
+      Param.DragDrop = DragDrop;
       Param.Options =
         FLAGMASK(DraggingAllFilesFromDirView(osLocal, FileList), coAllFiles);
       if (ForceQueue)
       {
         Param.Queue = asOn;
       }
-      if (ExecuteFileOperation(Operation, osLocal, FileList,
-            (WinConfiguration->DDTransferConfirmation == asOff), &Param))
+      bool NoConfirmation = DragDrop ? (WinConfiguration->DDTransferConfirmation == asOff) : false;
+      if (ExecuteFileOperation(Operation, osLocal, FileList, NoConfirmation, &Param))
       {
         if (IsFileControl(DropSourceControl, osLocal))
         {
@@ -7811,9 +7811,9 @@ void __fastcall TCustomScpExplorerForm::RemoteFileControlDragDropFileOperation(
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RemoteFileControlDDFileOperation(
   TObject * Sender, int Effect, UnicodeString /*SourcePath*/,
-  UnicodeString TargetPath, bool & /*DoOperation*/)
+  UnicodeString TargetPath, bool Paste, bool & /*DoOperation*/)
 {
-  RemoteFileControlDragDropFileOperation(Sender, Effect, TargetPath, false);
+  RemoteFileControlDragDropFileOperation(Sender, Effect, TargetPath, false, !Paste);
 }
 //---------------------------------------------------------------------------
 void __fastcall TCustomScpExplorerForm::RemoteFileContolDDChooseEffect(
@@ -9462,7 +9462,9 @@ void __fastcall TCustomScpExplorerForm::SessionsDDProcessDropped(
       TTerminalManager::Instance()->ActiveTerminal = TargetTerminal;
       RemoteFileControlDragDropFileOperation(SessionsPageControl, Effect,
         // Why don't we use Terminal->CurrentDirectory directly?
-        TTerminalManager::Instance()->ActiveTerminal->CurrentDirectory, false);
+        TTerminalManager::Instance()->ActiveTerminal->CurrentDirectory,
+        // do not force queue, drag drop
+        false, true);
     }
   }
 }
@@ -9475,8 +9477,8 @@ void __fastcall TCustomScpExplorerForm::QueueDDProcessDropped(
   {
     RemoteFileControlDragDropFileOperation(QueueView3, Effect,
       Terminal->CurrentDirectory,
-      // force queue
-      true);
+      // force queue, drag drop
+      true, true);
   }
 }
 //---------------------------------------------------------------------------

+ 4 - 4
source/forms/CustomScpExplorer.h

@@ -135,9 +135,9 @@ __published:
   void __fastcall QueueView3Enter(TObject *Sender);
   void __fastcall QueueView3SelectItem(TObject *Sender, TListItem *Item,
     bool Selected);
-  void __fastcall RemoteFileControlDDFileOperation(TObject * Sender,
-    int Effect, UnicodeString SourcePath, UnicodeString TargetPath,
-    bool & DoOperation);
+  void __fastcall RemoteFileControlDDFileOperation(
+    TObject * Sender, int Effect, UnicodeString SourcePath, UnicodeString TargetPath,
+    bool Paste, bool & DoOperation);
   void __fastcall RemoteFileContolDDChooseEffect(TObject * Sender,
     int grfKeyState, int & dwEffect);
   void __fastcall RemoteFileControlDDDragFileName(TObject * Sender,
@@ -289,7 +289,7 @@ private:
   void __fastcall SessionsDDDragOver(int KeyState, const TPoint & Point, int & Effect);
   void __fastcall SessionsDDProcessDropped(TObject * Sender, int KeyState, const TPoint & Point, int Effect);
   void __fastcall RemoteFileControlDragDropFileOperation(
-    TObject * Sender, int Effect, UnicodeString TargetPath, bool ForceQueue);
+    TObject * Sender, int Effect, UnicodeString TargetPath, bool ForceQueue, bool Paste);
   void __fastcall SessionsDDDragEnter(_di_IDataObject DataObj, int KeyState,
     const TPoint & Point, int & Effect, bool & Accept);
   void __fastcall SessionsDDDragLeave();

+ 3 - 3
source/forms/ScpCommander.cpp

@@ -1465,7 +1465,7 @@ void __fastcall TScpCommanderForm::DDFakeFileInitDrag(TFileList * FileList,
 //---------------------------------------------------------------------------
 void __fastcall TScpCommanderForm::LocalFileControlDDFileOperation(
   TObject * /*Sender*/, int dwEffect, UnicodeString SourcePath,
-  UnicodeString TargetPath, bool & DoOperation)
+  UnicodeString TargetPath, bool Paste, bool & DoOperation)
 {
   if (IsFileControl(DropSourceControl, osRemote))
   {
@@ -1485,9 +1485,9 @@ void __fastcall TScpCommanderForm::LocalFileControlDDFileOperation(
         TTransferType TransferType = dwEffect == DROPEFFECT_Copy ? ttCopy : ttMove;
         int Options =
           FLAGMASK(DraggingAllFilesFromDirView(osRemote, FInternalDDDownloadList), coAllFiles);
+        bool NoConfirmation = Paste ? false : (WinConfiguration->DDTransferConfirmation == asOff);
         if (CopyParamDialog(tdToLocal, TransferType,
-              false, FInternalDDDownloadList, TargetDirectory, CopyParams,
-              (WinConfiguration->DDTransferConfirmation != asOff), true, Options))
+              false, FInternalDDDownloadList, TargetDirectory, CopyParams, NoConfirmation, true, Options))
         {
           int Params =
             (TransferType == ttMove ? cpDelete : 0);

+ 3 - 3
source/forms/ScpCommander.h

@@ -437,9 +437,9 @@ __published:
   void __fastcall LocalFileControlDDDragEnter(TObject *Sender,
     IDataObject *DataObj, int grfKeyState, TPoint &Point,
     int &dwEffect, bool &Accept);
-  void __fastcall LocalFileControlDDFileOperation(TObject *Sender,
-    int dwEffect, UnicodeString SourcePath, UnicodeString TargetPath,
-    bool &DoOperation);
+  void __fastcall LocalFileControlDDFileOperation(
+    TObject *Sender, int dwEffect, UnicodeString SourcePath, UnicodeString TargetPath,
+    bool Paste, bool &DoOperation);
   void __fastcall RemoteFileControlDDFileOperationExecuted(TObject *Sender,
     int dwEffect, UnicodeString SourcePath, UnicodeString TargetPath);
   void __fastcall LocalDirViewDDTargetHasDropHandler(TObject *Sender,

+ 4 - 3
source/packages/filemng/CustomDirView.pas

@@ -61,7 +61,8 @@ type
 
   TDDErrorEvent = procedure(Sender: TObject; ErrorNo: TDDError) of object;
   TDDExecutedEvent = procedure(Sender: TObject; dwEffect: Longint) of object;
-  TDDFileOperationEvent = procedure(Sender: TObject; dwEffect: LongInt; SourcePath, TargetPath: string;
+  TDDFileOperationEvent =
+    procedure(Sender: TObject; dwEffect: LongInt; SourcePath, TargetPath: string; Paste: Boolean;
     var DoOperation: Boolean) of object;
   TDDFileOperationExecutedEvent = procedure(Sender: TObject; dwEffect: LongInt; SourcePath, TargetPath: string) of object;
 
@@ -269,7 +270,7 @@ type
     procedure KeyPress(var Key: Char); override;
     procedure KeyUp(var Key: Word; Shift: TShiftState); override;
     procedure LoadFiles; virtual; abstract;
-    procedure PerformItemDragDropOperation(Item: TListItem; Effect: Integer); virtual; abstract;
+    procedure PerformItemDragDropOperation(Item: TListItem; Effect: Integer; Paste: Boolean); virtual; abstract;
     procedure ProcessChangedFiles(DirView: TCustomDirView;
       FileList: TStrings; FullPath: Boolean; ExistingOnly: Boolean;
       Criterias: TCompareCriterias);
@@ -2333,7 +2334,7 @@ begin
         FOnDDProcessDropped(Self, grfKeyState, Point, dwEffect);
       if dwEffect <> DropEffect_None then
       begin
-        PerformItemDragDropOperation(DropTarget, dwEffect);
+        PerformItemDragDropOperation(DropTarget, dwEffect, False);
         if Assigned(FOnDDExecuted) then
           FOnDDExecuted(Self, dwEffect);
       end;

+ 13 - 12
source/packages/filemng/DirView.pas

@@ -174,7 +174,7 @@ type
     {Drag&drop helper functions:}
     procedure SignalFileDelete(Sender: TObject; Files: TStringList);
     procedure PerformDragDropFileOperation(TargetPath: string; Effect: Integer;
-      RenameOnCollision: Boolean);
+      RenameOnCollision: Boolean; Paste: Boolean);
     procedure SetDirColProperties(Value: TDirViewColProperties);
 
   protected
@@ -230,7 +230,7 @@ type
     function FileMatches(FileName: string; const SearchRec: TSearchRec): Boolean;
     function ItemOverlayIndexes(Item: TListItem): Word; override;
     procedure LoadFiles; override;
-    procedure PerformItemDragDropOperation(Item: TListItem; Effect: Integer); override;
+    procedure PerformItemDragDropOperation(Item: TListItem; Effect: Integer; Paste: Boolean); override;
     procedure SortItems; override;
     procedure StartFileDeleteThread;
     procedure WMDestroy(var Msg: TWMDestroy); message WM_DESTROY;
@@ -397,7 +397,7 @@ function MatchesFileExt(Ext: string; const FileExtList: string): Boolean;
 function DropLink(Item: PFDDListItem; TargetPath: string): Boolean;
 function DropFiles(
   DragDropFilesEx: TCustomizableDragDropFilesEx; Effect: Integer; FileOperator: TFileOperator; TargetPath: string;
-  RenameOnCollision: Boolean; IsRecycleBin: Boolean; ConfirmDelete: Boolean; ConfirmOverwrite: Boolean;
+  RenameOnCollision: Boolean; IsRecycleBin: Boolean; ConfirmDelete: Boolean; ConfirmOverwrite: Boolean; Paste: Boolean;
   Sender: TObject; OnDDFileOperation: TDDFileOperationEvent;
   out SourcePath: string; out SourceIsDirectory: Boolean): Boolean;
 
@@ -504,7 +504,7 @@ end;
 
 function DropFiles(
   DragDropFilesEx: TCustomizableDragDropFilesEx; Effect: Integer; FileOperator: TFileOperator; TargetPath: string;
-  RenameOnCollision: Boolean; IsRecycleBin: Boolean; ConfirmDelete: Boolean; ConfirmOverwrite: Boolean;
+  RenameOnCollision: Boolean; IsRecycleBin: Boolean; ConfirmDelete: Boolean; ConfirmOverwrite: Boolean; Paste: Boolean;
   Sender: TObject; OnDDFileOperation: TDDFileOperationEvent;
   out SourcePath: string; out SourceIsDirectory: Boolean): Boolean;
 var
@@ -584,7 +584,7 @@ begin
   DoFileOperation := True;
   if Assigned(OnDDFileOperation) then
   begin
-    OnDDFileOperation(Sender, Effect, SourcePath, TargetPath, DoFileOperation);
+    OnDDFileOperation(Sender, Effect, SourcePath, TargetPath, False, DoFileOperation);
   end;
 
   Result := DoFileOperation and (FileOperator.OperandFrom.Count > 0);
@@ -1659,7 +1659,7 @@ begin
   end;
 end; {Reload2}
 
-procedure TDirView.PerformItemDragDropOperation(Item: TListItem; Effect: Integer);
+procedure TDirView.PerformItemDragDropOperation(Item: TListItem; Effect: Integer; Paste: Boolean);
 var
   TargetPath: string;
   RenameOnCollision: Boolean;
@@ -1684,7 +1684,7 @@ begin
   end;
 
   if TargetPath <> '' then
-    PerformDragDropFileOperation(TargetPath, Effect, RenameOnCollision);
+    PerformDragDropFileOperation(TargetPath, Effect, RenameOnCollision, Paste);
 end;
 
 procedure TDirView.ReLoad(CacheIcons: Boolean);
@@ -3135,7 +3135,7 @@ begin
 end;
 
 procedure TDirView.PerformDragDropFileOperation(TargetPath: string;
-  Effect: Integer; RenameOnCollision: Boolean);
+  Effect: Integer; RenameOnCollision: Boolean; Paste: Boolean);
 var
   Index: Integer;
   SourcePath: string;
@@ -3179,7 +3179,8 @@ begin
                 TDirView(DropSourceControl).StopWatchThread;
 
             if DropFiles(
-                 DragDropFilesEx, Effect, FFileOperator, TargetPath, RenameOnCollision, IsRecycleBin, ConfirmDelete, ConfirmOverwrite,
+                 DragDropFilesEx, Effect, FFileOperator, TargetPath, RenameOnCollision, IsRecycleBin,
+                 ConfirmDelete, ConfirmOverwrite, Paste,
                  Self, OnDDFileOperation, SourcePath, SourceIsDirectory) then
             begin
               ReLoad2;
@@ -3370,18 +3371,18 @@ begin
     case LastClipBoardOperation of
       cboNone:
         begin
-          PerformDragDropFileOperation(TargetPath, DropEffect_Copy, False);
+          PerformDragDropFileOperation(TargetPath, DropEffect_Copy, False, True);
           if Assigned(OnDDExecuted) then OnDDExecuted(Self, DropEffect_Copy);
         end;
       cboCopy:
         begin
           PerformDragDropFileOperation(TargetPath, DropEffect_Copy,
-            ExcludeTrailingPathDelimiter(ExtractFilePath(TFDDListItem(DragDropFilesEx.FileList[0]^).Name)) = Path);
+            ExcludeTrailingPathDelimiter(ExtractFilePath(TFDDListItem(DragDropFilesEx.FileList[0]^).Name)) = Path, True);
           if Assigned(OnDDExecuted) then OnDDExecuted(Self, DropEffect_Copy);
         end;
       cboCut:
         begin
-          PerformDragDropFileOperation(TargetPath, DropEffect_Move, False);
+          PerformDragDropFileOperation(TargetPath, DropEffect_Move, False, True);
           if Assigned(OnDDExecuted) then OnDDExecuted(Self, DropEffect_Move);
           EmptyClipBoard;
         end;

+ 1 - 1
source/packages/filemng/DriveView.pas

@@ -2552,7 +2552,7 @@ begin
       end;
 
       if DropFiles(
-           DragDropFilesEx, Effect, FFileOperator, TargetPath, false, IsRecycleBin, ConfirmDelete, ConfirmOverwrite,
+           DragDropFilesEx, Effect, FFileOperator, TargetPath, false, IsRecycleBin, ConfirmDelete, ConfirmOverwrite, False,
            Self, OnDDFileOperation, SourcePath, SourceIsDirectory) then
       begin
         if Assigned(FOnDDFileOperationExecuted) then