NonVisual.cpp 89 KB

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