mirror of
https://github.com/winscp/winscp.git
synced 2026-10-24 02:28:55 +03:00
Streamlining edit history implementation + Bug fix: Some edits did not save their value to history when submitting with Enter
Source commit: 831a1ec2dd65d1dca58fcba246d02c77e156bcc6
This commit is contained in:
@@ -35,7 +35,7 @@
|
||||
<BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
|
||||
<BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
|
||||
<BCC_UseClassicCompiler>false</BCC_UseClassicCompiler>
|
||||
<BCC_UserSuppliedOptions>-Wno-ignored-attributes -Wno-padded -Wno-language-extension-token -Wno-c++98-compat-pedantic -Wno-zero-as-null-pointer-constant -Wno-old-style-cast</BCC_UserSuppliedOptions>
|
||||
<BCC_UserSuppliedOptions>-Wno-ignored-attributes -Wno-padded -Wno-language-extension-token -Wno-c++98-compat-pedantic -Wno-zero-as-null-pointer-constant -Wno-old-style-cast -Wno-global-constructors</BCC_UserSuppliedOptions>
|
||||
<BPILibOutputDir>$(INTERM_PATH)\$(Platform)\$(Config)</BPILibOutputDir>
|
||||
<DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
|
||||
<DCC_CVT_ACHAR_TO_WCHAR>true</DCC_CVT_ACHAR_TO_WCHAR>
|
||||
|
||||
@@ -122,8 +122,6 @@ bool __fastcall TConsoleDialog::Execute(const UnicodeString Command,
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandEdit->Items = CustomWinConfiguration->History[L"Commands"];
|
||||
|
||||
if (Log != NULL)
|
||||
{
|
||||
OutputMemo->Lines->BeginUpdate();
|
||||
@@ -162,7 +160,6 @@ bool __fastcall TConsoleDialog::Execute(const UnicodeString Command,
|
||||
if (FTerminal)
|
||||
{
|
||||
CommandEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"Commands"] = CommandEdit->Items;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -1455,6 +1455,7 @@ object ConsoleDialog: TConsoleDialog
|
||||
MaxLength = 2048
|
||||
TabOrder = 0
|
||||
OnChange = CommandEditChange
|
||||
HistoryKey = 'Commands'
|
||||
end
|
||||
object ExecuteButton: TButton
|
||||
Left = 377
|
||||
|
||||
@@ -402,8 +402,7 @@ bool __fastcall TCopyDialog::Execute()
|
||||
{
|
||||
// at start assume that copy param is current preset
|
||||
FPreset = GUIConfiguration->CopyParamCurrent;
|
||||
DirectoryEdit->Items = CustomWinConfiguration->History[
|
||||
FToRemote ? L"RemoteTarget" : L"LocalTarget"];
|
||||
DirectoryEdit->HistoryKey = FToRemote ? L"RemoteTarget" : L"LocalTarget";
|
||||
FExplore = false;
|
||||
bool Result = (ShowModal() == DefaultResult(this));
|
||||
if (Result)
|
||||
@@ -416,8 +415,6 @@ bool __fastcall TCopyDialog::Execute()
|
||||
GUIConfiguration->DefaultCopyParam = Params;
|
||||
}
|
||||
DirectoryEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[FToRemote ?
|
||||
L"RemoteTarget" : L"LocalTarget"] = DirectoryEdit->Items;
|
||||
|
||||
if (FLAGSET(FOptions, coShortCutHint))
|
||||
{
|
||||
|
||||
@@ -48,7 +48,6 @@ TCopyLocalDialog::TCopyLocalDialog(TComponent * Owner, bool Move, int Options)
|
||||
//---------------------------------------------------------------------------
|
||||
bool TCopyLocalDialog::Execute(UnicodeString & TargetDirectory, UnicodeString & FileMask, int & OutputOptions)
|
||||
{
|
||||
DirectoryEdit->Items = CustomWinConfiguration->History[L"LocalTarget"];
|
||||
SetDirectoryAndFileMask(TargetDirectory, FileMask);
|
||||
NeverShowAgainCheck->Checked = FLAGSET(OutputOptions, clooDoNotShowAgain);
|
||||
DebugAssert((OutputOptions & ~clooDoNotShowAgain) == 0);
|
||||
@@ -56,9 +55,7 @@ bool TCopyLocalDialog::Execute(UnicodeString & TargetDirectory, UnicodeString &
|
||||
if (Result)
|
||||
{
|
||||
ValidateDirectoryEdit();
|
||||
|
||||
DirectoryEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"LocalTarget"] = DirectoryEdit->Items;
|
||||
|
||||
FileMask = GetFileMask();
|
||||
TargetDirectory = GetDirectory();
|
||||
|
||||
@@ -48,6 +48,7 @@ object CopyLocalDialog: TCopyLocalDialog
|
||||
TabOrder = 0
|
||||
Text = 'DirectoryEdit'
|
||||
OnExit = DirectoryEditExit
|
||||
HistoryKey = 'LocalTarget'
|
||||
end
|
||||
object OkButton: TButton
|
||||
Left = 251
|
||||
|
||||
@@ -231,8 +231,6 @@ void __fastcall TCopyParamsFrame::BeforeExecute()
|
||||
// adding TRightsFrame on run-time corrupts the tab order, fix it
|
||||
TransferModeGroup->TabOrder = 0;
|
||||
DebugAssert(CustomWinConfiguration);
|
||||
AsciiFileMaskCombo->Items = CustomWinConfiguration->History[L"Mask"];
|
||||
IncludeFileMaskCombo->Items = CustomWinConfiguration->History[L"IncludeMask"];
|
||||
CopySpeedLimits(CustomWinConfiguration->History[L"SpeedLimit"], SpeedCombo->Items);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -240,9 +238,7 @@ void __fastcall TCopyParamsFrame::AfterExecute()
|
||||
{
|
||||
DebugAssert(CustomWinConfiguration);
|
||||
AsciiFileMaskCombo->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"Mask"] = AsciiFileMaskCombo->Items;
|
||||
IncludeFileMaskCombo->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"IncludeMask"] = IncludeFileMaskCombo->Items;
|
||||
SpeedCombo->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"SpeedLimit"] = SpeedCombo->Items;
|
||||
}
|
||||
|
||||
@@ -295,6 +295,7 @@ object CopyParamsFrame: TCopyParamsFrame
|
||||
TabOrder = 3
|
||||
Text = 'AsciiFileMaskCombo'
|
||||
OnExit = ValidateMaskComboExit
|
||||
HistoryKey = 'Mask'
|
||||
end
|
||||
end
|
||||
object OtherGroup: TGroupBox
|
||||
@@ -326,6 +327,7 @@ object CopyParamsFrame: TCopyParamsFrame
|
||||
TabOrder = 0
|
||||
Text = 'IncludeFileMaskCombo'
|
||||
OnExit = ValidateMaskComboExit
|
||||
HistoryKey = 'IncludeMask'
|
||||
end
|
||||
object IncludeFileMaskButton: TButton
|
||||
Left = 361
|
||||
|
||||
@@ -825,7 +825,7 @@ __fastcall TRemoteMoveDialog::TRemoteMoveDialog(bool Multi, TDirectoryExistsEven
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall TRemoteMoveDialog::Execute(UnicodeString & Target, UnicodeString & FileMask)
|
||||
{
|
||||
Combo->Items = CustomWinConfiguration->History[L"RemoteTarget"];
|
||||
Combo->HistoryKey = L"RemoteTarget";
|
||||
Combo->Text = UnixIncludeTrailingBackslash(Target) + FileMask;
|
||||
bool Result = TCustomDialog::Execute();
|
||||
if (Result)
|
||||
@@ -833,7 +833,6 @@ bool __fastcall TRemoteMoveDialog::Execute(UnicodeString & Target, UnicodeString
|
||||
Target = UnixExtractFilePath(Combo->Text);
|
||||
FileMask = GetFileMask();
|
||||
Combo->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"RemoteTarget"] = Combo->Items;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
@@ -899,11 +898,10 @@ private:
|
||||
UnicodeString FSite;
|
||||
TComboBox * FShortCutCombo;
|
||||
|
||||
UnicodeString __fastcall HistoryKey(const TCustomCommandType::TOption & Option);
|
||||
THistoryComboBox * __fastcall CreateHistoryComboBox(const TCustomCommandType::TOption & Option, const UnicodeString & Value);
|
||||
void __fastcall BrowseButtonClick(TObject * Sender);
|
||||
void __fastcall LinkLabelClick(TObject * Sender);
|
||||
UnicodeString __fastcall SaveHistoryComboBoxValue(TControl * Control, const TCustomCommandType::TOption & Option);
|
||||
UnicodeString __fastcall SaveHistoryComboBoxValue(TControl * Control);
|
||||
void __fastcall AddOptionComboBox(
|
||||
TComboBox * ComboBox, const UnicodeString & Value, const TCustomCommandType::TOption & Option,
|
||||
std::vector<UnicodeString> & Values);
|
||||
@@ -1194,18 +1192,16 @@ THistoryComboBox * __fastcall TCustomCommandOptionsDialog::CreateHistoryComboBox
|
||||
THistoryComboBox * ComboBox = new THistoryComboBox(this);
|
||||
ComboBox->AutoComplete = false;
|
||||
AddComboBox(ComboBox, CreateLabel(Option.Caption));
|
||||
ComboBox->Items = CustomWinConfiguration->History[HistoryKey(Option)];
|
||||
|
||||
UnicodeString HistoryKey = FCommand->GetOptionKey(Option, FSite);
|
||||
HistoryKey = CustomWinConfiguration->GetValidHistoryKey(HistoryKey);
|
||||
HistoryKey = L"CustomCommandOption_" + HistoryKey;
|
||||
ComboBox->HistoryKey = HistoryKey;
|
||||
|
||||
ComboBox->Text = Value;
|
||||
return ComboBox;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString __fastcall TCustomCommandOptionsDialog::HistoryKey(const TCustomCommandType::TOption & Option)
|
||||
{
|
||||
UnicodeString Result = FCommand->GetOptionKey(Option, FSite);
|
||||
Result = CustomWinConfiguration->GetValidHistoryKey(Result);
|
||||
return L"CustomCommandOption_" + Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall TCustomCommandOptionsDialog::Execute(TShortCut * ShortCut)
|
||||
{
|
||||
if (ShortCut != NULL)
|
||||
@@ -1233,11 +1229,11 @@ bool __fastcall TCustomCommandOptionsDialog::Execute(TShortCut * ShortCut)
|
||||
UnicodeString Value;
|
||||
if (Option.Kind == TCustomCommandType::okTextBox)
|
||||
{
|
||||
Value = SaveHistoryComboBoxValue(Control, Option);
|
||||
Value = SaveHistoryComboBoxValue(Control);
|
||||
}
|
||||
else if (Option.Kind == TCustomCommandType::okFile)
|
||||
{
|
||||
Value = SaveHistoryComboBoxValue(Control, Option);
|
||||
Value = SaveHistoryComboBoxValue(Control);
|
||||
}
|
||||
else if (Option.Kind == TCustomCommandType::okDropDownList)
|
||||
{
|
||||
@@ -1293,12 +1289,10 @@ UnicodeString __fastcall TCustomCommandOptionsDialog::GetComboBoxValue(
|
||||
return Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString __fastcall TCustomCommandOptionsDialog::SaveHistoryComboBoxValue(
|
||||
TControl * Control, const TCustomCommandType::TOption & Option)
|
||||
UnicodeString __fastcall TCustomCommandOptionsDialog::SaveHistoryComboBoxValue(TControl * Control)
|
||||
{
|
||||
THistoryComboBox * ComboBox = DebugNotNull(dynamic_cast<THistoryComboBox *>(Control));
|
||||
ComboBox->SaveToHistory();
|
||||
CustomWinConfiguration->History[HistoryKey(Option)] = ComboBox->Items;
|
||||
return ComboBox->Text;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
@@ -166,7 +166,6 @@ void __fastcall TCustomCommandDialog::ControlChange(TObject * /*Sender*/)
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall TCustomCommandDialog::Execute(TCustomCommandType & Command)
|
||||
{
|
||||
CommandEdit->Items = CustomWinConfiguration->History[L"CustomCommand"];
|
||||
if (CommandEdit->Items->Count == 0)
|
||||
{
|
||||
for (int i = 0; i < FCustomCommandList->Count; i++)
|
||||
@@ -190,7 +189,6 @@ bool __fastcall TCustomCommandDialog::Execute(TCustomCommandType & Command)
|
||||
GetCommand(Command);
|
||||
|
||||
CommandEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"CustomCommand"] = CommandEdit->Items;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
@@ -77,6 +77,7 @@ object CustomCommandDialog: TCustomCommandDialog
|
||||
OnChange = ControlChange
|
||||
OnGetData = CommandEditGetData
|
||||
OnSetData = CommandEditSetData
|
||||
HistoryKey = 'CustomCommand'
|
||||
end
|
||||
object ApplyToDirectoriesCheck: TCheckBox
|
||||
Left = 11
|
||||
|
||||
@@ -108,10 +108,8 @@ bool __fastcall TEditorPreferencesDialog::Execute(TEditorData * Editor, bool & R
|
||||
ReformatFileNameCommand(ExternalEditor);
|
||||
}
|
||||
ExternalEditorEdit->Text = ExternalEditor;
|
||||
ExternalEditorEdit->Items = CustomWinConfiguration->History[L"ExternalEditor"];
|
||||
FExternalEditorDefaults = GetExternalEditorDefaults();
|
||||
MaskEdit->Text = Editor->FileMask.Masks;
|
||||
MaskEdit->Items = CustomWinConfiguration->History[L"Mask"];
|
||||
ExternalEditorTextCheck->Checked = Editor->ExternalEditorText;
|
||||
SDIExternalEditorCheck->Checked = Editor->SDIExternalEditor;
|
||||
RememberCheck->Checked = Remember;
|
||||
@@ -135,10 +133,8 @@ bool __fastcall TEditorPreferencesDialog::Execute(TEditorData * Editor, bool & R
|
||||
}
|
||||
Editor->ExternalEditor = ExternalEditorEdit->Text;
|
||||
ExternalEditorEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"ExternalEditor"] = ExternalEditorEdit->Items;
|
||||
Editor->FileMask = MaskEdit->Text;
|
||||
MaskEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"Mask"] = MaskEdit->Items;
|
||||
Editor->ExternalEditorText = ExternalEditorTextCheck->Checked;
|
||||
Editor->SDIExternalEditor = SDIExternalEditorCheck->Checked;
|
||||
Remember = RememberCheck->Checked;
|
||||
|
||||
@@ -91,6 +91,7 @@ object EditorPreferencesDialog: TEditorPreferencesDialog
|
||||
Text = 'ExternalEditorEdit'
|
||||
OnChange = ControlChange
|
||||
OnExit = ExternalEditorEditExit
|
||||
HistoryKey = 'ExternalEditor'
|
||||
end
|
||||
object ExternalEditorBrowseButton: TButton
|
||||
Left = 342
|
||||
@@ -151,6 +152,7 @@ object EditorPreferencesDialog: TEditorPreferencesDialog
|
||||
TabOrder = 0
|
||||
Text = '*.*'
|
||||
OnExit = MaskEditExit
|
||||
HistoryKey = 'Mask'
|
||||
end
|
||||
end
|
||||
object OkButton: TButton
|
||||
|
||||
@@ -206,9 +206,7 @@ void __fastcall TFileFindDialog::Start()
|
||||
}
|
||||
|
||||
RemoteDirectoryEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"RemoteDirectory"] = RemoteDirectoryEdit->Items;
|
||||
MaskEdit->SaveToHistory();
|
||||
WinConfiguration->History[L"Mask"] = MaskEdit->Items;
|
||||
WinConfiguration->SelectMask = MaskEdit->Text;
|
||||
|
||||
DebugAssert(FState != ffFinding);
|
||||
@@ -398,10 +396,6 @@ void __fastcall TFileFindDialog::FormShow(TObject * /*Sender*/)
|
||||
InstallPathWordBreakProc(MaskEdit);
|
||||
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);
|
||||
RestoreFormSize(CustomWinConfiguration->FindFile.WindowParams, this);
|
||||
UnicodeString S = CustomWinConfiguration->FindFile.ListParams;
|
||||
|
||||
@@ -1415,6 +1415,7 @@ object FileFindDialog: TFileFindDialog
|
||||
TabOrder = 3
|
||||
Text = 'RemoteDirectoryEdit'
|
||||
OnChange = ControlChange
|
||||
HistoryKey = 'RemoteDirectory'
|
||||
end
|
||||
object MaskEdit: THistoryComboBox
|
||||
Left = 49
|
||||
@@ -1428,6 +1429,7 @@ object FileFindDialog: TFileFindDialog
|
||||
Text = 'MaskEdit'
|
||||
OnChange = ControlChange
|
||||
OnExit = MaskEditExit
|
||||
HistoryKey = 'Mask'
|
||||
end
|
||||
object MaskHintText: TStaticText
|
||||
Left = 213
|
||||
|
||||
@@ -198,17 +198,11 @@ void __fastcall TFullSynchronizeDialog::ControlChange(TObject * /*Sender*/)
|
||||
UpdateControls();
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString TFullSynchronizeDialog::GetRightDirectoryHistory()
|
||||
{
|
||||
return FLAGCLEAR(FOptions, fsoLocalLocal) ? L"RemoteDirectory" : L"LocalDirectory2";
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall TFullSynchronizeDialog::Execute()
|
||||
{
|
||||
// at start assume that copy param is current preset
|
||||
FPreset = GUIConfiguration->CopyParamCurrent;
|
||||
LocalDirectoryEdit->Items = CustomWinConfiguration->History[L"LocalDirectory"];
|
||||
RemoteDirectoryEdit->Items = CustomWinConfiguration->History[GetRightDirectoryHistory()];
|
||||
RemoteDirectoryEdit->HistoryKey = FLAGCLEAR(FOptions, fsoLocalLocal) ? L"RemoteDirectory" : L"LocalDirectory2";
|
||||
bool Result = (ShowModal() == DefaultResult(this));
|
||||
if (Result)
|
||||
{
|
||||
@@ -220,9 +214,7 @@ bool __fastcall TFullSynchronizeDialog::Execute()
|
||||
void __fastcall TFullSynchronizeDialog::Submitted()
|
||||
{
|
||||
LocalDirectoryEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"LocalDirectory"] = LocalDirectoryEdit->Items;
|
||||
RemoteDirectoryEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[GetRightDirectoryHistory()] = RemoteDirectoryEdit->Items;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void TFullSynchronizeDialog::SetDirectory2(const UnicodeString & value)
|
||||
|
||||
@@ -78,6 +78,7 @@ object FullSynchronizeDialog: TFullSynchronizeDialog
|
||||
TabOrder = 0
|
||||
Text = 'LocalDirectoryEdit'
|
||||
OnChange = ControlChange
|
||||
HistoryKey = 'LocalDirectory'
|
||||
end
|
||||
object LocalDirectoryBrowseButton: TButton
|
||||
Left = 429
|
||||
|
||||
@@ -101,7 +101,6 @@ private:
|
||||
void __fastcall StartInNewWindow();
|
||||
void DoLocalDirectoryBrowseButtonClick(TComboBox * ComboBox);
|
||||
bool CanSynchronizeTimestamps();
|
||||
UnicodeString GetRightDirectoryHistory();
|
||||
|
||||
public:
|
||||
__fastcall TFullSynchronizeDialog(TComponent* Owner);
|
||||
|
||||
@@ -160,13 +160,12 @@ __fastcall TPreferencesDialog::~TPreferencesDialog()
|
||||
//---------------------------------------------------------------------
|
||||
bool __fastcall TPreferencesDialog::Execute(TPreferencesDialogData * DialogData)
|
||||
{
|
||||
PuttyPathEdit->Items = CustomWinConfiguration->History[L"PuttyPath"];
|
||||
FDialogData = DialogData;
|
||||
bool Result = (ShowModal() == DefaultResult(this));
|
||||
if (Result)
|
||||
{
|
||||
SaveConfiguration();
|
||||
CustomWinConfiguration->History[L"PuttyPath"] = PuttyPathEdit->Items;
|
||||
PuttyPathEdit->SaveToHistory();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -2901,6 +2901,7 @@ object PreferencesDialog: TPreferencesDialog
|
||||
TabOrder = 0
|
||||
OnChange = PuttyPathEditChange
|
||||
OnExit = PuttyPathEditExit
|
||||
HistoryKey = 'PuttyPath'
|
||||
end
|
||||
object PuttyPasswordCheck2: TCheckBox
|
||||
Left = 11
|
||||
|
||||
@@ -61,7 +61,6 @@ bool __fastcall TRemoteTransferDialog::Execute(void *& Session, UnicodeString &
|
||||
break;
|
||||
}
|
||||
}
|
||||
DirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteTarget"];
|
||||
DirectoryEdit->Text = UnixIncludeTrailingBackslash(Target) + FileMask;
|
||||
FDirectCopy = DirectCopy;
|
||||
FOriginalTarget = Target;
|
||||
@@ -70,7 +69,7 @@ bool __fastcall TRemoteTransferDialog::Execute(void *& Session, UnicodeString &
|
||||
if (Result)
|
||||
{
|
||||
Session = GetSelectedSession();
|
||||
CustomWinConfiguration->History[L"RemoteTarget"] = DirectoryEdit->Items;
|
||||
DirectoryEdit->SaveToHistory();
|
||||
Target = GetTarget();
|
||||
FileMask = GetFileMask();
|
||||
DirectCopy = !NotDirectCopyCheck->Checked;
|
||||
|
||||
@@ -76,6 +76,7 @@ object RemoteTransferDialog: TRemoteTransferDialog
|
||||
MaxLength = 250
|
||||
TabOrder = 1
|
||||
OnChange = ControlChange
|
||||
HistoryKey = 'RemoteTarget'
|
||||
end
|
||||
object NotDirectCopyCheck: TCheckBox
|
||||
Left = 49
|
||||
|
||||
@@ -128,14 +128,12 @@ bool __fastcall TSelectMaskDialog::Execute(TFileFilter & FileFilter, TColor & Co
|
||||
{
|
||||
ApplyToDirectoriesCheck->Checked = FileFilter.Directories;
|
||||
MaskEdit->Text = FileFilter.Masks;
|
||||
MaskEdit->Items = WinConfiguration->History[L"Mask"];
|
||||
ActiveControl = MaskEdit;
|
||||
FColor = Color;
|
||||
bool Result = (ShowModal() == DefaultResult(this));
|
||||
if (Result)
|
||||
{
|
||||
MaskEdit->SaveToHistory();
|
||||
WinConfiguration->History[L"Mask"] = MaskEdit->Items;
|
||||
FileFilter.Directories = ApplyToDirectoriesCheck->Checked;
|
||||
FileFilter.Masks = MaskEdit->Text;
|
||||
Color = FColor;
|
||||
|
||||
@@ -102,6 +102,7 @@ object SelectMaskDialog: TSelectMaskDialog
|
||||
Text = '*.*'
|
||||
OnChange = MaskEditChange
|
||||
OnExit = MaskEditExit
|
||||
HistoryKey = 'Mask'
|
||||
end
|
||||
object HintText: TStaticText
|
||||
Left = 235
|
||||
|
||||
@@ -221,8 +221,6 @@ bool __fastcall TSynchronizeDialog::Execute()
|
||||
// at start assume that copy param is current preset
|
||||
FPreset = GUIConfiguration->CopyParamCurrent;
|
||||
|
||||
LocalDirectoryEdit->Items = CustomWinConfiguration->History[L"LocalDirectory"];
|
||||
RemoteDirectoryEdit->Items = CustomWinConfiguration->History[L"RemoteDirectory"];
|
||||
ShowModal();
|
||||
|
||||
return true;
|
||||
@@ -497,9 +495,7 @@ void __fastcall TSynchronizeDialog::Start()
|
||||
void __fastcall TSynchronizeDialog::SaveHistory()
|
||||
{
|
||||
LocalDirectoryEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"LocalDirectory"] = LocalDirectoryEdit->Items;
|
||||
RemoteDirectoryEdit->SaveToHistory();
|
||||
CustomWinConfiguration->History[L"RemoteDirectory"] = RemoteDirectoryEdit->Items;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall TSynchronizeDialog::StopButtonClick(TObject * /*Sender*/)
|
||||
|
||||
@@ -70,6 +70,7 @@ object SynchronizeDialog: TSynchronizeDialog
|
||||
TabOrder = 2
|
||||
Text = 'RemoteDirectoryEdit'
|
||||
OnChange = ControlChange
|
||||
HistoryKey = 'RemoteDirectory'
|
||||
end
|
||||
object LocalDirectoryEdit: THistoryComboBox
|
||||
Left = 49
|
||||
@@ -82,6 +83,7 @@ object SynchronizeDialog: TSynchronizeDialog
|
||||
TabOrder = 0
|
||||
Text = 'LocalDirectoryEdit'
|
||||
OnChange = ControlChange
|
||||
HistoryKey = 'LocalDirectory'
|
||||
end
|
||||
object LocalDirectoryBrowseButton: TButton
|
||||
Left = 413
|
||||
|
||||
@@ -28,7 +28,7 @@ void SaveToHistory(TStrings * Strings, const UnicodeString & T, TObject * Data,
|
||||
//---------------------------------------------------------------------------
|
||||
// TUIStateAwareComboBox
|
||||
//---------------------------------------------------------------------------
|
||||
TUIStateAwareComboBox::TUIStateAwareComboBox(TComponent * AOwner) :
|
||||
__fastcall TUIStateAwareComboBox::TUIStateAwareComboBox(TComponent * AOwner) :
|
||||
TComboBox(AOwner)
|
||||
{
|
||||
}
|
||||
@@ -64,6 +64,9 @@ void TUIStateAwareComboBox::SetDarkMode(bool Value)
|
||||
//---------------------------------------------------------------------------
|
||||
// THistoryComboBox
|
||||
//---------------------------------------------------------------------------
|
||||
THistoryComboHistoryEvent THistoryComboBox::OnLoadHistory = nullptr;
|
||||
THistoryComboHistoryEvent THistoryComboBox::OnSaveHistory = nullptr;
|
||||
//---------------------------------------------------------------------------
|
||||
__fastcall THistoryComboBox::THistoryComboBox(TComponent * AOwner) :
|
||||
TUIStateAwareComboBox(AOwner)
|
||||
{
|
||||
@@ -80,7 +83,7 @@ void __fastcall THistoryComboBox::KeyDown(unsigned short & Key, TShiftState Shif
|
||||
{
|
||||
if (Items->IndexOf(Text) < 0)
|
||||
{
|
||||
SaveToHistory();
|
||||
AddToHistory();
|
||||
}
|
||||
}
|
||||
if (DroppedDown && (Key == VK_DELETE) && Shift.Contains(ssCtrl) && !SaveOn.Empty())
|
||||
@@ -105,7 +108,7 @@ void __fastcall THistoryComboBox::DoExit()
|
||||
TUIStateAwareComboBox::DoExit();
|
||||
if (SaveOn.Contains(soExit))
|
||||
{
|
||||
SaveToHistory();
|
||||
AddToHistory();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -115,7 +118,7 @@ void __fastcall THistoryComboBox::DropDown()
|
||||
|
||||
if (SaveOn.Contains(soDropDown))
|
||||
{
|
||||
SaveToHistory();
|
||||
AddToHistory();
|
||||
}
|
||||
|
||||
int ItemWidth = GetMaxItemWidth() + ScaleByPixelsPerInch(8, this);
|
||||
@@ -140,7 +143,7 @@ void __fastcall THistoryComboBox::Change()
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void THistoryComboBox::SaveToHistory()
|
||||
void THistoryComboBox::AddToHistory()
|
||||
{
|
||||
if (!Text.IsEmpty())
|
||||
{
|
||||
@@ -154,6 +157,15 @@ void THistoryComboBox::SaveToHistory()
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void THistoryComboBox::SaveToHistory()
|
||||
{
|
||||
AddToHistory();
|
||||
if (OnSaveHistory != nullptr)
|
||||
{
|
||||
OnSaveHistory(this);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
int THistoryComboBox::GetMaxItemWidth()
|
||||
{
|
||||
int Result = 0;
|
||||
@@ -178,3 +190,33 @@ int THistoryComboBox::GetMaxItemWidth()
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void THistoryComboBox::LoadHistory()
|
||||
{
|
||||
if (!SaveOn.Empty() && !HistoryKey.IsEmpty() && HandleAllocated())
|
||||
{
|
||||
if (OnLoadHistory != nullptr)
|
||||
{
|
||||
OnLoadHistory(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Items->Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall THistoryComboBox::SetHistoryKey(UnicodeString value)
|
||||
{
|
||||
if (HistoryKey != value)
|
||||
{
|
||||
FHistoryKey = value;
|
||||
LoadHistory();
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall THistoryComboBox::CreateWnd()
|
||||
{
|
||||
TUIStateAwareComboBox::CreateWnd();
|
||||
LoadHistory();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ typedef Set<THistorySaveOnEnum, soExit, soDropDown> THistorySaveOn;
|
||||
class THistoryComboBox;
|
||||
typedef void __fastcall (__closure *THistoryComboBoxGetData)(THistoryComboBox * Sender, TObject * &Data);
|
||||
typedef void __fastcall (__closure *THistoryComboBoxSetData)(THistoryComboBox * Sender, TObject * Data);
|
||||
typedef void __fastcall (__closure *THistoryComboHistoryEvent)(THistoryComboBox * Sender);
|
||||
//---------------------------------------------------------------------------
|
||||
#define DefaultHistorySaveOn ((1 << soExit) + (1 << soDropDown))
|
||||
const int DefaultMaxHistorySize = 30;
|
||||
@@ -37,24 +38,34 @@ private:
|
||||
int FMaxHistorySize;
|
||||
THistoryComboBoxGetData FOnGetData;
|
||||
THistoryComboBoxSetData FOnSetData;
|
||||
UnicodeString FHistoryKey;
|
||||
|
||||
void __fastcall SetMaxHistorySize(int AMaxHistorySize);
|
||||
void __fastcall SetHistoryKey(UnicodeString value);
|
||||
int GetMaxItemWidth();
|
||||
void LoadHistory();
|
||||
void AddToHistory();
|
||||
|
||||
protected:
|
||||
DYNAMIC void __fastcall DoExit();
|
||||
DYNAMIC void __fastcall DropDown();
|
||||
DYNAMIC void __fastcall KeyDown(Word & Key, TShiftState Shift);
|
||||
DYNAMIC void __fastcall Change();
|
||||
virtual void __fastcall CreateWnd();
|
||||
|
||||
public:
|
||||
__fastcall THistoryComboBox(TComponent * AOwner);
|
||||
void SaveToHistory();
|
||||
|
||||
static THistoryComboHistoryEvent OnLoadHistory;
|
||||
static THistoryComboHistoryEvent OnSaveHistory;
|
||||
|
||||
__published:
|
||||
__property THistorySaveOn SaveOn = { read = FSaveOn, write = FSaveOn, default = 3 };
|
||||
__property int MaxHistorySize = { read = FMaxHistorySize, write = SetMaxHistorySize, default = 30 };
|
||||
__property THistoryComboBoxGetData OnGetData = { read = FOnGetData, write = FOnGetData };
|
||||
__property THistoryComboBoxSetData OnSetData = { read = FOnSetData, write = FOnSetData };
|
||||
__property UnicodeString HistoryKey = { read = FHistoryKey, write = SetHistoryKey };
|
||||
};
|
||||
//---------------------------------------------------------------------------
|
||||
void SaveToHistory(TStrings * Strings, const UnicodeString & T, TObject * Data = nullptr, int MaxHistorySize = DefaultMaxHistorySize);
|
||||
|
||||
@@ -890,8 +890,6 @@ public:
|
||||
bool __fastcall Execute(TUnicodeStringVector & Values);
|
||||
|
||||
private:
|
||||
UnicodeString __fastcall HistoryKey(int Index);
|
||||
|
||||
std::vector<THistoryComboBox *> FEdits;
|
||||
TUnicodeStringVector FPrompts;
|
||||
UnicodeString FCustomCommandName;
|
||||
@@ -918,24 +916,22 @@ __fastcall TCustomCommandPromptsDialog::TCustomCommandPromptsDialog(
|
||||
THistoryComboBox * ComboBox = new THistoryComboBox(this);
|
||||
ComboBox->AutoComplete = false;
|
||||
AddComboBox(ComboBox, CreateLabel(Prompt));
|
||||
ComboBox->Items = CustomWinConfiguration->History[HistoryKey(Index)];
|
||||
|
||||
UnicodeString HistoryKey = FPrompts[Index];
|
||||
if (HistoryKey.IsEmpty())
|
||||
{
|
||||
HistoryKey = IntToStr(static_cast<int>(Index));
|
||||
}
|
||||
HistoryKey = FORMAT(L"%s_%s", (FCustomCommandName, HistoryKey));
|
||||
HistoryKey = CustomWinConfiguration->GetValidHistoryKey(HistoryKey);
|
||||
HistoryKey = L"CustomCommandParam_" + HistoryKey;
|
||||
ComboBox->HistoryKey = HistoryKey;
|
||||
|
||||
ComboBox->Text = Defaults[Index];
|
||||
FEdits.push_back(ComboBox);
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
UnicodeString __fastcall TCustomCommandPromptsDialog::HistoryKey(int Index)
|
||||
{
|
||||
UnicodeString Result = FPrompts[Index];
|
||||
if (Result.IsEmpty())
|
||||
{
|
||||
Result = IntToStr(Index);
|
||||
}
|
||||
Result = FORMAT(L"%s_%s", (FCustomCommandName, Result));
|
||||
Result = CustomWinConfiguration->GetValidHistoryKey(Result);
|
||||
return L"CustomCommandParam_" + Result;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
bool __fastcall TCustomCommandPromptsDialog::Execute(TUnicodeStringVector & Values)
|
||||
{
|
||||
|
||||
@@ -947,7 +943,6 @@ bool __fastcall TCustomCommandPromptsDialog::Execute(TUnicodeStringVector & Valu
|
||||
{
|
||||
Values.push_back(FEdits[Index]->Text);
|
||||
FEdits[Index]->SaveToHistory();
|
||||
CustomWinConfiguration->History[HistoryKey(Index)] = FEdits[Index]->Items;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1465,6 +1460,16 @@ static void __fastcall AppGetMainFormHandle(void * /*Data*/, HWND & Handle)
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall LoadHistory(void *, THistoryComboBox * Sender)
|
||||
{
|
||||
Sender->Items = CustomWinConfiguration->History[Sender->HistoryKey];
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall SaveHistory(void *, THistoryComboBox * Sender)
|
||||
{
|
||||
CustomWinConfiguration->History[Sender->HistoryKey] = Sender->Items;
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall WinInitialize()
|
||||
{
|
||||
// Not sure if we need to call JclHookExceptions at all, stack trace tracking seems to work without it.
|
||||
@@ -1485,7 +1490,9 @@ void __fastcall WinInitialize()
|
||||
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
|
||||
OnApiPath = ApiPath;
|
||||
MainThread = GetCurrentThreadId();
|
||||
Application->OnGetMainFormHandle = MakeMethod<TGetHandleEvent>(NULL, AppGetMainFormHandle);
|
||||
Application->OnGetMainFormHandle = MakeMethod<TGetHandleEvent>(nullptr, AppGetMainFormHandle);
|
||||
THistoryComboBox::OnLoadHistory = MakeMethod<THistoryComboHistoryEvent>(nullptr, LoadHistory);
|
||||
THistoryComboBox::OnSaveHistory = MakeMethod<THistoryComboHistoryEvent>(nullptr, SaveHistory);
|
||||
}
|
||||
//---------------------------------------------------------------------------
|
||||
void __fastcall WinFinalize()
|
||||
|
||||
Reference in New Issue
Block a user