NonVisual.cpp 78 KB

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