PoChecker: Improve the GUI and its anchors.

git-svn-id: trunk@34454 -
This commit is contained in:
juha 2011-12-28 00:34:47 +00:00
parent 521400fd7f
commit ebed12f697
5 changed files with 138 additions and 95 deletions

View File

@ -1,29 +1,37 @@
object PoCheckerForm: TPoCheckerForm object PoCheckerForm: TPoCheckerForm
Left = 409 Left = 349
Height = 295 Height = 311
Top = 133 Top = 189
Width = 463 Width = 581
Caption = 'GUI Po-file checking tool' Caption = 'GUI Po-file checking tool'
ClientHeight = 295 ClientHeight = 311
ClientWidth = 463 ClientWidth = 581
OnCreate = FormCreate OnCreate = FormCreate
OnDestroy = FormDestroy OnDestroy = FormDestroy
LCLVersion = '0.9.31' LCLVersion = '0.9.31'
Visible = True
object TestListBox: TCheckListBox object TestListBox: TCheckListBox
Left = 168 AnchorSideLeft.Control = SelectTestLabel
Height = 163 AnchorSideTop.Control = SelectTestLabel
Top = 44 AnchorSideTop.Side = asrBottom
Width = 288 Left = 201
Height = 169
Top = 33
Width = 373
Anchors = [akTop, akLeft, akRight, akBottom]
BorderSpacing.Top = 6
Enabled = False Enabled = False
ItemHeight = 0 ItemHeight = 0
OnItemClick = TestListBoxItemClick
TabOrder = 0 TabOrder = 0
end end
object Label1: TLabel object SelectTestLabel: TLabel
Left = 168 AnchorSideLeft.Control = OpenBtn
Height = 15 AnchorSideLeft.Side = asrBottom
Top = 24 Left = 201
Width = 105 Height = 19
Top = 8
Width = 144
BorderSpacing.Left = 9
Caption = 'Select test types' Caption = 'Select test types'
Font.Style = [fsBold] Font.Style = [fsBold]
ParentColor = False ParentColor = False
@ -31,9 +39,9 @@ object PoCheckerForm: TPoCheckerForm
end end
object OpenBtn: TBitBtn object OpenBtn: TBitBtn
Left = 8 Left = 8
Height = 79 Height = 63
Top = 44 Top = 33
Width = 144 Width = 184
Caption = '&Open a po-file' Caption = '&Open a po-file'
Glyph.Data = { Glyph.Data = {
36040000424D3604000000000000360000002800000010000000100000000100 36040000424D3604000000000000360000002800000010000000100000000100
@ -75,10 +83,17 @@ object PoCheckerForm: TPoCheckerForm
TabOrder = 1 TabOrder = 1
end end
object RunBtn: TBitBtn object RunBtn: TBitBtn
AnchorSideLeft.Control = OpenBtn
AnchorSideTop.Control = OpenBtn
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = OpenBtn
AnchorSideRight.Side = asrBottom
Left = 8 Left = 8
Height = 79 Height = 63
Top = 128 Top = 102
Width = 144 Width = 184
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 6
Caption = '&Run Selected Tests' Caption = '&Run Selected Tests'
Enabled = False Enabled = False
Kind = bkOK Kind = bkOK
@ -87,43 +102,56 @@ object PoCheckerForm: TPoCheckerForm
end end
object StatusPanel: TPanel object StatusPanel: TPanel
Left = 0 Left = 0
Height = 48 Height = 49
Top = 247 Top = 262
Width = 463 Width = 581
Align = alBottom Align = alBottom
BevelOuter = bvLowered BevelOuter = bvLowered
ClientHeight = 48 ClientHeight = 49
ClientWidth = 463 ClientWidth = 581
TabOrder = 3 TabOrder = 3
object Label2: TLabel object CurTestHeaderLabel: TLabel
Left = 8 Left = 8
Height = 15 Height = 19
Top = 8 Top = 8
Width = 74 Width = 96
Caption = 'Current Test:' Caption = 'Current Test:'
ParentColor = False ParentColor = False
end end
object Label3: TLabel object CurPoHeaderLabel: TLabel
AnchorSideLeft.Control = CurTestHeaderLabel
AnchorSideTop.Control = CurTestHeaderLabel
AnchorSideTop.Side = asrBottom
Left = 8 Left = 8
Height = 15 Height = 19
Top = 24 Top = 27
Width = 87 Width = 111
Caption = 'Current po-file:' Caption = 'Current po-file:'
ParentColor = False ParentColor = False
end end
object CurTestLabel: TLabel object CurTestLabel: TLabel
Left = 104 AnchorSideLeft.Control = CurTestHeaderLabel
Height = 15 AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = CurTestHeaderLabel
AnchorSideTop.Side = asrCenter
Left = 110
Height = 19
Top = 8 Top = 8
Width = 73 Width = 95
BorderSpacing.Around = 6
Caption = 'CurTestLabel' Caption = 'CurTestLabel'
ParentColor = False ParentColor = False
end end
object CurPoLabel: TLabel object CurPoLabel: TLabel
Left = 104 AnchorSideLeft.Control = CurPoHeaderLabel
Height = 15 AnchorSideLeft.Side = asrBottom
Top = 24 AnchorSideTop.Control = CurPoHeaderLabel
Width = 65 AnchorSideTop.Side = asrCenter
Left = 125
Height = 19
Top = 27
Width = 82
BorderSpacing.Around = 6
Caption = 'CurPoLabel' Caption = 'CurPoLabel'
ParentColor = False ParentColor = False
end end
@ -131,15 +159,30 @@ object PoCheckerForm: TPoCheckerForm
object NoErrLabel: TLabel object NoErrLabel: TLabel
Left = 8 Left = 8
Height = 24 Height = 24
Top = 216 Top = 232
Width = 171 Width = 171
Anchors = [akLeft, akBottom]
Caption = 'No errors found' Caption = 'No errors found'
Font.Color = clRed Font.Color = clGreen
Font.Height = -19 Font.Height = -19
Font.Style = [fsBold] Font.Style = [fsBold]
ParentColor = False ParentColor = False
ParentFont = False ParentFont = False
end end
object SelectAllCheckBox: TCheckBox
AnchorSideLeft.Control = TestListBox
AnchorSideTop.Control = TestListBox
AnchorSideTop.Side = asrBottom
Left = 201
Height = 23
Top = 208
Width = 97
BorderSpacing.Top = 6
Caption = 'Select All'
Enabled = False
OnClick = SelectAllCheckBoxClick
TabOrder = 4
end
object OpenDialog: TOpenDialog object OpenDialog: TOpenDialog
Filter = 'po-files (*.po)|*.po|all files|*' Filter = 'po-files (*.po)|*.po|all files|*'
Options = [ofFileMustExist, ofEnableSizing, ofViewDetail] Options = [ofFileMustExist, ofEnableSizing, ofViewDetail]

View File

@ -33,8 +33,9 @@ type
{ TPoCheckerForm } { TPoCheckerForm }
TPoCheckerForm = class(TForm) TPoCheckerForm = class(TForm)
Label2: TLabel; SelectAllCheckBox: TCheckBox;
Label3: TLabel; CurTestHeaderLabel: TLabel;
CurPoHeaderLabel: TLabel;
CurTestLabel: TLabel; CurTestLabel: TLabel;
CurPoLabel: TLabel; CurPoLabel: TLabel;
NoErrLabel: TLabel; NoErrLabel: TLabel;
@ -42,14 +43,14 @@ type
RunBtn: TBitBtn; RunBtn: TBitBtn;
OpenBtn: TBitBtn; OpenBtn: TBitBtn;
Button3: TButton; Button3: TButton;
Label1: TLabel; SelectTestLabel: TLabel;
OpenDialog: TOpenDialog; OpenDialog: TOpenDialog;
TestListBox: TCheckListBox; TestListBox: TCheckListBox;
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject); procedure FormDestroy(Sender: TObject);
procedure OpenBtnClick(Sender: TObject); procedure OpenBtnClick(Sender: TObject);
procedure RunBtnClick(Sender: TObject); procedure RunBtnClick(Sender: TObject);
procedure TestListBoxItemClick(Sender: TObject; Index: integer); procedure SelectAllCheckBoxClick(Sender: TObject);
private private
PoFamily: TPoFamily; PoFamily: TPoFamily;
FChoosenMasterName: String; FChoosenMasterName: String;
@ -70,10 +71,10 @@ resourcestring
rsPoChecker = 'PO File Checker'; rsPoChecker = 'PO File Checker';
sSelectAllTests = 'Select all tests'; sSelectAllTests = 'Select all tests';
sUnSelectAllTests = 'Unselect all tests'; sUnSelectAllTests = 'Unselect all tests';
sCannotFindMaster = 'Cannot find master po file:'^m'%s'^m'for selected file'^m'%s'; sCannotFindMaster = 'Cannot find master po file:' + LineEnding + '%s' + LineEnding + 'for selected file' + LineEnding + '%s';
sNotAProperFileName = 'Selected filename'^m'%s'^m'does not seem to be a proper name for a po-file'; sNotAProperFileName = 'Selected filename' + LineEnding + '%s' + LineEnding + 'does not seem to be a proper name for a po-file';
sErrorOnCreate = 'Error creating an instance of TPoFamily:'^m'%s'; sErrorOnCreate = 'Error creating an instance of TPoFamily:' + LineEnding + '%s';
sErrorOnCleanup = 'An unrecoverable error occurred'^m'%s'^m'Please close the program'; sErrorOnCleanup = 'An unrecoverable error occurred' + LineEnding + '%s' + LineEnding + 'Please close the program';
sTotalErrors = 'Total errors found: %d'; sTotalErrors = 'Total errors found: %d';
//sNoErrorsFound = 'No errors found.'; //sNoErrorsFound = 'No errors found.';
@ -116,11 +117,12 @@ begin
begin begin
RunBtn.Enabled := True; RunBtn.Enabled := True;
TestListBox.Enabled := True; TestListBox.Enabled := True;
SelectAllCheckBox.Enabled := True;
end end
else else begin
begin RunBtn.Enabled := False;
RunBtn.Enabled := False;
TestListBox.Enabled := False; TestListBox.Enabled := False;
SelectAllCheckBox.Enabled := False;
end; end;
end; end;
@ -129,20 +131,20 @@ begin
RunSelectedTests; RunSelectedTests;
end; end;
procedure TPoCheckerForm.TestListBoxItemClick(Sender: TObject; Index: integer); procedure TPoCheckerForm.SelectAllCheckBoxClick(Sender: TObject);
var var
Check: Boolean; cb: TCheckBox;
i: Integer; i: Integer;
begin begin
if (Index = TestListBox.Count - 1) then cb := Sender as TCheckBox;
begin//Run All Test checkbox // Caption text : select all / unselect all
Check := TestListBox.Checked[Index]; if cb.Checked then
for i := 0 to TestListBox.Count - 2 do TestListBox.Checked[i] := Check; cb.Caption := sUnSelectAllTests
if Check then else
TestListBox.Items[Index] := sUnSelectAllTests cb.Caption := sSelectAllTests;
else // Set / reset all CheckListBox items.
TestListBox.Items[Index] := sSelectAllTests; for i := 0 to TestListBox.Count - 1 do
end; TestListBox.Checked[i] := cb.Checked;
end; end;
procedure TPoCheckerForm.OnTestStart(const ATestName, APoFileName: String); procedure TPoCheckerForm.OnTestStart(const ATestName, APoFileName: String);
@ -166,10 +168,8 @@ var
Opt: TPoTestOption; Opt: TPoTestOption;
begin begin
for Opt := Low(PoTestOptionNames) to High(PoTestOptionNames) do for Opt := Low(PoTestOptionNames) to High(PoTestOptionNames) do
begin
TestListBox.Items.Add(PoTestOptionNames[Opt]); TestListBox.Items.Add(PoTestOptionNames[Opt]);
end; SelectAllCheckBox.Caption := sSelectAllTests;
TestListBox.Items.Add(sSelectAllTests);
end; end;
function TPoCheckerForm.GetOptionsFromListBox: TPoTestOptions; function TPoCheckerForm.GetOptionsFromListBox: TPoTestOptions;
@ -183,7 +183,8 @@ begin
Index := Ord(Opt); Index := Ord(Opt);
if (Index < TestListBox.Count) then if (Index < TestListBox.Count) then
begin begin
if TestListBox.Checked[Index] then Result := Result + [Opt]; if TestListBox.Checked[Index] then
Result := Result + [Opt];
end; end;
end; end;
end; end;
@ -230,7 +231,8 @@ begin
OK := (FChoosenMasterName <> ''); OK := (FChoosenMasterName <> '');
if OK then if OK then
begin begin
if Assigned(PoFamily) then PoFamily.Free; if Assigned(PoFamily) then
PoFamily.Free;
try try
PoFamily := TPoFamily.Create(FChoosenMasterName, FChoosenChildName); PoFamily := TPoFamily.Create(FChoosenMasterName, FChoosenChildName);
PoFamily.OnTestStart := @OnTestStart; PoFamily.OnTestStart := @OnTestStart;
@ -276,8 +278,9 @@ begin
SL := TStringList.Create; SL := TStringList.Create;
try try
StatusPanel.Enabled := True; StatusPanel.Enabled := True;
if (not (ptoFindAllChilds in Options)) and Assigned(PoFamily.Child) and if (not (ptoFindAllChilds in Options)) and Assigned(PoFamily.Child)
(PoFamily.ChildName <> FChoosenChildName) then PoFamily.ChildName := FChoosenChildName; and (PoFamily.ChildName <> FChoosenChildName) then
PoFamily.ChildName := FChoosenChildName;
PoFamily.RunTests(Options, ErrorCount, SL); PoFamily.RunTests(Options, ErrorCount, SL);
if (ErrorCount > 0) then if (ErrorCount > 0) then
begin begin
@ -292,10 +295,8 @@ begin
ResultDlg.Free; ResultDlg.Free;
end; end;
end end
else else //no errors
begin//no errors
NoErrLabel.Visible := True; NoErrLabel.Visible := True;
end;
finally finally
if Assigned(SL) then if Assigned(SL) then
SL.Free; SL.Free;

View File

@ -8,7 +8,6 @@ interface
uses uses
Classes, SysUtils, LCLProc, FileUtil, StringHashList, Classes, SysUtils, LCLProc, FileUtil, StringHashList,
{LConvEncoding}
//{$IFDEF UNIX}{$IFNDEF DisableCWString}, cwstring{$ENDIF}{$ENDIF}, //{$IFDEF UNIX}{$IFNDEF DisableCWString}, cwstring{$ENDIF}{$ENDIF},
SimplePoFiles; SimplePoFiles;
@ -23,10 +22,14 @@ const
optRunAllTests: TPoTestOptions = []; optRunAllTests: TPoTestOptions = [];
optRunAllTestsOnAllChilds: TPoTestOptions = []; optRunAllTestsOnAllChilds: TPoTestOptions = [];
PoTestOptionNames: array[TPoTestOption] of String = ('Check number of items', 'Check for incompatible format arguments', PoTestOptionNames: array[TPoTestOption] of String = (
'Check missing identifiers','Check for mismatches in untranslated strings', 'Check number of items',
'Check for duplicate untranslated values', 'Check for incompatible format arguments',
'Find all translated po-files'); 'Check missing identifiers',
'Check for mismatches in untranslated strings',
'Check for duplicate untranslated values',
'Find all translated po-files'
);
Type Type
{ TPoFamily } { TPoFamily }
@ -81,7 +84,6 @@ function ExtractMasterNameFromChildName(const AChildName: String): String;
function FindAllTranslatedPoFiles(const Filename: string): TStringList; function FindAllTranslatedPoFiles(const Filename: string): TStringList;
implementation implementation
const const
@ -663,16 +665,12 @@ begin
ErrorCount := CurrErrCnt + ErrorCount; ErrorCount := CurrErrCnt + ErrorCount;
end; end;
if (ptoCheckMismatchedOriginals in Options) then if (ptoCheckMismatchedOriginals in Options) then
begin begin
CheckMismatchedOriginals(CurrErrCnt, ErrorLog); CheckMismatchedOriginals(CurrErrCnt, ErrorLog);
ErrorCount := CurrErrCnt + ErrorCount; ErrorCount := CurrErrCnt + ErrorCount;
end; end;
{ {
if (pto in Options) then if (pto in Options) then
begin begin

View File

@ -1,7 +1,7 @@
object ResultDlgForm: TResultDlgForm object ResultDlgForm: TResultDlgForm
Left = 284 Left = 275
Height = 635 Height = 635
Top = 108 Top = 100
Width = 742 Width = 742
ActiveControl = CopyBtn ActiveControl = CopyBtn
Caption = 'Results' Caption = 'Results'
@ -27,11 +27,12 @@ object ResultDlgForm: TResultDlgForm
object CloseBtn: TBitBtn object CloseBtn: TBitBtn
AnchorSideRight.Control = Panel1 AnchorSideRight.Control = Panel1
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 657 Left = 652
Height = 30 Height = 30
Top = 10 Top = 10
Width = 75 Width = 80
Anchors = [akRight] Anchors = [akRight]
AutoSize = True
BorderSpacing.Right = 10 BorderSpacing.Right = 10
DefaultCaption = True DefaultCaption = True
Kind = bkClose Kind = bkClose
@ -40,22 +41,24 @@ object ResultDlgForm: TResultDlgForm
end end
object SaveBtn: TBitBtn object SaveBtn: TBitBtn
AnchorSideRight.Control = CloseBtn AnchorSideRight.Control = CloseBtn
Left = 572 Left = 536
Height = 30 Height = 30
Top = 10 Top = 10
Width = 75 Width = 106
Anchors = [akRight] Anchors = [akRight]
AutoSize = True
BorderSpacing.Around = 10 BorderSpacing.Around = 10
Caption = '&Save to file' Caption = '&Save to file'
TabOrder = 1 TabOrder = 1
end end
object CopyBtn: TBitBtn object CopyBtn: TBitBtn
AnchorSideRight.Control = SaveBtn AnchorSideRight.Control = SaveBtn
Left = 487 Left = 452
Height = 30 Height = 30
Top = 10 Top = 10
Width = 75 Width = 74
Anchors = [akRight] Anchors = [akRight]
AutoSize = True
BorderSpacing.Around = 10 BorderSpacing.Around = 10
Caption = 'CopyBtn' Caption = 'CopyBtn'
OnClick = CopyBtnClick OnClick = CopyBtnClick

View File

@ -27,11 +27,9 @@ type
procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
private private
{ private declarations }
PoHL: TSynPoSyn; PoHL: TSynPoSyn;
procedure SaveToFile; procedure SaveToFile;
public public
{ public declarations }
property Log: TStringList read FLog write FLog; property Log: TStringList read FLog write FLog;
end; end;