This repository has been archived by the owner on Mar 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigform.pas
84 lines (69 loc) · 1.88 KB
/
configform.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
unit ConfigForm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Buttons, StdCtrls, ActnList, config;
type
{ TFormConfig }
TFormConfig = class(TForm)
ActionOK: TAction;
ActionList: TActionList;
ButtonOK: TButton;
EditHost: TLabeledEdit;
EditPort: TLabeledEdit;
EditUserName: TLabeledEdit;
EditNickName: TLabeledEdit;
EditRealName: TLabeledEdit;
EditAltNickName: TLabeledEdit;
Label1: TLabel;
MemoChannels: TMemo;
procedure ActionOKExecute(Sender: TObject);
private
FConfig: TIRCConfig;
procedure CarregarConfiguracao;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
end;
implementation
{$R *.lfm}
{ TFormConfig }
procedure TFormConfig.ActionOKExecute(Sender: TObject);
var
Port: integer;
begin
if not TryStrToInt(EditPort.Text, Port) then
raise Exception.Create('Port value is invalid.');
FConfig.Host := EditHost.Text;
FConfig.Port := Port;
FConfig.Username := EditUserName.Text;
FConfig.Nickname := EditNickName.Text;
FConfig.AltNickname := EditAltNickName.Text;
FConfig.RealName := EditRealName.Text;
FConfig.Channels.CommaText := MemoChannels.Lines.CommaText;
FConfig.Save;
end;
procedure TFormConfig.CarregarConfiguracao;
begin
FConfig.Load;
EditHost.Text := FConfig.Host;
EditPort.Text := IntToStr(FConfig.Port);
EditUserName.Text := FConfig.Username;
EditNickName.Text := FConfig.Nickname;
EditAltNickName.Text := FConfig.AltNickname;
EditRealName.Text := FConfig.RealName;
MemoChannels.Lines.AddStrings(FConfig.Channels);
end;
constructor TFormConfig.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FConfig := TIRCConfig.Create;
CarregarConfiguracao;
end;
destructor TFormConfig.Destroy;
begin
FConfig.Free;
inherited Destroy;
end;
end.