IDE: fix problem with combobox list when changing items order. Save form's layout in IDEDialogLayoutList. Issue #18931

git-svn-id: trunk@33098 -
This commit is contained in:
juha 2011-10-26 16:40:37 +00:00
parent 683285b605
commit f18dc977ec
4 changed files with 91 additions and 67 deletions

View File

@ -2,37 +2,36 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
Left = 307
Height = 309
Top = 209
Width = 450
AutoSize = True
Width = 353
BorderIcons = [biSystemMenu]
Caption = 'Clean Directory'
ClientHeight = 309
ClientWidth = 450
ClientWidth = 353
OnCreate = CleanDirectoryDialogCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '0.9.29'
LCLVersion = '0.9.31'
object DirGroupbox: TGroupBox
Left = 6
Height = 74
Height = 84
Top = 6
Width = 438
Width = 341
Align = alTop
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Directory'
ClientHeight = 56
ClientWidth = 434
ClientHeight = 67
ClientWidth = 337
TabOrder = 0
object DirCombobox: TComboBox
AnchorSideRight.Control = DirBrowseButton
Left = 6
Height = 21
Height = 23
Top = 6
Width = 394
Width = 297
Anchors = [akTop, akLeft, akRight]
AutoCompleteText = [cbactSearchAscending]
BorderSpacing.Around = 6
ItemHeight = 13
ItemHeight = 0
TabOrder = 0
Text = 'DirCombobox'
end
@ -40,9 +39,9 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
AnchorSideTop.Control = DirCombobox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 17
Top = 33
Width = 422
Height = 26
Top = 35
Width = 325
Align = alBottom
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Around = 6
@ -56,9 +55,9 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = DirGroupbox
AnchorSideRight.Side = asrBottom
Left = 406
Left = 309
Height = 21
Top = 6
Top = 7
Width = 23
Anchors = [akTop, akRight]
BorderSpacing.Right = 5
@ -69,33 +68,32 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
end
object RemoveGroupbox: TGroupBox
Left = 6
Height = 74
Top = 86
Width = 438
Height = 84
Top = 96
Width = 341
Align = alTop
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Remove files matching filter:'
ClientHeight = 56
ClientWidth = 434
ClientHeight = 67
ClientWidth = 337
TabOrder = 1
object RemoveCombobox: TComboBox
Left = 6
Height = 21
Height = 23
Top = 6
Width = 422
Width = 325
Align = alTop
AutoCompleteText = [cbactSearchAscending]
BorderSpacing.Around = 6
ItemHeight = 13
ItemHeight = 0
TabOrder = 0
Text = 'RemoveCombobox'
end
object SimpleSyntaxRemoveCheckbox: TCheckBox
Left = 6
Height = 17
Top = 33
Width = 422
Height = 26
Top = 35
Width = 325
Align = alTop
BorderSpacing.Around = 6
Caption = 'Simple syntax (e.g. * instead of .*)'
@ -104,33 +102,32 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
end
object KeepGroupbox: TGroupBox
Left = 6
Height = 105
Top = 166
Width = 438
Height = 85
Top = 186
Width = 341
Align = alClient
AutoSize = True
BorderSpacing.Around = 6
Caption = 'Keep files matching filter:'
ClientHeight = 87
ClientWidth = 434
ClientHeight = 68
ClientWidth = 337
TabOrder = 2
object KeepCombobox: TComboBox
Left = 6
Height = 21
Height = 23
Top = 6
Width = 422
Width = 325
Align = alTop
AutoCompleteText = [cbactSearchAscending]
BorderSpacing.Around = 6
ItemHeight = 13
ItemHeight = 0
TabOrder = 0
Text = 'KeepCombobox'
end
object SimpleSyntaxKeepCheckbox: TCheckBox
Left = 6
Height = 17
Top = 33
Width = 422
Height = 26
Top = 35
Width = 325
Align = alTop
BorderSpacing.Around = 6
Caption = 'Simple syntax (e.g. * instead of .*)'
@ -138,9 +135,9 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
end
object KeepTextFilesCheckbox: TCheckBox
Left = 6
Height = 17
Top = 56
Width = 422
Height = 26
Top = 64
Width = 325
Align = alTop
BorderSpacing.Around = 6
Caption = 'Keep Text Files'
@ -151,12 +148,16 @@ object CleanDirectoryDialog: TCleanDirectoryDialog
Left = 6
Height = 26
Top = 277
Width = 438
Width = 341
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
HelpButton.DefaultCaption = True
CloseButton.Name = 'CloseButton'
CloseButton.DefaultCaption = True
CloseButton.Enabled = False
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
TabOrder = 3
ShowButtons = [pbOK, pbCancel, pbHelp]
ShowBevel = False

View File

