LazStats: Add path to LHelp to Options.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7609 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2020-08-17 14:51:27 +00:00
parent 3a8e6c0071
commit 893acb17cb
10 changed files with 115 additions and 84 deletions

Binary file not shown.

View File

@@ -0,0 +1,4 @@
{$IFDEF MSWINDOWS}
{$DEFINE USE_EXTERNAL_HELP_VIEWER}
{$ENDIF}

View File

@@ -43,7 +43,7 @@
<PackageName Value="LCL"/> <PackageName Value="LCL"/>
</Item5> </Item5>
</RequiredPackages> </RequiredPackages>
<Units Count="170"> <Units Count="171">
<Unit0> <Unit0>
<Filename Value="LazStats.lpr"/> <Filename Value="LazStats.lpr"/>
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
@@ -1382,6 +1382,10 @@
<IsPartOfProject Value="True"/> <IsPartOfProject Value="True"/>
<UnitName Value="Utils"/> <UnitName Value="Utils"/>
</Unit169> </Unit169>
<Unit170>
<Filename Value="LazStats.inc"/>
<IsPartOfProject Value="True"/>
</Unit170>
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>

View File

@@ -7,9 +7,7 @@ unit MainUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{$IFDEF MSWINDOWS} {$include ../LazStats.inc}
{$DEFINE USE_EXTERNAL_HELP_VIEWER}
{$ENDIF}
interface interface
@@ -1306,7 +1304,9 @@ begin
{$IFDEF USE_EXTERNAL_HELP_VIEWER} {$IFDEF USE_EXTERNAL_HELP_VIEWER}
Application.OnHelp := @HelpHandler; Application.OnHelp := @HelpHandler;
{$ELSE} {$ELSE}
lhelpfn := Application.Location + 'LHelp.exe'; lhelpfn := Options.LHelpPath;
if lhelpfn = '<default>' then
lhelpfn := Application.Location + 'lhelp' + GetExeExt;
if FileExists(lhelpfn) then if FileExists(lhelpfn) then
begin begin
Maindatamodule.LHelpConnector.LHelpPath := lhelpfn; Maindatamodule.LHelpConnector.LHelpPath := lhelpfn;

View File

