-
Notifications
You must be signed in to change notification settings - Fork 436
/
about.pas
146 lines (121 loc) · 3.75 KB
/
about.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
unit About;
// -------------------------------------
// About-box
// -------------------------------------
interface
uses
Windows, Classes, Graphics, Forms, Controls, StdCtrls, ExtCtrls, SysUtils, ComCtrls, pngimage, gnugettext,
Dialogs, SynRegExpr;
type
TAboutBox = class(TForm)
btnClose: TButton;
btnForum: TButton;
gboxCredits: TGroupBox;
memoCredits: TMemo;
lblAppName: TLabel;
lblAppVersion: TLabel;
lblAppCompiled: TLabel;
lblAppWebpage: TLabel;
btnUpdateCheck: TButton;
ImageHeidisql: TImage;
imgDonate: TImage;
lblDonated: TLabel;
editDonated: TEdit;
btnDonatedOK: TButton;
procedure OpenURL(Sender: TObject);
procedure MouseOver(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure FormShow(Sender: TObject);
procedure editDonatedEnter(Sender: TObject);
procedure editDonatedExit(Sender: TObject);
procedure btnDonatedOKClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
uses
main, helpers;
{$R *.DFM}
procedure TAboutBox.OpenURL(Sender: TObject);
begin
ShellExec( TControl(Sender).Hint );
end;
procedure TAboutBox.MouseOver(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
lblAppWebpage.Font.Color := clBlue;
if (Sender is TLabel) then
begin
TLabel(Sender).Font.Color := clRed;
end;
end;
procedure TAboutBox.btnDonatedOKClick(Sender: TObject);
var
Check: TThreeStateBoolean;
begin
AppSettings.WriteString(asDonatedEmail, editDonated.Text);
Check := MainForm.HasDonated(True);
case Check of
nbUnset:
MessageDialog(_('Could not check donation state.'), mtWarning, [mbOK]);
nbFalse:
ErrorDialog(_('Not a valid donators email address'));
nbTrue:
MessageDialog(_('Thanks for donating!'), mtInformation, [mbOK]);
end;
imgDonate.Visible := Check <> nbTrue;
MainForm.lblDonate.Visible := imgDonate.Visible;
end;
procedure TAboutBox.editDonatedEnter(Sender: TObject);
begin
btnDonatedOK.Default := True;
btnClose.Default := False;
end;
procedure TAboutBox.editDonatedExit(Sender: TObject);
begin
btnDonatedOK.Default := False;
btnClose.Default := True;
end;
procedure TAboutBox.FormShow(Sender: TObject);
var
ReadMe, Credits: String;
rx: TRegExpr;
begin
Screen.Cursor := crHourGlass;
TranslateComponent(Self);
InheritFont(Font);
InheritFont(lblAppName.Font);
lblAppName.Font.Size := 14;
InheritFont(lblAppWebpage.Font);
imgDonate.Visible := MainForm.HasDonated(False) <> nbTrue;
imgDonate.OnClick := MainForm.lblDonate.OnClick;
editDonated.Text := AppSettings.ReadString(asDonatedEmail);
// Assign text
Caption := f_('About %s', [APPNAME]);
lblAppName.Caption := APPNAME;
lblAppVersion.Caption := _('Version') + ' ' + Mainform.AppVersion;
lblAppCompiled.Caption := _('Compiled on:') + ' ' + DateTimeToStr(GetImageLinkTimeStamp(Application.ExeName));
lblAppWebpage.Caption := AppDomain;
lblAppWebpage.Hint := AppDomain;
// Read credits from readme.txt
rx := TRegExpr.Create;
try
ReadMe := ReadTextFile(ExtractFilePath(ParamStr(0)) + 'readme.txt', TEncoding.UTF8);
rx.Expression := '\*\*\* Credits\:\s+(\S.+)$';
if rx.Exec(ReadMe) then begin
Credits := rx.Match[1];
// Turn linebreaks into single spaces, and let TMemo.WordWrap insert fitting linebreaks
rx.Expression := '(\S)'+CRLF+'(\S)';
Credits := rx.Replace(Credits, '${1} ${2}', True);
Credits := Trim(Credits);
memoCredits.Text := Credits;
end;
except
on E:Exception do
memoCredits.Text := E.Message;
end;
rx.Free;
Screen.Cursor := crDefault;
end;
end.