Converter: Show a ProgressBar in settings window when parent dir is scanned. Refactor code.

git-svn-id: trunk@38344 -
This commit is contained in:
juha 2012-08-23 06:21:58 +00:00
parent 11a9424522
commit 20131f3434
4 changed files with 223 additions and 116 deletions

View File

@ -66,10 +66,11 @@ type
private
fConverter: TConvertDelphiPBase;
fPath: string;
procedure CacheUnitsInPath(const APath: string);
protected
procedure Execute; override;
public
constructor Create(aConverter: TConvertDelphiPBase; aBasePath: string);
constructor Create(aConverter: TConvertDelphiPBase);
destructor Destroy; override;
end;
@ -132,8 +133,6 @@ type
// Missing units that are commented automatically in all units.
fAllCommentedUnits: TStringList;
function DoMissingUnits(AUsedUnitsTool: TUsedUnitsTool): integer; virtual;
procedure CacheUnitsInPath(const APath, ABasePath: string);
procedure CacheUnitsInPath(const APath: string);
function GetCachedUnitPath(const AUnitName: string): string;
procedure ShowEndingMessage(AStatus: TModalResult);
public
@ -381,13 +380,43 @@ begin
end;
end;
type
{ TUnitsSearcher }
TUnitsSearcher = class(TFileSearcher)
private
FList: TStrings;
FOwnerThread: TThread;
protected
procedure DoFileFound; override;
public
constructor Create(AOwnerThread: TThread; AList: TStrings);
end;
{ TUnitsSearcher }
procedure TUnitsSearcher.DoFileFound;
begin
// if FOwnerThread.Terminated then <- Does not work, Terminated is protected
// Stop;
FList.Add(FileName);
end;
constructor TUnitsSearcher.Create(AOwnerThread: TThread; AList: TStrings);
begin
FOwnerThread := AOwnerThread;
FList := AList;
end;
{ TCacheUnitsThread }
constructor TCacheUnitsThread.Create(aConverter: TConvertDelphiPBase; aBasePath: string);
constructor TCacheUnitsThread.Create(aConverter: TConvertDelphiPBase);
begin
inherited Create(True);
FreeOnTerminate:=True;
fConverter:=aConverter; // Will scan one level up from base path.
fPath:=TrimFilename(aBasePath+'..'+DirectorySeparator);
fPath:=TrimFilename(fConverter.fSettings.MainPath+'..'+DirectorySeparator);
end;
destructor TCacheUnitsThread.Destroy;
@ -395,6 +424,41 @@ begin
inherited Destroy;
end;
procedure TCacheUnitsThread.CacheUnitsInPath(const APath: string);
// Search all pascal units in APath and store them in fCachedUnitNames
// with a path relative to fConverter.fSettings.MainPath.
var
PasFileList: TStringList;
i: Integer;
PasFile, RelPath, SubPath, sUnitName, FileName: String;
Searcher: TFileSearcher;
begin
// ToDo: find a way to stop the search when this thread is terminated.
// It maybe means copying TFileSearcher code here
PasFileList := TStringList.Create;
Searcher := TUnitsSearcher.Create(Self, PasFileList);
try
Searcher.Search(APath, '*.pas');
for i:=0 to PasFileList.Count-1 do begin
PasFile:=PasFileList[i];
RelPath:=FileUtil.CreateRelativePath(PasFile, fConverter.fSettings.MainPath);
SubPath:=ExtractFilePath(RelPath);
FileName:=ExtractFileName(RelPath);
sUnitName:=ExtractFileNameOnly(FileName);
if (SubPath<>'') and (sUnitName<>'') then begin
// Map path by unit name.
fConverter.fCachedUnitNames[sUnitName]:=SubPath;
// Map real unit name by uppercase unit name.
fConverter.fCachedRealFileNames[UpperCase(sUnitName)]:=FileName;
end;
end;
finally
Searcher.Free;
PasFileList.Free;
end;
end;
procedure TCacheUnitsThread.Execute;
// This assumes that cache is not used while updating it.
// The main GUI thread must wait for this thread before starting conversion.
@ -414,8 +478,10 @@ procedure TCacheUnitsThread.Execute;
begin
//If a project is in a subfolder of the root, fPath will be root path.
//Do not search the entire drive, or we may find Borland VCL files and convert them too
if not IsRootPath(fPath) then
fConverter.CacheUnitsInPath(fPath); // Scan for unit files.
if IsRootPath(fPath) then
Sleep(1) // Let the main thread execute, avoid possible synchr. problems.
else
CacheUnitsInPath(fPath); // Scan for unit files.
end;
{ TConvertDelphiUnit }
@ -436,7 +502,7 @@ var
begin
IDEMessagesWindow.Clear;
DelphiUnit := TDelphiUnit.Create(Self, fOrigFilename, []);
Result:=fSettings.RunForm;
Result:=fSettings.RunForm(Nil);
if Result=mrOK then
with DelphiUnit do
try
@ -487,40 +553,6 @@ begin
Result := 0;
end;
procedure TConvertDelphiPBase.CacheUnitsInPath(const APath, ABasePath: string);
// Search all pascal units in APath and store them in fCachedUnitNames
// with a path relative to ABasePath.
var
PasFileList: TStringList;
i: Integer;
PasFile, RelPath, SubPath, sUnitName, FileName: String;
begin
PasFileList:=FindAllFiles(APath,'*.pas',true);
try
for i:=0 to PasFileList.Count-1 do begin
PasFile:=PasFileList[i];
RelPath:=FileUtil.CreateRelativePath(PasFile, ABasePath);
SubPath:=ExtractFilePath(RelPath);
FileName:=ExtractFileName(RelPath);
sUnitName:=ExtractFileNameOnly(FileName);
if (SubPath<>'') and (sUnitName<>'') then begin
// Map path by unit name.
fCachedUnitNames[sUnitName]:=SubPath;
// Map real unit name by uppercase unit name.
fCachedRealFileNames[UpperCase(sUnitName)]:=FileName;
end;
end;
finally
PasFileList.Free;
end;
end;
procedure TConvertDelphiPBase.CacheUnitsInPath(const APath: string);
// Same as above but uses fSettings.MainPath as base path.
begin
CacheUnitsInPath(APath, fSettings.MainPath);
end;
function TConvertDelphiPBase.GetCachedUnitPath(const AUnitName: string): string;
begin
Result:=fCachedUnitNames[AUnitName];
@ -765,6 +797,7 @@ function TDelphiUnit.AskUnitPathFromUser: TModalResult;
// Ask the user what to do with missing units.
var
TryAgain: Boolean;
CacheUnitsThread: TCacheUnitsThread;
UnitDirDialog: TSelectDirectoryDialog;
begin
with fUsedUnitsTool do
@ -789,7 +822,11 @@ begin
if UnitDirDialog.Execute then begin
fOwnerConverter.fPrevSelectedPath:=ExtractFilePath(UnitDirDialog.Filename);
// Add the new path to project if missing units are found.
fOwnerConverter.CacheUnitsInPath(UnitDirDialog.Filename);
// We use a thread here only to reuse its code. No parallel operations now.
CacheUnitsThread:=TCacheUnitsThread.Create(fOwnerConverter);
CacheUnitsThread.Start;
CacheUnitsThread.WaitFor; // Make sure the thread has finished before continuing.
// fOwnerConverter.CacheUnitsInPath(UnitDirDialog.Filename);
TryAgain:=fOwnerConverter.DoMissingUnits(fUsedUnitsTool)>0;
end
else
@ -917,17 +954,16 @@ begin
IDEMessagesWindow.Clear;
// Start scanning unit files one level above project path. The GUI will appear
// without delay but then we must wait for the thread before continuing.
CacheUnitsThread:=TCacheUnitsThread.Create(Self, fSettings.MainPath);
try
CacheUnitsThread:=TCacheUnitsThread.Create(Self);
// try
try
CacheUnitsThread.Start;
Result:=fSettings.RunForm; // Get settings from user.
Screen.Cursor:=crHourGlass;
try
CacheUnitsThread.WaitFor; // Make sure the thread has finished.
finally
Screen.Cursor:=crDefault;
end;
Result:=fSettings.RunForm(CacheUnitsThread); // Get settings from user.
//Screen.Cursor:=crHourGlass;
//try
// CacheUnitsThread.WaitFor; // Make sure the thread has finished.
//finally
// Screen.Cursor:=crDefault;
//end;
if Result=mrOK then begin
// create/open lazarus project or package file
fLazPFilename:=fSettings.DelphiToLazFilename(fOrigFilename, fLazPSuffix, false);
@ -954,9 +990,9 @@ begin
Result:=mrAbort;
end;
ShowEndingMessage(Result);
finally
CacheUnitsThread.Free;
end;
//finally
// CacheUnitsThread.Free;
//end;
end;
function TConvertDelphiProjPack.ConvertSub: TModalResult;

