ScpCommander.cpp 76 KB

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