NonVisual.cpp 90 KB

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