@@ -1,12 +1,12 @@
object OptionsFrm: TOptionsFrm object OptionsFrm: TOptionsFrm
Left = 510 Left = 510
Height = 320 Height = 364
Top = 266 Top = 266
Width = 352 Width = 349
AutoSize = True AutoSize = True
Caption = 'Options' Caption = 'Options'
ClientHeight = 320 ClientHeight = 364
ClientWidth = 352 ClientWidth = 349
OnActivate = FormActivate OnActivate = FormActivate
OnShow = FormShow OnShow = FormShow
Position = poMainFormCenter Position = poMainFormCenter
@@ -32,7 +32,7 @@ object OptionsFrm: TOptionsFrm
Left = 8 Left = 8
Height = 72 Height = 72
Top = 8 Top = 8
Width = 336 Width = 333
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
@@ -50,7 +50,7 @@ object OptionsFrm: TOptionsFrm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 1 ChildSizing.ControlsPerLine = 1
ClientHeight = 52 ClientHeight = 52
ClientWidth = 332 ClientWidth = 329
ItemIndex = 0 ItemIndex = 0
Items.Strings = ( Items.Strings = (
'English (default) period separator' 'English (default) period separator'
@@ -67,7 +67,7 @@ object OptionsFrm: TOptionsFrm
Left = 8 Left = 8
Height = 51 Height = 51
Top = 92 Top = 92
Width = 336 Width = 333
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
@@ -85,7 +85,7 @@ object OptionsFrm: TOptionsFrm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 4 ChildSizing.ControlsPerLine = 4
ClientHeight = 31 ClientHeight = 31
ClientWidth = 332 ClientWidth = 329
Columns = 4 Columns = 4
ItemIndex = 3 ItemIndex = 3
Items.Strings = ( Items.Strings = (
@@ -105,7 +105,7 @@ object OptionsFrm: TOptionsFrm
Left = 8 Left = 8
Height = 51 Height = 51
Top = 155 Top = 155
Width = 336 Width = 333
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
AutoFill = True AutoFill = True
AutoSize = True AutoSize = True
@@ -123,7 +123,7 @@ object OptionsFrm: TOptionsFrm
ChildSizing.Layout = cclLeftToRightThenTopToBottom ChildSizing.Layout = cclLeftToRightThenTopToBottom
ChildSizing.ControlsPerLine = 3 ChildSizing.ControlsPerLine = 3
ClientHeight = 31 ClientHeight = 31
ClientWidth = 332 ClientWidth = 329
Columns = 3 Columns = 3
ItemIndex = 2 ItemIndex = 2
Items.Strings = ( Items.Strings = (
@@ -133,28 +133,12 @@ object OptionsFrm: TOptionsFrm
) )
TabOrder = 2 TabOrder = 2
end end
object FilePathEdit: TEdit
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 23
Top = 235
Width = 336
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
TabOrder = 3
end
object CancelBtn: TButton object CancelBtn: TButton
AnchorSideTop.Control = HelpBtn AnchorSideTop.Control = HelpBtn
AnchorSideRight.Control = SaveBtn AnchorSideRight.Control = SaveBtn
Left = 169 Left = 166
Height = 25 Height = 25
Top = 281 Top = 329
Width = 62 Width = 62
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
@@ -164,16 +148,15 @@ object OptionsFrm: TOptionsFrm
Caption = 'Cancel' Caption = 'Cancel'
ModalResult = 2 ModalResult = 2
OnClick = CancelBtnClick OnClick = CancelBtnClick
TabOrder = 4 TabOrder = 3
end end
object SaveBtn: TButton object SaveBtn: TButton
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = HelpBtn AnchorSideTop.Control = HelpBtn
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 239 Left = 236
Height = 25 Height = 25
Top = 281 Top = 329
Width = 105 Width = 105
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
@@ -182,32 +165,16 @@ object OptionsFrm: TOptionsFrm
Caption = 'Save and Close' Caption = 'Save and Close'
ModalResult = 1 ModalResult = 1
OnClick = SaveBtnClick OnClick = SaveBtnClick
TabOrder = 5 TabOrder = 4
end
object BrowseBtn: TButton
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = HelpBtn
AnchorSideRight.Control = CancelBtn
Left = 88
Height = 25
Top = 281
Width = 73
Anchors = [akTop, akRight]
AutoSize = True
BorderSpacing.Right = 8
BorderSpacing.Bottom = 8
Caption = 'Browse...'
OnClick = BrowseBtnClick
TabOrder = 6
end end
object HelpBtn: TButton object HelpBtn: TButton
Tag = 135 Tag = 135
AnchorSideTop.Control = Bevel1 AnchorSideTop.Control = Bevel1
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = BrowseBtn AnchorSideRight.Control = CancelBtn
Left = 29 Left = 107
Height = 25 Height = 25
Top = 281 Top = 329
Width = 51 Width = 51
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
AutoSize = True AutoSize = True
@@ -217,24 +184,73 @@ object OptionsFrm: TOptionsFrm
BorderSpacing.Bottom = 8 BorderSpacing.Bottom = 8
Caption = 'Help' Caption = 'Help'
OnClick = HelpBtnClick OnClick = HelpBtnClick
TabOrder = 7 TabOrder = 5
end end
object Bevel1: TBevel object Bevel1: TBevel
AnchorSideLeft.Control = Owner AnchorSideLeft.Control = Owner
AnchorSideTop.Control = FilePathEdit AnchorSideTop.Control = LHelpPathEdit
AnchorSideTop.Side = asrBottom AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom AnchorSideRight.Side = asrBottom
Left = 0 Left = 0
Height = 3 Height = 3
Top = 270 Top = 318
Width = 352 Width = 349
Anchors = [akTop, akLeft, akRight] Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 12 BorderSpacing.Top = 12
Shape = bsBottomLine Shape = bsBottomLine
end end
object SelDir: TSelectDirectoryDialog object Label2: TLabel
left = 184 AnchorSideLeft.Control = LHelpPathEdit
top = 184 AnchorSideTop.Control = FilePathEdit
AnchorSideTop.Side = asrBottom
Left = 8
Height = 15
Top = 266
Width = 149
BorderSpacing.Top = 8
Caption = 'Path to help viewer (LHelp):'
ParentColor = False
end
object LHelpPathEdit: TFileNameEdit
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label2
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 23
Top = 283
Width = 333
FilterIndex = 0
HideDirectories = False
ButtonWidth = 23
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
MaxLength = 0
TabOrder = 6
end
object FilePathEdit: TDirectoryEdit
AnchorSideLeft.Control = Owner
AnchorSideTop.Control = Label1
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = Owner
AnchorSideRight.Side = asrBottom
Left = 8
Height = 23
Top = 235
Width = 333
ShowHidden = False
ButtonWidth = 23
NumGlyphs = 1
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 8
BorderSpacing.Top = 2
BorderSpacing.Right = 8
MaxLength = 0
TabOrder = 7
end end
end end

View File

@@ -1,12 +1,13 @@
unit OptionsUnit; unit OptionsUnit;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
{$include ../../LazStats.inc}
interface interface
uses uses
Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs, Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, Dialogs,
StdCtrls, ExtCtrls, Clipbrd, StdCtrls, ExtCtrls, Clipbrd, EditBtn,
Globals, ContextHelpUnit; Globals, ContextHelpUnit;
type type
@@ -15,17 +16,16 @@ type
TOptionsFrm = class(TForm) TOptionsFrm = class(TForm)
Bevel1: TBevel; Bevel1: TBevel;
BrowseBtn: TButton;
CancelBtn: TButton; CancelBtn: TButton;
FilePathEdit: TDirectoryEdit;
LHelpPathEdit: TFileNameEdit;
HelpBtn: TButton; HelpBtn: TButton;
Label2: TLabel;
SaveBtn: TButton; SaveBtn: TButton;
FilePathEdit: TEdit;
Label1: TLabel; Label1: TLabel;
FractionTypeGrp: TRadioGroup; FractionTypeGrp: TRadioGroup;
MissValsGrp: TRadioGroup; MissValsGrp: TRadioGroup;
JustificationGrp: TRadioGroup; JustificationGrp: TRadioGroup;
SelDir: TSelectDirectoryDialog;
procedure BrowseBtnClick(Sender: TObject);
procedure CancelBtnClick(Sender: TObject); procedure CancelBtnClick(Sender: TObject);
procedure FormActivate(Sender: TObject); procedure FormActivate(Sender: TObject);
procedure FormShow(Sender: TObject); procedure FormShow(Sender: TObject);
@@ -97,6 +97,10 @@ begin
else else
Options.Defaultpath := pathname; Options.Defaultpath := pathname;
// LHelp path
Readln(F, pathName);
Options.LHelpPath := pathname;
Close(F); Close(F);
end; end;
@@ -119,9 +123,8 @@ begin
WriteLn(F, ord(Options.DefaultMiss)); WriteLn(F, ord(Options.DefaultMiss));
WriteLn(F, ord(Options.DefaultJust)); WriteLn(F, ord(Options.DefaultJust));
WriteLn(F, Options.DefaultPath); WriteLn(F, Options.DefaultPath);
WriteLn(F, Options.LHelpPath);
CloseFile(F); CloseFile(F);
DefaultFormatSettings.DecimalSeparator := FractionTypeChars[Options.FractionType];
end; end;
@@ -136,6 +139,10 @@ begin
AOptions.DefaultPath := OpenStatPath AOptions.DefaultPath := OpenStatPath
else else
AOptions.DefaultPath := FilePathEdit.Text; AOptions.DefaultPath := FilePathEdit.Text;
if LHElpPathEdit.FileName = Application.Location + 'lhelp' + GetExeExt then
AOptions.LHelpPath := '<default>'
else
AOptions.LHelpPath := LHelpPathEdit.FileName;
end; end;
procedure TOptionsFrm.OptionsToControls(const AOptions: TOptions); procedure TOptionsFrm.OptionsToControls(const AOptions: TOptions);
@@ -147,6 +154,10 @@ begin
FilePathEdit.Text := OpenStatPath FilePathEdit.Text := OpenStatPath
else else
FilePathEdit.Text := AOptions.DefaultPath; FilePathEdit.Text := AOptions.DefaultPath;
if AOptions.LHelpPath = '<default>' then
LHelpPathEdit.FileName := Application.Location + 'lhelp' + GetExeExt
else
LHelpPathEdit.FileName := AOptions.LHelpPath;
end; end;
procedure TOptionsFrm.FormActivate(Sender: TObject); procedure TOptionsFrm.FormActivate(Sender: TObject);
@@ -156,9 +167,13 @@ begin
if FAutoSized then if FAutoSized then
exit; exit;
w := MaxValue([HelpBtn.Width, BrowseBtn.Width, SaveBtn.Width, CancelBtn.Width]); {$IFDEF USE_EXTERNAL_HELP_VIEWER}
Label2.Visible := false;
LHelpPathEdit.Visible := false;
{$ENDIF}
w := MaxValue([HelpBtn.Width, SaveBtn.Width, CancelBtn.Width]);
HelpBtn.Constraints.MinWidth := w; HelpBtn.Constraints.MinWidth := w;
BrowseBtn.Constraints.MinWidth := w;
SaveBtn.Constraints.MinWidth := w; SaveBtn.Constraints.MinWidth := w;
CancelBtn.Constraints.MinWidth := w; CancelBtn.Constraints.MinWidth := w;
@@ -188,16 +203,6 @@ begin
SaveOptions; SaveOptions;
end; end;
procedure TOptionsFrm.BrowseBtnClick(Sender: TObject);
begin
with SelDir do
begin
InitialDir := FilePathEdit.Text;
if Execute then
FilePathEdit.text := FileName;
end;
end;
procedure TOptionsFrm.CancelBtnClick(Sender: TObject); procedure TOptionsFrm.CancelBtnClick(Sender: TObject);
begin begin
Options := FSavedOptions; Options := FSavedOptions;

View File

@@ -51,6 +51,7 @@ type
FractionType: TFractionType; FractionType: TFractionType;
DefaultMiss: TMissingValueCode; DefaultMiss: TMissingValueCode;
DefaultJust: TJustification; DefaultJust: TJustification;
LHelpPath: String;
end; end;
var var
@@ -70,7 +71,8 @@ var
DefaultPath: ''; DefaultPath: '';
FractionType: ftPoint; FractionType: ftPoint;
DefaultMiss: mvcNines; DefaultMiss: mvcNines;
DefaultJust: jLeft DefaultJust: jLeft;
LHelpPath: '<default>';
); );