NonVisual.cpp 53 KB

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