View File

@ -1,12 +1,12 @@
object ConvertSettingsForm: TConvertSettingsForm
Left = 315
Height = 341
Height = 355
Top = 127
Width = 564
Width = 599
ActiveControl = ProjectPathEdit
Caption = 'Convert Delphi unit, project or package '
ClientHeight = 341
ClientWidth = 564
ClientHeight = 355
ClientWidth = 599
Constraints.MinHeight = 300
Constraints.MinWidth = 400
OnCreate = FormCreate
@ -17,10 +17,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = Owner
AnchorSideRight.Control = UnitReplaceDivider
Left = 9
Height = 20
Height = 25
Hint = 'Directory where project''s main file must be'
Top = 32
Width = 295
Width = 330
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 9
BorderSpacing.Right = 9
@ -32,9 +32,9 @@ object ConvertSettingsForm: TConvertSettingsForm
EditLabel.AnchorSideRight.Side = asrBottom
EditLabel.AnchorSideBottom.Control = ProjectPathEdit
EditLabel.Left = 9
EditLabel.Height = 15
EditLabel.Top = 10
EditLabel.Width = 295
EditLabel.Height = 17
EditLabel.Top = 8
EditLabel.Width = 330
EditLabel.Caption = 'Project Path:'
EditLabel.ParentColor = False
LabelSpacing = 7
@ -48,10 +48,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Control = TargetGroupBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 20
Height = 22
Hint = 'Creates a Backup directory under project directory'
Top = 194
Width = 170
Top = 185
Width = 215
BorderSpacing.Left = 3
BorderSpacing.Top = 9
Caption = 'Make backup of changed files'
@ -64,8 +64,8 @@ object ConvertSettingsForm: TConvertSettingsForm
object ButtonPanel1: TButtonPanel
Left = 6
Height = 41
Top = 294
Width = 552
Top = 308
Width = 587
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
@ -75,6 +75,7 @@ object ConvertSettingsForm: TConvertSettingsForm
CloseButton.Enabled = False
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
CancelButton.OnClick = CancelButtonClick
TabOrder = 2
ShowButtons = [pbOK, pbCancel, pbHelp]
end
@ -83,10 +84,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Control = BackupCheckBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 20
Height = 22
Hint = 'Separate form files allow different properties'
Top = 219
Width = 197
Top = 212
Width = 247
BorderSpacing.Top = 5
Caption = 'Keep converted files open in editor'
ParentShowHint = False
@ -94,7 +95,7 @@ object ConvertSettingsForm: TConvertSettingsForm
TabOrder = 3
end
object UnitReplaceDivider: TDividerBevel
Left = 313
Left = 348
Height = 17
Top = 9
Width = 239
@ -113,7 +114,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 313
Left = 348
Height = 17
Top = 65
Width = 239
@ -130,7 +131,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = UnitReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 314
Left = 349
Height = 25
Hint = 'Unit names in uses section of a source unit'
Top = 27
@ -149,7 +150,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 313
Left = 348
Height = 17
Top = 121
Width = 239
@ -166,7 +167,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = TypeReplaceDivider
AnchorSideTop.Control = TypeReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 314
Left = 349
Height = 25
Hint = 'Unknown types in form file (DFM/LFM)'
Top = 139
@ -185,7 +186,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 313
Left = 348
Height = 17
Top = 177
Width = 239
@ -204,7 +205,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 313
Left = 348
Height = 17
Top = 233
Width = 239
@ -221,7 +222,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = FuncReplaceDivider
AnchorSideTop.Control = FuncReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 314
Left = 349
Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 195
@ -238,7 +239,7 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = CoordOffsDivider
AnchorSideTop.Control = CoordOffsDivider
AnchorSideTop.Side = asrBottom
Left = 314
Left = 349
Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 251
@ -256,14 +257,14 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Control = ProjectPathEdit
AnchorSideTop.Side = asrBottom
Left = 9
Height = 122
Height = 108
Hint = 'xxx'
Top = 63
Top = 68
Width = 255
BorderSpacing.Top = 11
Caption = 'Target'
ClientHeight = 104
ClientWidth = 251
ClientHeight = 87
ClientWidth = 247
ParentShowHint = False
ShowHint = True
TabOrder = 8
@ -272,9 +273,9 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Control = MultiPlatformCheckBox
AnchorSideTop.Side = asrBottom
Left = 10
Height = 20
Top = 29
Width = 98
Height = 22
Top = 31
Width = 122
BorderSpacing.Top = 5
Caption = 'Support Delphi'
OnChange = SupportDelphiCheckBoxChange
@ -287,9 +288,9 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Control = SupportDelphiCheckBox
AnchorSideTop.Side = asrBottom
Left = 10
Height = 20
Top = 54
Width = 163
Height = 22
Top = 58
Width = 205
BorderSpacing.Top = 5
Caption = 'Use the same DFM form file'
OnChange = SameDfmCheckBoxChange
@ -300,9 +301,9 @@ object ConvertSettingsForm: TConvertSettingsForm
object MultiPlatformCheckBox: TCheckBox
AnchorSideTop.Control = TargetGroupBox
Left = 10
Height = 20
Height = 22
Top = 4
Width = 99
Width = 116
BorderSpacing.Top = 4
Caption = 'Multi-Platform'
ParentShowHint = False
@ -315,9 +316,9 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = UnitReplaceButton
AnchorSideTop.Side = asrCenter
Left = 412
Height = 24
Top = 27
Left = 447
Height = 29
Top = 25
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
@ -328,8 +329,8 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = UnitReplaceComboBox
AnchorSideTop.Control = UnknownPropsDivider
AnchorSideTop.Side = asrBottom
Left = 412
Height = 24
Left = 447
Height = 29
Top = 84
Width = 136
BorderSpacing.Top = 2
@ -342,9 +343,9 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = FuncReplaceButton
AnchorSideTop.Side = asrCenter
Left = 412
Height = 24
Top = 195
Left = 447
Height = 29
Top = 193
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
@ -356,9 +357,9 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CoordOffsButton
AnchorSideTop.Side = asrCenter
Left = 412
Height = 24
Top = 251
Left = 447
Height = 29
Top = 249
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
@ -370,13 +371,39 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = TypeReplaceButton
AnchorSideTop.Side = asrCenter
Left = 412
Height = 24
Top = 139
Left = 447
Height = 29
Top = 137
Width = 136
BorderSpacing.Left = 23
ItemHeight = 0
Style = csDropDownList
TabOrder = 13
end
object ScanProgressBar: TProgressBar
Left = 190
Height = 20
Top = 251
Width = 102
Style = pbstMarquee
TabOrder = 14
end
object ScanLabel: TLabel
Left = 16
Height = 17
Top = 251
Width = 166
Caption = 'Scanning parent directory'
ParentColor = False
end
object StopScanButton: TBitBtn
Left = 190
Height = 25
Top = 272
Width = 102
Caption = 'Stop'
OnClick = StopScanButtonClick
TabOrder = 15
Visible = False
end
end

