NonVisual.cpp 77 KB

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