mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 21:55:56 +02:00
Converter: cache unit paths using OnIdle handler.
git-svn-id: trunk@27384 -
This commit is contained in:
parent
40bf83e108
commit
8e3631c047
@ -138,6 +138,8 @@ type
|
||||
// Units that are found and will be added to project and converted.
|
||||
fUnitsToAddToProject: TStringList;
|
||||
fSettings: TConvertSettings;
|
||||
fDoneScan: Boolean;
|
||||
procedure OnIdle(Sender: TObject; var Done: Boolean);
|
||||
function ConvertSub: TModalResult;
|
||||
procedure CleanUpCompilerOptionsSearchPaths(Options: TBaseCompilerOptions);
|
||||
procedure SetCompilerModeForDefineTempl(DefTempl: TDefineTemplate);
|
||||
@ -871,8 +873,6 @@ begin
|
||||
fAllMissingUnits.Sorted:=true;
|
||||
fUnitsToAddToProject:=TStringList.Create;
|
||||
fPrevSelectedPath:=fSettings.MainPath;
|
||||
// Scan unit files a level above project path. Used later for missing units.
|
||||
CacheUnitsInPath(TrimFilename(fSettings.MainPath+'../'));
|
||||
end;
|
||||
|
||||
destructor TConvertDelphiPBase.Destroy;
|
||||
@ -885,13 +885,24 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TConvertDelphiPBase.OnIdle(Sender: TObject; var Done: Boolean);
|
||||
begin
|
||||
if not fDoneScan then begin
|
||||
CacheUnitsInPath(TrimFilename(fSettings.MainPath+'../'));
|
||||
fDoneScan:=True;
|
||||
end;
|
||||
Done:=True;
|
||||
end;
|
||||
|
||||
// Creates or updates a lazarus project (.lpi+.lpr) or package.
|
||||
function TConvertDelphiPBase.Convert: TModalResult;
|
||||
begin
|
||||
IDEMessagesWindow.Clear;
|
||||
Application.AddOnIdleHandler(@OnIdle, False);
|
||||
// Get settings from user.
|
||||
Result:=fSettings.RunForm;
|
||||
if Result=mrOK then begin
|
||||
Application.RemoveOnIdleHandler(@OnIdle);
|
||||
if (Result=mrOK) and fDoneScan then begin
|
||||
// create/open lazarus project or package file
|
||||
fLazPFilename:=fSettings.DelphiToLazFilename(fOrigPFilename, fLazPSuffix, false);
|
||||
|
||||
|
@ -15,7 +15,7 @@ object ConvertSettingsForm: TConvertSettingsForm
|
||||
object MissingStuffGroupBox: TGroupBox
|
||||
AnchorSideTop.Control = SettingsGroupBox
|
||||
AnchorSideTop.Side = asrBottom
|
||||
AnchorSideBottom.Control = ButtonPanel
|
||||
AnchorSideBottom.Control = ButtonPanel1
|
||||
Left = 0
|
||||
Height = 213
|
||||
Top = 219
|
||||
@ -237,7 +237,7 @@ object ConvertSettingsForm: TConvertSettingsForm
|
||||
State = cbChecked
|
||||
TabOrder = 3
|
||||
end
|
||||
object ButtonPanel: TButtonPanel
|
||||
object ButtonPanel1: TButtonPanel
|
||||
Left = 6
|
||||
Height = 39
|
||||
Top = 438
|
||||
|
@ -39,16 +39,20 @@ type
|
||||
|
||||
TConvertTarget = (ctLazarus, ctLazarusWin, ctLazarusAndDelphi);
|
||||
|
||||
TConvertSettingsForm = class;
|
||||
|
||||
{ TConvertSettings }
|
||||
|
||||
TConvertSettings = class
|
||||
private
|
||||
fEnabled: Boolean;
|
||||
fTitle: String; // Used for form caption.
|
||||
// Unit, Project or Package top file and path.
|
||||
fMainFilename: String;
|
||||
fMainPath: String;
|
||||
// Persistent storage in XML or some other format.
|
||||
fConfigStorage: TConfigStorage;
|
||||
fSettingsForm: TConvertSettingsForm;
|
||||
// Actual user settings.
|
||||
fBackupFiles: boolean;
|
||||
fTarget: TConvertTarget;
|
||||
@ -67,6 +71,7 @@ type
|
||||
fVisualOffsets: TVisualOffsets;
|
||||
// Getter / setter:
|
||||
function GetBackupPath: String;
|
||||
procedure SetEnabled(const AValue: Boolean);
|
||||
procedure SetMainFilename(const AValue: String);
|
||||
public
|
||||
constructor Create(const ATitle: string);
|
||||
@ -92,6 +97,7 @@ type
|
||||
property MainFilename: String read fMainFilename write SetMainFilename;
|
||||
property MainPath: String read fMainPath;
|
||||
property BackupPath: String read GetBackupPath;
|
||||
property Enabled: Boolean read fEnabled write SetEnabled;
|
||||
|
||||
property BackupFiles: boolean read fBackupFiles;
|
||||
property Target: TConvertTarget read fTarget;
|
||||
@ -113,7 +119,7 @@ type
|
||||
PropRemoveAutoCheckBox: TCheckBox;
|
||||
UnitReplaceAutoCheckBox: TCheckBox;
|
||||
BackupCheckBox: TCheckBox;
|
||||
ButtonPanel: TButtonPanel;
|
||||
ButtonPanel1: TButtonPanel;
|
||||
FuncReplaceEnableCheckBox: TCheckBox;
|
||||
VisualOffsEnableCheckBox: TCheckBox;
|
||||
Label1: TLabel;
|
||||
@ -336,6 +342,8 @@ begin
|
||||
fTitle:=ATitle;
|
||||
fMainFilename:='';
|
||||
fMainPath:='';
|
||||
fEnabled:=True;
|
||||
fSettingsForm:=Nil;
|
||||
fReplaceUnits:=TStringToStringTree.Create(false);
|
||||
fReplaceTypes:=TStringToStringTree.Create(false);
|
||||
fReplaceFuncs:=TFuncsAndCategories.Create;
|
||||
@ -469,12 +477,10 @@ begin
|
||||
end;
|
||||
|
||||
function TConvertSettings.RunForm: TModalResult;
|
||||
var
|
||||
SettingsForm: TConvertSettingsForm;
|
||||
begin
|
||||
SettingsForm:=TConvertSettingsForm.Create(nil, Self);
|
||||
with SettingsForm do
|
||||
fSettingsForm:=TConvertSettingsForm.Create(nil, Self);
|
||||
try
|
||||
with fSettingsForm do begin
|
||||
Caption:=fTitle;
|
||||
ProjectPathEdit.Text:=fMainPath;
|
||||
// Settings --> UI. Loaded from ConfigSettings earlier.
|
||||
@ -496,8 +502,9 @@ begin
|
||||
fEnableReplaceFuncs :=FuncReplaceEnableCheckBox.Checked;
|
||||
fEnableVisualOffs :=VisualOffsEnableCheckBox.Checked;
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
Free;
|
||||
FreeAndNil(fSettingsForm);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -587,6 +594,14 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TConvertSettings.SetEnabled(const AValue: Boolean);
|
||||
begin
|
||||
if fEnabled=AValue then exit;
|
||||
fEnabled:=AValue;
|
||||
if Assigned(fSettingsForm) then
|
||||
fSettingsForm.ButtonPanel1.Enabled:=fEnabled; // OKButton
|
||||
end;
|
||||
|
||||
|
||||
{ TConvertSettingsForm }
|
||||
|
||||
@ -610,9 +625,9 @@ begin
|
||||
BackupCheckBox.Caption:=lisBackupChangedFiles;
|
||||
BackupCheckBox.Hint:=lisBackupHint;
|
||||
|
||||
ButtonPanel.OKButton.Caption:=lisStartConversion;
|
||||
ButtonPanel.HelpButton.Caption:=lisMenuHelp;
|
||||
ButtonPanel.CancelButton.Caption:=dlgCancel;
|
||||
ButtonPanel1.OKButton.Caption:=lisStartConversion;
|
||||
ButtonPanel1.HelpButton.Caption:=lisMenuHelp;
|
||||
ButtonPanel1.CancelButton.Caption:=dlgCancel;
|
||||
|
||||
SameDFMCheckBox.Caption:=lisConvUseSameDFM;
|
||||
SameDFMCheckBox.Hint:=lisConvUseSameDFMHint;
|
||||
|
Loading…
Reference in New Issue
Block a user