NonVisual.cpp 58 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506
  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. CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
  744. }
  745. //---------------------------------------------------------------------------
  746. void __fastcall TNonVisualDataModule::CommanderShortcuts()
  747. {
  748. // Directory
  749. CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
  750. NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
  751. // File operation
  752. CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
  753. CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
  754. AddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
  755. AddEditLinkContextAction->ShortCut = AddEditLinkAction->ShortCut;
  756. // Focused operation
  757. CurrentCopyFocusedAction->ShortCut = ShortCut(VK_F5, NONE);
  758. CurrentMoveFocusedAction->ShortCut = ShortCut(VK_F6, NONE);
  759. CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
  760. CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
  761. RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
  762. RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
  763. // remote directory
  764. RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
  765. RemoteRefreshAction->ShortCut = ShortCut('R', CTRL);
  766. RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
  767. RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
  768. // local directory
  769. LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
  770. LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
  771. LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
  772. LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
  773. // selected operation
  774. CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
  775. CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
  776. CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
  777. CurrentDeleteAction->SecondaryShortCuts->Clear();
  778. CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
  779. CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);
  780. CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();
  781. CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));
  782. CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
  783. RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
  784. RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
  785. // selection
  786. SelectOneAction->ShortCut = VK_INSERT;
  787. SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
  788. UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
  789. SelectAllAction->ShortCut = ShortCut('A', CTRL);
  790. InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
  791. ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
  792. RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
  793. // commands
  794. NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
  795. // legacy shortcut (can be removed when necessary)
  796. NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
  797. CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
  798. }
  799. #undef CTRL
  800. #undef ALT
  801. #undef NONE
  802. //---------------------------------------------------------------------------
  803. void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
  804. {
  805. FScpExplorer = value;
  806. SessionIdleTimer->Enabled = (FScpExplorer != NULL);
  807. }
  808. //---------------------------------------------------------------------------
  809. void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
  810. TObject */*Sender*/)
  811. {
  812. DoIdle();
  813. }
  814. //---------------------------------------------------------------------------
  815. void __fastcall TNonVisualDataModule::DoIdle()
  816. {
  817. if (!FSessionIdleTimerExecuting)
  818. {
  819. FSessionIdleTimerExecuting = true;
  820. try
  821. {
  822. assert(ScpExplorer);
  823. ScpExplorer->Idle(FIdle >= 0);
  824. }
  825. __finally
  826. {
  827. FSessionIdleTimerExecuting = false;
  828. }
  829. }
  830. }
  831. //---------------------------------------------------------------------------
  832. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
  833. TTBCustomItem * Menu, bool OnFocused, bool Toolbar, bool Both)
  834. {
  835. for (int Index = 0; Index < WinConfiguration->CustomCommandList->Count; Index++)
  836. {
  837. const TCustomCommandType * Command = WinConfiguration->CustomCommandList->Commands[Index];
  838. int State;
  839. if (!Both)
  840. {
  841. State = ScpExplorer->CustomCommandState(*Command, OnFocused);
  842. }
  843. else
  844. {
  845. State = ScpExplorer->BothCustomCommandState(*Command);
  846. }
  847. if (State >= 0)
  848. {
  849. TTBCustomItem * Item = new TTBXItem(Owner);
  850. Item->Caption = Command->Name;
  851. if (Toolbar)
  852. {
  853. Item->Caption = StripHotkey(Item->Caption);
  854. }
  855. Item->Tag = Index;
  856. Item->Enabled = (State > 0);
  857. if (OnFocused)
  858. {
  859. Item->Tag = Item->Tag | 0x0100;
  860. }
  861. if (Both)
  862. {
  863. Item->Tag = Item->Tag | 0x0200;
  864. }
  865. Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (StripHotkey(Command->Name)));
  866. if (!Both)
  867. {
  868. Item->ShortCut = Command->ShortCut;
  869. }
  870. Item->OnClick = CustomCommandClick;
  871. Menu->Add(Item);
  872. }
  873. }
  874. TTBCustomItem * Item;
  875. if (!Both)
  876. {
  877. Item = new TTBXItem(Menu);
  878. Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
  879. Menu->Add(Item);
  880. Item = new TTBXItem(Menu);
  881. Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
  882. if (Toolbar)
  883. {
  884. Item->Caption = StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT));
  885. }
  886. Menu->Add(Item);
  887. }
  888. AddMenuSeparator(Menu);
  889. if (!Toolbar && !Both)
  890. {
  891. Item = new TTBXItem(Menu);
  892. Item->Action = CustomCommandsBandAction;
  893. Menu->Add(Item);
  894. }
  895. Item = new TTBXItem(Menu);
  896. Item->Action = CustomCommandsCustomizeAction;
  897. Menu->Add(Item);
  898. }
  899. //---------------------------------------------------------------------------
  900. void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action)
  901. {
  902. assert(Action);
  903. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  904. if (Menu)
  905. {
  906. int PrevCount = Menu->Count;
  907. bool OnFocused = (Menu == RemoteDirViewCustomCommandsMenu);
  908. CreateCustomCommandsMenu(Menu, OnFocused, false, false);
  909. for (int Index = 0; Index < PrevCount; Index++)
  910. {
  911. Menu->Delete(0);
  912. }
  913. }
  914. }
  915. //---------------------------------------------------------------------------
  916. void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
  917. {
  918. // can be called while explorer is being created
  919. if (ScpExplorer == NULL)
  920. {
  921. return;
  922. }
  923. int AdditionalCommands = 4;
  924. TCustomCommandList * CustomCommandList = WinConfiguration->CustomCommandList;
  925. bool Changed = (CustomCommandList->Count != (Toolbar->Items->Count - AdditionalCommands));
  926. if (!Changed)
  927. {
  928. int Index = 0;
  929. while (!Changed && (Index < CustomCommandList->Count))
  930. {
  931. Changed =
  932. (Toolbar->Items->Items[Index]->Caption !=
  933. StripHotkey(CustomCommandList->Commands[Index]->Name));
  934. Index++;
  935. }
  936. }
  937. if (Changed)
  938. {
  939. Toolbar->BeginUpdate();
  940. try
  941. {
  942. Toolbar->Items->Clear();
  943. CreateCustomCommandsMenu(Toolbar->Items, false, true, false);
  944. assert(CustomCommandList->Count == (Toolbar->Items->Count - AdditionalCommands));
  945. }
  946. __finally
  947. {
  948. Toolbar->EndUpdate();
  949. }
  950. }
  951. else
  952. {
  953. for (int Index = 0; Index < Toolbar->Items->Count - AdditionalCommands; Index++)
  954. {
  955. TTBCustomItem * Item = Toolbar->Items->Items[Index];
  956. int CommandIndex = (Item->Tag & 0x00FF);
  957. assert(CommandIndex == Index);
  958. int State = ScpExplorer->CustomCommandState(
  959. *CustomCommandList->Commands[CommandIndex], false);
  960. assert(State >= 0);
  961. Item->Enabled = (State > 0);
  962. }
  963. }
  964. }
  965. //---------------------------------------------------------------------------
  966. void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
  967. {
  968. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  969. assert(Item);
  970. const TCustomCommandType * Command = WinConfiguration->CustomCommandList->Commands[Item->Tag & 0x00FF];
  971. if (FLAGCLEAR(Item->Tag, 0x0200))
  972. {
  973. ScpExplorer->ExecuteFileOperation(foCustomCommand, osRemote,
  974. FLAGSET(Item->Tag, 0x0100), false, const_cast<TCustomCommandType *>(Command));
  975. }
  976. else
  977. {
  978. ScpExplorer->BothCustomCommand(*Command);
  979. }
  980. }
  981. //---------------------------------------------------------------------------
  982. void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
  983. {
  984. StoredSessions->Load();
  985. if (StoredSessions->Count == 0)
  986. {
  987. Abort();
  988. }
  989. else
  990. {
  991. CreateSessionListMenuLevel(
  992. dynamic_cast<TTBCustomItem *>(Action->ActionComponent), 0, 0);
  993. }
  994. }
  995. //---------------------------------------------------------------------------
  996. void __fastcall TNonVisualDataModule::CreateSessionListMenuLevel(
  997. TTBCustomItem * Menu, int Index, int Level)
  998. {
  999. assert(Index < StoredSessions->Count);
  1000. TSessionData * Data = StoredSessions->Sessions[Index];
  1001. AnsiString Path = Data->Name;
  1002. AnsiString Root;
  1003. for (int ALevel = 0; ALevel < Level; ALevel++)
  1004. {
  1005. Root.Insert(::CutToChar(Path, '/', false) + '/', Root.Length() + 1);
  1006. }
  1007. Menu->Clear();
  1008. int FirstSession = 0;
  1009. AnsiString PrevName;
  1010. while (Index < StoredSessions->Count)
  1011. {
  1012. TSessionData * Data = StoredSessions->Sessions[Index];
  1013. if (!AnsiSameText(Data->Name.SubString(1, Root.Length()), Root))
  1014. {
  1015. break;
  1016. }
  1017. else
  1018. {
  1019. AnsiString Name = Data->Name.SubString(Root.Length() + 1, Data->Name.Length() - Root.Length());
  1020. int P = Name.Pos('/');
  1021. if (P > 0)
  1022. {
  1023. Name.SetLength(P - 1);
  1024. }
  1025. if (Name != PrevName)
  1026. {
  1027. if (P > 0)
  1028. {
  1029. TTBCustomItem * Item = new TTBXSubmenuItem(Menu);
  1030. Item->Caption = Name;
  1031. Item->Tag = ((Level + 1) << 16) | Index; // MAKELONG
  1032. Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_HINT, (Root + Name));
  1033. Item->ImageIndex = SavedSessionsAction->ImageIndex;
  1034. Item->OnClick = SessionFolderItemClick;
  1035. Menu->Insert(FirstSession, Item);
  1036. FirstSession++;
  1037. }
  1038. else
  1039. {
  1040. TTBCustomItem * Item = new TTBXItem(Menu);
  1041. Item->Caption = Name;
  1042. Item->Tag = Index;
  1043. Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
  1044. Item->OnClick = SessionItemClick;
  1045. Menu->Insert(Menu->Count, Item);
  1046. }
  1047. PrevName = Name;
  1048. }
  1049. }
  1050. Index++;
  1051. }
  1052. }
  1053. //---------------------------------------------------------------------------
  1054. void __fastcall TNonVisualDataModule::SessionFolderItemClick(TObject * Sender)
  1055. {
  1056. TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
  1057. assert(Item != NULL);
  1058. CreateSessionListMenuLevel(Item, LOWORD(Item->Tag), HIWORD(Item->Tag));
  1059. }
  1060. //---------------------------------------------------------------------------
  1061. void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
  1062. {
  1063. assert(StoredSessions && (((TMenuItem *)Sender)->Tag < StoredSessions->Count));
  1064. ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TMenuItem *)Sender)->Tag]);
  1065. }
  1066. //---------------------------------------------------------------------------
  1067. TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
  1068. {
  1069. if (Index >= 0 && Index < 10)
  1070. {
  1071. return ShortCut((Word)(Index < 9 ? '0' + 1 + Index : '0'),
  1072. TShiftState() << ssAlt);
  1073. }
  1074. else
  1075. {
  1076. return scNone;
  1077. }
  1078. }
  1079. //---------------------------------------------------------------------------
  1080. void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
  1081. {
  1082. TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1083. assert(OpenedSessionsMenu != NULL);
  1084. TTerminalManager * Manager = TTerminalManager::Instance();
  1085. TStrings * TerminalList = Manager->TerminalList;
  1086. int PrevCount = OpenedSessionsMenu->Count;
  1087. for (int Index = 0; Index < TerminalList->Count; Index++)
  1088. {
  1089. TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
  1090. assert(Terminal);
  1091. TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
  1092. Item->Caption = TerminalList->Strings[Index];
  1093. Item->Tag = int(Terminal);
  1094. Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
  1095. Item->Checked = (Manager->ActiveTerminal == Terminal);
  1096. Item->ShortCut = OpenSessionShortCut(Index);
  1097. Item->OnClick = OpenedSessionItemClick;
  1098. Item->RadioItem = true;
  1099. OpenedSessionsMenu->Add(Item);
  1100. }
  1101. for (int Index = 0; Index < PrevCount; Index++)
  1102. {
  1103. OpenedSessionsMenu->Delete(0);
  1104. }
  1105. }
  1106. //---------------------------------------------------------------------------
  1107. void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
  1108. {
  1109. TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);
  1110. }
  1111. //---------------------------------------------------------------------------
  1112. void __fastcall TNonVisualDataModule::CreateEditorListMenu(TAction * Action)
  1113. {
  1114. assert(Action != NULL);
  1115. TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
  1116. if (Menu != NULL)
  1117. {
  1118. int PrevCount = Menu->Count;
  1119. TTBCustomItem * Item = new TTBXItem(Menu);
  1120. Item->Caption = LoadStr(INTERNAL_EDITOR_NAME);
  1121. Item->Tag = -1;
  1122. Item->Hint = LoadStr(INTERNAL_EDITOR_HINT);
  1123. Item->OnClick = EditorItemClick;
  1124. Menu->Add(Item);
  1125. AddMenuSeparator(Menu);
  1126. TStringList * UsedEditors = new TStringList();
  1127. try
  1128. {
  1129. UsedEditors->CaseSensitive = false;
  1130. UsedEditors->Sorted = true;
  1131. const TEditorList * EditorList = WinConfiguration->EditorList;
  1132. for (int Index = 0; Index < EditorList->Count; Index++)
  1133. {
  1134. const TEditorPreferences * Editor = EditorList->Editors[Index];
  1135. if ((Editor->Data->Editor == edExternal) &&
  1136. (UsedEditors->IndexOf(Editor->Data->ExternalEditor) < 0))
  1137. {
  1138. UsedEditors->Add(Editor->Data->ExternalEditor);
  1139. TTBCustomItem * Item = new TTBXItem(Menu);
  1140. Item->Caption = Editor->Name;
  1141. Item->Tag = Index;
  1142. Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
  1143. Item->OnClick = EditorItemClick;
  1144. Menu->Add(Item);
  1145. }
  1146. }
  1147. Item = new TTBXItem(Menu);
  1148. Item->Action = CurrentEditWithAction;
  1149. Menu->Add(Item);
  1150. AddMenuSeparator(Menu);
  1151. Item = new TTBXItem(Menu);
  1152. Item->Action = EditorListCustomizeAction;
  1153. Menu->Add(Item);
  1154. for (int Index = 0; Index < PrevCount; Index++)
  1155. {
  1156. Menu->Delete(0);
  1157. }
  1158. }
  1159. __finally
  1160. {
  1161. delete UsedEditors;
  1162. }
  1163. }
  1164. }
  1165. //---------------------------------------------------------------------------
  1166. void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
  1167. {
  1168. int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
  1169. if (Tag < 0)
  1170. {
  1171. ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false);
  1172. }
  1173. else
  1174. {
  1175. const TEditorList * EditorList = WinConfiguration->EditorList;
  1176. // sanity check
  1177. if (Tag < EditorList->Count)
  1178. {
  1179. ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag]->Data,
  1180. true, false);
  1181. }
  1182. }
  1183. }
  1184. //---------------------------------------------------------------------------
  1185. void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
  1186. {
  1187. TAction * Action = NULL;
  1188. switch (ScpExplorer->DefaultQueueOperation())
  1189. {
  1190. case qoItemQuery:
  1191. Action = QueueItemQueryAction;
  1192. break;
  1193. case qoItemError:
  1194. Action = QueueItemErrorAction;
  1195. break;
  1196. case qoItemPrompt:
  1197. Action = QueueItemPromptAction;
  1198. break;
  1199. case qoItemExecute:
  1200. Action = QueueItemExecuteAction;
  1201. break;
  1202. case qoItemPause:
  1203. Action = QueueItemPauseAction;
  1204. break;
  1205. case qoItemResume:
  1206. Action = QueueItemResumeAction;
  1207. break;
  1208. }
  1209. TTBCustomItem * Item;
  1210. for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
  1211. {
  1212. Item = QueuePopup->Items->Items[Index];
  1213. TTBItemOptions O = Item->Options;
  1214. if ((Action != NULL) && (Item->Action == Action))
  1215. {
  1216. O << tboDefault;
  1217. }
  1218. else
  1219. {
  1220. O >> tboDefault;
  1221. }
  1222. Item->Options = O;
  1223. }
  1224. QueueSpeedComboBoxItemUpdate(QueuePopupSpeedComboBoxItem);
  1225. }
  1226. //---------------------------------------------------------------------------
  1227. void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
  1228. {
  1229. TUpdatesConfiguration Updates = WinConfiguration->Updates;
  1230. unsigned short H, M, S, MS;
  1231. DecodeTime(Now(), H, M, S, MS);
  1232. int CurrentCompoundVer = Configuration->CompoundVersion;
  1233. ShowUpdatesAction->ImageIndex =
  1234. ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
  1235. !Updates.Results.Disabled &&
  1236. ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
  1237. ((!Updates.Results.Critical || Updates.ShownResults) &&
  1238. ((Updates.Results.Version > CurrentCompoundVer) ||
  1239. !Updates.Results.Message.IsEmpty())))) ? 80 :
  1240. ((int(Updates.Period) <= 0) ? 81 : 63));
  1241. }
  1242. //---------------------------------------------------------------------------
  1243. void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
  1244. {
  1245. if (ScpExplorer != NULL)
  1246. {
  1247. ScpExplorer->PreferencesDialog(APreferencesMode);
  1248. }
  1249. else
  1250. {
  1251. DoPreferencesDialog(APreferencesMode);
  1252. }
  1253. }
  1254. //---------------------------------------------------------------------------
  1255. void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action)
  1256. {
  1257. TCustomCommandType Command;
  1258. int State;
  1259. bool Defined = ScpExplorer->GetLastCustomCommand(
  1260. (Action == CustomCommandsLastFocusedAction), Command, State);
  1261. Action->Visible = Defined;
  1262. if (Defined)
  1263. {
  1264. AnsiString TitleCommand = Command.Command;
  1265. int MaxTitleCommandLen = 20;
  1266. if (TitleCommand.Length() > MaxTitleCommandLen)
  1267. {
  1268. TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + "...";
  1269. }
  1270. Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (TitleCommand));
  1271. Action->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (Command.Command));
  1272. Action->Enabled = (State > 0);
  1273. }
  1274. }
  1275. //---------------------------------------------------------------------------
  1276. AnsiString __fastcall TNonVisualDataModule::QueueItemSpeed(const AnsiString & Text,
  1277. TTBXComboBoxItem * Item)
  1278. {
  1279. unsigned long Speed = GetSpeedLimit(Text);
  1280. ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
  1281. AnsiString Result = SetSpeedLimit(Speed);
  1282. SaveToHistory(Item->Strings, Result);
  1283. CustomWinConfiguration->History["SpeedLimit"] = Item->Strings;
  1284. return Result;
  1285. }
  1286. //---------------------------------------------------------------------------
  1287. void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(
  1288. TObject * Sender)
  1289. {
  1290. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1291. QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);
  1292. }
  1293. //---------------------------------------------------------------------------
  1294. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(
  1295. TObject * Sender, AnsiString & NewText, bool & /*Accept*/)
  1296. {
  1297. TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
  1298. NewText = QueueItemSpeed(NewText, Item);
  1299. QueueItemSpeedAction->Text = NewText;
  1300. }
  1301. //---------------------------------------------------------------------------
  1302. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item)
  1303. {
  1304. // IDE often looses this link
  1305. Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;
  1306. Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;
  1307. }
  1308. //---------------------------------------------------------------------------
  1309. void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item)
  1310. {
  1311. Item->Strings = CustomWinConfiguration->History["SpeedLimit"];
  1312. }
  1313. //---------------------------------------------------------------------------
  1314. void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action)
  1315. {
  1316. TAction * Current = CurrentQueueOnceEmptyAction();
  1317. if (Current != Action)
  1318. {
  1319. Current->Checked = false;
  1320. Action->Checked = true;
  1321. }
  1322. }
  1323. //---------------------------------------------------------------------------
  1324. void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction()
  1325. {
  1326. TAction * Current = CurrentQueueOnceEmptyAction();
  1327. Current->Checked = false;
  1328. if (Current == QueueIdleOnceEmptyAction)
  1329. {
  1330. QueueDisconnectOnceEmptyAction->Checked = true;
  1331. }
  1332. else if (Current == QueueDisconnectOnceEmptyAction)
  1333. {
  1334. QueueShutDownOnceEmptyAction->Checked = true;
  1335. }
  1336. else if (Current == QueueShutDownOnceEmptyAction)
  1337. {
  1338. QueueIdleOnceEmptyAction->Checked = true;
  1339. }
  1340. else
  1341. {
  1342. assert(false);
  1343. }
  1344. }
  1345. //---------------------------------------------------------------------------
  1346. TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
  1347. {
  1348. TAction * Result;
  1349. if (QueueIdleOnceEmptyAction->Checked)
  1350. {
  1351. Result = QueueIdleOnceEmptyAction;
  1352. }
  1353. else if (QueueDisconnectOnceEmptyAction->Checked)
  1354. {
  1355. Result = QueueDisconnectOnceEmptyAction;
  1356. }
  1357. else if (QueueShutDownOnceEmptyAction->Checked)
  1358. {
  1359. Result = QueueShutDownOnceEmptyAction;
  1360. }
  1361. else
  1362. {
  1363. assert(false);
  1364. }
  1365. return Result;
  1366. }
  1367. //---------------------------------------------------------------------------
  1368. TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation()
  1369. {
  1370. TOnceDoneOperation Result;
  1371. TBasicAction * Current = CurrentQueueOnceEmptyAction();
  1372. if (Current == QueueIdleOnceEmptyAction)
  1373. {
  1374. Result = odoIdle;
  1375. }
  1376. else if (Current == QueueDisconnectOnceEmptyAction)
  1377. {
  1378. Result = odoDisconnect;
  1379. }
  1380. else if (Current == QueueShutDownOnceEmptyAction)
  1381. {
  1382. Result = odoShutDown;
  1383. }
  1384. else
  1385. {
  1386. assert(false);
  1387. }
  1388. return Result;
  1389. }
  1390. //---------------------------------------------------------------------------
  1391. void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation()
  1392. {
  1393. SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);
  1394. }
  1395. //---------------------------------------------------------------------------
  1396. void __fastcall TNonVisualDataModule::InitMenuItem(TTBCustomItem * Item)
  1397. {
  1398. TTBSeparatorItem * Separator = dynamic_cast<TTBSeparatorItem *>(Item);
  1399. if (Separator != NULL)
  1400. {
  1401. Separator->Hint = "E";
  1402. }
  1403. for (int Index = 0; Index < Item->Count; Index++)
  1404. {
  1405. InitMenuItem(Item->Items[Index]);
  1406. }
  1407. }
  1408. //---------------------------------------------------------------------------
  1409. void __fastcall TNonVisualDataModule::InitMenus(TComponent * Component)
  1410. {
  1411. TTBPopupMenu * Popup = dynamic_cast<TTBPopupMenu *>(Component);
  1412. TTBCustomToolbar * Toolbar = dynamic_cast<TTBCustomToolbar *>(Component);
  1413. if (Popup != NULL)
  1414. {
  1415. InitMenuItem(Popup->Items);
  1416. }
  1417. else if (Toolbar != NULL)
  1418. {
  1419. InitMenuItem(Toolbar->Items);
  1420. }
  1421. else
  1422. {
  1423. // do not try to descend below from toolbar/popup, as there should not be any
  1424. // other menu component and we save some time
  1425. for (int Index = 0; Index < Component->ComponentCount; Index++)
  1426. {
  1427. InitMenus(Component->Components[Index]);
  1428. }
  1429. }
  1430. }