| 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 | ButtonOk: TButton;
|
|---|
| 15 | ButtonCancel: TButton;
|
|---|
| 16 | CheckBoxAlwaysOnTop: TCheckBox;
|
|---|
| 17 | CheckBoxAutomaticDPI: TCheckBox;
|
|---|
| 18 | CheckBoxReopenLastFileOnStart: TCheckBox;
|
|---|
| 19 | CheckBoxStartMinimizedToTray: TCheckBox;
|
|---|
| 20 | CheckBoxStartOnLogon: TCheckBox;
|
|---|
| 21 | ComboBoxLanguage: TComboBox;
|
|---|
| 22 | ComboBoxTheme: TComboBox;
|
|---|
| 23 | Label1: TLabel;
|
|---|
| 24 | Label2: TLabel;
|
|---|
| 25 | Label3: TLabel;
|
|---|
| 26 | ScrollBox1: TScrollBox;
|
|---|
| 27 | SpinEditDPI: TSpinEdit;
|
|---|
| 28 | procedure CheckBoxAutomaticDPIChange(Sender: TObject);
|
|---|
| 29 | procedure CheckBoxStartOnLogonChange(Sender: TObject);
|
|---|
| 30 | procedure FormCreate(Sender: TObject);
|
|---|
| 31 | public
|
|---|
| 32 | procedure Load;
|
|---|
| 33 | procedure Save;
|
|---|
| 34 | procedure UpdateInterface;
|
|---|
| 35 | end;
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | implementation
|
|---|
| 39 |
|
|---|
| 40 | {$R *.lfm}
|
|---|
| 41 |
|
|---|
| 42 | uses
|
|---|
| 43 | Core, Theme;
|
|---|
| 44 |
|
|---|
| 45 | { TFormSettings }
|
|---|
| 46 |
|
|---|
| 47 | procedure TFormSettings.CheckBoxAutomaticDPIChange(Sender: TObject);
|
|---|
| 48 | begin
|
|---|
| 49 | UpdateInterface;
|
|---|
| 50 | end;
|
|---|
| 51 |
|
|---|
| 52 | procedure TFormSettings.CheckBoxStartOnLogonChange(Sender: TObject);
|
|---|
| 53 | begin
|
|---|
| 54 | UpdateInterface;
|
|---|
| 55 | end;
|
|---|
| 56 |
|
|---|
| 57 | procedure TFormSettings.FormCreate(Sender: TObject);
|
|---|
| 58 | begin
|
|---|
| 59 | Core.Core.Translator.TranslateComponentRecursive(Self);
|
|---|
| 60 | Core.Core.ThemeManager.Themes.LoadToStrings(ComboBoxTheme.Items);
|
|---|
| 61 | Core.Core.Translator.LanguageListToStrings(ComboBoxLanguage.Items);
|
|---|
| 62 | end;
|
|---|
| 63 |
|
|---|
| 64 | procedure TFormSettings.Load;
|
|---|
| 65 | begin
|
|---|
| 66 | ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.Core.Translator.Language);
|
|---|
| 67 | if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
|
|---|
| 68 | ComboBoxTheme.ItemIndex := ComboBoxTheme.Items.IndexOfObject(Core.Core.ThemeManager.Theme);
|
|---|
| 69 | if ComboBoxTheme.ItemIndex = -1 then ComboBoxTheme.ItemIndex := 0;
|
|---|
| 70 | CheckBoxAlwaysOnTop.Checked := Core.Core.AlwaysOnTop;
|
|---|
| 71 | CheckBoxStartOnLogon.Checked := Core.Core.StartOnLogon;
|
|---|
| 72 | CheckBoxStartMinimizedToTray.Checked := Core.Core.StartMinimizedToTray;
|
|---|
| 73 | CheckBoxAutomaticDPI.Checked := Core.Core.ScaleDPI1.AutoDetect;
|
|---|
| 74 | SpinEditDPI.Value := Core.Core.ScaleDPI1.DPI.X;
|
|---|
| 75 | CheckBoxReopenLastFileOnStart.Checked := Core.Core.ReopenLastFileOnStart;
|
|---|
| 76 | UpdateInterface;
|
|---|
| 77 | end;
|
|---|
| 78 |
|
|---|
| 79 | procedure TFormSettings.Save;
|
|---|
| 80 | begin
|
|---|
| 81 | if ComboBoxLanguage.ItemIndex <> -1 then
|
|---|
| 82 | Core.Core.Translator.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
|
|---|
| 83 | if ComboBoxTheme.ItemIndex <> -1 then
|
|---|
| 84 | Core.Core.ThemeManager.Theme := TTheme(ComboBoxTheme.Items.Objects[ComboBoxTheme.ItemIndex]);
|
|---|
| 85 | Core.Core.AlwaysOnTop := CheckBoxAlwaysOnTop.Checked;
|
|---|
| 86 | Core.Core.StartOnLogon := CheckBoxStartOnLogon.Checked;
|
|---|
| 87 | Core.Core.StartMinimizedToTray := CheckBoxStartMinimizedToTray.Checked;
|
|---|
| 88 | Core.Core.ScaleDPI1.AutoDetect := CheckBoxAutomaticDPI.Checked;
|
|---|
| 89 | Core.Core.ScaleDPI1.DPI := Point(SpinEditDPI.Value, SpinEditDPI.Value);
|
|---|
| 90 | Core.Core.ReopenLastFileOnStart := CheckBoxReopenLastFileOnStart.Checked;
|
|---|
| 91 | end;
|
|---|
| 92 |
|
|---|
| 93 | procedure TFormSettings.UpdateInterface;
|
|---|
| 94 | begin
|
|---|
| 95 | CheckBoxStartMinimizedToTray.Enabled := CheckBoxStartOnLogon.Checked;
|
|---|
| 96 | SpinEditDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
|
|---|
| 97 | Label2.Enabled := not CheckBoxAutomaticDPI.Checked;
|
|---|
| 98 | end;
|
|---|
| 99 |
|
|---|
| 100 | end.
|
|---|
| 101 |
|
|---|