ScpCommander.cpp 75 KB

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