NonVisual.cpp 58 KB

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