Converter: Improve settings GUI. Add a checkbox for disabling the scanning of parent dir.

git-svn-id: trunk@46399 -
This commit is contained in:
juha 2014-10-01 23:36:53 +00:00
parent 69cf796672
commit 44073052c7
4 changed files with 285 additions and 202 deletions

View File

@ -409,7 +409,7 @@ end;
constructor TCacheUnitsThread.Create(aConverter: TConvertDelphiPBase; aPath: string);
begin
inherited Create(True);
FreeOnTerminate:=True;
FreeOnTerminate:=False; // Will be set to True before starting;
// Create searcher already now. Its Stop method can be called anytime.
fSearcher:=TUnitsSearcher.Create(aConverter);
// The parent directory to be scanned

View File

@ -1,39 +1,22 @@
object ConvertSettingsForm: TConvertSettingsForm
Left = 315
Height = 400
Height = 415
Top = 127
Width = 671
Width = 655
Caption = 'Convert Delphi unit, project or package '
ClientHeight = 400
ClientWidth = 671
Constraints.MinHeight = 377
Constraints.MinWidth = 544
ClientHeight = 415
ClientWidth = 655
Constraints.MinHeight = 407
Constraints.MinWidth = 584
OnCreate = FormCreate
OnDestroy = FormDestroy
Position = poScreenCenter
LCLVersion = '1.1'
object BackupCheckBox: TCheckBox
AnchorSideLeft.Control = DelphiDefineCheckBox
AnchorSideTop.Control = DelphiDefineCheckBox
AnchorSideTop.Side = asrBottom
Left = 15
Height = 21
Hint = 'Creates a Backup directory under project directory'
Top = 238
Width = 211
BorderSpacing.Top = 3
Caption = 'Make backup of changed files'
Checked = True
ParentShowHint = False
ShowHint = True
State = cbChecked
TabOrder = 0
end
LCLVersion = '1.3'
object ButtonPanel1: TButtonPanel
Left = 6
Height = 41
Top = 353
Width = 659
Height = 38
Top = 371
Width = 643
OKButton.Name = 'OKButton'
OKButton.DefaultCaption = True
HelpButton.Name = 'HelpButton'
@ -44,37 +27,22 @@ object ConvertSettingsForm: TConvertSettingsForm
CancelButton.Name = 'CancelButton'
CancelButton.DefaultCaption = True
CancelButton.OnClick = CancelButtonClick
TabOrder = 1
TabOrder = 0
ShowButtons = [pbOK, pbCancel, pbHelp]
end
object KeepFileOpenCheckBox: TCheckBox
AnchorSideLeft.Control = BackupCheckBox
AnchorSideTop.Control = BackupCheckBox
AnchorSideTop.Side = asrBottom
Left = 15
Height = 21
Hint = 'Separate form files allow different properties'
Top = 262
Width = 242
BorderSpacing.Top = 3
Caption = 'Keep converted files open in editor'
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
object UnitReplaceDivider: TDividerBevel
AnchorSideTop.Control = InputPathLabel
Left = 396
Height = 17
Left = 380
Height = 20
Top = 9
Width = 262
Caption = 'Unit Replacements'
Anchors = [akTop, akRight]
Font.Style = [fsBold]
LeftIndent = 30
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object UnknownPropsDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
@ -82,27 +50,27 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 396
Height = 17
Top = 65
Left = 380
Height = 20
Top = 68
Width = 262
Caption = 'Unknown properties'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 39
Font.Style = [fsBold]
LeftIndent = 30
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object UnitReplaceButton: TBitBtn
AnchorSideLeft.Control = UnitReplaceDivider
AnchorSideTop.Control = UnitReplaceDivider
AnchorSideTop.Side = asrBottom
Left = 397
Left = 381
Height = 25
Hint = 'Unit names in uses section of a source unit'
Top = 27
Top = 30
Width = 118
BorderSpacing.Left = 1
BorderSpacing.Top = 1
@ -110,7 +78,7 @@ object ConvertSettingsForm: TConvertSettingsForm
OnClick = UnitReplaceButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 3
TabOrder = 1
end
object TypeReplaceDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
@ -118,18 +86,18 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 396
Height = 17
Top = 121
Left = 380
Height = 20
Top = 127
Width = 262
Caption = 'Type Replacements'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 39
Font.Style = [fsBold]
LeftIndent = 30
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object TypeReplaceButton: TBitBtn
AnchorSideLeft.Control = TypeReplaceDivider
@ -137,10 +105,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceButton
AnchorSideRight.Side = asrBottom
Left = 397
Left = 381
Height = 25
Hint = 'Unknown types in form file (DFM/LFM)'
Top = 139
Top = 148
Width = 118
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 1
@ -149,7 +117,7 @@ object ConvertSettingsForm: TConvertSettingsForm
OnClick = TypeReplaceButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 4
TabOrder = 2
end
object FuncReplaceDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
@ -157,18 +125,18 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 396
Height = 17
Top = 177
Left = 380
Height = 20
Top = 186
Width = 262
Caption = 'Function Replacements'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 39
Font.Style = [fsBold]
LeftIndent = 30
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object CoordOffsDivider: TDividerBevel
AnchorSideLeft.Control = UnitReplaceDivider
@ -176,18 +144,18 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideRight.Side = asrBottom
Left = 396
Height = 17
Top = 249
Left = 380
Height = 20
Top = 261
Width = 262
Caption = 'Coordinate Offsets'
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 55
Font.Style = [fsBold]
LeftIndent = 30
ParentFont = False
ParentShowHint = False
ShowHint = True
LeftIndent = 30
end
object FuncReplaceButton: TBitBtn
AnchorSideLeft.Control = FuncReplaceDivider
@ -195,10 +163,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceButton
AnchorSideRight.Side = asrBottom
Left = 397
Left = 381
Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 195
Top = 207
Width = 118
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 1
@ -207,7 +175,7 @@ object ConvertSettingsForm: TConvertSettingsForm
OnClick = FuncReplaceButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 5
TabOrder = 3
end
object CoordOffsButton: TBitBtn
AnchorSideLeft.Control = CoordOffsDivider
@ -215,10 +183,10 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceButton
AnchorSideRight.Side = asrBottom
Left = 397
Left = 381
Height = 25
Hint = 'Some Delphi functions can be replaced with a LCL function'
Top = 267
Top = 282
Width = 118
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 1
@ -227,34 +195,34 @@ object ConvertSettingsForm: TConvertSettingsForm
OnClick = CoordOffsButtonClick
ParentShowHint = False
ShowHint = True
TabOrder = 6
TabOrder = 4
end
object TargetGroupBox: TGroupBox
AnchorSideLeft.Control = InputPathListBox
AnchorSideTop.Control = InputPathListBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 98
Height = 113
Hint = 'xxx'
Top = 107
Width = 211
Top = 79
Width = 224
Anchors = [akLeft, akBottom]
AutoSize = True
BorderSpacing.Top = 7
Caption = 'Target'
ClientHeight = 79
ClientWidth = 207
ClientHeight = 88
ClientWidth = 220
ParentShowHint = False
ShowHint = True
TabOrder = 7
TabOrder = 5
object SupportDelphiCheckBox: TCheckBox
AnchorSideLeft.Control = CrossPlatformCheckBox
AnchorSideTop.Control = CrossPlatformCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 21
Top = 29
Width = 117
Height = 24
Top = 32
Width = 125
BorderSpacing.Top = 3
BorderSpacing.Right = 6
Caption = 'Support Delphi'
@ -269,9 +237,9 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Side = asrBottom
Left = 6
Height = 21
Top = 53
Width = 195
Height = 24
Top = 59
Width = 208
BorderSpacing.Top = 3
BorderSpacing.Right = 6
BorderSpacing.Bottom = 5
@ -285,9 +253,9 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Control = TargetGroupBox
AnchorSideTop.Control = TargetGroupBox
Left = 6
Height = 21
Height = 24
Top = 5
Width = 115
Width = 123
BorderSpacing.Left = 6
BorderSpacing.Top = 5
BorderSpacing.Right = 6
@ -302,14 +270,14 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = UnitReplaceButton
AnchorSideTop.Side = asrCenter
Left = 530
Height = 25
Top = 27
Left = 514
Height = 28
Top = 28
Width = 129
BorderSpacing.Left = 15
ItemHeight = 0
ItemHeight = 20
Style = csDropDownList
TabOrder = 8
TabOrder = 6
end
object UnknownPropsComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceComboBox
@ -317,15 +285,15 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25
Top = 84
Left = 514
Height = 28
Top = 90
Width = 129
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 2
ItemHeight = 0
ItemHeight = 20
Style = csDropDownList
TabOrder = 9
TabOrder = 7
end
object FuncReplaceComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceComboBox
@ -333,14 +301,14 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25
Top = 195
Left = 514
Height = 28
Top = 205
Width = 129
Anchors = [akTop, akLeft, akRight]
ItemHeight = 0
ItemHeight = 20
Style = csDropDownList
TabOrder = 10
TabOrder = 8
end
object CoordOffsComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceComboBox
@ -348,14 +316,14 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25
Top = 267
Left = 514
Height = 28
Top = 280
Width = 129
Anchors = [akTop, akLeft, akRight]
ItemHeight = 0
ItemHeight = 20
Style = csDropDownList
TabOrder = 11
TabOrder = 9
end
object TypeReplaceComboBox: TComboBox
AnchorSideLeft.Control = UnitReplaceComboBox
@ -363,37 +331,41 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrCenter
AnchorSideRight.Control = UnitReplaceComboBox
AnchorSideRight.Side = asrBottom
Left = 530
Height = 25
Top = 139
Left = 514
Height = 28
Top = 146
Width = 129
Anchors = [akTop, akLeft, akRight]
ItemHeight = 0
ItemHeight = 20
Style = csDropDownList
TabOrder = 12
TabOrder = 10
end
object ScanProgressBar: TProgressBar
AnchorSideLeft.Control = ScanLabel
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = KeepFileOpenCheckBox
AnchorSideTop.Control = CoordOffsComboBox
AnchorSideTop.Side = asrBottom
Left = 185
AnchorSideRight.Control = CoordOffsComboBox
AnchorSideRight.Side = asrBottom
Left = 541
Height = 20
Top = 298
Top = 317
Width = 102
Anchors = [akTop, akRight]
BorderSpacing.Left = 6
BorderSpacing.Top = 15
BorderSpacing.Top = 9
Style = pbstMarquee
TabOrder = 13
TabOrder = 11
end
object ScanLabel: TLabel
AnchorSideLeft.Control = BackupCheckBox
AnchorSideTop.Control = ScanProgressBar
AnchorSideTop.Side = asrCenter
Left = 15
Height = 15
Top = 301
Width = 164
AnchorSideRight.Control = ScanProgressBar
Left = 365
Height = 20
Top = 317
Width = 170
Anchors = [akTop, akRight]
BorderSpacing.Right = 6
Caption = 'Scanning parent directory'
ParentColor = False
end
@ -403,49 +375,33 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = ScanProgressBar
AnchorSideRight.Side = asrBottom
Left = 185
Left = 541
Height = 25
Top = 319
Top = 338
Width = 102
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 1
Caption = 'Stop'
OnClick = StopScanButtonClick
TabOrder = 14
TabOrder = 12
end
object FuncReplaceCommentCB: TCheckBox
AnchorSideLeft.Control = FuncReplaceButton
AnchorSideTop.Control = FuncReplaceButton
AnchorSideTop.Side = asrBottom
Left = 397
Height = 21
Top = 225
Width = 227
Left = 381
Height = 24
Top = 237
Width = 241
BorderSpacing.Top = 5
Caption = 'Add comment after replacement'
TabOrder = 15
end
object DelphiDefineCheckBox: TCheckBox
AnchorSideLeft.Control = TargetGroupBox
AnchorSideTop.Control = TargetGroupBox
AnchorSideTop.Side = asrBottom
Left = 15
Height = 21
Hint = 'Separate form files allow different properties'
Top = 214
Width = 217
BorderSpacing.Left = 3
BorderSpacing.Top = 9
Caption = 'Add defines simulating Delphi7'
ParentShowHint = False
ShowHint = True
TabOrder = 16
TabOrder = 13
end
object InputPathLabel: TLabel
Left = 12
Height = 15
Height = 20
Top = 9
Width = 93
Width = 99
Caption = 'InputPathLabel'
ParentColor = False
end
@ -456,14 +412,94 @@ object ConvertSettingsForm: TConvertSettingsForm
AnchorSideRight.Control = UnitReplaceDivider
AnchorSideBottom.Control = TargetGroupBox
Left = 12
Height = 75
Top = 25
Width = 375
Height = 42
Top = 30
Width = 359
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 1
BorderSpacing.Right = 9
BorderSpacing.Bottom = 1
ItemHeight = 0
TabOrder = 17
TabOrder = 14
end
object OtherOptGroupBox: TGroupBox
AnchorSideLeft.Control = TargetGroupBox
AnchorSideTop.Control = TargetGroupBox
AnchorSideTop.Side = asrBottom
Left = 12
Height = 142
Top = 195
Width = 273
AutoSize = True
BorderSpacing.Top = 3
Caption = 'Other'
ClientHeight = 117
ClientWidth = 269
TabOrder = 15
object DelphiDefineCheckBox: TCheckBox
AnchorSideLeft.Control = OtherOptGroupBox
AnchorSideTop.Control = OtherOptGroupBox
Left = 6
Height = 24
Top = 5
Width = 233
BorderSpacing.Left = 6
BorderSpacing.Top = 5
BorderSpacing.Right = 6
Caption = 'Add defines simulating Delphi7'
ParentShowHint = False
ShowHint = True
TabOrder = 0
end
object BackupCheckBox: TCheckBox
AnchorSideLeft.Control = DelphiDefineCheckBox
AnchorSideTop.Control = DelphiDefineCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 32
Width = 222
BorderSpacing.Top = 3
BorderSpacing.Right = 6
Caption = 'Make backup of changed files'
Checked = True
ParentShowHint = False
ShowHint = True
State = cbChecked
TabOrder = 1
end
object KeepFileOpenCheckBox: TCheckBox
AnchorSideLeft.Control = BackupCheckBox
AnchorSideTop.Control = BackupCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 59
Width = 257
BorderSpacing.Top = 3
BorderSpacing.Right = 6
BorderSpacing.Bottom = 5
Caption = 'Keep converted files open in editor'
ParentShowHint = False
ShowHint = True
TabOrder = 2
end
object ScanParentDirCheckBox: TCheckBox
AnchorSideLeft.Control = KeepFileOpenCheckBox
AnchorSideTop.Control = KeepFileOpenCheckBox
AnchorSideTop.Side = asrBottom
Left = 6
Height = 24
Top = 88
Width = 212
BorderSpacing.Top = 3
BorderSpacing.Right = 6
BorderSpacing.Bottom = 5
Caption = 'Scan files in parent directory'
OnClick = ScanParentDirCheckBoxClick
ParentShowHint = False
ShowHint = True
TabOrder = 3
end
end
end

