|
1 | | -unit About; |
2 | | - |
3 | | -{$mode delphi}{$H+} |
4 | | - |
5 | | -interface |
6 | | - |
7 | | -uses |
8 | | - Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ActnList, |
9 | | - ComCtrls, ExtCtrls, SynEdit, SynHighlighterSQL, laz.VirtualTrees, |
10 | | - RegExpr, Buttons, StdCtrls, Clipbrd, LCLIntf, LazVersion; |
11 | | - |
12 | | -type |
13 | | - |
14 | | - { TAboutBox } |
15 | | - |
16 | | - TAboutBox = class(TForm) |
17 | | - btnClose: TButton; |
18 | | - lblAppName: TLabel; |
19 | | - lblAppVersion: TLabel; |
20 | | - lblAppCompiled: TLabel; |
21 | | - lnklblWebpage: TLabel; |
22 | | - btnUpdateCheck: TButton; |
23 | | - ImageHeidisql: TImage; |
24 | | - lblDonated: TLabel; |
25 | | - editDonated: TEdit; |
26 | | - btnDonatedOK: TButton; |
27 | | - lnklblCredits: TLabel; |
28 | | - popupLabels: TPopupMenu; |
29 | | - menuCopyLabel: TMenuItem; |
30 | | - lblEnvironment: TLabel; |
31 | | - btnDonate: TButton; |
32 | | - lnklblCompiler: TLabel; |
33 | | - procedure OpenURL(Sender: TObject); |
34 | | - procedure FormShow(Sender: TObject); |
35 | | - procedure editDonatedEnter(Sender: TObject); |
36 | | - procedure editDonatedExit(Sender: TObject); |
37 | | - procedure btnDonatedOKClick(Sender: TObject); |
38 | | - procedure lnklblWebpageClick(Sender: TObject); |
39 | | - procedure lnklblCreditsClick(Sender: TObject); |
40 | | - procedure menuCopyLabelClick(Sender: TObject); |
41 | | - private |
42 | | - { Private declarations } |
43 | | - function GetCompilerVersion: String; |
44 | | - public |
45 | | - { Public declarations } |
46 | | - end; |
47 | | - |
48 | | -implementation |
49 | | - |
50 | | -uses |
51 | | - main, apphelpers, generic_types; |
52 | | - |
53 | | -{$R *.lfm} |
54 | | - |
55 | | - |
56 | | -procedure TAboutBox.OpenURL(Sender: TObject); |
57 | | -begin |
58 | | - ShellExec(TControl(Sender).Hint); |
59 | | -end; |
60 | | - |
61 | | - |
62 | | -procedure TAboutBox.btnDonatedOKClick(Sender: TObject); |
63 | | -var |
64 | | - Check: TThreeStateBoolean; |
65 | | -begin |
66 | | - AppSettings.WriteString(asDonatedEmail, editDonated.Text); |
67 | | - Check := MainForm.HasDonated(True); |
68 | | - case Check of |
69 | | - nbUnset: |
70 | | - MessageDialog(_('Could not check donation state.'), mtWarning, [mbOK]); |
71 | | - nbFalse: |
72 | | - ErrorDialog(_('Not a valid donor email address')); |
73 | | - nbTrue: |
74 | | - MessageDialog(_('Thanks for donating!'), mtInformation, [mbOK]); |
75 | | - end; |
76 | | - btnDonate.Visible := Check <> nbTrue; |
77 | | - MainForm.btnDonate.Visible := btnDonate.Visible; |
78 | | - MainForm.FormResize(Self); |
79 | | -end; |
80 | | - |
81 | | - |
82 | | -procedure TAboutBox.menuCopyLabelClick(Sender: TObject); |
83 | | -var |
84 | | - LabelComp: TComponent; |
85 | | -begin |
86 | | - // Copy label caption |
87 | | - LabelComp := PopupComponent(Sender); |
88 | | - if LabelComp is TLabel then begin |
89 | | - Clipboard.TryAsText := TLabel(LabelComp).Caption; |
90 | | - end; |
91 | | -end; |
92 | | - |
93 | | -procedure TAboutBox.editDonatedEnter(Sender: TObject); |
94 | | -begin |
95 | | - btnDonatedOK.Default := True; |
96 | | - btnClose.Default := False; |
97 | | -end; |
98 | | - |
99 | | - |
100 | | -procedure TAboutBox.editDonatedExit(Sender: TObject); |
101 | | -begin |
102 | | - btnDonatedOK.Default := False; |
103 | | - btnClose.Default := True; |
104 | | -end; |
105 | | - |
106 | | -procedure TAboutBox.FormShow(Sender: TObject); |
107 | | -begin |
108 | | - Screen.Cursor := crHourGlass; |
109 | | - |
110 | | - // Apply special font properties after form creation, as that disables ParentFont, which prevents InheritFont() to apply |
111 | | - lblAppName.Font.Size := Round(Screen.SystemFont.Size * 1.5); |
112 | | - lblAppName.Font.Style := [fsBold]; |
113 | | - |
114 | | - btnDonate.Caption := f_('Donate to the %s project', [APPNAME]); |
115 | | - btnDonate.Visible := MainForm.HasDonated(False) <> nbTrue; |
116 | | - btnDonate.OnClick := MainForm.DonateClick; |
117 | | - editDonated.Text := AppSettings.ReadString(asDonatedEmail); |
118 | | - |
119 | | - // Assign text |
120 | | - Caption := f_('About %s', [APPNAME]); |
121 | | - lblAppName.Caption := APPNAME; |
122 | | - lblAppVersion.Caption := _('Version') + ' ' + Mainform.AppVersion; |
123 | | - lblAppCompiled.Caption := _('Compiled on:') + ' ?' + {DateTimeToStr(GetImageLinkTimeStamp(Application.ExeName)) +} ' with'; |
124 | | - lnklblCompiler.Caption := GetCompilerVersion; |
125 | | - lnklblCompiler.Hint := 'https://www.lazarus-ide.org/?utm_source='+APPNAME; |
126 | | - lnklblWebpage.Caption := APPDOMAIN; |
127 | | - lnklblWebpage.Hint := APPDOMAIN+'?place='+EncodeURLParam(lnklblWebpage.Name); |
128 | | - |
129 | | - lnklblCompiler.Font.Style := lnklblCompiler.Font.Style + [fsUnderline]; |
130 | | - lnklblWebpage.Font.Style := lnklblWebpage.Font.Style + [fsUnderline]; |
131 | | - lnklblCredits.Font.Style := lnklblCredits.Font.Style + [fsUnderline]; |
132 | | - |
133 | | - ImageHeidisql.Hint := APPDOMAIN+'?place='+EncodeURLParam(ImageHeidisql.Name); |
134 | | - lblEnvironment.Caption := _('Environment:') + ' ' + GetOS; |
135 | | - |
136 | | - Screen.Cursor := crDefault; |
137 | | - btnClose.TrySetFocus; |
138 | | -end; |
139 | | - |
140 | | - |
141 | | -procedure TAboutBox.lnklblCreditsClick(Sender: TObject); |
142 | | -begin |
143 | | - Help(Sender, 'credits'); |
144 | | -end; |
145 | | - |
146 | | -procedure TAboutBox.lnklblWebpageClick(Sender: TObject); |
147 | | -begin |
148 | | - ShellExec((Sender as TLabel).Hint); |
149 | | -end; |
150 | | - |
151 | | -function TAboutBox.GetCompilerVersion: string; |
152 | | -begin |
153 | | - Result := 'Lazarus IDE v' + LazVersion.laz_version + ' and FreePascal v' + {$I %FPCVERSION%}; |
154 | | -end; |
155 | | - |
156 | | -end. |
157 | | - |
| 1 | +unit About; |
| 2 | + |
| 3 | +{$mode delphi}{$H+} |
| 4 | + |
| 5 | +interface |
| 6 | + |
| 7 | +uses |
| 8 | + Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ActnList, |
| 9 | + ComCtrls, ExtCtrls, SynEdit, SynHighlighterSQL, laz.VirtualTrees, |
| 10 | + RegExpr, Buttons, StdCtrls, Clipbrd, LCLIntf, LazVersion; |
| 11 | + |
| 12 | +type |
| 13 | + |
| 14 | + { TAboutBox } |
| 15 | + |
| 16 | + TAboutBox = class(TForm) |
| 17 | + btnClose: TButton; |
| 18 | + lblAppName: TLabel; |
| 19 | + lblAppVersion: TLabel; |
| 20 | + lblAppCompiled: TLabel; |
| 21 | + lnklblWebpage: TLabel; |
| 22 | + btnUpdateCheck: TButton; |
| 23 | + ImageHeidisql: TImage; |
| 24 | + lblDonated: TLabel; |
| 25 | + editDonated: TEdit; |
| 26 | + btnDonatedOK: TButton; |
| 27 | + lnklblCredits: TLabel; |
| 28 | + popupLabels: TPopupMenu; |
| 29 | + menuCopyLabel: TMenuItem; |
| 30 | + lblEnvironment: TLabel; |
| 31 | + btnDonate: TButton; |
| 32 | + lnklblCompiler: TLabel; |
| 33 | + procedure OpenURL(Sender: TObject); |
| 34 | + procedure FormShow(Sender: TObject); |
| 35 | + procedure editDonatedEnter(Sender: TObject); |
| 36 | + procedure editDonatedExit(Sender: TObject); |
| 37 | + procedure btnDonatedOKClick(Sender: TObject); |
| 38 | + procedure lnklblWebpageClick(Sender: TObject); |
| 39 | + procedure lnklblCreditsClick(Sender: TObject); |
| 40 | + procedure menuCopyLabelClick(Sender: TObject); |
| 41 | + private |
| 42 | + { Private declarations } |
| 43 | + function GetCompilerVersion: String; |
| 44 | + public |
| 45 | + { Public declarations } |
| 46 | + end; |
| 47 | + |
| 48 | +implementation |
| 49 | + |
| 50 | +uses |
| 51 | + main, apphelpers, generic_types; |
| 52 | + |
| 53 | +{$R *.lfm} |
| 54 | + |
| 55 | + |
| 56 | +procedure TAboutBox.OpenURL(Sender: TObject); |
| 57 | +begin |
| 58 | + ShellExec(TControl(Sender).Hint); |
| 59 | +end; |
| 60 | + |
| 61 | + |
| 62 | +procedure TAboutBox.btnDonatedOKClick(Sender: TObject); |
| 63 | +var |
| 64 | + Check: TThreeStateBoolean; |
| 65 | +begin |
| 66 | + AppSettings.WriteString(asDonatedEmail, editDonated.Text); |
| 67 | + Check := MainForm.HasDonated(True); |
| 68 | + case Check of |
| 69 | + nbUnset: |
| 70 | + MessageDialog(_('Could not check donation state.'), mtWarning, [mbOK]); |
| 71 | + nbFalse: |
| 72 | + ErrorDialog(_('Not a valid donor email address')); |
| 73 | + nbTrue: |
| 74 | + MessageDialog(_('Thanks for donating!'), mtInformation, [mbOK]); |
| 75 | + end; |
| 76 | + btnDonate.Visible := Check <> nbTrue; |
| 77 | + MainForm.btnDonate.Visible := btnDonate.Visible; |
| 78 | + MainForm.FormResize(Self); |
| 79 | +end; |
| 80 | + |
| 81 | + |
| 82 | +procedure TAboutBox.menuCopyLabelClick(Sender: TObject); |
| 83 | +var |
| 84 | + LabelComp: TComponent; |
| 85 | +begin |
| 86 | + // Copy label caption |
| 87 | + LabelComp := PopupComponent(Sender); |
| 88 | + if LabelComp is TLabel then begin |
| 89 | + Clipboard.TryAsText := TLabel(LabelComp).Caption; |
| 90 | + end; |
| 91 | +end; |
| 92 | + |
| 93 | +procedure TAboutBox.editDonatedEnter(Sender: TObject); |
| 94 | +begin |
| 95 | + btnDonatedOK.Default := True; |
| 96 | + btnClose.Default := False; |
| 97 | +end; |
| 98 | + |
| 99 | + |
| 100 | +procedure TAboutBox.editDonatedExit(Sender: TObject); |
| 101 | +begin |
| 102 | + btnDonatedOK.Default := False; |
| 103 | + btnClose.Default := True; |
| 104 | +end; |
| 105 | + |
| 106 | +procedure TAboutBox.FormShow(Sender: TObject); |
| 107 | +begin |
| 108 | + Screen.Cursor := crHourGlass; |
| 109 | + |
| 110 | + // Apply special font properties after form creation, as that disables ParentFont, which prevents InheritFont() to apply |
| 111 | + lblAppName.Font.Size := Round(Screen.SystemFont.Size * 1.5); |
| 112 | + lblAppName.Font.Style := [fsBold]; |
| 113 | + |
| 114 | + btnDonate.Caption := f_('Donate to the %s project', [APPNAME]); |
| 115 | + btnDonate.Visible := MainForm.HasDonated(False) <> nbTrue; |
| 116 | + btnDonate.OnClick := MainForm.DonateClick; |
| 117 | + editDonated.Text := AppSettings.ReadString(asDonatedEmail); |
| 118 | + |
| 119 | + // Assign text |
| 120 | + Caption := f_('About %s', [APPNAME]); |
| 121 | + lblAppName.Caption := APPNAME; |
| 122 | + lblAppVersion.Caption := _('Version') + ' ' + Mainform.AppVersion; |
| 123 | + lblAppCompiled.Caption := _('Compiled on:') + ' ?' + {DateTimeToStr(GetImageLinkTimeStamp(Application.ExeName)) +} ' with'; |
| 124 | + lnklblCompiler.Caption := GetCompilerVersion; |
| 125 | + lnklblCompiler.Hint := 'https://www.lazarus-ide.org/?utm_source='+APPNAME; |
| 126 | + lnklblWebpage.Caption := APPDOMAIN; |
| 127 | + lnklblWebpage.Hint := APPDOMAIN+'?place='+EncodeURLParam(lnklblWebpage.Name); |
| 128 | + |
| 129 | + lnklblCompiler.Font.Style := lnklblCompiler.Font.Style + [fsUnderline]; |
| 130 | + lnklblWebpage.Font.Style := lnklblWebpage.Font.Style + [fsUnderline]; |
| 131 | + lnklblCredits.Font.Style := lnklblCredits.Font.Style + [fsUnderline]; |
| 132 | + |
| 133 | + ImageHeidisql.Hint := APPDOMAIN+'?place='+EncodeURLParam(ImageHeidisql.Name); |
| 134 | + lblEnvironment.Caption := _('Environment:') + ' ' + GetOS; |
| 135 | + |
| 136 | + Screen.Cursor := crDefault; |
| 137 | + btnClose.TrySetFocus; |
| 138 | +end; |
| 139 | + |
| 140 | + |
| 141 | +procedure TAboutBox.lnklblCreditsClick(Sender: TObject); |
| 142 | +begin |
| 143 | + Help(Sender, 'credits'); |
| 144 | +end; |
| 145 | + |
| 146 | +procedure TAboutBox.lnklblWebpageClick(Sender: TObject); |
| 147 | +begin |
| 148 | + ShellExec((Sender as TLabel).Hint); |
| 149 | +end; |
| 150 | + |
| 151 | +function TAboutBox.GetCompilerVersion: string; |
| 152 | +begin |
| 153 | + Result := 'Lazarus IDE v' + LazVersion.laz_version + ' and FreePascal v' + {$I %FPCVERSION%}; |
| 154 | +end; |
| 155 | + |
| 156 | + |
| 157 | +end. |
| 158 | + |
0 commit comments