NonVisual.cpp 88 KB

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