NonVisual.cpp 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #pragma hdrstop
  4. #include <Common.h>
  5. #include "NonVisual.h"
  6. #include <CoreMain.h>
  7. #include <TextsWin.h>
  8. #include <Tools.h>
  9. #include <Setup.h>
  10. #include <Interface.h>
  11. #include "WinConfiguration.h"
  12. #include "TerminalManager.h"
  13. #include "TBX.hpp"
  14. #include "VCLCommon.h"
  15. #include <HistoryComboBox.hpp>
  16. //---------------------------------------------------------------------------
  17. #pragma package(smart_init)
  18. #pragma link "TB2Item"
  19. #pragma link "TBX"
  20. #pragma link "TB2ExtItems"
  21. #pragma link "TBXExtItems"
  22. #pragma link "TBXToolPals"
  23. #ifndef NO_RESOURCES
  24. #pragma resource "*.dfm"
  25. #endif
  26. TNonVisualDataModule *NonVisualDataModule;
  27. //---------------------------------------------------------------------------
  28. #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
  29. #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
  30. ((TCustomAction *)Action)->Enabled = (Condition); \
  31. if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
  32. Handled = true; } else
  33. #define UPDEX1(HandleAction, Condition, Other) UPDEX(HandleAction, Condition, Other, Other)
  34. #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
  35. ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
  36. #define UPDFUNC(HandleAction, Function) if (Action == HandleAction) { Function; Handled = true; } else
  37. #define EXE(HandleAction, Command) if (Action == HandleAction) { \
  38. Command; Handled = true; } else
  39. #define UPDACT(HandleAction, Command) \
  40. EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
  41. #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
  42. COMP ## Action->Visible = ScpExplorer->IsComponentPossible(fc ## COMP); \
  43. COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
  44. #define EXECOMP(COMP) EXE(COMP ## Action, \
  45. ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
  46. #define COLPROPS(SIDE) \
  47. ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
  48. #define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \
  49. SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \
  50. SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else
  51. #define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \
  52. if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \
  53. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
  54. else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )
  55. #define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \
  56. SIDE ## SortAscendingAction->Enabled = true; Handled = true; \
  57. SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else
  58. #define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \
  59. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
  60. #define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \
  61. CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \
  62. if (CurrentSortBy ## RCOL ## Action->Enabled) { \
  63. if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \
  64. CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \
  65. else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \
  66. } else CurrentSortBy ## RCOL ## Action->Checked = false; Handled = true; } else
  67. #define EXESORTC(COL, LCOL, RCOL) \
  68. EXE(CurrentSortBy ## COL ## Action, \
  69. Integer NewSortCol = \
  70. ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \
  71. if (COLPROPS(Current)->SortColumn == NewSortCol) \
  72. COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \
  73. else COLPROPS(Current)->SortColumn = NewSortCol \
  74. )
  75. #define UPDSHCOL(SIDE, PREFIX, COL) \
  76. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  77. ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])
  78. #define EXESHCOL(SIDE, PREFIX, COL) \
  79. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  80. COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])
  81. #define BAND_COMPONENTS \
  82. EMIT_BAND_COMPONENT(ExplorerMenuBand) \
  83. EMIT_BAND_COMPONENT(ExplorerAddressBand) \
  84. EMIT_BAND_COMPONENT(ExplorerToolbarBand) \
  85. EMIT_BAND_COMPONENT(ExplorerSelectionBand) \
  86. EMIT_BAND_COMPONENT(ExplorerSessionBand) \
  87. EMIT_BAND_COMPONENT(ExplorerPreferencesBand) \
  88. EMIT_BAND_COMPONENT(ExplorerSortBand) \
  89. EMIT_BAND_COMPONENT(ExplorerUpdatesBand) \
  90. EMIT_BAND_COMPONENT(ExplorerTransferBand) \
  91. EMIT_BAND_COMPONENT(ExplorerCustomCommandsBand) \
  92. EMIT_BAND_COMPONENT(CommanderMenuBand) \
  93. EMIT_BAND_COMPONENT(CommanderSessionBand) \
  94. EMIT_BAND_COMPONENT(CommanderPreferencesBand) \
  95. EMIT_BAND_COMPONENT(CommanderSortBand) \
  96. EMIT_BAND_COMPONENT(CommanderCommandsBand) \
  97. EMIT_BAND_COMPONENT(CommanderUpdatesBand) \
  98. EMIT_BAND_COMPONENT(CommanderTransferBand) \
  99. EMIT_BAND_COMPONENT(CommanderCustomCommandsBand) \
  100. EMIT_BAND_COMPONENT(CommanderLocalHistoryBand) \
  101. EMIT_BAND_COMPONENT(CommanderLocalNavigationBand) \
  102. EMIT_BAND_COMPONENT(CommanderLocalFileBand) \
  103. EMIT_BAND_COMPONENT(CommanderLocalSelectionBand) \
  104. EMIT_BAND_COMPONENT(CommanderRemoteHistoryBand) \
  105. EMIT_BAND_COMPONENT(CommanderRemoteNavigationBand) \
  106. EMIT_BAND_COMPONENT(CommanderRemoteFileBand) \
  107. EMIT_BAND_COMPONENT(CommanderRemoteSelectionBand)
  108. //---------------------------------------------------------------------------
  109. __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
  110. : TDataModule(Owner)
  111. {
  112. FListColumn = NULL;
  113. FSessionIdleTimerExecuting = false;
  114. FCustomizedToolbar = NULL;
  115. FBusy = 0;
  116. QueueSpeedComboBoxItem(QueuePopupSpeedComboBoxItem);
  117. }
  118. //---------------------------------------------------------------------------
  119. __fastcall TNonVisualDataModule::~TNonVisualDataModule()
  120. {
  121. }
  122. //---------------------------------------------------------------------------
  123. void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
  124. TBasicAction *Action, bool &Handled)
  125. {
  126. if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))
  127. {
  128. ((TAction *)Action)->Enabled = false;
  129. Handled = true;
  130. return;
  131. }
  132. void * Param;
  133. #define HasTerminal (ScpExplorer->Terminal != NULL) && ScpExplorer->Terminal->Active
  134. // CURRENT DIRVIEW
  135. #define EnabledSelectedOperation (ScpExplorer->EnableSelectedOperation[osCurrent])
  136. #define EnabledFocusedOperation (ScpExplorer->EnableFocusedOperation[osCurrent])
  137. #define EnabledSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osCurrent])
  138. #define EnabledFocusedFileOperation (ScpExplorer->EnableFocusedFileOperation[osCurrent])
  139. #define EnabledLocalSelectedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])
  140. #define EnabledLocalFocusedOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableFocusedOperation[osLocal])
  141. #define EnabledLocalSelectedFileOperation (ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedFileOperation[osLocal])
  142. #define EnabledRemoteSelectedOperation (ScpExplorer->EnableSelectedOperation[osRemote])
  143. #define EnabledRemoteFocusedOperation (ScpExplorer->EnableFocusedOperation[osRemote])
  144. #define EnabledRemoteSelectedFileOperation (ScpExplorer->EnableSelectedFileOperation[osRemote])
  145. // focused operation
  146. UPD(CurrentDeleteFocusedAction, EnabledFocusedOperation)
  147. UPD(CurrentPropertiesFocusedAction, EnabledFocusedOperation)
  148. UPD(CurrentEditFocusedAction, EnabledFocusedFileOperation &&
  149. !WinConfiguration->DisableOpenEdit)
  150. UPD(CurrentSystemMenuFocusedAction, EnabledFocusedOperation)
  151. UPD(CurrentEditWithFocusedAction, EnabledFocusedFileOperation &&
  152. !WinConfiguration->DisableOpenEdit)
  153. UPD(CurrentEditInternalFocusedAction, EnabledFocusedFileOperation &&
  154. !WinConfiguration->DisableOpenEdit)
  155. UPD(CurrentCopyToClipboardFocusedAction, EnabledFocusedOperation)
  156. // file operation
  157. UPD(CurrentRenameAction, EnabledFocusedOperation &&
  158. ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||
  159. ScpExplorer->Terminal->IsCapable[fcRename]))
  160. UPD(CurrentEditAction, EnabledSelectedFileOperation &&
  161. !WinConfiguration->DisableOpenEdit)
  162. UPD(CurrentEditInternalAction, EnabledSelectedFileOperation &&
  163. !WinConfiguration->DisableOpenEdit)
  164. UPD(CurrentEditWithAction, EnabledSelectedFileOperation &&
  165. !WinConfiguration->DisableOpenEdit)
  166. UPD(CurrentOpenAction, EnabledFocusedOperation &&
  167. !WinConfiguration->DisableOpenEdit)
  168. UPDEX1(CurrentAddEditLinkContextAction, ScpExplorer->CanAddEditLink(osCurrent),
  169. ((TAction *)Action)->Visible = ScpExplorer->LinkFocused())
  170. UPD(NewLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  171. // selected operation
  172. UPD(CurrentDeleteAction, EnabledSelectedOperation)
  173. UPD(CurrentDeleteAlternativeAction, EnabledSelectedOperation)
  174. UPD(CurrentPropertiesAction, EnabledSelectedOperation)
  175. UPD(CurrentCopyToClipboardAction, EnabledSelectedOperation)
  176. UPD(RemoteMoveToAction, EnabledSelectedOperation &&
  177. (DirView(osRemote) == DirView(osCurrent)) &&
  178. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  179. UPD(RemoteCopyToAction, EnabledSelectedOperation &&
  180. (DirView(osRemote) == DirView(osCurrent)))
  181. UPD(FileListToCommandLineAction, EnabledSelectedOperation)
  182. UPD(FileListToClipboardAction, EnabledSelectedOperation)
  183. UPD(FullFileListToClipboardAction, EnabledSelectedOperation)
  184. UPD(FileGenerateUrlAction2, EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
  185. UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT))
  186. UPD(CurrentAddEditLinkAction, ScpExplorer->CanAddEditLink(osCurrent))
  187. UPD(LockAction,
  188. EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)) &&
  189. ScpExplorer->Terminal->IsCapable[fcLocking])
  190. UPD(UnlockAction,
  191. EnabledSelectedOperation && (DirView(osRemote) == DirView(osCurrent)) &&
  192. ScpExplorer->Terminal->IsCapable[fcLocking])
  193. // local selected operation
  194. UPD(LocalCopyAction, HasTerminal && EnabledLocalSelectedOperation)
  195. UPD(LocalCopyQueueAction, HasTerminal && EnabledLocalSelectedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  196. UPD(LocalCopyNonQueueAction, HasTerminal && EnabledLocalSelectedOperation)
  197. UPD(LocalRenameAction, EnabledLocalSelectedOperation)
  198. UPD(LocalEditAction, EnabledLocalSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  199. UPD(LocalMoveAction, HasTerminal && EnabledLocalSelectedOperation)
  200. UPD(LocalCreateDirAction2, true)
  201. UPD(LocalDeleteAction, EnabledLocalSelectedOperation)
  202. UPD(LocalPropertiesAction, EnabledLocalSelectedOperation)
  203. UPD(LocalAddEditLinkAction2, ScpExplorer->CanAddEditLink(osLocal))
  204. UPD(LocalNewFileAction, !WinConfiguration->DisableOpenEdit)
  205. // local focused operation
  206. UPD(LocalCopyFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
  207. UPD(LocalCopyFocusedQueueAction, HasTerminal && EnabledLocalFocusedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  208. UPD(LocalCopyFocusedNonQueueAction, HasTerminal && EnabledLocalFocusedOperation)
  209. UPD(LocalMoveFocusedAction, HasTerminal && EnabledLocalFocusedOperation)
  210. // remote selected operation
  211. UPD(RemoteCopyAction, EnabledRemoteSelectedOperation)
  212. UPD(RemoteCopyQueueAction, EnabledRemoteSelectedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  213. UPD(RemoteCopyNonQueueAction, EnabledRemoteSelectedOperation)
  214. UPD(RemoteRenameAction, EnabledRemoteSelectedOperation &&
  215. ScpExplorer->Terminal->IsCapable[fcRename])
  216. UPD(RemoteEditAction, EnabledRemoteSelectedFileOperation && !WinConfiguration->DisableOpenEdit)
  217. UPD(RemoteMoveAction, EnabledRemoteSelectedOperation)
  218. UPD(RemoteCreateDirAction2, DirViewEnabled(osRemote))
  219. UPD(RemoteNewFileAction, DirViewEnabled(osRemote) && !WinConfiguration->DisableOpenEdit)
  220. UPD(RemoteDeleteAction, EnabledRemoteSelectedOperation)
  221. UPD(RemotePropertiesAction, EnabledRemoteSelectedOperation)
  222. UPD(RemoteAddEditLinkAction2, ScpExplorer->CanAddEditLink(osRemote))
  223. // remote focused operation
  224. UPD(RemoteCopyFocusedAction, EnabledRemoteFocusedOperation)
  225. UPD(RemoteCopyFocusedQueueAction, EnabledRemoteFocusedOperation && ScpExplorer->Terminal->IsCapable[fsBackgroundTransfers])
  226. UPD(RemoteCopyFocusedNonQueueAction, EnabledRemoteFocusedOperation)
  227. UPD(RemoteMoveFocusedAction, EnabledRemoteFocusedOperation)
  228. UPD(RemoteMoveToFocusedAction, EnabledFocusedOperation &&
  229. (DirView(osRemote) == DirView(osCurrent)) &&
  230. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  231. UPD(RemoteCopyToFocusedAction, EnabledFocusedOperation &&
  232. DirView(osRemote) == DirView(osCurrent))
  233. // directory
  234. UPD(CurrentCreateDirAction, DirViewEnabled(osCurrent))
  235. UPD(NewDirAction, DirViewEnabled(osCurrent))
  236. UPD(RemoteFindFilesAction, DirViewEnabled(osRemote))
  237. // selection
  238. UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
  239. UPD(SelectAction, DirView(osCurrent)->FilesCount)
  240. UPD(UnselectAction, DirView(osCurrent)->SelCount)
  241. UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
  242. UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
  243. UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
  244. UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)
  245. UPD(SelectSameExtAction, EnabledFocusedFileOperation)
  246. UPD(UnselectSameExtAction, EnabledFocusedFileOperation)
  247. UPD(PasteAction2, ScpExplorer->CanPasteFromClipBoard())
  248. UPD(LocalSelectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  249. UPD(LocalUnselectAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->SelCount)
  250. UPD(LocalSelectAllAction, ScpExplorer->HasDirView[osLocal] && DirView(osLocal)->FilesCount)
  251. UPD(RemoteSelectAction, DirView(osRemote)->FilesCount)
  252. UPD(RemoteUnselectAction, DirView(osRemote)->SelCount)
  253. UPD(RemoteSelectAllAction, DirView(osRemote)->FilesCount)
  254. //style
  255. UPDACT(CurrentCycleStyleAction,
  256. CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
  257. #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
  258. Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
  259. STYLEACTION(Icon)
  260. STYLEACTION(SmallIcon)
  261. STYLEACTION(List)
  262. STYLEACTION(Report)
  263. #undef STYLEACTION
  264. // REMOTE+LOCAL
  265. // back/forward
  266. #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
  267. UPDEX(SIDE ## DIRECTION ## Action, DirViewEnabled(os ## SIDE) && (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
  268. SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
  269. SIDE ## DIRECTION ## Action->Hint = L"")
  270. HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
  271. HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
  272. HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
  273. HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
  274. #undef HISTORYACTION
  275. #define PANEL_ACTIONS(SIDE) \
  276. UPD(SIDE ## ParentDirAction, DirViewEnabled(os ## SIDE) && !DirView(os ## SIDE)->IsRoot) \
  277. UPD(SIDE ## RootDirAction, DirViewEnabled(os ## SIDE) &&!DirView(os ## SIDE)->IsRoot) \
  278. UPD(SIDE ## HomeDirAction, DirViewEnabled(os ## SIDE)) \
  279. UPD(SIDE ## RefreshAction, DirViewEnabled(os ## SIDE) && DirView(os ## SIDE)->DirOK) \
  280. UPD(SIDE ## OpenDirAction, DirViewEnabled(os ## SIDE)) \
  281. UPD(SIDE ## ChangePathAction, DirViewEnabled(os ## SIDE)) \
  282. UPD(SIDE ## AddBookmarkAction, DirViewEnabled(os ## SIDE)) \
  283. UPD(SIDE ## PathToClipboardAction, DirViewEnabled(os ## SIDE)) \
  284. UPDEX1(SIDE ## FilterAction, DirViewEnabled(os ## SIDE), ((TAction *)Action)->Checked = !DirView(os ## SIDE)->Mask.IsEmpty())
  285. PANEL_ACTIONS(Local)
  286. PANEL_ACTIONS(Remote)
  287. #undef PANEL_ACTIONS
  288. UPD(LocalExploreDirectoryAction, true)
  289. // HELP
  290. UPD(AboutAction, true)
  291. UPD(HomepageAction, true)
  292. UPD(HistoryPageAction, true)
  293. UPD(TableOfContentsAction, true)
  294. UPD(ForumPageAction, true)
  295. UPDACT(CheckForUpdatesAction, ShowUpdatesUpdate())
  296. UPD(UpdatesPreferencesAction, true)
  297. UPD(DonatePageAction, true)
  298. UPD(DownloadPageAction, true)
  299. UPD(TipsAction, true)
  300. // VIEW
  301. UPDCOMP(SessionsTabs)
  302. UPDCOMP(StatusBar)
  303. UPDCOMP(ToolBar2)
  304. UPDCOMP(LocalStatusBar)
  305. UPDCOMP(RemoteStatusBar)
  306. UPDCOMP(CommandLinePanel)
  307. UPDCOMP(RemoteTree)
  308. UPDCOMP(LocalTree)
  309. #define EMIT_BAND_COMPONENT(COMP) UPDCOMP(COMP)
  310. BAND_COMPONENTS
  311. #undef EMIT_BAND_COMPONENT
  312. UPD(GoToCommandLineAction, true)
  313. UPD(GoToTreeAction, true)
  314. UPDEX(ShowHiddenFilesAction, true,
  315. ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
  316. UPDEX(FormatSizeBytesNoneAction, true,
  317. FormatSizeBytesNoneAction->Checked = (WinConfiguration->FormatSizeBytes == fbNone), )
  318. UPDEX(FormatSizeBytesKilobytesAction, true,
  319. FormatSizeBytesKilobytesAction->Checked = (WinConfiguration->FormatSizeBytes == fbKilobytes), )
  320. UPDEX(FormatSizeBytesShortAction, true,
  321. FormatSizeBytesShortAction->Checked = (WinConfiguration->FormatSizeBytes == fbShort), )
  322. UPDEX(AutoReadDirectoryAfterOpAction, true,
  323. AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )
  324. UPD(PreferencesAction, true)
  325. UPD(PresetsPreferencesAction, true)
  326. UPD(FileColorsPreferencesAction, true)
  327. UPDEX(LockToolbarsAction, true,
  328. LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
  329. UPDEX(SelectiveToolbarTextAction, true,
  330. SelectiveToolbarTextAction->Checked = WinConfiguration->SelectiveToolbarText, )
  331. UPDCOMP(CustomCommandsBand)
  332. UPD(ColorMenuAction, HasTerminal)
  333. UPD(GoToAddressAction, true)
  334. UPD(CustomizeToolbarAction, IsToolbarCustomizable())
  335. // SORT
  336. UPDSORTA(Local)
  337. UPDSORT(Local, dv, Name)
  338. UPDSORT(Local, dv, Ext)
  339. UPDSORT(Local, dv, Size)
  340. UPDSORT(Local, dv, Type)
  341. UPDSORT(Local, dv, Changed)
  342. UPDSORT(Local, dv, Attr)
  343. UPDSORTA(Remote)
  344. UPDSORT(Remote, uv, Name)
  345. UPDSORT(Remote, uv, Ext)
  346. UPDSORT(Remote, uv, Size)
  347. UPDSORT(Remote, uv, Changed)
  348. UPDSORT(Remote, uv, Rights)
  349. UPDSORT(Remote, uv, Owner)
  350. UPDSORT(Remote, uv, Group)
  351. UPDSORT(Remote, uv, Type)
  352. UPDSORTA(Current)
  353. UPDSORTC(dv, Name, uv, Name)
  354. UPDSORTC(dv, Ext, uv, Ext)
  355. UPDSORTC(dv, Size, uv, Size)
  356. UPDSORTC(dv, Type, uv, Type)
  357. UPDSORTC(dv, Changed, uv, Changed)
  358. UPDSORTC(dv, Attr, uv, Rights)
  359. UPDSORTC(dv, Name, uv, Owner)
  360. UPDSORTC(dv, Name, uv, Group)
  361. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  362. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  363. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*DebugFail()*/ )
  364. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  365. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*DebugFail()*/ )
  366. #undef COLVIEWPROPS
  367. // SHOW/HIDE COLUMN
  368. UPDSHCOL(Local, dv, Name)
  369. UPDSHCOL(Local, dv, Ext)
  370. UPDSHCOL(Local, dv, Size)
  371. UPDSHCOL(Local, dv, Type)
  372. UPDSHCOL(Local, dv, Changed)
  373. UPDSHCOL(Local, dv, Attr)
  374. UPDSHCOL(Remote, uv, Name)
  375. UPDSHCOL(Remote, uv, Ext)
  376. UPDSHCOL(Remote, uv, Size)
  377. UPDSHCOL(Remote, uv, Changed)
  378. UPDSHCOL(Remote, uv, Rights)
  379. UPDSHCOL(Remote, uv, Owner)
  380. UPDSHCOL(Remote, uv, Group)
  381. UPDSHCOL(Remote, uv, LinkTarget)
  382. UPDSHCOL(Remote, uv, Type)
  383. UPD(HideColumnAction, (ListColumn != NULL))
  384. UPD(BestFitColumnAction, (ListColumn != NULL))
  385. // SESSION
  386. UPD(NewSessionAction, true)
  387. UPD(SiteManagerAction, true)
  388. UPD(DuplicateSessionAction, HasTerminal)
  389. UPD(RenameSessionAction, HasTerminal)
  390. UPD(CloseSessionAction2, (ScpExplorer->Terminal != NULL))
  391. UPDEX1(DisconnectSessionAction, HasTerminal, DisconnectSessionAction->Visible = (ScpExplorer->Terminal == NULL) || !ScpExplorer->Terminal->Disconnected)
  392. UPDEX1(ReconnectSessionAction, (ScpExplorer->Terminal != NULL) && ScpExplorer->Terminal->Disconnected, ReconnectSessionAction->Visible = ReconnectSessionAction->Enabled)
  393. UPD(SavedSessionsAction2, true)
  394. UPD(WorkspacesAction, StoredSessions->HasAnyWorkspace())
  395. UPD(OpenedSessionsAction, HasTerminal)
  396. UPD(SaveCurrentSessionAction2, HasTerminal)
  397. UPD(SaveWorkspaceAction, HasTerminal)
  398. // COMMAND
  399. UPD(CompareDirectoriesAction, HasTerminal)
  400. UPD(SynchronizeAction, HasTerminal)
  401. UPD(FullSynchronizeAction, HasTerminal)
  402. UPD(ConsoleAction, ScpExplorer->CanConsole())
  403. UPD(PuttyAction, HasTerminal && TTerminalManager::Instance()->CanOpenInPutty())
  404. UPD(SynchronizeBrowsingAction, HasTerminal)
  405. UPD(CloseApplicationAction, true)
  406. UPD(FileSystemInfoAction, HasTerminal)
  407. UPD(SessionGenerateUrlAction2, HasTerminal)
  408. UPD(ClearCachesAction, HasTerminal && !ScpExplorer->Terminal->AreCachesEmpty)
  409. UPD(NewFileAction, DirViewEnabled(osCurrent) && !WinConfiguration->DisableOpenEdit)
  410. UPD(EditorListCustomizeAction, true)
  411. UPD(ChangePasswordAction, ScpExplorer->CanChangePassword())
  412. UPD(PrivateKeyUploadAction, ScpExplorer->CanPrivateKeyUpload())
  413. // CUSTOM COMMANDS
  414. UPD(CustomCommandsFileAction, true)
  415. UPD(CustomCommandsNonFileAction, true)
  416. UPD(CustomCommandsEnterAction, true)
  417. UPD(CustomCommandsEnterFocusedAction, true)
  418. UPDFUNC(CustomCommandsLastAction, CustomCommandsLastUpdate(CustomCommandsLastAction))
  419. UPDFUNC(CustomCommandsLastFocusedAction, CustomCommandsLastUpdate(CustomCommandsLastFocusedAction))
  420. UPD(CustomCommandsCustomizeAction, true)
  421. // QUEUE
  422. UPDEX(QueueEnableAction, HasTerminal, ((TAction *)Action)->Checked = ScpExplorer->GetQueueEnabled(), )
  423. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  424. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  425. UPDQUEUE(GoTo)
  426. UPDQUEUE(Preferences)
  427. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  428. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  429. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  430. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  431. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  432. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  433. UPDQUEUE(ItemDelete)
  434. UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
  435. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =
  436. !ScpExplorer->AllowQueueOperation(qoItemPause) &&
  437. !ScpExplorer->AllowQueueOperation(qoItemResume))
  438. UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
  439. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  440. UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
  441. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  442. UPDQUEUE(ItemUp)
  443. UPDQUEUE(ItemDown)
  444. UPDQUEUE(PauseAll)
  445. UPDQUEUE(ResumeAll)
  446. UPDQUEUE(DeleteAll)
  447. UPDQUEUE(DeleteAllDone)
  448. #undef UPDQUEUE
  449. UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &Param),
  450. QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(Param)),
  451. QueueItemSpeedAction->Text = L"")
  452. UPDACT(QueueToggleShowAction,
  453. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  454. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  455. ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  456. QUEUEACTION(Show)
  457. QUEUEACTION(HideWhenEmpty)
  458. QUEUEACTION(Hide)
  459. #undef QUEUEACTION
  460. UPDEX1(QueueCycleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty),
  461. QueueCycleOnceEmptyAction->ImageIndex = CurrentQueueOnceEmptyAction()->ImageIndex;
  462. QueueCycleOnceEmptyAction->Checked = !QueueIdleOnceEmptyAction->Checked)
  463. UPD(QueueIdleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  464. UPD(QueueDisconnectOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  465. UPD(QueueSuspendOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  466. UPD(QueueShutDownOnceEmptyAction2, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  467. UPDCOMP(CommanderPreferencesBand)
  468. UPDACT(QueueToolbarAction,
  469. ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  470. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar])
  471. ;
  472. }
  473. //---------------------------------------------------------------------------
  474. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  475. TBasicAction *Action, bool &Handled)
  476. {
  477. DebugAssert(ScpExplorer);
  478. if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
  479. {
  480. Handled = true;
  481. return;
  482. }
  483. ScpExplorer->BeforeAction();
  484. unsigned int ShortCutFlag = FLAGMASK((Action->ActionComponent == NULL), cocShortCutHint);
  485. {
  486. TAutoNestingCounter Counter(FBusy);
  487. // focused operation
  488. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, true))
  489. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, true))
  490. EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
  491. EXE(CurrentSystemMenuFocusedAction, ScpExplorer->DisplaySystemContextMenu())
  492. EXE(CurrentEditWithFocusedAction, ScpExplorer->ExecuteCurrentFileWith(true))
  493. EXE(CurrentEditInternalFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, true))
  494. EXE(CurrentCopyToClipboardFocusedAction, ScpExplorer->CopyFilesToClipboard(osCurrent, true))
  495. // operation
  496. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
  497. EXE(CurrentEditInternalAction, ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false))
  498. EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith(false))
  499. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  500. EXE(CurrentAddEditLinkAction, ScpExplorer->AddEditLink(osCurrent, false))
  501. EXE(CurrentAddEditLinkContextAction, ScpExplorer->AddEditLink(osCurrent, false))
  502. EXE(NewLinkAction, ScpExplorer->AddEditLink(osCurrent, true))
  503. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osCurrent, false))
  504. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false))
  505. EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osCurrent, false, false, (void*)true))
  506. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osCurrent, false))
  507. EXE(CurrentCopyToClipboardAction, ScpExplorer->CopyFilesToClipboard(osCurrent, false))
  508. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  509. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  510. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  511. EXE(FileGenerateUrlAction2, ScpExplorer->FileGenerateUrl())
  512. EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
  513. EXE(LockAction, ScpExplorer->ExecuteFileOperationCommand(foLock, osCurrent, false))
  514. EXE(UnlockAction, ScpExplorer->ExecuteFileOperationCommand(foUnlock, osCurrent, false))
  515. // local selected operation
  516. EXE(LocalCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, ShortCutFlag))
  517. EXE(LocalCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocQueue))
  518. EXE(LocalCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, false, cocNonQueue))
  519. EXE(LocalRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osLocal, false))
  520. EXE(LocalEditAction, ScpExplorer->ExecuteFile(osLocal, efDefaultEditor, NULL, true, false))
  521. EXE(LocalMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, false))
  522. EXE(LocalCreateDirAction2, ScpExplorer->CreateDirectory(osLocal))
  523. EXE(LocalDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osLocal, false))
  524. EXE(LocalPropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osLocal, false))
  525. EXE(LocalAddEditLinkAction2, ScpExplorer->AddEditLink(osLocal, false))
  526. EXE(LocalNewFileAction, ScpExplorer->EditNew(osLocal))
  527. // local focused operation
  528. EXE(LocalCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, ShortCutFlag))
  529. EXE(LocalCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocQueue))
  530. EXE(LocalCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osLocal, true, cocNonQueue))
  531. EXE(LocalMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osLocal, true))
  532. // remote selected operation
  533. EXE(RemoteCopyAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, ShortCutFlag))
  534. EXE(RemoteCopyQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocQueue))
  535. EXE(RemoteCopyNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, false, cocNonQueue))
  536. EXE(RemoteRenameAction, ScpExplorer->ExecuteFileOperationCommand(foRename, osRemote, false))
  537. EXE(RemoteEditAction, ScpExplorer->ExecuteFile(osRemote, efDefaultEditor, NULL, true, false))
  538. EXE(RemoteMoveAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, false))
  539. EXE(RemoteCreateDirAction2, ScpExplorer->CreateDirectory(osRemote))
  540. EXE(RemoteNewFileAction, ScpExplorer->EditNew(osRemote))
  541. EXE(RemoteDeleteAction, ScpExplorer->ExecuteFileOperationCommand(foDelete, osRemote, false))
  542. EXE(RemotePropertiesAction, ScpExplorer->ExecuteFileOperationCommand(foSetProperties, osRemote, false))
  543. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, false))
  544. EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, false))
  545. EXE(RemoteAddEditLinkAction2, ScpExplorer->AddEditLink(osRemote, false))
  546. // remote focused operation
  547. EXE(RemoteCopyFocusedAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, ShortCutFlag))
  548. EXE(RemoteCopyFocusedQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocQueue))
  549. EXE(RemoteCopyFocusedNonQueueAction, ScpExplorer->ExecuteCopyOperationCommand(osRemote, true, cocNonQueue))
  550. EXE(RemoteMoveFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foMove, osRemote, true))
  551. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteMove, osCurrent, true))
  552. EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperationCommand(foRemoteCopy, osCurrent, true))
  553. // directory
  554. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  555. EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
  556. EXE(RemoteFindFilesAction, ScpExplorer->RemoteFindFiles())
  557. //selection
  558. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  559. EXE(SelectAction, ScpExplorer->SelectByMask(osCurrent, true))
  560. EXE(UnselectAction, ScpExplorer->SelectByMask(osCurrent, false))
  561. EXE(SelectAllAction, ScpExplorer->SelectAll(osCurrent, smAll))
  562. EXE(InvertSelectionAction, ScpExplorer->SelectAll(osCurrent, smInvert))
  563. EXE(ClearSelectionAction, ScpExplorer->SelectAll(osCurrent, smNone))
  564. EXE(RestoreSelectionAction, ScpExplorer->RestoreSelectedNames(osCurrent))
  565. EXE(SelectSameExtAction, ScpExplorer->SelectSameExt(true))
  566. EXE(UnselectSameExtAction, ScpExplorer->SelectSameExt(false))
  567. EXE(LocalSelectAction, ScpExplorer->SelectByMask(osLocal, true))
  568. EXE(LocalUnselectAction, ScpExplorer->SelectByMask(osLocal, false))
  569. EXE(LocalSelectAllAction, ScpExplorer->SelectAll(osLocal, smAll))
  570. EXE(RemoteSelectAction, ScpExplorer->SelectByMask(osRemote, true))
  571. EXE(RemoteUnselectAction, ScpExplorer->SelectByMask(osRemote, false))
  572. EXE(RemoteSelectAllAction, ScpExplorer->SelectAll(osRemote, smAll))
  573. EXE(PasteAction2, ScpExplorer->PasteFromClipBoard())
  574. // style
  575. EXE(CurrentCycleStyleAction,
  576. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  577. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  578. )
  579. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  580. DirView(osCurrent)->ViewStyle = vs ## Style)
  581. STYLEACTION(Icon)
  582. STYLEACTION(SmallIcon)
  583. STYLEACTION(List)
  584. STYLEACTION(Report)
  585. #undef STYLEACTION
  586. #define PANEL_ACTIONS(SIDE) \
  587. EXE(SIDE ## BackAction, ScpExplorer->HistoryGo(os ## SIDE, -1)) \
  588. EXE(SIDE ## ForwardAction, ScpExplorer->HistoryGo(os ## SIDE, 1)) \
  589. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  590. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  591. EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \
  592. EXE(SIDE ## RefreshAction, ScpExplorer->ReloadDirectory(os ## SIDE)) \
  593. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  594. EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
  595. EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
  596. EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \
  597. EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE))
  598. PANEL_ACTIONS(Local)
  599. PANEL_ACTIONS(Remote)
  600. #undef PANEL_ACTIONS
  601. EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
  602. //HELP
  603. EXE(AboutAction, DoAboutDialog(Configuration))
  604. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  605. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  606. EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
  607. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  608. EXE(CheckForUpdatesAction, CheckForUpdates(false))
  609. EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
  610. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  611. EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
  612. EXE(TipsAction, ShowTips())
  613. // VIEW
  614. EXECOMP(SessionsTabs)
  615. EXECOMP(StatusBar)
  616. EXECOMP(ToolBar2)
  617. EXECOMP(LocalStatusBar)
  618. EXECOMP(RemoteStatusBar)
  619. #define EMIT_BAND_COMPONENT(COMP) EXECOMP(COMP)
  620. BAND_COMPONENTS
  621. #undef EMIT_BAND_COMPONENT
  622. EXECOMP(CommandLinePanel)
  623. EXECOMP(RemoteTree)
  624. EXECOMP(LocalTree)
  625. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  626. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  627. EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())
  628. EXE(FormatSizeBytesNoneAction, ScpExplorer->SetFormatSizeBytes(fbNone))
  629. EXE(FormatSizeBytesKilobytesAction, ScpExplorer->SetFormatSizeBytes(fbKilobytes))
  630. EXE(FormatSizeBytesShortAction, ScpExplorer->SetFormatSizeBytes(fbShort))
  631. EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())
  632. EXE(PreferencesAction, PreferencesDialog(::pmDefault) )
  633. EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
  634. EXE(FileColorsPreferencesAction, PreferencesDialog(pmFileColors) )
  635. EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
  636. EXE(SelectiveToolbarTextAction, WinConfiguration->SelectiveToolbarText = !WinConfiguration->SelectiveToolbarText)
  637. EXECOMP(CustomCommandsBand)
  638. EXE(ColorMenuAction, CreateSessionColorMenu(ColorMenuAction))
  639. EXE(GoToAddressAction, ScpExplorer->GoToAddress())
  640. EXE(CustomizeToolbarAction, CreateToolbarButtonsList())
  641. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  642. // SORT
  643. EXESORTA(Local)
  644. EXESORT(Local, dv, Name)
  645. EXESORT(Local, dv, Ext)
  646. EXESORT(Local, dv, Size)
  647. EXESORT(Local, dv, Type)
  648. EXESORT(Local, dv, Changed)
  649. EXESORT(Local, dv, Attr)
  650. EXESORTA(Remote)
  651. EXESORT(Remote, uv, Name)
  652. EXESORT(Remote, uv, Ext)
  653. EXESORT(Remote, uv, Size)
  654. EXESORT(Remote, uv, Changed)
  655. EXESORT(Remote, uv, Rights)
  656. EXESORT(Remote, uv, Owner)
  657. EXESORT(Remote, uv, Group)
  658. EXESORT(Remote, uv, Type)
  659. EXESORTA(Current)
  660. EXESORTC(Name, dvName, uvName)
  661. EXESORTC(Ext, dvExt, uvExt)
  662. EXESORTC(Size, dvSize, uvSize)
  663. EXESORTC(Type, dvType, uvType)
  664. EXESORTC(Changed, dvChanged, uvChanged)
  665. EXESORTC(Rights, dvAttr, uvRights)
  666. EXESORTC(Owner, dvName, uvOwner)
  667. EXESORTC(Group, dvName, uvGroup)
  668. EXE(SortColumnAscendingAction, DebugAssert(ListColumn);
  669. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  670. EXE(SortColumnDescendingAction, DebugAssert(ListColumn);
  671. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  672. // SHOW/HIDE COLUMN
  673. EXESHCOL(Local, dv, Name)
  674. EXESHCOL(Local, dv, Ext)
  675. EXESHCOL(Local, dv, Size)
  676. EXESHCOL(Local, dv, Type)
  677. EXESHCOL(Local, dv, Changed)
  678. EXESHCOL(Local, dv, Attr)
  679. EXESHCOL(Remote, uv, Name)
  680. EXESHCOL(Remote, uv, Ext)
  681. EXESHCOL(Remote, uv, Size)
  682. EXESHCOL(Remote, uv, Changed)
  683. EXESHCOL(Remote, uv, Rights)
  684. EXESHCOL(Remote, uv, Owner)
  685. EXESHCOL(Remote, uv, Group)
  686. EXESHCOL(Remote, uv, LinkTarget)
  687. EXESHCOL(Remote, uv, Type)
  688. EXE(HideColumnAction, DebugAssert(ListColumn);
  689. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  690. EXE(BestFitColumnAction, DebugAssert(ListColumn); ListColumn = NULL ) // TODO
  691. #undef COLVIEWPROPS
  692. // SESSION
  693. EXE(NewSessionAction, ScpExplorer->NewSession(false))
  694. EXE(SiteManagerAction, ScpExplorer->NewSession(true))
  695. EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession())
  696. EXE(RenameSessionAction, ScpExplorer->RenameSession())
  697. EXE(CloseSessionAction2, ScpExplorer->CloseSession())
  698. EXE(DisconnectSessionAction, ScpExplorer->DisconnectSession())
  699. EXE(ReconnectSessionAction, ScpExplorer->ReconnectSession())
  700. EXE(SavedSessionsAction2, CreateSessionListMenu(SavedSessionsAction2))
  701. EXE(WorkspacesAction, CreateWorkspacesMenu(WorkspacesAction))
  702. EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
  703. EXE(SaveCurrentSessionAction2, ScpExplorer->SaveCurrentSession())
  704. EXE(SaveWorkspaceAction, ScpExplorer->SaveWorkspace(false))
  705. // COMMAND
  706. EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
  707. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  708. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  709. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  710. EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
  711. EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())
  712. EXE(CloseApplicationAction, ScpExplorer->Close())
  713. EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
  714. EXE(SessionGenerateUrlAction2, ScpExplorer->SessionGenerateUrl())
  715. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  716. EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
  717. EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
  718. EXE(ChangePasswordAction, ScpExplorer->ChangePassword())
  719. EXE(PrivateKeyUploadAction, ScpExplorer->PrivateKeyUpload())
  720. // CUSTOM COMMANDS
  721. EXE(CustomCommandsFileAction, CreateCustomCommandsMenu(CustomCommandsFileAction, ccltFile))
  722. EXE(CustomCommandsNonFileAction, CreateCustomCommandsMenu(CustomCommandsNonFileAction, ccltNonFile))
  723. EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false))
  724. EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true))
  725. EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false))
  726. EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true))
  727. EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))
  728. // QUEUE
  729. EXE(QueueEnableAction, ScpExplorer->ToggleQueueEnabled())
  730. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  731. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  732. EXEQUEUE(GoTo)
  733. EXEQUEUE(Preferences)
  734. EXEQUEUE(ItemQuery)
  735. EXEQUEUE(ItemError)
  736. EXEQUEUE(ItemPrompt)
  737. EXEQUEUE(ItemDelete)
  738. EXEQUEUE(ItemExecute)
  739. EXEQUEUE(ItemPause)
  740. EXEQUEUE(ItemResume)
  741. EXEQUEUE(ItemUp)
  742. EXEQUEUE(ItemDown)
  743. EXEQUEUE(PauseAll)
  744. EXEQUEUE(ResumeAll)
  745. EXEQUEUE(DeleteAll)
  746. EXEQUEUE(DeleteAllDone)
  747. #undef EXEQUEUE
  748. EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
  749. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  750. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  751. if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
  752. Config.Show = qv ## SHOW; \
  753. WinConfiguration->QueueView = Config)
  754. QUEUEACTION(Show)
  755. QUEUEACTION(HideWhenEmpty)
  756. QUEUEACTION(Hide)
  757. #undef QUEUEACTION
  758. EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction())
  759. EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction))
  760. EXE(QueueDisconnectOnceEmptyAction2, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction2))
  761. EXE(QueueSuspendOnceEmptyAction2, SetQueueOnceEmptyAction(QueueSuspendOnceEmptyAction2))
  762. EXE(QueueShutDownOnceEmptyAction2, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction2))
  763. EXECOMP(QueueToolbar)
  764. EXE(QueueItemSpeedAction, )
  765. ;
  766. }
  767. DoIdle();
  768. }
  769. //---------------------------------------------------------------------------
  770. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  771. {
  772. // following actions needs to be updated even when all clients
  773. // are invisible, so the queue list toolbar button can be shown
  774. NonVisualDataModule->QueueItemQueryAction->Update();
  775. NonVisualDataModule->QueueItemErrorAction->Update();
  776. NonVisualDataModule->QueueItemPromptAction->Update();
  777. }
  778. //---------------------------------------------------------------------------
  779. #define CTRL TShiftState() << ssCtrl
  780. #define ALT TShiftState() << ssAlt
  781. #define SHIFT TShiftState() << ssShift
  782. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  783. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  784. #define NONE TShiftState()
  785. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  786. {
  787. // Directory
  788. CurrentCreateDirAction->ShortCut = ShortCut(L'D', CTRL);
  789. // File operation
  790. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  791. CurrentEditAction->ShortCut = ShortCut(L'E', CTRL);
  792. CurrentAddEditLinkAction->ShortCut = ShortCut(L'L', CTRLALT);
  793. CurrentEditInternalAction->ShortCut = 0;
  794. CurrentEditInternalFocusedAction->ShortCut = 0;
  795. // Focused operation
  796. RemoteCopyAction->ShortCut = ShortCut(L'T', CTRL);
  797. RemoteMoveAction->ShortCut = ShortCut(L'M', CTRL);
  798. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  799. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  800. RemoteMoveToFocusedAction->ShortCut = ShortCut(L'M', CTRLALT);
  801. // remote directory
  802. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  803. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  804. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  805. RemotePathToClipboardAction->ShortCut = ShortCut(L'P', CTRLSHIFT);
  806. // selected operation
  807. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_DELETE, SHIFT);
  808. RemoteMoveToAction->ShortCut = ShortCut(L'M', CTRLALT);
  809. // selection
  810. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  811. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  812. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  813. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  814. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);
  815. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  816. // commands
  817. NewFileAction->ShortCut = ShortCut(L'E', CTRLSHIFT);
  818. RemoteFindFilesAction->ShortCut = ShortCut(VK_F3, NONE);
  819. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  820. CloneShortcuts();
  821. }
  822. //---------------------------------------------------------------------------
  823. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  824. {
  825. bool ExplorerKeyboardShortcuts = WinConfiguration->ScpCommander.ExplorerKeyboardShortcuts;
  826. // Directory
  827. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  828. // File operation
  829. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  830. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  831. CurrentAddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  832. CurrentEditInternalAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  833. CurrentEditInternalFocusedAction->ShortCut = ShortCut(VK_F4, CTRLALT);
  834. // Focused operation
  835. RemoteCopyAction->ShortCut =
  836. ExplorerKeyboardShortcuts ? ShortCut(L'K', CTRL) : ShortCut(VK_F5, NONE);
  837. RemoteMoveAction->ShortCut = ShortCut(VK_F6, NONE);
  838. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  839. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  840. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  841. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  842. // remote directory
  843. RemoteOpenDirAction->ShortCut = ShortCut(L'O', CTRL);
  844. RemoteRefreshAction->ShortCut =
  845. ExplorerKeyboardShortcuts ? ShortCut(VK_F5, NONE) : ShortCut(L'R', CTRL);
  846. RemoteHomeDirAction->ShortCut = ShortCut(L'H', CTRL);
  847. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  848. // local directory
  849. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  850. // selected operation
  851. CurrentDeleteAction->SecondaryShortCuts->Clear();
  852. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  853. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);
  854. CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();
  855. CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));
  856. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  857. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  858. // selection
  859. SelectOneAction->ShortCut = VK_INSERT;
  860. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  861. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  862. SelectAllAction->ShortCut = ShortCut(L'A', CTRL);
  863. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  864. ClearSelectionAction->ShortCut = ShortCut(L'L', CTRLSHIFT);
  865. RestoreSelectionAction->ShortCut = ShortCut(L'R', CTRLSHIFT);
  866. // commands
  867. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  868. RemoteFindFilesAction->ShortCut =
  869. ExplorerKeyboardShortcuts ? ShortCut(VK_F3, NONE) : ShortCut(VK_F7, ALT);
  870. // legacy shortcut (can be removed when necessary)
  871. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  872. // Backward compatibility, can be abandoned, once there's a better use for Ctrl+T
  873. ConsoleAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(L'T', CTRL)));
  874. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  875. CloneShortcuts();
  876. }
  877. #undef CTRL
  878. #undef ALT
  879. #undef NONE
  880. //---------------------------------------------------------------------------
  881. void __fastcall TNonVisualDataModule::CloneShortcuts()
  882. {
  883. // Commands
  884. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  885. // File operation
  886. CurrentAddEditLinkContextAction->ShortCut = CurrentAddEditLinkAction->ShortCut;
  887. LocalAddEditLinkAction2->ShortCut = CurrentAddEditLinkAction->ShortCut;
  888. RemoteAddEditLinkAction2->ShortCut = CurrentAddEditLinkAction->ShortCut;
  889. RemoteNewFileAction->ShortCut = NewFileAction->ShortCut;
  890. LocalNewFileAction->ShortCut = NewFileAction->ShortCut;
  891. // local directory
  892. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  893. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  894. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  895. // selected operation
  896. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  897. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  898. // local selected operation
  899. LocalCopyAction->ShortCut = RemoteCopyAction->ShortCut;
  900. LocalRenameAction->ShortCut = CurrentRenameAction->ShortCut;
  901. LocalEditAction->ShortCut = CurrentEditAction->ShortCut;
  902. LocalMoveAction->ShortCut = RemoteMoveAction->ShortCut;
  903. LocalCreateDirAction2->ShortCut = CurrentCreateDirAction->ShortCut;
  904. LocalDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;
  905. LocalPropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;
  906. // local focused operation
  907. LocalCopyFocusedAction->ShortCut = LocalCopyAction->ShortCut;
  908. LocalMoveFocusedAction->ShortCut = LocalMoveAction->ShortCut;
  909. // remote selected operation
  910. RemoteRenameAction->ShortCut = CurrentRenameAction->ShortCut;
  911. RemoteEditAction->ShortCut = CurrentEditAction->ShortCut;
  912. RemoteCreateDirAction2->ShortCut = CurrentCreateDirAction->ShortCut;
  913. RemoteDeleteAction->ShortCut = CurrentDeleteAction->ShortCut;
  914. RemotePropertiesAction->ShortCut = CurrentPropertiesAction->ShortCut;
  915. // remote focused operation
  916. RemoteCopyFocusedAction->ShortCut = RemoteCopyAction->ShortCut;
  917. RemoteMoveFocusedAction->ShortCut = RemoteMoveAction->ShortCut;
  918. // selection
  919. LocalSelectAction->ShortCut = SelectAction->ShortCut;
  920. LocalUnselectAction->ShortCut = UnselectAction->ShortCut;
  921. LocalSelectAllAction->ShortCut = SelectAllAction->ShortCut;
  922. RemoteSelectAction->ShortCut = SelectAction->ShortCut;
  923. RemoteUnselectAction->ShortCut = UnselectAction->ShortCut;
  924. RemoteSelectAllAction->ShortCut = SelectAllAction->ShortCut;
  925. }
  926. //---------------------------------------------------------------------------
  927. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  928. {
  929. FScpExplorer = value;
  930. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  931. }
  932. //---------------------------------------------------------------------------
  933. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  934. TObject */*Sender*/)
  935. {
  936. DoIdle();
  937. }
  938. //---------------------------------------------------------------------------
  939. void __fastcall TNonVisualDataModule::DoIdle()
  940. {
  941. if (!FSessionIdleTimerExecuting)
  942. {
  943. FSessionIdleTimerExecuting = true;
  944. try
  945. {
  946. DebugAssert(ScpExplorer);
  947. ScpExplorer->Idle();
  948. }
  949. __finally
  950. {
  951. FSessionIdleTimerExecuting = false;
  952. }
  953. }
  954. }
  955. //---------------------------------------------------------------------------
  956. UnicodeString __fastcall TNonVisualDataModule::CustomCommandCaption(const TCustomCommandType * Command, bool Toolbar)
  957. {
  958. UnicodeString Result = Command->Name;
  959. if (Toolbar)
  960. {
  961. Result = StripHotkey(Result);
  962. Result = EscapeHotkey(Result);
  963. }
  964. return Result;
  965. }
  966. //---------------------------------------------------------------------------
  967. UnicodeString __fastcall TNonVisualDataModule::CustomCommandHint(const TCustomCommandType * Command)
  968. {
  969. UnicodeString Name = StripHotkey(Command->Name);
  970. UnicodeString LongHint =
  971. !Command->Description.IsEmpty() ? Command->Description : FMTLOAD(CUSTOM_COMMAND_HINT_LONG, (Name, Command->Command));
  972. UnicodeString Result = FORMAT(L"%s|%s", (Name, 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->Reload();
  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->Reload();
  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 = (TManagedTerminal*)(((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. CheckForUpdatesAction->Visible = !IsUWP();
  1531. }
  1532. //---------------------------------------------------------------------------
  1533. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1534. {
  1535. if (ScpExplorer != NULL)
  1536. {
  1537. ScpExplorer->PreferencesDialog(APreferencesMode);
  1538. }
  1539. else
  1540. {
  1541. DoPreferencesDialog(APreferencesMode);
  1542. }
  1543. }
  1544. //---------------------------------------------------------------------------
  1545. void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action)
  1546. {
  1547. TCustomCommandType Command;
  1548. int State;
  1549. bool Defined = ScpExplorer->GetLastCustomCommand(
  1550. (Action == CustomCommandsLastFocusedAction), Command, State);
  1551. Action->Visible = Defined;
  1552. if (Defined)
  1553. {
  1554. UnicodeString TitleCommand = Command.Command;
  1555. int MaxTitleCommandLen = 20;
  1556. if (TitleCommand.Length() > MaxTitleCommandLen)
  1557. {
  1558. TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + Ellipsis;
  1559. }
  1560. Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (EscapeHotkey(TitleCommand)));
  1561. Action->Hint = Command.Command;
  1562. Action->Enabled = (State > 0);
  1563. }
  1564. }
  1565. //---------------------------------------------------------------------------
  1566. UnicodeString __fastcall TNonVisualDataModule::QueueItemSpeed(const UnicodeString & Text,
  1567. TTBXComboBoxItem * Item)
  1568. {
  1569. // Keep in sync with TProgressForm::ItemSpeed
  1570. unsigned long Speed = GetSpeedLimit(Text);
  1571. ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
  1572. UnicodeString Result = SetSpeedLimit(Speed);
  1573. SaveToHistory(Item->Strings, Result);
  1574. CustomWinConfiguration->History[L"SpeedLimit"] = Item->Strings;
  1575. return Result;
  1576. }
  1577. //---------------------------------------------------------------------------
  1578. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(
  1579. TObject * Sender)
  1580. {
  1581. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1582. QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);
  1583. }
  1584. //---------------------------------------------------------------------------
  1585. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(
  1586. TObject * Sender, UnicodeString & NewText, bool & /*Accept*/)
  1587. {
  1588. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1589. NewText = QueueItemSpeed(NewText, Item);
  1590. QueueItemSpeedAction->Text = NewText;
  1591. }
  1592. //---------------------------------------------------------------------------
  1593. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item)
  1594. {
  1595. // IDE often looses this link
  1596. Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;
  1597. Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;
  1598. }
  1599. //---------------------------------------------------------------------------
  1600. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item)
  1601. {
  1602. CopySpeedLimits(CustomWinConfiguration->History[L"SpeedLimit"], Item->Strings);
  1603. }
  1604. //---------------------------------------------------------------------------
  1605. void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action)
  1606. {
  1607. TAction * Current = CurrentQueueOnceEmptyAction();
  1608. if (Current != Action)
  1609. {
  1610. Current->Checked = false;
  1611. Action->Checked = true;
  1612. }
  1613. }
  1614. //---------------------------------------------------------------------------
  1615. void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction()
  1616. {
  1617. TAction * Current = CurrentQueueOnceEmptyAction();
  1618. Current->Checked = false;
  1619. if (Current == QueueIdleOnceEmptyAction)
  1620. {
  1621. QueueDisconnectOnceEmptyAction2->Checked = true;
  1622. }
  1623. else if (Current == QueueDisconnectOnceEmptyAction2)
  1624. {
  1625. QueueSuspendOnceEmptyAction2->Checked = true;
  1626. }
  1627. else if (Current == QueueSuspendOnceEmptyAction2)
  1628. {
  1629. QueueShutDownOnceEmptyAction2->Checked = true;
  1630. }
  1631. else if (Current == QueueShutDownOnceEmptyAction2)
  1632. {
  1633. QueueIdleOnceEmptyAction->Checked = true;
  1634. }
  1635. else
  1636. {
  1637. DebugFail();
  1638. }
  1639. }
  1640. //---------------------------------------------------------------------------
  1641. TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
  1642. {
  1643. TAction * Result;
  1644. if (QueueIdleOnceEmptyAction->Checked)
  1645. {
  1646. Result = QueueIdleOnceEmptyAction;
  1647. }
  1648. else if (QueueDisconnectOnceEmptyAction2->Checked)
  1649. {
  1650. Result = QueueDisconnectOnceEmptyAction2;
  1651. }
  1652. else if (QueueSuspendOnceEmptyAction2->Checked)
  1653. {
  1654. Result = QueueSuspendOnceEmptyAction2;
  1655. }
  1656. else if (QueueShutDownOnceEmptyAction2->Checked)
  1657. {
  1658. Result = QueueShutDownOnceEmptyAction2;
  1659. }
  1660. else
  1661. {
  1662. DebugFail();
  1663. }
  1664. return Result;
  1665. }
  1666. //---------------------------------------------------------------------------
  1667. TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation()
  1668. {
  1669. TOnceDoneOperation Result;
  1670. TBasicAction * Current = CurrentQueueOnceEmptyAction();
  1671. if (Current == QueueIdleOnceEmptyAction)
  1672. {
  1673. Result = odoIdle;
  1674. }
  1675. else if (Current == QueueDisconnectOnceEmptyAction2)
  1676. {
  1677. Result = odoDisconnect;
  1678. }
  1679. else if (Current == QueueSuspendOnceEmptyAction2)
  1680. {
  1681. Result = odoSuspend;
  1682. }
  1683. else if (Current == QueueShutDownOnceEmptyAction2)
  1684. {
  1685. Result = odoShutDown;
  1686. }
  1687. else
  1688. {
  1689. DebugFail();
  1690. }
  1691. return Result;
  1692. }
  1693. //---------------------------------------------------------------------------
  1694. void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation()
  1695. {
  1696. SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);
  1697. }
  1698. //---------------------------------------------------------------------------
  1699. void __fastcall TNonVisualDataModule::StartBusy()
  1700. {
  1701. FBusy++;
  1702. }
  1703. //---------------------------------------------------------------------------
  1704. void __fastcall TNonVisualDataModule::EndBusy()
  1705. {
  1706. FBusy--;
  1707. }
  1708. //---------------------------------------------------------------------------
  1709. bool __fastcall TNonVisualDataModule::GetBusy()
  1710. {
  1711. return
  1712. (FBusy > 0) ||
  1713. ((ScpExplorer != NULL) && ScpExplorer->IsBusy());
  1714. }
  1715. //---------------------------------------------------------------------------
  1716. void __fastcall TNonVisualDataModule::FocusedEditMenuItemPopup(TTBCustomItem * Sender,
  1717. bool /*FromLink*/)
  1718. {
  1719. CreateEditorListMenu(Sender, true);
  1720. }
  1721. //---------------------------------------------------------------------------
  1722. void __fastcall TNonVisualDataModule::EditMenuItemPopup(TTBCustomItem * Sender,
  1723. bool /*FromLink*/)
  1724. {
  1725. CreateEditorListMenu(Sender, false);
  1726. }
  1727. //---------------------------------------------------------------------------
  1728. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemAdjustImageIndex(
  1729. TTBXComboBoxItem * Sender, const UnicodeString /*AText*/, int /*AIndex*/, int & ImageIndex)
  1730. {
  1731. // Use fixed image (do not change image by item index)
  1732. ImageIndex = Sender->ImageIndex;
  1733. }
  1734. //---------------------------------------------------------------------------
  1735. void __fastcall TNonVisualDataModule::ToolbarButtonItemClick(TObject * Sender)
  1736. {
  1737. TTBCustomItem * Item = DebugNotNull(dynamic_cast<TTBCustomItem *>(Sender));
  1738. TTBCustomItem * ButtonItem = reinterpret_cast<TTBCustomItem *>(Item->Tag);
  1739. ButtonItem->Visible = !ButtonItem->Visible;
  1740. }
  1741. //---------------------------------------------------------------------------
  1742. bool __fastcall TNonVisualDataModule::IsCustomizableToolbarItem(TTBCustomItem * Item)
  1743. {
  1744. return
  1745. (dynamic_cast<TTBXItem *>(Item) != NULL) ||
  1746. (dynamic_cast<TTBXSubmenuItem *>(Item) != NULL);
  1747. }
  1748. //---------------------------------------------------------------------------
  1749. bool __fastcall TNonVisualDataModule::IsToolbarCustomizable()
  1750. {
  1751. bool Result = false;
  1752. if (FCustomizedToolbar != NULL)
  1753. {
  1754. for (int Index = 0; Index < FCustomizedToolbar->Items->Count; Index++)
  1755. {
  1756. if (IsCustomizableToolbarItem(FCustomizedToolbar->Items->Items[Index]))
  1757. {
  1758. Result = true;
  1759. break;
  1760. }
  1761. }
  1762. }
  1763. return Result;
  1764. }
  1765. //---------------------------------------------------------------------------
  1766. void __fastcall TNonVisualDataModule::CreateToolbarButtonsList()
  1767. {
  1768. if (FCustomizedToolbar != NULL)
  1769. {
  1770. TTBCustomItem * CustomizeItem = DebugNotNull(dynamic_cast<TTBCustomItem *>(CustomizeToolbarAction->ActionComponent));
  1771. CustomizeItem->Clear();
  1772. for (int Index = 0; Index < FCustomizedToolbar->Items->Count; Index++)
  1773. {
  1774. TTBCustomItem * ButtonItem = FCustomizedToolbar->Items->Items[Index];
  1775. TTBCustomItem * Item = NULL;
  1776. if (dynamic_cast<TTBSeparatorItem *>(ButtonItem) != NULL)
  1777. {
  1778. Item = new TTBSeparatorItem(CustomizeItem);
  1779. }
  1780. else if (IsCustomizableToolbarItem(ButtonItem))
  1781. {
  1782. Item = new TTBXItem(CustomizeItem);
  1783. Item->Caption = StripEllipsis(ButtonItem->Caption);
  1784. Item->ImageIndex = ButtonItem->ImageIndex;
  1785. Item->Tag = reinterpret_cast<int>(ButtonItem);
  1786. Item->OnClick = ToolbarButtonItemClick;
  1787. Item->Checked = ButtonItem->Visible;
  1788. }
  1789. if (Item != NULL)
  1790. {
  1791. CustomizeItem->Insert(CustomizeItem->Count, Item);
  1792. }
  1793. }
  1794. }
  1795. }
  1796. //---------------------------------------------------------------------------
  1797. void __fastcall TNonVisualDataModule::ControlContextPopup(TObject * Sender, const TPoint & MousePos)
  1798. {
  1799. TTBDock * Dock = dynamic_cast<TTBDock *>(Sender);
  1800. if (Dock != NULL)
  1801. {
  1802. // While we can identify toolbar for which context menu is popping up in OnExecute,
  1803. // we cannot in OnUpdate, so we have to remeber it here.
  1804. FCustomizedToolbar = dynamic_cast<TTBCustomToolbar *>(Dock->ControlAtPos(MousePos, true, true, false));
  1805. }
  1806. else
  1807. {
  1808. FCustomizedToolbar = NULL;
  1809. }
  1810. }