Browse Source

Bug 2189: Command to open the same folder as in the other panel in local file manager mode

https://winscp.net/tracker/2189

Source commit: 57de695eeab38a77742ee469c2e5e10b44d28daa
Martin Prikryl 2 years ago
parent
commit
cf79a50ffb

+ 18 - 0
source/forms/CustomScpExplorer.cpp

@@ -3063,6 +3063,24 @@ TOperationSide __fastcall TCustomScpExplorerForm::GetSide(TOperationSide Side)
   return Side;
 }
 //---------------------------------------------------------------------------
+TOperationSide TCustomScpExplorerForm::GetOtherSide(TOperationSide Side)
+{
+  TOperationSide Result;
+  switch (GetSide(Side))
+  {
+    case osLocal:
+      Result = osOther;
+      break;
+    case osOther:
+      Result = osLocal;
+      break;
+    default:
+      DebugFail();
+      Abort();
+  }
+  return Result;
+}
+//---------------------------------------------------------------------------
 bool __fastcall TCustomScpExplorerForm::ExecuteFileOperation(TFileOperation Operation,
   TOperationSide Side, bool OnFocused, bool NoConfirmation, void * Param)
 {

+ 1 - 0
source/forms/CustomScpExplorer.h

@@ -793,6 +793,7 @@ public:
   bool CanCloseSession(TManagedTerminal * Session);
   virtual UnicodeString __fastcall DefaultDownloadTargetDirectory() = 0;
   virtual bool SupportedSession(TSessionData * SessionData) = 0;
+  TOperationSide GetOtherSide(TOperationSide Side);
 
   void __fastcall NewSession(const UnicodeString & SessionUrl = L"");
   virtual void NewTab(TOperationSide Side = osCurrent, bool AllowReverse = true);

+ 2 - 0
source/forms/NonVisual.cpp

@@ -293,6 +293,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
     UPD(SIDE ## HomeDirAction, DirViewEnabled(os ## SIDE)) \
     UPD(SIDE ## RefreshAction, DirViewEnabled(os ## SIDE) && DirView(os ## SIDE)->DirOK) \
     UPD(SIDE ## OpenDirAction, DirViewEnabled(os ## SIDE)) \
+    UPD(SIDE ## OtherDirAction, ScpExplorer->IsLocalBrowserMode() && !SamePaths(DirView(osLocal)->Path, DirView(osOther)->Path)) \
     UPD(SIDE ## ChangePathAction2, DirViewEnabled(os ## SIDE)) \
     UPD(SIDE ## AddBookmarkAction2, DirViewEnabled(os ## SIDE)) \
     UPD(SIDE ## PathToClipboardAction2, DirViewEnabled(os ## SIDE)) \
@@ -641,6 +642,7 @@ void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
       EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \
       EXE(SIDE ## RefreshAction, ScpExplorer->ReloadDirectory(os ## SIDE)) \
       EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
+      EXE(SIDE ## OtherDirAction, DirView(os ## SIDE)->Path = DirView(ScpExplorer->GetOtherSide(os ## SIDE))->Path) \
       EXE(SIDE ## ChangePathAction2, ScpExplorer->ChangePath(os ## SIDE)) \
       EXE(SIDE ## AddBookmarkAction2, ScpExplorer->AddBookmark(os ## SIDE)) \
       EXE(SIDE ## PathToClipboardAction2, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \

+ 22 - 0
source/forms/NonVisual.dfm

@@ -2413,6 +2413,22 @@ object NonVisualDataModule: TNonVisualDataModule
         'the file panel'
       ShortCut = 40973
     end
+    object LocalOtherDirAction: TAction
+      Tag = 9
+      Category = 'Local Directory'
+      Caption = 'Path fro&m Other Panel'
+      HelpKeyword = 'task_navigate#manual'
+      Hint = 'Open the same directory as in the other panel'
+      ShortCut = 16574
+    end
+    object RemoteOtherDirAction: TAction
+      Tag = 14
+      Category = 'Remote Directory'
+      Caption = 'Path fro&m Other Panel'
+      HelpKeyword = 'task_navigate#manual'
+      Hint = 'Open the same directory as in the other panel'
+      ShortCut = 16574
+    end
   end
   object ExplorerBarPopup: TTBXPopupMenu
     Images = GlyphsModule.ExplorerImages
@@ -2664,6 +2680,9 @@ object NonVisualDataModule: TNonVisualDataModule
       object TBXItem89: TTBXItem
         Action = RemoteHomeDirAction
       end
+      object TBXItem109: TTBXItem
+        Action = RemoteOtherDirAction
+      end
       object TBXSeparatorItem14: TTBXSeparatorItem
       end
       object TBXItem90: TTBXItem
@@ -2745,6 +2764,9 @@ object NonVisualDataModule: TNonVisualDataModule
       object TBXItem96: TTBXItem
         Action = LocalHomeDirAction
       end
+      object TBXItem113: TTBXItem
+        Action = LocalOtherDirAction
+      end
       object TBXSeparatorItem16: TTBXSeparatorItem
       end
       object TBXItem97: TTBXItem

+ 4 - 0
source/forms/NonVisual.h

@@ -695,6 +695,10 @@ __published:    // IDE-managed Components
   TTBXItem *RemoteCalculateDirectorySizesPopupItem;
   TTBXItem *LocalCalculateDirectorySizesPopupItem;
   TTBXItem *TBXItem112;
+  TAction *LocalOtherDirAction;
+  TAction *RemoteOtherDirAction;
+  TTBXItem *TBXItem109;
+  TTBXItem *TBXItem113;
   void __fastcall ExplorerActionsUpdate(TBasicAction *Action, bool &Handled);
   void __fastcall ExplorerActionsExecute(TBasicAction *Action, bool &Handled);
   void __fastcall SessionIdleTimerTimer(TObject *Sender);

+ 1 - 13
source/forms/ScpCommander.cpp

@@ -2785,19 +2785,7 @@ void TScpCommanderForm::LocalLocalCopy(
       Abort();
   }
 
-  TOperationSide OtherSide;
-  switch (GetSide(Side))
-  {
-    case osLocal:
-      OtherSide = osOther;
-      break;
-    case osOther:
-      OtherSide = osLocal;
-      break;
-    default:
-      DebugFail();
-      Abort();
-  }
+  TOperationSide OtherSide = GetOtherSide(GetSide(Side));
 
   TCustomDirView * SourceDirView = DirView(Side);
   UnicodeString DestinationDir = DirView(OtherSide)->PathName;

+ 6 - 0
source/forms/ScpCommander.dfm

@@ -70,6 +70,9 @@ inherited ScpCommanderForm: TScpCommanderForm
           object TBXItem6: TTBXItem
             Action = NonVisualDataModule.LocalHomeDirAction
           end
+          object TBXItem262: TTBXItem
+            Action = NonVisualDataModule.LocalOtherDirAction
+          end
           object TBXSeparatorItem3: TTBXSeparatorItem
           end
           object TBXItem7: TTBXItem
@@ -673,6 +676,9 @@ inherited ScpCommanderForm: TScpCommanderForm
           object TBXItem87: TTBXItem
             Action = NonVisualDataModule.RemoteHomeDirAction
           end
+          object TBXItem261: TTBXItem
+            Action = NonVisualDataModule.RemoteOtherDirAction
+          end
           object TBXSeparatorItem26: TTBXSeparatorItem
           end
           object TBXItem88: TTBXItem

+ 2 - 0
source/forms/ScpCommander.h

@@ -458,6 +458,8 @@ __published:
   TTBXItem *TBXItem259;
   TTBXSeparatorItem *TBXSeparatorItem71;
   TTBXItem *TBXItem260;
+  TTBXItem *TBXItem261;
+  TTBXItem *TBXItem262;
   void __fastcall SplitterMoved(TObject *Sender);
   void __fastcall SplitterCanResize(TObject *Sender, int &NewSize,
     bool &Accept);