NonVisual.cpp 80 KB

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