| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "NonVisual.h"
- #include <Common.h>
- #include <CoreMain.h>
- #include <TextsWin.h>
- #include <Tools.h>
- #include <Setup.h>
- #include <Log.h>
- #include <Interface.h>
- #include "WinConfiguration.h"
- #include "TerminalManager.h"
- #include "TBX.hpp"
- #include "VCLCommon.h"
- #include <HistoryComboBox.hpp>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma link "TB2Item"
- #pragma link "TBX"
- #pragma link "TB2ExtItems"
- #pragma link "TBXExtItems"
- #ifndef NO_RESOURCES
- #pragma resource "*.dfm"
- #endif
- TNonVisualDataModule *NonVisualDataModule;
- //---------------------------------------------------------------------------
- #define SCPCOMMANDER ((TScpCommanderForm *)ScpExplorer)
- #define UPDEX(HandleAction, Condition, OtherEnabled, OtherDisabled) if (Action == HandleAction) { \
- ((TCustomAction *)Action)->Enabled = (Condition); \
- if (((TCustomAction *)Action)->Enabled) { OtherEnabled; } else { OtherDisabled; }; \
- Handled = true; } else
- #define UPDEX1(HandleAction, Condition, Other) UPDEX(HandleAction, Condition, Other, Other)
- #define UPD(HandleAction, Condition) if (Action == HandleAction) { \
- ((TCustomAction *)Action)->Enabled = (Condition); Handled = true; } else
- #define UPDFUNC(HandleAction, Function) if (Action == HandleAction) { Function; Handled = true; } else
- #define EXE(HandleAction, Command) if (Action == HandleAction) { \
- Command; Handled = true; } else
- #define UPDACT(HandleAction, Command) \
- EXE(HandleAction, ((TCustomAction *)Action)->Enabled = true; Command)
- #define UPDCOMP(COMP) if (Action == COMP ## Action) { COMP ## Action->Enabled = true; \
- COMP ## Action->Checked = ScpExplorer->ComponentVisible[fc ## COMP]; Handled = true; } else
- #define EXECOMP(COMP) EXE(COMP ## Action, \
- ScpExplorer->ComponentVisible[fc ## COMP] = !ScpExplorer->ComponentVisible[fc ## COMP] )
- #define COLPROPS(SIDE) \
- ((TCustomDirViewColProperties*)ScpExplorer->DirView(os ## SIDE)->ColProperties)
- #define UPDSORT(SIDE, PREFIX, COL) if (Action == SIDE ## SortBy ## COL ## Action) { \
- SIDE ## SortBy ## COL ## Action->Enabled = true; Handled = true; \
- SIDE ## SortBy ## COL ## Action->Checked = (COLPROPS(SIDE)->SortColumn == PREFIX ## COL); } else
- #define EXESORT(SIDE, PREFIX, COL) EXE(SIDE ## SortBy ## COL ## Action, \
- if (COLPROPS(SIDE)->SortColumn == PREFIX ## COL) \
- COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; \
- else COLPROPS(SIDE)->SortColumn = PREFIX ## COL )
- #define UPDSORTA(SIDE) if (Action == SIDE ## SortAscendingAction) { \
- SIDE ## SortAscendingAction->Enabled = true; Handled = true; \
- SIDE ## SortAscendingAction->Checked = COLPROPS(SIDE)->SortAscending; } else
- #define EXESORTA(SIDE) EXE(SIDE ## SortAscendingAction, \
- COLPROPS(SIDE)->SortAscending = !COLPROPS(SIDE)->SortAscending; )
- #define UPDSORTC(LPREFIX, LCOL, RPREFIX, RCOL) if (Action == CurrentSortBy ## RCOL ## Action) { \
- CurrentSortBy ## RCOL ## Action->Enabled = ScpExplorer->AllowedAction((TAction *)Action, aaShortCut); \
- if (CurrentSortBy ## RCOL ## Action->Enabled) { \
- if (ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) \
- CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == RPREFIX ## RCOL); \
- else CurrentSortBy ## RCOL ## Action->Checked = (COLPROPS(Current)->SortColumn == LPREFIX ## LCOL); \
- } else CurrentSortBy ## RCOL ## Action->Checked = false; Handled = true; } else
- #define EXESORTC(COL, LCOL, RCOL) \
- EXE(CurrentSortBy ## COL ## Action, \
- Integer NewSortCol = \
- ((ScpExplorer->DirView(osCurrent) == ScpExplorer->DirView(osRemote)) ? RCOL : LCOL); \
- if (COLPROPS(Current)->SortColumn == NewSortCol) \
- COLPROPS(Current)->SortAscending = !COLPROPS(Current)->SortAscending; \
- else COLPROPS(Current)->SortColumn = NewSortCol \
- )
- #define UPDSHCOL(SIDE, PREFIX, COL) \
- EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
- ShowHide ## SIDE ## COL ## ColumnAction->Checked = COLPROPS(SIDE)->Visible[PREFIX ## COL])
- #define EXESHCOL(SIDE, PREFIX, COL) \
- EXE(ShowHide ## SIDE ## COL ## ColumnAction, \
- COLPROPS(SIDE)->Visible[PREFIX ## COL] = !COLPROPS(SIDE)->Visible[PREFIX ## COL])
- //---------------------------------------------------------------------------
- __fastcall TNonVisualDataModule::TNonVisualDataModule(TComponent* Owner)
- : TDataModule(Owner)
- {
- FListColumn = NULL;
- FSessionIdleTimerExecuting = false;
- FIdle = 0;
- QueueSpeedComboBoxItem(QueuePopupSpeedComboBoxItem);
- InitMenus(this);
- }
- //---------------------------------------------------------------------------
- __fastcall TNonVisualDataModule::~TNonVisualDataModule()
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::LogActionsUpdate(
- TBasicAction *Action, bool &Handled)
- {
- TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
- bool ValidLogMemo = LogMemo && LogMemo->Parent;
- UPD(LogClearAction, ValidLogMemo && LogMemo->Lines->Count)
- // removed potentially CPU intensive check for "all selected already"
- UPD(LogSelectAllAction, ValidLogMemo && LogMemo->Lines->Count)
- UPD(LogCopyAction, ValidLogMemo && LogMemo->SelLength)
- UPD(LogCloseAction, Configuration->Logging && (WinConfiguration->LogView == lvWindow))
- UPD(LogPreferencesAction, true)
- ;
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::LogActionsExecute(
- TBasicAction *Action, bool &Handled)
- {
- FIdle--;
- try
- {
- TLogMemo * LogMemo = TTerminalManager::Instance()->LogMemo;
- assert(LogMemo && LogMemo->Parent);
- EXE(LogClearAction, LogMemo->SessionLog->Clear())
- EXE(LogSelectAllAction, LogMemo->SelectAll())
- EXE(LogCopyAction, LogMemo->CopyToClipboard())
- EXE(LogCloseAction, WinConfiguration->LogView = lvNone)
- EXE(LogPreferencesAction, PreferencesDialog(pmLogging));
- ;
- }
- __finally
- {
- assert(FIdle < 0);
- FIdle++;
- }
- DoIdle();
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::ExplorerActionsUpdate(
- TBasicAction *Action, bool &Handled)
- {
- if (!ScpExplorer || !ScpExplorer->AllowedAction((TAction *)Action, aaUpdate))
- {
- ((TAction *)Action)->Enabled = false;
- Handled = true;
- return;
- }
- void * Param;
- // CURRENT DIRVIEW
- bool EnableSelectedOperation = ScpExplorer->EnableSelectedOperation[osCurrent];
- bool EnableFocusedOperation = ScpExplorer->EnableFocusedOperation[osCurrent];
- bool EnableSelectedFileOperation = ScpExplorer->EnableSelectedFileOperation[osCurrent];
- bool EnableFocusedFileOperation = ScpExplorer->EnableFocusedFileOperation[osCurrent];
- // focused operation
- UPD(CurrentCopyFocusedAction, EnableFocusedOperation)
- UPD(CurrentMoveFocusedAction, EnableFocusedOperation)
- UPD(CurrentDeleteFocusedAction, EnableFocusedOperation)
- UPD(CurrentPropertiesFocusedAction, EnableFocusedOperation)
- UPD(RemoteMoveToFocusedAction, EnableFocusedOperation &&
- (DirView(osRemote) == DirView(osCurrent)) &&
- ScpExplorer->Terminal->IsCapable[fcRemoteMove])
- UPD(RemoteCopyToFocusedAction, EnableFocusedOperation &&
- DirView(osRemote) == DirView(osCurrent))
- UPD(CurrentEditFocusedAction, EnableFocusedFileOperation &&
- !WinConfiguration->DisableOpenEdit)
- // file operation
- UPD(CurrentRenameAction, EnableFocusedOperation &&
- ((ScpExplorer->HasDirView[osLocal] && DirView(osLocal) == DirView(osCurrent)) ||
- ScpExplorer->Terminal->IsCapable[fcRename]))
- UPD(CurrentEditAction, EnableSelectedFileOperation &&
- !WinConfiguration->DisableOpenEdit)
- UPD(CurrentEditAlternativeAction, EnableSelectedFileOperation &&
- !WinConfiguration->DisableOpenEdit)
- UPD(CurrentEditWithAction, EnableSelectedFileOperation &&
- !WinConfiguration->DisableOpenEdit)
- UPD(CurrentOpenAction, EnableFocusedOperation &&
- !WinConfiguration->DisableOpenEdit &&
- !DirView(osCurrent)->ItemIsDirectory(DirView(osCurrent)->ItemFocused))
- UPD(AddEditLinkAction, ScpExplorer->CanAddEditLink())
- UPDEX1(AddEditLinkContextAction, ScpExplorer->CanAddEditLink(),
- ((TAction *)Action)->Visible = ScpExplorer->LinkFocused())
- UPD(NewLinkAction, ScpExplorer->CanAddEditLink())
- // selected operaton
- UPD(CurrentCopyAction, EnableSelectedOperation)
- UPD(RemoteCopyAction, ScpExplorer->EnableSelectedOperation[osRemote])
- UPD(LocalCopyAction, ScpExplorer->HasDirView[osLocal] && ScpExplorer->EnableSelectedOperation[osLocal])
- UPD(CurrentMoveAction, EnableSelectedOperation)
- UPD(CurrentDeleteAction, EnableSelectedOperation)
- UPD(CurrentDeleteAlternativeAction, EnableSelectedOperation)
- UPD(CurrentPropertiesAction, EnableSelectedOperation)
- UPD(RemoteMoveToAction, EnableSelectedOperation &&
- (DirView(osRemote) == DirView(osCurrent)) &&
- ScpExplorer->Terminal->IsCapable[fcRemoteMove])
- UPD(RemoteCopyToAction, EnableSelectedOperation &&
- (DirView(osRemote) == DirView(osCurrent)))
- UPD(FileListToCommandLineAction, EnableSelectedOperation)
- UPD(FileListToClipboardAction, EnableSelectedOperation)
- UPD(FullFileListToClipboardAction, EnableSelectedOperation)
- UPD(UrlToClipboardAction, EnableSelectedOperation && (DirView(osRemote) == DirView(osCurrent)))
- UPD(FileListFromClipboardAction, IsFormatInClipboard(CF_TEXT));
- // directory
- UPD(CurrentCreateDirAction, true)
- UPD(NewDirAction, true)
- // selection
- UPD(SelectOneAction, DirView(osCurrent)->FilesCount)
- UPD(SelectAction, DirView(osCurrent)->FilesCount)
- UPD(UnselectAction, DirView(osCurrent)->SelCount)
- UPD(SelectAllAction, DirView(osCurrent)->FilesCount)
- UPD(InvertSelectionAction, DirView(osCurrent)->FilesCount)
- UPD(ClearSelectionAction, DirView(osCurrent)->SelCount)
- UPD(RestoreSelectionAction, DirView(osCurrent)->SelectedNamesSaved)
- UPD(PasteAction, ScpExplorer->CanPasteFromClipBoard())
- //style
- UPDACT(CurrentCycleStyleAction,
- CurrentCycleStyleAction->ImageIndex = 8 + (DirView(osCurrent)->ViewStyle + 1) % 4)
- #define STYLEACTION(Style) UPDACT(Current ## Style ## Action, \
- Current ## Style ## Action->Checked = (DirView(osCurrent)->ViewStyle == vs ## Style))
- STYLEACTION(Icon)
- STYLEACTION(SmallIcon)
- STYLEACTION(List)
- STYLEACTION(Report)
- #undef STYLEACTION
- // REMOTE+LOCAL
- // back/forward
- #define HISTORYACTION(SIDE, DIRECTION, HINTFMT, DELTA) \
- UPDEX(SIDE ## DIRECTION ## Action, (DirView(os ## SIDE)->DIRECTION ## Count > 0), \
- SIDE ## DIRECTION ## Action->Hint = FMTLOAD(HINTFMT, (DirView(os ## SIDE)->HistoryPath[DELTA])), \
- SIDE ## DIRECTION ## Action->Hint = "")
- HISTORYACTION(Local, Back, EXPLORER_BACK_HINT, -1)
- HISTORYACTION(Local, Forward, EXPLORER_FORWARD_HINT, 1)
- HISTORYACTION(Remote, Back, EXPLORER_BACK_HINT, -1)
- HISTORYACTION(Remote, Forward, EXPLORER_FORWARD_HINT, 1)
- #undef HISTORYACTION
- #define PANEL_ACTIONS(SIDE) \
- UPD(SIDE ## ParentDirAction, !DirView(os ## SIDE)->IsRoot) \
- UPD(SIDE ## RootDirAction, !DirView(os ## SIDE)->IsRoot) \
- UPD(SIDE ## HomeDirAction, true) \
- UPD(SIDE ## RefreshAction, DirView(os ## SIDE)->DirOK) \
- UPD(SIDE ## OpenDirAction, true) \
- UPD(SIDE ## ChangePathAction, true) \
- UPD(SIDE ## AddBookmarkAction, true) \
- UPD(SIDE ## PathToClipboardAction, true) \
- UPDEX1(SIDE ## FilterAction, true, ((TAction *)Action)->Checked = !DirView(os ## SIDE)->Mask.IsEmpty())
- PANEL_ACTIONS(Local)
- PANEL_ACTIONS(Remote)
- #undef PANEL_ACTIONS
- UPD(LocalExploreDirectoryAction, true)
- // HELP
- UPD(AboutAction, true)
- UPD(HomepageAction, true)
- UPD(HistoryPageAction, true)
- UPD(TableOfContentsAction, true)
- UPD(ForumPageAction, true)
- UPD(CheckForUpdatesAction, true)
- UPDACT(ShowUpdatesAction, ShowUpdatesUpdate())
- UPD(UpdatesPreferencesAction, true)
- UPD(DonatePageAction, true)
- UPD(DownloadPageAction, true)
- // VIEW
- UPDCOMP(StatusBar)
- UPDCOMP(ToolBar)
- UPDCOMP(LocalStatusBar)
- UPDCOMP(RemoteStatusBar)
- UPDCOMP(CommandLinePanel)
- UPDCOMP(RemoteTree)
- UPDCOMP(LocalTree)
- UPDCOMP(ExplorerMenuBand)
- UPDCOMP(ExplorerAddressBand)
- UPDCOMP(ExplorerToolbarBand)
- UPDCOMP(ExplorerSelectionBand)
- UPDCOMP(ExplorerSessionBand)
- UPDCOMP(ExplorerPreferencesBand)
- UPDCOMP(ExplorerSortBand)
- UPDCOMP(ExplorerUpdatesBand)
- UPDCOMP(ExplorerTransferBand)
- UPDCOMP(ExplorerCustomCommandsBand)
- UPDCOMP(CommanderMenuBand)
- UPDCOMP(CommanderSessionBand)
- UPDCOMP(CommanderPreferencesBand)
- UPDCOMP(CommanderSelectionBand)
- UPDCOMP(CommanderToolbarBand)
- UPDCOMP(CommanderSortBand)
- UPDCOMP(CommanderCommandsBand)
- UPDCOMP(CommanderUpdatesBand)
- UPDCOMP(CommanderTransferBand)
- UPDCOMP(CommanderUploadDownloadBand)
- UPDCOMP(CommanderCustomCommandsBand)
- UPDCOMP(CommanderLocalHistoryBand)
- UPDCOMP(CommanderLocalNavigationBand)
- UPDCOMP(CommanderRemoteHistoryBand)
- UPDCOMP(CommanderRemoteNavigationBand)
- UPD(GoToCommandLineAction, true)
- UPD(GoToTreeAction, true)
- UPDEX(ViewLogAction, Configuration->Logging,
- ViewLogAction->Checked = (WinConfiguration->LogView == lvWindow),
- ViewLogAction->Checked = false )
- UPDEX(ShowHiddenFilesAction, true,
- ShowHiddenFilesAction->Checked = WinConfiguration->ShowHiddenFiles, )
- UPDEX(AutoReadDirectoryAfterOpAction, true,
- AutoReadDirectoryAfterOpAction->Checked = Configuration->AutoReadDirectoryAfterOp, )
- UPD(PreferencesAction, true)
- UPD(PresetsPreferencesAction, true)
- UPDEX(LockToolbarsAction, true,
- LockToolbarsAction->Checked = WinConfiguration->LockToolbars, )
- UPDCOMP(CustomCommandsBand)
- UPD(ColorMenuAction, true)
- UPDACT(ColorDefaultAction,
- ColorDefaultAction->Checked = (ScpExplorer->SessionColor == 0));
- UPD(ColorPickAction, true);
- // SORT
- UPDSORTA(Local)
- UPDSORT(Local, dv, Name)
- UPDSORT(Local, dv, Ext)
- UPDSORT(Local, dv, Size)
- UPDSORT(Local, dv, Type)
- UPDSORT(Local, dv, Changed)
- UPDSORT(Local, dv, Attr)
- UPDSORTA(Remote)
- UPDSORT(Remote, uv, Name)
- UPDSORT(Remote, uv, Ext)
- UPDSORT(Remote, uv, Size)
- UPDSORT(Remote, uv, Changed)
- UPDSORT(Remote, uv, Rights)
- UPDSORT(Remote, uv, Owner)
- UPDSORT(Remote, uv, Group)
- UPDSORT(Remote, uv, Type)
- UPDSORTA(Current)
- UPDSORTC(dv, Name, uv, Name)
- UPDSORTC(dv, Ext, uv, Ext)
- UPDSORTC(dv, Size, uv, Size)
- UPDSORTC(dv, Type, uv, Type)
- UPDSORTC(dv, Changed, uv, Changed)
- UPDSORTC(dv, Attr, uv, Rights)
- UPDSORTC(dv, Name, uv, Owner)
- UPDSORTC(dv, Name, uv, Group)
- #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
- UPDEX(SortColumnAscendingAction, (ListColumn != NULL), SortColumnAscendingAction->Checked =
- (COLVIEWPROPS->SortColumn == ListColumn->Index) && COLVIEWPROPS->SortAscending, /*assert(false)*/ )
- UPDEX(SortColumnDescendingAction, (ListColumn != NULL), SortColumnDescendingAction->Checked =
- (COLVIEWPROPS->SortColumn == ListColumn->Index) && !COLVIEWPROPS->SortAscending, /*assert(false)*/ )
- #undef COLVIEWPROPS
- // SHOW/HIDE COLUMN
- UPDSHCOL(Local, dv, Name)
- UPDSHCOL(Local, dv, Ext)
- UPDSHCOL(Local, dv, Size)
- UPDSHCOL(Local, dv, Type)
- UPDSHCOL(Local, dv, Changed)
- UPDSHCOL(Local, dv, Attr)
- UPDSHCOL(Remote, uv, Name)
- UPDSHCOL(Remote, uv, Ext)
- UPDSHCOL(Remote, uv, Size)
- UPDSHCOL(Remote, uv, Changed)
- UPDSHCOL(Remote, uv, Rights)
- UPDSHCOL(Remote, uv, Owner)
- UPDSHCOL(Remote, uv, Group)
- UPDSHCOL(Remote, uv, LinkTarget)
- UPDSHCOL(Remote, uv, Type)
- UPD(HideColumnAction, (ListColumn != NULL))
- UPD(BestFitColumnAction, (ListColumn != NULL))
- // SESSION
- UPD(NewSessionAction, true)
- UPD(DuplicateSessionAction, true)
- UPD(CloseSessionAction, true)
- UPD(SavedSessionsAction, (StoredSessions->Count > 0))
- UPD(OpenedSessionsAction, true)
- UPD(SaveCurrentSessionAction, true)
- // COMMAND
- UPD(CompareDirectoriesAction, true)
- UPD(SynchronizeAction, true)
- UPD(FullSynchronizeAction, true)
- UPD(ConsoleAction, true)
- UPD(PuttyAction, TTerminalManager::Instance()->CanOpenInPutty())
- UPD(SynchronizeBrowsingAction, true)
- UPD(CloseApplicationAction, true)
- UPD(FileSystemInfoAction, true)
- UPD(ClearCachesAction, (ScpExplorer->Terminal != NULL) && !ScpExplorer->Terminal->AreCachesEmpty)
- UPD(NewFileAction, !WinConfiguration->DisableOpenEdit)
- UPD(EditorListCustomizeAction, true)
- // CUSTOM COMMANDS
- UPD(CustomCommandsAction, true)
- UPD(CustomCommandsEnterAction, true)
- UPD(CustomCommandsEnterFocusedAction, true)
- UPDFUNC(CustomCommandsLastAction, CustomCommandsLastUpdate(CustomCommandsLastAction))
- UPDFUNC(CustomCommandsLastFocusedAction, CustomCommandsLastUpdate(CustomCommandsLastFocusedAction))
- UPD(CustomCommandsCustomizeAction, true)
- // QUEUE
- #define UPDQUEUE(OPERATION) UPD(Queue ## OPERATION ## Action, \
- ScpExplorer->AllowQueueOperation(qo ## OPERATION))
- UPDQUEUE(GoTo)
- UPDQUEUE(Preferences)
- UPDEX(QueueItemQueryAction, ScpExplorer->AllowQueueOperation(qoItemQuery),
- ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
- UPDEX(QueueItemErrorAction, ScpExplorer->AllowQueueOperation(qoItemError),
- ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
- UPDEX(QueueItemPromptAction, ScpExplorer->AllowQueueOperation(qoItemPrompt),
- ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
- UPDQUEUE(ItemDelete)
- UPDEX(QueueItemExecuteAction, ScpExplorer->AllowQueueOperation(qoItemExecute),
- ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible =
- !ScpExplorer->AllowQueueOperation(qoItemPause) &&
- !ScpExplorer->AllowQueueOperation(qoItemResume))
- UPDEX(QueueItemPauseAction, ScpExplorer->AllowQueueOperation(qoItemPause),
- ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
- UPDEX(QueueItemResumeAction, ScpExplorer->AllowQueueOperation(qoItemResume),
- ((TAction *)Action)->Visible = true, ((TAction *)Action)->Visible = false)
- UPDQUEUE(ItemUp)
- UPDQUEUE(ItemDown)
- UPDQUEUE(PauseAll)
- UPDQUEUE(ResumeAll)
- #undef UPDQUEUE
- UPDEX(QueueItemSpeedAction, ScpExplorer->AllowQueueOperation(qoItemSpeed, &Param),
- QueueItemSpeedAction->Text = SetSpeedLimit(reinterpret_cast<unsigned long>(Param)),
- QueueItemSpeedAction->Text = "")
- UPDACT(QueueToggleShowAction,
- ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueView])
- #define QUEUEACTION(SHOW) UPDACT(Queue ## SHOW ## Action, \
- ((TAction *)Action)->Checked = WinConfiguration->QueueView.Show == qv ## SHOW)
- QUEUEACTION(Show)
- QUEUEACTION(HideWhenEmpty)
- QUEUEACTION(Hide)
- #undef QUEUEACTION
- UPDACT(QueueCycleOnceEmptyAction,
- QueueCycleOnceEmptyAction->ImageIndex = CurrentQueueOnceEmptyAction()->ImageIndex;
- QueueCycleOnceEmptyAction->Checked = !QueueIdleOnceEmptyAction->Checked)
- UPD(QueueIdleOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
- UPD(QueueDisconnectOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
- UPD(QueueShutDownOnceEmptyAction, ScpExplorer->AllowQueueOperation(qoOnceEmpty))
- UPDCOMP(CommanderPreferencesBand)
- UPDACT(QueueToolbarAction,
- ((TAction *)Action)->Enabled = ScpExplorer->ComponentVisible[fcQueueView];
- ((TAction *)Action)->Checked = ScpExplorer->ComponentVisible[fcQueueToolbar])
- ;
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::ExplorerActionsExecute(
- TBasicAction *Action, bool &Handled)
- {
- assert(ScpExplorer);
- if (!ScpExplorer->AllowedAction((TAction *)Action, aaExecute))
- {
- Handled = true;
- return;
- }
- ScpExplorer->BeforeAction();
- FIdle--;
- try
- {
- // focused operation
- EXE(CurrentCopyFocusedAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, true))
- EXE(CurrentMoveFocusedAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, true))
- EXE(CurrentDeleteFocusedAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, true))
- EXE(CurrentPropertiesFocusedAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, true))
- EXE(RemoteMoveToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, true))
- EXE(RemoteCopyToFocusedAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, true))
- EXE(CurrentEditFocusedAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, true))
- // operation
- EXE(CurrentCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osCurrent, false))
- EXE(RemoteCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osRemote, false))
- EXE(LocalCopyAction, ScpExplorer->ExecuteFileOperation(foCopy, osLocal, false))
- EXE(CurrentMoveAction, ScpExplorer->ExecuteFileOperation(foMove, osCurrent, false))
- EXE(CurrentEditAction, ScpExplorer->ExecuteFile(osCurrent, efDefaultEditor, NULL, true, false))
- EXE(CurrentEditAlternativeAction, CreateEditorListMenu(CurrentEditAlternativeAction))
- EXE(CurrentEditWithAction, ScpExplorer->ExecuteCurrentFileWith())
- EXE(CurrentOpenAction, ScpExplorer->ExecuteCurrentFile())
- EXE(AddEditLinkAction, ScpExplorer->AddEditLink(false))
- EXE(AddEditLinkContextAction, ScpExplorer->AddEditLink(false))
- EXE(NewLinkAction, ScpExplorer->AddEditLink(true))
- EXE(CurrentRenameAction, ScpExplorer->ExecuteFileOperation(foRename, osCurrent, false))
- EXE(CurrentDeleteAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, false))
- EXE(CurrentDeleteAlternativeAction, ScpExplorer->ExecuteFileOperation(foDelete, osCurrent, false, false, (void*)true))
- EXE(CurrentPropertiesAction, ScpExplorer->ExecuteFileOperation(foSetProperties, osCurrent, false))
- EXE(RemoteMoveToAction, ScpExplorer->ExecuteFileOperation(foRemoteMove, osCurrent, false))
- EXE(RemoteCopyToAction, ScpExplorer->ExecuteFileOperation(foRemoteCopy, osCurrent, false))
- EXE(FileListToCommandLineAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedCommandLine))
- EXE(FileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFileList, pedClipboard))
- EXE(FullFileListToClipboardAction, ScpExplorer->PanelExport(osCurrent, peFullFileList, pedClipboard))
- EXE(UrlToClipboardAction, ScpExplorer->PanelExport(osCurrent, peUrl, pedClipboard))
- EXE(FileListFromClipboardAction, ScpExplorer->FileListFromClipboard())
- // directory
- EXE(CurrentCreateDirAction, ScpExplorer->CreateDirectory(osCurrent))
- EXE(NewDirAction, ScpExplorer->CreateDirectory(osCurrent))
- //selection
- EXE(SelectOneAction, DirView(osCurrent)->SelectCurrentItem(DirView(osCurrent)->NortonLike))
- EXE(SelectAction, DirView(osCurrent)->DoSelectByMask(true))
- EXE(UnselectAction, DirView(osCurrent)->DoSelectByMask(false))
- EXE(SelectAllAction, DirView(osCurrent)->SelectAll(smAll))
- EXE(InvertSelectionAction, DirView(osCurrent)->SelectAll(smInvert))
- EXE(ClearSelectionAction, DirView(osCurrent)->SelectAll(smNone))
- EXE(RestoreSelectionAction, DirView(osCurrent)->RestoreSelectedNames())
- EXE(PasteAction, ScpExplorer->PasteFromClipBoard())
- // style
- EXE(CurrentCycleStyleAction,
- if (DirView(osCurrent)->ViewStyle == vsReport) DirView(osCurrent)->ViewStyle = vsIcon;
- else DirView(osCurrent)->ViewStyle = (TViewStyle)(DirView(osCurrent)->ViewStyle + 1);
- )
- #define STYLEACTION(Style) EXE(Current ## Style ## Action, \
- DirView(osCurrent)->ViewStyle = vs ## Style)
- STYLEACTION(Icon)
- STYLEACTION(SmallIcon)
- STYLEACTION(List)
- STYLEACTION(Report)
- #undef STYLEACTION
- #define PANEL_ACTIONS(SIDE) \
- EXE(SIDE ## BackAction, DirView(os ## SIDE)->HistoryGo(-1)) \
- EXE(SIDE ## ForwardAction, DirView(os ## SIDE)->HistoryGo(1)) \
- EXE(SIDE ## ParentDirAction, DirView(os ## SIDE)->ExecuteParentDirectory()) \
- EXE(SIDE ## RootDirAction, DirView(os ## SIDE)->ExecuteRootDirectory()) \
- EXE(SIDE ## HomeDirAction, ScpExplorer->HomeDirectory(os ## SIDE)) \
- EXE(SIDE ## RefreshAction, DirView(os ## SIDE)->ReloadDirectory()) \
- EXE(SIDE ## OpenDirAction, ScpExplorer->OpenDirectory(os ## SIDE)) \
- EXE(SIDE ## ChangePathAction, ScpExplorer->ChangePath(os ## SIDE)) \
- EXE(SIDE ## AddBookmarkAction, ScpExplorer->AddBookmark(os ## SIDE)) \
- EXE(SIDE ## PathToClipboardAction, ScpExplorer->PanelExport(os ## SIDE, pePath, pedClipboard)) \
- EXE(SIDE ## FilterAction, ScpExplorer->Filter(os ## SIDE))
- PANEL_ACTIONS(Local)
- PANEL_ACTIONS(Remote)
- #undef PANEL_ACTIONS
- EXE(LocalExploreDirectoryAction, ScpExplorer->ExploreLocalDirectory())
- //HELP
- EXE(AboutAction, DoAboutDialog(Configuration))
- EXE(HomepageAction, OpenBrowser(LoadStr(HOMEPAGE_URL)))
- EXE(HistoryPageAction, OpenBrowser(LoadStr(HISTORY_URL)))
- EXE(TableOfContentsAction, Application->HelpSystem->ShowTableOfContents())
- EXE(ForumPageAction, OpenBrowser(LoadStr(FORUM_URL)))
- EXE(CheckForUpdatesAction, CheckForUpdates(false))
- EXE(ShowUpdatesAction, CheckForUpdates(true))
- EXE(UpdatesPreferencesAction, PreferencesDialog(pmUpdates))
- EXE(DonatePageAction, OpenBrowser(LoadStr(DONATE_URL)))
- EXE(DownloadPageAction, OpenBrowser(LoadStr(DOWNLOAD_URL)))
- // VIEW
- EXECOMP(StatusBar)
- EXECOMP(ToolBar)
- EXECOMP(LocalStatusBar)
- EXECOMP(RemoteStatusBar)
- EXECOMP(ExplorerMenuBand)
- EXECOMP(ExplorerAddressBand)
- EXECOMP(ExplorerToolbarBand)
- EXECOMP(ExplorerSelectionBand)
- EXECOMP(ExplorerSessionBand)
- EXECOMP(ExplorerPreferencesBand)
- EXECOMP(ExplorerSortBand)
- EXECOMP(ExplorerUpdatesBand)
- EXECOMP(ExplorerTransferBand)
- EXECOMP(ExplorerCustomCommandsBand)
- EXECOMP(CommanderMenuBand)
- EXECOMP(CommanderSessionBand)
- EXECOMP(CommanderPreferencesBand)
- EXECOMP(CommanderSelectionBand)
- EXECOMP(CommanderToolbarBand)
- EXECOMP(CommanderSortBand)
- EXECOMP(CommanderCommandsBand)
- EXECOMP(CommanderUpdatesBand)
- EXECOMP(CommanderTransferBand)
- EXECOMP(CommanderUploadDownloadBand)
- EXECOMP(CommanderCustomCommandsBand)
- EXECOMP(CommanderLocalHistoryBand)
- EXECOMP(CommanderLocalNavigationBand)
- EXECOMP(CommanderRemoteHistoryBand)
- EXECOMP(CommanderRemoteNavigationBand)
- EXECOMP(CommandLinePanel)
- EXECOMP(RemoteTree)
- EXECOMP(LocalTree)
- EXE(GoToCommandLineAction, ScpExplorer->GoToCommandLine())
- EXE(GoToTreeAction, ScpExplorer->GoToTree())
- EXE(ViewLogAction, WinConfiguration->LogView =
- (WinConfiguration->LogView == lvNone ? lvWindow : lvNone) )
- EXE(ShowHiddenFilesAction, ScpExplorer->ToggleShowHiddenFiles())
- EXE(AutoReadDirectoryAfterOpAction, ScpExplorer->ToggleAutoReadDirectoryAfterOp())
- EXE(PreferencesAction, PreferencesDialog(pmDefault) )
- EXE(PresetsPreferencesAction, PreferencesDialog(pmPresets) )
- EXE(LockToolbarsAction, WinConfiguration->LockToolbars = !WinConfiguration->LockToolbars)
- EXECOMP(CustomCommandsBand)
- EXE(ColorMenuAction, );
- EXE(ColorDefaultAction, ScpExplorer->SessionColor = (TColor)0);
- EXE(ColorPickAction, ScpExplorer->SessionColorPick());
- #define COLVIEWPROPS ((TCustomDirViewColProperties*)(((TCustomDirView*)(((TListColumns*)(ListColumn->Collection))->Owner()))->ColProperties))
- // SORT
- EXESORTA(Local)
- EXESORT(Local, dv, Name)
- EXESORT(Local, dv, Ext)
- EXESORT(Local, dv, Size)
- EXESORT(Local, dv, Type)
- EXESORT(Local, dv, Changed)
- EXESORT(Local, dv, Attr)
- EXESORTA(Remote)
- EXESORT(Remote, uv, Name)
- EXESORT(Remote, uv, Ext)
- EXESORT(Remote, uv, Size)
- EXESORT(Remote, uv, Changed)
- EXESORT(Remote, uv, Rights)
- EXESORT(Remote, uv, Owner)
- EXESORT(Remote, uv, Group)
- EXESORT(Remote, uv, Type)
- EXESORTA(Current)
- EXESORTC(Name, dvName, uvName)
- EXESORTC(Ext, dvExt, uvExt)
- EXESORTC(Size, dvSize, uvSize)
- EXESORTC(Type, dvType, uvType)
- EXESORTC(Changed, dvChanged, uvChanged)
- EXESORTC(Rights, dvAttr, uvRights)
- EXESORTC(Owner, dvName, uvOwner)
- EXESORTC(Group, dvName, uvGroup)
- EXE(SortColumnAscendingAction, assert(ListColumn);
- COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = true; ListColumn = NULL )
- EXE(SortColumnDescendingAction, assert(ListColumn);
- COLVIEWPROPS->SortColumn = ListColumn->Index; COLVIEWPROPS->SortAscending = false; ListColumn = NULL )
- // SHOW/HIDE COLUMN
- EXESHCOL(Local, dv, Name)
- EXESHCOL(Local, dv, Ext)
- EXESHCOL(Local, dv, Size)
- EXESHCOL(Local, dv, Type)
- EXESHCOL(Local, dv, Changed)
- EXESHCOL(Local, dv, Attr)
- EXESHCOL(Remote, uv, Name)
- EXESHCOL(Remote, uv, Ext)
- EXESHCOL(Remote, uv, Size)
- EXESHCOL(Remote, uv, Changed)
- EXESHCOL(Remote, uv, Rights)
- EXESHCOL(Remote, uv, Owner)
- EXESHCOL(Remote, uv, Group)
- EXESHCOL(Remote, uv, LinkTarget)
- EXESHCOL(Remote, uv, Type)
- EXE(HideColumnAction, assert(ListColumn);
- COLVIEWPROPS->Visible[ListColumn->Index] = false; ListColumn = NULL )
- EXE(BestFitColumnAction, assert(ListColumn); ListColumn = NULL ) // TODO
- #undef COLVIEWPROPS
- // SESSION
- EXE(NewSessionAction, ScpExplorer->NewSession())
- EXE(DuplicateSessionAction, ScpExplorer->DuplicateSession())
- EXE(CloseSessionAction, ScpExplorer->CloseSession())
- EXE(SavedSessionsAction, CreateSessionListMenu(SavedSessionsAction))
- EXE(OpenedSessionsAction, CreateOpenedSessionListMenu(OpenedSessionsAction))
- EXE(SaveCurrentSessionAction, ScpExplorer->SaveCurrentSession())
- // COMMAND
- EXE(CompareDirectoriesAction, ScpExplorer->CompareDirectories())
- EXE(SynchronizeAction, ScpExplorer->SynchronizeDirectories())
- EXE(FullSynchronizeAction, ScpExplorer->FullSynchronizeDirectories())
- EXE(ConsoleAction, ScpExplorer->OpenConsole())
- EXE(PuttyAction, TTerminalManager::Instance()->OpenInPutty())
- EXE(SynchronizeBrowsingAction, ScpExplorer->SynchronizeBrowsingChanged())
- EXE(CloseApplicationAction, ScpExplorer->Close())
- EXE(FileSystemInfoAction, ScpExplorer->FileSystemInfo())
- EXE(ClearCachesAction, ScpExplorer->Terminal->ClearCaches())
- EXE(NewFileAction, ScpExplorer->EditNew(osCurrent))
- EXE(EditorListCustomizeAction, PreferencesDialog(pmEditor))
- // CUSTOM COMMANDS
- EXE(CustomCommandsAction, CreateCustomCommandsMenu(CustomCommandsAction))
- EXE(CustomCommandsEnterAction, ScpExplorer->AdHocCustomCommand(false))
- EXE(CustomCommandsEnterFocusedAction, ScpExplorer->AdHocCustomCommand(true))
- EXE(CustomCommandsLastAction, ScpExplorer->LastCustomCommand(false))
- EXE(CustomCommandsLastFocusedAction, ScpExplorer->LastCustomCommand(true))
- EXE(CustomCommandsCustomizeAction, PreferencesDialog(pmCustomCommands))
- // QUEUE
- #define EXEQUEUE(OPERATION) EXE(Queue ## OPERATION ## Action, \
- ScpExplorer->ExecuteQueueOperation(qo ## OPERATION))
- EXEQUEUE(GoTo)
- EXEQUEUE(Preferences)
- EXEQUEUE(ItemQuery)
- EXEQUEUE(ItemError)
- EXEQUEUE(ItemPrompt)
- EXEQUEUE(ItemDelete)
- EXEQUEUE(ItemExecute)
- EXEQUEUE(ItemPause)
- EXEQUEUE(ItemResume)
- EXEQUEUE(ItemUp)
- EXEQUEUE(ItemDown)
- EXEQUEUE(PauseAll)
- EXEQUEUE(ResumeAll)
- #undef EXEQUEUE
- EXE(QueueToggleShowAction, ScpExplorer->ToggleQueueVisibility())
- #define QUEUEACTION(SHOW) EXE(Queue ## SHOW ## Action, \
- TQueueViewConfiguration Config = WinConfiguration->QueueView; \
- if (Config.Show != qvShow) Config.LastHideShow = Config.Show; \
- Config.Show = qv ## SHOW; \
- WinConfiguration->QueueView = Config)
- QUEUEACTION(Show)
- QUEUEACTION(HideWhenEmpty)
- QUEUEACTION(Hide)
- #undef QUEUEACTION
- EXE(QueueCycleOnceEmptyAction, CycleQueueOnceEmptyAction());
- EXE(QueueIdleOnceEmptyAction, SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction))
- EXE(QueueDisconnectOnceEmptyAction, SetQueueOnceEmptyAction(QueueDisconnectOnceEmptyAction))
- EXE(QueueShutDownOnceEmptyAction, SetQueueOnceEmptyAction(QueueShutDownOnceEmptyAction))
- EXECOMP(QueueToolbar);
- EXE(QueueItemSpeedAction, )
- ;
- }
- __finally
- {
- assert(FIdle < 0);
- FIdle++;
- }
- DoIdle();
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::UpdateNonVisibleActions()
- {
- // following actions needs to be updated even when all clients
- // are invisible, so the queue list toolbar button can be shown
- NonVisualDataModule->QueueItemQueryAction->Update();
- NonVisualDataModule->QueueItemErrorAction->Update();
- NonVisualDataModule->QueueItemPromptAction->Update();
- }
- //---------------------------------------------------------------------------
- #define CTRL TShiftState() << ssCtrl
- #define ALT TShiftState() << ssAlt
- #define SHIFT TShiftState() << ssShift
- #define CTRLSHIFT TShiftState() << ssCtrl << ssShift
- #define CTRLALT TShiftState() << ssCtrl << ssAlt
- #define NONE TShiftState()
- void __fastcall TNonVisualDataModule::ExplorerShortcuts()
- {
- // Directory
- CurrentCreateDirAction->ShortCut = ShortCut('D', CTRL);
- NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
- // File operation
- CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
- CurrentEditAction->ShortCut = ShortCut('E', CTRL);
- AddEditLinkAction->ShortCut = ShortCut('L', CTRLALT);
- AddEditLinkContextAction->ShortCut = AddEditLinkAction->ShortCut;
- // Focused operation
- CurrentCopyFocusedAction->ShortCut = ShortCut('C', CTRL);
- CurrentMoveFocusedAction->ShortCut = ShortCut('M', CTRL);
- CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_DELETE, NONE);
- CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_RETURN, ALT);
- RemoteMoveToFocusedAction->ShortCut = ShortCut('M', CTRLALT);
- // remote directory
- RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
- RemoteRefreshAction->ShortCut = ShortCut(VK_F5, NONE);
- RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
- RemotePathToClipboardAction->ShortCut = ShortCut('P', CTRLSHIFT);
- // selected operation
- CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
- CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
- CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
- CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_DELETE, SHIFT);
- CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
- RemoteMoveToAction->ShortCut = ShortCut('M', CTRLALT);
- // selection
- SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
- UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
- SelectAllAction->ShortCut = ShortCut('A', CTRL);
- InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
- ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
- RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
- // commands
- NewFileAction->ShortCut = ShortCut('E', CTRLSHIFT);
- CloseApplicationAction->ShortCut = ShortCut(VK_F4, ALT);
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CommanderShortcuts()
- {
- // Directory
- CurrentCreateDirAction->ShortCut = ShortCut(VK_F7, NONE);
- NewDirAction->ShortCut = CurrentCreateDirAction->ShortCut;
- // File operation
- CurrentRenameAction->ShortCut = ShortCut(VK_F2, NONE);
- CurrentEditAction->ShortCut = ShortCut(VK_F4, NONE);
- AddEditLinkAction->ShortCut = ShortCut(VK_F6, ALT);
- AddEditLinkContextAction->ShortCut = AddEditLinkAction->ShortCut;
- // Focused operation
- CurrentCopyFocusedAction->ShortCut = ShortCut(VK_F5, NONE);
- CurrentMoveFocusedAction->ShortCut = ShortCut(VK_F6, NONE);
- CurrentDeleteFocusedAction->ShortCut = ShortCut(VK_F8, NONE);
- CurrentPropertiesFocusedAction->ShortCut = ShortCut(VK_F9, NONE);
- RemoteMoveToFocusedAction->ShortCut = ShortCut(VK_F6, SHIFT);
- RemoteCopyToFocusedAction->ShortCut = ShortCut(VK_F5, SHIFT);
- // remote directory
- RemoteOpenDirAction->ShortCut = ShortCut('O', CTRL);
- RemoteRefreshAction->ShortCut = ShortCut('R', CTRL);
- RemoteHomeDirAction->ShortCut = ShortCut('H', CTRL);
- RemotePathToClipboardAction->ShortCut = ShortCut(VK_OEM_6 /* ] */, CTRL);
- // local directory
- LocalOpenDirAction->ShortCut = RemoteOpenDirAction->ShortCut;
- LocalRefreshAction->ShortCut = RemoteRefreshAction->ShortCut;
- LocalHomeDirAction->ShortCut = RemoteHomeDirAction->ShortCut;
- LocalPathToClipboardAction->ShortCut = ShortCut(VK_OEM_4 /* [ */, CTRL);
- // selected operation
- CurrentCopyAction->ShortCut = CurrentCopyFocusedAction->ShortCut;
- CurrentMoveAction->ShortCut = CurrentMoveFocusedAction->ShortCut;
- CurrentDeleteAction->ShortCut = CurrentDeleteFocusedAction->ShortCut;
- CurrentDeleteAction->SecondaryShortCuts->Clear();
- CurrentDeleteAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, NONE)));
- CurrentDeleteAlternativeAction->ShortCut = ShortCut(VK_F8, SHIFT);
- CurrentDeleteAlternativeAction->SecondaryShortCuts->Clear();
- CurrentDeleteAlternativeAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_DELETE, SHIFT)));
- CurrentPropertiesAction->ShortCut = CurrentPropertiesFocusedAction->ShortCut;
- RemoteMoveToAction->ShortCut = ShortCut(VK_F6, SHIFT);
- RemoteCopyToAction->ShortCut = ShortCut(VK_F5, SHIFT);
- // selection
- SelectOneAction->ShortCut = VK_INSERT;
- SelectAction->ShortCut = ShortCut(VK_ADD, NONE);
- UnselectAction->ShortCut = ShortCut(VK_SUBTRACT, NONE);
- SelectAllAction->ShortCut = ShortCut('A', CTRL);
- InvertSelectionAction->ShortCut = ShortCut(VK_MULTIPLY, NONE);
- ClearSelectionAction->ShortCut = ShortCut('L', CTRL);
- RestoreSelectionAction->ShortCut = ShortCut('R', CTRLALT);
- // commands
- NewFileAction->ShortCut = ShortCut(VK_F4, SHIFT);
- // legacy shortcut (can be removed when necessary)
- NewFileAction->SecondaryShortCuts->Add(ShortCutToText(ShortCut(VK_F4, CTRLSHIFT)));
- CloseApplicationAction->ShortCut = ShortCut(VK_F10, NONE);
- }
- #undef CTRL
- #undef ALT
- #undef NONE
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::SetScpExplorer(TCustomScpExplorerForm * value)
- {
- FScpExplorer = value;
- SessionIdleTimer->Enabled = (FScpExplorer != NULL);
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::SessionIdleTimerTimer(
- TObject */*Sender*/)
- {
- DoIdle();
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::DoIdle()
- {
- if (!FSessionIdleTimerExecuting)
- {
- FSessionIdleTimerExecuting = true;
- try
- {
- assert(ScpExplorer);
- ScpExplorer->Idle(FIdle >= 0);
- }
- __finally
- {
- FSessionIdleTimerExecuting = false;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(
- TTBCustomItem * Menu, bool OnFocused, bool Toolbar, bool Both)
- {
- for (int Index = 0; Index < WinConfiguration->CustomCommands->Count; Index++)
- {
- AnsiString Description = WinConfiguration->CustomCommands->Names[Index];
- int State;
- if (!Both)
- {
- State = ScpExplorer->CustomCommandState(Description, OnFocused);
- }
- else
- {
- State = ScpExplorer->BothCustomCommandState(Description);
- }
- if (State >= 0)
- {
- TTBCustomItem * Item = new TTBXItem(Owner);
- Item->Caption = Description;
- if (Toolbar)
- {
- Item->Caption = StripHotkey(Item->Caption);
- }
- Item->Tag = Index;
- Item->Enabled = (State > 0);
- if (OnFocused)
- {
- Item->Tag = Item->Tag | 0x0100;
- }
- if (Both)
- {
- Item->Tag = Item->Tag | 0x0200;
- }
- Item->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (StripHotkey(Description)));
- Item->OnClick = CustomCommandClick;
- Menu->Add(Item);
- }
- }
- TTBCustomItem * Item;
- if (!Both)
- {
- Item = new TTBXItem(Menu);
- Item->Action = OnFocused ? CustomCommandsEnterFocusedAction : CustomCommandsEnterAction;
- Menu->Add(Item);
- Item = new TTBXItem(Menu);
- Item->Action = OnFocused ? CustomCommandsLastFocusedAction : CustomCommandsLastAction;
- if (Toolbar)
- {
- Item->Caption = StripHotkey(LoadStr(CUSTOM_COMMAND_LAST_SHORT));
- }
- Menu->Add(Item);
- }
- AddMenuSeparator(Menu);
- if (!Toolbar && !Both)
- {
- Item = new TTBXItem(Menu);
- Item->Action = CustomCommandsBandAction;
- Menu->Add(Item);
- }
- Item = new TTBXItem(Menu);
- Item->Action = CustomCommandsCustomizeAction;
- Menu->Add(Item);
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CreateCustomCommandsMenu(TAction * Action)
- {
- assert(Action);
- TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
- if (Menu)
- {
- int PrevCount = Menu->Count;
- bool OnFocused = (Menu == RemoteDirViewCustomCommandsMenu);
- CreateCustomCommandsMenu(Menu, OnFocused, false, false);
- for (int Index = 0; Index < PrevCount; Index++)
- {
- Menu->Delete(0);
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::UpdateCustomCommandsToolbar(TTBXToolbar * Toolbar)
- {
- // can be called while explorer is being created
- if (ScpExplorer == NULL)
- {
- return;
- }
- int AdditionalCommands = 4;
- TCustomCommands * CustomCommands = WinConfiguration->CustomCommands;
- bool Changed = (CustomCommands->Count != (Toolbar->Items->Count - AdditionalCommands));
- if (!Changed)
- {
- int Index = 0;
- while (!Changed && (Index < CustomCommands->Count))
- {
- Changed =
- (Toolbar->Items->Items[Index]->Caption !=
- StripHotkey(CustomCommands->Names[Index]));
- Index++;
- }
- }
- if (Changed)
- {
- Toolbar->BeginUpdate();
- try
- {
- Toolbar->Items->Clear();
- CreateCustomCommandsMenu(Toolbar->Items, false, true, false);
- assert(CustomCommands->Count == (Toolbar->Items->Count - AdditionalCommands));
- }
- __finally
- {
- Toolbar->EndUpdate();
- }
- }
- else
- {
- for (int Index = 0; Index < Toolbar->Items->Count - AdditionalCommands; Index++)
- {
- TTBCustomItem * Item = Toolbar->Items->Items[Index];
- int CommandIndex = (Item->Tag & 0x00FF);
- assert(CommandIndex == Index);
- AnsiString Description = WinConfiguration->CustomCommands->Names[CommandIndex];
- int State = ScpExplorer->CustomCommandState(Description, false);
- assert(State >= 0);
- Item->Enabled = (State > 0);
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CustomCommandClick(TObject * Sender)
- {
- TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
- assert(Item);
- TCustomCommandParam Param;
- Param.Name = WinConfiguration->CustomCommands->Names[Item->Tag & 0x00FF];
- Param.Command = WinConfiguration->CustomCommands->Values[Param.Name];
- Param.Params = WinConfiguration->CustomCommands->Params[Param.Name];
- if (FLAGCLEAR(Item->Tag, 0x0200))
- {
- ScpExplorer->ExecuteFileOperation(foCustomCommand, osRemote,
- FLAGSET(Item->Tag, 0x0100), false, &Param);
- }
- else
- {
- ScpExplorer->BothCustomCommand(Param.Name, Param.Command, Param.Params);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CreateSessionListMenu(TAction * Action)
- {
- StoredSessions->Load();
- if (StoredSessions->Count == 0)
- {
- Abort();
- }
- else
- {
- CreateSessionListMenuLevel(
- dynamic_cast<TTBCustomItem *>(Action->ActionComponent), 0, 0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CreateSessionListMenuLevel(
- TTBCustomItem * Menu, int Index, int Level)
- {
- assert(Index < StoredSessions->Count);
- TSessionData * Data = StoredSessions->Sessions[Index];
- AnsiString Path = Data->Name;
- AnsiString Root;
- for (int ALevel = 0; ALevel < Level; ALevel++)
- {
- Root.Insert(::CutToChar(Path, '/', false) + '/', Root.Length() + 1);
- }
- Menu->Clear();
- int FirstSession = 0;
- AnsiString PrevName;
- while (Index < StoredSessions->Count)
- {
- TSessionData * Data = StoredSessions->Sessions[Index];
- if (!AnsiSameText(Data->Name.SubString(1, Root.Length()), Root))
- {
- break;
- }
- else
- {
- AnsiString Name = Data->Name.SubString(Root.Length() + 1, Data->Name.Length() - Root.Length());
- int P = Name.Pos('/');
- if (P > 0)
- {
- Name.SetLength(P - 1);
- }
- if (Name != PrevName)
- {
- if (P > 0)
- {
- TTBCustomItem * Item = new TTBXSubmenuItem(Menu);
- Item->Caption = Name;
- Item->Tag = ((Level + 1) << 16) | Index; // MAKELONG
- Item->Hint = FMTLOAD(SAVEDSESSIONFOLDER_HINT, (Root + Name));
- Item->ImageIndex = SavedSessionsAction->ImageIndex;
- Item->OnClick = SessionFolderItemClick;
- Menu->Insert(FirstSession, Item);
- FirstSession++;
- }
- else
- {
- TTBCustomItem * Item = new TTBXItem(Menu);
- Item->Caption = Name;
- Item->Tag = Index;
- Item->Hint = FMTLOAD(SAVEDSESSION_HINT, (Data->Name));
- Item->OnClick = SessionItemClick;
- Menu->Insert(Menu->Count, Item);
- }
- PrevName = Name;
- }
- }
- Index++;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::SessionFolderItemClick(TObject * Sender)
- {
- TTBCustomItem * Item = dynamic_cast<TTBCustomItem *>(Sender);
- assert(Item != NULL);
- CreateSessionListMenuLevel(Item, LOWORD(Item->Tag), HIWORD(Item->Tag));
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::SessionItemClick(TObject * Sender)
- {
- assert(StoredSessions && (((TMenuItem *)Sender)->Tag < StoredSessions->Count));
- ScpExplorer->OpenStoredSession(StoredSessions->Sessions[((TMenuItem *)Sender)->Tag]);
- }
- //---------------------------------------------------------------------------
- TShortCut __fastcall TNonVisualDataModule::OpenSessionShortCut(int Index)
- {
- if (Index >= 0 && Index < 10)
- {
- return ShortCut((Word)(Index < 9 ? '0' + 1 + Index : '0'),
- TShiftState() << ssAlt);
- }
- else
- {
- return scNone;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CreateOpenedSessionListMenu(TAction * Action)
- {
- TTBCustomItem * OpenedSessionsMenu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
- assert(OpenedSessionsMenu != NULL);
- TTerminalManager * Manager = TTerminalManager::Instance();
- TStrings * TerminalList = Manager->TerminalList;
- int PrevCount = OpenedSessionsMenu->Count;
- for (int Index = 0; Index < TerminalList->Count; Index++)
- {
- TTerminal * Terminal = dynamic_cast<TTerminal *>(TerminalList->Objects[Index]);
- assert(Terminal);
- TTBCustomItem * Item = new TTBXItem(OpenedSessionsMenu);
- Item->Caption = TerminalList->Strings[Index];
- Item->Tag = int(Terminal);
- Item->Hint = FMTLOAD(OPENEDSESSION_HINT, (Item->Caption));
- Item->Checked = (Manager->ActiveTerminal == Terminal);
- Item->ShortCut = OpenSessionShortCut(Index);
- Item->OnClick = OpenedSessionItemClick;
- Item->RadioItem = true;
- OpenedSessionsMenu->Add(Item);
- }
- for (int Index = 0; Index < PrevCount; Index++)
- {
- OpenedSessionsMenu->Delete(0);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::OpenedSessionItemClick(TObject * Sender)
- {
- TTerminalManager::Instance()->ActiveTerminal = (TTerminal*)(((TMenuItem *)Sender)->Tag);
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CreateEditorListMenu(TAction * Action)
- {
- assert(Action != NULL);
- TTBCustomItem * Menu = dynamic_cast<TTBCustomItem *>(Action->ActionComponent);
- if (Menu != NULL)
- {
- int PrevCount = Menu->Count;
- TTBCustomItem * Item = new TTBXItem(Menu);
- Item->Caption = LoadStr(INTERNAL_EDITOR_NAME);
- Item->Tag = -1;
- Item->Hint = LoadStr(INTERNAL_EDITOR_HINT);
- Item->OnClick = EditorItemClick;
- Menu->Add(Item);
- AddMenuSeparator(Menu);
- TStringList * UsedEditors = new TStringList();
- try
- {
- UsedEditors->CaseSensitive = false;
- UsedEditors->Sorted = true;
- const TEditorList * EditorList = WinConfiguration->EditorList;
- for (int Index = 0; Index < EditorList->Count; Index++)
- {
- const TEditorPreferences * Editor = EditorList->Editors[Index];
- if ((Editor->Data->Editor == edExternal) &&
- (UsedEditors->IndexOf(Editor->Data->ExternalEditor) < 0))
- {
- UsedEditors->Add(Editor->Data->ExternalEditor);
- TTBCustomItem * Item = new TTBXItem(Menu);
- Item->Caption = Editor->Name;
- Item->Tag = Index;
- Item->Hint = FMTLOAD(EXTERNAL_EDITOR_HINT, (Editor->Name));
- Item->OnClick = EditorItemClick;
- Menu->Add(Item);
- }
- }
- Item = new TTBXItem(Menu);
- Item->Action = CurrentEditWithAction;
- Menu->Add(Item);
- AddMenuSeparator(Menu);
- Item = new TTBXItem(Menu);
- Item->Action = EditorListCustomizeAction;
- Menu->Add(Item);
- for (int Index = 0; Index < PrevCount; Index++)
- {
- Menu->Delete(0);
- }
- }
- __finally
- {
- delete UsedEditors;
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::EditorItemClick(TObject * Sender)
- {
- int Tag = dynamic_cast<TTBXItem*>(Sender)->Tag;
- if (Tag < 0)
- {
- ScpExplorer->ExecuteFile(osCurrent, efInternalEditor, NULL, true, false);
- }
- else
- {
- const TEditorList * EditorList = WinConfiguration->EditorList;
- // sanity check
- if (Tag < EditorList->Count)
- {
- ScpExplorer->ExecuteFile(osCurrent, efExternalEditor, EditorList->Editors[Tag]->Data,
- true, false);
- }
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::QueuePopupPopup(TObject * /*Sender*/)
- {
- TAction * Action = NULL;
- switch (ScpExplorer->DefaultQueueOperation())
- {
- case qoItemQuery:
- Action = QueueItemQueryAction;
- break;
- case qoItemError:
- Action = QueueItemErrorAction;
- break;
- case qoItemPrompt:
- Action = QueueItemPromptAction;
- break;
- case qoItemExecute:
- Action = QueueItemExecuteAction;
- break;
- case qoItemPause:
- Action = QueueItemPauseAction;
- break;
- case qoItemResume:
- Action = QueueItemResumeAction;
- break;
- }
- TTBCustomItem * Item;
- for (int Index = 0; Index < QueuePopup->Items->Count; Index++)
- {
- Item = QueuePopup->Items->Items[Index];
- TTBItemOptions O = Item->Options;
- if ((Action != NULL) && (Item->Action == Action))
- {
- O << tboDefault;
- }
- else
- {
- O >> tboDefault;
- }
- Item->Options = O;
- }
- QueueSpeedComboBoxItemUpdate(QueuePopupSpeedComboBoxItem);
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::ShowUpdatesUpdate()
- {
- TUpdatesConfiguration Updates = WinConfiguration->Updates;
- unsigned short H, M, S, MS;
- DecodeTime(Now(), H, M, S, MS);
- int CurrentCompoundVer = Configuration->CompoundVersion;
- ShowUpdatesAction->ImageIndex =
- ((Updates.HaveResults && (Updates.Results.ForVersion == CurrentCompoundVer) &&
- !Updates.Results.Disabled &&
- ((Updates.Results.Critical && !Updates.ShownResults && (MS >= 500)) ||
- ((!Updates.Results.Critical || Updates.ShownResults) &&
- ((Updates.Results.Version > CurrentCompoundVer) ||
- !Updates.Results.Message.IsEmpty())))) ? 80 :
- ((int(Updates.Period) <= 0) ? 81 : 63));
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::PreferencesDialog(TPreferencesMode APreferencesMode)
- {
- if (ScpExplorer != NULL)
- {
- ScpExplorer->PreferencesDialog(APreferencesMode);
- }
- else
- {
- DoPreferencesDialog(APreferencesMode);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CustomCommandsLastUpdate(TAction * Action)
- {
- TCustomCommandParam CustomCommand;
- int State;
- bool Defined = ScpExplorer->GetLastCustomCommand(
- (Action == CustomCommandsLastFocusedAction), CustomCommand, State);
- Action->Visible = Defined;
- if (Defined)
- {
- AnsiString TitleCommand = CustomCommand.Command;
- int MaxTitleCommandLen = 20;
- if (TitleCommand.Length() > MaxTitleCommandLen)
- {
- TitleCommand = TitleCommand.SubString(1, MaxTitleCommandLen - 3) + "...";
- }
- Action->Caption = FMTLOAD(CUSTOM_COMMAND_LAST, (TitleCommand));
- Action->Hint = FMTLOAD(CUSTOM_COMMAND_HINT, (CustomCommand.Command));
- Action->Enabled = (State > 0);
- }
- }
- //---------------------------------------------------------------------------
- AnsiString __fastcall TNonVisualDataModule::QueueItemSpeed(const AnsiString & Text,
- TTBXComboBoxItem * Item)
- {
- unsigned long Speed = GetSpeedLimit(Text);
- ScpExplorer->ExecuteQueueOperation(qoItemSpeed, reinterpret_cast<void*>(Speed));
- AnsiString Result = SetSpeedLimit(Speed);
- SaveToHistory(Item->Strings, Result);
- CustomWinConfiguration->History["SpeedLimit"] = Item->Strings;
- return Result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::QueuePopupSpeedComboBoxItemItemClick(
- TObject * Sender)
- {
- TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
- QueueItemSpeedAction->Text = QueueItemSpeed(Item->Text, Item);
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemAcceptText(
- TObject * Sender, AnsiString & NewText, bool & /*Accept*/)
- {
- TTBXComboBoxItem * Item = dynamic_cast<TTBXComboBoxItem *>(Sender);
- NewText = QueueItemSpeed(NewText, Item);
- QueueItemSpeedAction->Text = NewText;
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItem(TTBXComboBoxItem * Item)
- {
- // IDE often looses this link
- Item->OnAcceptText = QueueSpeedComboBoxItemAcceptText;
- Item->OnItemClick = QueuePopupSpeedComboBoxItemItemClick;
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::QueueSpeedComboBoxItemUpdate(TTBXComboBoxItem * Item)
- {
- Item->Strings = CustomWinConfiguration->History["SpeedLimit"];
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::SetQueueOnceEmptyAction(TAction * Action)
- {
- TAction * Current = CurrentQueueOnceEmptyAction();
- if (Current != Action)
- {
- Current->Checked = false;
- Action->Checked = true;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::CycleQueueOnceEmptyAction()
- {
- TAction * Current = CurrentQueueOnceEmptyAction();
- Current->Checked = false;
- if (Current == QueueIdleOnceEmptyAction)
- {
- QueueDisconnectOnceEmptyAction->Checked = true;
- }
- else if (Current == QueueDisconnectOnceEmptyAction)
- {
- QueueShutDownOnceEmptyAction->Checked = true;
- }
- else if (Current == QueueShutDownOnceEmptyAction)
- {
- QueueIdleOnceEmptyAction->Checked = true;
- }
- else
- {
- assert(false);
- }
- }
- //---------------------------------------------------------------------------
- TAction * __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyAction()
- {
- TAction * Result;
- if (QueueIdleOnceEmptyAction->Checked)
- {
- Result = QueueIdleOnceEmptyAction;
- }
- else if (QueueDisconnectOnceEmptyAction->Checked)
- {
- Result = QueueDisconnectOnceEmptyAction;
- }
- else if (QueueShutDownOnceEmptyAction->Checked)
- {
- Result = QueueShutDownOnceEmptyAction;
- }
- else
- {
- assert(false);
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- TOnceDoneOperation __fastcall TNonVisualDataModule::CurrentQueueOnceEmptyOperation()
- {
- TOnceDoneOperation Result;
- TBasicAction * Current = CurrentQueueOnceEmptyAction();
- if (Current == QueueIdleOnceEmptyAction)
- {
- Result = odoIdle;
- }
- else if (Current == QueueDisconnectOnceEmptyAction)
- {
- Result = odoDisconnect;
- }
- else if (Current == QueueShutDownOnceEmptyAction)
- {
- Result = odoShutDown;
- }
- else
- {
- assert(false);
- }
- return Result;
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::ResetQueueOnceEmptyOperation()
- {
- SetQueueOnceEmptyAction(QueueIdleOnceEmptyAction);
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::InitMenuItem(TTBCustomItem * Item)
- {
- TTBSeparatorItem * Separator = dynamic_cast<TTBSeparatorItem *>(Item);
- if (Separator != NULL)
- {
- Separator->Hint = "E";
- }
- for (int Index = 0; Index < Item->Count; Index++)
- {
- InitMenuItem(Item->Items[Index]);
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TNonVisualDataModule::InitMenus(TComponent * Component)
- {
- TTBPopupMenu * Popup = dynamic_cast<TTBPopupMenu *>(Component);
- TTBCustomToolbar * Toolbar = dynamic_cast<TTBCustomToolbar *>(Component);
- if (Popup != NULL)
- {
- InitMenuItem(Popup->Items);
- }
- else if (Toolbar != NULL)
- {
- InitMenuItem(Toolbar->Items);
- }
- else
- {
- // do not try to descend below from toolbar/popup, as there should not be any
- // other menu component and we save some time
- for (int Index = 0; Index < Component->ComponentCount; Index++)
- {
- InitMenus(Component->Components[Index]);
- }
- }
- }
|