ScpCommander.cpp 75 KB

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