1
0

NonVisual.cpp 84 KB

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