NonVisual.cpp 80 KB

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