1 | unit UFormSetting;
|
---|
2 |
|
---|
3 | {$mode delphi}
|
---|
4 |
|
---|
5 | interface
|
---|
6 |
|
---|
7 | uses
|
---|
8 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
---|
9 | CoolTranslator, ULanguages;
|
---|
10 |
|
---|
11 | type
|
---|
12 |
|
---|
13 | { TSettingForm }
|
---|
14 |
|
---|
15 | TSettingForm = class(TForm)
|
---|
16 | ButtonSave: TButton;
|
---|
17 | ButtonCancel: TButton;
|
---|
18 | ComboBoxLanguage: TComboBox;
|
---|
19 | Label2: TLabel;
|
---|
20 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
---|
21 | procedure FormShow(Sender: TObject);
|
---|
22 | private
|
---|
23 | procedure Save;
|
---|
24 | procedure Load;
|
---|
25 | public
|
---|
26 | { public declarations }
|
---|
27 | end;
|
---|
28 |
|
---|
29 | var
|
---|
30 | SettingForm: TSettingForm;
|
---|
31 |
|
---|
32 | implementation
|
---|
33 |
|
---|
34 | {$R *.lfm}
|
---|
35 |
|
---|
36 | uses
|
---|
37 | UCore, UFormMain;
|
---|
38 |
|
---|
39 | { TSettingForm }
|
---|
40 |
|
---|
41 | procedure TSettingForm.FormShow(Sender: TObject);
|
---|
42 | begin
|
---|
43 | MainForm.PersistentForm.Load(Self);
|
---|
44 |
|
---|
45 | Load;
|
---|
46 | end;
|
---|
47 |
|
---|
48 | procedure TSettingForm.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
---|
49 | );
|
---|
50 | begin
|
---|
51 | if ModalResult = mrOK then Save;
|
---|
52 | MainForm.PersistentForm.Save(Self);
|
---|
53 | end;
|
---|
54 |
|
---|
55 | procedure TSettingForm.Save;
|
---|
56 | begin
|
---|
57 | with Core.CoolTranslator1 do
|
---|
58 | Language := TLanguage(Languages[ComboBoxLanguage.ItemIndex]);
|
---|
59 | end;
|
---|
60 |
|
---|
61 | procedure TSettingForm.Load;
|
---|
62 | begin
|
---|
63 | with Core.CoolTranslator1 do begin
|
---|
64 | LanguageListToStrings(ComboBoxLanguage.Items);
|
---|
65 | if Assigned(Language) then begin
|
---|
66 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Language);
|
---|
67 | // Select automatic if no other match
|
---|
68 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
---|
69 | end else ComboBoxLanguage.ItemIndex := 0;
|
---|
70 | end;
|
---|
71 | end;
|
---|
72 |
|
---|
73 | end.
|
---|
74 |
|
---|