NonVisual.cpp 89 KB

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