Converter: show settings dialog only once when converting many unit files. Improve settings GUI.

git-svn-id: trunk@41735 -
This commit is contained in:
juha 2013-06-16 23:42:42 +00:00
parent 96e7696f47
commit d4936c7bdc
4 changed files with 258 additions and 258 deletions

View File

@ -120,8 +120,6 @@ type
// wrapping either one unit or whole project / package conversion. // wrapping either one unit or whole project / package conversion.
TConvertDelphiPBase = class TConvertDelphiPBase = class
private private
// Original unit's, project's or package's file name, .pas .lpi .lpk .dpr .dpk
fOrigFilename: string;
fSettings: TConvertSettings; fSettings: TConvertSettings;
fErrorMsg: string; fErrorMsg: string;
// IsConsoleApp is only updated for TConvertDelphiProjPack. // IsConsoleApp is only updated for TConvertDelphiProjPack.
@ -139,6 +137,7 @@ type
protected protected
function EndConvert(AStatus: TModalResult): Boolean; function EndConvert(AStatus: TModalResult): Boolean;
public public
constructor Create(const ADescription: string);
constructor Create(const AFilename, ADescription: string); constructor Create(const AFilename, ADescription: string);
destructor Destroy; override; destructor Destroy; override;
public public
@ -152,7 +151,7 @@ type
private private
DirectoryTemplate: TDefineTemplate; DirectoryTemplate: TDefineTemplate;
public public
constructor Create(const AFilename: string); constructor Create(aFiles: TStrings);
destructor Destroy; override; destructor Destroy; override;
function Convert: TModalResult; function Convert: TModalResult;
end; end;
@ -822,14 +821,18 @@ end;
{ TConvertDelphiPBase } { TConvertDelphiPBase }
constructor TConvertDelphiPBase.Create(const AFilename, ADescription: string); constructor TConvertDelphiPBase.Create(const ADescription: string);
begin begin
inherited Create; inherited Create;
fOrigFilename:=AFilename;
fSettings:=TConvertSettings.Create(ADescription); fSettings:=TConvertSettings.Create(ADescription);
fSettings.MainFilename:=fOrigFilename;
fIsConsoleApp:=False; // Default = GUI app. fIsConsoleApp:=False; // Default = GUI app.
fPrevSelectedPath:=fSettings.MainPath; end;
constructor TConvertDelphiPBase.Create(const AFilename, ADescription: string);
begin
Create(ADescription);
fSettings.MainFilenames.Add(AFilename);
fPrevSelectedPath:=AFilename;
end; end;
destructor TConvertDelphiPBase.Destroy; destructor TConvertDelphiPBase.Destroy;
@ -866,12 +869,21 @@ end;
{ TConvertDelphiUnit } { TConvertDelphiUnit }
constructor TConvertDelphiUnit.Create(const AFilename: string); constructor TConvertDelphiUnit.Create(aFiles: TStrings);
var var
MacroName, s: String; MacroName, s: String;
i: Integer;
begin begin
inherited Create(AFilename, lisConvDelphiConvertDelphiUnit); inherited Create(lisConvDelphiConvertDelphiUnit);
// Add the list of files if they exist.
for i := 0 to aFiles.Count-1 do begin
s:=CleanAndExpandFilename(aFiles[i]);
if FileExistsUTF8(s) then begin
fSettings.MainFilenames.Add(s);
if (i=0) and (fPrevSelectedPath='') then
fPrevSelectedPath:=s;
end;
end;
// use a template for compiler mode delphi for a single directory // use a template for compiler mode delphi for a single directory
DirectoryTemplate:=TDefineTemplate.Create('Delphi unit conversion', DirectoryTemplate:=TDefineTemplate.Create('Delphi unit conversion',
'Mode Delphi for single unit conversion', '', fSettings.MainPath, da_Directory); 'Mode Delphi for single unit conversion', '', fSettings.MainPath, da_Directory);
@ -890,36 +902,45 @@ end;
function TConvertDelphiUnit.Convert: TModalResult; function TConvertDelphiUnit.Convert: TModalResult;
var var
DelphiUnit: TDelphiUnit; DelphiUnit: TDelphiUnit;
i: Integer;
begin begin
DelphiUnit := TDelphiUnit.Create(Self, fOrigFilename, []); Result:=fSettings.RunForm(Nil);
try if Result=mrOK then begin
Result:=fSettings.RunForm(Nil); try
if Result=mrOK then begin try
fSettings.ClearLog; fSettings.ClearLog;
with DelphiUnit do for i:=0 to fSettings.MainFilenames.Count-1 do begin
try Application.ProcessMessages;
Result:=CopyAndLoadFile; if i>0 then
if Result<>mrOK then Exit; fSettings.AddLogLine('');
Result:=ConvertUnitFile; DelphiUnit := TDelphiUnit.Create(Self, fSettings.MainFilenames[i], []);
if Result<>mrOK then Exit; with DelphiUnit do
Result:=SaveCodeBufferToFile(fPascalBuffer,fLazUnitFilename); try
if Result<>mrOK then Exit; Result:=CopyAndLoadFile;
Result:=ConvertFormFile; if Result<>mrOK then Exit;
if Result<>mrOK then Exit; Result:=ConvertUnitFile;
Result:=LazarusIDE.DoSaveEditorFile(fLazUnitFilename,[]); if Result<>mrOK then Exit;
except Result:=SaveCodeBufferToFile(fPascalBuffer,fLazUnitFilename);
on e: EDelphiConverterError do begin if Result<>mrOK then Exit;
fErrorMsg:=e.Message; Result:=ConvertFormFile;
if Result<>mrOK then Exit;
Result:=LazarusIDE.DoSaveEditorFile(fLazUnitFilename,[]);
finally
DelphiUnit.Free;
end; end;
else begin
fErrorMsg:=CodeToolBoss.ErrorMessage;
end;
Result:=mrAbort;
end; end;
except
on e: EDelphiConverterError do begin
fErrorMsg:=e.Message;
end;
else begin
fErrorMsg:=CodeToolBoss.ErrorMessage;
end;
Result:=mrAbort;
end;
finally
EndConvert(Result);
end; end;
finally
EndConvert(Result);
DelphiUnit.Free;
end; end;
end; end;
@ -963,7 +984,7 @@ var
StartTime, EndTime: TDateTime; StartTime, EndTime: TDateTime;
s: string; s: string;
begin begin
if CompareFileExt(fOrigFilename,'.dproj',false)=0 then begin if CompareFileExt(fSettings.MainFilename,'.dproj',false)=0 then begin
fErrorMsg:= fErrorMsg:=
'.dproj file is not supported yet. The file is used by Delphi 2007 and newer.'+ '.dproj file is not supported yet. The file is used by Delphi 2007 and newer.'+
' Please select a .dpr file for projects or .dpk file for packages.'; ' Please select a .dpr file for projects or .dpk file for packages.';
@ -980,15 +1001,15 @@ begin
StartTime:=Now; StartTime:=Now;
fSettings.ClearLog; fSettings.ClearLog;
// create/open lazarus project or package file // create/open lazarus project or package file
fLazPMainFilename:=fSettings.DelphiToLazFilename(fOrigFilename, fLazPMainSuffix, false); fLazPMainFilename:=fSettings.DelphiToLazFilename(fSettings.MainFilename,
fLazPMainSuffix, false);
// Find Delphi project / package file name // Find Delphi project / package file name
if CompareFileExt(fOrigFilename,fDelphiPSuffix,false)=0 then if CompareFileExt(fSettings.MainFilename,fDelphiPSuffix,false)=0 then
fDelphiPFilename:=fOrigFilename fDelphiPFilename:=fSettings.MainFilename
else else
fDelphiPFilename:=ChangeFileExt(fOrigFilename,fDelphiPSuffix); fDelphiPFilename:=ChangeFileExt(fSettings.MainFilename,fDelphiPSuffix);
if not FileExistsUTF8(fDelphiPFilename) then if not FileExistsUTF8(fDelphiPFilename) then
fDelphiPFilename:=FindDiskFileCaseInsensitive(fOrigFilename); fDelphiPFilename:=FindDiskFileCaseInsensitive(fSettings.MainFilename);
// ? fDelphiPFilename:=CodeToolBoss.DirectoryCachePool.FindDiskFilename(fDelphiPFilename); // ? fDelphiPFilename:=CodeToolBoss.DirectoryCachePool.FindDiskFilename(fDelphiPFilename);
// Actual conversion. // Actual conversion.
@ -1018,9 +1039,9 @@ begin
Result:=CreateInstance; Result:=CreateInstance;
if Result<>mrOK then exit; if Result<>mrOK then exit;
// Create main source file (.lpr/.lpk) (only copy, no conversion) // Create main source file (.lpr/.lpk) (only copy, no conversion)
fMainUnitConverter:=TDelphiUnit.Create(Self, fOrigFilename,[]); fMainUnitConverter:=TDelphiUnit.Create(Self, fSettings.MainFilename,[]);
if fSettings.SupportDelphi then if fSettings.SupportDelphi then
fMainUnitConverter.LazFileExt:=ExtractFileExt(fOrigFilename) fMainUnitConverter.LazFileExt:=ExtractFileExt(fSettings.MainFilename)
else else
fMainUnitConverter.LazFileExt:=fLazPSuffix; // '.lpr' or '' fMainUnitConverter.LazFileExt:=fLazPSuffix; // '.lpr' or ''
Result:=fMainUnitConverter.CopyAndLoadFile; Result:=fMainUnitConverter.CopyAndLoadFile;
@ -1575,7 +1596,8 @@ begin
FoundUnits, MisUnits, NormalUnits) then FoundUnits, MisUnits, NormalUnits) then
begin begin
LazarusIDE.DoJumpToCodeToolBossError; LazarusIDE.DoJumpToCodeToolBossError;
fErrorMsg:='Problems when trying to find all units from project file '+fOrigFilename; fErrorMsg:='Problems when trying to find all units from project file '
+fSettings.MainFilename;
exit(mrCancel); exit(mrCancel);
end; end;
try // Add all units to the project try // Add all units to the project
@ -1914,7 +1936,8 @@ begin
FoundUnits, MisUnits, NormalUnits) then FoundUnits, MisUnits, NormalUnits) then
begin begin
LazarusIDE.DoJumpToCodeToolBossError; LazarusIDE.DoJumpToCodeToolBossError;
fErrorMsg:='Problems when trying to find all units from package file '+fOrigFilename; fErrorMsg:='Problems when trying to find all units from package file '
+fSettings.MainFilename;
exit(mrCancel); exit(mrCancel);
end; end;
try try

