1
0

NonVisual.cpp 77 KB

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