|
@@ -10,6 +10,7 @@
|
|
|
#include <CoreMain.h>
|
|
#include <CoreMain.h>
|
|
|
#include <Tools.h>
|
|
#include <Tools.h>
|
|
|
#include <BaseUtils.hpp>
|
|
#include <BaseUtils.hpp>
|
|
|
|
|
+#include <Terminal.h>
|
|
|
#include "FileFind.h"
|
|
#include "FileFind.h"
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
#pragma package(smart_init)
|
|
#pragma package(smart_init)
|
|
@@ -21,30 +22,32 @@
|
|
|
#pragma resource "*.dfm"
|
|
#pragma resource "*.dfm"
|
|
|
#endif
|
|
#endif
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
-bool __fastcall DoFileFindDialog(UnicodeString Directory,
|
|
|
|
|
- TFindEvent OnFind, UnicodeString & Path)
|
|
|
|
|
|
|
+TFileFindDialog * FileFindDialog = NULL;
|
|
|
|
|
+//---------------------------------------------------------------------------
|
|
|
|
|
+void __fastcall ShowFileFindDialog(
|
|
|
|
|
+ TTerminal * Terminal, UnicodeString Directory, TFindEvent OnFind, TFocusFileEvent OnFocusFile)
|
|
|
{
|
|
{
|
|
|
- bool Result;
|
|
|
|
|
- TFileFindDialog * Dialog = new TFileFindDialog(Application, OnFind);
|
|
|
|
|
- try
|
|
|
|
|
|
|
+ if (FileFindDialog == NULL)
|
|
|
{
|
|
{
|
|
|
- Result = Dialog->Execute(Directory, Path);
|
|
|
|
|
|
|
+ FileFindDialog = new TFileFindDialog(Application);
|
|
|
}
|
|
}
|
|
|
- __finally
|
|
|
|
|
|
|
+ FileFindDialog->Init(Terminal, Directory, OnFind, OnFocusFile);
|
|
|
|
|
+ FileFindDialog->Show();
|
|
|
|
|
+}
|
|
|
|
|
+//---------------------------------------------------------------------------
|
|
|
|
|
+void __fastcall HideFileFindDialog()
|
|
|
|
|
+{
|
|
|
|
|
+ if (FileFindDialog != NULL)
|
|
|
{
|
|
{
|
|
|
- delete Dialog;
|
|
|
|
|
|
|
+ FileFindDialog->Close();
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- return Result;
|
|
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
-__fastcall TFileFindDialog::TFileFindDialog(TComponent * Owner, TFindEvent OnFind)
|
|
|
|
|
|
|
+__fastcall TFileFindDialog::TFileFindDialog(TComponent * Owner)
|
|
|
: TForm(Owner)
|
|
: TForm(Owner)
|
|
|
{
|
|
{
|
|
|
UseSystemSettings(this);
|
|
UseSystemSettings(this);
|
|
|
- FOnFind = OnFind;
|
|
|
|
|
FState = ffInit;
|
|
FState = ffInit;
|
|
|
- FMinimizedByMe = false;
|
|
|
|
|
|
|
|
|
|
FixComboBoxResizeBug(MaskEdit);
|
|
FixComboBoxResizeBug(MaskEdit);
|
|
|
FixComboBoxResizeBug(RemoteDirectoryEdit);
|
|
FixComboBoxResizeBug(RemoteDirectoryEdit);
|
|
@@ -61,17 +64,27 @@ __fastcall TFileFindDialog::TFileFindDialog(TComponent * Owner, TFindEvent OnFin
|
|
|
UseDesktopFont(FileView);
|
|
UseDesktopFont(FileView);
|
|
|
UseDesktopFont(StatusBar);
|
|
UseDesktopFont(StatusBar);
|
|
|
|
|
|
|
|
- SetGlobalMinimizeHandler(this, GlobalMinimize);
|
|
|
|
|
FFrameAnimation.Init(AnimationPaintBox, L"Find");
|
|
FFrameAnimation.Init(AnimationPaintBox, L"Find");
|
|
|
FixFormIcons(this);
|
|
FixFormIcons(this);
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
__fastcall TFileFindDialog::~TFileFindDialog()
|
|
__fastcall TFileFindDialog::~TFileFindDialog()
|
|
|
{
|
|
{
|
|
|
- ClearGlobalMinimizeHandler(GlobalMinimize);
|
|
|
|
|
|
|
+ TFindFileConfiguration FormConfiguration = CustomWinConfiguration->FindFile;
|
|
|
|
|
+ FormConfiguration.ListParams = FileView->ColProperties->ParamsStr;
|
|
|
|
|
+ UnicodeString WindowParams = StoreFormSize(this);
|
|
|
|
|
+ // this is particularly to prevent saving the form state
|
|
|
|
|
+ // for the first time, keeping default positioning by a system
|
|
|
|
|
+ if (!FWindowParams.IsEmpty() && (FWindowParams != WindowParams))
|
|
|
|
|
+ {
|
|
|
|
|
+ FormConfiguration.WindowParams = WindowParams;
|
|
|
|
|
+ }
|
|
|
|
|
+ CustomWinConfiguration->FindFile = FormConfiguration;
|
|
|
|
|
|
|
|
Clear();
|
|
Clear();
|
|
|
delete FSystemImageList;
|
|
delete FSystemImageList;
|
|
|
|
|
+ DebugAssert(FileFindDialog == this);
|
|
|
|
|
+ FileFindDialog = NULL;
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
bool __fastcall TFileFindDialog::IsFinding()
|
|
bool __fastcall TFileFindDialog::IsFinding()
|
|
@@ -82,7 +95,7 @@ bool __fastcall TFileFindDialog::IsFinding()
|
|
|
void __fastcall TFileFindDialog::UpdateControls()
|
|
void __fastcall TFileFindDialog::UpdateControls()
|
|
|
{
|
|
{
|
|
|
bool Finding = IsFinding();
|
|
bool Finding = IsFinding();
|
|
|
- Caption = LoadStr(Finding ? FIND_FILE_FINDING : FIND_FILE_TITLE);
|
|
|
|
|
|
|
+ Caption = FORMAT("%s - %s", (LoadStr(Finding ? FIND_FILE_FINDING : FIND_FILE_TITLE), FTerminalName));
|
|
|
UnicodeString StartStopCaption;
|
|
UnicodeString StartStopCaption;
|
|
|
if (Finding)
|
|
if (Finding)
|
|
|
{
|
|
{
|
|
@@ -95,9 +108,7 @@ void __fastcall TFileFindDialog::UpdateControls()
|
|
|
StartStopCaption = LoadStr(FIND_FILE_START);
|
|
StartStopCaption = LoadStr(FIND_FILE_START);
|
|
|
}
|
|
}
|
|
|
StartStopButton->Caption = StartStopCaption;
|
|
StartStopButton->Caption = StartStopCaption;
|
|
|
- CancelButton->Visible = !Finding;
|
|
|
|
|
EnableControl(FilterGroup, !Finding);
|
|
EnableControl(FilterGroup, !Finding);
|
|
|
- MinimizeButton->Visible = Finding;
|
|
|
|
|
EnableControl(FocusButton, (FileView->ItemFocused != NULL));
|
|
EnableControl(FocusButton, (FileView->ItemFocused != NULL));
|
|
|
EnableControl(CopyButton, (FileView->Items->Count > 0));
|
|
EnableControl(CopyButton, (FileView->Items->Count > 0));
|
|
|
switch (FState)
|
|
switch (FState)
|
|
@@ -137,30 +148,30 @@ void __fastcall TFileFindDialog::ControlChange(TObject * /*Sender*/)
|
|
|
UpdateControls();
|
|
UpdateControls();
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
-bool __fastcall TFileFindDialog::Execute(UnicodeString Directory, UnicodeString & Path)
|
|
|
|
|
|
|
+void __fastcall TFileFindDialog::Init(
|
|
|
|
|
+ TTerminal * Terminal, UnicodeString Directory, TFindEvent OnFind, TFocusFileEvent OnFocusFile)
|
|
|
{
|
|
{
|
|
|
- MaskEdit->Text = WinConfiguration->SelectMask;
|
|
|
|
|
- RemoteDirectoryEdit->Text = UnixExcludeTrailingBackslash(Directory);
|
|
|
|
|
-
|
|
|
|
|
- // have to set history after value, to prevent autocompletition
|
|
|
|
|
- MaskEdit->Items = WinConfiguration->History[L"Mask"];
|
|
|
|
|
- RemoteDirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteDirectory"];
|
|
|
|
|
-
|
|
|
|
|
- bool Result = (ShowModal() == FocusButton->ModalResult);
|
|
|
|
|
- if (Result)
|
|
|
|
|
|
|
+ if (FTerminal != Terminal)
|
|
|
{
|
|
{
|
|
|
- Path = static_cast<TRemoteFile *>(FileView->ItemFocused->Data)->FullFileName;
|
|
|
|
|
- // To make focussing directories work,
|
|
|
|
|
- // otherwise it would try to focus "empty-named file" in the Path
|
|
|
|
|
- Path = UnixExcludeTrailingBackslash(Path);
|
|
|
|
|
|
|
+ FTerminal = Terminal;
|
|
|
|
|
+ FTerminalName = Terminal->SessionData->SessionName;
|
|
|
|
|
+ Clear();
|
|
|
|
|
+ FState = ffInit;
|
|
|
|
|
+ ActiveControl = MaskEdit;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- TFindFileConfiguration FormConfiguration = CustomWinConfiguration->FindFile;
|
|
|
|
|
- FormConfiguration.ListParams = FileView->ColProperties->ParamsStr;
|
|
|
|
|
- FormConfiguration.WindowParams = StoreFormSize(this);
|
|
|
|
|
- CustomWinConfiguration->FindFile = FormConfiguration;
|
|
|
|
|
|
|
+ FOnFind = OnFind;
|
|
|
|
|
+ FOnFocusFile = OnFocusFile;
|
|
|
|
|
|
|
|
- return Result;
|
|
|
|
|
|
|
+ MaskEdit->Text = WinConfiguration->SelectMask;
|
|
|
|
|
+ RemoteDirectoryEdit->Text = UnixExcludeTrailingBackslash(Directory);
|
|
|
|
|
+ UpdateControls();
|
|
|
|
|
+}
|
|
|
|
|
+//---------------------------------------------------------------------------
|
|
|
|
|
+void __fastcall TFileFindDialog::CreateParams(TCreateParams & Params)
|
|
|
|
|
+{
|
|
|
|
|
+ TForm::CreateParams(Params);
|
|
|
|
|
+ Params.WndParent = GetDesktopWindow();
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TFileFindDialog::Clear()
|
|
void __fastcall TFileFindDialog::Clear()
|
|
@@ -209,7 +220,7 @@ void __fastcall TFileFindDialog::Start()
|
|
|
FDirectory = UnicodeString();
|
|
FDirectory = UnicodeString();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- FOnFind(Directory, MaskEdit->Text, FileFound, FindingFile);
|
|
|
|
|
|
|
+ FOnFind(FTerminal, Directory, MaskEdit->Text, FileFound, FindingFile);
|
|
|
}
|
|
}
|
|
|
__finally
|
|
__finally
|
|
|
{
|
|
{
|
|
@@ -223,13 +234,20 @@ void __fastcall TFileFindDialog::Start()
|
|
|
FState = ffAborted;
|
|
FState = ffAborted;
|
|
|
}
|
|
}
|
|
|
FFrameAnimation.Stop();
|
|
FFrameAnimation.Stop();
|
|
|
- if (IsApplicationMinimized() && FMinimizedByMe)
|
|
|
|
|
|
|
+ if (WindowState == wsMinimized)
|
|
|
{
|
|
{
|
|
|
ShowNotification(
|
|
ShowNotification(
|
|
|
NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)),
|
|
NULL, MainInstructions(LoadStr(BALLOON_OPERATION_COMPLETE)),
|
|
|
qtInformation);
|
|
qtInformation);
|
|
|
- FMinimizedByMe = false;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (!FFocusPath.IsEmpty())
|
|
|
|
|
+ {
|
|
|
|
|
+ UnicodeString FocusPath = FFocusPath;
|
|
|
|
|
+ FFocusPath = L"";
|
|
|
|
|
+ DoFocusFile(FocusPath);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
UpdateControls();
|
|
UpdateControls();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -317,25 +335,25 @@ void __fastcall TFileFindDialog::Stop()
|
|
|
UpdateControls();
|
|
UpdateControls();
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
-void __fastcall TFileFindDialog::MinimizeButtonClick(TObject * Sender)
|
|
|
|
|
-{
|
|
|
|
|
- CallGlobalMinimizeHandler(Sender);
|
|
|
|
|
-}
|
|
|
|
|
-//---------------------------------------------------------------------------
|
|
|
|
|
-void __fastcall TFileFindDialog::GlobalMinimize(TObject * /*Sender*/)
|
|
|
|
|
-{
|
|
|
|
|
- ApplicationMinimize();
|
|
|
|
|
- FMinimizedByMe = true;
|
|
|
|
|
-}
|
|
|
|
|
-//---------------------------------------------------------------------------
|
|
|
|
|
void __fastcall TFileFindDialog::FormShow(TObject * /*Sender*/)
|
|
void __fastcall TFileFindDialog::FormShow(TObject * /*Sender*/)
|
|
|
{
|
|
{
|
|
|
InstallPathWordBreakProc(MaskEdit);
|
|
InstallPathWordBreakProc(MaskEdit);
|
|
|
InstallPathWordBreakProc(RemoteDirectoryEdit);
|
|
InstallPathWordBreakProc(RemoteDirectoryEdit);
|
|
|
|
|
|
|
|
|
|
+ // have to set history after value, to prevent autocompletition
|
|
|
|
|
+ MaskEdit->Items = WinConfiguration->History[L"Mask"];
|
|
|
|
|
+ RemoteDirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteDirectory"];
|
|
|
|
|
+
|
|
|
UpdateFormPosition(this, poOwnerFormCenter);
|
|
UpdateFormPosition(this, poOwnerFormCenter);
|
|
|
RestoreFormSize(CustomWinConfiguration->FindFile.WindowParams, this);
|
|
RestoreFormSize(CustomWinConfiguration->FindFile.WindowParams, this);
|
|
|
FileView->ColProperties->ParamsStr = CustomWinConfiguration->FindFile.ListParams;
|
|
FileView->ColProperties->ParamsStr = CustomWinConfiguration->FindFile.ListParams;
|
|
|
|
|
+
|
|
|
|
|
+ DebugAssert(FWindowParams.IsEmpty());
|
|
|
|
|
+ if (FWindowParams.IsEmpty())
|
|
|
|
|
+ {
|
|
|
|
|
+ FWindowParams = StoreFormSize(this);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
UpdateControls();
|
|
UpdateControls();
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
@@ -360,19 +378,47 @@ void __fastcall TFileFindDialog::HelpButtonClick(TObject * /*Sender*/)
|
|
|
FormHelp(this);
|
|
FormHelp(this);
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
-void __fastcall TFileFindDialog::FormKeyDown(TObject * /*Sender*/, WORD & Key,
|
|
|
|
|
- TShiftState Shift)
|
|
|
|
|
|
|
+void __fastcall TFileFindDialog::Dispatch(void * Message)
|
|
|
{
|
|
{
|
|
|
- if ((Key == VK_ESCAPE) && StopIfFinding())
|
|
|
|
|
|
|
+ TMessage * M = reinterpret_cast<TMessage*>(Message);
|
|
|
|
|
+ if (M->Msg == CM_DIALOGKEY)
|
|
|
{
|
|
{
|
|
|
- Key = 0;
|
|
|
|
|
|
|
+ CMDialogKey(*((TWMKeyDown *)Message));
|
|
|
}
|
|
}
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ TForm::Dispatch(Message);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+//---------------------------------------------------------------------------
|
|
|
|
|
+void __fastcall TFileFindDialog::CMDialogKey(TWMKeyDown & Message)
|
|
|
|
|
+{
|
|
|
|
|
+ // Handling VK_ESCAPE in FormKeyDown causes a beep when any "edit" has focus.
|
|
|
|
|
+ // Moreover FormKeyDown is called when the the "esc" is pressed while drop down list is unrolled.
|
|
|
|
|
+ if (Message.CharCode == VK_ESCAPE)
|
|
|
|
|
+ {
|
|
|
|
|
+ Close();
|
|
|
|
|
+ Message.Result = 1;
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ TForm::Dispatch(&Message);
|
|
|
|
|
+}
|
|
|
|
|
+//---------------------------------------------------------------------------
|
|
|
|
|
+void __fastcall TFileFindDialog::FormKeyDown(TObject * /*Sender*/, WORD & Key,
|
|
|
|
|
+ TShiftState Shift)
|
|
|
|
|
+{
|
|
|
if ((Key == L'C') && Shift.Contains(ssCtrl) &&
|
|
if ((Key == L'C') && Shift.Contains(ssCtrl) &&
|
|
|
(dynamic_cast<TCustomCombo *>(ActiveControl) == NULL))
|
|
(dynamic_cast<TCustomCombo *>(ActiveControl) == NULL))
|
|
|
{
|
|
{
|
|
|
CopyToClipboard();
|
|
CopyToClipboard();
|
|
|
Key = 0;
|
|
Key = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ else if ((Key == VK_F10) && Shift.Empty())
|
|
|
|
|
+ {
|
|
|
|
|
+ Key = 0;
|
|
|
|
|
+ StopIfFinding();
|
|
|
|
|
+ Close();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TFileFindDialog::MaskEditExit(TObject * /*Sender*/)
|
|
void __fastcall TFileFindDialog::MaskEditExit(TObject * /*Sender*/)
|
|
@@ -380,18 +426,39 @@ void __fastcall TFileFindDialog::MaskEditExit(TObject * /*Sender*/)
|
|
|
ValidateMaskEdit(MaskEdit);
|
|
ValidateMaskEdit(MaskEdit);
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
+void __fastcall TFileFindDialog::DoFocusFile(const UnicodeString & Path)
|
|
|
|
|
+{
|
|
|
|
|
+ FOnFocusFile(FTerminal, Path);
|
|
|
|
|
+}
|
|
|
|
|
+//---------------------------------------------------------------------------
|
|
|
|
|
+void __fastcall TFileFindDialog::FocusFile()
|
|
|
|
|
+{
|
|
|
|
|
+ UnicodeString Path = static_cast<TRemoteFile *>(FileView->ItemFocused->Data)->FullFileName;
|
|
|
|
|
+ // To make focussing directories work,
|
|
|
|
|
+ // otherwise it would try to focus "empty-named file" in the Path
|
|
|
|
|
+ Path = UnixExcludeTrailingBackslash(Path);
|
|
|
|
|
+
|
|
|
|
|
+ if (StopIfFinding())
|
|
|
|
|
+ {
|
|
|
|
|
+ FFocusPath = Path;
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ DoFocusFile(Path);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+//---------------------------------------------------------------------------
|
|
|
void __fastcall TFileFindDialog::FileViewDblClick(TObject * /*Sender*/)
|
|
void __fastcall TFileFindDialog::FileViewDblClick(TObject * /*Sender*/)
|
|
|
{
|
|
{
|
|
|
if (FileView->ItemFocused != NULL)
|
|
if (FileView->ItemFocused != NULL)
|
|
|
{
|
|
{
|
|
|
- StopIfFinding();
|
|
|
|
|
- ModalResult = FocusButton->ModalResult;
|
|
|
|
|
|
|
+ FocusFile();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TFileFindDialog::FocusButtonClick(TObject * /*Sender*/)
|
|
void __fastcall TFileFindDialog::FocusButtonClick(TObject * /*Sender*/)
|
|
|
{
|
|
{
|
|
|
- StopIfFinding();
|
|
|
|
|
|
|
+ FocusFile();
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TFileFindDialog::FileViewSelectItem(TObject * /*Sender*/,
|
|
void __fastcall TFileFindDialog::FileViewSelectItem(TObject * /*Sender*/,
|
|
@@ -427,19 +494,9 @@ void __fastcall TFileFindDialog::CopyButtonClick(TObject * /*Sender*/)
|
|
|
CopyToClipboard();
|
|
CopyToClipboard();
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|
|
|
-void __fastcall TFileFindDialog::Dispatch(void * Message)
|
|
|
|
|
|
|
+void __fastcall TFileFindDialog::FormClose(TObject * /*Sender*/, TCloseAction & Action)
|
|
|
{
|
|
{
|
|
|
- TMessage * M = reinterpret_cast<TMessage*>(Message);
|
|
|
|
|
- if (M->Msg == WM_SYSCOMMAND)
|
|
|
|
|
- {
|
|
|
|
|
- if (!HandleMinimizeSysCommand(*M))
|
|
|
|
|
- {
|
|
|
|
|
- TForm::Dispatch(Message);
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- TForm::Dispatch(Message);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ StopIfFinding();
|
|
|
|
|
+ Action = caFree;
|
|
|
}
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------
|