View File

@ -1,56 +1,25 @@
object ConvertSettingsForm: TConvertSettingsForm object ConvertSettingsForm: TConvertSettingsForm
Left = 315 Left = 315
Height = 380 Height = 400
Top = 127 Top = 127
Width = 577 Width = 671
ActiveControl = ProjectPathEdit
Caption = 'Convert Delphi unit, project or package ' Caption = 'Convert Delphi unit, project or package '
ClientHeight = 380 ClientHeight = 400
ClientWidth = 577 ClientWidth = 671
Constraints.MinHeight = 328 Constraints.MinHeight = 377
Constraints.MinWidth = 544 Constraints.MinWidth = 544
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
Position = poScreenCenter Position = poScreenCenter
LCLVersion = '1.1' LCLVersion = '1.1'
object ProjectPathEdit: TLabeledEdit
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = UnitReplaceDivider
Left = 9
Height = 21
Hint = 'Directory where project''s main file must be'
Top = 32
Width = 293
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 9
BorderSpacing.Right = 9
BorderStyle = bsNone
Color = clBtnFace
EditLabel.AnchorSideLeft.Control = ProjectPathEdit
EditLabel.AnchorSideTop.Side = asrCenter
EditLabel.AnchorSideRight.Control = ProjectPathEdit
EditLabel.AnchorSideRight.Side = asrBottom
EditLabel.AnchorSideBottom.Control = ProjectPathEdit
EditLabel.Left = 9
EditLabel.Height = 15
EditLabel.Top = 10
EditLabel.Width = 293
EditLabel.Caption = 'Project Path:'
EditLabel.ParentColor = False
LabelSpacing = 7
ParentShowHint = False
ReadOnly = True
ShowHint = True
TabOrder = 0
end
object BackupCheckBox: TCheckBox object BackupCheckBox: TCheckBox
AnchorSideLeft.Control = DelphiDefineCheckBox AnchorSideLeft.Control = DelphiDefineCheckBox
AnchorSideTop.Control = DelphiDefineCheckBox AnchorSideTop.Control = DelphiDefineCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 Left = 15
Height = 21 Height = 21
Hint = 'Creates a Backup directory under project directory' Hint = 'Creates a Backup directory under project directory'
Top = 195 Top = 238
Width = 211 Width = 211
BorderSpacing.Top = 3 BorderSpacing.Top = 3
Caption = 'Make backup of changed files' Caption = 'Make backup of changed files'
@ -58,13 +27,13 @@ object ConvertSettingsForm: TConvertSettingsForm
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
State = cbChecked State = cbChecked
TabOrder = 1 TabOrder = 0
end end
object ButtonPanel1: TButtonPanel object ButtonPanel1: TButtonPanel
Left = 6 Left = 6
Height = 41 Height = 41
Top = 333 Top = 353
Width = 565 Width = 659
OKButton.Name = 'OKButton' OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton' HelpButton.Name = 'HelpButton'
@ -75,32 +44,32 @@ object ConvertSettingsForm: TConvertSettingsForm
CancelButton.Name = 'CancelButton' CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True CancelButton.DefaultCaption = True
CancelButton.OnClick = CancelButtonClick CancelButton.OnClick = CancelButtonClick
TabOrder = 2 TabOrder = 1
ShowButtons = [pbOK, pbCancel, pbHelp] ShowButtons = [pbOK, pbCancel, pbHelp]
end end
object KeepFileOpenCheckBox: TCheckBox object KeepFileOpenCheckBox: TCheckBox
AnchorSideLeft.Control = BackupCheckBox AnchorSideLeft.Control = BackupCheckBox
AnchorSideTop.Control = BackupCheckBox AnchorSideTop.Control = BackupCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 Left = 15
Height = 21 Height = 21
Hint = 'Separate form files allow different properties' Hint = 'Separate form files allow different properties'
Top = 219 Top = 262
Width = 242 Width = 242
BorderSpacing.Top = 3 BorderSpacing.Top = 3
Caption = 'Keep converted files open in editor' Caption = 'Keep converted files open in editor'
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 3 TabOrder = 2
end end
object UnitReplaceDivider: TDividerBevel object UnitReplaceDivider: TDividerBevel
Left = 311 AnchorSideTop.Control = InputPathLabel
Left = 396
Height = 17 Height = 17
Top = 9 Top = 9
Width = 239 Width = 262
Caption = 'Unit Replacements' Caption = 'Unit Replacements'
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
BorderSpacing.Top = 9
Font.Style = [fsBold] Font.Style = [fsBold]
ParentFont = False ParentFont = False
ParentShowHint = False ParentShowHint = False
@ -113,10 +82,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 311 Left = 396
Height = 17 Height = 17
Top = 65 Top = 65
Width = 239 Width = 262
Caption = 'Unknown properties' Caption = 'Unknown properties'
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 39 BorderSpacing.Top = 39
@ -130,18 +99,18 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = UnitReplaceDivider AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = UnitReplaceDivider AnchorSideTop.Control = UnitReplaceDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 312 Left = 397
Height = 25 Height = 25
Hint = 'Unit names in uses section of a source unit' Hint = 'Unit names in uses section of a source unit'
Top = 27 Top = 27
Width = 75 Width = 118
BorderSpacing.Left = 1 BorderSpacing.Left = 1
BorderSpacing.Top = 1 BorderSpacing.Top = 1
Caption = 'Edit' Caption = 'Edit'
OnClick = UnitReplaceButtonClick OnClick = UnitReplaceButtonClick
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 4 TabOrder = 3
end end
object TypeReplaceDivider: TDividerBevel object TypeReplaceDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider AnchorSideLeft.Control = UnitReplaceDivider
@ -149,10 +118,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 311 Left = 396
Height = 17 Height = 17
Top = 121 Top = 121
Width = 239 Width = 262
Caption = 'Type Replacements' Caption = 'Type Replacements'
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 39 BorderSpacing.Top = 39
@ -166,18 +135,21 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = TypeReplaceDivider AnchorSideLeft.Control = TypeReplaceDivider
AnchorSideTop.Control = TypeReplaceDivider AnchorSideTop.Control = TypeReplaceDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 312 AnchorSideRight.Control = UnitReplaceButton
AnchorSideRight.Side = asrBottom
Left = 397
Height = 25 Height = 25
Hint = 'Unknown types in form file (DFM/LFM)' Hint = 'Unknown types in form file (DFM/LFM)'
Top = 139 Top = 139
Width = 75 Width = 118
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 1 BorderSpacing.Left = 1
BorderSpacing.Top = 1 BorderSpacing.Top = 1
Caption = 'Edit' Caption = 'Edit'
OnClick = TypeReplaceButtonClick OnClick = TypeReplaceButtonClick
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 5 TabOrder = 4
end end
object FuncReplaceDivider: TDividerBevel object FuncReplaceDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider AnchorSideLeft.Control = UnitReplaceDivider
@ -185,10 +157,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 311 Left = 396
Height = 17 Height = 17
Top = 177 Top = 177
Width = 239 Width = 262
Caption = 'Function Replacements' Caption = 'Function Replacements'
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 39 BorderSpacing.Top = 39
@ -204,10 +176,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 311 Left = 396
Height = 17 Height = 17
Top = 249 Top = 249
Width = 239 Width = 262
Caption = 'Coordinate Offsets' Caption = 'Coordinate Offsets'
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 55 BorderSpacing.Top = 55
@ -221,53 +193,60 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = FuncReplaceDivider AnchorSideLeft.Control = FuncReplaceDivider
AnchorSideTop.Control = FuncReplaceDivider AnchorSideTop.Control = FuncReplaceDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 312 AnchorSideRight.Control = UnitReplaceButton
AnchorSideRight.Side = asrBottom
Left = 397
Height = 25 Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function' Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 195 Top = 195
Width = 75 Width = 118
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 1 BorderSpacing.Left = 1
BorderSpacing.Top = 1 BorderSpacing.Top = 1
Caption = 'Edit' Caption = 'Edit'
OnClick = FuncReplaceButtonClick OnClick = FuncReplaceButtonClick
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 6 TabOrder = 5
end end
object CoordOffsButton: TBitBtn object CoordOffsButton: TBitBtn
AnchorSideLeft.Control = CoordOffsDivider AnchorSideLeft.Control = CoordOffsDivider
AnchorSideTop.Control = CoordOffsDivider AnchorSideTop.Control = CoordOffsDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 312 AnchorSideRight.Control = UnitReplaceButton
AnchorSideRight.Side = asrBottom
Left = 397
Height = 25 Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function' Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 267 Top = 267
Width = 75 Width = 118
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 1 BorderSpacing.Left = 1
BorderSpacing.Top = 1 BorderSpacing.Top = 1
Caption = 'Edit' Caption = 'Edit'
OnClick = CoordOffsButtonClick OnClick = CoordOffsButtonClick
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 7 TabOrder = 6
end end
object TargetGroupBox: TGroupBox object TargetGroupBox: TGroupBox
AnchorSideLeft.Control = ProjectPathEdit AnchorSideLeft.Control = InputPathListBox
AnchorSideTop.Control = ProjectPathEdit AnchorSideTop.Control = InputPathListBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 9 Left = 12
Height = 98 Height = 98
Hint = 'xxx' Hint = 'xxx'
Top = 64 Top = 107
Width = 211 Width = 211
Anchors = [akLeft, akBottom]
AutoSize = True AutoSize = True
BorderSpacing.Top = 11 BorderSpacing.Top = 7
Caption = 'Target' Caption = 'Target'
ClientHeight = 79 ClientHeight = 79
ClientWidth = 207 ClientWidth = 207
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 8 TabOrder = 7
object SupportDelphiCheckBox: TCheckBox object SupportDelphiCheckBox: TCheckBox
AnchorSideLeft.Control = CrossPlatformCheckBox AnchorSideLeft.Control = CrossPlatformCheckBox
AnchorSideTop.Control = CrossPlatformCheckBox AnchorSideTop.Control = CrossPlatformCheckBox
@ -323,91 +302,97 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = UnitReplaceButton AnchorSideTop.Control = UnitReplaceButton
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 410 Left = 530
Height = 25 Height = 25
Top = 27 Top = 27
Width = 136 Width = 129
BorderSpacing.Left = 23 BorderSpacing.Left = 15
ItemHeight = 0 ItemHeight = 0
Style = csDropDownList Style = csDropDownList
TabOrder = 9 TabOrder = 8
end end
object UnknownPropsComboBox: TComboBox object UnknownPropsComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceComboBox AnchorSideLeft.Control = UnitReplaceComboBox
AnchorSideTop.Control = UnknownPropsDivider AnchorSideTop.Control = UnknownPropsDivider
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 410 AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25 Height = 25
Top = 84 Top = 84
Width = 136 Width = 129
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2 BorderSpacing.Top = 2
ItemHeight = 0 ItemHeight = 0
Style = csDropDownList Style = csDropDownList
TabOrder = 9
end
object FuncReplaceComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceComboBox
AnchorSideTop.Control = FuncReplaceButton
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25
Top = 195
Width = 129
Anchors = [akTop, akLeft, akRight]
ItemHeight = 0
Style = csDropDownList
TabOrder = 10 TabOrder = 10
end end
object FuncReplaceComboBox: TComboBox object CoordOffsComboBox: TComboBox
AnchorSideLeft.Control = FuncReplaceButton AnchorSideLeft.Control = UnitReplaceComboBox
AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = CoordOffsButton
AnchorSideTop.Control = FuncReplaceButton
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 410 AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25 Height = 25
Top = 195 Top = 267
Width = 136 Width = 129
BorderSpacing.Left = 23 Anchors = [akTop, akLeft, akRight]
ItemHeight = 0 ItemHeight = 0
Style = csDropDownList Style = csDropDownList
TabOrder = 11 TabOrder = 11
end end
object CoordOffsComboBox: TComboBox object TypeReplaceComboBox: TComboBox
AnchorSideLeft.Control = CoordOffsButton AnchorSideLeft.Control = UnitReplaceComboBox
AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = TypeReplaceButton
AnchorSideTop.Control = CoordOffsButton
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 410 AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25 Height = 25
Top = 267 Top = 139
Width = 136 Width = 129
BorderSpacing.Left = 23 Anchors = [akTop, akLeft, akRight]
ItemHeight = 0 ItemHeight = 0
Style = csDropDownList Style = csDropDownList
TabOrder = 12 TabOrder = 12
end end
object TypeReplaceComboBox: TComboBox
AnchorSideLeft.Control = TypeReplaceButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TypeReplaceButton
AnchorSideTop.Side = asrCenter
Left = 410
Height = 25
Top = 139
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
Style = csDropDownList
TabOrder = 13
end
object ScanProgressBar: TProgressBar object ScanProgressBar: TProgressBar
AnchorSideLeft.Control = ScanLabel AnchorSideLeft.Control = ScanLabel
AnchorSideLeft.Side = asrBottom AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = KeepFileOpenCheckBox AnchorSideTop.Control = KeepFileOpenCheckBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 182 Left = 185
Height = 20 Height = 20
Top = 259 Top = 298
Width = 102 Width = 102
BorderSpacing.Left = 6 BorderSpacing.Left = 6
BorderSpacing.Top = 19 BorderSpacing.Top = 15
Style = pbstMarquee Style = pbstMarquee
TabOrder = 14 TabOrder = 13
end end
object ScanLabel: TLabel object ScanLabel: TLabel
AnchorSideLeft.Control = BackupCheckBox AnchorSideLeft.Control = BackupCheckBox
AnchorSideTop.Control = ScanProgressBar AnchorSideTop.Control = ScanProgressBar
AnchorSideTop.Side = asrCenter AnchorSideTop.Side = asrCenter
Left = 12 Left = 15
Height = 15 Height = 15
Top = 262 Top = 301
Width = 164 Width = 164
Caption = 'Scanning parent directory' Caption = 'Scanning parent directory'
ParentColor = False ParentColor = False
@ -418,42 +403,67 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ScanProgressBar AnchorSideRight.Control = ScanProgressBar
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 182 Left = 185
Height = 25 Height = 25
Top = 280 Top = 319
Width = 102 Width = 102
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 1 BorderSpacing.Top = 1
Caption = 'Stop' Caption = 'Stop'
OnClick = StopScanButtonClick OnClick = StopScanButtonClick
TabOrder = 15 TabOrder = 14
end end
object FuncReplaceCommentCB: TCheckBox object FuncReplaceCommentCB: TCheckBox
AnchorSideLeft.Control = FuncReplaceButton AnchorSideLeft.Control = FuncReplaceButton
AnchorSideTop.Control = FuncReplaceButton AnchorSideTop.Control = FuncReplaceButton
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 312 Left = 397
Height = 21 Height = 21
Top = 225 Top = 225
Width = 227 Width = 227
BorderSpacing.Top = 5 BorderSpacing.Top = 5
Caption = 'Add comment after replacement' Caption = 'Add comment after replacement'
TabOrder = 16 TabOrder = 15
end end
object DelphiDefineCheckBox: TCheckBox object DelphiDefineCheckBox: TCheckBox
AnchorSideLeft.Control = TargetGroupBox AnchorSideLeft.Control = TargetGroupBox
AnchorSideTop.Control = TargetGroupBox AnchorSideTop.Control = TargetGroupBox
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
Left = 12 Left = 15
Height = 21 Height = 21
Hint = 'Separate form files allow different properties' Hint = 'Separate form files allow different properties'
Top = 171 Top = 214
Width = 217 Width = 217
BorderSpacing.Left = 3 BorderSpacing.Left = 3
BorderSpacing.Top = 9 BorderSpacing.Top = 9
Caption = 'Add defines simulating Delphi7' Caption = 'Add defines simulating Delphi7'
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 16
end
object InputPathLabel: TLabel
Left = 12
Height = 15
Top = 9
Width = 93
Caption = 'InputPathLabel'
ParentColor = False
end
object InputPathListBox: TListBox
AnchorSideLeft.Control = InputPathLabel
AnchorSideTop.Control = InputPathLabel
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideBottom.Control = TargetGroupBox
Left = 12
Height = 75
Top = 25
Width = 375
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 1
BorderSpacing.Right = 9
BorderSpacing.Bottom = 1
ItemHeight = 0
TabOrder = 17 TabOrder = 17
end end
end end

