33 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
44 * obtain one at http://mozilla.org/MPL/2.0/
55 *
6- * Copyright (C) 2005-2014 , Peter Johnson (www.delphidabbler.com).
6+ * Copyright (C) 2005-2016 , Peter Johnson (www.delphidabbler.com).
77 *
88 * $Rev$
99 * $Date$
@@ -89,6 +89,8 @@ TAboutDlg = class(TGenericViewDlg)
8989 pnlTitle: TPanel;
9090 frmTitle: THTMLTpltDlgFrame;
9191 tsPaths: TTabSheet;
92+ btnViewAppConfig: TButton;
93+ btnViewUserConfig: TButton;
9294 procedure btnRegisterClick (Sender: TObject);
9395 procedure FormCreate (Sender: TObject);
9496 procedure FormDestroy (Sender: TObject);
@@ -98,6 +100,8 @@ TAboutDlg = class(TGenericViewDlg)
98100 // / a tab is clicked.</remarks>
99101 procedure pcDetailMouseDown (Sender: TObject; Button: TMouseButton;
100102 Shift: TShiftState; X, Y: Integer);
103+ procedure btnViewAppConfigClick (Sender: TObject);
104+ procedure btnViewUserConfigClick (Sender: TObject);
101105 strict private
102106 fMainDBPathGp: TPathInfoBox; // control that displays main database folder
103107 fUserDBPathGp: TPathInfoBox; // control that displays user database folder
@@ -120,6 +124,12 @@ TAboutDlg = class(TGenericViewDlg)
120124 determines names that are displayed.
121125 @return Required HTML.
122126 }
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+ }
123133 strict protected
124134 procedure ConfigForm ; override;
125135 { Configures form by creating custom controls and initialising HTML frames.
@@ -162,9 +172,9 @@ implementation
162172 // Delphi
163173 SysUtils, Graphics, Math, Windows, ShellAPI, IOUtils,
164174 // 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;
168178
169179
170180{
@@ -215,7 +225,15 @@ procedure TAboutDlg.ArrangeForm;
215225begin
216226 fMainDBPathGp.Top := TCtrlArranger.BottomOf(fInstallPathGp, 8 );
217227 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]);
219237 // Set height of title frame and page control
220238 pnlTitle.Height := frmTitle.DocHeight;
221239 pcDetail.ClientHeight :=
@@ -240,15 +258,31 @@ procedure TAboutDlg.btnRegisterClick(Sender: TObject);
240258 btnRegister.Hide; // hide registration button now that program registered OK
241259end ;
242260
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+
243275procedure TAboutDlg.ConfigForm ;
244276 { Configures form by creating custom controls and initialising HTML frames.
245277 Called from ancestor class.
246278 }
247279
248- function CreatePathInfoBox (const Caption, Path: string): TPathInfoBox;
280+ function CreatePathInfoBox (const Caption, Path: string;
281+ const TabOrder: Integer): TPathInfoBox;
249282 { Creates and initialises a custom path information control.
250283 @param Caption [in] Group box caption.
251284 @param Path [in] Path to be displayed.
285+ @param TabOrder [in] Tab order of info box.
252286 @return New control.
253287 }
254288 begin
@@ -257,6 +291,7 @@ procedure TAboutDlg.ConfigForm;
257291 Result.SetBounds(8 , 8 , tsPaths.ClientWidth - 16 , 0 );
258292 Result.Caption := Caption;
259293 Result.Path := Path;
294+ Result.TabOrder := TabOrder;
260295 end ;
261296
262297resourcestring
@@ -268,14 +303,16 @@ procedure TAboutDlg.ConfigForm;
268303 inherited ;
269304 // Creates required custom controls
270305 fInstallPathGp := CreatePathInfoBox(
271- sInstallPathGpCaption, TAppInfo.AppExeDir
306+ sInstallPathGpCaption, TAppInfo.AppExeDir, 0
272307 );
273308 fMainDBPathGp := CreatePathInfoBox(
274- sMainDBPathGpCaption, TAppInfo.AppDataDir
309+ sMainDBPathGpCaption, TAppInfo.AppDataDir, 1
275310 );
276311 fUserDBPathGp := CreatePathInfoBox(
277- sUserDBPathGpCaption, TAppInfo.UserDataDir
312+ sUserDBPathGpCaption, TAppInfo.UserDataDir, 2
278313 );
314+ btnViewAppConfig.TabOrder := fUserDBPathGp.TabOrder + 1 ;
315+ btnViewUserConfig.TabOrder := btnViewAppConfig.TabOrder + 1 ;
279316 // Load content into HTML frames
280317 InitHTMLFrames;
281318end ;
@@ -551,6 +588,24 @@ procedure TAboutDlg.UpdateTitleCSS(Sender: TObject;
551588 end ;
552589end ;
553590
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+
554609{ TPathInfoBox }
555610
556611procedure TPathInfoBox.BtnClick (Sender: TObject);
0 commit comments