1
0

ScpCommander.cpp 74 KB

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