View File

@ -52,8 +52,7 @@ type
fTitle: String; // Used for form caption. fTitle: String; // Used for form caption.
fLog: TStringList; fLog: TStringList;
// Unit, Project or Package top file and path. // Unit, Project or Package top file and path.
fMainFilename: String; fMainFilenames: TStringList;
fMainPath: String;
// Persistent storage in XML or some other format. // Persistent storage in XML or some other format.
fConfigStorage: TConfigStorage; fConfigStorage: TConfigStorage;
fSettingsForm: TConvertSettingsForm; fSettingsForm: TConvertSettingsForm;
@ -83,8 +82,9 @@ type
fCoordOffsets: TVisualOffsets; fCoordOffsets: TVisualOffsets;
// Getter / setter: // Getter / setter:
function GetBackupPath: String; function GetBackupPath: String;
function GetMainFilename: String;
function GetMainPath: String;
procedure SetEnabled(const AValue: Boolean); procedure SetEnabled(const AValue: Boolean);
procedure SetMainFilename(const AValue: String);
public public
constructor Create(const ATitle: string); constructor Create(const ATitle: string);
destructor Destroy; override; destructor Destroy; override;
@ -108,8 +108,9 @@ type
function AddLogLine(const ALine: string): integer; function AddLogLine(const ALine: string): integer;
function SaveLog: Boolean; function SaveLog: Boolean;
public public
property MainFilename: String read fMainFilename write SetMainFilename; property MainFilenames: TStringlist read fMainFilenames;
property MainPath: String read fMainPath; property MainFilename: String read GetMainFilename;
property MainPath: String read GetMainPath;
property BackupPath: String read GetBackupPath; property BackupPath: String read GetBackupPath;
property Enabled: Boolean read fEnabled write SetEnabled; property Enabled: Boolean read fEnabled write SetEnabled;
property DelphiDefine: Boolean read fDelphiDefine; property DelphiDefine: Boolean read fDelphiDefine;
@ -137,6 +138,8 @@ type
TConvertSettingsForm = class(TForm) TConvertSettingsForm = class(TForm)
FuncReplaceCommentCB: TCheckBox; FuncReplaceCommentCB: TCheckBox;
DelphiDefineCheckBox: TCheckBox; DelphiDefineCheckBox: TCheckBox;
InputPathLabel: TLabel;
InputPathListBox: TListBox;
StopScanButton: TBitBtn; StopScanButton: TBitBtn;
CoordOffsComboBox: TComboBox; CoordOffsComboBox: TComboBox;
ScanLabel: TLabel; ScanLabel: TLabel;
@ -160,7 +163,6 @@ type
ButtonPanel1: TButtonPanel; ButtonPanel1: TButtonPanel;
TypeReplaceButton: TBitBtn; TypeReplaceButton: TBitBtn;
UnitReplaceButton: TBitBtn; UnitReplaceButton: TBitBtn;
ProjectPathEdit: TLabeledEdit;
CoordOffsButton: TBitBtn; CoordOffsButton: TBitBtn;
procedure SameDfmCheckBoxChange(Sender: TObject); procedure SameDfmCheckBoxChange(Sender: TObject);
procedure StopScanButtonClick(Sender: TObject); procedure StopScanButtonClick(Sender: TObject);
@ -389,8 +391,7 @@ var
begin begin
fTitle:=ATitle; fTitle:=ATitle;
fLog:=TStringList.Create; fLog:=TStringList.Create;
fMainFilename:=''; fMainFilenames:=TStringList.Create;
fMainPath:='';
fEnabled:=True; fEnabled:=True;
fSettingsForm:=Nil; fSettingsForm:=Nil;
fOmitProjUnits:=TStringToStringTree.Create(false); fOmitProjUnits:=TStringToStringTree.Create(false);
@ -652,6 +653,7 @@ begin
fReplaceTypes.Free; fReplaceTypes.Free;
fReplaceUnits.Free; fReplaceUnits.Free;
fOmitProjUnits.Free; fOmitProjUnits.Free;
fMainFilenames.Free;
fLog.Free; fLog.Free;
inherited Destroy; inherited Destroy;
end; end;
@ -669,8 +671,8 @@ begin
end end
else else
ThreadTerminated(nil); // Hide controls dealing with scanning ThreadTerminated(nil); // Hide controls dealing with scanning
Caption:=fTitle + ' - ' + ExtractFileName(fMainFilename); Caption:=fTitle + ' - ' + ExtractFileName(MainFilename);
ProjectPathEdit.Text:=fMainPath; InputPathListBox.Items.Assign(fMainFilenames);
// Settings --> UI. Loaded from ConfigSettings earlier. // Settings --> UI. Loaded from ConfigSettings earlier.
DelphiDefineCheckBox.Checked :=fDelphiDefine; DelphiDefineCheckBox.Checked :=fDelphiDefine;
BackupCheckBox.Checked :=fBackupFiles; BackupCheckBox.Checked :=fBackupFiles;
@ -719,7 +721,7 @@ function TConvertSettings.DelphiToLazFilename(const DelphiFilename, LazExt: stri
var var
RelPath, SubPath, fn: string; RelPath, SubPath, fn: string;
begin begin
RelPath:=FileUtil.CreateRelativePath(DelphiFilename, fMainPath); RelPath:=FileUtil.CreateRelativePath(DelphiFilename, MainPath);
SubPath:=ExtractFilePath(RelPath); SubPath:=ExtractFilePath(RelPath);
if LazExt='' then // Include ext in filename if not defined. if LazExt='' then // Include ext in filename if not defined.
fn:=ExtractFileName(RelPath) fn:=ExtractFileName(RelPath)
@ -727,7 +729,7 @@ begin
fn:=ExtractFileNameOnly(RelPath); fn:=ExtractFileNameOnly(RelPath);
if LowercaseFilename then if LowercaseFilename then
fn:=LowerCase(fn); fn:=LowerCase(fn);
Result:=fMainPath+SubPath+fn+LazExt; Result:=MainPath+SubPath+fn+LazExt;
end; end;
function TConvertSettings.RenameDelphiToLazFile(const DelphiFilename: string; function TConvertSettings.RenameDelphiToLazFile(const DelphiFilename: string;
@ -741,7 +743,7 @@ function TConvertSettings.RenameDelphiToLazFile(const DelphiFilename, LazExt: st
var var
RelPath, SubPath, fn: string; RelPath, SubPath, fn: string;
begin begin
RelPath:=FileUtil.CreateRelativePath(DelphiFilename, fMainPath); RelPath:=FileUtil.CreateRelativePath(DelphiFilename, MainPath);
SubPath:=ExtractFilePath(RelPath); SubPath:=ExtractFilePath(RelPath);
if LazExt='' then // Include ext in filename if not defined. if LazExt='' then // Include ext in filename if not defined.
fn:=ExtractFileName(RelPath) fn:=ExtractFileName(RelPath)
@ -754,7 +756,7 @@ begin
Result:=BackupFile(DelphiFilename); // Save before rename. Result:=BackupFile(DelphiFilename); // Save before rename.
if Result<>mrOK then exit; if Result<>mrOK then exit;
end; end;
LazFilename:=fMainPath+SubPath+fn+LazExt; LazFilename:=MainPath+SubPath+fn+LazExt;
Result:=RenameFileWithErrorDialogs(DelphiFilename,LazFilename,[mbAbort]); Result:=RenameFileWithErrorDialogs(DelphiFilename,LazFilename,[mbAbort]);
end; end;
@ -792,7 +794,7 @@ var
aFilename: String; aFilename: String;
Code: TCodeBuffer; Code: TCodeBuffer;
begin begin
aFilename:=fMainPath+'AutomaticConversion.log'; aFilename:=MainPath+'AutomaticConversion.log';
Code:=CodeToolBoss.CreateFile(aFilename); Code:=CodeToolBoss.CreateFile(aFilename);
Code.Assign(fLog); Code.Assign(fLog);
Result:=SaveCodeBuffer(Code)=mrOk; Result:=SaveCodeBuffer(Code)=mrOk;
@ -800,25 +802,29 @@ begin
IDEMessagesWindow.AddMsg('This log was saved to '+aFilename, '', -1); IDEMessagesWindow.AddMsg('This log was saved to '+aFilename, '', -1);
end; end;
procedure TConvertSettings.SetMainFilename(const AValue: String);
begin
fMainFilename:=AValue;
fMainPath:=ExtractFilePath(AValue);
end;
function TConvertSettings.GetBackupPath: String; function TConvertSettings.GetBackupPath: String;
const const
BackupPathName='ConverterBackup'; BackupPathName='ConverterBackup';
begin begin
Result:=''; Result:='';
if fBackupFiles then begin if fBackupFiles then begin
Result:=fMainPath+BackupPathName+PathDelim; Result:=MainPath+BackupPathName+PathDelim;
// Create backup path if needed. // Create backup path if needed.
if not DirectoryExistsUTF8(Result) then if not DirectoryExistsUTF8(Result) then
CreateDirUTF8(Result); CreateDirUTF8(Result);
end; end;
end; end;
function TConvertSettings.GetMainFilename: String;
begin
Result:=fMainFilenames[0];
end;
function TConvertSettings.GetMainPath: String;
begin
Result:=ExtractFilePath(fMainFilenames[0]);
end;
procedure TConvertSettings.SetEnabled(const AValue: Boolean); procedure TConvertSettings.SetEnabled(const AValue: Boolean);
begin begin
if fEnabled=AValue then exit; if fEnabled=AValue then exit;
@ -843,9 +849,9 @@ end;
procedure TConvertSettingsForm.FormCreate(Sender: TObject); procedure TConvertSettingsForm.FormCreate(Sender: TObject);
begin begin
ProjectPathEdit.Text:=''; InputPathLabel.Caption:=lisProjectPath;
ProjectPathEdit.EditLabel.Caption:=lisProjectPath; InputPathListBox.Clear;
ProjectPathEdit.Hint:=lisProjectPathHint; InputPathListBox.Hint:=lisProjectPathHint;
DelphiDefineCheckBox.Caption:=lisAddDelphiDefine; DelphiDefineCheckBox.Caption:=lisAddDelphiDefine;
DelphiDefineCheckBox.Hint:=lisAddDelphiDefineHint; DelphiDefineCheckBox.Hint:=lisAddDelphiDefineHint;
BackupCheckBox.Caption:=lisBackupChangedFiles; BackupCheckBox.Caption:=lisBackupChangedFiles;
@ -979,6 +985,5 @@ begin
EditCoordOffsets(fSettings.CoordOffsets, lisConvCoordOffs); EditCoordOffsets(fSettings.CoordOffsets, lisConvCoordOffs);
end; end;
end. end.

View File

@ -952,7 +952,6 @@ type
// conversion // conversion
function DoConvertDFMtoLFM: TModalResult; function DoConvertDFMtoLFM: TModalResult;
function DoConvertDelphiUnit(const DelphiFilename: string; CanAbort: boolean): TModalResult;
function DoConvertDelphiProject(const DelphiFilename: string): TModalResult; function DoConvertDelphiProject(const DelphiFilename: string): TModalResult;
function DoConvertDelphiPackage(const DelphiFilename: string): TModalResult; function DoConvertDelphiPackage(const DelphiFilename: string): TModalResult;
@ -4384,18 +4383,12 @@ begin
end; end;
procedure TMainIDE.mnuToolConvertDelphiUnitClicked(Sender: TObject); procedure TMainIDE.mnuToolConvertDelphiUnitClicked(Sender: TObject);
procedure UpdateEnvironment;
begin
SetRecentFilesMenu;
SaveEnvironment;
end;
var var
OpenDialog: TOpenDialog; OpenDialog: TOpenDialog;
AFilename: string; AFilename: string;
i: Integer; i: Integer;
MultiOpen: Boolean; OldChange: Boolean;
Converter: TConvertDelphiUnit;
begin begin
OpenDialog:=TOpenDialog.Create(nil); OpenDialog:=TOpenDialog.Create(nil);
try try
@ -4405,20 +4398,23 @@ begin
dlgAllFiles+' ('+GetAllFilesMask+')|' + GetAllFilesMask; dlgAllFiles+' ('+GetAllFilesMask+')|' + GetAllFilesMask;
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect]; OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
if InputHistories.LastConvertDelphiUnit<>'' then begin if InputHistories.LastConvertDelphiUnit<>'' then begin
OpenDialog.InitialDir:= OpenDialog.InitialDir:=ExtractFilePath(InputHistories.LastConvertDelphiUnit);
ExtractFilePath(InputHistories.LastConvertDelphiUnit); OpenDialog.Filename :=ExtractFileName(InputHistories.LastConvertDelphiUnit);
OpenDialog.Filename:=
ExtractFileName(InputHistories.LastConvertDelphiUnit);
end; end;
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
MultiOpen:=OpenDialog.Files.Count>1; InputHistories.LastConvertDelphiUnit:=OpenDialog.Files[0];
for i := 0 to OpenDialog.Files.Count-1 do begin OldChange:=OpenEditorsOnCodeToolChange;
AFilename:=CleanAndExpandFilename(OpenDialog.Files.Strings[i]); OpenEditorsOnCodeToolChange:=true;
if FileExistsUTF8(AFilename) Converter:=TConvertDelphiUnit.Create(OpenDialog.Files);
and (DoConvertDelphiUnit(AFilename,MultiOpen)=mrAbort) then try
break; if Converter.Convert=mrOK then begin
SetRecentFilesMenu;
SaveEnvironment;
end;
finally
Converter.Free;
OpenEditorsOnCodeToolChange:=OldChange;
end; end;
UpdateEnvironment;
end; end;
InputHistories.StoreFileDialogSettings(OpenDialog); InputHistories.StoreFileDialogSettings(OpenDialog);
finally finally
@ -4427,13 +4423,6 @@ begin
end; end;
procedure TMainIDE.mnuToolConvertDelphiProjectClicked(Sender: TObject); procedure TMainIDE.mnuToolConvertDelphiProjectClicked(Sender: TObject);
procedure UpdateEnvironment;
begin
SetRecentFilesMenu;
SaveEnvironment;
end;
var var
OpenDialog: TOpenDialog; OpenDialog: TOpenDialog;
AFilename: string; AFilename: string;
@ -4446,16 +4435,15 @@ begin
lisLazarusProject+' (*.lpr)|*.lpr|'+ lisLazarusProject+' (*.lpr)|*.lpr|'+
dlgAllFiles+' ('+GetAllFilesMask+')|' + GetAllFilesMask; dlgAllFiles+' ('+GetAllFilesMask+')|' + GetAllFilesMask;
if InputHistories.LastConvertDelphiProject<>'' then begin if InputHistories.LastConvertDelphiProject<>'' then begin
OpenDialog.InitialDir:= OpenDialog.InitialDir:=ExtractFilePath(InputHistories.LastConvertDelphiProject);
ExtractFilePath(InputHistories.LastConvertDelphiProject); OpenDialog.Filename :=ExtractFileName(InputHistories.LastConvertDelphiProject);
OpenDialog.Filename:=
ExtractFileName(InputHistories.LastConvertDelphiProject);
end; end;
if OpenDialog.Execute then begin if OpenDialog.Execute then begin
AFilename:=CleanAndExpandFilename(OpenDialog.Filename); AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
if FileExistsUTF8(AFilename) then if FileExistsUTF8(AFilename) then
DoConvertDelphiProject(AFilename); DoConvertDelphiProject(AFilename);
UpdateEnvironment; SetRecentFilesMenu;
SaveEnvironment;
end; end;
InputHistories.StoreFileDialogSettings(OpenDialog); InputHistories.StoreFileDialogSettings(OpenDialog);
finally finally
@ -4464,13 +4452,6 @@ begin
end; end;
procedure TMainIDE.mnuToolConvertDelphiPackageClicked(Sender: TObject); procedure TMainIDE.mnuToolConvertDelphiPackageClicked(Sender: TObject);
procedure UpdateEnvironment;
begin
SetRecentFilesMenu;
SaveEnvironment;
end;
var var
OpenDialog: TOpenDialog; OpenDialog: TOpenDialog;
AFilename: string; AFilename: string;
@ -4483,14 +4464,15 @@ begin
dlgAllFiles+' ('+GetAllFilesMask+')|' + GetAllFilesMask; dlgAllFiles+' ('+GetAllFilesMask+')|' + GetAllFilesMask;
if InputHistories.LastConvertDelphiPackage<>'' then begin if InputHistories.LastConvertDelphiPackage<>'' then begin
OpenDialog.InitialDir:=ExtractFilePath(InputHistories.LastConvertDelphiPackage); OpenDialog.InitialDir:=ExtractFilePath(InputHistories.LastConvertDelphiPackage);
OpenDialog.Filename:=ExtractFileName(InputHistories.LastConvertDelphiPackage); OpenDialog.Filename :=ExtractFileName(InputHistories.LastConvertDelphiPackage);
end; end;
if OpenDialog.Execute then begin if OpenDialog.Execute then begin
AFilename:=CleanAndExpandFilename(OpenDialog.Filename); AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
//debugln('TMainIDE.mnuToolConvertDelphiProjectClicked A ',AFilename); //debugln('TMainIDE.mnuToolConvertDelphiProjectClicked A ',AFilename);
if FileExistsUTF8(AFilename) then if FileExistsUTF8(AFilename) then
DoConvertDelphiPackage(AFilename); DoConvertDelphiPackage(AFilename);
UpdateEnvironment; SetRecentFilesMenu;
SaveEnvironment;
end; end;
InputHistories.StoreFileDialogSettings(OpenDialog); InputHistories.StoreFileDialogSettings(OpenDialog);
finally finally
@ -7985,26 +7967,7 @@ begin
DoCheckFilesOnDisk; DoCheckFilesOnDisk;
end; end;
function TMainIDE.DoConvertDelphiUnit(const DelphiFilename: string; function TMainIDE.DoConvertDelphiProject(const DelphiFilename: string): TModalResult;
CanAbort: boolean): TModalResult;
var
OldChange: Boolean;
Converter: TConvertDelphiUnit;
begin
InputHistories.LastConvertDelphiUnit:=DelphiFilename;
OldChange:=OpenEditorsOnCodeToolChange;
OpenEditorsOnCodeToolChange:=true;
Converter := TConvertDelphiUnit.Create(DelphiFilename);
try
Result:=Converter.Convert;
finally
Converter.Free;
OpenEditorsOnCodeToolChange:=OldChange;
end;
end;
function TMainIDE.DoConvertDelphiProject(const DelphiFilename: string
): TModalResult;
var var
OldChange: Boolean; OldChange: Boolean;
Converter: TConvertDelphiProject; Converter: TConvertDelphiProject;
@ -8021,8 +7984,7 @@ begin
end; end;
end; end;
function TMainIDE.DoConvertDelphiPackage(const DelphiFilename: string function TMainIDE.DoConvertDelphiPackage(const DelphiFilename: string): TModalResult;
): TModalResult;
var var
OldChange: Boolean; OldChange: Boolean;
Converter: TConvertDelphiPackage; Converter: TConvertDelphiPackage;