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