ScpCommander.cpp 75 KB

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