Changeset 118 for trunk/Forms


Ignore:
Timestamp:
Oct 23, 2022, 10:55:55 PM (2 years ago)
Author:
chronos
Message:
  • Added: UCore main data module.
  • Added: Test cases support for better future testing.
Location:
trunk/Forms
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormMain.lfm

    r112 r118  
    3737    Top = 21
    3838  end
    39   object Translator1: TTranslator
    40     POFilesFolder = 'Languages'
    41     OnTranslate = Translator1Translate
    42     Left = 496
    43     Top = 358
    44   end
    4539  object ApplicationInfo1: TApplicationInfo
    4640    Identification = 1
     
    6155    Top = 460
    6256  end
    63   object PersistentForm1: TPersistentForm
    64     MinVisiblePart = 50
    65     EntireVisible = False
    66     Left = 488
    67     Top = 536
    68   end
    6957end
  • trunk/Forms/UFormMain.pas

    r100 r118  
    1515    ApplicationInfo1: TApplicationInfo;
    1616    PaintBox1: TPaintBox;
    17     PersistentForm1: TPersistentForm;
    1817    Timer1: TTimer;
    19     Translator1: TTranslator;
    2018    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    2119    procedure FormCreate(Sender: TObject);
     
    6058
    6159uses
    62   UFormImages, UPixelPointer;
     60  UFormImages, UPixelPointer, UCore, UFormTest, UTestCases;
    6361
    6462resourcestring
     
    7977  {$IFDEF UNIX}
    8078  // If installed in UNIX system then use installation directory for po files
    81   if not DirectoryExists(Translator1.POFilesFolder) and DirectoryExists(UnixLanguagesDir) then
    82     Translator1.POFilesFolder := UnixLanguagesDir;
     79  if not DirectoryExists(Core.Translator1.POFilesFolder) and DirectoryExists(UnixLanguagesDir) then
     80    Core.Translator1.POFilesFolder := UnixLanguagesDir;
    8381  {$ENDIF}
    8482
    8583  Engine := TEngine.Create;
    8684  Engine.RegistryContext := ApplicationInfo1.GetRegistryContext;
     85  Engine.Translator := Core.Translator1;
    8786  LoadConfig;
    8887  // Load cities after language core is loaded to have city names translated
     
    9594procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction);
    9695begin
    97   PersistentForm1.Save(Self);
     96  Core.PersistentForm1.Save(Self);
    9897end;
    9998
     
    116115const
    117116  KeyF11 = 122;
     117{$IFDEF DEBUG}
     118  KeyF12 = 123;
     119{$ENDIF}
    118120begin
    119121  if Key = KeyF11 then begin
    120122    FullScreen := not FullScreen;
    121     PersistentForm1.SetFullScreen(FormMain.FullScreen);
     123    Core.PersistentForm1.SetFullScreen(FormMain.FullScreen);
    122124  end else
     125{$IFDEF DEBUG}
     126  if Key = KeyF12 then begin
     127    FormTest := TFormTest.Create(nil);
     128    try
     129      FormTest.TestCases := InitTestCases;
     130      try
     131        FormTest.ShowModal;
     132      finally
     133        FormTest.TestCases.Free;
     134      end;
     135    finally
     136      FormTest.Free;
     137    end;
     138  end else
     139{$ENDIF}
    123140    Engine.KeyUp(Key);
    124141end;
     
    128145  if not Initialized then begin
    129146    Initialized := True;
    130     PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext;
    131     PersistentForm1.Load(Self, False, True);
    132     FullScreen := PersistentForm1.FormFullScreen;
     147    Core.PersistentForm1.RegistryContext := ApplicationInfo1.GetRegistryContext;
     148    Core.PersistentForm1.Load(Self, False, True);
     149    FullScreen := Core.PersistentForm1.FormFullScreen;
    133150    Engine.InitMenus;
    134151    Engine.OnDarkModeChange := DarkModeChange;
     
    214231    if ValueExists('LanguageCode') then begin
    215232      LangCode := ReadStringWithDefault('LanguageCode', '');
    216       Translator1.Language := Translator1.Languages.SearchByCode(LangCode);
    217     end else Translator1.Language := Translator1.Languages.SearchByCode('');
     233      Core.Translator1.Language := Core.Translator1.Languages.SearchByCode(LangCode);
     234    end else Core.Translator1.Language := Core.Translator1.Languages.SearchByCode('');
    218235    Engine.LoadFromRegistry;
    219236  finally
     
    228245    CurrentContext := ApplicationInfo1.GetRegistryContext;
    229246
    230     if Assigned(Translator1.Language) and (Translator1.Language.Code <> '') then
    231       WriteString('LanguageCode', Translator1.Language.Code)
     247    if Assigned(Core.Translator1.Language) and (Core.Translator1.Language.Code <> '') then
     248      WriteString('LanguageCode', Core.Translator1.Language.Code)
    232249      else DeleteValue('LanguageCode');
    233250    Engine.SaveToRegistry;
Note: See TracChangeset for help on using the changeset viewer.