source: trunk/Forms/FormSettings.pas

Last change on this file was 221, checked in by chronos, 4 days ago
  • Fixed: Use scrollbox in resizable forms.
  • Fixed: Translate all forms.
File size: 3.1 KB
Line 
1unit FormSettings;
2
3interface
4
5uses
6 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
7 Menus, Spin, ExtCtrls, Languages, FormEx;
8
9type
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
38implementation
39
40{$R *.lfm}
41
42uses
43 Core, Theme;
44
45{ TFormSettings }
46
47procedure TFormSettings.CheckBoxAutomaticDPIChange(Sender: TObject);
48begin
49 UpdateInterface;
50end;
51
52procedure TFormSettings.CheckBoxStartOnLogonChange(Sender: TObject);
53begin
54 UpdateInterface;
55end;
56
57procedure TFormSettings.FormCreate(Sender: TObject);
58begin
59 Core.Core.Translator.TranslateComponentRecursive(Self);
60 Core.Core.ThemeManager.Themes.LoadToStrings(ComboBoxTheme.Items);
61 Core.Core.Translator.LanguageListToStrings(ComboBoxLanguage.Items);
62end;
63
64procedure TFormSettings.Load;
65begin
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;
77end;
78
79procedure TFormSettings.Save;
80begin
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;
91end;
92
93procedure TFormSettings.UpdateInterface;
94begin
95 CheckBoxStartMinimizedToTray.Enabled := CheckBoxStartOnLogon.Checked;
96 SpinEditDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
97 Label2.Enabled := not CheckBoxAutomaticDPI.Checked;
98end;
99
100end.
101
Note: See TracBrowser for help on using the repository browser.