source: trunk/Forms/FormSettings.pas

Last change on this file was 164, checked in by chronos, 17 months ago
  • Fixed: Build under Windows.
  • Fixed: Correctly apply theme to contacts form.
File size: 3.9 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 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
49implementation
50
51{$R *.lfm}
52
53uses
54 Core, Theme;
55
56{ TFormSettings }
57
58procedure TFormSettings.FormShow(Sender: TObject);
59begin
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;
67end;
68
69procedure TFormSettings.ButtonOkClick(Sender: TObject);
70begin
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]);
75end;
76
77procedure TFormSettings.ButtonBrowseClick(Sender: TObject);
78begin
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;
84end;
85
86procedure TFormSettings.CheckBoxAutomaticDPIChange(Sender: TObject);
87begin
88 UpdateInterface;
89end;
90
91procedure TFormSettings.CheckBoxStartOnLogonChange(Sender: TObject);
92begin
93 UpdateInterface;
94end;
95
96procedure TFormSettings.LoadData;
97begin
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;
109end;
110
111procedure TFormSettings.SaveData;
112begin
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;
123end;
124
125procedure TFormSettings.UpdateInterface;
126begin
127 SpinEditDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
128 LabelDPI.Enabled := not CheckBoxAutomaticDPI.Checked;
129end;
130
131end.
132
Note: See TracBrowser for help on using the repository browser.