diff --git a/source/My.cbproj b/source/My.cbproj
index 29330ed7b..3c5924f3f 100644
--- a/source/My.cbproj
+++ b/source/My.cbproj
@@ -35,7 +35,7 @@
true
true
false
- -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-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
$(INTERM_PATH)\$(Platform)\$(Config)
JPHNE
true
diff --git a/source/forms/Console.cpp b/source/forms/Console.cpp
index f70b72bf8..255fe9e58 100644
--- a/source/forms/Console.cpp
+++ b/source/forms/Console.cpp
@@ -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;
diff --git a/source/forms/Console.dfm b/source/forms/Console.dfm
index 31154ffe7..cd0efbb84 100644
--- a/source/forms/Console.dfm
+++ b/source/forms/Console.dfm
@@ -1455,6 +1455,7 @@ object ConsoleDialog: TConsoleDialog
MaxLength = 2048
TabOrder = 0
OnChange = CommandEditChange
+ HistoryKey = 'Commands'
end
object ExecuteButton: TButton
Left = 377
diff --git a/source/forms/Copy.cpp b/source/forms/Copy.cpp
index 6e93b00e9..cc81ae9cb 100644
--- a/source/forms/Copy.cpp
+++ b/source/forms/Copy.cpp
@@ -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))
{
diff --git a/source/forms/CopyLocal.cpp b/source/forms/CopyLocal.cpp
index bfdd60941..5a512d97f 100644
--- a/source/forms/CopyLocal.cpp
+++ b/source/forms/CopyLocal.cpp
@@ -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();
diff --git a/source/forms/CopyLocal.dfm b/source/forms/CopyLocal.dfm
index e2623651b..953e776f2 100644
--- a/source/forms/CopyLocal.dfm
+++ b/source/forms/CopyLocal.dfm
@@ -48,6 +48,7 @@ object CopyLocalDialog: TCopyLocalDialog
TabOrder = 0
Text = 'DirectoryEdit'
OnExit = DirectoryEditExit
+ HistoryKey = 'LocalTarget'
end
object OkButton: TButton
Left = 251
diff --git a/source/forms/CopyParams.cpp b/source/forms/CopyParams.cpp
index 330d10824..012a49e31 100644
--- a/source/forms/CopyParams.cpp
+++ b/source/forms/CopyParams.cpp
@@ -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;
}
diff --git a/source/forms/CopyParams.dfm b/source/forms/CopyParams.dfm
index 90c918b69..3c594222d 100644
--- a/source/forms/CopyParams.dfm
+++ b/source/forms/CopyParams.dfm
@@ -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
diff --git a/source/forms/Custom.cpp b/source/forms/Custom.cpp
index 3cb90b3b7..91557c2d1 100644
--- a/source/forms/Custom.cpp
+++ b/source/forms/Custom.cpp
@@ -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 & 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(Control));
ComboBox->SaveToHistory();
- CustomWinConfiguration->History[HistoryKey(Option)] = ComboBox->Items;
return ComboBox->Text;
}
//---------------------------------------------------------------------------
diff --git a/source/forms/CustomCommand.cpp b/source/forms/CustomCommand.cpp
index 0a4c9b6a4..b25e9228a 100644
--- a/source/forms/CustomCommand.cpp
+++ b/source/forms/CustomCommand.cpp
@@ -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;
}
diff --git a/source/forms/CustomCommand.dfm b/source/forms/CustomCommand.dfm
index 060fb73c2..1680bcb27 100644
--- a/source/forms/CustomCommand.dfm
+++ b/source/forms/CustomCommand.dfm
@@ -77,6 +77,7 @@ object CustomCommandDialog: TCustomCommandDialog
OnChange = ControlChange
OnGetData = CommandEditGetData
OnSetData = CommandEditSetData
+ HistoryKey = 'CustomCommand'
end
object ApplyToDirectoriesCheck: TCheckBox
Left = 11
diff --git a/source/forms/EditorPreferences.cpp b/source/forms/EditorPreferences.cpp
index bcca235f6..01414759b 100644
--- a/source/forms/EditorPreferences.cpp
+++ b/source/forms/EditorPreferences.cpp
@@ -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;
diff --git a/source/forms/EditorPreferences.dfm b/source/forms/EditorPreferences.dfm
index 327fe74f5..6f76ec710 100644
--- a/source/forms/EditorPreferences.dfm
+++ b/source/forms/EditorPreferences.dfm
@@ -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
diff --git a/source/forms/FileFind.cpp b/source/forms/FileFind.cpp
index 2b203311e..fec5e58aa 100644
--- a/source/forms/FileFind.cpp
+++ b/source/forms/FileFind.cpp
@@ -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;
diff --git a/source/forms/FileFind.dfm b/source/forms/FileFind.dfm
index c27f78765..ac9b7774a 100644
--- a/source/forms/FileFind.dfm
+++ b/source/forms/FileFind.dfm
@@ -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
diff --git a/source/forms/FullSynchronize.cpp b/source/forms/FullSynchronize.cpp
index 3532abda1..f73086c9f 100644
--- a/source/forms/FullSynchronize.cpp
+++ b/source/forms/FullSynchronize.cpp
@@ -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)
diff --git a/source/forms/FullSynchronize.dfm b/source/forms/FullSynchronize.dfm
index d425fe272..ba3e1d063 100644
--- a/source/forms/FullSynchronize.dfm
+++ b/source/forms/FullSynchronize.dfm
@@ -78,6 +78,7 @@ object FullSynchronizeDialog: TFullSynchronizeDialog
TabOrder = 0
Text = 'LocalDirectoryEdit'
OnChange = ControlChange
+ HistoryKey = 'LocalDirectory'
end
object LocalDirectoryBrowseButton: TButton
Left = 429
diff --git a/source/forms/FullSynchronize.h b/source/forms/FullSynchronize.h
index 1f8ce648a..d286dd37e 100644
--- a/source/forms/FullSynchronize.h
+++ b/source/forms/FullSynchronize.h
@@ -101,7 +101,6 @@ private:
void __fastcall StartInNewWindow();
void DoLocalDirectoryBrowseButtonClick(TComboBox * ComboBox);
bool CanSynchronizeTimestamps();
- UnicodeString GetRightDirectoryHistory();
public:
__fastcall TFullSynchronizeDialog(TComponent* Owner);
diff --git a/source/forms/Preferences.cpp b/source/forms/Preferences.cpp
index 9f1a40ba0..5f8dc875f 100644
--- a/source/forms/Preferences.cpp
+++ b/source/forms/Preferences.cpp
@@ -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
{
diff --git a/source/forms/Preferences.dfm b/source/forms/Preferences.dfm
index a20f0f258..f4572e218 100644
--- a/source/forms/Preferences.dfm
+++ b/source/forms/Preferences.dfm
@@ -2901,6 +2901,7 @@ object PreferencesDialog: TPreferencesDialog
TabOrder = 0
OnChange = PuttyPathEditChange
OnExit = PuttyPathEditExit
+ HistoryKey = 'PuttyPath'
end
object PuttyPasswordCheck2: TCheckBox
Left = 11
diff --git a/source/forms/RemoteTransfer.cpp b/source/forms/RemoteTransfer.cpp
index d0ae1ad77..520b266a9 100644
--- a/source/forms/RemoteTransfer.cpp
+++ b/source/forms/RemoteTransfer.cpp
@@ -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;
diff --git a/source/forms/RemoteTransfer.dfm b/source/forms/RemoteTransfer.dfm
index 52bc93f09..63c9e0871 100644
--- a/source/forms/RemoteTransfer.dfm
+++ b/source/forms/RemoteTransfer.dfm
@@ -76,6 +76,7 @@ object RemoteTransferDialog: TRemoteTransferDialog
MaxLength = 250
TabOrder = 1
OnChange = ControlChange
+ HistoryKey = 'RemoteTarget'
end
object NotDirectCopyCheck: TCheckBox
Left = 49
diff --git a/source/forms/SelectMask.cpp b/source/forms/SelectMask.cpp
index d065bb3fa..11bb650cf 100644
--- a/source/forms/SelectMask.cpp
+++ b/source/forms/SelectMask.cpp
@@ -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;
diff --git a/source/forms/SelectMask.dfm b/source/forms/SelectMask.dfm
index c833626b5..05702fea4 100644
--- a/source/forms/SelectMask.dfm
+++ b/source/forms/SelectMask.dfm
@@ -102,6 +102,7 @@ object SelectMaskDialog: TSelectMaskDialog
Text = '*.*'
OnChange = MaskEditChange
OnExit = MaskEditExit
+ HistoryKey = 'Mask'
end
object HintText: TStaticText
Left = 235
diff --git a/source/forms/Synchronize.cpp b/source/forms/Synchronize.cpp
index d421a8e7d..bba7fb4bd 100644
--- a/source/forms/Synchronize.cpp
+++ b/source/forms/Synchronize.cpp
@@ -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*/)
diff --git a/source/forms/Synchronize.dfm b/source/forms/Synchronize.dfm
index 9bc77f9cf..447ad30ef 100644
--- a/source/forms/Synchronize.dfm
+++ b/source/forms/Synchronize.dfm
@@ -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
diff --git a/source/packages/my/HistoryComboBox.cpp b/source/packages/my/HistoryComboBox.cpp
index a327cf641..076bdf28c 100644
--- a/source/packages/my/HistoryComboBox.cpp
+++ b/source/packages/my/HistoryComboBox.cpp
@@ -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();
+}
diff --git a/source/packages/my/HistoryComboBox.h b/source/packages/my/HistoryComboBox.h
index 14106f2ed..f0dd57f48 100644
--- a/source/packages/my/HistoryComboBox.h
+++ b/source/packages/my/HistoryComboBox.h
@@ -26,6 +26,7 @@ typedef Set 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);
diff --git a/source/windows/WinInterface.cpp b/source/windows/WinInterface.cpp
index 78c2a6a8d..569047893 100644
--- a/source/windows/WinInterface.cpp
+++ b/source/windows/WinInterface.cpp
@@ -890,8 +890,6 @@ public:
bool __fastcall Execute(TUnicodeStringVector & Values);
private:
- UnicodeString __fastcall HistoryKey(int Index);
-
std::vector 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(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(NULL, AppGetMainFormHandle);
+ Application->OnGetMainFormHandle = MakeMethod(nullptr, AppGetMainFormHandle);
+ THistoryComboBox::OnLoadHistory = MakeMethod(nullptr, LoadHistory);
+ THistoryComboBox::OnSaveHistory = MakeMethod(nullptr, SaveHistory);
}
//---------------------------------------------------------------------------
void __fastcall WinFinalize()