View File

@ -57,12 +57,13 @@ type
fConfigStorage: TConfigStorage;
fSettingsForm: TConvertSettingsForm;
// Actual user settings.
fDelphiDefine: Boolean;
fBackupFiles: Boolean;
fKeepFileOpen: Boolean;
fCrossPlatform: Boolean;
fSupportDelphi: Boolean;
fSameDfmFile: Boolean;
fDelphiDefine: Boolean;
fBackupFiles: Boolean;
fKeepFileOpen: Boolean;
fScanParentDir: Boolean;
fFuncReplaceComment: Boolean;
// Modes for replacements:
fUnitsReplaceMode: TReplaceModeLong;
@ -113,12 +114,15 @@ type
property MainPath: String read GetMainPath;
property BackupPath: String read GetBackupPath;
property Enabled: Boolean read fEnabled write SetEnabled;
property DelphiDefine: Boolean read fDelphiDefine;
property BackupFiles: Boolean read fBackupFiles;
property KeepFileOpen: Boolean read fKeepFileOpen;
property CrossPlatform: Boolean read fCrossPlatform;
property SupportDelphi: Boolean read fSupportDelphi;
property SameDfmFile: Boolean read fSameDfmFile;
property DelphiDefine: Boolean read fDelphiDefine;
property BackupFiles: Boolean read fBackupFiles;
property KeepFileOpen: Boolean read fKeepFileOpen;
property ScanParentDir: Boolean read fScanParentDir;
property FuncReplaceComment: Boolean read fFuncReplaceComment;
property UnitsReplaceMode: TReplaceModeLong read fUnitsReplaceMode;
property PropReplaceMode: TReplaceModeLong read fPropReplaceMode;
@ -136,10 +140,14 @@ type
{ TConvertSettingsForm }
TConvertSettingsForm = class(TForm)
FuncReplaceCommentCB: TCheckBox;
BackupCheckBox: TCheckBox;
DelphiDefineCheckBox: TCheckBox;
FuncReplaceCommentCB: TCheckBox;
ScanParentDirCheckBox: TCheckBox;
OtherOptGroupBox: TGroupBox;
InputPathLabel: TLabel;
InputPathListBox: TListBox;
KeepFileOpenCheckBox: TCheckBox;
StopScanButton: TBitBtn;
CoordOffsComboBox: TComboBox;
ScanLabel: TLabel;
@ -158,13 +166,12 @@ type
FuncReplaceDivider: TDividerBevel;
CoordOffsDivider: TDividerBevel;
FuncReplaceButton: TBitBtn;
KeepFileOpenCheckBox: TCheckBox;
BackupCheckBox: TCheckBox;
ButtonPanel1: TButtonPanel;
TypeReplaceButton: TBitBtn;
UnitReplaceButton: TBitBtn;
CoordOffsButton: TBitBtn;
procedure SameDfmCheckBoxChange(Sender: TObject);
procedure ScanParentDirCheckBoxClick(Sender: TObject);
procedure StopScanButtonClick(Sender: TObject);
procedure CancelButtonClick(Sender: TObject);
procedure SupportDelphiCheckBoxChange(Sender: TObject);
@ -177,6 +184,9 @@ type
private
fSettings: TConvertSettings;
fCacheUnitsThread: TThread;
fThreadStarted: Boolean;
procedure StartThreadIfValid;
procedure ThreadGuiShow(aRunning: Boolean);
procedure ThreadTerminated(Sender: TObject);
public
constructor Create(AOwner: TComponent; ASettings: TConvertSettings); reintroduce;
@ -401,12 +411,13 @@ begin
fCoordOffsets:=TVisualOffsets.Create;
// Load settings from ConfigStorage.
fConfigStorage:=GetIDEConfigStorage('delphiconverter.xml', true);
fDelphiDefine :=fConfigStorage.GetValue('DelphiDefine', true);
fBackupFiles :=fConfigStorage.GetValue('BackupFiles', true);
fKeepFileOpen :=fConfigStorage.GetValue('KeepFileOpen', false);
fCrossPlatform :=fConfigStorage.GetValue('CrossPlatform', true);
fSupportDelphi :=fConfigStorage.GetValue('SupportDelphi', false);
fSameDfmFile :=fConfigStorage.GetValue('SameDfmFile', false);
fDelphiDefine :=fConfigStorage.GetValue('DelphiDefine', true);
fBackupFiles :=fConfigStorage.GetValue('BackupFiles', true);
fKeepFileOpen :=fConfigStorage.GetValue('KeepFileOpen', false);
fScanParentDir :=fConfigStorage.GetValue('ScanParentDir', true);
fFuncReplaceComment :=fConfigStorage.GetValue('FuncReplaceComment', true);
fUnitsReplaceMode:=TReplaceModeLong(fConfigStorage.GetValue('UnitsReplaceMode', 2));
fPropReplaceMode :=TReplaceModeLong(fConfigStorage.GetValue('UnknownPropsMode', 2));
@ -629,12 +640,13 @@ end;
destructor TConvertSettings.Destroy;
begin
// Save possibly modified settings to ConfigStorage.
fConfigStorage.SetDeleteValue('DelphiDefine', fDelphiDefine, true);
fConfigStorage.SetDeleteValue('BackupFiles', fBackupFiles, true);
fConfigStorage.SetDeleteValue('KeepFileOpen', fKeepFileOpen, false);
fConfigStorage.SetDeleteValue('CrossPlatform', fCrossPlatform, true);
fConfigStorage.SetDeleteValue('SupportDelphi', fSupportDelphi, false);
fConfigStorage.SetDeleteValue('SameDfmFile', fSameDfmFile, false);
fConfigStorage.SetDeleteValue('DelphiDefine', fDelphiDefine, true);
fConfigStorage.SetDeleteValue('BackupFiles', fBackupFiles, true);
fConfigStorage.SetDeleteValue('KeepFileOpen', fKeepFileOpen, false);
fConfigStorage.SetDeleteValue('ScanParentDir', fScanParentDir, true);
fConfigStorage.SetDeleteValue('FuncReplaceComment',fFuncReplaceComment, true);
fConfigStorage.SetDeleteValue('UnitsReplaceMode', integer(fUnitsReplaceMode), 2);
fConfigStorage.SetDeleteValue('UnknownPropsMode', integer(fPropReplaceMode), 2);
@ -663,24 +675,18 @@ 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(MainFilename);
InputPathListBox.Items.Assign(fMainFilenames);
// Settings --> UI. Loaded from ConfigSettings earlier.
DelphiDefineCheckBox.Checked :=fDelphiDefine;
BackupCheckBox.Checked :=fBackupFiles;
KeepFileOpenCheckBox.Checked :=fKeepFileOpen;
CrossPlatformCheckBox.Checked :=fCrossPlatform;
SupportDelphiCheckBox.Checked :=fSupportDelphi;
SameDfmCheckBox.Checked :=fSameDfmFile;
DelphiDefineCheckBox.Checked :=fDelphiDefine;
BackupCheckBox.Checked :=fBackupFiles;
KeepFileOpenCheckBox.Checked :=fKeepFileOpen;
ScanParentDirCheckBox.Checked :=fScanParentDir;
FuncReplaceCommentCB.Checked :=fFuncReplaceComment;
UnitReplaceComboBox.ItemIndex :=integer(fUnitsReplaceMode);
UnknownPropsComboBox.ItemIndex :=integer(fPropReplaceMode);
TypeReplaceComboBox.ItemIndex :=integer(fTypeReplaceMode);
@ -688,16 +694,21 @@ begin
CoordOffsComboBox.ItemIndex :=integer(fCoordOffsMode);
SupportDelphiCheckBoxChange(SupportDelphiCheckBox);
SameDfmCheckBoxChange(SameDfmCheckBox);
fCacheUnitsThread := ACacheUnitsThread;
StartThreadIfValid;
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.
fDelphiDefine :=DelphiDefineCheckBox.Checked;
fBackupFiles :=BackupCheckBox.Checked;
fKeepFileOpen :=KeepFileOpenCheckBox.Checked;
fCrossPlatform :=CrossPlatformCheckBox.Checked;
fSupportDelphi :=SupportDelphiCheckBox.Checked;
fSameDfmFile :=SameDfmCheckBox.Checked;
fDelphiDefine :=DelphiDefineCheckBox.Checked;
fBackupFiles :=BackupCheckBox.Checked;
fKeepFileOpen :=KeepFileOpenCheckBox.Checked;
fScanParentDir :=ScanParentDirCheckBox.Checked;
fFuncReplaceComment:=FuncReplaceCommentCB.Checked;
fUnitsReplaceMode:=TReplaceModeLong(UnitReplaceComboBox.ItemIndex);
fPropReplaceMode :=TReplaceModeLong(UnknownPropsComboBox.ItemIndex);
fTypeReplaceMode :=TReplaceModeAllow(TypeReplaceComboBox.ItemIndex);
@ -848,6 +859,8 @@ end;
destructor TConvertSettingsForm.Destroy;
begin
if Assigned(fCacheUnitsThread) and not fThreadStarted then
fCacheUnitsThread.Free;
inherited Destroy;
end;
@ -856,21 +869,30 @@ begin
InputPathLabel.Caption:=lisToFPCPath; // Reuse a string form options page.
InputPathListBox.Clear;
InputPathListBox.Hint:=lisProjectPathHint;
DelphiDefineCheckBox.Caption:=lisAddDelphiDefine;
DelphiDefineCheckBox.Hint:=lisAddDelphiDefineHint;
BackupCheckBox.Caption:=lisBackupChangedFiles;
BackupCheckBox.Hint:=lisBackupHint;
KeepFileOpenCheckBox.Caption:=lisKeepFileOpen;
KeepFileOpenCheckBox.Hint:=lisKeepFileOpenHint;
// Target
TargetGroupBox.Caption:=lisConvertTarget;
TargetGroupBox.Hint:=lisConvertTargetHint;
CrossPlatformCheckBox.Caption:=lisConvertTargetCrossPlatform;
CrossPlatformCheckBox.Hint:=lisConvertTargetCrossPlatformHint;
SupportDelphiCheckBox.Caption:=lisConvertTargetSupportDelphi;
SupportDelphiCheckBox.Hint:=lisConvertTargetSupportDelphiHint;
SameDfmCheckBox.Caption:=lisConvertTargetSameDfmFile;
SameDfmCheckBox.Hint:=lisConvertTargetSameDfmFileHint;
TargetGroupBox.Caption:=lisConvertTarget;
TargetGroupBox.Hint:=lisConvertTargetHint;
// Other
OtherOptGroupBox.Caption:=lisCEOtherGroup;
OtherOptGroupBox.Hint:=lisConvertTargetHint;
DelphiDefineCheckBox.Caption:=lisAddDelphiDefine;
DelphiDefineCheckBox.Hint:=lisAddDelphiDefineHint;
BackupCheckBox.Caption:=lisBackupChangedFiles;
BackupCheckBox.Hint:=lisBackupHint;
KeepFileOpenCheckBox.Caption:=lisKeepFileOpen;
KeepFileOpenCheckBox.Hint:=lisKeepFileOpenHint;
ScanParentDirCheckBox.Caption:=lisScanFilesInParentDir;
ScanParentDirCheckBox.Hint:=lisScanFilesInParentDirHint;
// File system scanning
ScanLabel.Caption := lisScanParentDir;
StopScanButton.Caption:=lisStop;
StopScanButton.LoadGlyphFromResourceName(HInstance, 'menu_stop');
// Unit Replacements
UnitReplaceDivider.Caption:=lisConvUnitReplacements;
UnitReplaceButton.Caption:=lisEdit; // Recycled string.
@ -910,14 +932,8 @@ begin
CoordOffsButton.Hint:=lisConvCoordHint;
CoordOffsComboBox.Items.Add(lisDisabled);
CoordOffsComboBox.Items.Add(lisEnabled);
// File system scanning
ScanLabel.Caption := lisScanParentDir;
StopScanButton.Caption:=lisStop;
StopScanButton.LoadGlyphFromResourceName(HInstance, 'menu_stop');
ButtonPanel1.OKButton.Caption:=lisStartConversion;
ButtonPanel1.HelpButton.Caption:=lisMenuHelp;
ButtonPanel1.CancelButton.Caption:=lisCancel;
end;
procedure TConvertSettingsForm.FormDestroy(Sender: TObject);
@ -945,6 +961,26 @@ begin
CoordOffsComboBox.Enabled:=not Chk;
end;
procedure TConvertSettingsForm.ScanParentDirCheckBoxClick(Sender: TObject);
begin
if (Sender as TCheckBox).Checked then
StartThreadIfValid;
end;
procedure TConvertSettingsForm.StartThreadIfValid;
begin
if ScanParentDirCheckBox.Checked and Assigned(fCacheUnitsThread) then
begin
ThreadGuiShow(True);
fCacheUnitsThread.FreeOnTerminate:=True;
fCacheUnitsThread.OnTerminate:=@ThreadTerminated;
fCacheUnitsThread.Start;
fThreadStarted := True;
end
else
ThreadGuiShow(False); // Hide controls dealing with scanning
end;
procedure TConvertSettingsForm.StopScanButtonClick(Sender: TObject);
begin
(fCacheUnitsThread as TCacheUnitsThread).Searcher.Stop; // Terminate;
@ -958,12 +994,19 @@ begin
end;
end;
procedure TConvertSettingsForm.ThreadGuiShow(aRunning: Boolean);
begin
ScanLabel.Visible := aRunning;
ScanProgressBar.Visible := aRunning;
StopScanButton.Visible := aRunning;
// These are disabled while thread is running
ButtonPanel1.OKButton.Enabled := not aRunning;
ScanParentDirCheckBox.Enabled := not aRunning;
end;
procedure TConvertSettingsForm.ThreadTerminated(Sender: TObject);
begin
ScanLabel.Visible := False;
ScanProgressBar.Visible := False;
StopScanButton.Visible := False;
ButtonPanel1.OKButton.Enabled := True;
ThreadGuiShow(False);
fCacheUnitsThread := nil; // Thread frees itself. Make the variable nil, too.
end;

View File

@ -608,6 +608,7 @@ resourcestring
lisStartConversion = 'Start Conversion';
lisConvertTarget = 'Target';
lisConvertTargetHint = 'Converter adds conditional compilation to support different targets';
lisConvertOtherHint = 'Other options affecting the conversion';
lisConvertTargetCrossPlatform = 'Cross-platform';
lisConvertTargetCrossPlatformHint = 'Cross-platform versus Windows-only';
lisConvertTargetSupportDelphi = 'Support Delphi';
@ -616,6 +617,9 @@ resourcestring
lisConvertTargetSameDfmFileHint = 'Same DFM file for Lazarus and Delphi instead of copying it to LFM';
lisKeepFileOpen = 'Keep converted files open in editor';
lisKeepFileOpenHint = 'All project files will be open in editor after conversion';
lisScanFilesInParentDir = 'Scan files in parent directory';
lisScanFilesInParentDirHint = 'Search for source files in sibling directories'
+' (parent directory and its children)';
lisConvUnknownProps = 'Unknown properties';
lisConvTypesToReplace = 'Types to replace';
lisConvTypeReplacements = 'Type Replacements';