ScpCommander.cpp 76 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include "ScpCommander.h"
  5. #include <Common.h>
  6. #include <CoreMain.h>
  7. #include <Interface.h>
  8. #include <TextsCore.h>
  9. #include <TextsWin.h>
  10. #include <HelpWin.h>
  11. #include <VCLCommon.h>
  12. #include <GUITools.h>
  13. #include <DragDrop.hpp>
  14. #include <StrUtils.hpp>
  15. #include "Glyphs.h"
  16. #include "NonVisual.h"
  17. #include "Tools.h"
  18. #include "WinConfiguration.h"
  19. #include "TerminalManager.h"
  20. #include "Bookmarks.h"
  21. //---------------------------------------------------------------------------
  22. #pragma package(smart_init)
  23. #pragma link "CustomDirView"
  24. #pragma link "CustomScpExplorer"
  25. #pragma link "CustomUnixDirView"
  26. #pragma link "IEListView"
  27. #pragma link "NortonLikeListView"
  28. #pragma link "UnixDirView"
  29. #pragma link "DirView"
  30. #pragma link "PathLabel"
  31. #pragma link "HistoryComboBox"
  32. #pragma link "CustomDriveView"
  33. #pragma link "DriveView"
  34. #pragma link "UnixDriveView"
  35. #pragma link "TB2Dock"
  36. #pragma link "TB2Item"
  37. #pragma link "TB2Toolbar"
  38. #pragma link "TBX"
  39. #pragma link "TB2ExtItems"
  40. #pragma link "TBXExtItems"
  41. #pragma link "TBXLists"
  42. #pragma link "TBXStatusBars"
  43. #pragma link "TBXToolPals"
  44. #pragma link "ThemePageControl"
  45. #ifndef NO_RESOURCES
  46. #pragma resource "*.dfm"
  47. #endif
  48. //---------------------------------------------------------------------------
  49. class TSynchronizedBrowsingGuard
  50. {
  51. public:
  52. TSynchronizedBrowsingGuard()
  53. {
  54. FWasSynchronisingBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  55. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  56. }
  57. ~TSynchronizedBrowsingGuard()
  58. {
  59. NonVisualDataModule->SynchronizeBrowsingAction->Checked = FWasSynchronisingBrowsing;
  60. }
  61. private:
  62. bool FWasSynchronisingBrowsing;
  63. };
  64. //---------------------------------------------------------------------------
  65. __fastcall TScpCommanderForm::TScpCommanderForm(TComponent* Owner)
  66. : TCustomScpExplorerForm(Owner)
  67. {
  68. FConstructed = true;
  69. FCurrentSide = osLocal;
  70. FLastLeftPanelWidth = LeftPanelWidth;
  71. FNormalPanelsWidth = -1;
  72. FSynchronisingBrowse = false;
  73. FFirstTerminal = true;
  74. FInternalDDDownloadList = new TStringList();
  75. FLocalPathComboBoxPaths = new TStringList();
  76. LocalPathComboUpdateDrives();
  77. LocalBackButton->LinkSubitems = HistoryMenu(osLocal, true)->Items;
  78. LocalForwardButton->LinkSubitems = HistoryMenu(osLocal, false)->Items;
  79. RemoteBackButton->LinkSubitems = HistoryMenu(osRemote, true)->Items;
  80. RemoteForwardButton->LinkSubitems = HistoryMenu(osRemote, false)->Items;
  81. TopDock->PopupMenu = NonVisualDataModule->CommanderBarPopup;
  82. CopyPopup(StatusBar, TopDock);
  83. CopyPopup(QueueDock, TopDock);
  84. CopyPopup(QueueLabel, TopDock);
  85. CopyPopup(BottomDock, TopDock);
  86. CopyPopup(QueueSeparatorPanel, TopDock);
  87. LocalTopDock->PopupMenu = NonVisualDataModule->LocalPanelPopup;
  88. CopyPopup(LocalPathLabel, LocalTopDock);
  89. CopyPopup(LocalStatusBar, LocalTopDock);
  90. CopyPopup(LocalDriveView, LocalTopDock);
  91. CopyPopup(LocalBottomDock, LocalTopDock);
  92. RemoteTopDock->PopupMenu = NonVisualDataModule->RemotePanelPopup;
  93. CopyPopup(RemotePathLabel, RemoteTopDock);
  94. CopyPopup(RemoteStatusBar, RemoteTopDock);
  95. CopyPopup(RemoteDriveView, RemoteTopDock);
  96. CopyPopup(RemoteBottomDock, RemoteTopDock);
  97. SetShortcuts();
  98. Splitter->ShowHint = True;
  99. LocalPanelSplitter->ShowHint = true;
  100. reinterpret_cast<TLabel*>(Splitter)->OnDblClick = SplitterDblClick;
  101. reinterpret_cast<TLabel*>(LocalPanelSplitter)->OnDblClick = PanelSplitterDblClick;
  102. reinterpret_cast<TLabel*>(RemotePanelSplitter)->OnDblClick = PanelSplitterDblClick;
  103. CommandLineCombo->Text = L"";
  104. FCommandLineComboPopulated = false;
  105. for (int i = 0; i < Toolbar2Toolbar->Items->Count; i++)
  106. {
  107. UpdateToolbar2ItemCaption(Toolbar2Toolbar->Items->Items[i]);
  108. }
  109. UseDesktopFont(LocalDirView);
  110. UseDesktopFont(LocalDriveView);
  111. UseDesktopFont(LocalPathLabel);
  112. UseDesktopFont(RemotePathLabel);
  113. UseDesktopFont(LocalStatusBar);
  114. UseDesktopFont(StatusBar);
  115. NonVisualDataModule->QueueSpeedComboBoxItem(QueueSpeedComboBoxItem);
  116. // particularly to reorder panels on right-to-left bidi mode
  117. ConfigurationChanged();
  118. }
  119. //---------------------------------------------------------------------------
  120. __fastcall TScpCommanderForm::~TScpCommanderForm()
  121. {
  122. delete FInternalDDDownloadList;
  123. SAFE_DESTROY(FLocalPathComboBoxPaths);
  124. }
  125. //---------------------------------------------------------------------------
  126. void __fastcall TScpCommanderForm::UpdateToolbar2ItemCaption(TTBCustomItem * Item)
  127. {
  128. Item->Caption =
  129. ShortCutToText(Item->ShortCut) + L" " +
  130. StripEllipsis(StripHotkey(Item->Caption));
  131. }
  132. //---------------------------------------------------------------------------
  133. void __fastcall TScpCommanderForm::RestoreFormParams()
  134. {
  135. DebugAssert(WinConfiguration);
  136. TCustomScpExplorerForm::RestoreFormParams();
  137. RestoreForm(WinConfiguration->ScpCommander.WindowParams, this);
  138. }
  139. //---------------------------------------------------------------------------
  140. void __fastcall TScpCommanderForm::RestoreParams()
  141. {
  142. DebugAssert(Configuration);
  143. TCustomScpExplorerForm::RestoreParams();
  144. LeftPanelWidth = WinConfiguration->ScpCommander.LocalPanelWidth;
  145. LoadToolbarsLayoutStr(WinConfiguration->ScpCommander.ToolbarsLayout, WinConfiguration->ScpCommander.ToolbarsButtons);
  146. if (IsUWP())
  147. {
  148. UpdatesToolbar->Visible = false;
  149. }
  150. SessionsPageControl->Visible = WinConfiguration->ScpCommander.SessionsTabs;
  151. StatusBar->Visible = WinConfiguration->ScpCommander.StatusBar;
  152. #define RESTORE_PANEL_PARAMS(PANEL) \
  153. PANEL ## DirView->ColProperties->ParamsStr = WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams; \
  154. PANEL ## StatusBar->Visible = WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar; \
  155. PANEL ## DriveView->Visible = WinConfiguration->ScpCommander.PANEL ## Panel.DriveView; \
  156. if (PANEL ## DriveView->Align == alTop) \
  157. PANEL ## DriveView->Height = LoadDimension(WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeight, WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeightPixelsPerInch, this); \
  158. else \
  159. PANEL ## DriveView->Width = LoadDimension(WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidth, WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidthPixelsPerInch, this)
  160. RESTORE_PANEL_PARAMS(Local);
  161. RESTORE_PANEL_PARAMS(Remote);
  162. #undef RESTORE_PANEL_PARAMS
  163. FPanelsRestored = true;
  164. // just to make sure
  165. LocalDirView->DirColProperties->ExtVisible = false;
  166. RemoteDirView->UnixColProperties->ExtVisible = false;
  167. }
  168. //---------------------------------------------------------------------------
  169. void __fastcall TScpCommanderForm::StoreParams()
  170. {
  171. DebugAssert(WinConfiguration);
  172. WinConfiguration->BeginUpdate();
  173. try
  174. {
  175. WinConfiguration->ScpCommander.ToolbarsLayout = GetToolbarsLayoutStr();
  176. WinConfiguration->ScpCommander.ToolbarsButtons = GetToolbarsButtonsStr();
  177. WinConfiguration->ScpCommander.LocalPanelWidth = LeftPanelWidth;
  178. WinConfiguration->ScpCommander.SessionsTabs = SessionsPageControl->Visible;
  179. WinConfiguration->ScpCommander.StatusBar = StatusBar->Visible;
  180. SaveCommandLine();
  181. WinConfiguration->ScpCommander.CurrentPanel = FCurrentSide;
  182. #define STORE_PANEL_PARAMS(PANEL) \
  183. WinConfiguration->ScpCommander.PANEL ## Panel.DirViewParams = PANEL ## DirView->ColProperties->ParamsStr; \
  184. WinConfiguration->ScpCommander.PANEL ## Panel.StatusBar = PANEL ## StatusBar->Visible; \
  185. WinConfiguration->ScpCommander.PANEL ## Panel.DriveView = PANEL ## DriveView->Visible; \
  186. if (PANEL ## DriveView->Align == alTop) \
  187. { \
  188. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeight = PANEL ## DriveView->Height; \
  189. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewHeightPixelsPerInch = GetControlPixelsPerInch(this); \
  190. } \
  191. else \
  192. { \
  193. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidth = PANEL ## DriveView->Width; \
  194. WinConfiguration->ScpCommander.PANEL ## Panel.DriveViewWidthPixelsPerInch = GetControlPixelsPerInch(this); \
  195. }
  196. STORE_PANEL_PARAMS(Local);
  197. STORE_PANEL_PARAMS(Remote);
  198. #undef RESTORE_PANEL_PARAMS
  199. WinConfiguration->ScpCommander.WindowParams = StoreForm(this);
  200. TCustomScpExplorerForm::StoreParams();
  201. }
  202. __finally
  203. {
  204. WinConfiguration->EndUpdate();
  205. }
  206. }
  207. //---------------------------------------------------------------------------
  208. void __fastcall TScpCommanderForm::UpdateTerminal(TTerminal * Terminal)
  209. {
  210. TCustomScpExplorerForm::UpdateTerminal(Terminal);
  211. TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Terminal);
  212. DebugAssert(ManagedTerminal != NULL);
  213. DebugAssert(LocalDirView != NULL);
  214. SAFE_DESTROY(ManagedTerminal->LocalExplorerState);
  215. if (WinConfiguration->PreservePanelState)
  216. {
  217. ManagedTerminal->LocalExplorerState = LocalDirView->SaveState();
  218. }
  219. }
  220. //---------------------------------------------------------------------------
  221. void __fastcall TScpCommanderForm::UpdateSessionData(TSessionData * Data)
  222. {
  223. // Keep in sync with TSessionData::CopyStateData
  224. TCustomScpExplorerForm::UpdateSessionData(Data);
  225. DebugAssert(LocalDirView);
  226. Data->LocalDirectory = LocalDirView->PathName;
  227. Data->SynchronizeBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  228. }
  229. //---------------------------------------------------------------------------
  230. bool __fastcall TScpCommanderForm::InternalDDDownload(UnicodeString & TargetDirectory)
  231. {
  232. DebugAssert(IsFileControl(FDDTargetControl, osLocal));
  233. bool Result = false;
  234. if (FDDTargetControl == LocalDirView)
  235. {
  236. if (LocalDirView->DropTarget)
  237. {
  238. // when drop target is not directory, it is probably file type, which have
  239. // associated drop handler (such as ZIP file in WinXP). in this case we
  240. // must leave drop handling to destination application.
  241. // ! this check is duplicated in LocalDirViewDDTargetHasDropHandler()
  242. // for shellex downloads
  243. if (LocalDirView->ItemIsDirectory(LocalDirView->DropTarget))
  244. {
  245. TargetDirectory = LocalDirView->ItemFullFileName(LocalDirView->DropTarget);
  246. Result = true;
  247. }
  248. }
  249. else
  250. {
  251. TargetDirectory = DefaultDownloadTargetDirectory();
  252. Result = true;
  253. }
  254. }
  255. else if (FDDTargetControl == LocalDriveView)
  256. {
  257. DebugAssert(LocalDriveView->DropTarget != NULL);
  258. TargetDirectory = LocalDriveView->NodePathName(LocalDriveView->DropTarget);
  259. Result = true;
  260. }
  261. else
  262. {
  263. DebugFail();
  264. Abort();
  265. }
  266. return Result;
  267. }
  268. //---------------------------------------------------------------------------
  269. UnicodeString __fastcall TScpCommanderForm::DefaultDownloadTargetDirectory()
  270. {
  271. return IncludeTrailingBackslash(LocalDirView->Path);
  272. }
  273. //---------------------------------------------------------------------------
  274. bool __fastcall TScpCommanderForm::CopyParamDialog(TTransferDirection Direction,
  275. TTransferType Type, bool Temp, TStrings * FileList, UnicodeString & TargetDirectory,
  276. TGUICopyParamType & CopyParam, bool Confirm, bool DragDrop, int Options)
  277. {
  278. bool Result = false;
  279. // Temp means d&d here so far, may change in future!
  280. if (Temp && (Direction == tdToLocal) &&
  281. IsFileControl(FDDTargetControl, osLocal))
  282. {
  283. Result = InternalDDDownload(TargetDirectory);
  284. if (Result)
  285. {
  286. DebugAssert(FileList->Count > 0);
  287. FInternalDDDownloadList->Assign(FileList);
  288. }
  289. }
  290. else if (!Temp && TargetDirectory.IsEmpty())
  291. {
  292. if (Direction == tdToLocal)
  293. {
  294. TargetDirectory = DefaultDownloadTargetDirectory();
  295. }
  296. else
  297. {
  298. TargetDirectory = UnixIncludeTrailingBackslash(RemoteDirView->Path);
  299. }
  300. }
  301. if (!Result)
  302. {
  303. Result = TCustomScpExplorerForm::CopyParamDialog(Direction, Type, Temp,
  304. FileList, TargetDirectory, CopyParam, Confirm, DragDrop, Options);
  305. }
  306. return Result;
  307. }
  308. //---------------------------------------------------------------------------
  309. void __fastcall TScpCommanderForm::DoShow()
  310. {
  311. // Make sure the RemoteDirView is disabled (if not connected yet)
  312. // before the focusing below,
  313. // otherwise we disable the view while setting it focused
  314. // (UpdateControls gets calling within the SetFocus),
  315. // leading to VCL focus inconsistency wih Windows,
  316. // and the view [anothing actually] not getting focused after the session
  317. // is finally connected
  318. UpdateControls();
  319. // If we do not call SetFocus on any control before DoShow,
  320. // no control will get focused on Login dialog
  321. // (HACK seems like a bug in VCL)
  322. if (WinConfiguration->ScpCommander.CurrentPanel == osLocal)
  323. {
  324. LocalDirView->SetFocus();
  325. FRemoteDirViewWasFocused = false;
  326. }
  327. else
  328. {
  329. if (RemoteDirView->Enabled)
  330. {
  331. RemoteDirView->SetFocus();
  332. }
  333. else
  334. {
  335. LocalDirView->SetFocus();
  336. }
  337. FRemoteDirViewWasFocused = true;
  338. }
  339. TCustomScpExplorerForm::DoShow();
  340. }
  341. //---------------------------------------------------------------------------
  342. Boolean __fastcall TScpCommanderForm::AllowedAction(TAction * Action, TActionAllowed Allowed)
  343. {
  344. #define FLAG ((TActionFlag)(Action->Tag))
  345. return
  346. TCustomScpExplorerForm::AllowedAction(Action, Allowed) &&
  347. // always require Commander flag
  348. (FLAG & afCommander) &&
  349. // if action is execution or update, we don't require any other flag
  350. // if we check for shortcut, we require proper dirview to be selected
  351. ((Allowed != aaShortCut) ||
  352. ((FLAG & afLocal) && (FCurrentSide == osLocal)) ||
  353. ((FLAG & afRemote) && (FCurrentSide == osRemote))
  354. );
  355. #undef FLAG
  356. }
  357. //---------------------------------------------------------------------------
  358. TCustomDirView * __fastcall TScpCommanderForm::DirView(TOperationSide Side)
  359. {
  360. Side = GetSide(Side);
  361. if (Side == osLocal)
  362. {
  363. return LocalDirView;
  364. }
  365. else
  366. {
  367. return TCustomScpExplorerForm::DirView(Side);
  368. }
  369. }
  370. //---------------------------------------------------------------------------
  371. bool __fastcall TScpCommanderForm::DirViewEnabled(TOperationSide Side)
  372. {
  373. Side = GetSide(Side);
  374. if (Side == osLocal)
  375. {
  376. return true;
  377. }
  378. else
  379. {
  380. return TCustomScpExplorerForm::DirViewEnabled(Side);
  381. }
  382. }
  383. //---------------------------------------------------------------------------
  384. bool __fastcall TScpCommanderForm::IsFileControl(TObject * Control,
  385. TOperationSide Side)
  386. {
  387. return
  388. ((Side == osLocal) &&
  389. ((Control == LocalDirView) || (Control == LocalDriveView))) ||
  390. TCustomScpExplorerForm::IsFileControl(Control, Side);
  391. }
  392. //---------------------------------------------------------------------------
  393. void __fastcall TScpCommanderForm::ReloadLocalDirectory(const UnicodeString Directory)
  394. {
  395. if (Directory.IsEmpty() || SamePaths(Directory, LocalDirView->Path))
  396. {
  397. LocalDirView->ReloadDirectory();
  398. LocalDriveView->ValidateDirectory(LocalDriveView->Selected);
  399. }
  400. TCustomScpExplorerForm::ReloadLocalDirectory();
  401. }
  402. //---------------------------------------------------------------------------
  403. void __fastcall TScpCommanderForm::BatchStart(void *& Storage)
  404. {
  405. Storage = new bool;
  406. *static_cast<bool*>(Storage) = LocalDirView->WatchForChanges;
  407. LocalDirView->WatchForChanges = false;
  408. LocalDriveView->WatchDirectory = false;
  409. TCustomScpExplorerForm::BatchStart(Storage);
  410. }
  411. //---------------------------------------------------------------------------
  412. void __fastcall TScpCommanderForm::BatchEnd(void * Storage)
  413. {
  414. TCustomScpExplorerForm::BatchEnd(Storage);
  415. DebugAssert(Storage != NULL);
  416. LocalDirView->WatchForChanges = *static_cast<bool*>(Storage);
  417. LocalDriveView->WatchDirectory = LocalDirView->WatchForChanges;
  418. delete Storage;
  419. }
  420. //---------------------------------------------------------------------------
  421. void __fastcall TScpCommanderForm::StartingDisconnected()
  422. {
  423. TCustomScpExplorerForm::StartingDisconnected();
  424. LocalDefaultDirectory();
  425. }
  426. //---------------------------------------------------------------------------
  427. void __fastcall TScpCommanderForm::TerminalChanged(bool Replaced)
  428. {
  429. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  430. TCustomScpExplorerForm::TerminalChanged(Replaced);
  431. if (Terminal)
  432. {
  433. // we will load completelly different directory, so particularly
  434. // do not attempt to select previously selected directory
  435. LocalDirView->ContinueSession(false);
  436. TManagedTerminal * ManagedTerminal = dynamic_cast<TManagedTerminal *>(Terminal);
  437. DebugAssert(ManagedTerminal != NULL);
  438. // reset home directory
  439. LocalDirView->HomeDirectory = L"";
  440. if (FFirstTerminal || !WinConfiguration->ScpCommander.PreserveLocalDirectory)
  441. {
  442. UnicodeString LocalDirectory = ManagedTerminal->StateData->LocalDirectory;
  443. bool DocumentsDir = LocalDirectory.IsEmpty();
  444. if (!DocumentsDir)
  445. {
  446. try
  447. {
  448. LocalDirView->Path = LocalDirectory;
  449. }
  450. catch(Exception & E)
  451. {
  452. DocumentsDir = true;
  453. if (!Terminal->SessionData->UpdateDirectories)
  454. {
  455. Terminal->ShowExtendedException(&E);
  456. }
  457. }
  458. }
  459. if (DocumentsDir)
  460. {
  461. LocalDefaultDirectory();
  462. }
  463. }
  464. FFirstTerminal = false;
  465. if (WinConfiguration->DefaultDirIsHome &&
  466. !Terminal->SessionData->UpdateDirectories)
  467. {
  468. LocalDirView->HomeDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
  469. }
  470. if (WinConfiguration->PreservePanelState &&
  471. !WinConfiguration->ScpCommander.PreserveLocalDirectory)
  472. {
  473. if (ManagedTerminal->LocalExplorerState != NULL)
  474. {
  475. LocalDirView->RestoreState(ManagedTerminal->LocalExplorerState);
  476. }
  477. else
  478. {
  479. LocalDirView->ClearState();
  480. }
  481. NonVisualDataModule->SynchronizeBrowsingAction->Checked = ManagedTerminal->StateData->SynchronizeBrowsing;
  482. }
  483. }
  484. }
  485. //---------------------------------------------------------------------------
  486. void __fastcall TScpCommanderForm::LocalDefaultDirectory()
  487. {
  488. try
  489. {
  490. LocalDirView->HomeDirectory = L"";
  491. LocalDirView->ExecuteHomeDirectory();
  492. }
  493. catch(Exception & E)
  494. {
  495. ShowExtendedException(NULL, &E);
  496. LocalDirView->Path = ExtractFilePath(Application->ExeName);
  497. }
  498. }
  499. //---------------------------------------------------------------------------
  500. void __fastcall TScpCommanderForm::ConfigurationChanged()
  501. {
  502. TCustomScpExplorerForm::ConfigurationChanged();
  503. if (WinConfiguration->DefaultDirIsHome && Terminal &&
  504. !Terminal->SessionData->UpdateDirectories)
  505. {
  506. LocalDirView->HomeDirectory = ExpandFileName(Terminal->SessionData->LocalDirectory);
  507. }
  508. else
  509. {
  510. LocalDirView->HomeDirectory = L"";
  511. }
  512. LocalDirView->DimmHiddenFiles = WinConfiguration->DimmHiddenFiles;
  513. LocalDriveView->DimmHiddenDirs = WinConfiguration->DimmHiddenFiles;
  514. LocalDirView->ShowHiddenFiles = WinConfiguration->ShowHiddenFiles;
  515. LocalDirView->FormatSizeBytes = WinConfiguration->FormatSizeBytes;
  516. LocalDriveView->ShowHiddenDirs = WinConfiguration->ShowHiddenFiles;
  517. LocalDirView->ConfirmOverwrite = WinConfiguration->ConfirmOverwriting;
  518. LocalDriveView->ConfirmOverwrite = WinConfiguration->ConfirmOverwriting;
  519. LocalDirView->NortonLike = WinConfiguration->ScpCommander.NortonLikeMode;
  520. RemoteDirView->NortonLike = WinConfiguration->ScpCommander.NortonLikeMode;
  521. LocalDirView->NaturalOrderNumericalSorting = WinConfiguration->NaturalOrderNumericalSorting;
  522. LocalDriveView->NaturalOrderNumericalSorting = WinConfiguration->NaturalOrderNumericalSorting;
  523. LocalDirView->TimeoutShellIconRetrieval = WinConfiguration->TimeoutShellIconRetrieval;
  524. if (LocalDirView->RowSelect != WinConfiguration->FullRowSelect)
  525. {
  526. LocalDirView->RowSelect = WinConfiguration->FullRowSelect;
  527. // selection is not redrawn automatically when RowSelect changes
  528. LocalDirView->Invalidate();
  529. }
  530. // See also LocalDirViewDDTargetHasDropHandler
  531. LocalDirView->DragDropFilesEx->ShellExtensions->DropHandler = !WinConfiguration->DDFakeFile;
  532. LocalDriveView->DragDropFilesEx->ShellExtensions->DropHandler = !WinConfiguration->DDFakeFile;
  533. if (Panel(true)->Left > Panel(false)->Left)
  534. {
  535. DisableAlign();
  536. try
  537. {
  538. int AWidth = ClientWidth;
  539. Panel(false)->Align = alClient;
  540. // In bidi mode it gets swapped to alRight, what does not work with the rest of this logic
  541. Splitter->Align = alLeft;
  542. Panel(true)->Align = alLeft;
  543. TControl * ControlsOrder[] =
  544. { Panel(true), Splitter, Panel(false) };
  545. SetHorizontalControlsOrder(ControlsOrder, LENOF(ControlsOrder));
  546. Panel(true)->TabOrder = 0;
  547. Panel(false)->TabOrder = 1;
  548. ClientWidth = AWidth;
  549. LeftPanelWidth = FLastLeftPanelWidth;
  550. }
  551. __finally
  552. {
  553. EnableAlign();
  554. }
  555. int LocalIndex = MenuToolbar->Items->IndexOf(LocalMenuButton);
  556. int RemoteIndex = MenuToolbar->Items->IndexOf(RemoteMenuButton);
  557. MenuToolbar->Items->Move(LocalIndex, RemoteIndex);
  558. RemoteIndex = MenuToolbar->Items->IndexOf(RemoteMenuButton);
  559. MenuToolbar->Items->Move(RemoteIndex, LocalIndex);
  560. SWAP(TShortCut, NonVisualDataModule->LocalChangePathAction->ShortCut,
  561. NonVisualDataModule->RemoteChangePathAction->ShortCut);
  562. }
  563. if ((RemoteDriveView->Align == alLeft) != WinConfiguration->ScpCommander.TreeOnLeft)
  564. {
  565. TScpCommanderPanelConfiguration LocalPanel = WinConfiguration->ScpCommander.LocalPanel;
  566. TScpCommanderPanelConfiguration RemotePanel = WinConfiguration->ScpCommander.RemotePanel;
  567. bool TreeOnLeft = WinConfiguration->ScpCommander.TreeOnLeft;
  568. // save value only is it was set yet
  569. if (FPanelsRestored)
  570. {
  571. if (TreeOnLeft)
  572. {
  573. // want to be on left, so it is on top, saving height
  574. LocalPanel.DriveViewHeight = LocalDriveView->Height;
  575. RemotePanel.DriveViewHeight = RemoteDriveView->Height;
  576. }
  577. else
  578. {
  579. LocalPanel.DriveViewWidth = LocalDriveView->Width;
  580. RemotePanel.DriveViewWidth = RemoteDriveView->Width;
  581. }
  582. }
  583. TAlign NonClientAlign = (TreeOnLeft ? alLeft : alTop);
  584. // VCL adjusts cursors only between crVSplit and crHSplit,
  585. // See TSplitter.RequestAlign
  586. TCursor SplitterCursor = (TreeOnLeft ? crSizeWE : crSizeNS);
  587. LocalDriveView->Align = NonClientAlign;
  588. LocalPanelSplitter->Align = NonClientAlign;
  589. LocalPanelSplitter->Cursor = SplitterCursor;
  590. RemoteDriveView->Align = NonClientAlign;
  591. RemotePanelSplitter->Align = NonClientAlign;
  592. RemotePanelSplitter->Cursor = SplitterCursor;
  593. FixControlsPlacement();
  594. if (TreeOnLeft)
  595. {
  596. LocalDriveView->Width = LocalPanel.DriveViewWidth;
  597. RemoteDriveView->Width = RemotePanel.DriveViewWidth;
  598. }
  599. else
  600. {
  601. LocalDriveView->Height = LocalPanel.DriveViewHeight;
  602. RemoteDriveView->Height = RemotePanel.DriveViewHeight;
  603. }
  604. // in case it trigges config-changed event (does not),
  605. // make sure it does only after we apply the TreeOnLeft change to avoid endless recursion
  606. WinConfiguration->ScpCommander.LocalPanel = LocalPanel;
  607. WinConfiguration->ScpCommander.RemotePanel = RemotePanel;
  608. }
  609. if (FExplorerKeyboardShortcuts != WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts)
  610. {
  611. SetShortcuts();
  612. }
  613. }
  614. //---------------------------------------------------------------------------
  615. void __fastcall TScpCommanderForm::SetShortcuts()
  616. {
  617. // set common norton shorcuts to our actions
  618. NonVisualDataModule->CommanderShortcuts();
  619. FExplorerKeyboardShortcuts = WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts;
  620. }
  621. //---------------------------------------------------------------------------
  622. TPanel * __fastcall TScpCommanderForm::Panel(bool Left)
  623. {
  624. bool SwappedPanels = WinConfiguration->ScpCommander.SwappedPanels;
  625. if (IsRightToLeft())
  626. {
  627. SwappedPanels = !SwappedPanels;
  628. }
  629. return (SwappedPanels == Left ? RemotePanel : LocalPanel);
  630. }
  631. //---------------------------------------------------------------------------
  632. TPanel * __fastcall TScpCommanderForm::CurrentPanel()
  633. {
  634. return (FCurrentSide == osLocal ? LocalPanel : RemotePanel);
  635. }
  636. //---------------------------------------------------------------------------
  637. void __fastcall TScpCommanderForm::SetLeftPanelWidth(double value)
  638. {
  639. double Total = LocalPanel->Width + RemotePanel->Width;
  640. FLeftPanelWidth = value;
  641. if (value * Total != Panel(true)->Width)
  642. {
  643. Panel(true)->Width = static_cast<int>(value * Total);
  644. UpdateControls();
  645. }
  646. }
  647. //---------------------------------------------------------------------------
  648. double __fastcall TScpCommanderForm::GetLeftPanelWidth()
  649. {
  650. return FLeftPanelWidth;
  651. }
  652. //---------------------------------------------------------------------------
  653. void __fastcall TScpCommanderForm::SplitterMoved(TObject * /*Sender*/)
  654. {
  655. double Left = Panel(true)->Width;
  656. double Total = LocalPanel->Width + RemotePanel->Width;
  657. FLeftPanelWidth = Left / Total;
  658. FLastLeftPanelWidth = LeftPanelWidth;
  659. UpdateControls();
  660. }
  661. //---------------------------------------------------------------------------
  662. void __fastcall TScpCommanderForm::SplitterCanResize(TObject * /*Sender*/,
  663. int &NewSize, bool & /*Accept*/)
  664. {
  665. // When splitter is drag so far to right, that width contraint of remote panel would
  666. // be violated, it doesn't stop, but extend form width.
  667. // Following prevents this behavior.
  668. if (ClientWidth - NewSize - Splitter->Width < Panel(false)->Constraints->MinWidth)
  669. NewSize = (ClientWidth - Panel(false)->Constraints->MinWidth - Splitter->Width);
  670. }
  671. //---------------------------------------------------------------------------
  672. void __fastcall TScpCommanderForm::SplitterDblClick(TObject * /*Sender*/)
  673. {
  674. LeftPanelWidth = 0.5;
  675. }
  676. //---------------------------------------------------------------------------
  677. void __fastcall TScpCommanderForm::PanelSplitterDblClick(TObject * Sender)
  678. {
  679. TSplitter * Splitter = dynamic_cast<TSplitter *>(Sender);
  680. DebugAssert(Splitter != NULL);
  681. TCustomDriveView * DriveView;
  682. TCustomDriveView * OtherDriveView;
  683. if (Splitter == LocalPanelSplitter)
  684. {
  685. DriveView = LocalDriveView;
  686. OtherDriveView = RemoteDriveView;
  687. }
  688. else
  689. {
  690. DriveView = RemoteDriveView;
  691. OtherDriveView = LocalDriveView;
  692. }
  693. bool TreeOnLeft = WinConfiguration->ScpCommander.TreeOnLeft;
  694. DebugAssert(DriveView->Visible);
  695. if (OtherDriveView->Visible)
  696. {
  697. if (TreeOnLeft)
  698. {
  699. DriveView->Width = OtherDriveView->Width;
  700. }
  701. else
  702. {
  703. DriveView->Height = OtherDriveView->Height;
  704. }
  705. }
  706. else
  707. {
  708. if (TreeOnLeft)
  709. {
  710. OtherDriveView->Width = DriveView->Width;
  711. }
  712. else
  713. {
  714. OtherDriveView->Height = DriveView->Height;
  715. }
  716. OtherDriveView->Visible = true;
  717. }
  718. FixControlsPlacement();
  719. }
  720. //---------------------------------------------------------------------------
  721. void __fastcall TScpCommanderForm::UpdateControls()
  722. {
  723. TCustomScpExplorerForm::UpdateControls();
  724. UnicodeString SplitterLongHint = Splitter->Hint;
  725. int P = SplitterLongHint.Pos(L"|");
  726. if (P == 0)
  727. {
  728. P = SplitterLongHint.Pos(L"\n");
  729. }
  730. SplitterLongHint.Delete(1, P);
  731. Splitter->Hint = FORMAT(L"%0.0f%%\n%s", (LeftPanelWidth*100, SplitterLongHint));
  732. UnicodeString ACommandLinePromptLabel = LoadStr(COMMAND_LINE_LABEL) + " " +
  733. ((FCurrentSide == osRemote) ? L"$" : L">");
  734. if (CommandLinePromptLabel->Caption != ACommandLinePromptLabel)
  735. {
  736. CommandLinePromptLabel->Caption = ACommandLinePromptLabel;
  737. // command line combo width needs to be updated as caption width has probably changed
  738. ToolBarResize(CommandLineToolbar);
  739. }
  740. LocalDirView->DarkMode = WinConfiguration->UseDarkTheme();
  741. LocalDriveView->DarkMode = LocalDirView->DarkMode;
  742. LocalDirView->Color = PanelColor();
  743. LocalDriveView->Color = LocalDirView->Color;
  744. LocalDirView->Font->Color = GetWindowTextColor(LocalDirView->Color);
  745. LocalDriveView->Font->Color = LocalDirView->Font->Color;
  746. bool LocalSide = (FCurrentSide == osLocal);
  747. TAction * CurrentCopyAction = LocalSide ? NonVisualDataModule->LocalCopyAction : NonVisualDataModule->RemoteCopyAction;
  748. if (CurrentCopyItem->Action != CurrentCopyAction)
  749. {
  750. CurrentCopyItem->Action = CurrentCopyAction;
  751. CurrentCopyToolbar2Item->Action = CurrentCopyAction;
  752. UpdateToolbar2ItemCaption(CurrentCopyToolbar2Item);
  753. CurrentCopyNonQueueItem->Action = LocalSide ? NonVisualDataModule->LocalCopyNonQueueAction : NonVisualDataModule->RemoteCopyNonQueueAction;
  754. CurrentCopyQueueItem->Action = LocalSide ? NonVisualDataModule->LocalCopyQueueAction : NonVisualDataModule->RemoteCopyQueueAction;
  755. TAction * CurrentMoveAction = LocalSide ? NonVisualDataModule->LocalMoveAction : NonVisualDataModule->RemoteMoveAction;
  756. CurrentMoveItem->Action = CurrentMoveAction;
  757. CurrentMoveToolbar2Item->Action = CurrentMoveAction;
  758. UpdateToolbar2ItemCaption(CurrentMoveToolbar2Item);
  759. }
  760. CommandLineCombo->Enabled = (FCurrentSide == osLocal) || CanConsole();
  761. CommandLinePromptLabel->Enabled = CommandLineCombo->Enabled;
  762. }
  763. //---------------------------------------------------------------------------
  764. void __fastcall TScpCommanderForm::ChangePath(TOperationSide Side)
  765. {
  766. DebugAssert((Side == osLocal) || (Side == osRemote));
  767. TTBXComboBoxItem * PathComboBox;
  768. if (Side == osLocal)
  769. {
  770. PathComboBox = LocalPathComboBox;
  771. }
  772. else
  773. {
  774. PathComboBox = RemotePathComboBox;
  775. }
  776. ClickToolbarItem(PathComboBox, false);
  777. }
  778. //---------------------------------------------------------------------------
  779. TControl * __fastcall TScpCommanderForm::GetComponent(Byte Component)
  780. {
  781. switch (Component) {
  782. case fcToolBar2: return Toolbar2Toolbar; // name changed to enforce change of default visibility
  783. case fcStatusBar: return StatusBar;
  784. case fcLocalStatusBar: return LocalStatusBar;
  785. case fcRemoteStatusBar: return RemoteStatusBar;
  786. case fcCommandLinePanel: return CommandLineToolbar;
  787. case fcLocalTree: return LocalDriveView;
  788. case fcSessionToolbar: return SessionToolbar;
  789. case fcCustomCommandsBand: return CustomCommandsToolbar;
  790. case fcColorMenu: return reinterpret_cast<TControl*>(ColorMenuItem);
  791. case fcTransferDropDown: return reinterpret_cast<TControl*>(TransferDropDown);
  792. case fcTransferList: return reinterpret_cast<TControl*>(TransferList);
  793. case fcTransferLabel: return reinterpret_cast<TControl*>(TransferLabel);
  794. case fcLocalPopup: return reinterpret_cast<TControl *>(NonVisualDataModule->LocalFilePopup);
  795. case fcRemotePathComboBox: return reinterpret_cast<TControl*>(RemotePathComboBox);
  796. case fcCommanderMenuBand: return MenuToolbar;
  797. case fcCommanderSessionBand: return SessionToolbar;
  798. case fcCommanderPreferencesBand: return PreferencesToolbar;
  799. case fcCommanderSortBand: return SortToolbar;
  800. case fcCommanderCommandsBand: return CommandsToolbar;
  801. case fcCommanderUpdatesBand: return UpdatesToolbar;
  802. case fcCommanderTransferBand: return TransferToolbar;
  803. case fcCommanderCustomCommandsBand: return CustomCommandsToolbar;
  804. case fcCommanderLocalHistoryBand: return LocalHistoryToolbar;
  805. case fcCommanderLocalNavigationBand: return LocalNavigationToolbar;
  806. case fcCommanderLocalFileBand: return LocalFileToolbar;
  807. case fcCommanderLocalSelectionBand: return LocalSelectionToolbar;
  808. case fcCommanderRemoteHistoryBand: return RemoteHistoryToolbar;
  809. case fcCommanderRemoteNavigationBand: return RemoteNavigationToolbar;
  810. case fcCommanderRemoteFileBand: return RemoteFileToolbar;
  811. case fcCommanderRemoteSelectionBand: return RemoteSelectionToolbar;
  812. default: return TCustomScpExplorerForm::GetComponent(Component);
  813. }
  814. }
  815. //---------------------------------------------------------------------------
  816. void __fastcall TScpCommanderForm::FixControlsPlacement()
  817. {
  818. TCustomScpExplorerForm::FixControlsPlacement();
  819. QueueSeparatorPanel->Visible = QueuePanel->Visible;
  820. LocalPanelSplitter->Visible = LocalDriveView->Visible;
  821. TControl * ControlsOrder[] =
  822. { BottomDock, QueueSeparatorPanel, QueueSplitter, QueuePanel, StatusBar };
  823. SetVerticalControlsOrder(ControlsOrder, LENOF(ControlsOrder));
  824. TControl * LocalControlsOrder[] =
  825. { LocalTopDock, LocalPathLabel, LocalDriveView, LocalPanelSplitter,
  826. LocalDirView, LocalBottomDock, LocalStatusBar };
  827. SetVerticalControlsOrder(LocalControlsOrder, LENOF(LocalControlsOrder));
  828. SetHorizontalControlsOrder(LocalControlsOrder, LENOF(LocalControlsOrder));
  829. TControl * RemoteControlsOrder[] =
  830. { RemoteTopDock, RemotePathLabel, RemoteDriveView, RemotePanelSplitter,
  831. RemoteDirView, RemoteBottomDock, RemoteStatusBar };
  832. SetVerticalControlsOrder(RemoteControlsOrder, LENOF(RemoteControlsOrder));
  833. SetHorizontalControlsOrder(RemoteControlsOrder, LENOF(RemoteControlsOrder));
  834. if (LocalDirView->ItemFocused != NULL)
  835. {
  836. LocalDirView->ItemFocused->MakeVisible(false);
  837. }
  838. }
  839. //---------------------------------------------------------------------------
  840. bool __fastcall TScpCommanderForm::GetHasDirView(TOperationSide Side)
  841. {
  842. return TCustomScpExplorerForm::GetHasDirView(Side) || (Side == osLocal);
  843. }
  844. //---------------------------------------------------------------------------
  845. void __fastcall TScpCommanderForm::CompareDirectories()
  846. {
  847. LocalDirView->CompareFiles(RemoteDirView, false,
  848. WinConfiguration->ScpCommander.CompareCriterias());
  849. RemoteDirView->CompareFiles(LocalDirView, false,
  850. WinConfiguration->ScpCommander.CompareCriterias());
  851. if (LocalDirView->SelCount + RemoteDirView->SelCount == 0)
  852. {
  853. MessageDialog(LoadStr(COMPARE_NO_DIFFERENCES), qtInformation, qaOK,
  854. HELP_COMPARE_NO_DIFFERENCES);
  855. }
  856. }
  857. //---------------------------------------------------------------------------
  858. void __fastcall TScpCommanderForm::SynchronizeDirectories()
  859. {
  860. UnicodeString LocalDirectory = LocalDirView->PathName;
  861. UnicodeString RemoteDirectory = RemoteDirView->PathName;
  862. DoSynchronizeDirectories(LocalDirectory, RemoteDirectory, false);
  863. }
  864. //---------------------------------------------------------------------------
  865. void __fastcall TScpCommanderForm::FullSynchronizeDirectories()
  866. {
  867. UnicodeString LocalDirectory = LocalDirView->PathName;
  868. UnicodeString RemoteDirectory = RemoteDirView->PathName;
  869. bool SaveMode = !(GUIConfiguration->SynchronizeModeAuto < 0);
  870. TSynchronizeMode Mode =
  871. (SaveMode ? (TSynchronizeMode)GUIConfiguration->SynchronizeModeAuto :
  872. ((FCurrentSide == osLocal) ? smRemote : smLocal));
  873. int Params = GUIConfiguration->SynchronizeParams;
  874. if (DoFullSynchronizeDirectories(LocalDirectory, RemoteDirectory, Mode, Params, SaveMode, false) >= 0)
  875. {
  876. if (SaveMode)
  877. {
  878. GUIConfiguration->SynchronizeModeAuto = Mode;
  879. }
  880. }
  881. }
  882. //---------------------------------------------------------------------------
  883. void __fastcall TScpCommanderForm::ExploreLocalDirectory()
  884. {
  885. OpenFolderInExplorer(LocalDirView->Path);
  886. }
  887. //---------------------------------------------------------------------------
  888. void __fastcall TScpCommanderForm::LocalDirViewExecFile(TObject *Sender,
  889. TListItem *Item, bool &AllowExec)
  890. {
  891. DebugAssert(Item);
  892. if ((UpperCase(PFileRec(Item->Data)->FileExt) == L"LNK") &&
  893. DirectoryExists(ApiPath(ResolveFileShortCut(LocalDirView->ItemFullFileName(Item), true))))
  894. {
  895. AllowExec = true;
  896. }
  897. else
  898. {
  899. DoDirViewExecFile(Sender, Item, AllowExec);
  900. }
  901. }
  902. //---------------------------------------------------------------------------
  903. void __fastcall TScpCommanderForm::LocalFileControlDDDragEnter(TObject *Sender,
  904. IDataObject *DataObj, int grfKeyState, TPoint &Point, int &dwEffect,
  905. bool &Accept)
  906. {
  907. // LocalDirViewDDDragEnter is duplication of
  908. // TCustomScpExplorerForm::DirViewDDDragEnter, but it differs in
  909. // literal type of 'DataObj' parameter.Actual type is however same
  910. FileControlDDDragEnter(Sender, DataObj, grfKeyState, Point, dwEffect, Accept);
  911. }
  912. //---------------------------------------------------------------------------
  913. bool __fastcall TScpCommanderForm::PanelOperation(TOperationSide Side,
  914. bool DragDrop)
  915. {
  916. return TCustomScpExplorerForm::PanelOperation(Side, DragDrop) ||
  917. (DropSourceControl == LocalDirView);
  918. }
  919. //---------------------------------------------------------------------------
  920. void __fastcall TScpCommanderForm::FileOperationProgress(
  921. TFileOperationProgressType & ProgressData)
  922. {
  923. // Heuristic: When operation finishes and DD targed is local dir view,
  924. // we suppose that drag&drop download finished, so local dir view should be
  925. // reloaded
  926. if (!ProgressData.InProgress && FProgressForm &&
  927. IsFileControl(FDDTargetControl, osLocal) &&
  928. ((ProgressData.Operation == ::foCopy) || (ProgressData.Operation == ::foMove)))
  929. {
  930. ReloadLocalDirectory();
  931. }
  932. TCustomScpExplorerForm::FileOperationProgress(ProgressData);
  933. }
  934. //---------------------------------------------------------------------------
  935. UnicodeString __fastcall TScpCommanderForm::ChangeFilePath(UnicodeString Path, TOperationSide Side)
  936. {
  937. TGUICopyParamType CopyParams = GUIConfiguration->CurrentCopyParam;
  938. UnicodeString Result;
  939. while (!Path.IsEmpty())
  940. {
  941. int P = Path.Pos(Side == osLocal ? L'\\' : L'/');
  942. if (P > 0)
  943. {
  944. Result += Terminal->ChangeFileName(&CopyParams, Path.SubString(1, P - 1), Side, false) +
  945. (Side == osLocal ? L'/' : L'\\');
  946. Path.Delete(1, P);
  947. }
  948. else
  949. {
  950. Result += Terminal->ChangeFileName(&CopyParams, Path, osLocal, false);
  951. Path = L"";
  952. }
  953. }
  954. return Result;
  955. }
  956. //---------------------------------------------------------------------------
  957. void __fastcall TScpCommanderForm::CreateRemoteDirectory(const UnicodeString & Path)
  958. {
  959. UnicodeString Dir = UnixExtractFileDir(Path);
  960. if (!IsUnixRootPath(Dir) && !Terminal->FileExists(Dir))
  961. {
  962. CreateRemoteDirectory(Dir);
  963. }
  964. TRemoteProperties Properties = GUIConfiguration->NewDirectoryProperties;
  965. TCustomScpExplorerForm::CreateRemoteDirectory(Path, Properties);
  966. }
  967. //---------------------------------------------------------------------------
  968. void __fastcall TScpCommanderForm::SynchronizeBrowsingLocal(
  969. UnicodeString PrevPath, UnicodeString & NewPath, bool Create)
  970. {
  971. Terminal->ExceptionOnFail = true;
  972. TStrings * Paths = new TStringList();
  973. try
  974. {
  975. Paths->Add(IncludeTrailingBackslash(PrevPath));
  976. Paths->Add(IncludeTrailingBackslash(LocalDirView->Path));
  977. UnicodeString CommonPath;
  978. if (ExtractCommonPath(Paths, CommonPath))
  979. {
  980. PrevPath = IncludeTrailingBackslash(PrevPath);
  981. CommonPath = IncludeTrailingBackslash(CommonPath);
  982. NewPath = RemoteDirView->Path;
  983. while (!SamePaths(PrevPath, CommonPath))
  984. {
  985. if (NewPath == UnixExcludeTrailingBackslash(NewPath))
  986. {
  987. Abort();
  988. }
  989. NewPath = UnixExtractFilePath(UnixExcludeTrailingBackslash(NewPath));
  990. PrevPath = ExtractFilePath(ExcludeTrailingBackslash(PrevPath));
  991. }
  992. NewPath = UnixIncludeTrailingBackslash(NewPath) +
  993. ToUnixPath(LocalDirView->Path.SubString(PrevPath.Length() + 1,
  994. LocalDirView->Path.Length() - PrevPath.Length()));
  995. }
  996. else
  997. {
  998. Abort();
  999. }
  1000. if (Create)
  1001. {
  1002. CreateRemoteDirectory(UnixExcludeTrailingBackslash(NewPath));
  1003. }
  1004. RemoteDirView->Path = NewPath;
  1005. }
  1006. __finally
  1007. {
  1008. Terminal->ExceptionOnFail = false;
  1009. delete Paths;
  1010. }
  1011. }
  1012. //---------------------------------------------------------------------------
  1013. void __fastcall TScpCommanderForm::CreateLocalDirectory(const UnicodeString & Path)
  1014. {
  1015. UnicodeString Dir = ExtractFileDir(Path);
  1016. if (!Dir.IsEmpty() && !DirectoryExists(Dir))
  1017. {
  1018. CreateLocalDirectory(Dir);
  1019. }
  1020. LocalDirView->CreateDirectory(Path);
  1021. }
  1022. //---------------------------------------------------------------------------
  1023. void __fastcall TScpCommanderForm::SynchronizeBrowsingRemote(
  1024. UnicodeString PrevPath, UnicodeString & NewPath, bool Create)
  1025. {
  1026. TStrings * Paths = new TStringList();
  1027. try
  1028. {
  1029. Paths->Add(UnixIncludeTrailingBackslash(PrevPath));
  1030. Paths->Add(UnixIncludeTrailingBackslash(RemoteDirView->Path));
  1031. UnicodeString CommonPath;
  1032. if (UnixExtractCommonPath(Paths, CommonPath))
  1033. {
  1034. PrevPath = UnixIncludeTrailingBackslash(PrevPath);
  1035. CommonPath = UnixIncludeTrailingBackslash(CommonPath);
  1036. UnicodeString NewLocalPath;
  1037. NewPath = ExcludeTrailingBackslash(LocalDirView->Path);
  1038. while (!UnixSamePath(PrevPath, CommonPath))
  1039. {
  1040. NewLocalPath = ExcludeTrailingBackslash(ExtractFileDir(NewPath));
  1041. if (NewLocalPath == NewPath)
  1042. {
  1043. Abort();
  1044. }
  1045. NewPath = NewLocalPath;
  1046. PrevPath = UnixExtractFilePath(UnixExcludeTrailingBackslash(PrevPath));
  1047. }
  1048. NewPath = IncludeTrailingBackslash(NewPath) +
  1049. ChangeFilePath(
  1050. RemoteDirView->Path.SubString(PrevPath.Length() + 1,
  1051. RemoteDirView->Path.Length() - PrevPath.Length()),
  1052. osRemote);
  1053. }
  1054. else
  1055. {
  1056. Abort();
  1057. }
  1058. }
  1059. __finally
  1060. {
  1061. delete Paths;
  1062. }
  1063. if (Create)
  1064. {
  1065. CreateLocalDirectory(ExcludeTrailingBackslash(NewPath));
  1066. }
  1067. LocalDirView->Path = NewPath;
  1068. }
  1069. //---------------------------------------------------------------------------
  1070. void __fastcall TScpCommanderForm::SynchronizeBrowsing(TCustomDirView * ADirView,
  1071. UnicodeString PrevPath, UnicodeString & NewPath, bool Create)
  1072. {
  1073. if (ADirView == LocalDirView)
  1074. {
  1075. SynchronizeBrowsingLocal(PrevPath, NewPath, Create);
  1076. }
  1077. else
  1078. {
  1079. SynchronizeBrowsingRemote(PrevPath, NewPath, Create);
  1080. }
  1081. }
  1082. //---------------------------------------------------------------------------
  1083. void __fastcall TScpCommanderForm::SynchronizeBrowsing(TCustomDirView * ADirView)
  1084. {
  1085. UnicodeString PrevPath;
  1086. // cannot assign to UnicodeString before the class is constructed,
  1087. // if we do, the value get lost when UnicodeString constructor gets finally called,
  1088. // what results in memory leak in the best case
  1089. if (FConstructed)
  1090. {
  1091. PrevPath = FPrevPath[ADirView == LocalDirView];
  1092. FPrevPath[ADirView == LocalDirView] = ADirView->Path;
  1093. }
  1094. if (!FSynchronisingBrowse && NonVisualDataModule->SynchronizeBrowsingAction->Checked &&
  1095. !PrevPath.IsEmpty() && PrevPath != ADirView->Path)
  1096. {
  1097. TValueRestorer<bool> AllowTransferPresetAutoSelectRestorer(FAllowTransferPresetAutoSelect);
  1098. FAllowTransferPresetAutoSelect = false;
  1099. TValueRestorer<bool> SynchronisingBrowseRestorer(FSynchronisingBrowse);
  1100. FSynchronisingBrowse = true;
  1101. try
  1102. {
  1103. UnicodeString NewPath;
  1104. bool Error = false;
  1105. std::unique_ptr<TStrings> ErrorMoreMessages;
  1106. UnicodeString ErrorHelpKeyword;
  1107. try
  1108. {
  1109. SynchronizeBrowsing(ADirView, PrevPath, NewPath, false);
  1110. }
  1111. // EAbort means that we do not know how to synchronize browsing
  1112. // there's no fallback scenario for that
  1113. catch(EAbort &)
  1114. {
  1115. throw;
  1116. }
  1117. catch(Exception & E)
  1118. {
  1119. // what does this say?
  1120. if (Application->Terminated)
  1121. {
  1122. throw;
  1123. }
  1124. else
  1125. {
  1126. Error = true;
  1127. ErrorMoreMessages.reset(ExceptionToMoreMessages(&E));
  1128. ErrorHelpKeyword =
  1129. MergeHelpKeyword(HELP_SYNC_DIR_BROWSE_ERROR, GetExceptionHelpKeyword(&E));
  1130. }
  1131. }
  1132. // this was moved here out of the above catch clause,
  1133. // to avoid deep nesting, what seems to cause some stray access violations
  1134. if (Error)
  1135. {
  1136. if (MoreMessageDialog(FMTLOAD(SYNC_DIR_BROWSE_CREATE2, (NewPath)),
  1137. ErrorMoreMessages.get(), qtConfirmation, qaYes | qaNo,
  1138. ErrorHelpKeyword) == qaYes)
  1139. {
  1140. try
  1141. {
  1142. SynchronizeBrowsing(ADirView, PrevPath, NewPath, true);
  1143. }
  1144. catch(Exception & E)
  1145. {
  1146. if (!Application->Terminated)
  1147. {
  1148. Terminal->ShowExtendedException(&E);
  1149. }
  1150. throw;
  1151. }
  1152. }
  1153. else
  1154. {
  1155. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  1156. }
  1157. }
  1158. }
  1159. catch(Exception & E)
  1160. {
  1161. NonVisualDataModule->SynchronizeBrowsingAction->Checked = false;
  1162. // what does this say?
  1163. if (Application->Terminated)
  1164. {
  1165. throw;
  1166. }
  1167. else
  1168. {
  1169. MessageDialog(LoadStr(SYNC_DIR_BROWSE_ERROR), qtInformation, qaOK,
  1170. HELP_SYNC_DIR_BROWSE_ERROR);
  1171. }
  1172. }
  1173. // note the value restorers at the beginning of this block
  1174. }
  1175. }
  1176. //---------------------------------------------------------------------------
  1177. void __fastcall TScpCommanderForm::DoDirViewLoaded(TCustomDirView * ADirView)
  1178. {
  1179. TCustomScpExplorerForm::DoDirViewLoaded(ADirView);
  1180. UpdateControls();
  1181. SynchronizeBrowsing(ADirView);
  1182. }
  1183. //---------------------------------------------------------------------------
  1184. void __fastcall TScpCommanderForm::AddEditLink(TOperationSide Side, bool Add)
  1185. {
  1186. if (GetSide(Side) == osLocal)
  1187. {
  1188. bool Edit = false;
  1189. UnicodeString FileName;
  1190. UnicodeString PointTo;
  1191. bool SymbolicLink = true;
  1192. if (LocalDirView->ItemFocused)
  1193. {
  1194. DebugAssert(LocalDirView->ItemFocused->Data);
  1195. PFileRec FileRec = (PFileRec)LocalDirView->ItemFocused->Data;
  1196. Edit = !Add && (UpperCase(FileRec->FileExt) == L"LNK");
  1197. if (Edit)
  1198. {
  1199. UnicodeString FullName = LocalDirView->ItemFullFileName(LocalDirView->ItemFocused);
  1200. FileName = FullName;
  1201. PointTo = ResolveFileShortCut(FullName, false);
  1202. if (PointTo.IsEmpty())
  1203. {
  1204. throw Exception(FMTLOAD(RESOLVE_SHORTCUT_ERROR, (FullName)));
  1205. }
  1206. }
  1207. else
  1208. {
  1209. PointTo = FileRec->FileName;
  1210. }
  1211. }
  1212. if (DoSymlinkDialog(FileName, PointTo, osLocal, SymbolicLink, Edit, false))
  1213. {
  1214. Configuration->Usage->Inc(L"LocalShortcutsCreated");
  1215. DebugAssert(SymbolicLink);
  1216. DebugAssert(!FileName.IsEmpty());
  1217. DebugAssert(!PointTo.IsEmpty());
  1218. if (ExtractFileDrive(FileName) == L"" && FileName[1] != L'\\')
  1219. {
  1220. FileName = IncludeTrailingBackslash(LocalDirView->PathName) + FileName;
  1221. }
  1222. if (ExtractFileDrive(PointTo) == L"" && PointTo[1] != L'\\')
  1223. {
  1224. PointTo = IncludeTrailingBackslash(LocalDirView->PathName) + PointTo;
  1225. }
  1226. if (ExtractFileExt(FileName) == L"")
  1227. {
  1228. FileName = FileName + L".lnk";
  1229. }
  1230. if (Edit)
  1231. {
  1232. DeleteFileChecked(FileName);
  1233. }
  1234. if (!CreateFileShortCut(PointTo, FileName, L""))
  1235. {
  1236. throw Exception(CREATE_SHORTCUT_ERROR);
  1237. }
  1238. }
  1239. }
  1240. else
  1241. {
  1242. TCustomScpExplorerForm::AddEditLink(Side, Add);
  1243. }
  1244. }
  1245. //---------------------------------------------------------------------------
  1246. void __fastcall TScpCommanderForm::DoOpenDirectoryDialog(TOpenDirectoryMode Mode,
  1247. TOperationSide Side)
  1248. {
  1249. bool UseLocationProfiles;
  1250. do
  1251. {
  1252. UseLocationProfiles = WinConfiguration->UseLocationProfiles;
  1253. // Location profiles dialog is not ready to be run without terminal
  1254. if (UseLocationProfiles && (Terminal != NULL))
  1255. {
  1256. TStrings * LocalDirectories = NULL;
  1257. TStrings * RemoteDirectories = NULL;
  1258. try
  1259. {
  1260. LocalDirectories = CreateVisitedDirectories(osLocal);
  1261. RemoteDirectories = CreateVisitedDirectories(osRemote);
  1262. UnicodeString Local = LocalDirView->PathName;
  1263. UnicodeString Remote = RemoteDirView->PathName;
  1264. if (LocationProfilesDialog(Mode, Side, Local, Remote, LocalDirectories,
  1265. RemoteDirectories, Terminal))
  1266. {
  1267. DoOpenBookmark(Local, Remote);
  1268. }
  1269. }
  1270. __finally
  1271. {
  1272. delete LocalDirectories;
  1273. delete RemoteDirectories;
  1274. }
  1275. }
  1276. else
  1277. {
  1278. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1279. TCustomScpExplorerForm::DoOpenDirectoryDialog(Mode, Side);
  1280. }
  1281. // for second and further rounds, always do browse only
  1282. Mode = odBrowse;
  1283. }
  1284. while (UseLocationProfiles != WinConfiguration->UseLocationProfiles);
  1285. }
  1286. //---------------------------------------------------------------------------
  1287. void __fastcall TScpCommanderForm::DoOpenBookmark(UnicodeString Local, UnicodeString Remote)
  1288. {
  1289. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1290. // make sure that whatever path is valid it is opened first and only
  1291. // after that an eventual error is reported
  1292. try
  1293. {
  1294. if (!Local.IsEmpty())
  1295. {
  1296. LocalDirView->Path = Local;
  1297. }
  1298. }
  1299. __finally
  1300. {
  1301. if (!Remote.IsEmpty())
  1302. {
  1303. // While we might get here when the session is closed (from location profiles),
  1304. // it's not a problem as the Path setter is noop then
  1305. RemoteDirView->Path = Remote;
  1306. }
  1307. }
  1308. }
  1309. //---------------------------------------------------------------------------
  1310. bool __fastcall TScpCommanderForm::OpenBookmark(TOperationSide Side, TBookmark * Bookmark)
  1311. {
  1312. bool Result;
  1313. if (WinConfiguration->UseLocationProfiles)
  1314. {
  1315. DoOpenBookmark(Bookmark->Local, Bookmark->Remote);
  1316. Result = true;
  1317. }
  1318. else
  1319. {
  1320. Result = TCustomScpExplorerForm::OpenBookmark(Side, Bookmark);
  1321. }
  1322. return Result;
  1323. }
  1324. //---------------------------------------------------------------------------
  1325. void __fastcall TScpCommanderForm::LocalDirViewDDTargetHasDropHandler(
  1326. TObject * /*Sender*/, TListItem * Item, int & /*Effect*/, bool & DropHandler)
  1327. {
  1328. // When drop target is not directory, it is probably file type, which have
  1329. // associated drop handler (such as EXE file). In this case we
  1330. // cannot allow drop when when using shellex,
  1331. // as drop handlers are disabled, so drop would error
  1332. // (see TShellExtension.DropHandler assignment in ConfigurationChanged),
  1333. if (WinConfiguration->DDFakeFile &&
  1334. !LocalDirView->ItemIsDirectory(Item))
  1335. {
  1336. DropHandler = false;
  1337. }
  1338. }
  1339. //---------------------------------------------------------------------------
  1340. bool __fastcall TScpCommanderForm::DDGetTarget(
  1341. UnicodeString & Directory, bool & ForceQueue, UnicodeString & CounterName)
  1342. {
  1343. bool Result;
  1344. if (!FDDFakeFileTarget.IsEmpty())
  1345. {
  1346. Directory = FDDFakeFileTarget;
  1347. FDDFakeFileTarget = L"";
  1348. Result = true;
  1349. CounterName = L"DownloadsDragDropInternal";
  1350. ForceQueue = false;
  1351. }
  1352. else
  1353. {
  1354. Result = TCustomScpExplorerForm::DDGetTarget(Directory, ForceQueue, CounterName);
  1355. }
  1356. return Result;
  1357. }
  1358. //---------------------------------------------------------------------------
  1359. void __fastcall TScpCommanderForm::DDFakeFileInitDrag(TFileList * FileList,
  1360. bool & Created)
  1361. {
  1362. FDDFakeFileTarget = L"";
  1363. TCustomScpExplorerForm::DDFakeFileInitDrag(FileList, Created);
  1364. }
  1365. //---------------------------------------------------------------------------
  1366. void __fastcall TScpCommanderForm::LocalFileControlDDFileOperation(
  1367. TObject * /*Sender*/, int dwEffect, UnicodeString SourcePath,
  1368. UnicodeString TargetPath, bool Paste, bool & DoOperation)
  1369. {
  1370. if (IsFileControl(DropSourceControl, osRemote))
  1371. {
  1372. UnicodeString TargetDirectory;
  1373. if (InternalDDDownload(TargetDirectory))
  1374. {
  1375. // See TCustomScpExplorerForm::QueueDDProcessDropped
  1376. if (FDDExtMapFile != NULL)
  1377. {
  1378. FDDFakeFileTarget = TargetDirectory;
  1379. }
  1380. else
  1381. {
  1382. DebugAssert(FInternalDDDownloadList->Count > 0);
  1383. DebugAssert(dwEffect == DROPEFFECT_Copy || dwEffect == DROPEFFECT_Move);
  1384. TGUICopyParamType CopyParams = GUIConfiguration->CurrentCopyParam;
  1385. TTransferType TransferType = dwEffect == DROPEFFECT_Copy ? ttCopy : ttMove;
  1386. int Options =
  1387. FLAGMASK(DraggingAllFilesFromDirView(osRemote, FInternalDDDownloadList), coAllFiles);
  1388. bool NoConfirmation = Paste ? false : (WinConfiguration->DDTransferConfirmation == asOff);
  1389. if (CopyParamDialog(tdToLocal, TransferType,
  1390. false, FInternalDDDownloadList, TargetDirectory, CopyParams, NoConfirmation, true, Options))
  1391. {
  1392. int Params =
  1393. (TransferType == ttMove ? cpDelete : 0);
  1394. DDDownload(FInternalDDDownloadList, TargetDirectory,
  1395. &CopyParams, Params);
  1396. Configuration->Usage->Inc(L"DownloadsDragDropInternal");
  1397. FInternalDDDownloadList->Clear();
  1398. }
  1399. }
  1400. DoOperation = false;
  1401. }
  1402. }
  1403. }
  1404. //---------------------------------------------------------------------------
  1405. void __fastcall TScpCommanderForm::RemoteFileControlDDFileOperationExecuted(
  1406. TObject * /*Sender*/, int dwEffect, UnicodeString /*SourcePath*/,
  1407. UnicodeString /*TargetPath*/)
  1408. {
  1409. if ((dwEffect == DROPEFFECT_Move) &&
  1410. IsFileControl(DropSourceControl, osLocal))
  1411. {
  1412. ReloadLocalDirectory();
  1413. }
  1414. }
  1415. //---------------------------------------------------------------------------
  1416. void __fastcall TScpCommanderForm::LocalDirViewEnter(TObject * /*Sender*/)
  1417. {
  1418. SideEnter(osLocal);
  1419. }
  1420. //---------------------------------------------------------------------------
  1421. void __fastcall TScpCommanderForm::LocalDriveViewEnter(TObject * /*Sender*/)
  1422. {
  1423. MakeNextInTabOrder(LocalDirView, LocalDriveView);
  1424. SideEnter(osLocal);
  1425. }
  1426. //---------------------------------------------------------------------------
  1427. void __fastcall TScpCommanderForm::SideEnter(TOperationSide Side)
  1428. {
  1429. if (Visible && (FCurrentSide != Side))
  1430. {
  1431. // this may get called yet before controls are initialized
  1432. CommandLineCombo->Strings->Clear();
  1433. FCommandLineComboPopulated = false;
  1434. }
  1435. TCustomScpExplorerForm::SideEnter(Side);
  1436. if (Visible)
  1437. {
  1438. UpdateControls();
  1439. UpdatePanelsPathLabelsStatus();
  1440. }
  1441. }
  1442. //---------------------------------------------------------------------------
  1443. void __fastcall TScpCommanderForm::UpdatePanelsPathLabelsStatus()
  1444. {
  1445. LocalPathLabel->UpdateStatus();
  1446. RemotePathLabel->UpdateStatus();
  1447. }
  1448. //---------------------------------------------------------------------------
  1449. void __fastcall TScpCommanderForm::OpenConsole(UnicodeString Command)
  1450. {
  1451. SaveCommandLine();
  1452. try
  1453. {
  1454. TCustomScpExplorerForm::OpenConsole(Command);
  1455. }
  1456. __finally
  1457. {
  1458. FCommandLineComboPopulated = false;
  1459. }
  1460. }
  1461. //---------------------------------------------------------------------------
  1462. void __fastcall TScpCommanderForm::SaveCommandLine()
  1463. {
  1464. if (FCommandLineComboPopulated)
  1465. {
  1466. CustomWinConfiguration->History[
  1467. FCurrentSide == osRemote ? L"Commands" : L"LocalCommands"] =
  1468. CommandLineCombo->Strings;
  1469. }
  1470. }
  1471. //---------------------------------------------------------------------------
  1472. bool __fastcall TScpCommanderForm::ExecuteCommandLine()
  1473. {
  1474. UnicodeString Command = CommandLineCombo->Text;
  1475. bool Result =
  1476. !NonVisualDataModule->Busy &&
  1477. !Command.IsEmpty() &&
  1478. ((FCurrentSide != osRemote) ||
  1479. (Terminal->AllowedAnyCommand(Command) &&
  1480. EnsureCommandSessionFallback(fcAnyCommand)));
  1481. if (Result)
  1482. {
  1483. CommandLinePopulate();
  1484. SaveToHistory(CommandLineCombo->Strings, Command);
  1485. CommandLineCombo->Text = L"";
  1486. if (FCurrentSide == osRemote)
  1487. {
  1488. OpenConsole(Command);
  1489. }
  1490. else
  1491. {
  1492. ExecuteShellChecked(Command);
  1493. }
  1494. }
  1495. return Result;
  1496. }
  1497. //---------------------------------------------------------------------------
  1498. void __fastcall TScpCommanderForm::CommandLinePopulate()
  1499. {
  1500. if (!FCommandLineComboPopulated)
  1501. {
  1502. TStrings * CommandsHistory;
  1503. CommandsHistory = CustomWinConfiguration->History[
  1504. FCurrentSide == osRemote ? L"Commands" : L"LocalCommands"];
  1505. if ((CommandsHistory != NULL) && (CommandsHistory->Count > 0))
  1506. {
  1507. CommandLineCombo->Strings = CommandsHistory;
  1508. }
  1509. else
  1510. {
  1511. CommandLineCombo->Strings->Clear();
  1512. }
  1513. FCommandLineComboPopulated = true;
  1514. }
  1515. }
  1516. //---------------------------------------------------------------------------
  1517. void __fastcall TScpCommanderForm::GoToCommandLine()
  1518. {
  1519. ComponentVisible[fcCommandLinePanel] = true;
  1520. if (CommandLineCombo->Enabled)
  1521. {
  1522. ClickToolbarItem(CommandLineCombo, true);
  1523. }
  1524. }
  1525. //---------------------------------------------------------------------------
  1526. void __fastcall TScpCommanderForm::GoToTree()
  1527. {
  1528. if (FCurrentSide == osLocal)
  1529. {
  1530. ComponentVisible[fcLocalTree] = true;
  1531. LocalDriveView->SetFocus();
  1532. }
  1533. else
  1534. {
  1535. TCustomScpExplorerForm::GoToTree();
  1536. }
  1537. }
  1538. //---------------------------------------------------------------------------
  1539. void __fastcall TScpCommanderForm::PanelExportStore(TOperationSide Side,
  1540. TPanelExport Export, TPanelExportDestination Destination,
  1541. TStrings * ExportData)
  1542. {
  1543. if (Destination == pedCommandLine)
  1544. {
  1545. ComponentVisible[fcCommandLinePanel] = true;
  1546. UnicodeString Buf;
  1547. for (int Index = 0; Index < ExportData->Count; Index++)
  1548. {
  1549. Buf += ExportData->Strings[Index] + L" ";
  1550. }
  1551. CommandLineCombo->Text = CommandLineCombo->Text + Buf;
  1552. }
  1553. else
  1554. {
  1555. TCustomScpExplorerForm::PanelExportStore(Side, Export, Destination, ExportData);
  1556. }
  1557. }
  1558. //---------------------------------------------------------------------------
  1559. int __fastcall TScpCommanderForm::GetStaticComponentsHeight()
  1560. {
  1561. return TCustomScpExplorerForm::GetStaticComponentsHeight() +
  1562. (BottomDock->Visible ? BottomDock->Height : 0) +
  1563. (QueueSeparatorPanel->Visible ? QueueSeparatorPanel->Height : 0) +
  1564. (StatusBar->Visible ? StatusBar->Height : 0);
  1565. }
  1566. //---------------------------------------------------------------------------
  1567. void __fastcall TScpCommanderForm::SysResizing(unsigned int Cmd)
  1568. {
  1569. TCustomScpExplorerForm::SysResizing(Cmd);
  1570. if ((Cmd == SC_MAXIMIZE) ||
  1571. ((Cmd == SC_DEFAULT) && (WindowState != wsMaximized)))
  1572. {
  1573. FNormalPanelsWidth = LocalPanel->Width + RemotePanel->Width;
  1574. }
  1575. else if ((Cmd == SC_RESTORE) ||
  1576. ((Cmd == SC_DEFAULT) && (WindowState == wsMaximized)))
  1577. {
  1578. if (FNormalPanelsWidth >= 0)
  1579. {
  1580. Panel(true)->Width = static_cast<int>(FLeftPanelWidth * FNormalPanelsWidth);
  1581. FNormalPanelsWidth = -1;
  1582. }
  1583. }
  1584. }
  1585. //---------------------------------------------------------------------------
  1586. void __fastcall TScpCommanderForm::Resize()
  1587. {
  1588. TCustomScpExplorerForm::Resize();
  1589. LeftPanelWidth = FLastLeftPanelWidth;
  1590. UpdateControls();
  1591. }
  1592. //---------------------------------------------------------------------------
  1593. void __fastcall TScpCommanderForm::PathLabelDblClick(TObject * Sender)
  1594. {
  1595. OpenDirectory(Sender == LocalPathLabel ? osLocal : osRemote);
  1596. }
  1597. //---------------------------------------------------------------------------
  1598. void __fastcall TScpCommanderForm::LocalPathLabelGetStatus(
  1599. TCustomPathLabel * /*Sender*/, bool & Active)
  1600. {
  1601. // WORKAROUND this strange form is here to make borland compiler work :-)
  1602. Active = Active || LocalDriveView->Focused();
  1603. }
  1604. //---------------------------------------------------------------------------
  1605. void __fastcall TScpCommanderForm::RemotePathLabelGetStatus(
  1606. TCustomPathLabel * /*Sender*/, bool & Active)
  1607. {
  1608. // WORKAROUND this strange form is here to make borland compiler work :-)
  1609. Active = Active || RemoteDriveView->Focused();
  1610. }
  1611. //---------------------------------------------------------------------------
  1612. void __fastcall TScpCommanderForm::LocalPathLabelPathClick(
  1613. TCustomPathLabel * /*Sender*/, UnicodeString Path)
  1614. {
  1615. if (SamePaths(Path, LocalDirView->Path))
  1616. {
  1617. OpenDirectory(osLocal);
  1618. }
  1619. else
  1620. {
  1621. LocalDirView->Path = Path;
  1622. }
  1623. }
  1624. //---------------------------------------------------------------------------
  1625. void __fastcall TScpCommanderForm::RemotePathLabelPathClick(
  1626. TCustomPathLabel * /*Sender*/, UnicodeString Path)
  1627. {
  1628. if (UnixSamePath(Path, RemoteDirView->Path))
  1629. {
  1630. OpenDirectory(osRemote);
  1631. }
  1632. else
  1633. {
  1634. RemoteDirView->Path = Path;
  1635. }
  1636. }
  1637. //---------------------------------------------------------------------------
  1638. void __fastcall TScpCommanderForm::LocalDirViewFileIconForName(
  1639. TObject * /*Sender*/, TListItem * /*Item*/, UnicodeString & FileName)
  1640. {
  1641. UnicodeString PartialExt = Configuration->PartialExt;
  1642. if (AnsiSameText(ExtractFileExt(FileName), PartialExt))
  1643. {
  1644. FileName.SetLength(FileName.Length() - PartialExt.Length());
  1645. }
  1646. if (WinConfiguration->LocalIconsByExt)
  1647. {
  1648. FileName = ExtractFileName(FileName);
  1649. }
  1650. }
  1651. //---------------------------------------------------------------------------
  1652. void __fastcall TScpCommanderForm::LocalDirViewUpdateStatusBar(
  1653. TObject * /*Sender*/, const TStatusFileInfo & FileInfo)
  1654. {
  1655. UpdateFileStatusBar(LocalStatusBar, FileInfo, osLocal);
  1656. }
  1657. //---------------------------------------------------------------------------
  1658. void __fastcall TScpCommanderForm::RemoteDirViewUpdateStatusBar(
  1659. TObject * /*Sender*/, const TStatusFileInfo & FileInfo)
  1660. {
  1661. UpdateFileStatusBar(RemoteStatusBar, FileInfo, osRemote);
  1662. }
  1663. //---------------------------------------------------------------------------
  1664. void __fastcall TScpCommanderForm::LocalStatusBarClick(TObject * /*Sender*/)
  1665. {
  1666. LocalDirView->SetFocus();
  1667. }
  1668. //---------------------------------------------------------------------------
  1669. UnicodeString __fastcall TScpCommanderForm::PathForCaption()
  1670. {
  1671. UnicodeString Result;
  1672. if (FCurrentSide == osLocal)
  1673. {
  1674. // for consistency do not show even local path when there is no terminal
  1675. if (Terminal != NULL)
  1676. {
  1677. switch (WinConfiguration->PathInCaption)
  1678. {
  1679. case picShort:
  1680. {
  1681. Result = ExtractFileName(LocalDirView->PathName);
  1682. if (Result.IsEmpty())
  1683. {
  1684. Result = LocalDirView->PathName;
  1685. }
  1686. }
  1687. break;
  1688. case picFull:
  1689. Result = LocalDirView->PathName;
  1690. break;
  1691. }
  1692. }
  1693. }
  1694. else
  1695. {
  1696. Result = TCustomScpExplorerForm::PathForCaption();
  1697. }
  1698. return Result;
  1699. }
  1700. //---------------------------------------------------------------------------
  1701. void __fastcall TScpCommanderForm::GetTransferPresetAutoSelectData(
  1702. TCopyParamRuleData & Data)
  1703. {
  1704. TCustomScpExplorerForm::GetTransferPresetAutoSelectData(Data);
  1705. Data.LocalDirectory = LocalDirView->PathName;
  1706. }
  1707. //---------------------------------------------------------------------------
  1708. void __fastcall TScpCommanderForm::BeforeAction()
  1709. {
  1710. TCustomScpExplorerForm::BeforeAction();
  1711. if (LocalDirView->ItemFocused != NULL)
  1712. {
  1713. LocalDirView->ItemFocused->CancelEdit();
  1714. }
  1715. }
  1716. //---------------------------------------------------------------------------
  1717. void __fastcall TScpCommanderForm::RemoteDirViewPathChange(TCustomDirView * /*Sender*/)
  1718. {
  1719. UpdateRemotePathComboBox(false);
  1720. ResetIncrementalSearch();
  1721. }
  1722. //---------------------------------------------------------------------------
  1723. void __fastcall TScpCommanderForm::UpdateImages()
  1724. {
  1725. TCustomScpExplorerForm::UpdateImages();
  1726. TImageList * ImageList = ShellImageListForControl(this, ilsSmall);
  1727. RemotePathComboBox->Images = ImageList;
  1728. RemotePathComboBox->SubMenuImages = ImageList;
  1729. LocalPathComboBox->Images = ImageList;
  1730. LocalPathComboBox->SubMenuImages = ImageList;
  1731. }
  1732. //---------------------------------------------------------------------------
  1733. void __fastcall TScpCommanderForm::LocalPathComboUpdateDrives()
  1734. {
  1735. FLocalSpecialPaths = 0;
  1736. TStrings* Strings = LocalPathComboBox->Strings;
  1737. Strings->BeginUpdate();
  1738. try
  1739. {
  1740. Strings->Clear();
  1741. FLocalPathComboBoxPaths->Clear();
  1742. Strings->Add(LoadStr(SPECIAL_FOLDER_MY_DOCUMENTS));
  1743. FLocalPathComboBoxPaths->AddObject(GetPersonalFolder(),
  1744. (TObject *)DriveInfo->SpecialFolder[CSIDL_PERSONAL]->ImageIndex);
  1745. FLocalSpecialPaths++;
  1746. Strings->Add(LoadStr(SPECIAL_FOLDER_DESKTOP));
  1747. FLocalPathComboBoxPaths->AddObject(GetDesktopFolder(),
  1748. (TObject *)DriveInfo->SpecialFolder[CSIDL_DESKTOP]->ImageIndex);
  1749. FLocalSpecialPaths++;
  1750. std::unique_ptr<TStrings> Drives(LocalDriveView->GetDrives());
  1751. for (int Index = 0; Index < Drives->Count; Index++)
  1752. {
  1753. UnicodeString Drive = Drives->Strings[Index];
  1754. if (DriveInfo->Get(Drive)->Valid)
  1755. {
  1756. UnicodeString Caption = DriveInfo->GetPrettyName(Drive);
  1757. if (DriveInfo->IsRealDrive(Drive))
  1758. {
  1759. Caption.Insert(L"&", 0);
  1760. }
  1761. Strings->Add(Caption);
  1762. UnicodeString RootPath = DriveInfo->GetDriveRoot(Drive);
  1763. int ImageIndex = DriveInfo->GetImageIndex(Drive);
  1764. FLocalPathComboBoxPaths->AddObject(RootPath, reinterpret_cast<TObject *>(ImageIndex));
  1765. }
  1766. }
  1767. }
  1768. __finally
  1769. {
  1770. Strings->EndUpdate();
  1771. }
  1772. }
  1773. //---------------------------------------------------------------------------
  1774. void __fastcall TScpCommanderForm::LocalPathComboUpdate()
  1775. {
  1776. // this may get called even after destructor finishes
  1777. // (e.g. from SetDockAllowDrag invoked [indirectly] from StoreParams)
  1778. if (FLocalPathComboBoxPaths != NULL)
  1779. {
  1780. DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
  1781. int Index = 0;
  1782. while ((Index < FLocalPathComboBoxPaths->Count) &&
  1783. !SamePaths(FLocalPathComboBoxPaths->Strings[Index],
  1784. LocalDirView->Path.SubString(1, FLocalPathComboBoxPaths->Strings[Index].Length())))
  1785. {
  1786. Index++;
  1787. }
  1788. // what to do if not?
  1789. if (Index < FLocalPathComboBoxPaths->Count)
  1790. {
  1791. LocalPathComboBox->ItemIndex = Index;
  1792. }
  1793. }
  1794. }
  1795. //---------------------------------------------------------------------------
  1796. void __fastcall TScpCommanderForm::LocalDirViewPathChange(TCustomDirView * /*Sender*/)
  1797. {
  1798. LocalPathComboUpdate();
  1799. ResetIncrementalSearch();
  1800. if (IsUncPath(LocalDirView->Path))
  1801. {
  1802. Configuration->Usage->Inc(L"BrowsedUncPath");
  1803. }
  1804. }
  1805. //---------------------------------------------------------------------------
  1806. void __fastcall TScpCommanderForm::LocalPathComboBoxCancel(TObject * /*Sender*/)
  1807. {
  1808. LocalPathComboUpdate();
  1809. }
  1810. //---------------------------------------------------------------------------
  1811. void __fastcall TScpCommanderForm::LocalPathComboBoxAdjustImageIndex(
  1812. TTBXComboBoxItem * /*Sender*/, const UnicodeString AText, int AIndex,
  1813. int & ImageIndex)
  1814. {
  1815. // this may get called even before constructor starts
  1816. // (e.g. from FixControlsPlacement)
  1817. if (FLocalPathComboBoxPaths != NULL)
  1818. {
  1819. DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
  1820. DebugAssert(AIndex < FLocalPathComboBoxPaths->Count);
  1821. if (AIndex < 0)
  1822. {
  1823. AIndex = LocalPathComboBox->ItemIndex;
  1824. }
  1825. if (AIndex >= 0)
  1826. {
  1827. ImageIndex = int(FLocalPathComboBoxPaths->Objects[AIndex]);
  1828. }
  1829. }
  1830. }
  1831. //---------------------------------------------------------------------------
  1832. void __fastcall TScpCommanderForm::LocalPathComboBoxItemClick(TObject * /*Sender*/)
  1833. {
  1834. DebugAssert(FLocalPathComboBoxPaths->Count == LocalPathComboBox->Strings->Count);
  1835. DebugAssert((LocalPathComboBox->ItemIndex >= 0) && (LocalPathComboBox->ItemIndex < FLocalPathComboBoxPaths->Count));
  1836. UnicodeString Path = FLocalPathComboBoxPaths->Strings[LocalPathComboBox->ItemIndex];
  1837. if (LocalPathComboBox->ItemIndex >= FLocalSpecialPaths)
  1838. {
  1839. LocalDirView->ExecuteDrive(DriveInfo->GetDriveKey(Path));
  1840. }
  1841. else
  1842. {
  1843. LocalDirView->Path = Path;
  1844. }
  1845. }
  1846. //---------------------------------------------------------------------------
  1847. void __fastcall TScpCommanderForm::ToolbarItemResize(TTBXCustomDropDownItem * Item, int Width)
  1848. {
  1849. TCustomScpExplorerForm::ToolbarItemResize(Item, Width);
  1850. if ((Item == LocalPathComboBox) ||
  1851. (Item == RemotePathComboBox) ||
  1852. (Item == CommandLineCombo))
  1853. {
  1854. dynamic_cast<TTBXComboBoxItem *>(Item)->MinListWidth = Width - 4;
  1855. }
  1856. }
  1857. //---------------------------------------------------------------------------
  1858. void __fastcall TScpCommanderForm::CommandLineComboPopup(
  1859. TTBCustomItem * /*Sender*/, bool /*FromLink*/)
  1860. {
  1861. CommandLinePopulate();
  1862. }
  1863. //---------------------------------------------------------------------------
  1864. void __fastcall TScpCommanderForm::CommandLineComboBeginEdit(
  1865. TTBEditItem * /*Sender*/, TTBEditItemViewer * /*Viewer*/, TEdit *EditControl)
  1866. {
  1867. InstallPathWordBreakProc(EditControl);
  1868. FCommandLineComboEdit = EditControl;
  1869. FToolbarEditOldWndProc = EditControl->WindowProc;
  1870. EditControl->WindowProc = CommandLineComboEditWndProc;
  1871. }
  1872. //---------------------------------------------------------------------------
  1873. void __fastcall TScpCommanderForm::ExitToolbar()
  1874. {
  1875. CurrentPanel()->SetFocus();
  1876. }
  1877. //---------------------------------------------------------------------------
  1878. void __fastcall TScpCommanderForm::CommandLineComboEditWndProc(TMessage & Message)
  1879. {
  1880. bool Handled = false;
  1881. if (Message.Msg == WM_CHAR)
  1882. {
  1883. switch (reinterpret_cast<TWMChar &>(Message).CharCode)
  1884. {
  1885. case VK_ESCAPE:
  1886. CommandLineCombo->Text = L"";
  1887. ExitToolbar();
  1888. Handled = true;
  1889. break;
  1890. case VK_TAB:
  1891. CommandLineCombo->Text = FCommandLineComboEdit->Text;
  1892. ExitToolbar();
  1893. Handled = true;
  1894. break;
  1895. case VK_RETURN:
  1896. CommandLineCombo->Text = FCommandLineComboEdit->Text;
  1897. ExitToolbar();
  1898. if (!ExecuteCommandLine())
  1899. {
  1900. // re-enter command line
  1901. // (most probably exited by now as message dialog was shown)
  1902. GoToCommandLine();
  1903. }
  1904. Handled = true;
  1905. break;
  1906. }
  1907. }
  1908. if (!Handled)
  1909. {
  1910. FToolbarEditOldWndProc(Message);
  1911. }
  1912. }
  1913. //---------------------------------------------------------------------------
  1914. void __fastcall TScpCommanderForm::LocalDriveViewRefreshDrives(TObject * /*Sender*/)
  1915. {
  1916. LocalPathComboUpdateDrives();
  1917. LocalPathComboUpdate();
  1918. }
  1919. //---------------------------------------------------------------------------
  1920. void __fastcall TScpCommanderForm::HomeDirectory(TOperationSide Side)
  1921. {
  1922. bool SynchronizeBrowsing = NonVisualDataModule->SynchronizeBrowsingAction->Checked;
  1923. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1924. TCustomScpExplorerForm::HomeDirectory(Side);
  1925. if (SynchronizeBrowsing)
  1926. {
  1927. TCustomScpExplorerForm::HomeDirectory(GetOtherSize(Side));
  1928. }
  1929. }
  1930. //---------------------------------------------------------------------------
  1931. void __fastcall TScpCommanderForm::QueueSubmenuItemPopup(
  1932. TTBCustomItem * /*Sender*/, bool /*FromLink*/)
  1933. {
  1934. NonVisualDataModule->QueueSpeedComboBoxItemUpdate(QueueSpeedComboBoxItem);
  1935. }
  1936. //---------------------------------------------------------------------------
  1937. void __fastcall TScpCommanderForm::DoFocusRemotePath(TTerminal * Terminal, const UnicodeString & Path)
  1938. {
  1939. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1940. TCustomScpExplorerForm::DoFocusRemotePath(Terminal, Path);
  1941. }
  1942. //---------------------------------------------------------------------------
  1943. TOperationSide __fastcall TScpCommanderForm::GetOtherSize(TOperationSide Side)
  1944. {
  1945. Side = GetSide(Side);
  1946. return ReverseOperationSide(Side);
  1947. }
  1948. //---------------------------------------------------------------------------
  1949. void __fastcall TScpCommanderForm::HistoryGo(TOperationSide Side, int Index)
  1950. {
  1951. TOperationSide OtherSide = GetOtherSize(Side);
  1952. if (NonVisualDataModule->SynchronizeBrowsingAction->Checked &&
  1953. ((Index < 0) ? (-Index < DirView(OtherSide)->BackCount) : (Index < DirView(OtherSide)->ForwardCount)))
  1954. {
  1955. TSynchronizedBrowsingGuard SynchronizedBrowsingGuard;
  1956. TCustomScpExplorerForm::HistoryGo(Side, Index);
  1957. TCustomScpExplorerForm::HistoryGo(OtherSide, Index);
  1958. }
  1959. else
  1960. {
  1961. TCustomScpExplorerForm::HistoryGo(Side, Index);
  1962. }
  1963. }
  1964. //---------------------------------------------------------------------------
  1965. void __fastcall TScpCommanderForm::DirViewHistoryGo(
  1966. TCustomDirView * Sender, int Index, bool & Cancel)
  1967. {
  1968. TOperationSide Side = (Sender == DirView(osRemote) ? osRemote : osLocal);
  1969. HistoryGo(Side, Index);
  1970. Cancel = true;
  1971. }
  1972. //---------------------------------------------------------------------------
  1973. bool __fastcall TScpCommanderForm::EligibleForImageDisplayMode(TTBCustomItem * Item)
  1974. {
  1975. return
  1976. TCustomScpExplorerForm::EligibleForImageDisplayMode(Item) &&
  1977. ((Item->Parent == NULL) || (Item->Parent->ParentComponent != Toolbar2Toolbar));
  1978. }
  1979. //---------------------------------------------------------------------------
  1980. bool __fastcall TScpCommanderForm::UpdateToolbarDisplayMode()
  1981. {
  1982. bool Result = TCustomScpExplorerForm::UpdateToolbarDisplayMode();
  1983. if (Result)
  1984. {
  1985. // command line combo width needs to be updated as caption visibility has changed
  1986. ToolBarResize(CommandLineToolbar);
  1987. }
  1988. return Result;
  1989. }
  1990. //---------------------------------------------------------------------------
  1991. void __fastcall TScpCommanderForm::QueueLabelUpdateStatus()
  1992. {
  1993. TCustomScpExplorerForm::QueueLabelUpdateStatus();
  1994. // this is here to deactivate panels path labels when moving focus from
  1995. // directory tree to queue
  1996. UpdatePanelsPathLabelsStatus();
  1997. }
  1998. //---------------------------------------------------------------------------
  1999. void __fastcall TScpCommanderForm::LocalDirViewContextPopup(TObject * /*Sender*/,
  2000. TPoint & MousePos, bool & Handled)
  2001. {
  2002. if (!WinConfiguration->ScpCommander.SystemContextMenu && !FForceSystemContextMenu)
  2003. {
  2004. DirViewContextPopupDefaultItem(osLocal, NonVisualDataModule->LocalOpenMenuItem, dcaOpen);
  2005. DirViewContextPopupDefaultItem(osLocal, NonVisualDataModule->LocalEditMenuItem, dcaEdit);
  2006. DirViewContextPopupDefaultItem(osLocal, NonVisualDataModule->LocalCopyMenuItem, dcaCopy);
  2007. DirViewContextPopup(osLocal, fcLocalPopup, MousePos);
  2008. Handled = true;
  2009. }
  2010. }
  2011. //---------------------------------------------------------------------------
  2012. void __fastcall TScpCommanderForm::DisplaySystemContextMenu()
  2013. {
  2014. TAutoFlag Flag(FForceSystemContextMenu);
  2015. if ((FLastContextPopupScreenPoint.x >= 0) && (FLastContextPopupScreenPoint.Y >= 0))
  2016. {
  2017. LocalDirView->DisplayContextMenu(FLastContextPopupScreenPoint);
  2018. }
  2019. else
  2020. {
  2021. LocalDirView->DisplayContextMenuInSitu();
  2022. }
  2023. }
  2024. //---------------------------------------------------------------------------
  2025. void __fastcall TScpCommanderForm::LocalStatusBarPanelClick(TTBXCustomStatusBar * /*Sender*/,
  2026. TTBXStatusPanel * Panel)
  2027. {
  2028. FileStatusBarPanelClick(Panel, osLocal);
  2029. }
  2030. //---------------------------------------------------------------------------
  2031. void __fastcall TScpCommanderForm::RemoteStatusBarPanelClick(TTBXCustomStatusBar * /*Sender*/,
  2032. TTBXStatusPanel *Panel)
  2033. {
  2034. FileStatusBarPanelClick(Panel, osRemote);
  2035. }
  2036. //---------------------------------------------------------------------------
  2037. void __fastcall TScpCommanderForm::GoToAddress()
  2038. {
  2039. OpenDirectory(GetSide(osCurrent));
  2040. }
  2041. //---------------------------------------------------------------------------
  2042. void __fastcall TScpCommanderForm::RemotePathLabelMaskClick(TObject * /*Sender*/)
  2043. {
  2044. Filter(osRemote);
  2045. }
  2046. //---------------------------------------------------------------------------
  2047. void __fastcall TScpCommanderForm::LocalPathLabelMaskClick(TObject * /*Sender*/)
  2048. {
  2049. Filter(osLocal);
  2050. }
  2051. //---------------------------------------------------------------------------
  2052. void __fastcall TScpCommanderForm::LocalOpenDirButtonPopup(TTBCustomItem * /*Sender*/, bool /*FromLink*/)
  2053. {
  2054. CreateOpenDirMenu(LocalOpenDirButton, osLocal);
  2055. }
  2056. //---------------------------------------------------------------------------
  2057. void __fastcall TScpCommanderForm::RemoteOpenDirButtonPopup(TTBCustomItem * /*Sender*/, bool /*FromLink*/)
  2058. {
  2059. CreateOpenDirMenu(RemoteOpenDirButton, osRemote);
  2060. }
  2061. //---------------------------------------------------------------------------
  2062. void __fastcall TScpCommanderForm::CopyFilesToClipboard(TOperationSide Side)
  2063. {
  2064. if (GetSide(Side) == osLocal)
  2065. {
  2066. TInstantOperationVisualizer Visualizer;
  2067. LocalDirView->CopyToClipBoard();
  2068. }
  2069. else
  2070. {
  2071. TCustomScpExplorerForm::CopyFilesToClipboard(Side);
  2072. }
  2073. }
  2074. //---------------------------------------------------------------------------
  2075. void __fastcall TScpCommanderForm::PasteFromClipBoard()
  2076. {
  2077. if (DoesClipboardContainOurFiles() && (GetSide(osCurrent) == osLocal))
  2078. {
  2079. if (DebugAlwaysTrue(CanPasteToDirViewFromClipBoard()))
  2080. {
  2081. ClipboardDownload(LocalDirView->Path, !WinConfiguration->ConfirmTransferring, false);
  2082. }
  2083. }
  2084. else
  2085. {
  2086. TCustomScpExplorerForm::PasteFromClipBoard();
  2087. }
  2088. }
  2089. //---------------------------------------------------------------------------
  2090. void __fastcall TScpCommanderForm::FileColorsChanged()
  2091. {
  2092. TCustomScpExplorerForm::FileColorsChanged();
  2093. DoFileColorsChanged(LocalDirView);
  2094. }
  2095. //---------------------------------------------------------------------------