From f15c953b8b5abec13a7b615f5705ad406dbbdace Mon Sep 17 00:00:00 2001 From: Graeme Geldenhuys Date: Tue, 24 Aug 2010 13:27:37 +0200 Subject: docview: new configuration option: open docview help on startup. --- docview/src/frm_configuration.pas | 26 ++++++++++++++++++++++++++ docview/src/frm_main.pas | 16 ++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/docview/src/frm_configuration.pas b/docview/src/frm_configuration.pas index 2e19939b..e69226fb 100644 --- a/docview/src/frm_configuration.pas +++ b/docview/src/frm_configuration.pas @@ -33,6 +33,7 @@ type lbSearchDirs: TfpgListBox; btnSearchDirDelete: TfpgButton; chkEscapeIPFSymbols: TfpgCheckBox; + chkStartupHelp: TfpgCheckBox; {@VFD_HEAD_END: ConfigurationForm} procedure btnNormalFontClicked(Sender: TObject); procedure btnFixedFontClicked(Sender: TObject); @@ -143,6 +144,7 @@ begin cbIndexStyle.FocusItem := Ord(Settings.IndexStyle); lbSearchDirs.Items.Assign(Settings.SearchDirectories); chkEscapeIPFSymbols.Checked := Settings.IPFTopicSaveAsEscaped; + chkStartupHelp.Checked := Settings.StartupHelp; // Fonts & Color edtNormalFont.Text := Settings.NormalFont.FontDesc; edtFixedFont.Text := Settings.FixedFont.FontDesc; @@ -154,6 +156,7 @@ begin Settings.IndexStyle := TIndexStyle(cbIndexStyle.FocusItem); Settings.SearchDirectories.Assign(lbSearchDirs.Items); Settings.IPFTopicSaveAsEscaped := chkEscapeIPFSymbols.Checked; + Settings.StartupHelp := chkStartupHelp.Checked; // Fonts & Color Settings.NormalFont.Free; Settings.NormalFont := fpgGetFont(edtNormalFont.Text); @@ -174,6 +177,7 @@ begin Name := 'ConfigurationForm'; SetPosition(310, 157, 515, 439); WindowTitle := 'Configuration'; + Hint := ''; WindowPosition := wpOneThirdDown; PageControl1 := TfpgPageControl.Create(self); @@ -183,6 +187,7 @@ begin SetPosition(4, 4, 506, 388); Anchors := [anLeft,anRight,anTop,anBottom]; ActivePageIndex := 0; + Hint := ''; TabOrder := 0; OnChange := @PageControl1Change; end; @@ -245,6 +250,8 @@ begin Name := 'edtNormalFont'; SetPosition(124, 16, 248, 24); Anchors := [anLeft,anRight,anTop]; + ExtraHint := ''; + Hint := ''; TabOrder := 1; Text := ''; FontDesc := '#Edit1'; @@ -280,6 +287,8 @@ begin Name := 'edtFixedFont'; SetPosition(124, 48, 248, 24); Anchors := [anLeft,anRight,anTop]; + ExtraHint := ''; + Hint := ''; TabOrder := 4; Text := ''; FontDesc := '#Edit1'; @@ -320,6 +329,7 @@ begin Name := 'Panel1'; SetPosition(128, 116, 204, 28); FontDesc := '#Label1'; + Hint := ''; Style := bsLowered; Text := 'Panel'; end; @@ -330,6 +340,7 @@ begin Name := 'cbIndexStyle'; SetPosition(12, 32, 160, 22); FontDesc := '#List'; + Hint := ''; Items.Add('Alphabetical'); Items.Add('FileOnly'); Items.Add('Full'); @@ -375,6 +386,7 @@ begin Name := 'lbSearchDirs'; SetPosition(12, 84, 388, 148); FontDesc := '#List'; + Hint := ''; HotTrack := False; PopupFrame := False; TabOrder := 5; @@ -400,10 +412,24 @@ begin SetPosition(12, 244, 480, 20); Anchors := [anLeft,anRight,anTop]; FontDesc := '#Label1'; + Hint := ''; TabOrder := 6; Text := 'Escape symbols when saving topics as IPF text'; end; + chkStartupHelp := TfpgCheckBox.Create(tsGeneral); + with chkStartupHelp do + begin + Name := 'chkStartupHelp'; + SetPosition(12, 264, 480, 20); + Anchors := [anLeft,anRight,anTop]; + Checked := True; + FontDesc := '#Label1'; + Hint := ''; + TabOrder := 8; + Text := 'Show DocView help at startup if no files opened'; + end; + {@VFD_BODY_END: ConfigurationForm} {%endregion} end; diff --git a/docview/src/frm_main.pas b/docview/src/frm_main.pas index 814556ef..ae89331b 100644 --- a/docview/src/frm_main.pas +++ b/docview/src/frm_main.pas @@ -337,6 +337,8 @@ begin end; procedure TMainForm.MainFormShow(Sender: TObject); +var + lFilename: TfpgString; begin bvlBody.Realign; @@ -355,6 +357,20 @@ begin ProcessCommandLineParams; RichView.Images := FImages; + + if ParamCount = 0 then + begin + // user hasn't requested any particular file + // at startup, so if the option is still set, + // load the DocView help file + if Settings.StartupHelp then + begin + lFilename := GetOwnHelpFileName; + if FileExists(lFilename) then + OpenFile(lFilename, '', true); + end; + end; + end; procedure TMainForm.MainFormDestroy(Sender: TObject); -- cgit v1.2.3-70-g09d2