1
0

NonVisual.cpp 90 KB

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