NonVisual.cpp 68 KB

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