Changeset 83 for trunk/Packages
- Timestamp:
- Dec 28, 2021, 5:00:37 PM (3 years ago)
- Location:
- trunk/Packages/Common
- Files:
-
- 1 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/Common/Common.lpk
r76 r83 37 37 </Other> 38 38 </CompilerOptions> 39 <Description Value="Various libraries"/> 40 <License Value="GNU/GPL"/> 41 <Version Minor="7"/> 42 <Files Count="27"> 39 <Description Value="Common package with various useful units. 40 41 Source: https://svn.zdechov.net/PascalClassLibrary/Common/"/> 42 <License Value="Copy left."/> 43 <Version Minor="9"/> 44 <Files Count="29"> 43 45 <Item1> 44 46 <Filename Value="StopWatch.pas"/> … … 157 159 </Item26> 158 160 <Item27> 161 <Filename Value="UFormAbout.pas"/> 162 <UnitName Value="UFormAbout"/> 163 </Item27> 164 <Item28> 165 <Filename Value="UAboutDialog.pas"/> 166 <HasRegisterProc Value="True"/> 167 <UnitName Value="UAboutDialog"/> 168 </Item28> 169 <Item29> 159 170 <Filename Value="UPixelPointer.pas"/> 160 171 <UnitName Value="UPixelPointer"/> 161 </Item2 7>172 </Item29> 162 173 </Files> 163 174 <i18n> -
trunk/Packages/Common/Common.pas
r76 r83 13 13 UJobProgressView, UXMLUtils, UApplicationInfo, USyncCounter, UListViewSort, 14 14 UPersistentForm, UFindFile, UScaleDPI, UTheme, UStringTable, UMetaCanvas, 15 UGeometric, UTranslator, ULanguages, UPixelPointer, LazarusPackageIntf; 15 UGeometric, UTranslator, ULanguages, UFormAbout, UAboutDialog, 16 UPixelPointer, LazarusPackageIntf; 16 17 17 18 implementation … … 30 31 RegisterUnit('UTheme', @UTheme.Register); 31 32 RegisterUnit('UTranslator', @UTranslator.Register); 33 RegisterUnit('UAboutDialog', @UAboutDialog.Register); 32 34 end; 33 35 -
trunk/Packages/Common/UApplicationInfo.pas
r60 r83 6 6 7 7 uses 8 SysUtils, Classes, Forms, URegistry, Controls, Graphics ;8 SysUtils, Classes, Forms, URegistry, Controls, Graphics, LCLType; 9 9 10 10 type … … 14 14 TApplicationInfo = class(TComponent) 15 15 private 16 FDescription: T Caption;16 FDescription: TTranslateString; 17 17 FIcon: TBitmap; 18 18 FIdentification: Byte; … … 49 49 property EmailContact: string read FEmailContact write FEmailContact; 50 50 property AppName: string read FAppName write FAppName; 51 property Description: string read FDescription write FDescription;51 property Description: TTranslateString read FDescription write FDescription; 52 52 property ReleaseDate: TDateTime read FReleaseDate write FReleaseDate; 53 53 property RegistryKey: string read FRegistryKey write FRegistryKey; -
trunk/Packages/Common/UCommon.pas
r63 r83 8 8 {$ifdef Windows}Windows,{$endif} 9 9 {$ifdef Linux}baseunix,{$endif} 10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, LCLType, Forms, Controls,10 Classes, SysUtils, StrUtils, Dialogs, Process, LCLIntf, 11 11 FileUtil; //, ShFolder, ShellAPI; 12 12 … … 40 40 {$ENDIF} 41 41 42 function IntToBin(Data: Int64; Count: Byte): string;42 function AddLeadingZeroes(const aNumber, Length : integer) : string; 43 43 function BinToInt(BinStr: string): Int64; 44 function TryHexToInt(Data: string; var Value: Integer): Boolean;45 function TryBinToInt(Data: string; var Value: Integer): Boolean;46 44 function BinToHexString(Source: AnsiString): string; 47 45 //function DelTree(DirName : string): Boolean; … … 49 47 function BCDToInt(Value: Byte): Byte; 50 48 function CompareByteArray(Data1, Data2: TArrayOfByte): Boolean; 49 procedure CopyStringArray(Dest: TStringArray; Source: array of string); 50 function CombinePaths(Path1, Path2: string): string; 51 function ComputerName: string; 52 procedure DeleteFiles(APath, AFileSpec: string); 53 procedure ExecuteProgram(Executable: string; Parameters: array of string); 54 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog); 55 procedure FreeThenNil(var Obj); 56 function GetDirCount(Dir: string): Integer; 51 57 function GetUserName: string; 52 function LoggedOnUserNameEx(Format: TUserNameFormat): string;53 function SplitString(var Text: string; Count: Word): string;54 58 function GetBitCount(Variable: QWord; MaxIndex: Integer): Integer; 55 59 function GetBit(Variable: QWord; Index: Byte): Boolean; 60 function GetStringPart(var Text: string; Separator: string): string; 61 function GenerateNewName(OldName: string): string; 62 function GetFileFilterItemExt(Filter: string; Index: Integer): string; 63 function IntToBin(Data: Int64; Count: Byte): string; 64 function LastPos(const SubStr: String; const S: String): Integer; 65 function LoadFileToStr(const FileName: TFileName): AnsiString; 66 function LoggedOnUserNameEx(Format: TUserNameFormat): string; 67 function MergeArray(A, B: array of string): TArrayOfString; 68 function OccurenceOfChar(What: Char; Where: string): Integer; 69 procedure OpenWebPage(URL: string); 70 procedure OpenFileInShell(FileName: string); 71 function PosFromIndex(SubStr: string; Text: string; 72 StartIndex: Integer): Integer; 73 function PosFromIndexReverse(SubStr: string; Text: string; 74 StartIndex: Integer): Integer; 75 function RemoveQuotes(Text: string): string; 76 procedure SaveStringToFile(S, FileName: string); 56 77 procedure SetBit(var Variable: Int64; Index: Byte; State: Boolean); overload; 57 78 procedure SetBit(var Variable: QWord; Index: Byte; State: Boolean); overload; 58 79 procedure SetBit(var Variable: Cardinal; Index: Byte; State: Boolean); overload; 59 80 procedure SetBit(var Variable: Word; Index: Byte; State: Boolean); overload; 60 function AddLeadingZeroes(const aNumber, Length : integer) : string;61 function LastPos(const SubStr: String; const S: String): Integer;62 function GenerateNewName(OldName: string): string;63 function GetFileFilterItemExt(Filter: string; Index: Integer): string;64 procedure FileDialogUpdateFilterFileType(FileDialog: TOpenDialog);65 procedure DeleteFiles(APath, AFileSpec: string);66 procedure OpenWebPage(URL: string);67 procedure OpenFileInShell(FileName: string);68 procedure ExecuteProgram(Executable: string; Parameters: array of string);69 procedure FreeThenNil(var Obj);70 function RemoveQuotes(Text: string): string;71 function ComputerName: string;72 function OccurenceOfChar(What: Char; Where: string): Integer;73 function GetDirCount(Dir: string): Integer;74 function MergeArray(A, B: array of string): TArrayOfString;75 function LoadFileToStr(const FileName: TFileName): AnsiString;76 procedure SaveStringToFile(S, FileName: string);77 81 procedure SearchFiles(AList: TStrings; Dir: string; 78 82 FilterMethod: TFilterMethod = nil; FileNameMethod: TFileNameMethod = nil); 79 function GetStringPart(var Text: string; Separator: string): string;83 function SplitString(var Text: string; Count: Word): string; 80 84 function StripTags(const S: string): string; 81 function PosFromIndex(SubStr: string; Text: string; 82 StartIndex: Integer): Integer; 83 function PosFromIndexReverse(SubStr: string; Text: string; 84 StartIndex: Integer): Integer; 85 procedure CopyStringArray(Dest: TStringArray; Source: array of string); 85 function TryHexToInt(Data: string; var Value: Integer): Boolean; 86 function TryBinToInt(Data: string; var Value: Integer): Boolean; 87 procedure SortStrings(Strings: TStrings); 86 88 87 89 … … 669 671 end; 670 672 673 function CombinePaths(Path1, Path2: string): string; 674 begin 675 Result := Path1; 676 if Result <> '' then Result := Result + DirectorySeparator + Path2 677 else Result := Path2; 678 end; 679 680 procedure SortStrings(Strings: TStrings); 681 var 682 Tmp: TStringList; 683 begin 684 Strings.BeginUpdate; 685 try 686 if Strings is TStringList then begin 687 TStringList(Strings).Sort; 688 end else begin 689 Tmp := TStringList.Create; 690 try 691 Tmp.Assign(Strings); 692 Tmp.Sort; 693 Strings.Assign(Tmp); 694 finally 695 Tmp.Free; 696 end; 697 end; 698 finally 699 Strings.EndUpdate; 700 end; 701 end; 702 671 703 672 704 initialization -
trunk/Packages/Common/UFormAbout.lfm
r60 r83 11 11 OnShow = FormShow 12 12 Position = poScreenCenter 13 LCLVersion = '2.0. 2.0'13 LCLVersion = '2.0.10.0' 14 14 object LabelDescription: TLabel 15 15 Left = 30 16 Height = 2 616 Height = 24 17 17 Top = 135 18 18 Width = 642 … … 28 28 object LabelContent: TLabel 29 29 Left = 30 30 Height = 2 631 Top = 1 9130 Height = 24 31 Top = 189 32 32 Width = 642 33 33 Align = alTop … … 50 50 TabOrder = 0 51 51 object LabelAppName: TLabel 52 Left = 9653 Height = 10052 Left = 108 53 Height = 84 54 54 Top = 20 55 Width = 5 7255 Width = 564 56 56 Anchors = [akTop, akLeft, akRight] 57 57 AutoSize = False … … 68 68 Top = 30 69 69 Width = 72 70 Proportional = True 71 Stretch = True 70 72 end 71 73 end -
trunk/Packages/Common/UFormAbout.pas
r60 r83 50 50 if Assigned(AboutDialog) then 51 51 with TAboutDialog(AboutDialog) do begin 52 if Assigned( CoolTranslator) then53 CoolTranslator.TranslateComponentRecursive(Self);52 if Assigned(Translator) then 53 Translator.TranslateComponentRecursive(Self); 54 54 if Assigned(ThemeManager) then 55 55 ThemeManager.UseTheme(Self); -
trunk/Packages/Common/ULanguages.pas
r60 r83 1 1 unit ULanguages; 2 2 3 {$mode objfpc}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface 6 6 7 7 uses 8 Classes, SysUtils, Contnrs;8 Classes, SysUtils, fgl; 9 9 10 10 type … … 15 15 end; 16 16 17 { TLanguage List}18 19 TLanguage List = class(TObjectList)17 { TLanguages } 18 19 TLanguages = class(TFPGObjectList<TLanguage>) 20 20 function SearchByCode(ACode: string): TLanguage; 21 21 procedure AddNew(Code: string; Name: string); 22 constructor Create ;22 constructor Create(FreeObjects: Boolean = True); 23 23 end; 24 24 … … 223 223 224 224 225 { TLanguage List}226 227 function TLanguage List.SearchByCode(ACode: string): TLanguage;225 { TLanguages } 226 227 function TLanguages.SearchByCode(ACode: string): TLanguage; 228 228 var 229 229 I: Integer; … … 235 235 end; 236 236 237 procedure TLanguage List.AddNew(Code: string; Name: string);237 procedure TLanguages.AddNew(Code: string; Name: string); 238 238 var 239 239 NewItem: TLanguage; … … 245 245 end; 246 246 247 constructor TLanguage List.Create;247 constructor TLanguages.Create(FreeObjects: Boolean); 248 248 begin 249 inherited Create;249 inherited; 250 250 AddNew('', SLangAuto); 251 251 AddNew('aa', SLang_aa); -
trunk/Packages/Common/UListViewSort.pas
r55 r83 81 81 FOnChange: TNotifyEvent; 82 82 FStringGrid1: TStringGrid; 83 procedure DoOnChange; 83 84 procedure GridDoOnKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 84 85 procedure GridDoOnResize(Sender: TObject); … … 90 91 function TextEnteredColumn(Index: Integer): Boolean; 91 92 function GetColValue(Index: Integer): string; 93 procedure Reset; 92 94 property StringGrid: TStringGrid read FStringGrid1 write FStringGrid1; 93 95 published … … 152 154 { TListViewFilter } 153 155 156 procedure TListViewFilter.DoOnChange; 157 begin 158 if Assigned(FOnChange) then FOnChange(Self); 159 end; 160 154 161 procedure TListViewFilter.GridDoOnKeyUp(Sender: TObject; var Key: Word; 155 162 Shift: TShiftState); 156 163 begin 157 if Assigned(FOnChange) then 158 FOnChange(Self); 164 DoOnChange; 159 165 end; 160 166 … … 227 233 Result := StringGrid.Cells[Index, 0] 228 234 else Result := ''; 235 end; 236 237 procedure TListViewFilter.Reset; 238 var 239 I: Integer; 240 begin 241 with StringGrid do 242 for I := 0 to ColCount - 1 do 243 Cells[I, 0] := ''; 244 DoOnChange; 229 245 end; 230 246 -
trunk/Packages/Common/UMetaCanvas.pas
r67 r83 6 6 7 7 uses 8 Classes, SysUtils, Graphics, Contnrs,Types, fgl;8 Classes, SysUtils, Graphics, Types, fgl; 9 9 10 10 type -
trunk/Packages/Common/UPixelPointer.pas
r77 r83 15 15 private 16 16 procedure SetRGB(AValue: Cardinal); 17 function GetRGB: Cardinal; 17 18 public 18 function GetRGB: Cardinal;19 19 property RGB: Cardinal read GetRGB write SetRGB; 20 20 case Integer of … … 57 57 function Color32ToPixel32(Color: TColor32): TPixel32; 58 58 function Pixel32ToColor32(Color: TPixel32): TColor32; 59 function Color32ToColor(Color: TColor32): TColor; 60 function ColorToColor32(Color: TColor): TColor32; 59 61 60 62 implementation … … 136 138 var 137 139 SrcPtr, DstPtr: TPixelPointer; 138 SubPtr: TPixelPointer;139 140 X, Y: Integer; 140 141 XX, YY: Integer; … … 281 282 end; 282 283 284 function Color32ToColor(Color: TColor32): TColor; 285 begin 286 Result := ((Color shr 16) and $ff) or (Color and $00ff00) or 287 ((Color and $ff) shl 16); 288 end; 289 290 function ColorToColor32(Color: TColor): TColor32; 291 begin 292 Result := $ff000000 or ((Color shr 16) and $ff) or (Color and $00ff00) or 293 ((Color and $ff) shl 16); 294 end; 295 283 296 function PixelPointer(Bitmap: TRasterImage; BaseX: Integer; 284 297 BaseY: Integer): TPixelPointer; -
trunk/Packages/Common/UScaleDPI.pas
r55 r83 227 227 Temp[I] := TBitmap.Create; 228 228 Temp[I].SetSize(NewWidth, NewHeight); 229 {$IFDEF Linux} 230 Temp[I].PixelFormat := pf24bit; 231 {$ELSE} 229 232 Temp[I].PixelFormat := pf32bit; 233 {$ENDIF} 230 234 Temp[I].TransparentColor := TempBmp.TransparentColor; 231 235 //Temp[I].TransparentMode := TempBmp.TransparentMode; -
trunk/Packages/Common/UTheme.pas
r55 r83 5 5 uses 6 6 Classes, SysUtils, Graphics, ComCtrls, Controls, ExtCtrls, Menus, StdCtrls, 7 Spin, Forms, Contnrs, Grids;7 Spin, Forms, fgl, Grids; 8 8 9 9 type … … 19 19 { TThemes } 20 20 21 TThemes = class(T ObjectList)21 TThemes = class(TFPGObjectList<TTheme>) 22 22 function AddNew(Name: string): TTheme; 23 23 function FindByName(Name: string): TTheme; … … 74 74 procedure TThemes.LoadToStrings(Strings: TStrings); 75 75 var 76 Theme: TTheme;76 I: Integer; 77 77 begin 78 Strings.Clear; 79 for Theme in Self do 80 Strings.AddObject(Theme.Name, Theme); 78 Strings.BeginUpdate; 79 try 80 while Strings.Count < Count do Strings.Add(''); 81 while Strings.Count > Count do Strings.Delete(Strings.Count - 1); 82 for I := 0 to Count - 1 do begin 83 Strings[I] := Items[I].Name; 84 Strings.Objects[I] := Items[I]; 85 end; 86 finally 87 Strings.EndUpdate; 88 end; 81 89 end; 82 90 … … 123 131 destructor TThemeManager.Destroy; 124 132 begin 125 Themes.Free;126 inherited Destroy;133 FreeAndNil(Themes); 134 inherited; 127 135 end; 128 136 -
trunk/Packages/Common/UThreading.pas
r55 r83 6 6 7 7 uses 8 Classes, SysUtils, Forms, Contnrs, SyncObjs;8 Classes, SysUtils, Forms, fgl, SyncObjs; 9 9 10 10 type … … 22 22 function GetSuspended: Boolean; virtual; abstract; 23 23 function GetTerminated: Boolean; virtual; abstract; 24 function GetThreadId: Integer; virtual; abstract;24 function GetThreadId: TThreadID; virtual; abstract; 25 25 procedure SetFreeOnTerminate(const AValue: Boolean); virtual; abstract; 26 26 procedure SetPriority(const AValue: TThreadPriority); virtual; abstract; … … 42 42 property Terminated: Boolean read GetTerminated write SetTerminated; 43 43 property Finished: Boolean read GetFinished; 44 property ThreadId: Integerread GetThreadId;44 property ThreadId: TThreadID read GetThreadId; 45 45 end; 46 46 … … 68 68 function GetSuspended: Boolean; override; 69 69 function GetTerminated: Boolean; override; 70 function GetThreadId: Integer; override;70 function GetThreadId: TThreadID; override; 71 71 procedure SetFreeOnTerminate(const AValue: Boolean); override; 72 72 procedure SetPriority(const AValue: TThreadPriority); override; … … 102 102 { TThreadList } 103 103 104 TThreadList = class(T ObjectList)105 function FindById(Id: Integer): TVirtualThread;104 TThreadList = class(TFPGObjectList<TVirtualThread>) 105 function FindById(Id: TThreadID): TVirtualThread; 106 106 constructor Create; virtual; 107 107 end; … … 164 164 if MainThreadID = ThreadID then Method 165 165 else begin 166 Thread := ThreadList.FindById(ThreadID); 166 try 167 ThreadListLock.Acquire; 168 Thread := ThreadList.FindById(ThreadID); 169 finally 170 ThreadListLock.Release; 171 end; 167 172 if Assigned(Thread) then begin 168 173 Thread.Synchronize(Method); … … 173 178 { TThreadList } 174 179 175 function TThreadList.FindById(Id: Integer): TVirtualThread;180 function TThreadList.FindById(Id: TThreadID): TVirtualThread; 176 181 var 177 182 I: Integer; 178 183 begin 179 184 I := 0; 180 while (I < ThreadList.Count) and (T VirtualThread(ThreadList[I]).ThreadID <> Id) do185 while (I < ThreadList.Count) and (ThreadList[I].ThreadID <> Id) do 181 186 Inc(I); 182 if I < ThreadList.Count then Result := T VirtualThread(ThreadList[I])187 if I < ThreadList.Count then Result := ThreadList[I] 183 188 else Result := nil; 184 189 end; … … 233 238 end; 234 239 235 function TListedThread.GetThreadId: Integer;240 function TListedThread.GetThreadId: TThreadID; 236 241 begin 237 242 Result := FThread.ThreadID; … … 356 361 ThreadListLock := TCriticalSection.Create; 357 362 ThreadList := TThreadList.Create; 358 ThreadList. OwnsObjects := False;363 ThreadList.FreeObjects := False; 359 364 360 365 finalization -
trunk/Packages/Common/UTranslator.pas
r60 r83 1 1 unit UTranslator; 2 2 3 {$mode Delphi}{$H+}3 {$mode delphi}{$H+} 4 4 5 5 interface 6 6 7 7 uses 8 Classes, SysUtils, Forms, ExtCtrls, Controls, Contnrs, LazFileUtils, LazUTF8,8 Classes, SysUtils, Forms, ExtCtrls, Controls, fgl, LazFileUtils, LazUTF8, 9 9 Translations, TypInfo, Dialogs, FileUtil, LCLProc, ULanguages, LCLType, 10 10 LCLVersion; … … 12 12 type 13 13 THandleStringEvent = function (AValue: string): string of object; 14 15 TPoFiles = class(TFPGObjectList<TPOFile>) 16 end; 14 17 15 18 { TComponentExcludes } … … 24 27 { TComponentExcludesList } 25 28 26 TComponentExcludesList = class(T ObjectList)29 TComponentExcludesList = class(TFPGObjectList<TComponentExcludes>) 27 30 function FindByClassType(AClassType: TClass): TComponentExcludes; 28 31 procedure DumpToStrings(Strings: TStrings); … … 36 39 FOnAutomaticLanguage: THandleStringEvent; 37 40 FOnTranslate: TNotifyEvent; 38 FP OFilesFolder: string;39 FP OFiles: TObjectList; // TObjectList<TPOFile>;41 FPoFilesFolder: string; 42 FPoFiles: TPoFiles; 40 43 function GetLocale: string; 41 44 function GetLocaleShort: string; … … 50 53 public 51 54 ComponentExcludes: TComponentExcludesList; 52 Languages: TLanguage List;55 Languages: TLanguages; 53 56 procedure Translate; 54 procedure LanguageListToStrings(Strings: TStrings );57 procedure LanguageListToStrings(Strings: TStrings; WithCode: Boolean = True); 55 58 procedure TranslateResourceStrings(PoFileName: string); 56 59 procedure TranslateUnitResourceStrings(UnitName: string; PoFileName: string); … … 63 66 destructor Destroy; override; 64 67 published 65 property POFilesFolder: string read FP OFilesFolder write SetPOFilesFolder;68 property POFilesFolder: string read FPoFilesFolder write SetPOFilesFolder; 66 69 property Language: TLanguage read FLanguage write SetLanguage; 67 70 property OnTranslate: TNotifyEvent read FOnTranslate write FOnTranslate; … … 71 74 72 75 procedure Register; 76 73 77 74 78 implementation … … 117 121 destructor TComponentExcludes.Destroy; 118 122 begin 119 PropertyExcludes.Free;120 inherited Destroy;123 FreeAndNil(PropertyExcludes); 124 inherited; 121 125 end; 122 126 … … 128 132 I, J: Integer; 129 133 Po: TPoFile; 130 Item: TP OFileItem;134 Item: TPoFileItem; 131 135 begin 132 136 TranslateComponentRecursive(Application); … … 134 138 // Merge files to single translation file 135 139 try 136 Po := TP OFile.Create;137 for I := 0 to FP OFiles.Count - 1 do140 Po := TPoFile.Create; 141 for I := 0 to FPoFiles.Count - 1 do 138 142 with TPoFile(FPoFiles[I]) do 139 143 for J := 0 to Items.Count - 1 do … … 162 166 SearchMask: string; 163 167 begin 164 FP OFiles.Clear;168 FPoFiles.Clear; 165 169 if Assigned(FLanguage) then 166 170 try … … 177 181 if FileExists(FileName) and ( 178 182 ((LocaleShort = '') and (Pos('.', FileName) = Pos('.po', FileName))) or 179 (LocaleShort <> '')) then FP OFiles.Add(TPOFile.Create(FileName));183 (LocaleShort <> '')) then FPoFiles.Add(TPOFile.Create(FileName)); 180 184 end; 181 185 finally … … 281 285 var 282 286 Item: TClass; 283 284 287 Excludes: TComponentExcludes; 285 288 begin … … 301 304 function TTranslator.GetLangFileDir: string; 302 305 begin 303 Result := FP OFilesFolder;306 Result := FPoFilesFolder; 304 307 if Copy(Result, 1, 1) <> DirectorySeparator then 305 308 Result := ExtractFileDir(Application.ExeName) + … … 307 310 end; 308 311 309 procedure TTranslator.LanguageListToStrings(Strings: TStrings );312 procedure TTranslator.LanguageListToStrings(Strings: TStrings; WithCode: Boolean = True); 310 313 var 311 314 I: Integer; … … 313 316 begin 314 317 with Strings do begin 315 Clear; 316 for I := 0 to Languages.Count - 1 do 317 with TLanguage(Languages[I]) do 318 if Available then begin 319 ItemName := Name; 320 if Code <> '' then ItemName := ItemName + ' (' + Code + ')'; 321 AddObject(ItemName, Languages[I]); 322 end; 318 BeginUpdate; 319 try 320 Clear; 321 for I := 0 to Languages.Count - 1 do 322 with Languages[I] do 323 if Available then begin 324 ItemName := Name; 325 if WithCode and (Code <> '') then ItemName := ItemName + ' (' + Code + ')'; 326 AddObject(ItemName, Languages[I]); 327 end; 328 finally 329 EndUpdate; 330 end; 323 331 end; 324 332 end; … … 342 350 if Text <> '' then begin 343 351 for I := 0 to FPoFiles.Count - 1 do begin 344 Result := TPoFile(FP OFiles[I]).Translate(Identifier, Text);352 Result := TPoFile(FPoFiles[I]).Translate(Identifier, Text); 345 353 if Result <> Text then Break; 346 354 end; … … 369 377 begin 370 378 LangDir := GetLangFileDir; 371 TLanguage(Languages[0]).Available := True; // Automatic379 Languages.SearchByCode('').Available := True; // Automatic 372 380 373 381 for I := 1 to Languages.Count - 1 do 374 with TLanguage(Languages[I])do begin382 with Languages[I] do begin 375 383 Available := FileExists(LangDir + DirectorySeparator + ExtractFileNameOnly(Application.ExeName) + 376 384 '.' + Code + ExtensionSeparator + 'po') or (Code = 'en'); … … 381 389 begin 382 390 inherited; 383 FP OFiles := TObjectList.Create;391 FPoFiles := TPoFiles.Create; 384 392 ComponentExcludes := TComponentExcludesList.Create; 385 Languages := TLanguage List.Create;393 Languages := TLanguages.Create; 386 394 POFilesFolder := 'Languages'; 387 395 CheckLanguageFiles; … … 395 403 destructor TTranslator.Destroy; 396 404 begin 397 F POFiles.Free;398 Languages.Free;399 ComponentExcludes.Free;400 inherited Destroy;405 FreeAndNil(FPoFiles); 406 FreeAndNil(Languages); 407 FreeAndNil(ComponentExcludes); 408 inherited; 401 409 end; 402 410
Note:
See TracChangeset
for help on using the changeset viewer.