mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-07 12:00:44 +02:00
lcl: set TFileNameEdit.FilterIndex before OnAcceptFileName execution + formatting (issue #0017306)
git-svn-id: trunk@29916 -
This commit is contained in:
parent
7fe0a34e7b
commit
df3550bba9
@ -165,15 +165,15 @@ type
|
|||||||
FDefaultExt: String;
|
FDefaultExt: String;
|
||||||
FHideDirectories: Boolean;
|
FHideDirectories: Boolean;
|
||||||
FInitialDir: String;
|
FInitialDir: String;
|
||||||
FOnAcceptFN: TAcceptFileNameEvent;
|
FOnAcceptFileName: TAcceptFileNameEvent;
|
||||||
FOnFolderChange: TNotifyEvent;
|
FOnFolderChange: TNotifyEvent;
|
||||||
FFileNameChangeLock: Integer;
|
FFileNameChangeLock: Integer;
|
||||||
procedure SetFileName(const AValue: String);
|
procedure SetFileName(const AValue: String);
|
||||||
protected
|
protected
|
||||||
function GetDefaultGlyph: TBitmap; override;
|
function GetDefaultGlyph: TBitmap; override;
|
||||||
function GetDefaultGlyphName: String; override;
|
function GetDefaultGlyphName: String; override;
|
||||||
function CreateDialog(AKind : TDialogKind) : TCommonDialog; virtual;
|
function CreateDialog(AKind: TDialogKind): TCommonDialog; virtual;
|
||||||
procedure SaveDialogResult(AKind : TDialogKind; D : TCommonDialog); virtual;
|
procedure SaveDialogResult(AKind: TDialogKind; D: TCommonDialog); virtual;
|
||||||
procedure DoButtonClick (Sender: TObject); override;
|
procedure DoButtonClick (Sender: TObject); override;
|
||||||
procedure RunDialog; virtual;
|
procedure RunDialog; virtual;
|
||||||
procedure TextChanged; override;
|
procedure TextChanged; override;
|
||||||
@ -186,7 +186,7 @@ type
|
|||||||
// TFileName properties.
|
// TFileName properties.
|
||||||
property FileName: String read FFileName write SetFileName;
|
property FileName: String read FFileName write SetFileName;
|
||||||
property InitialDir: String read FInitialDir write FInitialDir;
|
property InitialDir: String read FInitialDir write FInitialDir;
|
||||||
property OnAcceptFileName: TAcceptFileNameEvent read FOnAcceptFN write FonAcceptFN;
|
property OnAcceptFileName: TAcceptFileNameEvent read FOnAcceptFileName write FOnAcceptFileName;
|
||||||
property OnFolderChange: TNotifyEvent read FOnFolderChange write FOnFolderChange;
|
property OnFolderChange: TNotifyEvent read FOnFolderChange write FOnFolderChange;
|
||||||
property DialogKind: TDialogKind read FDialogKind write FDialogKind default dkOpen;
|
property DialogKind: TDialogKind read FDialogKind write FDialogKind default dkOpen;
|
||||||
property DialogTitle: String read FDialogTitle write FDialogTitle;
|
property DialogTitle: String read FDialogTitle write FDialogTitle;
|
||||||
@ -747,24 +747,24 @@ var
|
|||||||
O: TOpenDialog;
|
O: TOpenDialog;
|
||||||
S: TSaveDialog;
|
S: TSaveDialog;
|
||||||
begin
|
begin
|
||||||
Case AKind of
|
case AKind of
|
||||||
dkopen, dkPictureOpen:
|
dkopen, dkPictureOpen:
|
||||||
begin
|
begin
|
||||||
O:=TOpenDialog.Create(Self);
|
O := TOpenDialog.Create(Self);
|
||||||
O.FileName:=FileName;
|
O.FileName := FileName;
|
||||||
O.Options:=DialogOptions;
|
O.Options := DialogOptions;
|
||||||
O.InitialDir:=InitialDir;
|
O.InitialDir := InitialDir;
|
||||||
O.Filter:=Filter;
|
O.Filter := Filter;
|
||||||
O.FilterIndex:=FilterIndex;
|
O.FilterIndex := FilterIndex;
|
||||||
Result:=O;
|
Result := O;
|
||||||
end;
|
end;
|
||||||
dkSave, dkPictureSave:
|
dkSave, dkPictureSave:
|
||||||
begin
|
begin
|
||||||
S:=TSaveDialog.Create(Self);
|
S:=TSaveDialog.Create(Self);
|
||||||
S.DefaultExt:= FDefaultExt;
|
S.DefaultExt := FDefaultExt;
|
||||||
S.Filter:=Filter;
|
S.Filter := Filter;
|
||||||
S.FilterIndex:=FilterIndex;
|
S.FilterIndex := FilterIndex;
|
||||||
Result:=S;
|
Result := S;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// Set some common things.
|
// Set some common things.
|
||||||
@ -776,24 +776,26 @@ var
|
|||||||
FN: String;
|
FN: String;
|
||||||
begin
|
begin
|
||||||
case AKind of
|
case AKind of
|
||||||
dkOpen,dkPictureOpen :
|
dkOpen, dkPictureOpen :
|
||||||
begin
|
begin
|
||||||
FN:=TOpenDialog(D).FileName;
|
FilterIndex := TOpenDialog(D).FilterIndex;
|
||||||
if (FN<>'') then
|
FN := TOpenDialog(D).FileName;
|
||||||
|
if (FN <> '') then
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnAcceptFN) then
|
if Assigned(OnAcceptFileName) then
|
||||||
FOnAcceptFN(Self,Fn);
|
OnAcceptFileName(Self, FN);
|
||||||
end;
|
end;
|
||||||
if (FN<>'') then
|
if (FN <> '') then
|
||||||
begin
|
begin
|
||||||
// set FDialogFiles first since assigning of FileName trigger events
|
// set FDialogFiles first since assigning of FileName trigger events
|
||||||
FDialogFiles.Text:=TOpenDialog(D).Files.Text;
|
FDialogFiles.Text := TOpenDialog(D).Files.Text;
|
||||||
FileName:=FN;
|
FileName := FN;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
dkSave,dkPictureSave :
|
dkSave, dkPictureSave :
|
||||||
begin
|
begin
|
||||||
FileName:=TSaveDialog(D).FileName;
|
FileName := TSaveDialog(D).FileName;
|
||||||
|
FilterIndex := TSaveDialog(D).FilterIndex;
|
||||||
FDialogFiles.Clear;
|
FDialogFiles.Clear;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -817,12 +819,12 @@ end;
|
|||||||
|
|
||||||
procedure TFileNameEdit.RunDialog;
|
procedure TFileNameEdit.RunDialog;
|
||||||
var
|
var
|
||||||
D : TCommonDialog;
|
D: TCommonDialog;
|
||||||
begin
|
begin
|
||||||
D:=CreateDialog(DialogKind);
|
D := CreateDialog(DialogKind);
|
||||||
try
|
try
|
||||||
if D.Execute then
|
if D.Execute then
|
||||||
SaveDialogResult(DialogKind,D);
|
SaveDialogResult(DialogKind, D);
|
||||||
finally
|
finally
|
||||||
D.Free;
|
D.Free;
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user