NonVisual.cpp 89 KB

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