NonVisual.cpp 88 KB

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