NonVisual.cpp 43 KB

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