NonVisual.cpp 90 KB

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