source: tags/1.4.0/Forms/UFormSettings.pas

Last change on this file was 154, checked in by chronos, 7 years ago
  • Fixed: Settings dialog buttons position on form resize.
File size: 2.9 KB
Line 
1unit UFormSettings;
2
3{$mode delphi}
4
5interface
6
7uses
8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
9 Menus, Spin, ExtCtrls, ULanguages;
10
11type
12
13 { TFormSettings }
14
15 TFormSettings = class(TForm)
16 Bevel1: TBevel;
17 ButtonOk: TButton;
18 ButtonCancel: TButton;
19 CheckBoxReopenLastFileOnStart: TCheckBox;
20 CheckBoxAutomaticDPI: TCheckBox;
21 CheckBoxStartMinimizedToTray: TCheckBox;
22 CheckBoxStartOnLogon: TCheckBox;
23 CheckBoxAlwaysOnTop: TCheckBox;
24 ComboBoxLanguage: TComboBox;
25 Label1: TLabel;
26 Label2: TLabel;
27 SpinEditDPI: TSpinEdit;
28 procedure ButtonOkClick(Sender: TObject);
29 procedure CheckBoxAutomaticDPIChange(Sender: TObject);
30 procedure CheckBoxStartOnLogonChange(Sender: TObject);
31 procedure FormCreate(Sender: TObject);
32 procedure FormShow(Sender: TObject);
33 private
34 { private declarations }
35 public
36 procedure Load;
37 procedure Save;
38 procedure UpdateInterface;
39 end;
40
41var
42 FormSettings: TFormSettings;
43
44implementation
45
46{$R *.lfm}
47
48uses
49 UCore;
50
51{ TFormSettings }
52
53procedure TFormSettings.FormShow(Sender: TObject);
54begin
55 Core.CoolTranslator1.LanguageListToStrings(ComboBoxLanguage.Items);
56 ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.CoolTranslator1.Language);
57 if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
58end;
59
60procedure TFormSettings.ButtonOkClick(Sender: TObject);
61begin
62 if ComboBoxLanguage.ItemIndex <> -1 then
63 Core.CoolTranslator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
64end;
65
66procedure TFormSettings.CheckBoxAutomaticDPIChange(Sender: TObject);
67begin
68 UpdateInterface;
69end;
70
71procedure TFormSettings.CheckBoxStartOnLogonChange(Sender: TObject);
72begin
73 UpdateInterface;
74end;
75
76procedure TFormSettings.FormCreate(Sender: TObject);
77begin
78 Core.CoolTranslator1.TranslateComponentRecursive(Self);
79end;
80
81procedure TFormSettings.Load;
82begin
83 CheckBoxAlwaysOnTop.Checked := Core.AlwaysOnTop;
84 CheckBoxStartOnLogon.Checked := Core.StartOnLogon;
85 CheckBoxStartMinimizedToTray.Checked := Core.StartMinimizedToTray;
86 CheckBoxAutomaticDPI.Checked := Core.ScaleDPI1.AutoDetect;
87 SpinEditDPI.Value := Core.ScaleDPI1.DPI.X;
88 CheckBoxReopenLastFileOnStart.Checked := Core.ReopenLastFileOnStart;
89 UpdateInterface;
90end;
91
92procedure TFormSettings.Save;
93begin
94 Core.AlwaysOnTop := CheckBoxAlwaysOnTop.Checked;
95 Core.StartOnLogon := CheckBoxStartOnLogon.Checked;
96 Core.StartMinimizedToTray := CheckBoxStartMinimizedToTray.Checked;
97 Core.ScaleDPI1.AutoDetect := CheckBoxAutomaticDPI.Checked;
98 Core.ScaleDPI1.DPI := Point(SpinEditDPI.Value, SpinEditDPI.Value);
99 Core.ReopenLastFileOnStart := CheckBoxReopenLastFileOnStart.Checked;
100end;
101
102procedure TFormSettings.UpdateInterface;
103begin
104 CheckBoxStartMinimizedToTray.Enabled := CheckBoxStartOnLogon.Checked;
105 SpinEditDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
106 Label2.Enabled := not CheckBoxAutomaticDPI.Checked;
107end;
108
109end.
110
Note: See TracBrowser for help on using the repository browser.