| 1 | unit UFormSettings;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
|
|---|
| 7 | Menus, Spin, ExtCtrls, ULanguages;
|
|---|
| 8 |
|
|---|
| 9 | type
|
|---|
| 10 |
|
|---|
| 11 | { TFormSettings }
|
|---|
| 12 |
|
|---|
| 13 | TFormSettings = class(TForm)
|
|---|
| 14 | Bevel1: TBevel;
|
|---|
| 15 | ButtonOk: TButton;
|
|---|
| 16 | ButtonCancel: TButton;
|
|---|
| 17 | CheckBoxReopenLastFileOnStart: TCheckBox;
|
|---|
| 18 | CheckBoxAutomaticDPI: TCheckBox;
|
|---|
| 19 | ComboBoxLanguage: TComboBox;
|
|---|
| 20 | ComboBoxTheme: TComboBox;
|
|---|
| 21 | EditDefaultVcardVersion: TEdit;
|
|---|
| 22 | EditMapUrl: TEdit;
|
|---|
| 23 | Label1: TLabel;
|
|---|
| 24 | Label2: TLabel;
|
|---|
| 25 | Label3: TLabel;
|
|---|
| 26 | LabelDPI: TLabel;
|
|---|
| 27 | SpinEditDPI: TSpinEdit;
|
|---|
| 28 | procedure ButtonOkClick(Sender: TObject);
|
|---|
| 29 | procedure CheckBoxAutomaticDPIChange(Sender: TObject);
|
|---|
| 30 | procedure CheckBoxStartOnLogonChange(Sender: TObject);
|
|---|
| 31 | procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
|---|
| 32 | procedure FormCreate(Sender: TObject);
|
|---|
| 33 | procedure FormShow(Sender: TObject);
|
|---|
| 34 | private
|
|---|
| 35 | { private declarations }
|
|---|
| 36 | public
|
|---|
| 37 | procedure LoadData;
|
|---|
| 38 | procedure SaveData;
|
|---|
| 39 | procedure UpdateInterface;
|
|---|
| 40 | end;
|
|---|
| 41 |
|
|---|
| 42 | var
|
|---|
| 43 | FormSettings: TFormSettings;
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | implementation
|
|---|
| 47 |
|
|---|
| 48 | {$R *.lfm}
|
|---|
| 49 |
|
|---|
| 50 | uses
|
|---|
| 51 | UCore, UTheme;
|
|---|
| 52 |
|
|---|
| 53 | { TFormSettings }
|
|---|
| 54 |
|
|---|
| 55 | procedure TFormSettings.FormShow(Sender: TObject);
|
|---|
| 56 | begin
|
|---|
| 57 | Core.PersistentForm1.Load(Self);
|
|---|
| 58 |
|
|---|
| 59 | Core.Translator.LanguageListToStrings(ComboBoxLanguage.Items);
|
|---|
| 60 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Translator.Language);
|
|---|
| 61 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
|---|
| 62 |
|
|---|
| 63 | Core.ThemeManager1.Themes.LoadToStrings(ComboBoxTheme.Items);
|
|---|
| 64 | ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.ThemeManager1.Theme);
|
|---|
| 65 | if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
|
|---|
| 66 | end;
|
|---|
| 67 |
|
|---|
| 68 | procedure TFormSettings.ButtonOkClick(Sender: TObject);
|
|---|
| 69 | begin
|
|---|
| 70 | if ComboBoxLanguage.ItemIndex <> -1 then
|
|---|
| 71 | Core.Translator.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
|---|
| 72 | if ComboBoxTheme.ItemIndex <> -1 then
|
|---|
| 73 | Core.ThemeManager1.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
|
|---|
| 74 | end;
|
|---|
| 75 |
|
|---|
| 76 | procedure TFormSettings.CheckBoxAutomaticDPIChange(Sender: TObject);
|
|---|
| 77 | begin
|
|---|
| 78 | UpdateInterface;
|
|---|
| 79 | end;
|
|---|
| 80 |
|
|---|
| 81 | procedure TFormSettings.CheckBoxStartOnLogonChange(Sender: TObject);
|
|---|
| 82 | begin
|
|---|
| 83 | UpdateInterface;
|
|---|
| 84 | end;
|
|---|
| 85 |
|
|---|
| 86 | procedure TFormSettings.FormClose(Sender: TObject; var CloseAction: TCloseAction
|
|---|
| 87 | );
|
|---|
| 88 | begin
|
|---|
| 89 | Core.PersistentForm1.Save(Self);
|
|---|
| 90 | end;
|
|---|
| 91 |
|
|---|
| 92 | procedure TFormSettings.FormCreate(Sender: TObject);
|
|---|
| 93 | begin
|
|---|
| 94 | Core.Translator.TranslateComponentRecursive(Self);
|
|---|
| 95 | Core.ThemeManager1.UseTheme(Self);
|
|---|
| 96 | end;
|
|---|
| 97 |
|
|---|
| 98 | procedure TFormSettings.LoadData;
|
|---|
| 99 | begin
|
|---|
| 100 | CheckBoxAutomaticDPI.Checked := Core.ScaleDPI1.AutoDetect;
|
|---|
| 101 | SpinEditDPI.Value := Core.ScaleDPI1.DPI.X;
|
|---|
| 102 | CheckBoxReopenLastFileOnStart.Checked := Core.ReopenLastFileOnStart;
|
|---|
| 103 | EditDefaultVcardVersion.Text := Core.DefaultVcardVersion;
|
|---|
| 104 | EditMapUrl.Text := Core.MapUrl;
|
|---|
| 105 | UpdateInterface;
|
|---|
| 106 | end;
|
|---|
| 107 |
|
|---|
| 108 | procedure TFormSettings.SaveData;
|
|---|
| 109 | begin
|
|---|
| 110 | Core.ScaleDPI1.AutoDetect := CheckBoxAutomaticDPI.Checked;
|
|---|
| 111 | Core.ScaleDPI1.DPI := Point(SpinEditDPI.Value, SpinEditDPI.Value);
|
|---|
| 112 | Core.ReopenLastFileOnStart := CheckBoxReopenLastFileOnStart.Checked;
|
|---|
| 113 | Core.DefaultVcardVersion := EditDefaultVcardVersion.Text;
|
|---|
| 114 | Core.MapUrl := EditMapUrl.Text;
|
|---|
| 115 | end;
|
|---|
| 116 |
|
|---|
| 117 | procedure TFormSettings.UpdateInterface;
|
|---|
| 118 | begin
|
|---|
| 119 | SpinEditDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
|
|---|
| 120 | LabelDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
|
|---|
| 121 | end;
|
|---|
| 122 |
|
|---|
| 123 | end.
|
|---|
| 124 |
|
|---|