Converter: Display single success message after conversion of multiple dfm files.

git-svn-id: trunk@60053 -
This commit is contained in:
wp 2019-01-10 13:34:52 +00:00
parent 4014c0f4fd
commit 2c93efc441
3 changed files with 21 additions and 9 deletions

View File

@ -62,7 +62,8 @@ type
constructor Create;
destructor Destroy; override;
function ConvertDfmToLfm(const aFilename: string): TModalResult;
function Convert(const DfmFilename: string): TModalResult;
function Convert(const DfmFilename: string;
DisplaySuccessMessage: Boolean): TModalResult;
public
property Settings: TConvertSettings read fSettings write fSettings;
end;
@ -248,7 +249,8 @@ begin
inherited Destroy;
end;
function TDFMConverter.Convert(const DfmFilename: string): TModalResult;
function TDFMConverter.Convert(const DfmFilename: string;
DisplaySuccessMessage: Boolean): TModalResult;
var
s: String;
Urgency: TMessageLineUrgency;
@ -256,17 +258,22 @@ begin
Result:=ConvertDfmToLfm(DfmFilename);
if Result=mrOK then begin
if fOrigFormat=sofBinary then begin
s:=Format(lisFileSIsConvertedToTextFormat, [DfmFilename]);
if DisplaySuccessMessage then
s:=Format(lisFileSIsConvertedToTextFormat, [DfmFilename])
else
s:='';
Urgency:=mluHint;
end
else begin
s:=Format(lisFileSHasIncorrectSyntax, [DfmFilename]);
Urgency:=mluError;
end;
if Assigned(fSettings) then
fSettings.AddLogLine(Urgency, s, DfmFilename)
else
ShowMessage(s);
if s <> '' then begin
if Assigned(fSettings) then
fSettings.AddLogLine(Urgency, s, DfmFilename)
else
ShowMessage(s);
end;
end;
end;

View File

@ -5065,6 +5065,7 @@ resourcestring
+' properties/classes which do not exist in the LCL. They can be replaced or removed.';
lisFileSIsConvertedToTextFormat = 'File %s was converted to text format.';
lisFileSCountConvertedToTextFormat = '%d files were converted to text format.';
lisFileSHasIncorrectSyntax = 'File %s has incorrect syntax.';
lisAddedMissingObjectSToPascalSource = 'Added missing object "%s" to pascal source.';
lisReplacedTypeSWithS = 'Replaced type "%s" with "%s".';

View File

@ -8029,7 +8029,7 @@ function TMainIDE.DoConvertDFMtoLFM: TModalResult;
var
OpenDialog: TOpenDialog;
DFMConverter: TDFMConverter;
i: integer;
i, n: integer;
AFilename: string;
begin
Result:=mrOk;
@ -8040,15 +8040,19 @@ begin
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
OpenDialog.Filter:=dlgFilterDelphiForm+' (*.dfm)|*.dfm|'+dlgFilterAll+'|'+GetAllFilesMask;
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
n := 0;
For I := 0 to OpenDialog.Files.Count-1 do begin
AFilename:=ExpandFileNameUTF8(OpenDialog.Files.Strings[i]);
DFMConverter:=TDFMConverter.Create;
try
Result:=DFMConverter.Convert(AFilename);
Result:=DFMConverter.Convert(AFilename, OpenDialog.Files.Count = 1);
if Result = mrOK then inc(n);
finally
DFMConverter.Free;
end;
end;
if OpenDialog.Files.Count > 1 then
ShowMessageFmt(lisFileSCountConvertedToTextFormat, [n]);
SaveEnvironment;
end;
InputHistories.StoreFileDialogSettings(OpenDialog);