@ -32,9 +32,8 @@ interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Buttons,
StdCtrls, FileUtil, LCLProc, Laz_XMLCfg, SynRegExpr, ButtonPanel,
IDEHelpIntf,
LazarusIDEStrConsts, LazConf, IDEProcs, TransferMacros, InputHistory,
ShowDeletingFilesDlg;
IDEWindowIntf, IDEHelpIntf, LazarusIDEStrConsts, LazConf, IDEProcs,
TransferMacros, InputHistory, ShowDeletingFilesDlg;
type
@ -53,8 +52,9 @@ type
DirCombobox: TCOMBOBOX;
DirGroupbox: TGROUPBOX;
RemoveGroupbox: TGROUPBOX;
procedure HelpButtonClick(Sender: TObject);
procedure CleanDirectoryDialogCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure HelpButtonClick(Sender: TObject);
procedure DirBrowseButtonClick(Sender: TObject);
procedure OkButtonClick(Sender: TObject);
private
@ -66,7 +66,6 @@ type
function GetConfigFilename: string;
function SearchFilesToDelete(var List: TStrings): boolean;
function DeleteFiles(List: TStrings): boolean;
procedure AddDirectory(const Directory: string);
property Macros: TTransferMacroList read FMacros write SetMacros;
end;
@ -89,7 +88,8 @@ begin
CleanDirectoryDialog:=TCleanDirectoryDialog.Create(nil);
CleanDirectoryDialog.Macros:=Macros;
CleanDirectoryDialog.LoadSettings;
CleanDirectoryDialog.AddDirectory(DefaultDirectory);
AddToRecentList(DefaultDirectory,CleanDirectoryDialog.DirCombobox.Items,20);
CleanDirectoryDialog.DirComboBox.ItemIndex:=0;
Result:=CleanDirectoryDialog.ShowModal;
CleanDirectoryDialog.Free;
end;
@ -128,12 +128,19 @@ begin
SimpleSyntaxKeepCheckbox.Caption:=lisClDirSimpleSyntaxEGInsteadOf;
KeepTextFilesCheckbox.Caption:=lisClDirKeepAllTextFiles;
ButtonPanel.OKButton.Caption:=lisOk;
ButtonPanel.OKButton.Caption:=lisClDirClean;
ButtonPanel.HelpButton.Caption:=lisMenuHelp;
ButtonPanel.CancelButton.Caption:=dlgCancel;
ButtonPanel.OKButton.OnClick := @OKButtonClick;
ButtonPanel.HelpButton.OnClick := @HelpButtonClick;
IDEDialogLayoutList.ApplyLayout(Self);
end;
procedure TCleanDirectoryDialog.FormDestroy(Sender: TObject);
begin
IDEDialogLayoutList.SaveLayout(Self);
end;
procedure TCleanDirectoryDialog.HelpButtonClick(Sender: TObject);
@ -226,9 +233,9 @@ var
Filename: String;
Path: String;
begin
AddToRecentList(DirCombobox.Text, DirCombobox.Items, 20);
AddToRecentList(RemoveCombobox.Text, RemoveCombobox.Items, 20);
AddToRecentList(KeepCombobox.Text, KeepCombobox.Items, 20);
AddComboTextToRecentList(DirCombobox, 20);
AddComboTextToRecentList(RemoveCombobox, 20);
AddComboTextToRecentList(KeepCombobox, 20);
try
InvalidateFileStateCache;
Filename:=GetConfigFilename;
@ -441,10 +448,5 @@ begin
Result:=true;
end;
procedure TCleanDirectoryDialog.AddDirectory(const Directory: string);
begin
AddToRecentList(Directory,DirCombobox.Items,20);
end;
end.

View File

@ -273,15 +273,12 @@ uses
Unix, BaseUnix;
{$EndIf}
function AddToRecentList(const s: string; RecentList: TStrings;
Max: integer): boolean;
function AddToRecentList(const s: string; RecentList: TStrings; Max: integer): boolean;
begin
if (RecentList.Count>0) and (RecentList[0]=s) then begin
Result:=false;
exit;
end else begin
if (RecentList.Count>0) and (RecentList[0]=s) then
exit(false)
else
Result:=true;
end;
RemoveFromRecentList(s,RecentList);
RecentList.Insert(0,s);
if Max>0 then
@ -289,6 +286,29 @@ begin
RecentList.Delete(RecentList.Count-1);
end;
function AddComboTextToRecentList(cb: TCombobox; Max: integer): boolean;
var
List: TStringList;
begin
List := TStringList.Create;
try
List.Assign(cb.Items);
if (List.Count>0) and (List[0]=cb.Text) then
exit(false)
else
Result:=true;
RemoveFromRecentList(cb.Text,List);
List.Insert(0,cb.Text);
if Max>0 then
while List.Count>Max do
List.Delete(List.Count-1);
cb.Items.Assign(List);
cb.ItemIndex:=0;
finally
List.Free;
end;
end;
procedure RemoveFromRecentList(const s: string; RecentList: TStrings);
var i: integer;
begin

View File

@ -4169,6 +4169,7 @@ resourcestring
lisClDirKeepAllTextFiles = 'Keep all text files';
lisClDirKeepFilesMatchingFilter = 'Keep files matching filter';
lisClDirCleanDirectory = 'Clean Directory';
lisClDirClean = 'Clean';
// LFM repair wizard
lisTheLFMLazarusFormFileContainsInvalidPropertiesThis = 'The LFM (Lazarus '