3
3
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
4
* obtain one at http://mozilla.org/MPL/2.0/
5
5
*
6
- * Copyright (C) 2005-2014 , Peter Johnson (www.delphidabbler.com).
6
+ * Copyright (C) 2005-2016 , Peter Johnson (www.delphidabbler.com).
7
7
*
8
8
* $Rev$
9
9
* $Date$
@@ -89,6 +89,8 @@ TAboutDlg = class(TGenericViewDlg)
89
89
pnlTitle: TPanel;
90
90
frmTitle: THTMLTpltDlgFrame;
91
91
tsPaths: TTabSheet;
92
+ btnViewAppConfig: TButton;
93
+ btnViewUserConfig: TButton;
92
94
procedure btnRegisterClick (Sender: TObject);
93
95
procedure FormCreate (Sender: TObject);
94
96
procedure FormDestroy (Sender: TObject);
@@ -98,6 +100,8 @@ TAboutDlg = class(TGenericViewDlg)
98
100
// / a tab is clicked.</remarks>
99
101
procedure pcDetailMouseDown (Sender: TObject; Button: TMouseButton;
100
102
Shift: TShiftState; X, Y: Integer);
103
+ procedure btnViewAppConfigClick (Sender: TObject);
104
+ procedure btnViewUserConfigClick (Sender: TObject);
101
105
strict private
102
106
fMainDBPathGp: TPathInfoBox; // control that displays main database folder
103
107
fUserDBPathGp: TPathInfoBox; // control that displays user database folder
@@ -120,6 +124,12 @@ TAboutDlg = class(TGenericViewDlg)
120
124
determines names that are displayed.
121
125
@return Required HTML.
122
126
}
127
+ procedure ViewConfigFile (const FileName, DlgTitle: string);
128
+ { Displays content of a config file in a preview dialogue box. If file
129
+ does not exist an error message is displayed.
130
+ @param FileName [in] Name of config file.
131
+ @param DlgTitle [in] Title of preview dialogue box.
132
+ }
123
133
strict protected
124
134
procedure ConfigForm ; override;
125
135
{ Configures form by creating custom controls and initialising HTML frames.
@@ -162,9 +172,9 @@ implementation
162
172
// Delphi
163
173
SysUtils, Graphics, Math, Windows, ShellAPI, IOUtils,
164
174
// Project
165
- FmEasterEgg, FmRegistrationDlg, UAppInfo, UColours, UConsts, UCSSUtils ,
166
- UCtrlArranger, UFontHelper, UGraphicUtils, UHTMLUtils, UHTMLTemplate ,
167
- UResourceUtils, UThemesEx;
175
+ FmEasterEgg, FmPreviewDlg, FmRegistrationDlg, UAppInfo, UColours, UConsts,
176
+ UCSSUtils, UCtrlArranger, UEncodings, UFontHelper, UGraphicUtils, UHTMLUtils,
177
+ UHTMLTemplate, UIOUtils, UMessageBox, UResourceUtils, UThemesEx;
168
178
169
179
170
180
{
@@ -215,7 +225,15 @@ procedure TAboutDlg.ArrangeForm;
215
225
begin
216
226
fMainDBPathGp.Top := TCtrlArranger.BottomOf(fInstallPathGp, 8 );
217
227
fUserDBPathGp.Top := TCtrlArranger.BottomOf(fMainDBPathGp, 8 );
218
- PathTabHeight := TCtrlArranger.BottomOf(fUserDBPathGp);
228
+ TCtrlArranger.AlignTops(
229
+ [btnViewAppConfig, btnViewUserConfig],
230
+ TCtrlArranger.BottomOf(fUserDBPathGp, 8 )
231
+ );
232
+ PathTabHeight := TCtrlArranger.BottomOf(
233
+ [btnViewUserConfig, btnViewAppConfig]
234
+ );
235
+ TCtrlArranger.AlignLefts([fUserDBPathGp, btnViewAppConfig]);
236
+ TCtrlArranger.AlignRights([fUserDBPathGp, btnViewUserConfig]);
219
237
// Set height of title frame and page control
220
238
pnlTitle.Height := frmTitle.DocHeight;
221
239
pcDetail.ClientHeight :=
@@ -240,15 +258,31 @@ procedure TAboutDlg.btnRegisterClick(Sender: TObject);
240
258
btnRegister.Hide; // hide registration button now that program registered OK
241
259
end ;
242
260
261
+ procedure TAboutDlg.btnViewAppConfigClick (Sender: TObject);
262
+ resourcestring
263
+ sTitle = ' Application Config File' ;
264
+ begin
265
+ ViewConfigFile(TAppInfo.AppConfigFileName, sTitle);
266
+ end ;
267
+
268
+ procedure TAboutDlg.btnViewUserConfigClick (Sender: TObject);
269
+ resourcestring
270
+ sTitle = ' Per-User Config File' ;
271
+ begin
272
+ ViewConfigFile(TAppInfo.UserConfigFileName, sTitle);
273
+ end ;
274
+
243
275
procedure TAboutDlg.ConfigForm ;
244
276
{ Configures form by creating custom controls and initialising HTML frames.
245
277
Called from ancestor class.
246
278
}
247
279
248
- function CreatePathInfoBox (const Caption, Path: string): TPathInfoBox;
280
+ function CreatePathInfoBox (const Caption, Path: string;
281
+ const TabOrder: Integer): TPathInfoBox;
249
282
{ Creates and initialises a custom path information control.
250
283
@param Caption [in] Group box caption.
251
284
@param Path [in] Path to be displayed.
285
+ @param TabOrder [in] Tab order of info box.
252
286
@return New control.
253
287
}
254
288
begin
@@ -257,6 +291,7 @@ procedure TAboutDlg.ConfigForm;
257
291
Result.SetBounds(8 , 8 , tsPaths.ClientWidth - 16 , 0 );
258
292
Result.Caption := Caption;
259
293
Result.Path := Path;
294
+ Result.TabOrder := TabOrder;
260
295
end ;
261
296
262
297
resourcestring
@@ -268,14 +303,16 @@ procedure TAboutDlg.ConfigForm;
268
303
inherited ;
269
304
// Creates required custom controls
270
305
fInstallPathGp := CreatePathInfoBox(
271
- sInstallPathGpCaption, TAppInfo.AppExeDir
306
+ sInstallPathGpCaption, TAppInfo.AppExeDir, 0
272
307
);
273
308
fMainDBPathGp := CreatePathInfoBox(
274
- sMainDBPathGpCaption, TAppInfo.AppDataDir
309
+ sMainDBPathGpCaption, TAppInfo.AppDataDir, 1
275
310
);
276
311
fUserDBPathGp := CreatePathInfoBox(
277
- sUserDBPathGpCaption, TAppInfo.UserDataDir
312
+ sUserDBPathGpCaption, TAppInfo.UserDataDir, 2
278
313
);
314
+ btnViewAppConfig.TabOrder := fUserDBPathGp.TabOrder + 1 ;
315
+ btnViewUserConfig.TabOrder := btnViewAppConfig.TabOrder + 1 ;
279
316
// Load content into HTML frames
280
317
InitHTMLFrames;
281
318
end ;
@@ -551,6 +588,24 @@ procedure TAboutDlg.UpdateTitleCSS(Sender: TObject;
551
588
end ;
552
589
end ;
553
590
591
+ procedure TAboutDlg.ViewConfigFile (const FileName, DlgTitle: string);
592
+ var
593
+ Data: TEncodedData;
594
+ resourcestring
595
+ sErrorMsg = ' Sorry, this config file does not (yet) exist.' ;
596
+ begin
597
+ if not TFile.Exists(FileName) then
598
+ begin
599
+ TMessageBox.Error(Self, sErrorMsg);
600
+ Exit;
601
+ end ;
602
+ Data := TEncodedData.Create(
603
+ TFileIO.ReadAllText(FileName, TEncoding.Unicode, True),
604
+ etUTF16LE
605
+ );
606
+ TPreviewDlg.Execute(Self, Data, dtPlainText, DlgTitle);
607
+ end ;
608
+
554
609
{ TPathInfoBox }
555
610
556
611
procedure TPathInfoBox.BtnClick (Sender: TObject);
0 commit comments