NonVisual.cpp 90 KB

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