-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSettings.pas
126 lines (110 loc) · 2.88 KB
/
Settings.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{ The Weather Project - SETTINGS UNIT
(C) 2022 Connor Bell - ALL RIGHTS RESERVED
}
unit Settings;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ComCtrls, Vcl.ToolWin, Vcl.StdCtrls,
Vcl.ExtCtrls, Vcl.Themes;
type
TfrmSettings = class(TForm)
clbrMain: TCoolBar;
tlbrMain: TToolBar;
tlbtnClose: TToolButton;
pgcSettings: TPageControl;
tbsPersonalisation: TTabSheet;
grpTheme: TGroupBox;
pnlBase: TPanel;
btnSave: TButton;
btnClose: TButton;
btnDefault: TButton;
cbbTheme: TComboBox;
procedure tlbtnCloseClick(Sender: TObject);
procedure btnSaveClick(Sender: TObject);
procedure btnDefaultClick(Sender: TObject);
procedure btnCloseClick(Sender: TObject);
procedure cbbThemeChange(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure WriteTheme;
end;
var
frmSettings: TfrmSettings;
implementation
uses
Main;
{$R *.dfm}
procedure TfrmSettings.btnCloseClick(Sender: TObject);
begin
// CLOSE FORM
frmSettings.Close;
end;
procedure TfrmSettings.btnDefaultClick(Sender: TObject);
var
txtFile : TextFile;
begin
// SET DEFAULT THEME
if not FileExists('Theme.txt') then
begin
// File doesn't exist
MessageDlg('Error: Cannot save settings because the file "Theme" could not be located' + #13 +
'Locate the file and try again', mtError, [mbOK], 0);
Exit;
end
else
begin
// Write to File
AssignFile(txtFile, 'Theme.txt');
Rewrite(txtFile);
Writeln(txtFile, 'Luna');
end;
CloseFile(txtFile);
// Set Theme
TStyleManager.TrySetStyle('Luna');
MessageDlg('Saved', mtInformation, [mbOK], 0);
end;
procedure TfrmSettings.btnSaveClick(Sender: TObject);
begin
// READ SETTINGS
// Set Theme
WriteTheme;
MessageDlg('Saved', mtInformation, [mbOK], 0);
end;
procedure TfrmSettings.cbbThemeChange(Sender: TObject);
begin
// ENABLE BUTTONS
btnSave.Enabled := True;
btnDefault.Enabled := True;
end;
procedure TfrmSettings.tlbtnCloseClick(Sender: TObject);
begin
// CLOSE SETTINGS
frmSettings.Close;
end;
procedure TfrmSettings.WriteTheme;
var
txtFile : TextFile;
begin
// SAVE AND SET THEME
if not FileExists('Theme.txt') then
begin
// File doesn't exist
MessageDlg('Error: Cannot save settings because the file "Theme" could not be located' + #13 +
'Locate the file and try again', mtError, [mbOK], 0);
Exit;
end
else
begin
// Write to File
AssignFile(txtFile, 'Theme.txt');
Rewrite(txtFile);
Writeln(txtFile, cbbTheme.Text);
end;
CloseFile(txtFile);
// Set Theme
TStyleManager.TrySetStyle(cbbTheme.Text);
end;
end.