View File

@ -31,7 +31,7 @@ interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, IDEProcs,
StdCtrls, EditBtn, Buttons, ExtCtrls, DialogProcs, ButtonPanel,
StdCtrls, EditBtn, Buttons, ExtCtrls, DialogProcs, ButtonPanel, ComCtrls,
LazarusIDEStrConsts, CodeToolsStructs, DividerBevel, AVL_Tree, BaseIDEIntf,
LazConfigStorage, ConverterTypes, ReplaceNamesUnit, ReplaceFuncsUnit;
@ -84,7 +84,7 @@ type
public
constructor Create(const ATitle: string);
destructor Destroy; override;
function RunForm: TModalResult;
function RunForm(ACacheUnitsThread: TThread): TModalResult;
// Lazarus file name based on Delphi file name, keep suffix.
function DelphiToLazFilename(const DelphiFilename: string;
@ -106,7 +106,6 @@ type
property MainPath: String read fMainPath;
property BackupPath: String read GetBackupPath;
property Enabled: Boolean read fEnabled write SetEnabled;
property BackupFiles: boolean read fBackupFiles;
property KeepFileOpen: boolean read fKeepFileOpen;
property MultiPlatform: boolean read fMultiPlatform;
@ -128,7 +127,10 @@ type
{ TConvertSettingsForm }
TConvertSettingsForm = class(TForm)
StopScanButton: TBitBtn;
CoordOffsComboBox: TComboBox;
ScanLabel: TLabel;
ScanProgressBar: TProgressBar;
UnitReplaceComboBox: TComboBox;
MultiPlatformCheckBox: TCheckBox;
SameDfmCheckBox: TCheckBox;
@ -150,7 +152,9 @@ type
UnitReplaceButton: TBitBtn;
ProjectPathEdit: TLabeledEdit;
CoordOffsButton: TBitBtn;
procedure CancelButtonClick(Sender: TObject);
procedure SameDfmCheckBoxChange(Sender: TObject);
procedure StopScanButtonClick(Sender: TObject);
procedure SupportDelphiCheckBoxChange(Sender: TObject);
procedure TypeReplaceButtonClick(Sender: TObject);
procedure FuncReplaceButtonClick(Sender: TObject);
@ -160,10 +164,13 @@ type
procedure FormDestroy(Sender: TObject);
private
fSettings: TConvertSettings;
fCacheUnitsThread: TThread;
procedure ThreadTerminated(Sender: TObject);
public
constructor Create(AOwner: TComponent; ASettings: TConvertSettings); reintroduce;
destructor Destroy; override;
end;
property CacheUnitsThread: TThread read fCacheUnitsThread;
end;
var
ConvertSettingsForm: TConvertSettingsForm;
@ -609,11 +616,19 @@ begin
inherited Destroy;
end;
function TConvertSettings.RunForm: TModalResult;
function TConvertSettings.RunForm(ACacheUnitsThread: TThread): TModalResult;
begin
fSettingsForm:=TConvertSettingsForm.Create(nil, Self);
try
with fSettingsForm do begin
fCacheUnitsThread := ACacheUnitsThread;
if Assigned(fCacheUnitsThread) then begin
fCacheUnitsThread.OnTerminate:=@ThreadTerminated;
ButtonPanel1.OKButton.Enabled := False; // Disabled while thread is running
fCacheUnitsThread.Start;
end
else
ThreadTerminated(nil); // Hide controls dealing with scanning
Caption:=fTitle + ' - ' + ExtractFileName(fMainFilename);
ProjectPathEdit.Text:=fMainPath;
// Settings --> UI. Loaded from ConfigSettings earlier.
@ -629,8 +644,8 @@ begin
CoordOffsComboBox.ItemIndex :=integer(fCoordOffsMode);
SupportDelphiCheckBoxChange(SupportDelphiCheckBox);
SameDfmCheckBoxChange(SameDfmCheckBox);
Result:=ShowModal; // Let the user change settings in a form.
if Result=mrOK then begin
Result:=ShowModal; // Let the user change settings in a form.
if Result=mrOK then begin // The thread will finished before the form closes.
// UI --> Settings. Will be saved to ConfigSettings later.
fBackupFiles :=BackupCheckBox.Checked;
fKeepFileOpen :=KeepFileOpenCheckBox.Checked;
@ -778,6 +793,7 @@ begin
// Unit Replacements
UnitReplaceDivider.Caption:=lisConvUnitReplacements;
UnitReplaceButton.Caption:=lisEdit; // Recycled string.
UnitReplaceButton.LoadGlyphFromLazarusResource('laz_edit');
UnitReplaceDivider.Hint:=lisConvUnitReplHint;
UnitReplaceButton.Hint:=lisConvUnitReplHint;
UnitReplaceComboBox.Items.Add(lisDisabled); // 'Disabled'
@ -791,6 +807,7 @@ begin
// Type Replacements
TypeReplaceDivider.Caption:=lisConvTypeReplacements;
TypeReplaceButton.Caption:=lisEdit;
TypeReplaceButton.LoadGlyphFromLazarusResource('laz_edit');
TypeReplaceDivider.Hint:=lisConvTypeReplHint;
TypeReplaceButton.Hint:=lisConvTypeReplHint;
TypeReplaceComboBox.Items.Add(lisInteractive);
@ -798,6 +815,7 @@ begin
// Func Replacements
FuncReplaceDivider.Caption:=lisConvFuncReplacements;
FuncReplaceButton.Caption:=lisEdit;
FuncReplaceButton.LoadGlyphFromLazarusResource('laz_edit');
FuncReplaceDivider.Hint:=lisConvFuncReplHint;
FuncReplaceButton.Hint:=lisConvFuncReplHint;
FuncReplaceComboBox.Items.Add(lisDisabled);
@ -805,10 +823,15 @@ begin
// Coordinate Offsets
CoordOffsDivider.Caption:=lisConvCoordOffs;
CoordOffsButton.Caption:=lisEdit;
CoordOffsButton.LoadGlyphFromLazarusResource('laz_edit');
CoordOffsDivider.Hint:=lisConvCoordHint;
CoordOffsButton.Hint:=lisConvCoordHint;
CoordOffsComboBox.Items.Add(lisDisabled);
CoordOffsComboBox.Items.Add(lisEnabled);
// File system scanning
ScanLabel.Caption := lisScanParentDir;
StopScanButton.Caption:=lisStop;
StopScanButton.LoadGlyphFromLazarusResource('menu_stop');
ButtonPanel1.OKButton.Caption:=lisStartConversion;
ButtonPanel1.HelpButton.Caption:=lisMenuHelp;
@ -840,6 +863,26 @@ begin
CoordOffsComboBox.Enabled:=not Chk;
end;
procedure TConvertSettingsForm.CancelButtonClick(Sender: TObject);
begin
if Assigned(fCacheUnitsThread) then
fCacheUnitsThread.WaitFor;
end;
procedure TConvertSettingsForm.ThreadTerminated(Sender: TObject);
begin
ScanLabel.Visible := False;
ScanProgressBar.Visible := False;
StopScanButton.Visible := False;
ButtonPanel1.OKButton.Enabled := True;
fCacheUnitsThread := nil; // Thread frees itself. Make the variable nil, too.
end;
procedure TConvertSettingsForm.StopScanButtonClick(Sender: TObject);
begin
fCacheUnitsThread.Terminate;
end;
// Edit replacements in grids
procedure TConvertSettingsForm.UnitReplaceButtonClick(Sender: TObject);

View File

@ -571,6 +571,7 @@ resourcestring
lisConvTopOff = 'Top offset';
lisConvLeftOff = 'Left offset';
lisConvDelphiFunc = 'Delphi Function';
lisScanParentDir = 'Scanning parent directory';
lisReplacement = 'Replacement';
lisReplacements = 'Replacements';
lisInteractive = 'Interactive';
@ -2038,7 +2039,7 @@ resourcestring
dlgMainViewUnits = 'View Project Units';
dlgMainViewFrames = 'View Project Frames';
dlgMultiSelect = 'Multi Select';
// check compiler options dialog
dlgCCOCaption = 'Checking compiler options';
dlgCCOTest = 'Test';