NonVisual.cpp 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include "NonVisual.h"
  6. #include <CoreMain.h>
  7. #include <TextsWin.h>
  8. #include <Tools.h>
  9. #include <Setup.h>
  10. #include <Interface.h>
  11. #include "WinConfiguration.h"
  12. #include "TerminalManager.h"
  13. #include "TBX.hpp"
  14. #include "VCLCommon.h"
  15. #include <HistoryComboBox.hpp>
  16. //---------------------------------------------------------------------------
  17. #pragma package(smart_init)
  18. #pragma link "TB2Item"
  19. #pragma link "TBX"
  20. #pragma link "TB2ExtItems"
  21. #pragma link "TBXExtItems"
  22. #pragma link "TBXToolPals"
  23. #pragma resource "*.dfm"
  24. TNonVisualDataModule *NonVisualDataModule;
  25. //---------------------------------------------------------------------------
  26. #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
  27. #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
  28. ((TCustomAction *)Action)->Enabled = (Condition); \
  29. if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
  30. Handled = true; } else
  31. #define UPDEX1(HandleAction, Condition, Other) UPDEX(HandleAction, Condition, Other, Other)
  32. #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
  33. ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
  34. #define UPDFUNC(HandleAction, Function) if (Action == HandleAction) { Function; Handled = true; } else
  35. #define EXE(HandleAction, Command) if (Action == HandleAction) { \
  36. Command; Handled = true; } else
  37. #define UPDACT(HandleAction, Command) \
  38. EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
  39. #define UPDCOMP2(COMP, NUM) if (Action == COMP ## Action ## NUM) { COMP ## Action ## NUM->Enabled = true; \
  40. COMP ## Action ## NUM->Visible = ScpExplorer->IsComponentPossible(fc ## COMP); \
  41. COMP ## Action ## NUM->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
  42. #define UPDCOMP(COMP) UPDCOMP2(COMP, )
  43. #define EXECOMP2(COMP, NUM) EXE(COMP ## Action ## NUM, \
  44. ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
  45. #define EXECOMP(COMP) EXECOMP2(COMP, )
  46. #define COLPROPS(SIDE) \
  47. ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
  48. #define UPDSORT(SIDE, NAME, LCOL, RCOL, NUM) \
  49. UPDEX(SIDE ## SortBy ## NAME ## Action ## NUM, (AuxInt = (ScpExplorer->IsSideLocalBrowser(os ## SIDE) ? LCOL : RCOL)) >= 0, \
  50. Action->Checked = (COLPROPS(SIDE)->SortColumn == AuxInt), \
  51. Action->Checked = false \
  52. )
  53. #define EXESORT(SIDE, NAME, LCOL, RCOL, NUM) \
  54. EXE(SIDE ## SortBy ## NAME ## Action ## NUM, \
  55. int Col = (ScpExplorer->IsSideLocalBrowser(os ## SIDE) ? LCOL : RCOL); \
  56. if (COLPROPS(SIDE)->SortColumn == Col) \
  57. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
  58. else \
  59. COLPROPS(SIDE)->SortColumn = Col; \
  60. )
  61. #define UPDSORTA(SIDE, NUM) if (Action == SIDE ## SortAscendingAction ## NUM) { \
  62. SIDE ## SortAscendingAction ## NUM->Enabled = true; Handled = true; \
  63. SIDE ## SortAscendingAction ## NUM->Checked = COLPROPS(SIDE)->SortAscending; } else
  64. #define EXESORTA(SIDE, NUM) EXE(SIDE ## SortAscendingAction ## NUM, \
  65. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
  66. #define UPDSHCOL(SIDE, NAME, LCOL, RCOL) \
  67. UPDFUNC(ShowHide ## SIDE ## NAME ## ColumnAction2, \
  68. int Col = (ScpExplorer->IsSideLocalBrowser(os ## SIDE) ? LCOL : RCOL); \
  69. Action->Enabled = (Col >= 0); \
  70. Action->Checked = Action->Enabled && COLPROPS(SIDE)->Visible[Col]; \
  71. )
  72. #define EXESHCOL(SIDE, NAME, LCOL, RCOL) \
  73. EXE(ShowHide ## SIDE ## NAME ## ColumnAction2, \
  74. int Col = (ScpExplorer->IsSideLocalBrowser(os ## SIDE) ? LCOL : RCOL); \
  75. COLPROPS(SIDE)->Visible[Col] = !COLPROPS(SIDE)->Visible[Col])
  76. #define BAND_COMPONENTS \
  77. EMIT_BAND_COMPONENT(ExplorerMenuBand) \
  78. EMIT_BAND_COMPONENT(ExplorerAddressBand) \
  79. EMIT_BAND_COMPONENT(ExplorerToolbarBand) \
  80. EMIT_BAND_COMPONENT(ExplorerSelectionBand) \
  81. EMIT_BAND_COMPONENT(ExplorerSessionBand) \
  82. EMIT_BAND_COMPONENT(ExplorerPreferencesBand) \
  83. EMIT_BAND_COMPONENT(ExplorerSortBand) \
  84. EMIT_BAND_COMPONENT(ExplorerUpdatesBand) \
  85. EMIT_BAND_COMPONENT(ExplorerTransferBand) \
  86. EMIT_BAND_COMPONENT(ExplorerCustomCommandsBand) \
  87. EMIT_BAND_COMPONENT(CommanderMenuBand) \
  88. EMIT_BAND_COMPONENT(CommanderSessionBand) \
  89. EMIT_BAND_COMPONENT(CommanderPreferencesBand) \
  90. EMIT_BAND_COMPONENT(CommanderSortBand) \
  91. EMIT_BAND_COMPONENT(CommanderCommandsBand) \
  92. EMIT_BAND_COMPONENT(CommanderUpdatesBand) \
  93. EMIT_BAND_COMPONENT(CommanderTransferBand) \
  94. EMIT_BAND_COMPONENT(CommanderCustomCommandsBand) \
  95. EMIT_BAND_COMPONENT2(CommanderLocalHistoryBand, 2) \
  96. EMIT_BAND_COMPONENT2(CommanderLocalNavigationBand, 2) \
  97. EMIT_BAND_COMPONENT2(CommanderLocalFileBand, 2) \
  98. EMIT_BAND_COMPONENT2(CommanderLocalSelectionBand, 2) \
  99. EMIT_BAND_COMPONENT2(CommanderRemoteHistoryBand, 2) \
  100. EMIT_BAND_COMPONENT2(CommanderRemoteNavigationBand, 2) \
  101. EMIT_BAND_COMPONENT2(CommanderRemoteFileBand, 2) \
  102. EMIT_BAND_COMPONENT2(CommanderRemoteSelectionBand, 2)
  103. #define EMIT_BAND_COMPONENT(COMP) EMIT_BAND_COMPONENT2(COMP, )
  104. //---------------------------------------------------------------------------
  105. __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
  106. : TDataModule(Owner)
  107. {
  108. FListColumn = NULL;
  109. FSessionIdleTimerExecuting = false;
  110. FCustomizedToolbar = NULL;
  111. FBusy = 0;
  112. QueueSpeedComboBoxItem(QueuePopupSpeedComboBoxItem);
  113. FRemoteRootDirImageIndex = RemoteRootDirAction->ImageIndex;
  114. }
  115. //---------------------------------------------------------------------------
  116. __fastcall TNonVisualDataModule::~TNonVisualDataModule()
  117. {
  118. }
  119. //---------------------------------------------------------------------------
  120. void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
  121. TBasicAction * BasicAction, bool & Handled)
  122. {
  123. TAction * Action = DebugNotNull(dynamic_cast<TAction *>(BasicAction));
  124. if (!ScpExplorer || !ScpExplorer->AllowedAction(Action, aaUpdate))
  125. {
  126. Action->Enabled = false;
  127. Handled = true;
  128. return;
  129. }
  130. void * AuxVoidPtr;
  131. int AuxInt;
  132. #define HasTerminal ScpExplorer->HasActiveTerminal()
  133. // CURRENT DIRVIEW
  134. #define EnabledSelectedOperation (ScpExplorer->EnableSelectedOperation[osCurrent])
  135. #define EnabledFocusedOperation (ScpExplorer->EnableFocusedOperation[osCurrent])
  136. #define EnabledSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osCurrent])
  137. #define EnabledFocusedFileOperation (ScpExplorer->EnableFocusedFileOperation[osCurrent])
  138. #define EnabledLocalSelectedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])
  139. #define EnabledLocalFocusedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableFocusedOperation[osLocal])
  140. #define EnabledLocalSelectedFileOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedFileOperation[osLocal])
  141. #define EnabledRemoteSelectedOperation (ScpExplorer->EnableSelectedOperation[osRemote] && HasTerminal)
  142. #define EnabledRemoteFocusedOperation (ScpExplorer->EnableFocusedOperation[osRemote] && HasTerminal)
  143. #define EnabledRemoteSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osRemote] && HasTerminal)
  144. // focused operation
  145. UPD(CurrentDeleteFocusedAction, EnabledFocusedOperation)
  146. UPD(CurrentPropertiesFocusedAction, EnabledFocusedOperation)
  147. UPD(CurrentEditFocusedAction, EnabledFocusedFileOperation &&
  148. !WinConfiguration->DisableOpenEdit)
  149. UPD(CurrentSystemMenuFocusedAction, EnabledFocusedOperation)
  150. UPD(CurrentEditWithFocusedAction, EnabledFocusedFileOperation &&
  151. !WinConfiguration->DisableOpenEdit)
  152. UPD(CurrentEditInternalFocusedAction, EnabledFocusedFileOperation &&
  153. !WinConfiguration->DisableOpenEdit)
  154. UPD(CurrentCopyToClipboardFocusedAction2, EnabledFocusedOperation)
  155. // file operation
  156. UPD(CurrentRenameAction, EnabledFocusedOperation &&
  157. (ScpExplorer->IsSideLocalBrowser(osCurrent) || ScpExplorer->Terminal->IsCapable[fcRename]))
  158. UPD(CurrentEditAction, EnabledSelectedFileOperation &&
  159. !WinConfiguration->DisableOpenEdit)
  160. UPD(CurrentEditInternalAction, EnabledSelectedFileOperation &&
  161. !WinConfiguration->DisableOpenEdit)
  162. UPD(CurrentEditWithAction, EnabledSelectedFileOperation &&
  163. !WinConfiguration->DisableOpenEdit)
  164. UPD(CurrentOpenAction, EnabledFocusedOperation &&
  165. !WinConfiguration->DisableOpenEdit)
  166. UPDEX1(CurrentAddEditLinkContextAction, ScpExplorer->CanAddEditLink(osCurrent),
  167. Action->Visible = ScpExplorer->LinkFocused())
  168. UPD(NewLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  169. // selected operation
  170. UPD(CurrentDeleteAction, EnabledSelectedOperation)
  171. UPD(CurrentDeleteAlternativeAction, EnabledSelectedOperation)
  172. UPD(CurrentPropertiesAction, EnabledSelectedOperation)
  173. UPD(CurrentCopyToClipboardAction2, EnabledSelectedOperation)
  174. UPD(RemoteMoveToAction, EnabledSelectedOperation &&
  175. !ScpExplorer->IsSideLocalBrowser(osCurrent) &&
  176. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  177. UPD(RemoteCopyToAction, EnabledSelectedOperation &&
  178. !ScpExplorer->IsSideLocalBrowser(osCurrent))
  179. UPD(FileListToCommandLineAction, EnabledSelectedOperation)
  180. UPD(FileListToClipboardAction, EnabledSelectedOperation)
  181. UPD(FullFileListToClipboardAction, EnabledSelectedOperation)
  182. UPD(FileGenerateUrlAction2, EnabledSelectedOperation && !ScpExplorer->IsSideLocalBrowser(osCurrent))
  183. UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT))
  184. UPD(CurrentAddEditLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  185. UPD(LockAction,
  186. EnabledSelectedOperation && !ScpExplorer->IsSideLocalBrowser(osCurrent) &&
  187. ScpExplorer->Terminal->IsCapable[fcLocking])
  188. UPD(UnlockAction,
  189. EnabledSelectedOperation && !ScpExplorer->IsSideLocalBrowser(osCurrent) &&
  190. ScpExplorer->Terminal->IsCapable[fcLocking])
  191. // local selected operation
  192. UPD(LocalCopyAction, HasTerminal && EnabledLocalSelectedOperation)
  193. UPD(LocalCopyQueueAction, HasTerminal && EnabledLocalSelectedOperation && ScpExplorer->Terminal->IsCapable[fcBackgroundTransfers])
  194. UPD(LocalCopyNonQueueAction, HasTerminal && EnabledLocalSelectedOperation)
  195. UPD(LocalRenameAction2, EnabledLocalSelectedOperation)
  196. UPD(LocalEditAction2, EnabledLocalSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  197. UPD(LocalMoveAction, HasTerminal && EnabledLocalSelectedOperation)
  198. UPD(LocalCreateDirAction3, true)
  199. UPD(LocalDeleteAction2, EnabledLocalSelectedOperation)
  200. UPD(LocalPropertiesAction2, EnabledLocalSelectedOperation)
  201. UPD(LocalAddEditLinkAction3, ScpExplorer->CanAddEditLink(osLocal))
  202. UPD(LocalNewFileAction, !WinConfiguration->DisableOpenEdit)
  203. // local focused operation
  204. UPD(LocalCopyFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
  205. UPD(LocalCopyFocusedQueueAction, HasTerminal && EnabledLocalFocusedOperation && ScpExplorer->Terminal->IsCapable[fcBackgroundTransfers])
  206. UPD(LocalCopyFocusedNonQueueAction, HasTerminal && EnabledLocalFocusedOperation)
  207. UPD(LocalMoveFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
  208. // remote selected operation
  209. UPD(RemoteCopyAction, EnabledRemoteSelectedOperation)
  210. UPD(RemoteCopyQueueAction, EnabledRemoteSelectedOperation && ScpExplorer->Terminal->IsCapable[fcBackgroundTransfers])
  211. UPD(RemoteCopyNonQueueAction, EnabledRemoteSelectedOperation)
  212. UPD(RemoteRenameAction2, EnabledRemoteSelectedOperation &&
  213. ScpExplorer->Terminal->IsCapable[fcRename])
  214. UPD(RemoteEditAction2, EnabledRemoteSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  215. UPD(RemoteMoveAction, EnabledRemoteSelectedOperation)
  216. UPD(RemoteCreateDirAction3, DirViewEnabled(osRemote))
  217. UPD(RemoteNewFileAction, DirViewEnabled(osRemote) && !WinConfiguration->DisableOpenEdit)
  218. UPD(RemoteDeleteAction2, EnabledRemoteSelectedOperation)
  219. UPD(RemotePropertiesAction2, EnabledRemoteSelectedOperation)
  220. UPD(RemoteAddEditLinkAction3, ScpExplorer->CanAddEditLink(osRemote))
  221. // remote focused operation
  222. UPD(RemoteCopyFocusedAction, EnabledRemoteFocusedOperation)
  223. UPD(RemoteCopyFocusedQueueAction, EnabledRemoteFocusedOperation && ScpExplorer->Terminal->IsCapable[fcBackgroundTransfers])
  224. UPD(RemoteCopyFocusedNonQueueAction, EnabledRemoteFocusedOperation)
  225. UPD(RemoteMoveFocusedAction, EnabledRemoteFocusedOperation)
  226. UPD(RemoteMoveToFocusedAction, EnabledFocusedOperation &&
  227. !ScpExplorer->IsSideLocalBrowser(osCurrent) &&
  228. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  229. UPD(RemoteCopyToFocusedAction, EnabledFocusedOperation &&
  230. !ScpExplorer->IsSideLocalBrowser(osCurrent))
  231. // directory
  232. UPD(CurrentCreateDirAction, DirViewEnabled(osCurrent))
  233. UPD(NewDirAction, DirViewEnabled(osCurrent))
  234. UPD(RemoteFindFilesAction2, HasTerminal)
  235. // selection
  236. UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
  237. UPD(SelectAction, DirView(osCurrent)->FilesCount)
  238. UPD(UnselectAction, DirView(osCurrent)->SelCount)
  239. UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
  240. UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
  241. UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
  242. UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)
  243. UPD(SelectSameExtAction, EnabledFocusedFileOperation)
  244. UPD(UnselectSameExtAction, EnabledFocusedFileOperation)
  245. UPD(PasteAction3, ScpExplorer->CanPasteFromClipBoard())
  246. UPD(LocalSelectAction2, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  247. UPD(LocalUnselectAction2, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->SelCount)
  248. UPD(LocalSelectAllAction2, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  249. UPD(RemoteSelectAction2, DirView(osRemote)->FilesCount)
  250. UPD(RemoteUnselectAction2, DirView(osRemote)->SelCount)
  251. UPD(RemoteSelectAllAction2, DirView(osRemote)->FilesCount)
  252. //style
  253. UPDACT(CurrentCycleStyleAction,
  254. CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
  255. #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
  256. Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
  257. STYLEACTION(Icon)
  258. STYLEACTION(SmallIcon)
  259. STYLEACTION(List)
  260. STYLEACTION(Report)
  261. #undef STYLEACTION
  262. // REMOTE+LOCAL
  263. // back/forward
  264. #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
  265. UPDEX(SIDE ## DIRECTION ## Action, DirViewEnabled(os ## SIDE) && (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
  266. SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
  267. SIDE ## DIRECTION ## Action->Hint = L"")
  268. HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
  269. HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
  270. HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
  271. HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
  272. #undef HISTORYACTION
  273. #define PANEL_ACTIONS(SIDE) \
  274. UPD(SIDE ## ParentDirAction, DirViewEnabled(os ## SIDE) && !DirView(os ## SIDE)->IsRoot) \
  275. UPDEX1(SIDE ## RootDirAction, DirViewEnabled(os ## SIDE) && !DirView(os ## SIDE)->IsRoot, Action->ImageIndex = (ScpExplorer->IsSideLocalBrowser(os ## SIDE) ? LocalRootDirAction->ImageIndex : FRemoteRootDirImageIndex)) \
  276. UPD(SIDE ## HomeDirAction, DirViewEnabled(os ## SIDE)) \
  277. UPD(SIDE ## RefreshAction, DirViewEnabled(os ## SIDE) && DirView(os ## SIDE)->DirOK) \
  278. UPD(SIDE ## OpenDirAction, DirViewEnabled(os ## SIDE)) \
  279. UPD(SIDE ## ChangePathAction2, DirViewEnabled(os ## SIDE)) \
  280. UPD(SIDE ## AddBookmarkAction2, DirViewEnabled(os ## SIDE)) \
  281. UPD(SIDE ## PathToClipboardAction2, DirViewEnabled(os ## SIDE)) \
  282. UPDEX1(SIDE ## FilterAction, DirViewEnabled(os ## SIDE), Action->Checked = !DirView(os ## SIDE)->Mask.IsEmpty()) \
  283. UPD(SIDE ## ExploreDirectoryAction, ScpExplorer->IsSideLocalBrowser(os ## SIDE))
  284. PANEL_ACTIONS(Local)
  285. PANEL_ACTIONS(Remote)
  286. #undef PANEL_ACTIONS
  287. // HELP
  288. UPD(AboutAction, true)
  289. UPD(HomepageAction, true)
  290. UPD(HistoryPageAction, true)
  291. UPD(TableOfContentsAction, true)
  292. UPD(ForumPageAction, true)
  293. UPDACT(CheckForUpdatesAction, ShowUpdatesUpdate())
  294. UPD(UpdatesPreferencesAction, true)
  295. UPD(DonatePageAction, true)
  296. UPD(DownloadPageAction, true)
  297. UPDEX1(TipsAction, true, TipsAction->Visible = AnyTips())
  298. // VIEW
  299. UPDCOMP(SessionsTabs)
  300. UPDCOMP(StatusBar)
  301. UPDCOMP(ToolBar2)
  302. UPDCOMP2(LocalStatusBar, 2)
  303. UPDCOMP2(RemoteStatusBar, 2)
  304. UPDCOMP(CommandLinePanel)
  305. UPDCOMP(RemoteTree)
  306. UPDCOMP(LocalTree)
  307. #define EMIT_BAND_COMPONENT2(COMP, NUM) UPDCOMP2(COMP, NUM)
  308. BAND_COMPONENTS
  309. #undef EMIT_BAND_COMPONENT2
  310. UPD(CommanderLocalPanelAction, true)
  311. UPD(CommanderRemotePanelAction, true)
  312. UPD(GoToCommandLineAction, true)
  313. UPD(GoToTreeAction, true)
  314. UPDEX(ShowHiddenFilesAction, true,
  315. ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
  316. UPDEX(FormatSizeBytesNoneAction, true,
  317. FormatSizeBytesNoneAction->Checked = (WinConfiguration->FormatSizeBytes == fbNone), )
  318. UPDEX(FormatSizeBytesKilobytesAction, true,
  319. FormatSizeBytesKilobytesAction->Checked = (WinConfiguration->FormatSizeBytes == fbKilobytes), )
  320. UPDEX(FormatSizeBytesShortAction, true,
  321. FormatSizeBytesShortAction->Checked = (WinConfiguration->FormatSizeBytes == fbShort), )
  322. UPDEX(AutoReadDirectoryAfterOpAction, true,
  323. AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )
  324. UPD(PreferencesAction, true)
  325. UPD(PresetsPreferencesAction, true)
  326. UPD(FileColorsPreferencesAction, true)
  327. UPDEX(LockToolbarsAction, true,
  328. LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
  329. UPDEX(SelectiveToolbarTextAction, true,
  330. SelectiveToolbarTextAction->Checked = WinConfiguration->SelectiveToolbarText, )
  331. UPDCOMP(CustomCommandsBand)
  332. UPD(ColorMenuAction, HasTerminal)
  333. UPD(GoToAddressAction, true)
  334. UPD(CustomizeToolbarAction, IsToolbarCustomizable())
  335. // SORT
  336. UPDSORTA(Local, 2)
  337. #define UPDSORTL(NAME, COL) UPDSORT(Local, NAME, COL, -1, 2)
  338. UPDSORTL(Name, dvName)
  339. UPDSORTL(Ext, dvExt)
  340. UPDSORTL(Size, dvSize)
  341. UPDSORTL(Type, dvType)
  342. UPDSORTL(Changed, dvChanged)
  343. UPDSORTL(Attr, dvAttr)
  344. #undef UPDSORTL
  345. UPDSORTA(Remote, 2)
  346. UPDSORT(Remote, Name, dvName, uvName, 2)
  347. UPDSORT(Remote, Ext, dvExt, uvExt, 2)
  348. UPDSORT(Remote, Size, dvSize, uvSize, 2)
  349. UPDSORT(Remote, Changed, dvChanged, uvChanged, 2)
  350. UPDSORT(Remote, Rights, dvAttr, uvRights, 2)
  351. UPDSORT(Remote, Owner, -1, uvOwner, 2)
  352. UPDSORT(Remote, Group, -1, uvGroup, 2)
  353. UPDSORT(Remote, Type, dvType, uvType, 2)
  354. UPDSORTA(Current, )
  355. UPDSORT(Current, Name, dvName, uvName, )
  356. UPDSORT(Current, Ext, dvExt, uvExt, )
  357. UPDSORT(Current, Size, dvSize, uvSize, )
  358. UPDSORT(Current, Type, dvType, uvType, 2)
  359. UPDSORT(Current, Changed, dvChanged, uvChanged, )
  360. UPDSORT(Current, Rights, dvAttr, uvRights, )
  361. UPDSORT(Current, Owner, -1, uvOwner, )
  362. UPDSORT(Current, Group, -1, uvGroup, )
  363. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  364. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  365. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, )
  366. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  367. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, )
  368. #undef COLVIEWPROPS
  369. // SHOW/HIDE COLUMN
  370. #define UPDSHCOLL(NAME) UPDSHCOL(Local, NAME, dv ## NAME, -1)
  371. UPDSHCOLL(Name)
  372. UPDSHCOLL(Ext)
  373. UPDSHCOLL(Size)
  374. UPDSHCOLL(Type)
  375. UPDSHCOLL(Changed)
  376. UPDSHCOLL(Attr)
  377. #undef UPDSHCOLL
  378. UPDSHCOL(Remote, Name, dvName, uvName)
  379. UPDSHCOL(Remote, Ext, dvExt, uvExt)
  380. UPDSHCOL(Remote, Size, dvSize, uvSize)
  381. UPDSHCOL(Remote, Changed, dvChanged, uvChanged)
  382. UPDSHCOL(Remote, Rights, dvAttr, uvRights)
  383. UPDSHCOL(Remote, Owner, -1, uvOwner)
  384. UPDSHCOL(Remote, Group, -1, uvGroup)
  385. UPDSHCOL(Remote, LinkTarget, -1, uvLinkTarget)
  386. UPDSHCOL(Remote, Type, dvType, uvType)
  387. UPD(HideColumnAction, (ListColumn != NULL))
  388. UPD(BestFitColumnAction, (ListColumn != NULL))
  389. // SESSION
  390. UPD(NewSessionAction, true)
  391. UPD(SiteManagerAction, true)
  392. UPD(DuplicateSessionAction, HasTerminal)
  393. UPD(RenameSessionAction, HasTerminal)
  394. UPD(CloseSessionAction2, (ScpExplorer->Terminal != NULL))
  395. UPDEX1(DisconnectSessionAction, HasTerminal, DisconnectSessionAction->Visible = (ScpExplorer->Terminal == NULL) || !ScpExplorer->Terminal->Disconnected)
  396. UPDEX1(ReconnectSessionAction, (ScpExplorer->Terminal != NULL) && ScpExplorer->Terminal->Disconnected, ReconnectSessionAction->Visible = ReconnectSessionAction->Enabled)
  397. UPD(SavedSessionsAction2, true)
  398. UPD(WorkspacesAction, StoredSessions->HasAnyWorkspace())
  399. UPD(OpenedSessionsAction, HasTerminal)
  400. UPD(SaveCurrentSessionAction2, HasTerminal)
  401. UPD(SaveWorkspaceAction, HasTerminal)
  402. // COMMAND
  403. UPD(CompareDirectoriesAction2, HasTerminal)
  404. UPD(SynchronizeAction, HasTerminal)
  405. UPD(FullSynchronizeAction, HasTerminal)
  406. UPD(ConsoleAction, ScpExplorer->CanConsole())
  407. UPD(PuttyAction, HasTerminal && TTerminalManager::Instance()->CanOpenInPutty())
  408. UPD(SynchronizeBrowsingAction2, HasTerminal)
  409. UPD(CloseApplicationAction2, true)
  410. UPD(FileSystemInfoAction, HasTerminal)
  411. UPD(SessionGenerateUrlAction2, HasTerminal)
  412. UPD(ClearCachesAction, HasTerminal && !ScpExplorer->Terminal->AreCachesEmpty)
  413. UPD(NewFileAction, DirViewEnabled(osCurrent) && !WinConfiguration->DisableOpenEdit)
  414. UPD(EditorListCustomizeAction, true)
  415. UPD(ChangePasswordAction, ScpExplorer->CanChangePassword())
  416. UPD(PrivateKeyUploadAction, ScpExplorer->CanPrivateKeyUpload())
  417. // CUSTOM COMMANDS
  418. UPD(CustomCommandsFileAction, true)
  419. UPD(CustomCommandsNonFileAction, true)
  420. UPD(CustomCommandsEnterAction, true)
  421. UPD(CustomCommandsEnterFocusedAction, true)
  422. UPDFUNC(CustomCommandsLastAction, CustomCommandsLastUpdate(CustomCommandsLastAction))
  423. UPDFUNC(CustomCommandsLastFocusedAction, CustomCommandsLastUpdate(CustomCommandsLastFocusedAction))
  424. UPD(CustomCommandsCustomizeAction, true)
  425. // QUEUE
  426. UPDEX(QueueEnableAction, HasTerminal, Action->Checked = ScpExplorer->GetQueueEnabled(), )
  427. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  428. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  429. UPDQUEUE(GoTo)
  430. UPDQUEUE(Preferences)
  431. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  432. Action->Visible = true, Action->Visible = false)
  433. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  434. Action->Visible = true, Action->Visible = false)
  435. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  436. Action->Visible = true, Action->Visible = false)
  437. UPDQUEUE(ItemDelete)
  438. UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
  439. Action->Visible = true, Action->Visible =
  440. !ScpExplorer->AllowQueueOperation(qoItemPause) &&
  441. !ScpExplorer->AllowQueueOperation(qoItemResume))
  442. UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
  443. Action->Visible = true, Action->Visible = false)
  444. UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
  445. Action->Visible = true, Action->Visible = false)
  446. UPDQUEUE(ItemUp)
  447. UPDQUEUE(ItemDown)
  448. UPDQUEUE(PauseAll)
  449. UPDQUEUE(ResumeAll)
  450. UPDQUEUE(DeleteAll)
  451. UPDQUEUE(DeleteAllDone)
  452. #undef UPDQUEUE
  453. UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &AuxVoidPtr),
  454. QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(AuxVoidPtr)),
  455. QueueItemSpeedAction->Text = L"")
  456. UPDACT(QueueToggleShowAction,
  457. Action->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  458. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  459. Action->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  460. QUEUEACTION(Show)
  461. QUEUEACTION(HideWhenEmpty)
  462. QUEUEACTION(Hide)
  463. #undef QUEUEACTION
  464. UPDEX1(QueueCycleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty),
  465. QueueCycleOnceEmptyAction->ImageIndex = CurrentQueueOnceEmptyAction()->ImageIndex;
  466. QueueCycleOnceEmptyAction->Checked = !QueueIdleOnceEmptyAction->Checked)
  467. UPD(QueueIdleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  468. UPD(QueueDisconnectOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  469. UPD(QueueSuspendOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  470. UPD(QueueShutDownOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  471. UPDCOMP(CommanderPreferencesBand)
  472. UPDACT(QueueToolbarAction,
  473. Action->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  474. Action->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar])
  475. UPDACT(QueueFileListAction,
  476. Action->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  477. Action->Checked = ScpExplorer->ComponentVisible[fcQueueFileList])
  478. ;
  479. }
  480. //---------------------------------------------------------------------------
  481. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  482. TBasicAction * BasicAction, bool & Handled)
  483. {
  484. DebugAssert(ScpExplorer);
  485. TAction * Action = DebugNotNull(dynamic_cast<TAction *>(BasicAction));
  486. if (!ScpExplorer->AllowedAction(Action, aaExecute))
  487. {
  488. Handled = true;
  489. return;
  490. }
  491. ScpExplorer->BeforeAction();
  492. unsigned int ShortCutFlag = FLAGMASK((Action->ActionComponent == NULL), cocShortCutHint);
  493. {
  494. TAutoNestingCounter Counter(FBusy);
  495. // focused operation
  496. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, true))
  497. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, true))
  498. EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
  499. EXE(CurrentSystemMenuFocusedAction, ScpExplorer->DisplaySystemContextMenu())
  500. EXE(CurrentEditWithFocusedAction, ScpExplorer->ExecuteCurrentFileWith(true))
  501. EXE(CurrentEditInternalFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, true))
  502. EXE(CurrentCopyToClipboardFocusedAction2, ScpExplorer->CopyFilesToClipboard(osCurrent, true))
  503. // operation
  504. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
  505. EXE(CurrentEditInternalAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false))
  506. EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith(false))
  507. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  508. EXE(CurrentAddEditLinkAction, ScpExplorer->AddEditLink(osCurrent, false))
  509. EXE(CurrentAddEditLinkContextAction, ScpExplorer->AddEditLink(osCurrent, false))
  510. EXE(NewLinkAction, ScpExplorer->AddEditLink(osCurrent, true))
  511. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osCurrent, false))
  512. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false))
  513. EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false, false, (void*)true))
  514. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, false))
  515. EXE(CurrentCopyToClipboardAction2, ScpExplorer->CopyFilesToClipboard(osCurrent, false))
  516. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  517. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  518. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  519. EXE(FileGenerateUrlAction2, ScpExplorer->FileGenerateUrl())
  520. EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
  521. EXE(LockAction, ScpExplorer->ExecuteFileOperationCommand(foLock, osCurrent, false))
  522. EXE(UnlockAction, ScpExplorer->ExecuteFileOperationCommand(foUnlock, osCurrent, false))
  523. // local selected operation
  524. EXE(LocalCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, ShortCutFlag))
  525. EXE(LocalCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocQueue))
  526. EXE(LocalCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocNonQueue))
  527. EXE(LocalRenameAction2, ScpExplorer->ExecuteFileOperationCommand(foRename, osLocal, false))
  528. EXE(LocalEditAction2, ScpExplorer->ExecuteFile(osLocal, efDefaultEditor, NULL, true, false))
  529. EXE(LocalMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, false))
  530. EXE(LocalCreateDirAction3, ScpExplorer->CreateDirectory(osLocal))
  531. EXE(LocalDeleteAction2, ScpExplorer->ExecuteFileOperationCommand(foDelete, osLocal, false))
  532. EXE(LocalPropertiesAction2, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osLocal, false))
  533. EXE(LocalAddEditLinkAction3, ScpExplorer->AddEditLink(osLocal, false))
  534. EXE(LocalNewFileAction, ScpExplorer->EditNew(osLocal))
  535. // local focused operation
  536. EXE(LocalCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, ShortCutFlag))
  537. EXE(LocalCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocQueue))
  538. EXE(LocalCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocNonQueue))
  539. EXE(LocalMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, true))
  540. // remote selected operation
  541. EXE(RemoteCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, ShortCutFlag))
  542. EXE(RemoteCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocQueue))
  543. EXE(RemoteCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocNonQueue))
  544. EXE(RemoteRenameAction2, ScpExplorer->ExecuteFileOperationCommand(foRename, osRemote, false))
  545. EXE(RemoteEditAction2, ScpExplorer->ExecuteFile(osRemote, efDefaultEditor, NULL, true, false))
  546. EXE(RemoteMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, false))
  547. EXE(RemoteCreateDirAction3, ScpExplorer->CreateDirectory(osRemote))
  548. EXE(RemoteNewFileAction, ScpExplorer->EditNew(osRemote))
  549. EXE(RemoteDeleteAction2, ScpExplorer->ExecuteFileOperationCommand(foDelete, osRemote, false))
  550. EXE(RemotePropertiesAction2, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osRemote, false))
  551. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, false))
  552. EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, false))
  553. EXE(RemoteAddEditLinkAction3, ScpExplorer->AddEditLink(osRemote, false))
  554. // remote focused operation
  555. EXE(RemoteCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, ShortCutFlag))
  556. EXE(RemoteCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocQueue))
  557. EXE(RemoteCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocNonQueue))
  558. EXE(RemoteMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, true))
  559. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, true))
  560. EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, true))
  561. // directory
  562. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  563. EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
  564. EXE(RemoteFindFilesAction2, ScpExplorer->RemoteFindFiles())
  565. //selection
  566. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  567. EXE(SelectAction, ScpExplorer->SelectByMask(osCurrent, true))
  568. EXE(UnselectAction, ScpExplorer->SelectByMask(osCurrent, false))
  569. EXE(SelectAllAction, ScpExplorer->SelectAll(osCurrent, smAll))
  570. EXE(InvertSelectionAction, ScpExplorer->SelectAll(osCurrent, smInvert))
  571. EXE(ClearSelectionAction, ScpExplorer->SelectAll(osCurrent, smNone))
  572. EXE(RestoreSelectionAction, ScpExplorer->RestoreSelectedNames(osCurrent))
  573. EXE(SelectSameExtAction, ScpExplorer->SelectSameExt(true))
  574. EXE(UnselectSameExtAction, ScpExplorer->SelectSameExt(false))
  575. EXE(LocalSelectAction2, ScpExplorer->SelectByMask(osLocal, true))
  576. EXE(LocalUnselectAction2, ScpExplorer->SelectByMask(osLocal, false))
  577. EXE(LocalSelectAllAction2, ScpExplorer->SelectAll(osLocal, smAll))
  578. EXE(RemoteSelectAction2, ScpExplorer->SelectByMask(osRemote, true))
  579. EXE(RemoteUnselectAction2, ScpExplorer->SelectByMask(osRemote, false))
  580. EXE(RemoteSelectAllAction2, ScpExplorer->SelectAll(osRemote, smAll))
  581. EXE(PasteAction3, ScpExplorer->PasteFromClipBoard())
  582. // style
  583. EXE(CurrentCycleStyleAction,
  584. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  585. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  586. )
  587. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  588. DirView(osCurrent)->ViewStyle = vs ## Style)
  589. STYLEACTION(Icon)
  590. STYLEACTION(SmallIcon)
  591. STYLEACTION(List)
  592. STYLEACTION(Report)
  593. #undef STYLEACTION
  594. #define PANEL_ACTIONS(SIDE) \
  595. EXE(SIDE ## BackAction, ScpExplorer->HistoryGo(os ## SIDE, -1)) \
  596. EXE(SIDE ## ForwardAction, ScpExplorer->HistoryGo(os ## SIDE, 1)) \
  597. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  598. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  599. EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \
  600. EXE(SIDE ## RefreshAction, ScpExplorer->ReloadDirectory(os ## SIDE)) \
  601. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  602. EXE(SIDE ## ChangePathAction2, ScpExplorer->ChangePath(os ## SIDE)) \
  603. EXE(SIDE ## AddBookmarkAction2, ScpExplorer->AddBookmark(os ## SIDE)) \
  604. EXE(SIDE ## PathToClipboardAction2, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \
  605. EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE)) \
  606. EXE(SIDE ## ExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory(os ## SIDE))
  607. PANEL_ACTIONS(Local)
  608. PANEL_ACTIONS(Remote)
  609. #undef PANEL_ACTIONS
  610. //HELP
  611. EXE(AboutAction, DoAboutDialog(Configuration))
  612. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  613. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  614. EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
  615. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  616. EXE(CheckForUpdatesAction, CheckForUpdates(false))
  617. EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
  618. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  619. EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
  620. EXE(TipsAction, ShowTips())
  621. // VIEW
  622. EXECOMP(SessionsTabs)
  623. EXECOMP(StatusBar)
  624. EXECOMP(ToolBar2)
  625. EXECOMP2(LocalStatusBar, 2)
  626. EXECOMP2(RemoteStatusBar, 2)
  627. #define EMIT_BAND_COMPONENT2(COMP, NUM) EXECOMP2(COMP, NUM)
  628. BAND_COMPONENTS
  629. #undef EMIT_BAND_COMPONENT2
  630. EXECOMP(CommandLinePanel)
  631. EXECOMP(RemoteTree)
  632. EXECOMP(LocalTree)
  633. EXE(CommanderLocalPanelAction, )
  634. EXE(CommanderRemotePanelAction, )
  635. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  636. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  637. EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())
  638. EXE(FormatSizeBytesNoneAction, ScpExplorer->SetFormatSizeBytes(fbNone))
  639. EXE(FormatSizeBytesKilobytesAction, ScpExplorer->SetFormatSizeBytes(fbKilobytes))
  640. EXE(FormatSizeBytesShortAction, ScpExplorer->SetFormatSizeBytes(fbShort))
  641. EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())
  642. EXE(PreferencesAction, PreferencesDialog(::pmDefault) )
  643. EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
  644. EXE(FileColorsPreferencesAction, PreferencesDialog(pmFileColors) )
  645. EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
  646. EXE(SelectiveToolbarTextAction, WinConfiguration->SelectiveToolbarText = !WinConfiguration->SelectiveToolbarText)
  647. EXECOMP(CustomCommandsBand)
  648. EXE(ColorMenuAction, CreateSessionColorMenu(ColorMenuAction))
  649. EXE(GoToAddressAction, ScpExplorer->GoToAddress())
  650. EXE(CustomizeToolbarAction, CreateToolbarButtonsList())
  651. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  652. // SORT
  653. #define EXESORTL(NAME, COL) EXESORT(Local, NAME, COL, COL, 2)
  654. EXESORTL(Name, dvName)
  655. EXESORTL(Ext, dvExt)
  656. EXESORTL(Size, dvSize)
  657. EXESORTL(Type, dvType)
  658. EXESORTL(Changed, dvChanged)
  659. EXESORTL(Attr, dvAttr)
  660. #undef EXESORTL
  661. EXESORTA(Remote, 2)
  662. EXESORT(Remote, Name, dvName, uvName, 2)
  663. EXESORT(Remote, Ext, dvExt, uvExt, 2)
  664. EXESORT(Remote, Size, dvSize, uvSize, 2)
  665. EXESORT(Remote, Changed, dvChanged, uvChanged, 2)
  666. EXESORT(Remote, Rights, dvAttr, uvRights, 2)
  667. EXESORT(Remote, Owner, -1, uvOwner, 2)
  668. EXESORT(Remote, Group, -1, uvGroup, 2)
  669. EXESORT(Remote, Type, dvType, uvType, 2)
  670. EXESORTA(Current, )
  671. EXESORT(Current, Name, dvName, uvName, )
  672. EXESORT(Current, Ext, dvExt, uvExt, )
  673. EXESORT(Current, Size, dvSize, uvSize, )
  674. EXESORT(Current, Type, dvType, uvType, 2)
  675. EXESORT(Current, Changed, dvChanged, uvChanged, )
  676. EXESORT(Current, Rights, dvAttr, uvRights, )
  677. EXESORT(Current, Owner, -1, uvOwner, )
  678. EXESORT(Current, Group, -1, uvGroup, )
  679. EXE(SortColumnAscendingAction, DebugAssert(ListColumn);
  680. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  681. EXE(SortColumnDescendingAction, DebugAssert(ListColumn);
  682. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  683. // SHOW/HIDE COLUMN
  684. #define EXESHCOLL(NAME) EXESHCOL(Local, NAME, dv ## NAME, -1)
  685. EXESHCOLL(Name)
  686. EXESHCOLL(Ext)
  687. EXESHCOLL(Size)
  688. EXESHCOLL(Type)
  689. EXESHCOLL(Changed)
  690. EXESHCOLL(Attr)
  691. #undef EXESHCOLL
  692. EXESHCOL(Remote, Name, dvName, uvName)
  693. EXESHCOL(Remote, Ext, dvExt, uvExt)
  694. EXESHCOL(Remote, Size, dvSize, uvSize)
  695. EXESHCOL(Remote, Changed, dvChanged, uvChanged)
  696. EXESHCOL(Remote, Rights, dvAttr, uvRights)
  697. EXESHCOL(Remote, Owner, -1, uvOwner)
  698. EXESHCOL(Remote, Group, -1, uvGroup)
  699. EXESHCOL(Remote, LinkTarget, -1, uvLinkTarget)
  700. EXESHCOL(Remote, Type, dvType, uvType)
  701. EXE(HideColumnAction, DebugAssert(ListColumn);
  702. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  703. EXE(BestFitColumnAction, DebugAssert(ListColumn); ListColumn = NULL ) // TODO
  704. #undef COLVIEWPROPS
  705. // SESSION
  706. EXE(NewSessionAction, ScpExplorer->NewSession(false))
  707. EXE(SiteManagerAction, ScpExplorer->NewSession(true))
  708. EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession())
  709. EXE(RenameSessionAction, ScpExplorer->RenameSession())
  710. EXE(CloseSessionAction2, ScpExplorer->CloseSession())
  711. EXE(DisconnectSessionAction, ScpExplorer->DisconnectSession())
  712. EXE(ReconnectSessionAction, ScpExplorer->ReconnectSession())
  713. EXE(SavedSessionsAction2, CreateSessionListMenu(SavedSessionsAction2))
  714. EXE(WorkspacesAction, CreateWorkspacesMenu(WorkspacesAction))
  715. EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
  716. EXE(SaveCurrentSessionAction2, ScpExplorer->SaveCurrentSession())
  717. EXE(SaveWorkspaceAction, ScpExplorer->SaveWorkspace(false))
  718. // COMMAND
  719. EXE(CompareDirectoriesAction2, ScpExplorer->CompareDirectories())
  720. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  721. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  722. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  723. EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
  724. EXE(SynchronizeBrowsingAction2, ScpExplorer->SynchronizeBrowsingChanged())
  725. EXE(CloseApplicationAction2, ScpExplorer->CloseApp())
  726. EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
  727. EXE(SessionGenerateUrlAction2, ScpExplorer->SessionGenerateUrl())
  728. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  729. EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
  730. EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
  731. EXE(ChangePasswordAction, ScpExplorer->ChangePassword())
  732. EXE(PrivateKeyUploadAction, ScpExplorer->PrivateKeyUpload())
  733. // CUSTOM COMMANDS
  734. EXE(CustomCommandsFileAction, CreateCustomCommandsMenu(CustomCommandsFileAction, ccltFile))
  735. EXE(CustomCommandsNonFileAction, CreateCustomCommandsMenu(CustomCommandsNonFileAction, ccltNonFile))
  736. EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false))
  737. EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true))
  738. EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false))
  739. EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true))
  740. EXE(CustomCommandsCustomizeAction, CustomCommandsCustomize(NULL))
  741. // QUEUE
  742. EXE(QueueEnableAction, ScpExplorer->ToggleQueueEnabled())
  743. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  744. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  745. EXEQUEUE(GoTo)
  746. EXEQUEUE(Preferences)
  747. EXEQUEUE(ItemQuery)
  748. EXEQUEUE(ItemError)
  749. EXEQUEUE(ItemPrompt)
  750. EXEQUEUE(ItemDelete)
  751. EXEQUEUE(ItemExecute)
  752. EXEQUEUE(ItemPause)
  753. EXEQUEUE(ItemResume)
  754. EXEQUEUE(ItemUp)
  755. EXEQUEUE(ItemDown)
  756. EXEQUEUE(PauseAll)
  757. EXEQUEUE(ResumeAll)
  758. EXEQUEUE(DeleteAll)
  759. EXEQUEUE(DeleteAllDone)
  760. #undef EXEQUEUE
  761. EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
  762. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  763. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  764. if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
  765. Config.Show = qv ## SHOW; \
  766. WinConfiguration->QueueView = Config)
  767. QUEUEACTION(Show)
  768. QUEUEACTION(HideWhenEmpty)
  769. QUEUEACTION(Hide)
  770. #undef QUEUEACTION
  771. EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction())
  772. EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction))
  773. EXE(QueueDisconnectOnceEmptyAction2, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction2))
  774. EXE(QueueSuspendOnceEmptyAction2, SetQueueOnceEmptyAction(QueueSuspendOnceEmptyAction2))
  775. EXE(QueueShutDownOnceEmptyAction2, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction2))
  776. EXECOMP(QueueToolbar)
  777. EXECOMP(QueueFileList)
  778. EXE(QueueItemSpeedAction, )
  779. ;
  780. }
  781. DoIdle();
  782. }
  783. //---------------------------------------------------------------------------
  784. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  785. {
  786. // following actions needs to be updated even when all clients
  787. // are invisible, so the queue list toolbar button can be shown
  788. NonVisualDataModule->QueueItemQueryAction->Update();
  789. NonVisualDataModule->QueueItemErrorAction->Update();
  790. NonVisualDataModule->QueueItemPromptAction->Update();
  791. }
  792. //---------------------------------------------------------------------------
  793. #define CTRL TShiftState() << ssCtrl
  794. #define ALT TShiftState() << ssAlt
  795. #define SHIFT TShiftState() << ssShift
  796. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  797. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  798. #define NONE TShiftState()
  799. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  800. {
  801. // Directory
  802. CurrentCreateDirAction->ShortCut = ShortCut(L'D', CTRL);
  803. // File operation
  804. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  805. CurrentEditAction->ShortCut = ShortCut(L'E', CTRL);
  806. CurrentAddEditLinkAction->ShortCut = ShortCut(L'L', CTRLALT);
  807. CurrentEditInternalAction->ShortCut = 0;
  808. CurrentEditInternalFocusedAction->ShortCut = 0;
  809. // Focused operation
  810. RemoteCopyAction->ShortCut = ShortCut(L'T', CTRL);
  811. RemoteMoveAction->ShortCut = ShortCut(L'M', CTRL);
  812. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  813. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  814. RemoteMoveToFocusedAction->ShortCut = ShortCut(L'M', CTRLALT);
  815. // remote directory
  816. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  817. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  818. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  819. RemotePathToClipboardAction2->ShortCut = ShortCut(L'P', CTRLSHIFT);
  820. // selected operation
  821. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_DELETE, SHIFT);
  822. RemoteMoveToAction->ShortCut = ShortCut(L'M', CTRLALT);
  823. // selection
  824. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  825. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  826. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  827. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  828. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);
  829. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  830. // commands
  831. NewFileAction->ShortCut = ShortCut(L'E', CTRLSHIFT);
  832. RemoteFindFilesAction2->ShortCut = ShortCut(VK_F3, NONE);
  833. CloseApplicationAction2->ShortCut = ShortCut(VK_F4, ALT);
  834. CloneShortcuts();
  835. }
  836. //---------------------------------------------------------------------------
  837. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  838. {
  839. bool ExplorerKeyboardShortcuts = WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts;
  840. // Directory
  841. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  842. // File operation
  843. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  844. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  845. CurrentAddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  846. CurrentEditInternalAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  847. CurrentEditInternalFocusedAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  848. // Focused operation
  849. RemoteCopyAction->ShortCut =
  850. ExplorerKeyboardShortcuts ? ShortCut(L'K', CTRL) : ShortCut(VK_F5, NONE);
  851. RemoteMoveAction->ShortCut = ShortCut(VK_F6, NONE);
  852. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  853. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  854. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  855. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  856. // remote directory
  857. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  858. RemoteRefreshAction->ShortCut =
  859. ExplorerKeyboardShortcuts ? ShortCut(VK_F5, NONE) : ShortCut(L'R', CTRL);
  860. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  861. RemotePathToClipboardAction2->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  862. // local directory
  863. LocalPathToClipboardAction2->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  864. // selected operation
  865. CurrentDeleteAction->SecondaryShortCuts->Clear();
  866. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  867. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);
  868. CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();
  869. CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));
  870. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  871. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  872. // selection
  873. SelectOneAction->ShortCut = VK_INSERT;
  874. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  875. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  876. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  877. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  878. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);
  879. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  880. // commands
  881. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  882. RemoteFindFilesAction2->ShortCut =
  883. ExplorerKeyboardShortcuts ? ShortCut(VK_F3, NONE) : ShortCut(VK_F7, ALT);
  884. // legacy shortcut (can be removed when necessary)
  885. NewFileAction->SecondaryShortCuts->Clear();
  886. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  887. // Backward compatibility, can be abandoned, once there's a better use for Ctrl+T
  888. ConsoleAction->SecondaryShortCuts->Clear();
  889. ConsoleAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(L'T', CTRL)));
  890. CloseApplicationAction2->ShortCut = ShortCut(VK_F10, NONE);
  891. TShortCut CtrlF4 = ShortCut(VK_F4, CTRL);
  892. LocalSortByExtAction2->ShortCut = ExplorerKeyboardShortcuts ? TShortCut(0) : CtrlF4;
  893. RemoteSortByExtAction2->ShortCut = LocalSortByExtAction2->ShortCut;
  894. CurrentSortByExtAction->ShortCut = LocalSortByExtAction2->ShortCut;
  895. int Index = CloseSessionAction2->SecondaryShortCuts->IndexOfShortCut(CtrlF4);
  896. if (ExplorerKeyboardShortcuts && (Index < 0))
  897. {
  898. CloseSessionAction2->SecondaryShortCuts->Add(ShortCutToText(CtrlF4));
  899. }
  900. else if (!ExplorerKeyboardShortcuts && (Index >= 0))
  901. {
  902. CloseSessionAction2->SecondaryShortCuts->Delete(Index);
  903. }
  904. CloneShortcuts();
  905. }
  906. #undef CTRL
  907. #undef ALT
  908. #undef NONE
  909. //---------------------------------------------------------------------------
  910. void __fastcall TNonVisualDataModule::CloneShortcuts()
  911. {
  912. // Commands
  913. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  914. // File operation
  915. CurrentAddEditLinkContextAction->ShortCut = CurrentAddEditLinkAction->ShortCut;
  916. LocalAddEditLinkAction3->ShortCut = CurrentAddEditLinkAction->ShortCut;
  917. RemoteAddEditLinkAction3->ShortCut = CurrentAddEditLinkAction->ShortCut;
  918. RemoteNewFileAction->ShortCut = NewFileAction->ShortCut;
  919. LocalNewFileAction->ShortCut = NewFileAction->ShortCut;
  920. // local directory
  921. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  922. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  923. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  924. // selected operation
  925. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  926. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  927. // local selected operation
  928. LocalCopyAction->ShortCut = RemoteCopyAction->ShortCut;
  929. LocalRenameAction2->ShortCut = CurrentRenameAction->ShortCut;
  930. LocalEditAction2->ShortCut = CurrentEditAction->ShortCut;
  931. LocalMoveAction->ShortCut = RemoteMoveAction->ShortCut;
  932. LocalCreateDirAction3->ShortCut = CurrentCreateDirAction->ShortCut;
  933. LocalDeleteAction2->ShortCut = CurrentDeleteAction->ShortCut;
  934. LocalPropertiesAction2->ShortCut = CurrentPropertiesAction->ShortCut;
  935. // local focused operation
  936. LocalCopyFocusedAction->ShortCut = LocalCopyAction->ShortCut;
  937. LocalMoveFocusedAction->ShortCut = LocalMoveAction->ShortCut;
  938. // remote selected operation
  939. RemoteRenameAction2->ShortCut = CurrentRenameAction->ShortCut;
  940. RemoteEditAction2->ShortCut = CurrentEditAction->ShortCut;
  941. RemoteCreateDirAction3->ShortCut = CurrentCreateDirAction->ShortCut;
  942. RemoteDeleteAction2->ShortCut = CurrentDeleteAction->ShortCut;
  943. RemotePropertiesAction2->ShortCut = CurrentPropertiesAction->ShortCut;
  944. // remote focused operation
  945. RemoteCopyFocusedAction->ShortCut = RemoteCopyAction->ShortCut;
  946. RemoteMoveFocusedAction->ShortCut = RemoteMoveAction->ShortCut;
  947. // selection
  948. LocalSelectAction2->ShortCut = SelectAction->ShortCut;
  949. LocalUnselectAction2->ShortCut = UnselectAction->ShortCut;
  950. LocalSelectAllAction2->ShortCut = SelectAllAction->ShortCut;
  951. RemoteSelectAction2->ShortCut = SelectAction->ShortCut;
  952. RemoteUnselectAction2->ShortCut = UnselectAction->ShortCut;
  953. RemoteSelectAllAction2->ShortCut = SelectAllAction->ShortCut;
  954. }
  955. //---------------------------------------------------------------------------
  956. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  957. {
  958. FScpExplorer = value;
  959. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  960. }
  961. //---------------------------------------------------------------------------
  962. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  963. TObject */*Sender*/)
  964. {
  965. DoIdle();
  966. }
  967. //---------------------------------------------------------------------------
  968. void __fastcall TNonVisualDataModule::DoIdle()
  969. {
  970. if (!FSessionIdleTimerExecuting)
  971. {
  972. FSessionIdleTimerExecuting = true;
  973. try
  974. {
  975. DebugAssert(ScpExplorer);
  976. ScpExplorer->Idle();
  977. }
  978. __finally
  979. {
  980. FSessionIdleTimerExecuting = false;
  981. }
  982. }
  983. }
  984. //---------------------------------------------------------------------------
  985. UnicodeString __fastcall TNonVisualDataModule::CustomCommandCaption(const TCustomCommandType * Command, bool Toolbar)
  986. {
  987. UnicodeString Result = Command->Name;
  988. if (Toolbar)
  989. {
  990. Result = StripHotkey(Result);
  991. Result = EscapeHotkey(Result);
  992. }
  993. return Result;
  994. }
  995. //---------------------------------------------------------------------------
  996. UnicodeString __fastcall TNonVisualDataModule::CustomCommandHint(const TCustomCommandType * Command)
  997. {
  998. UnicodeString Name = StripHotkey(Command->Name);
  999. UnicodeString LongHint =
  1000. !Command->Description.IsEmpty() ? Command->Description : FMTLOAD(CUSTOM_COMMAND_HINT_LONG, (Name, Command->Command));
  1001. UnicodeString Result = FORMAT(L"%s|%s", (Name, LongHint));
  1002. return Result;
  1003. }
  1004. //---------------------------------------------------------------------------
  1005. const int CustomCommandOnFocused = 0x0100;
  1006. const int CustomCommandBoth = 0x0200;
  1007. const int CustomCommandExtension = 0x0400;
  1008. const int CustomCommandIndexMask = 0x00FF;
  1009. //---------------------------------------------------------------------------
  1010. // See IsValidIdent
  1011. static UnicodeString MakeIdent(const UnicodeString & S)
  1012. {
  1013. UnicodeString Result;
  1014. for (int Index = 1; Index <= S.Length(); Index++)
  1015. {
  1016. wchar_t C = S[Index];
  1017. if (IsLetter(C) ||
  1018. (!Result.IsEmpty() && IsDigit(C)))
  1019. {
  1020. Result += C;
  1021. }
  1022. }
  1023. return Result;
  1024. }
  1025. //---------------------------------------------------------------------------
  1026. int __fastcall TNonVisualDataModule::CreateCustomCommandsListMenu(
  1027. TCustomCommandList * List, TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType,
  1028. int Tag, TStrings * HiddenCommands)
  1029. {
  1030. int Result = 0;
  1031. for (int Index = 0; Index < List->Count; Index++)
  1032. {
  1033. const TCustomCommandType * Command = List->Commands[Index];
  1034. int State = ScpExplorer->CustomCommandState(*Command, OnFocused, ListType);
  1035. if (State >= 0)
  1036. {
  1037. TTBCustomItem * Item = new TTBXItem(Owner);
  1038. Item->Caption = CustomCommandCaption(Command, Toolbar);
  1039. Item->Tag = Index | Tag;
  1040. Item->Enabled = (State > 0);
  1041. if (Toolbar)
  1042. {
  1043. UnicodeString Name = ExtractFileName(Command->Id);
  1044. if (Name.IsEmpty())
  1045. {
  1046. Name = Command->Name;
  1047. }
  1048. Name = MakeIdent(Name);
  1049. Name += L"CustomCommand";
  1050. // This is only the last resort to avoid run-time errors.
  1051. // If there are duplicates, button hidding won't be deterministic.
  1052. int X = 0;
  1053. UnicodeString UniqueName = Name;
  1054. while (Owner->FindComponent(UniqueName) != NULL)
  1055. {
  1056. X++;
  1057. UniqueName = FORMAT(L"%s%d", (Name, X));
  1058. }
  1059. Item->Name = UniqueName;
  1060. Item->Visible = (HiddenCommands->IndexOf(Item->Name) < 0);
  1061. }
  1062. if (OnFocused)
  1063. {
  1064. Item->Tag = Item->Tag | CustomCommandOnFocused;
  1065. }
  1066. if (ListType == ccltBoth)
  1067. {
  1068. Item->Tag = Item->Tag | CustomCommandBoth;
  1069. }
  1070. Item->Hint = CustomCommandHint(Command);
  1071. Item->ShortCut = Command->ShortCut;
  1072. Item->OnClick = CustomCommandClick;
  1073. Menu->Add(Item);
  1074. Result++;
  1075. }
  1076. }
  1077. return Result;
  1078. }
  1079. //---------------------------------------------------------------------------
  1080. void __fastcall TNonVisualDataModule::CustomCommandsCustomize(TObject *)
  1081. {
  1082. PreferencesDialog(pmCustomCommands);
  1083. }
  1084. //---------------------------------------------------------------------------
  1085. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  1086. TTBCustomItem * Menu, bool OnFocused, bool Toolbar, TCustomCommandListType ListType, TStrings * HiddenCommands)
  1087. {
  1088. CreateCustomCommandsListMenu(WinConfiguration->CustomCommandList, Menu, OnFocused, Toolbar, ListType, 0, HiddenCommands);
  1089. TTBCustomItem * Item;
  1090. if ((ListType == ccltAll) || (ListType == ccltFile) || (ListType == ccltNonFile))
  1091. {
  1092. Item = new TTBXItem(Menu);
  1093. Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
  1094. Menu->Add(Item);
  1095. Item = new TTBXItem(Menu);
  1096. Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
  1097. if (Toolbar)
  1098. {
  1099. Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));
  1100. }
  1101. Menu->Add(Item);
  1102. }
  1103. TTBXSeparatorItem * Separator = AddMenuSeparator(Menu);
  1104. int ExtensionItems =
  1105. CreateCustomCommandsListMenu(WinConfiguration->ExtensionList, Menu, OnFocused, Toolbar, ListType, CustomCommandExtension, HiddenCommands);
  1106. Separator->Visible = (ExtensionItems > 0);
  1107. AddMenuSeparator(Menu);
  1108. if (((ListType == ccltFile) || ((ListType == ccltNonFile) && !OnFocused)) && DebugAlwaysTrue(!Toolbar))
  1109. {
  1110. Item = new TTBXSubmenuItem(Menu);
  1111. // copy the texts from the action, but do not use is as a handler, because it will duplicate the auxiliary commands in the submenu
  1112. Item->Action = (ListType == ccltFile) ? CustomCommandsNonFileAction : CustomCommandsFileAction;
  1113. Item->Action = NULL;
  1114. TCustomCommandListType SubListType = (ListType == ccltFile) ? ccltNonFile : ccltFile;
  1115. int CustomCommandItems = CreateCustomCommandsListMenu(WinConfiguration->CustomCommandList, Item, OnFocused, Toolbar, SubListType, 0, HiddenCommands);
  1116. TTBXSeparatorItem * Separator = AddMenuSeparator(Item);
  1117. int ExtensionItems = CreateCustomCommandsListMenu(WinConfiguration->ExtensionList, Item, OnFocused, Toolbar, SubListType, CustomCommandExtension, HiddenCommands);
  1118. Separator->Visible = (ExtensionItems > 0);
  1119. Item->Enabled = (CustomCommandItems + ExtensionItems > 0);
  1120. Menu->Add(Item);
  1121. }
  1122. if (!Toolbar && (ListType != ccltBoth))
  1123. {
  1124. Item = new TTBXItem(Menu);
  1125. Item->Action = CustomCommandsBandAction;
  1126. Menu->Add(Item);
  1127. }
  1128. Item = new TTBXItem(Menu);
  1129. Item->Action = CustomCommandsCustomizeAction;
  1130. if (ListType == ccltBoth)
  1131. {
  1132. // Hack. Bypass the Busy test in ExplorerActionsExecute.
  1133. Item->OnClick = CustomCommandsCustomize;
  1134. }
  1135. Menu->Add(Item);
  1136. }
  1137. //---------------------------------------------------------------------------
  1138. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  1139. TAction * Action, bool OnFocused, TCustomCommandListType ListType)
  1140. {
  1141. DebugAssert(Action);
  1142. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1143. if (Menu)
  1144. {
  1145. int PrevCount = Menu->Count;
  1146. CreateCustomCommandsMenu(Menu, OnFocused, false, ListType, NULL);
  1147. for (int Index = 0; Index < PrevCount; Index++)
  1148. {
  1149. Menu->Delete(0);
  1150. }
  1151. }
  1152. }
  1153. //---------------------------------------------------------------------------
  1154. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action, TCustomCommandListType ListType)
  1155. {
  1156. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1157. if (DebugAlwaysTrue(Menu != NULL))
  1158. {
  1159. bool OnFocused =
  1160. (Menu == RemoteDirViewPopupCustomCommandsMenu) || (Menu == LocalFilePopupCustomCommandsMenu) || (Menu == RemoteFilePopupCustomCommandsMenu);
  1161. CreateCustomCommandsMenu(Action, OnFocused, ListType);
  1162. }
  1163. }
  1164. //---------------------------------------------------------------------------
  1165. bool __fastcall TNonVisualDataModule::CheckCustomCommandsToolbarList(TTBXToolbar * Toolbar, TCustomCommandList * List, int & Index)
  1166. {
  1167. bool Changed = false;
  1168. int CommandIndex = 0;
  1169. while (!Changed && (CommandIndex < List->Count))
  1170. {
  1171. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  1172. const TCustomCommandType * Command = List->Commands[CommandIndex];
  1173. UnicodeString Caption = CustomCommandCaption(Command, true);
  1174. UnicodeString Hint = CustomCommandHint(Command);
  1175. Changed =
  1176. (Item->Caption != Caption) ||
  1177. (Item->Hint != Hint);
  1178. Index++;
  1179. CommandIndex++;
  1180. }
  1181. return Changed;
  1182. }
  1183. //---------------------------------------------------------------------------
  1184. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbarList(TTBXToolbar * Toolbar, TCustomCommandList * List, int & Index)
  1185. {
  1186. for (int CommandIndex = 0; CommandIndex < List->Count; CommandIndex++, Index++)
  1187. {
  1188. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  1189. DebugAssert((Item->Tag & CustomCommandIndexMask) == CommandIndex);
  1190. int State = ScpExplorer->CustomCommandState(*List->Commands[CommandIndex], false, ccltAll);
  1191. DebugAssert(State >= 0);
  1192. Item->Enabled = (State > 0);
  1193. }
  1194. }
  1195. //---------------------------------------------------------------------------
  1196. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
  1197. {
  1198. TCustomCommandList * CustomCommandList = WinConfiguration->CustomCommandList;
  1199. TCustomCommandList * ExtensionList = WinConfiguration->ExtensionList;
  1200. int AfterCustomCommandsCommandCount = 2; // ad hoc, last
  1201. int AdditionalCommands = AfterCustomCommandsCommandCount + 3; // custom/ext separator + separator, customize
  1202. int CommandCount = CustomCommandList->Count + ExtensionList->Count;
  1203. bool Changed = (CommandCount + AdditionalCommands != Toolbar->Items->Count);
  1204. if (!Changed)
  1205. {
  1206. int Index = 0;
  1207. Changed = CheckCustomCommandsToolbarList(Toolbar, CustomCommandList, Index);
  1208. if (!Changed)
  1209. {
  1210. Index += AfterCustomCommandsCommandCount;
  1211. Changed = (dynamic_cast<TTBXSeparatorItem *>(Toolbar->Items->Items[Index]) == NULL);
  1212. Index++;
  1213. if (!Changed)
  1214. {
  1215. Changed = CheckCustomCommandsToolbarList(Toolbar, ExtensionList, Index);
  1216. }
  1217. }
  1218. }
  1219. if (Changed)
  1220. {
  1221. Toolbar->BeginUpdate();
  1222. try
  1223. {
  1224. std::unique_ptr<TStrings> HiddenCommands(CreateSortedStringList());
  1225. for (int Index = 0; Index < Toolbar->Items->Count; Index++)
  1226. {
  1227. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  1228. if (IsCustomizableToolbarItem(Item) && !Item->Visible)
  1229. {
  1230. HiddenCommands->Add(Item->Name);
  1231. }
  1232. }
  1233. Toolbar->Items->Clear();
  1234. CreateCustomCommandsMenu(Toolbar->Items, false, true, ccltAll, HiddenCommands.get());
  1235. DebugAssert(CommandCount + AdditionalCommands == Toolbar->Items->Count);
  1236. }
  1237. __finally
  1238. {
  1239. Toolbar->EndUpdate();
  1240. }
  1241. }
  1242. else
  1243. {
  1244. int Index = 0;
  1245. UpdateCustomCommandsToolbarList(Toolbar, CustomCommandList, Index);
  1246. Index += AfterCustomCommandsCommandCount + 1;
  1247. UpdateCustomCommandsToolbarList(Toolbar, ExtensionList, Index);
  1248. }
  1249. }
  1250. //---------------------------------------------------------------------------
  1251. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  1252. {
  1253. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1254. DebugAssert(Item);
  1255. const TCustomCommandList * List = FLAGSET(Item->Tag, CustomCommandExtension) ? WinConfiguration->ExtensionList : WinConfiguration->CustomCommandList;
  1256. const TCustomCommandType * Command = List->Commands[Item->Tag & CustomCommandIndexMask];
  1257. if (FLAGCLEAR(Item->Tag, CustomCommandBoth))
  1258. {
  1259. ScpExplorer->ExecuteFileOperationCommand(foCustomCommand, osRemote,
  1260. FLAGSET(Item->Tag, CustomCommandOnFocused), false, const_cast<TCustomCommandType *>(Command));
  1261. }
  1262. else
  1263. {
  1264. ScpExplorer->BothCustomCommand(*Command);
  1265. }
  1266. }
  1267. //---------------------------------------------------------------------------
  1268. void __fastcall TNonVisualDataModule::CreateSessionColorMenu(TAction * Action)
  1269. {
  1270. if (DebugAlwaysTrue(Action->ActionComponent != NULL))
  1271. {
  1272. ::CreateSessionColorMenu(Action->ActionComponent, ScpExplorer->SessionColor,
  1273. SessionColorChange);
  1274. }
  1275. }
  1276. //---------------------------------------------------------------------------
  1277. void __fastcall TNonVisualDataModule::SessionColorChange(TColor Color)
  1278. {
  1279. ScpExplorer->SessionColor = Color;
  1280. }
  1281. //---------------------------------------------------------------------------
  1282. void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
  1283. {
  1284. StoredSessions->Reload();
  1285. CreateSessionListMenuLevel(
  1286. dynamic_cast<TTBCustomItem *>(Action->ActionComponent), 0, 0);
  1287. }
  1288. //---------------------------------------------------------------------------
  1289. UnicodeString __fastcall TNonVisualDataModule::GetSessionFolderRoot(
  1290. TSessionData * Data, int Level)
  1291. {
  1292. UnicodeString Path = Data->Name;
  1293. UnicodeString Root;
  1294. for (int ALevel = 0; ALevel < Level; ALevel++)
  1295. {
  1296. Root.Insert(CutToChar(Path, L'/', false) + L'/', Root.Length() + 1);
  1297. }
  1298. return Root;
  1299. }
  1300. //---------------------------------------------------------------------------
  1301. void __fastcall TNonVisualDataModule::CreateSessionListMenuLevel(
  1302. TTBCustomItem * Menu, int Index, int Level)
  1303. {
  1304. Menu->Clear();
  1305. TTBCustomItem * Item = new TTBXItem(Menu);
  1306. UnicodeString Root;
  1307. if (Level == 0)
  1308. {
  1309. Item->Action = SiteManagerAction;
  1310. Root = L"";
  1311. }
  1312. else
  1313. {
  1314. DebugAssert(Index < StoredSessions->Count);
  1315. TSessionData * Data = StoredSessions->Sessions[Index];
  1316. Root = GetSessionFolderRoot(Data, Level);
  1317. Item->Caption = LoadStr(SAVEDSESSIONFOLDER_THIS_OPEN);
  1318. Item->Tag = MAKELONG(Index, Level);
  1319. UnicodeString FolderName = Root;
  1320. if (DebugAlwaysTrue(!FolderName.IsEmpty() && FolderName[FolderName.Length()] == L'/'))
  1321. {
  1322. FolderName.Delete(FolderName.Length(), 1);
  1323. }
  1324. Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_THIS_HINT, (FolderName));
  1325. Item->OnClick = SessionFolderThisItemClick;
  1326. }
  1327. Menu->Insert(Menu->Count, Item);
  1328. AddMenuSeparator(Menu);
  1329. int FirstSession = Menu->Count;
  1330. UnicodeString PrevName;
  1331. while (Index < StoredSessions->Count)
  1332. {
  1333. TSessionData * Data = StoredSessions->Sessions[Index];
  1334. if (!AnsiSameText(Data->Name.SubString(1, Root.Length()), Root))
  1335. {
  1336. // Sessions are sorted, so no chance further sessions may match
  1337. break;
  1338. }
  1339. else if (!Data->IsWorkspace)
  1340. {
  1341. UnicodeString Name = Data->Name.SubString(Root.Length() + 1, Data->Name.Length() - Root.Length());
  1342. int P = Name.Pos(L'/');
  1343. if (P > 0)
  1344. {
  1345. Name.SetLength(P - 1);
  1346. }
  1347. if (Name != PrevName)
  1348. {
  1349. if (P > 0)
  1350. {
  1351. TTBCustomItem * Item = new TTBXSubmenuItem(Menu);
  1352. Item->Caption = Name;
  1353. Item->Tag = ((Level + 1) << 16) | Index; // MAKELONG
  1354. Item->ImageIndex = SavedSessionsAction2->ImageIndex;
  1355. Item->OnClick = SessionFolderItemClick;
  1356. Menu->Insert(FirstSession, Item);
  1357. FirstSession++;
  1358. }
  1359. else
  1360. {
  1361. TTBCustomItem * Item = new TTBXItem(Menu);
  1362. Item->Caption = Name;
  1363. Item->Tag = Index;
  1364. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  1365. Item->OnClick = SessionItemClick;
  1366. Menu->Insert(Menu->Count, Item);
  1367. }
  1368. PrevName = Name;
  1369. }
  1370. }
  1371. Index++;
  1372. }
  1373. }
  1374. //---------------------------------------------------------------------------
  1375. void __fastcall TNonVisualDataModule::SessionFolderItemClick(TObject * Sender)
  1376. {
  1377. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1378. DebugAssert(Item != NULL);
  1379. CreateSessionListMenuLevel(Item, LOWORD(Item->Tag), HIWORD(Item->Tag));
  1380. }
  1381. //---------------------------------------------------------------------------
  1382. void __fastcall TNonVisualDataModule::SessionFolderThisItemClick(TObject * Sender)
  1383. {
  1384. TTBCustomItem * Item = DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender));
  1385. int Index = LOWORD(Item->Tag);
  1386. int Level = HIWORD(Item->Tag);
  1387. UnicodeString Folder = GetSessionFolderRoot(StoredSessions->Sessions[Index], Level);
  1388. ScpExplorer->OpenFolderOrWorkspace(Folder);
  1389. }
  1390. //---------------------------------------------------------------------------
  1391. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  1392. {
  1393. DebugAssert(StoredSessions && (((TTBCustomItem *)Sender)->Tag < StoredSessions->Count));
  1394. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TTBCustomItem *)Sender)->Tag]);
  1395. }
  1396. //---------------------------------------------------------------------------
  1397. void __fastcall TNonVisualDataModule::CreateWorkspacesMenu(TAction * Action)
  1398. {
  1399. StoredSessions->Reload();
  1400. if (!StoredSessions->HasAnyWorkspace())
  1401. {
  1402. Abort();
  1403. }
  1404. else
  1405. {
  1406. TTBCustomItem * Menu =
  1407. DebugNotNull(dynamic_cast<TTBCustomItem *>(Action->ActionComponent));
  1408. Menu->Clear();
  1409. std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());
  1410. for (int Index = 0; Index < Workspaces->Count; Index++)
  1411. {
  1412. TTBCustomItem * Item = new TTBXItem(Menu);
  1413. Item->Caption = Workspaces->Strings[Index];
  1414. Item->Tag = Index;
  1415. Item->Hint = FMTLOAD(WORKSPACE_HINT, (Workspaces->Strings[Index]));
  1416. Item->OnClick = WorkspaceItemClick;
  1417. Menu->Insert(Menu->Count, Item);
  1418. }
  1419. }
  1420. }
  1421. //---------------------------------------------------------------------------
  1422. void __fastcall TNonVisualDataModule::WorkspaceItemClick(TObject * Sender)
  1423. {
  1424. std::unique_ptr<TStrings> Workspaces(StoredSessions->GetWorkspaces());
  1425. ScpExplorer->OpenFolderOrWorkspace(
  1426. Workspaces->Strings[DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender))->Tag]);
  1427. }
  1428. //---------------------------------------------------------------------------
  1429. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  1430. {
  1431. if (Index >= 0 && Index < 10)
  1432. {
  1433. return ShortCut((Word)(Index < 9 ? L'0' + 1 + Index : L'0'),
  1434. TShiftState() << ssAlt);
  1435. }
  1436. else
  1437. {
  1438. return scNone;
  1439. }
  1440. }
  1441. //---------------------------------------------------------------------------
  1442. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
  1443. {
  1444. TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1445. DebugAssert(OpenedSessionsMenu != NULL);
  1446. TTerminalManager * Manager = TTerminalManager::Instance();
  1447. TStrings * TerminalList = Manager->TerminalList;
  1448. int PrevCount = OpenedSessionsMenu->Count;
  1449. for (int Index = 0; Index < TerminalList->Count; Index++)
  1450. {
  1451. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  1452. DebugAssert(Terminal);
  1453. TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
  1454. Item->Caption = TerminalList->Strings[Index];
  1455. Item->Tag = int(Terminal);
  1456. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  1457. Item->Checked = (Manager->ActiveTerminal == Terminal);
  1458. Item->ShortCut = OpenSessionShortCut(Index);
  1459. Item->OnClick = OpenedSessionItemClick;
  1460. Item->RadioItem = true;
  1461. OpenedSessionsMenu->Add(Item);
  1462. }
  1463. for (int Index = 0; Index < PrevCount; Index++)
  1464. {
  1465. OpenedSessionsMenu->Delete(0);
  1466. }
  1467. }
  1468. //---------------------------------------------------------------------------
  1469. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  1470. {
  1471. TTerminalManager::Instance()->ActiveTerminal = (TManagedTerminal*)(((TMenuItem *)Sender)->Tag);
  1472. }
  1473. //---------------------------------------------------------------------------
  1474. void __fastcall TNonVisualDataModule::CreateEditorListMenu(TTBCustomItem * Menu, bool OnFocused)
  1475. {
  1476. DebugAssert(Menu != NULL);
  1477. int PrevCount = Menu->Count;
  1478. TTBCustomItem * Item;
  1479. Item = new TTBXItem(Menu);
  1480. Item->Action = OnFocused ? CurrentEditFocusedAction : CurrentEditAction;
  1481. Menu->Add(Item);
  1482. AddMenuSeparator(Menu);
  1483. Item = new TTBXItem(Menu);
  1484. Item->Action = OnFocused ? CurrentEditInternalFocusedAction : CurrentEditInternalAction;
  1485. Menu->Add(Item);
  1486. AddMenuSeparator(Menu);
  1487. TStringList * UsedEditors = CreateSortedStringList();
  1488. try
  1489. {
  1490. const TEditorList * EditorList = WinConfiguration->EditorList;
  1491. for (int Index = 0; Index < EditorList->Count; Index++)
  1492. {
  1493. const TEditorPreferences * Editor = EditorList->Editors[Index];
  1494. if ((Editor->Data->Editor == edExternal) &&
  1495. (UsedEditors->IndexOf(Editor->Data->ExternalEditor) < 0))
  1496. {
  1497. UsedEditors->Add(Editor->Data->ExternalEditor);
  1498. TTBCustomItem * Item = new TTBXItem(Menu);
  1499. Item->Caption = Editor->Name;
  1500. Item->Tag = Index;
  1501. Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
  1502. if (OnFocused)
  1503. {
  1504. Item->OnClick = EditorItemClickFocused;
  1505. }
  1506. else
  1507. {
  1508. Item->OnClick = EditorItemClick;
  1509. }
  1510. Menu->Add(Item);
  1511. }
  1512. }
  1513. Item = new TTBXItem(Menu);
  1514. Item->Action = OnFocused ? CurrentEditWithFocusedAction : CurrentEditWithAction;
  1515. Menu->Add(Item);
  1516. AddMenuSeparator(Menu);
  1517. Item = new TTBXItem(Menu);
  1518. Item->Action = EditorListCustomizeAction;
  1519. Menu->Add(Item);
  1520. for (int Index = 0; Index < PrevCount; Index++)
  1521. {
  1522. Menu->Delete(0);
  1523. }
  1524. }
  1525. __finally
  1526. {
  1527. delete UsedEditors;
  1528. }
  1529. }
  1530. //---------------------------------------------------------------------------
  1531. void __fastcall TNonVisualDataModule::DoEditorItemClick(TObject * Sender, bool OnFocused)
  1532. {
  1533. int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
  1534. const TEditorList * EditorList = WinConfiguration->EditorList;
  1535. // sanity check
  1536. if (Tag < EditorList->Count)
  1537. {
  1538. ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag]->Data,
  1539. true, OnFocused);
  1540. }
  1541. }
  1542. //---------------------------------------------------------------------------
  1543. void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
  1544. {
  1545. DoEditorItemClick(Sender, false);
  1546. }
  1547. //---------------------------------------------------------------------------
  1548. void __fastcall TNonVisualDataModule::EditorItemClickFocused(TObject * Sender)
  1549. {
  1550. DoEditorItemClick(Sender, true);
  1551. }
  1552. //---------------------------------------------------------------------------
  1553. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  1554. {
  1555. TAction * Action = NULL;
  1556. switch (ScpExplorer->DefaultQueueOperation())
  1557. {
  1558. case qoItemQuery:
  1559. Action = QueueItemQueryAction;
  1560. break;
  1561. case qoItemError:
  1562. Action = QueueItemErrorAction;
  1563. break;
  1564. case qoItemPrompt:
  1565. Action = QueueItemPromptAction;
  1566. break;
  1567. case qoItemExecute:
  1568. Action = QueueItemExecuteAction;
  1569. break;
  1570. case qoItemPause:
  1571. Action = QueueItemPauseAction;
  1572. break;
  1573. case qoItemResume:
  1574. Action = QueueItemResumeAction;
  1575. break;
  1576. }
  1577. TTBCustomItem * Item;
  1578. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  1579. {
  1580. Item = QueuePopup->Items->Items[Index];
  1581. TTBItemOptions O = Item->Options;
  1582. if ((Action != NULL) && (Item->Action == Action))
  1583. {
  1584. O << tboDefault;
  1585. }
  1586. else
  1587. {
  1588. O >> tboDefault;
  1589. }
  1590. Item->Options = O;
  1591. }
  1592. QueueSpeedComboBoxItemUpdate(QueuePopupSpeedComboBoxItem);
  1593. }
  1594. //---------------------------------------------------------------------------
  1595. void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
  1596. {
  1597. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  1598. unsigned short H, M, S, MS;
  1599. DecodeTime(Now(), H, M, S, MS);
  1600. int CurrentCompoundVer = Configuration->CompoundVersion;
  1601. CheckForUpdatesAction->ImageIndex =
  1602. ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
  1603. !Updates.Results.Disabled &&
  1604. ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
  1605. ((!Updates.Results.Critical || Updates.ShownResults) &&
  1606. ((Updates.Results.Version > CurrentCompoundVer) ||
  1607. !Updates.Results.Message.IsEmpty())))) ? 80 :
  1608. ((int(Updates.Period) <= 0) ? 81 : 63));
  1609. CheckForUpdatesAction->Visible = !IsUWP();
  1610. }
  1611. //---------------------------------------------------------------------------
  1612. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1613. {
  1614. if (ScpExplorer != NULL)
  1615. {
  1616. ScpExplorer->PreferencesDialog(APreferencesMode);
  1617. }
  1618. else
  1619. {
  1620. DoPreferencesDialog(APreferencesMode);
  1621. }
  1622. }
  1623. //---------------------------------------------------------------------------
  1624. void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action)
  1625. {
  1626. TCustomCommandType Command;
  1627. int State;
  1628. bool Defined = ScpExplorer->GetLastCustomCommand(
  1629. (Action == CustomCommandsLastFocusedAction), Command, State);
  1630. Action->Visible = Defined;
  1631. if (Defined)
  1632. {
  1633. UnicodeString TitleCommand = Command.Command;
  1634. int MaxTitleCommandLen = 20;
  1635. if (TitleCommand.Length() > MaxTitleCommandLen)
  1636. {
  1637. TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + Ellipsis;
  1638. }
  1639. Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (EscapeHotkey(TitleCommand)));
  1640. Action->Hint = Command.Command;
  1641. Action->Enabled = (State > 0);
  1642. }
  1643. }
  1644. //---------------------------------------------------------------------------
  1645. UnicodeString __fastcall TNonVisualDataModule::QueueItemSpeed(const UnicodeString & Text,
  1646. TTBXComboBoxItem * Item)
  1647. {
  1648. // Keep in sync with TProgressForm::ItemSpeed
  1649. unsigned long Speed = GetSpeedLimit(Text);
  1650. ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
  1651. UnicodeString Result = SetSpeedLimit(Speed);
  1652. SaveToHistory(Item->Strings, Result);
  1653. CustomWinConfiguration->History[L"SpeedLimit"] = Item->Strings;
  1654. return Result;
  1655. }
  1656. //---------------------------------------------------------------------------
  1657. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(
  1658. TObject * Sender)
  1659. {
  1660. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1661. QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);
  1662. }
  1663. //---------------------------------------------------------------------------
  1664. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(
  1665. TObject * Sender, UnicodeString & NewText, bool & /*Accept*/)
  1666. {
  1667. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1668. NewText = QueueItemSpeed(NewText, Item);
  1669. QueueItemSpeedAction->Text = NewText;
  1670. }
  1671. //---------------------------------------------------------------------------
  1672. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item)
  1673. {
  1674. // IDE often looses this link
  1675. Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;
  1676. Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;
  1677. }
  1678. //---------------------------------------------------------------------------
  1679. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item)
  1680. {
  1681. CopySpeedLimits(CustomWinConfiguration->History[L"SpeedLimit"], Item->Strings);
  1682. }
  1683. //---------------------------------------------------------------------------
  1684. void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action)
  1685. {
  1686. TAction * Current = CurrentQueueOnceEmptyAction();
  1687. if (Current != Action)
  1688. {
  1689. Current->Checked = false;
  1690. Action->Checked = true;
  1691. }
  1692. }
  1693. //---------------------------------------------------------------------------
  1694. void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction()
  1695. {
  1696. TAction * Current = CurrentQueueOnceEmptyAction();
  1697. Current->Checked = false;
  1698. if (Current == QueueIdleOnceEmptyAction)
  1699. {
  1700. QueueDisconnectOnceEmptyAction2->Checked = true;
  1701. }
  1702. else if (Current == QueueDisconnectOnceEmptyAction2)
  1703. {
  1704. QueueSuspendOnceEmptyAction2->Checked = true;
  1705. }
  1706. else if (Current == QueueSuspendOnceEmptyAction2)
  1707. {
  1708. QueueShutDownOnceEmptyAction2->Checked = true;
  1709. }
  1710. else if (Current == QueueShutDownOnceEmptyAction2)
  1711. {
  1712. QueueIdleOnceEmptyAction->Checked = true;
  1713. }
  1714. else
  1715. {
  1716. DebugFail();
  1717. }
  1718. }
  1719. //---------------------------------------------------------------------------
  1720. TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
  1721. {
  1722. TAction * Result;
  1723. if (QueueIdleOnceEmptyAction->Checked)
  1724. {
  1725. Result = QueueIdleOnceEmptyAction;
  1726. }
  1727. else if (QueueDisconnectOnceEmptyAction2->Checked)
  1728. {
  1729. Result = QueueDisconnectOnceEmptyAction2;
  1730. }
  1731. else if (QueueSuspendOnceEmptyAction2->Checked)
  1732. {
  1733. Result = QueueSuspendOnceEmptyAction2;
  1734. }
  1735. else if (QueueShutDownOnceEmptyAction2->Checked)
  1736. {
  1737. Result = QueueShutDownOnceEmptyAction2;
  1738. }
  1739. else
  1740. {
  1741. DebugFail();
  1742. }
  1743. return Result;
  1744. }
  1745. //---------------------------------------------------------------------------
  1746. TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation()
  1747. {
  1748. TOnceDoneOperation Result;
  1749. TBasicAction * Current = CurrentQueueOnceEmptyAction();
  1750. if (Current == QueueIdleOnceEmptyAction)
  1751. {
  1752. Result = odoIdle;
  1753. }
  1754. else if (Current == QueueDisconnectOnceEmptyAction2)
  1755. {
  1756. Result = odoDisconnect;
  1757. }
  1758. else if (Current == QueueSuspendOnceEmptyAction2)
  1759. {
  1760. Result = odoSuspend;
  1761. }
  1762. else if (Current == QueueShutDownOnceEmptyAction2)
  1763. {
  1764. Result = odoShutDown;
  1765. }
  1766. else
  1767. {
  1768. DebugFail();
  1769. }
  1770. return Result;
  1771. }
  1772. //---------------------------------------------------------------------------
  1773. void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation()
  1774. {
  1775. SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);
  1776. }
  1777. //---------------------------------------------------------------------------
  1778. void __fastcall TNonVisualDataModule::StartBusy()
  1779. {
  1780. FBusy++;
  1781. }
  1782. //---------------------------------------------------------------------------
  1783. void __fastcall TNonVisualDataModule::EndBusy()
  1784. {
  1785. FBusy--;
  1786. }
  1787. //---------------------------------------------------------------------------
  1788. bool __fastcall TNonVisualDataModule::GetBusy()
  1789. {
  1790. return
  1791. (FBusy > 0) ||
  1792. ((ScpExplorer != NULL) && ScpExplorer->IsBusy());
  1793. }
  1794. //---------------------------------------------------------------------------
  1795. void __fastcall TNonVisualDataModule::FocusedEditMenuItemPopup(TTBCustomItem * Sender,
  1796. bool /*FromLink*/)
  1797. {
  1798. CreateEditorListMenu(Sender, true);
  1799. }
  1800. //---------------------------------------------------------------------------
  1801. void __fastcall TNonVisualDataModule::EditMenuItemPopup(TTBCustomItem * Sender,
  1802. bool /*FromLink*/)
  1803. {
  1804. CreateEditorListMenu(Sender, false);
  1805. }
  1806. //---------------------------------------------------------------------------
  1807. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemAdjustImageIndex(
  1808. TTBXComboBoxItem * Sender, const UnicodeString /*AText*/, int /*AIndex*/, int & ImageIndex)
  1809. {
  1810. // Use fixed image (do not change image by item index)
  1811. ImageIndex = Sender->ImageIndex;
  1812. }
  1813. //---------------------------------------------------------------------------
  1814. void __fastcall TNonVisualDataModule::ToolbarButtonItemClick(TObject * Sender)
  1815. {
  1816. TTBCustomItem * Item = DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender));
  1817. TTBCustomItem * ButtonItem = reinterpret_cast<TTBCustomItem *>(Item->Tag);
  1818. ButtonItem->Visible = !ButtonItem->Visible;
  1819. }
  1820. //---------------------------------------------------------------------------
  1821. bool __fastcall TNonVisualDataModule::IsCustomizableToolbarItem(TTBCustomItem * Item)
  1822. {
  1823. return
  1824. ((dynamic_cast<TTBXItem *>(Item) != NULL) ||
  1825. (dynamic_cast<TTBXSubmenuItem *>(Item) != NULL)) &&
  1826. (Item->Action != CustomCommandsLastAction) &&
  1827. DebugAlwaysTrue(Item->Action != CustomCommandsLastFocusedAction);
  1828. }
  1829. //---------------------------------------------------------------------------
  1830. bool __fastcall TNonVisualDataModule::IsToolbarCustomizable()
  1831. {
  1832. bool Result = false;
  1833. if (FCustomizedToolbar != NULL)
  1834. {
  1835. for (int Index = 0; Index < FCustomizedToolbar->Items->Count; Index++)
  1836. {
  1837. if (IsCustomizableToolbarItem(FCustomizedToolbar->Items->Items[Index]))
  1838. {
  1839. Result = true;
  1840. break;
  1841. }
  1842. }
  1843. }
  1844. return Result;
  1845. }
  1846. //---------------------------------------------------------------------------
  1847. void __fastcall TNonVisualDataModule::CreateToolbarButtonsList()
  1848. {
  1849. if (FCustomizedToolbar != NULL)
  1850. {
  1851. TTBCustomItem * CustomizeItem = DebugNotNull(dynamic_cast<TTBCustomItem *>(CustomizeToolbarAction->ActionComponent));
  1852. CustomizeItem->Clear();
  1853. for (int Index = 0; Index < FCustomizedToolbar->Items->Count; Index++)
  1854. {
  1855. TTBCustomItem * ButtonItem = FCustomizedToolbar->Items->Items[Index];
  1856. TTBCustomItem * Item = NULL;
  1857. if (dynamic_cast<TTBSeparatorItem *>(ButtonItem) != NULL)
  1858. {
  1859. Item = new TTBSeparatorItem(CustomizeItem);
  1860. }
  1861. else if (IsCustomizableToolbarItem(ButtonItem))
  1862. {
  1863. Item = new TTBXItem(CustomizeItem);
  1864. Item->Caption = StripEllipsis(ButtonItem->Caption);
  1865. Item->ImageIndex = ButtonItem->ImageIndex;
  1866. Item->Tag = reinterpret_cast<int>(ButtonItem);
  1867. Item->OnClick = ToolbarButtonItemClick;
  1868. Item->Checked = ButtonItem->Visible;
  1869. }
  1870. if (Item != NULL)
  1871. {
  1872. CustomizeItem->Insert(CustomizeItem->Count, Item);
  1873. }
  1874. }
  1875. }
  1876. }
  1877. //---------------------------------------------------------------------------
  1878. void __fastcall TNonVisualDataModule::ControlContextPopup(TObject * Sender, const TPoint & MousePos)
  1879. {
  1880. TTBDock * Dock = dynamic_cast<TTBDock *>(Sender);
  1881. if (Dock != NULL)
  1882. {
  1883. // While we can identify toolbar for which context menu is popping up in OnExecute,
  1884. // we cannot in OnUpdate, so we have to remember it here.
  1885. FCustomizedToolbar = dynamic_cast<TTBCustomToolbar *>(Dock->ControlAtPos(MousePos, true, true, false));
  1886. }
  1887. else
  1888. {
  1889. FCustomizedToolbar = NULL;
  1890. }
  1891. }