NonVisual.cpp 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508
  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. #ifndef NO_RESOURCES
  24. #pragma resource "*.dfm"
  25. #endif
  26. TNonVisualDataModule *NonVisualDataModule;
  27. //---------------------------------------------------------------------------
  28. #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
  29. #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
  30. ((TCustomAction *)Action)->Enabled = (Condition); \
  31. if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
  32. Handled = true; } else
  33. #define UPDEX1(HandleAction, Condition, Other) UPDEX(HandleAction, Condition, Other, Other)
  34. #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
  35. ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
  36. #define UPDFUNC(HandleAction, Function) if (Action == HandleAction) { Function; Handled = true; } else
  37. #define EXE(HandleAction, Command) if (Action == HandleAction) { \
  38. Command; Handled = true; } else
  39. #define UPDACT(HandleAction, Command) \
  40. EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
  41. #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
  42. COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
  43. #define EXECOMP(COMP) EXE(COMP ## Action, \
  44. ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
  45. #define COLPROPS(SIDE) \
  46. ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
  47. #define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \
  48. SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \
  49. SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else
  50. #define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \
  51. if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \
  52. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
  53. else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )
  54. #define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \
  55. SIDE ## SortAscendingAction->Enabled = true; Handled = true; \
  56. SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else
  57. #define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \
  58. COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
  59. #define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \
  60. CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \
  61. if (CurrentSortBy ## RCOL ## Action->Enabled) { \
  62. if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \
  63. CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \
  64. else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \
  65. } else CurrentSortBy ## RCOL ## Action->Checked = false; Handled = true; } else
  66. #define EXESORTC(COL, LCOL, RCOL) \
  67. EXE(CurrentSortBy ## COL ## Action, \
  68. Integer NewSortCol = \
  69. ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \
  70. if (COLPROPS(Current)->SortColumn == NewSortCol) \
  71. COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \
  72. else COLPROPS(Current)->SortColumn = NewSortCol \
  73. )
  74. #define UPDSHCOL(SIDE, PREFIX, COL) \
  75. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  76. ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])
  77. #define EXESHCOL(SIDE, PREFIX, COL) \
  78. EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
  79. COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])
  80. //---------------------------------------------------------------------------
  81. __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
  82. : TDataModule(Owner)
  83. {
  84. FListColumn = NULL;
  85. FSessionIdleTimerExecuting = false;
  86. FIdle = 0;
  87. QueueSpeedComboBoxItem(QueuePopupSpeedComboBoxItem);
  88. InitMenus(this);
  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(LogSelectAllAction, ValidLogMemo && LogMemo->Lines->Count)
  103. UPD(LogCopyAction, ValidLogMemo && LogMemo->SelLength)
  104. UPD(LogCloseAction, Configuration->Logging && (WinConfiguration->LogView == lvWindow))
  105. UPD(LogPreferencesAction, true)
  106. ;
  107. }
  108. //---------------------------------------------------------------------------
  109. void __fastcall TNonVisualDataModule::LogActionsExecute(
  110. TBasicAction *Action, bool &Handled)
  111. {
  112. FIdle--;
  113. try
  114. {
  115. TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
  116. assert(LogMemo && LogMemo->Parent);
  117. EXE(LogClearAction, LogMemo->SessionLog->Clear())
  118. EXE(LogSelectAllAction, LogMemo->SelectAll())
  119. EXE(LogCopyAction, LogMemo->CopyToClipboard())
  120. EXE(LogCloseAction, WinConfiguration->LogView = lvNone)
  121. EXE(LogPreferencesAction, PreferencesDialog(pmLogging));
  122. ;
  123. }
  124. __finally
  125. {
  126. assert(FIdle < 0);
  127. FIdle++;
  128. }
  129. DoIdle();
  130. }
  131. //---------------------------------------------------------------------------
  132. void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
  133. TBasicAction *Action, bool &Handled)
  134. {
  135. if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))
  136. {
  137. ((TAction *)Action)->Enabled = false;
  138. Handled = true;
  139. return;
  140. }
  141. void * Param;
  142. // CURRENT DIRVIEW
  143. bool EnableSelectedOperation = ScpExplorer->EnableSelectedOperation[osCurrent];
  144. bool EnableFocusedOperation = ScpExplorer->EnableFocusedOperation[osCurrent];
  145. bool EnableSelectedFileOperation = ScpExplorer->EnableSelectedFileOperation[osCurrent];
  146. bool EnableFocusedFileOperation = ScpExplorer->EnableFocusedFileOperation[osCurrent];
  147. // focused operation
  148. UPD(CurrentCopyFocusedAction, EnableFocusedOperation)
  149. UPD(CurrentMoveFocusedAction, EnableFocusedOperation)
  150. UPD(CurrentDeleteFocusedAction, EnableFocusedOperation)
  151. UPD(CurrentPropertiesFocusedAction, EnableFocusedOperation)
  152. UPD(RemoteMoveToFocusedAction, EnableFocusedOperation &&
  153. (DirView(osRemote) == DirView(osCurrent)) &&
  154. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  155. UPD(RemoteCopyToFocusedAction, EnableFocusedOperation &&
  156. DirView(osRemote) == DirView(osCurrent))
  157. UPD(CurrentEditFocusedAction, EnableFocusedFileOperation &&
  158. !WinConfiguration->DisableOpenEdit)
  159. // file operation
  160. UPD(CurrentRenameAction, EnableFocusedOperation &&
  161. ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||
  162. ScpExplorer->Terminal->IsCapable[fcRename]))
  163. UPD(CurrentEditAction, EnableSelectedFileOperation &&
  164. !WinConfiguration->DisableOpenEdit)
  165. UPD(CurrentEditAlternativeAction, EnableSelectedFileOperation &&
  166. !WinConfiguration->DisableOpenEdit)
  167. UPD(CurrentEditWithAction, EnableSelectedFileOperation &&
  168. !WinConfiguration->DisableOpenEdit)
  169. UPD(CurrentOpenAction, EnableFocusedOperation &&
  170. !WinConfiguration->DisableOpenEdit &&
  171. !DirView(osCurrent)->ItemIsDirectory(DirView(osCurrent)->ItemFocused))
  172. UPD(AddEditLinkAction, ScpExplorer->CanAddEditLink())
  173. UPDEX1(AddEditLinkContextAction, ScpExplorer->CanAddEditLink(),
  174. ((TAction *)Action)->Visible = ScpExplorer->LinkFocused())
  175. UPD(NewLinkAction, ScpExplorer->CanAddEditLink())
  176. // selected operaton
  177. UPD(CurrentCopyAction, EnableSelectedOperation)
  178. UPD(RemoteCopyAction, ScpExplorer->EnableSelectedOperation[osRemote])
  179. UPD(LocalCopyAction, ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])
  180. UPD(CurrentMoveAction, EnableSelectedOperation)
  181. UPD(CurrentDeleteAction, EnableSelectedOperation)
  182. UPD(CurrentDeleteAlternativeAction, EnableSelectedOperation)
  183. UPD(CurrentPropertiesAction, EnableSelectedOperation)
  184. UPD(RemoteMoveToAction, EnableSelectedOperation &&
  185. (DirView(osRemote) == DirView(osCurrent)) &&
  186. ScpExplorer->Terminal->IsCapable[fcRemoteMove])
  187. UPD(RemoteCopyToAction, EnableSelectedOperation &&
  188. (DirView(osRemote) == DirView(osCurrent)))
  189. UPD(FileListToCommandLineAction, EnableSelectedOperation)
  190. UPD(FileListToClipboardAction, EnableSelectedOperation)
  191. UPD(FullFileListToClipboardAction, EnableSelectedOperation)
  192. UPD(UrlToClipboardAction, EnableSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
  193. UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT));
  194. // directory
  195. UPD(CurrentCreateDirAction, true)
  196. UPD(NewDirAction, true)
  197. UPD(FindFilesAction, (DirView(osRemote) == DirView(osCurrent)))
  198. // selection
  199. UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
  200. UPD(SelectAction, DirView(osCurrent)->FilesCount)
  201. UPD(UnselectAction, DirView(osCurrent)->SelCount)
  202. UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
  203. UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
  204. UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
  205. UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)
  206. UPD(PasteAction, ScpExplorer->CanPasteFromClipBoard())
  207. //style
  208. UPDACT(CurrentCycleStyleAction,
  209. CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
  210. #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
  211. Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
  212. STYLEACTION(Icon)
  213. STYLEACTION(SmallIcon)
  214. STYLEACTION(List)
  215. STYLEACTION(Report)
  216. #undef STYLEACTION
  217. // REMOTE+LOCAL
  218. // back/forward
  219. #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
  220. UPDEX(SIDE ## DIRECTION ## Action, (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
  221. SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
  222. SIDE ## DIRECTION ## Action->Hint = "")
  223. HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
  224. HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
  225. HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
  226. HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
  227. #undef HISTORYACTION
  228. #define PANEL_ACTIONS(SIDE) \
  229. UPD(SIDE ## ParentDirAction, !DirView(os ## SIDE)->IsRoot) \
  230. UPD(SIDE ## RootDirAction, !DirView(os ## SIDE)->IsRoot) \
  231. UPD(SIDE ## HomeDirAction, true) \
  232. UPD(SIDE ## RefreshAction, DirView(os ## SIDE)->DirOK) \
  233. UPD(SIDE ## OpenDirAction, true) \
  234. UPD(SIDE ## ChangePathAction, true) \
  235. UPD(SIDE ## AddBookmarkAction, true) \
  236. UPD(SIDE ## PathToClipboardAction, true) \
  237. UPDEX1(SIDE ## FilterAction, true, ((TAction *)Action)->Checked = !DirView(os ## SIDE)->Mask.IsEmpty())
  238. PANEL_ACTIONS(Local)
  239. PANEL_ACTIONS(Remote)
  240. #undef PANEL_ACTIONS
  241. UPD(LocalExploreDirectoryAction, true)
  242. // HELP
  243. UPD(AboutAction, true)
  244. UPD(HomepageAction, true)
  245. UPD(HistoryPageAction, true)
  246. UPD(TableOfContentsAction, true)
  247. UPD(ForumPageAction, true)
  248. UPD(CheckForUpdatesAction, true)
  249. UPDACT(ShowUpdatesAction, ShowUpdatesUpdate())
  250. UPD(UpdatesPreferencesAction, true)
  251. UPD(DonatePageAction, true)
  252. UPD(DownloadPageAction, true)
  253. // VIEW
  254. UPDCOMP(StatusBar)
  255. UPDCOMP(ToolBar)
  256. UPDCOMP(LocalStatusBar)
  257. UPDCOMP(RemoteStatusBar)
  258. UPDCOMP(CommandLinePanel)
  259. UPDCOMP(RemoteTree)
  260. UPDCOMP(LocalTree)
  261. UPDCOMP(ExplorerMenuBand)
  262. UPDCOMP(ExplorerAddressBand)
  263. UPDCOMP(ExplorerToolbarBand)
  264. UPDCOMP(ExplorerSelectionBand)
  265. UPDCOMP(ExplorerSessionBand)
  266. UPDCOMP(ExplorerPreferencesBand)
  267. UPDCOMP(ExplorerSortBand)
  268. UPDCOMP(ExplorerUpdatesBand)
  269. UPDCOMP(ExplorerTransferBand)
  270. UPDCOMP(ExplorerCustomCommandsBand)
  271. UPDCOMP(CommanderMenuBand)
  272. UPDCOMP(CommanderSessionBand)
  273. UPDCOMP(CommanderPreferencesBand)
  274. UPDCOMP(CommanderSelectionBand)
  275. UPDCOMP(CommanderToolbarBand)
  276. UPDCOMP(CommanderSortBand)
  277. UPDCOMP(CommanderCommandsBand)
  278. UPDCOMP(CommanderUpdatesBand)
  279. UPDCOMP(CommanderTransferBand)
  280. UPDCOMP(CommanderUploadDownloadBand)
  281. UPDCOMP(CommanderCustomCommandsBand)
  282. UPDCOMP(CommanderLocalHistoryBand)
  283. UPDCOMP(CommanderLocalNavigationBand)
  284. UPDCOMP(CommanderRemoteHistoryBand)
  285. UPDCOMP(CommanderRemoteNavigationBand)
  286. UPD(GoToCommandLineAction, true)
  287. UPD(GoToTreeAction, true)
  288. UPDEX(ViewLogAction, Configuration->Logging,
  289. ViewLogAction->Checked = (WinConfiguration->LogView == lvWindow),
  290. ViewLogAction->Checked = false )
  291. UPDEX(ShowHiddenFilesAction, true,
  292. ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
  293. UPDEX(AutoReadDirectoryAfterOpAction, true,
  294. AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )
  295. UPD(PreferencesAction, true)
  296. UPD(PresetsPreferencesAction, true)
  297. UPDEX(LockToolbarsAction, true,
  298. LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
  299. UPDCOMP(CustomCommandsBand)
  300. UPD(ColorMenuAction, true)
  301. UPDACT(ColorDefaultAction,
  302. ColorDefaultAction->Checked = (ScpExplorer->SessionColor == 0));
  303. UPD(ColorPickAction, true);
  304. // SORT
  305. UPDSORTA(Local)
  306. UPDSORT(Local, dv, Name)
  307. UPDSORT(Local, dv, Ext)
  308. UPDSORT(Local, dv, Size)
  309. UPDSORT(Local, dv, Type)
  310. UPDSORT(Local, dv, Changed)
  311. UPDSORT(Local, dv, Attr)
  312. UPDSORTA(Remote)
  313. UPDSORT(Remote, uv, Name)
  314. UPDSORT(Remote, uv, Ext)
  315. UPDSORT(Remote, uv, Size)
  316. UPDSORT(Remote, uv, Changed)
  317. UPDSORT(Remote, uv, Rights)
  318. UPDSORT(Remote, uv, Owner)
  319. UPDSORT(Remote, uv, Group)
  320. UPDSORT(Remote, uv, Type)
  321. UPDSORTA(Current)
  322. UPDSORTC(dv, Name, uv, Name)
  323. UPDSORTC(dv, Ext, uv, Ext)
  324. UPDSORTC(dv, Size, uv, Size)
  325. UPDSORTC(dv, Type, uv, Type)
  326. UPDSORTC(dv, Changed, uv, Changed)
  327. UPDSORTC(dv, Attr, uv, Rights)
  328. UPDSORTC(dv, Name, uv, Owner)
  329. UPDSORTC(dv, Name, uv, Group)
  330. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  331. UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
  332. (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  333. UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
  334. (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*assert(false)*/ )
  335. #undef COLVIEWPROPS
  336. // SHOW/HIDE COLUMN
  337. UPDSHCOL(Local, dv, Name)
  338. UPDSHCOL(Local, dv, Ext)
  339. UPDSHCOL(Local, dv, Size)
  340. UPDSHCOL(Local, dv, Type)
  341. UPDSHCOL(Local, dv, Changed)
  342. UPDSHCOL(Local, dv, Attr)
  343. UPDSHCOL(Remote, uv, Name)
  344. UPDSHCOL(Remote, uv, Ext)
  345. UPDSHCOL(Remote, uv, Size)
  346. UPDSHCOL(Remote, uv, Changed)
  347. UPDSHCOL(Remote, uv, Rights)
  348. UPDSHCOL(Remote, uv, Owner)
  349. UPDSHCOL(Remote, uv, Group)
  350. UPDSHCOL(Remote, uv, LinkTarget)
  351. UPDSHCOL(Remote, uv, Type)
  352. UPD(HideColumnAction, (ListColumn != NULL))
  353. UPD(BestFitColumnAction, (ListColumn != NULL))
  354. // SESSION
  355. UPD(NewSessionAction, true)
  356. UPD(DuplicateSessionAction, true)
  357. UPD(CloseSessionAction, true)
  358. UPD(SavedSessionsAction, (StoredSessions->Count > 0))
  359. UPD(OpenedSessionsAction, true)
  360. UPD(SaveCurrentSessionAction, true)
  361. // COMMAND
  362. UPD(CompareDirectoriesAction, true)
  363. UPD(SynchronizeAction, true)
  364. UPD(FullSynchronizeAction, true)
  365. UPD(ConsoleAction, true)
  366. UPD(PuttyAction, TTerminalManager::Instance()->CanOpenInPutty())
  367. UPD(SynchronizeBrowsingAction, true)
  368. UPD(CloseApplicationAction, true)
  369. UPD(FileSystemInfoAction, true)
  370. UPD(ClearCachesAction, (ScpExplorer->Terminal != NULL) && !ScpExplorer->Terminal->AreCachesEmpty)
  371. UPD(NewFileAction, !WinConfiguration->DisableOpenEdit)
  372. UPD(EditorListCustomizeAction, true)
  373. // CUSTOM COMMANDS
  374. UPD(CustomCommandsAction, true)
  375. UPD(CustomCommandsEnterAction, true)
  376. UPD(CustomCommandsEnterFocusedAction, true)
  377. UPDFUNC(CustomCommandsLastAction, CustomCommandsLastUpdate(CustomCommandsLastAction))
  378. UPDFUNC(CustomCommandsLastFocusedAction, CustomCommandsLastUpdate(CustomCommandsLastFocusedAction))
  379. UPD(CustomCommandsCustomizeAction, true)
  380. // QUEUE
  381. #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
  382. ScpExplorer->AllowQueueOperation(qo ## OPERATION))
  383. UPDQUEUE(GoTo)
  384. UPDQUEUE(Preferences)
  385. UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
  386. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  387. UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
  388. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  389. UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
  390. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  391. UPDQUEUE(ItemDelete)
  392. UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
  393. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =
  394. !ScpExplorer->AllowQueueOperation(qoItemPause) &&
  395. !ScpExplorer->AllowQueueOperation(qoItemResume))
  396. UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
  397. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  398. UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
  399. ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
  400. UPDQUEUE(ItemUp)
  401. UPDQUEUE(ItemDown)
  402. UPDQUEUE(PauseAll)
  403. UPDQUEUE(ResumeAll)
  404. #undef UPDQUEUE
  405. UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &Param),
  406. QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(Param)),
  407. QueueItemSpeedAction->Text = "")
  408. UPDACT(QueueToggleShowAction,
  409. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
  410. #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
  411. ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
  412. QUEUEACTION(Show)
  413. QUEUEACTION(HideWhenEmpty)
  414. QUEUEACTION(Hide)
  415. #undef QUEUEACTION
  416. UPDACT(QueueCycleOnceEmptyAction,
  417. QueueCycleOnceEmptyAction->ImageIndex = CurrentQueueOnceEmptyAction()->ImageIndex;
  418. QueueCycleOnceEmptyAction->Checked = !QueueIdleOnceEmptyAction->Checked)
  419. UPD(QueueIdleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  420. UPD(QueueDisconnectOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  421. UPD(QueueShutDownOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
  422. UPDCOMP(CommanderPreferencesBand)
  423. UPDACT(QueueToolbarAction,
  424. ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
  425. ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar])
  426. ;
  427. }
  428. //---------------------------------------------------------------------------
  429. void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
  430. TBasicAction *Action, bool &Handled)
  431. {
  432. assert(ScpExplorer);
  433. if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
  434. {
  435. Handled = true;
  436. return;
  437. }
  438. ScpExplorer->BeforeAction();
  439. FIdle--;
  440. try
  441. {
  442. // focused operation
  443. EXE(CurrentCopyFocusedAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, true))
  444. EXE(CurrentMoveFocusedAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, true))
  445. EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, true))
  446. EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, true))
  447. EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, true))
  448. EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, true))
  449. EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
  450. // operation
  451. EXE(CurrentCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, false))
  452. EXE(RemoteCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osRemote, false))
  453. EXE(LocalCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osLocal, false))
  454. EXE(CurrentMoveAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, false))
  455. EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
  456. EXE(CurrentEditAlternativeAction, CreateEditorListMenu(CurrentEditAlternativeAction))
  457. EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith())
  458. EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
  459. EXE(AddEditLinkAction, ScpExplorer->AddEditLink(false))
  460. EXE(AddEditLinkContextAction, ScpExplorer->AddEditLink(false))
  461. EXE(NewLinkAction, ScpExplorer->AddEditLink(true))
  462. EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperation(foRename, osCurrent, false))
  463. EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, false))
  464. EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, false, false, (void*)true))
  465. EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, false))
  466. EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, false))
  467. EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, false))
  468. EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
  469. EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
  470. EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
  471. EXE(UrlToClipboardAction, ScpExplorer->PanelExport(osCurrent, peUrl, pedClipboard))
  472. EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
  473. // directory
  474. EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
  475. EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
  476. EXE(FindFilesAction, ScpExplorer->FindFiles())
  477. //selection
  478. EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
  479. EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true))
  480. EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false))
  481. EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll))
  482. EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert))
  483. EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone))
  484. EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames())
  485. EXE(PasteAction, ScpExplorer->PasteFromClipBoard())
  486. // style
  487. EXE(CurrentCycleStyleAction,
  488. if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
  489. else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
  490. )
  491. #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
  492. DirView(osCurrent)->ViewStyle = vs ## Style)
  493. STYLEACTION(Icon)
  494. STYLEACTION(SmallIcon)
  495. STYLEACTION(List)
  496. STYLEACTION(Report)
  497. #undef STYLEACTION
  498. #define PANEL_ACTIONS(SIDE) \
  499. EXE(SIDE ## BackAction, DirView(os ## SIDE)->HistoryGo(-1)) \
  500. EXE(SIDE ## ForwardAction, DirView(os ## SIDE)->HistoryGo(1)) \
  501. EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
  502. EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
  503. EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \
  504. EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \
  505. EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
  506. EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
  507. EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
  508. EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \
  509. EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE))
  510. PANEL_ACTIONS(Local)
  511. PANEL_ACTIONS(Remote)
  512. #undef PANEL_ACTIONS
  513. EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
  514. //HELP
  515. EXE(AboutAction, DoAboutDialog(Configuration))
  516. EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
  517. EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
  518. EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
  519. EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
  520. EXE(CheckForUpdatesAction, CheckForUpdates(false))
  521. EXE(ShowUpdatesAction, CheckForUpdates(true))
  522. EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
  523. EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
  524. EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
  525. // VIEW
  526. EXECOMP(StatusBar)
  527. EXECOMP(ToolBar)
  528. EXECOMP(LocalStatusBar)
  529. EXECOMP(RemoteStatusBar)
  530. EXECOMP(ExplorerMenuBand)
  531. EXECOMP(ExplorerAddressBand)
  532. EXECOMP(ExplorerToolbarBand)
  533. EXECOMP(ExplorerSelectionBand)
  534. EXECOMP(ExplorerSessionBand)
  535. EXECOMP(ExplorerPreferencesBand)
  536. EXECOMP(ExplorerSortBand)
  537. EXECOMP(ExplorerUpdatesBand)
  538. EXECOMP(ExplorerTransferBand)
  539. EXECOMP(ExplorerCustomCommandsBand)
  540. EXECOMP(CommanderMenuBand)
  541. EXECOMP(CommanderSessionBand)
  542. EXECOMP(CommanderPreferencesBand)
  543. EXECOMP(CommanderSelectionBand)
  544. EXECOMP(CommanderToolbarBand)
  545. EXECOMP(CommanderSortBand)
  546. EXECOMP(CommanderCommandsBand)
  547. EXECOMP(CommanderUpdatesBand)
  548. EXECOMP(CommanderTransferBand)
  549. EXECOMP(CommanderUploadDownloadBand)
  550. EXECOMP(CommanderCustomCommandsBand)
  551. EXECOMP(CommanderLocalHistoryBand)
  552. EXECOMP(CommanderLocalNavigationBand)
  553. EXECOMP(CommanderRemoteHistoryBand)
  554. EXECOMP(CommanderRemoteNavigationBand)
  555. EXECOMP(CommandLinePanel)
  556. EXECOMP(RemoteTree)
  557. EXECOMP(LocalTree)
  558. EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
  559. EXE(GoToTreeAction, ScpExplorer->GoToTree())
  560. EXE(ViewLogAction, WinConfiguration->LogView =
  561. (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) )
  562. EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())
  563. EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())
  564. EXE(PreferencesAction, PreferencesDialog(pmDefault) )
  565. EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
  566. EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
  567. EXECOMP(CustomCommandsBand)
  568. EXE(ColorMenuAction, );
  569. EXE(ColorDefaultAction, ScpExplorer->SessionColor = (TColor)0);
  570. EXE(ColorPickAction, ScpExplorer->SessionColorPick());
  571. #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
  572. // SORT
  573. EXESORTA(Local)
  574. EXESORT(Local, dv, Name)
  575. EXESORT(Local, dv, Ext)
  576. EXESORT(Local, dv, Size)
  577. EXESORT(Local, dv, Type)
  578. EXESORT(Local, dv, Changed)
  579. EXESORT(Local, dv, Attr)
  580. EXESORTA(Remote)
  581. EXESORT(Remote, uv, Name)
  582. EXESORT(Remote, uv, Ext)
  583. EXESORT(Remote, uv, Size)
  584. EXESORT(Remote, uv, Changed)
  585. EXESORT(Remote, uv, Rights)
  586. EXESORT(Remote, uv, Owner)
  587. EXESORT(Remote, uv, Group)
  588. EXESORT(Remote, uv, Type)
  589. EXESORTA(Current)
  590. EXESORTC(Name, dvName, uvName)
  591. EXESORTC(Ext, dvExt, uvExt)
  592. EXESORTC(Size, dvSize, uvSize)
  593. EXESORTC(Type, dvType, uvType)
  594. EXESORTC(Changed, dvChanged, uvChanged)
  595. EXESORTC(Rights, dvAttr, uvRights)
  596. EXESORTC(Owner, dvName, uvOwner)
  597. EXESORTC(Group, dvName, uvGroup)
  598. EXE(SortColumnAscendingAction, assert(ListColumn);
  599. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
  600. EXE(SortColumnDescendingAction, assert(ListColumn);
  601. COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
  602. // SHOW/HIDE COLUMN
  603. EXESHCOL(Local, dv, Name)
  604. EXESHCOL(Local, dv, Ext)
  605. EXESHCOL(Local, dv, Size)
  606. EXESHCOL(Local, dv, Type)
  607. EXESHCOL(Local, dv, Changed)
  608. EXESHCOL(Local, dv, Attr)
  609. EXESHCOL(Remote, uv, Name)
  610. EXESHCOL(Remote, uv, Ext)
  611. EXESHCOL(Remote, uv, Size)
  612. EXESHCOL(Remote, uv, Changed)
  613. EXESHCOL(Remote, uv, Rights)
  614. EXESHCOL(Remote, uv, Owner)
  615. EXESHCOL(Remote, uv, Group)
  616. EXESHCOL(Remote, uv, LinkTarget)
  617. EXESHCOL(Remote, uv, Type)
  618. EXE(HideColumnAction, assert(ListColumn);
  619. COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
  620. EXE(BestFitColumnAction, assert(ListColumn); ListColumn = NULL ) // TODO
  621. #undef COLVIEWPROPS
  622. // SESSION
  623. EXE(NewSessionAction, ScpExplorer->NewSession())
  624. EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession())
  625. EXE(CloseSessionAction, ScpExplorer->CloseSession())
  626. EXE(SavedSessionsAction, CreateSessionListMenu(SavedSessionsAction))
  627. EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
  628. EXE(SaveCurrentSessionAction, ScpExplorer->SaveCurrentSession())
  629. // COMMAND
  630. EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
  631. EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
  632. EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
  633. EXE(ConsoleAction, ScpExplorer->OpenConsole())
  634. EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
  635. EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())
  636. EXE(CloseApplicationAction, ScpExplorer->Close())
  637. EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
  638. EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
  639. EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
  640. EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
  641. // CUSTOM COMMANDS
  642. EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction))
  643. EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false))
  644. EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true))
  645. EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false))
  646. EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true))
  647. EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))
  648. // QUEUE
  649. #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
  650. ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
  651. EXEQUEUE(GoTo)
  652. EXEQUEUE(Preferences)
  653. EXEQUEUE(ItemQuery)
  654. EXEQUEUE(ItemError)
  655. EXEQUEUE(ItemPrompt)
  656. EXEQUEUE(ItemDelete)
  657. EXEQUEUE(ItemExecute)
  658. EXEQUEUE(ItemPause)
  659. EXEQUEUE(ItemResume)
  660. EXEQUEUE(ItemUp)
  661. EXEQUEUE(ItemDown)
  662. EXEQUEUE(PauseAll)
  663. EXEQUEUE(ResumeAll)
  664. #undef EXEQUEUE
  665. EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
  666. #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
  667. TQueueViewConfiguration Config = WinConfiguration->QueueView; \
  668. if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
  669. Config.Show = qv ## SHOW; \
  670. WinConfiguration->QueueView = Config)
  671. QUEUEACTION(Show)
  672. QUEUEACTION(HideWhenEmpty)
  673. QUEUEACTION(Hide)
  674. #undef QUEUEACTION
  675. EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction());
  676. EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction))
  677. EXE(QueueDisconnectOnceEmptyAction, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction))
  678. EXE(QueueShutDownOnceEmptyAction, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction))
  679. EXECOMP(QueueToolbar);
  680. EXE(QueueItemSpeedAction, )
  681. ;
  682. }
  683. __finally
  684. {
  685. assert(FIdle < 0);
  686. FIdle++;
  687. }
  688. DoIdle();
  689. }
  690. //---------------------------------------------------------------------------
  691. void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
  692. {
  693. // following actions needs to be updated even when all clients
  694. // are invisible, so the queue list toolbar button can be shown
  695. NonVisualDataModule->QueueItemQueryAction->Update();
  696. NonVisualDataModule->QueueItemErrorAction->Update();
  697. NonVisualDataModule->QueueItemPromptAction->Update();
  698. }
  699. //---------------------------------------------------------------------------
  700. #define CTRL TShiftState() << ssCtrl
  701. #define ALT TShiftState() << ssAlt
  702. #define SHIFT TShiftState() << ssShift
  703. #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
  704. #define CTRLALT TShiftState() << ssCtrl << ssAlt
  705. #define NONE TShiftState()
  706. void __fastcall TNonVisualDataModule::ExplorerShortcuts()
  707. {
  708. // Directory
  709. CurrentCreateDirAction->ShortCut = ShortCut('D', CTRL);
  710. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  711. // File operation
  712. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  713. CurrentEditAction->ShortCut = ShortCut('E', CTRL);
  714. AddEditLinkAction->ShortCut = ShortCut('L', CTRLALT);
  715. AddEditLinkContextAction->ShortCut = AddEditLinkAction->ShortCut;
  716. // Focused operation
  717. CurrentCopyFocusedAction->ShortCut = ShortCut('C', CTRL);
  718. CurrentMoveFocusedAction->ShortCut = ShortCut('M', CTRL);
  719. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
  720. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
  721. RemoteMoveToFocusedAction->ShortCut = ShortCut('M', CTRLALT);
  722. // remote directory
  723. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  724. RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
  725. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  726. RemotePathToClipboardAction->ShortCut = ShortCut('P', CTRLSHIFT);
  727. // selected operation
  728. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  729. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  730. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  731. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_DELETE, SHIFT);
  732. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  733. RemoteMoveToAction->ShortCut = ShortCut('M', CTRLALT);
  734. // selection
  735. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  736. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  737. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  738. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  739. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  740. RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
  741. // commands
  742. NewFileAction->ShortCut = ShortCut('E', CTRLSHIFT);
  743. FindFilesAction->ShortCut = ShortCut(VK_F3, NONE);
  744. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  745. }
  746. //---------------------------------------------------------------------------
  747. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  748. {
  749. // Directory
  750. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  751. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  752. // File operation
  753. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  754. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  755. AddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  756. AddEditLinkContextAction->ShortCut = AddEditLinkAction->ShortCut;
  757. // Focused operation
  758. CurrentCopyFocusedAction->ShortCut = ShortCut(VK_F5, NONE);
  759. CurrentMoveFocusedAction->ShortCut = ShortCut(VK_F6, NONE);
  760. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  761. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  762. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  763. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  764. // remote directory
  765. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  766. RemoteRefreshAction->ShortCut = ShortCut('R', CTRL);
  767. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  768. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  769. // local directory
  770. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  771. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  772. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  773. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  774. // selected operation
  775. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  776. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  777. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  778. CurrentDeleteAction->SecondaryShortCuts->Clear();
  779. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  780. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);
  781. CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();
  782. CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));
  783. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  784. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  785. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  786. // selection
  787. SelectOneAction->ShortCut = VK_INSERT;
  788. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  789. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  790. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  791. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  792. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  793. RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
  794. // commands
  795. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  796. FindFilesAction->ShortCut = ShortCut(VK_F7, ALT);
  797. // legacy shortcut (can be removed when necessary)
  798. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  799. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  800. }
  801. #undef CTRL
  802. #undef ALT
  803. #undef NONE
  804. //---------------------------------------------------------------------------
  805. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  806. {
  807. FScpExplorer = value;
  808. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  809. }
  810. //---------------------------------------------------------------------------
  811. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  812. TObject */*Sender*/)
  813. {
  814. DoIdle();
  815. }
  816. //---------------------------------------------------------------------------
  817. void __fastcall TNonVisualDataModule::DoIdle()
  818. {
  819. if (!FSessionIdleTimerExecuting)
  820. {
  821. FSessionIdleTimerExecuting = true;
  822. try
  823. {
  824. assert(ScpExplorer);
  825. ScpExplorer->Idle(FIdle >= 0);
  826. }
  827. __finally
  828. {
  829. FSessionIdleTimerExecuting = false;
  830. }
  831. }
  832. }
  833. //---------------------------------------------------------------------------
  834. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  835. TTBCustomItem * Menu, bool OnFocused, bool Toolbar, bool Both)
  836. {
  837. for (int Index = 0; Index < WinConfiguration->CustomCommandList->Count; Index++)
  838. {
  839. const TCustomCommandType * Command = WinConfiguration->CustomCommandList->Commands[Index];
  840. int State;
  841. if (!Both)
  842. {
  843. State = ScpExplorer->CustomCommandState(*Command, OnFocused);
  844. }
  845. else
  846. {
  847. State = ScpExplorer->BothCustomCommandState(*Command);
  848. }
  849. if (State >= 0)
  850. {
  851. TTBCustomItem * Item = new TTBXItem(Owner);
  852. Item->Caption = Command->Name;
  853. if (Toolbar)
  854. {
  855. Item->Caption = EscapeHotkey(StripHotkey(Item->Caption));
  856. }
  857. Item->Tag = Index;
  858. Item->Enabled = (State > 0);
  859. if (OnFocused)
  860. {
  861. Item->Tag = Item->Tag | 0x0100;
  862. }
  863. if (Both)
  864. {
  865. Item->Tag = Item->Tag | 0x0200;
  866. }
  867. Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (StripHotkey(Command->Name)));
  868. if (!Both)
  869. {
  870. Item->ShortCut = Command->ShortCut;
  871. }
  872. Item->OnClick = CustomCommandClick;
  873. Menu->Add(Item);
  874. }
  875. }
  876. TTBCustomItem * Item;
  877. if (!Both)
  878. {
  879. Item = new TTBXItem(Menu);
  880. Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
  881. Menu->Add(Item);
  882. Item = new TTBXItem(Menu);
  883. Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
  884. if (Toolbar)
  885. {
  886. Item->Caption = EscapeHotkey(StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT)));
  887. }
  888. Menu->Add(Item);
  889. }
  890. AddMenuSeparator(Menu);
  891. if (!Toolbar && !Both)
  892. {
  893. Item = new TTBXItem(Menu);
  894. Item->Action = CustomCommandsBandAction;
  895. Menu->Add(Item);
  896. }
  897. Item = new TTBXItem(Menu);
  898. Item->Action = CustomCommandsCustomizeAction;
  899. Menu->Add(Item);
  900. }
  901. //---------------------------------------------------------------------------
  902. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action)
  903. {
  904. assert(Action);
  905. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  906. if (Menu)
  907. {
  908. int PrevCount = Menu->Count;
  909. bool OnFocused = (Menu == RemoteDirViewCustomCommandsMenu);
  910. CreateCustomCommandsMenu(Menu, OnFocused, false, false);
  911. for (int Index = 0; Index < PrevCount; Index++)
  912. {
  913. Menu->Delete(0);
  914. }
  915. }
  916. }
  917. //---------------------------------------------------------------------------
  918. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
  919. {
  920. // can be called while explorer is being created
  921. if (ScpExplorer == NULL)
  922. {
  923. return;
  924. }
  925. int AdditionalCommands = 4;
  926. TCustomCommandList * CustomCommandList = WinConfiguration->CustomCommandList;
  927. bool Changed = (CustomCommandList->Count != (Toolbar->Items->Count - AdditionalCommands));
  928. if (!Changed)
  929. {
  930. int Index = 0;
  931. while (!Changed && (Index < CustomCommandList->Count))
  932. {
  933. Changed =
  934. (Toolbar->Items->Items[Index]->Caption !=
  935. EscapeHotkey(StripHotkey(CustomCommandList->Commands[Index]->Name)));
  936. Index++;
  937. }
  938. }
  939. if (Changed)
  940. {
  941. Toolbar->BeginUpdate();
  942. try
  943. {
  944. Toolbar->Items->Clear();
  945. CreateCustomCommandsMenu(Toolbar->Items, false, true, false);
  946. assert(CustomCommandList->Count == (Toolbar->Items->Count - AdditionalCommands));
  947. }
  948. __finally
  949. {
  950. Toolbar->EndUpdate();
  951. }
  952. }
  953. else
  954. {
  955. for (int Index = 0; Index < Toolbar->Items->Count - AdditionalCommands; Index++)
  956. {
  957. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  958. int CommandIndex = (Item->Tag & 0x00FF);
  959. assert(CommandIndex == Index);
  960. int State = ScpExplorer->CustomCommandState(
  961. *CustomCommandList->Commands[CommandIndex], false);
  962. assert(State >= 0);
  963. Item->Enabled = (State > 0);
  964. }
  965. }
  966. }
  967. //---------------------------------------------------------------------------
  968. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  969. {
  970. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  971. assert(Item);
  972. const TCustomCommandType * Command = WinConfiguration->CustomCommandList->Commands[Item->Tag & 0x00FF];
  973. if (FLAGCLEAR(Item->Tag, 0x0200))
  974. {
  975. ScpExplorer->ExecuteFileOperation(foCustomCommand, osRemote,
  976. FLAGSET(Item->Tag, 0x0100), false, const_cast<TCustomCommandType *>(Command));
  977. }
  978. else
  979. {
  980. ScpExplorer->BothCustomCommand(*Command);
  981. }
  982. }
  983. //---------------------------------------------------------------------------
  984. void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
  985. {
  986. StoredSessions->Load();
  987. if (StoredSessions->Count == 0)
  988. {
  989. Abort();
  990. }
  991. else
  992. {
  993. CreateSessionListMenuLevel(
  994. dynamic_cast<TTBCustomItem *>(Action->ActionComponent), 0, 0);
  995. }
  996. }
  997. //---------------------------------------------------------------------------
  998. void __fastcall TNonVisualDataModule::CreateSessionListMenuLevel(
  999. TTBCustomItem * Menu, int Index, int Level)
  1000. {
  1001. assert(Index < StoredSessions->Count);
  1002. TSessionData * Data = StoredSessions->Sessions[Index];
  1003. AnsiString Path = Data->Name;
  1004. AnsiString Root;
  1005. for (int ALevel = 0; ALevel < Level; ALevel++)
  1006. {
  1007. Root.Insert(::CutToChar(Path, '/', false) + '/', Root.Length() + 1);
  1008. }
  1009. Menu->Clear();
  1010. int FirstSession = 0;
  1011. AnsiString PrevName;
  1012. while (Index < StoredSessions->Count)
  1013. {
  1014. TSessionData * Data = StoredSessions->Sessions[Index];
  1015. if (!AnsiSameText(Data->Name.SubString(1, Root.Length()), Root))
  1016. {
  1017. break;
  1018. }
  1019. else
  1020. {
  1021. AnsiString Name = Data->Name.SubString(Root.Length() + 1, Data->Name.Length() - Root.Length());
  1022. int P = Name.Pos('/');
  1023. if (P > 0)
  1024. {
  1025. Name.SetLength(P - 1);
  1026. }
  1027. if (Name != PrevName)
  1028. {
  1029. if (P > 0)
  1030. {
  1031. TTBCustomItem * Item = new TTBXSubmenuItem(Menu);
  1032. Item->Caption = Name;
  1033. Item->Tag = ((Level + 1) << 16) | Index; // MAKELONG
  1034. Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_HINT, (Root + Name));
  1035. Item->ImageIndex = SavedSessionsAction->ImageIndex;
  1036. Item->OnClick = SessionFolderItemClick;
  1037. Menu->Insert(FirstSession, Item);
  1038. FirstSession++;
  1039. }
  1040. else
  1041. {
  1042. TTBCustomItem * Item = new TTBXItem(Menu);
  1043. Item->Caption = Name;
  1044. Item->Tag = Index;
  1045. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  1046. Item->OnClick = SessionItemClick;
  1047. Menu->Insert(Menu->Count, Item);
  1048. }
  1049. PrevName = Name;
  1050. }
  1051. }
  1052. Index++;
  1053. }
  1054. }
  1055. //---------------------------------------------------------------------------
  1056. void __fastcall TNonVisualDataModule::SessionFolderItemClick(TObject * Sender)
  1057. {
  1058. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1059. assert(Item != NULL);
  1060. CreateSessionListMenuLevel(Item, LOWORD(Item->Tag), HIWORD(Item->Tag));
  1061. }
  1062. //---------------------------------------------------------------------------
  1063. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  1064. {
  1065. assert(StoredSessions && (((TMenuItem *)Sender)->Tag < StoredSessions->Count));
  1066. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TMenuItem *)Sender)->Tag]);
  1067. }
  1068. //---------------------------------------------------------------------------
  1069. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  1070. {
  1071. if (Index >= 0 && Index < 10)
  1072. {
  1073. return ShortCut((Word)(Index < 9 ? '0' + 1 + Index : '0'),
  1074. TShiftState() << ssAlt);
  1075. }
  1076. else
  1077. {
  1078. return scNone;
  1079. }
  1080. }
  1081. //---------------------------------------------------------------------------
  1082. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
  1083. {
  1084. TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1085. assert(OpenedSessionsMenu != NULL);
  1086. TTerminalManager * Manager = TTerminalManager::Instance();
  1087. TStrings * TerminalList = Manager->TerminalList;
  1088. int PrevCount = OpenedSessionsMenu->Count;
  1089. for (int Index = 0; Index < TerminalList->Count; Index++)
  1090. {
  1091. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  1092. assert(Terminal);
  1093. TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
  1094. Item->Caption = TerminalList->Strings[Index];
  1095. Item->Tag = int(Terminal);
  1096. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  1097. Item->Checked = (Manager->ActiveTerminal == Terminal);
  1098. Item->ShortCut = OpenSessionShortCut(Index);
  1099. Item->OnClick = OpenedSessionItemClick;
  1100. Item->RadioItem = true;
  1101. OpenedSessionsMenu->Add(Item);
  1102. }
  1103. for (int Index = 0; Index < PrevCount; Index++)
  1104. {
  1105. OpenedSessionsMenu->Delete(0);
  1106. }
  1107. }
  1108. //---------------------------------------------------------------------------
  1109. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  1110. {
  1111. TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);
  1112. }
  1113. //---------------------------------------------------------------------------
  1114. void __fastcall TNonVisualDataModule::CreateEditorListMenu(TAction * Action)
  1115. {
  1116. assert(Action != NULL);
  1117. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1118. if (Menu != NULL)
  1119. {
  1120. int PrevCount = Menu->Count;
  1121. TTBCustomItem * Item = new TTBXItem(Menu);
  1122. Item->Caption = LoadStr(INTERNAL_EDITOR_NAME);
  1123. Item->Tag = -1;
  1124. Item->Hint = LoadStr(INTERNAL_EDITOR_HINT);
  1125. Item->OnClick = EditorItemClick;
  1126. Menu->Add(Item);
  1127. AddMenuSeparator(Menu);
  1128. TStringList * UsedEditors = new TStringList();
  1129. try
  1130. {
  1131. UsedEditors->CaseSensitive = false;
  1132. UsedEditors->Sorted = true;
  1133. const TEditorList * EditorList = WinConfiguration->EditorList;
  1134. for (int Index = 0; Index < EditorList->Count; Index++)
  1135. {
  1136. const TEditorPreferences * Editor = EditorList->Editors[Index];
  1137. if ((Editor->Data->Editor == edExternal) &&
  1138. (UsedEditors->IndexOf(Editor->Data->ExternalEditor) < 0))
  1139. {
  1140. UsedEditors->Add(Editor->Data->ExternalEditor);
  1141. TTBCustomItem * Item = new TTBXItem(Menu);
  1142. Item->Caption = Editor->Name;
  1143. Item->Tag = Index;
  1144. Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
  1145. Item->OnClick = EditorItemClick;
  1146. Menu->Add(Item);
  1147. }
  1148. }
  1149. Item = new TTBXItem(Menu);
  1150. Item->Action = CurrentEditWithAction;
  1151. Menu->Add(Item);
  1152. AddMenuSeparator(Menu);
  1153. Item = new TTBXItem(Menu);
  1154. Item->Action = EditorListCustomizeAction;
  1155. Menu->Add(Item);
  1156. for (int Index = 0; Index < PrevCount; Index++)
  1157. {
  1158. Menu->Delete(0);
  1159. }
  1160. }
  1161. __finally
  1162. {
  1163. delete UsedEditors;
  1164. }
  1165. }
  1166. }
  1167. //---------------------------------------------------------------------------
  1168. void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
  1169. {
  1170. int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
  1171. if (Tag < 0)
  1172. {
  1173. ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false);
  1174. }
  1175. else
  1176. {
  1177. const TEditorList * EditorList = WinConfiguration->EditorList;
  1178. // sanity check
  1179. if (Tag < EditorList->Count)
  1180. {
  1181. ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag]->Data,
  1182. true, false);
  1183. }
  1184. }
  1185. }
  1186. //---------------------------------------------------------------------------
  1187. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  1188. {
  1189. TAction * Action = NULL;
  1190. switch (ScpExplorer->DefaultQueueOperation())
  1191. {
  1192. case qoItemQuery:
  1193. Action = QueueItemQueryAction;
  1194. break;
  1195. case qoItemError:
  1196. Action = QueueItemErrorAction;
  1197. break;
  1198. case qoItemPrompt:
  1199. Action = QueueItemPromptAction;
  1200. break;
  1201. case qoItemExecute:
  1202. Action = QueueItemExecuteAction;
  1203. break;
  1204. case qoItemPause:
  1205. Action = QueueItemPauseAction;
  1206. break;
  1207. case qoItemResume:
  1208. Action = QueueItemResumeAction;
  1209. break;
  1210. }
  1211. TTBCustomItem * Item;
  1212. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  1213. {
  1214. Item = QueuePopup->Items->Items[Index];
  1215. TTBItemOptions O = Item->Options;
  1216. if ((Action != NULL) && (Item->Action == Action))
  1217. {
  1218. O << tboDefault;
  1219. }
  1220. else
  1221. {
  1222. O >> tboDefault;
  1223. }
  1224. Item->Options = O;
  1225. }
  1226. QueueSpeedComboBoxItemUpdate(QueuePopupSpeedComboBoxItem);
  1227. }
  1228. //---------------------------------------------------------------------------
  1229. void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
  1230. {
  1231. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  1232. unsigned short H, M, S, MS;
  1233. DecodeTime(Now(), H, M, S, MS);
  1234. int CurrentCompoundVer = Configuration->CompoundVersion;
  1235. ShowUpdatesAction->ImageIndex =
  1236. ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
  1237. !Updates.Results.Disabled &&
  1238. ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
  1239. ((!Updates.Results.Critical || Updates.ShownResults) &&
  1240. ((Updates.Results.Version > CurrentCompoundVer) ||
  1241. !Updates.Results.Message.IsEmpty())))) ? 80 :
  1242. ((int(Updates.Period) <= 0) ? 81 : 63));
  1243. }
  1244. //---------------------------------------------------------------------------
  1245. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1246. {
  1247. if (ScpExplorer != NULL)
  1248. {
  1249. ScpExplorer->PreferencesDialog(APreferencesMode);
  1250. }
  1251. else
  1252. {
  1253. DoPreferencesDialog(APreferencesMode);
  1254. }
  1255. }
  1256. //---------------------------------------------------------------------------
  1257. void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action)
  1258. {
  1259. TCustomCommandType Command;
  1260. int State;
  1261. bool Defined = ScpExplorer->GetLastCustomCommand(
  1262. (Action == CustomCommandsLastFocusedAction), Command, State);
  1263. Action->Visible = Defined;
  1264. if (Defined)
  1265. {
  1266. AnsiString TitleCommand = Command.Command;
  1267. int MaxTitleCommandLen = 20;
  1268. if (TitleCommand.Length() > MaxTitleCommandLen)
  1269. {
  1270. TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + "...";
  1271. }
  1272. Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (TitleCommand));
  1273. Action->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (Command.Command));
  1274. Action->Enabled = (State > 0);
  1275. }
  1276. }
  1277. //---------------------------------------------------------------------------
  1278. AnsiString __fastcall TNonVisualDataModule::QueueItemSpeed(const AnsiString & Text,
  1279. TTBXComboBoxItem * Item)
  1280. {
  1281. unsigned long Speed = GetSpeedLimit(Text);
  1282. ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
  1283. AnsiString Result = SetSpeedLimit(Speed);
  1284. SaveToHistory(Item->Strings, Result);
  1285. CustomWinConfiguration->History["SpeedLimit"] = Item->Strings;
  1286. return Result;
  1287. }
  1288. //---------------------------------------------------------------------------
  1289. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(
  1290. TObject * Sender)
  1291. {
  1292. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1293. QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);
  1294. }
  1295. //---------------------------------------------------------------------------
  1296. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(
  1297. TObject * Sender, AnsiString & NewText, bool & /*Accept*/)
  1298. {
  1299. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1300. NewText = QueueItemSpeed(NewText, Item);
  1301. QueueItemSpeedAction->Text = NewText;
  1302. }
  1303. //---------------------------------------------------------------------------
  1304. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item)
  1305. {
  1306. // IDE often looses this link
  1307. Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;
  1308. Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;
  1309. }
  1310. //---------------------------------------------------------------------------
  1311. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item)
  1312. {
  1313. Item->Strings = CustomWinConfiguration->History["SpeedLimit"];
  1314. }
  1315. //---------------------------------------------------------------------------
  1316. void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action)
  1317. {
  1318. TAction * Current = CurrentQueueOnceEmptyAction();
  1319. if (Current != Action)
  1320. {
  1321. Current->Checked = false;
  1322. Action->Checked = true;
  1323. }
  1324. }
  1325. //---------------------------------------------------------------------------
  1326. void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction()
  1327. {
  1328. TAction * Current = CurrentQueueOnceEmptyAction();
  1329. Current->Checked = false;
  1330. if (Current == QueueIdleOnceEmptyAction)
  1331. {
  1332. QueueDisconnectOnceEmptyAction->Checked = true;
  1333. }
  1334. else if (Current == QueueDisconnectOnceEmptyAction)
  1335. {
  1336. QueueShutDownOnceEmptyAction->Checked = true;
  1337. }
  1338. else if (Current == QueueShutDownOnceEmptyAction)
  1339. {
  1340. QueueIdleOnceEmptyAction->Checked = true;
  1341. }
  1342. else
  1343. {
  1344. assert(false);
  1345. }
  1346. }
  1347. //---------------------------------------------------------------------------
  1348. TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
  1349. {
  1350. TAction * Result;
  1351. if (QueueIdleOnceEmptyAction->Checked)
  1352. {
  1353. Result = QueueIdleOnceEmptyAction;
  1354. }
  1355. else if (QueueDisconnectOnceEmptyAction->Checked)
  1356. {
  1357. Result = QueueDisconnectOnceEmptyAction;
  1358. }
  1359. else if (QueueShutDownOnceEmptyAction->Checked)
  1360. {
  1361. Result = QueueShutDownOnceEmptyAction;
  1362. }
  1363. else
  1364. {
  1365. assert(false);
  1366. }
  1367. return Result;
  1368. }
  1369. //---------------------------------------------------------------------------
  1370. TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation()
  1371. {
  1372. TOnceDoneOperation Result;
  1373. TBasicAction * Current = CurrentQueueOnceEmptyAction();
  1374. if (Current == QueueIdleOnceEmptyAction)
  1375. {
  1376. Result = odoIdle;
  1377. }
  1378. else if (Current == QueueDisconnectOnceEmptyAction)
  1379. {
  1380. Result = odoDisconnect;
  1381. }
  1382. else if (Current == QueueShutDownOnceEmptyAction)
  1383. {
  1384. Result = odoShutDown;
  1385. }
  1386. else
  1387. {
  1388. assert(false);
  1389. }
  1390. return Result;
  1391. }
  1392. //---------------------------------------------------------------------------
  1393. void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation()
  1394. {
  1395. SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);
  1396. }
  1397. //---------------------------------------------------------------------------
  1398. void __fastcall TNonVisualDataModule::InitMenuItem(TTBCustomItem * Item)
  1399. {
  1400. TTBSeparatorItem * Separator = dynamic_cast<TTBSeparatorItem *>(Item);
  1401. if (Separator != NULL)
  1402. {
  1403. Separator->Hint = "E";
  1404. }
  1405. for (int Index = 0; Index < Item->Count; Index++)
  1406. {
  1407. InitMenuItem(Item->Items[Index]);
  1408. }
  1409. }
  1410. //---------------------------------------------------------------------------
  1411. void __fastcall TNonVisualDataModule::InitMenus(TComponent * Component)
  1412. {
  1413. TTBPopupMenu * Popup = dynamic_cast<TTBPopupMenu *>(Component);
  1414. TTBCustomToolbar * Toolbar = dynamic_cast<TTBCustomToolbar *>(Component);
  1415. if (Popup != NULL)
  1416. {
  1417. InitMenuItem(Popup->Items);
  1418. }
  1419. else if (Toolbar != NULL)
  1420. {
  1421. InitMenuItem(Toolbar->Items);
  1422. }
  1423. else
  1424. {
  1425. // do not try to descend below from toolbar/popup, as there should not be any
  1426. // other menu component and we save some time
  1427. for (int Index = 0; Index < Component->ComponentCount; Index++)
  1428. {
  1429. InitMenus(Component->Components[Index]);
  1430. }
  1431. }
  1432. }