diff --git a/.gitattributes b/.gitattributes index 8b8148918d..078fafd76d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5502,6 +5502,8 @@ packager/confirmpkglistdlg.lfm svneol=native#text/plain packager/confirmpkglistdlg.pas svneol=native#text/plain packager/frames/package_description_options.lfm svneol=native#text/plain packager/frames/package_description_options.pas svneol=native#text/pascal +packager/frames/package_integration_options.lfm svneol=native#text/plain +packager/frames/package_integration_options.pas svneol=native#text/pascal packager/frames/package_usage_options.lfm svneol=native#text/plain packager/frames/package_usage_options.pas svneol=native#text/pascal packager/globallinks/README.txt svneol=native#text/plain diff --git a/ide/lazarus.lpi b/ide/lazarus.lpi index 33a5ee64f7..b6709c4f32 100644 --- a/ide/lazarus.lpi +++ b/ide/lazarus.lpi @@ -59,7 +59,7 @@ - + @@ -600,6 +600,13 @@ + + + + + + + diff --git a/ide/main.pp b/ide/main.pp index a7a172e87d..9cdb8cbd91 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -131,7 +131,7 @@ uses compiler_other_options, compiler_inherited_options, compiler_compilation_options, BuildModesEditor, // package option frames - package_usage_options, package_description_options, + package_usage_options, package_description_options, package_integration_options, // rest of the ide Splash, IDEDefs, LazarusIDEStrConsts, LazConf, MsgView, SearchResultView, diff --git a/packager/frames/package_integration_options.lfm b/packager/frames/package_integration_options.lfm new file mode 100644 index 0000000000..d401a1db41 --- /dev/null +++ b/packager/frames/package_integration_options.lfm @@ -0,0 +1,101 @@ +inherited PackageIntegrationOptionsFrame: TPackageIntegrationOptionsFrame + Height = 352 + Width = 461 + ClientHeight = 352 + ClientWidth = 461 + TabOrder = 0 + DesignLeft = 517 + DesignTop = 273 + object PkgTypeRadioGroup: TRadioGroup[0] + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = Owner + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 116 + Top = 0 + Width = 461 + Anchors = [akTop, akLeft, akRight] + AutoFill = True + Caption = 'PackageType' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 98 + ClientWidth = 457 + ItemIndex = 2 + Items.Strings = ( + 'Designtime only' + 'Runtime only' + 'Designtime and Runtime' + ) + OnClick = PkgTypeRadioGroupClick + TabOrder = 0 + end + object UpdateRadioGroup: TRadioGroup[1] + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = PkgTypeRadioGroup + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 116 + Top = 122 + Width = 461 + Anchors = [akTop, akLeft, akRight] + AutoFill = True + BorderSpacing.Top = 6 + Caption = 'Update/Rebuild' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.EnlargeHorizontal = crsHomogenousChildResize + ChildSizing.EnlargeVertical = crsHomogenousChildResize + ChildSizing.ShrinkHorizontal = crsScaleChilds + ChildSizing.ShrinkVertical = crsScaleChilds + ChildSizing.Layout = cclLeftToRightThenTopToBottom + ChildSizing.ControlsPerLine = 1 + ClientHeight = 98 + ClientWidth = 457 + ItemIndex = 0 + Items.Strings = ( + 'Automatically rebuild as needed' + 'Auto rebuild when rebuilding all' + 'Manual compilation (never automatically)' + ) + TabOrder = 1 + end + object LazDocGroupBox: TGroupBox[2] + AnchorSideLeft.Control = Owner + AnchorSideTop.Control = UpdateRadioGroup + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 0 + Height = 53 + Top = 244 + Width = 461 + Anchors = [akTop, akLeft, akRight] + AutoSize = True + BorderSpacing.Top = 6 + Caption = 'LazDoc - Lazarus documentation' + ClientHeight = 35 + ClientWidth = 457 + TabOrder = 2 + object LazDocPathEdit: TEdit + AnchorSideLeft.Control = LazDocGroupBox + AnchorSideTop.Control = LazDocGroupBox + Left = 6 + Height = 23 + Top = 6 + Width = 365 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Around = 6 + TabOrder = 0 + end + end +end diff --git a/packager/frames/package_integration_options.pas b/packager/frames/package_integration_options.pas new file mode 100644 index 0000000000..f2e6eee9b9 --- /dev/null +++ b/packager/frames/package_integration_options.pas @@ -0,0 +1,234 @@ +unit package_integration_options; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, FileUtil, Forms, Controls, ExtCtrls, StdCtrls, Dialogs, + IDEOptionsIntf, MacroIntf, + LazarusIDEStrConsts, PackageDefs, PathEditorDlg, IDEProcs; + +type + + { TPackageIntegrationOptionsFrame } + + TPackageIntegrationOptionsFrame = class(TAbstractIDEOptionsEditor) + LazDocGroupBox: TGroupBox; + LazDocPathEdit: TEdit; + PkgTypeRadioGroup: TRadioGroup; + UpdateRadioGroup: TRadioGroup; + procedure PkgTypeRadioGroupClick(Sender: TObject); + private + FLazPackage: TLazPackage; + LazDocPathButton: TPathEditorButton; + FStoredPkgType: Integer; + procedure PathEditBtnClick(Sender: TObject); + procedure PathEditBtnExecuted(Sender: TObject); + function ShowMsgPackageTypeMustBeDesign: boolean; + public + function Check: Boolean; override; + function GetTitle: string; override; + procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; + procedure ReadSettings(AOptions: TAbstractIDEOptions); override; + procedure WriteSettings(AOptions: TAbstractIDEOptions); override; + class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; + end; + +implementation + +{$R *.lfm} + +{ TPackageIntegrationOptionsFrame } + +procedure TPackageIntegrationOptionsFrame.PkgTypeRadioGroupClick(Sender: TObject); +begin + if (PkgTypeRadioGroup.ItemIndex = 1) and (FLazPackage.PackageType <> lptRunTime) then + begin + // user sets to runtime only + if (FLazPackage.AutoInstall <> pitNope) then + ShowMsgPackageTypeMustBeDesign; + end; +end; + +procedure TPackageIntegrationOptionsFrame.PathEditBtnClick(Sender: TObject); +var + AButton: TPathEditorButton absolute Sender; +begin + AButton.CurrentPathEditor.Path := LazDocPathEdit.Text; + AButton.CurrentPathEditor.Templates := ''; +end; + +procedure TPackageIntegrationOptionsFrame.PathEditBtnExecuted(Sender: TObject); +var + AButton: TPathEditorButton absolute Sender; + NewPath: string; + OldPath: string; + CurDir: string; + StartPos: integer; + DlgResult: TModalResult; + OldStartPos: longint; +begin + if AButton.CurrentPathEditor.ModalResult <> mrOk then + Exit; + NewPath := AButton.CurrentPathEditor.Path; + OldPath := LazDocPathEdit.Text; + if OldPath <> NewPath then + begin + // check NewPath + StartPos := 1; + repeat + OldStartPos := StartPos; + CurDir := GetNextDirectoryInSearchPath(NewPath, StartPos); + if CurDir <> '' then + begin + IDEMacros.SubstituteMacros(CurDir); + FLazPackage.LongenFilename(CurDir); + if not DirPathExists(CurDir) then + begin + DlgResult := QuestionDlg(lisEnvOptDlgDirectoryNotFound, + Format(lisDirectoryNotFound, ['"', CurDir, '"']), + mtError, [mrIgnore, mrYes, lisRemoveFromSearchPath, mrCancel], 0); + case DlgResult of + mrIgnore: ; + mrYes: + begin + // remove directory from search path + NewPath := copy(NewPath, 1, OldStartPos - 1) + + copy(NewPath, StartPos, length(NewPath)); + StartPos := OldStartPos; + end; + else + // undo + NewPath := OldPath; + break; + end; + end; + end; + until StartPos > length(NewPath); + end; + LazDocPathEdit.Text := NewPath; +end; + +function TPackageIntegrationOptionsFrame.GetTitle: string; +begin + Result := lisPckOptsIDEIntegration; +end; + +procedure TPackageIntegrationOptionsFrame.Setup(ADialog: TAbstractOptionsEditorDialog); +begin + PkgTypeRadioGroup.Caption := lisPckOptsPackageType; + PkgTypeRadioGroup.Items[0] := lisPckOptsDesigntimeOnly; + PkgTypeRadioGroup.Items[1] := lisPckOptsRuntimeOnly; + PkgTypeRadioGroup.Items[2] := lisPckOptsDesigntimeAndRuntime; + UpdateRadioGroup.Caption := lisPckOptsUpdateRebuild; + UpdateRadioGroup.Items[0] := lisPckOptsAutomaticallyRebuildAsNeeded; + UpdateRadioGroup.Items[1] := lisPckOptsAutoRebuildWhenRebuildingAll; + UpdateRadioGroup.Items[2] := lisPckOptsManualCompilationNeverAutomatically; + LazDocGroupBox.Caption := lisPckOptsLazDocLazarusDocumentation; + + LazDocPathButton := TPathEditorButton.Create(Self); + with LazDocPathButton do + begin + Name := 'LazDocPathButton'; + Caption := '...'; + AutoSize := True; + Anchors := [akRight]; + AnchorParallel(akRight, 6, LazDocGroupBox); + AnchorParallel(akTop, 0, LazDocPathEdit); + AnchorParallel(akBottom, 0, LazDocPathEdit); + OnClick := @PathEditBtnClick; + OnExecuted := @PathEditBtnExecuted; + Parent := LazDocGroupBox; + end; + LazDocPathEdit.AnchorToNeighbour(akRight, 0, LazDocPathButton); +end; + +procedure TPackageIntegrationOptionsFrame.ReadSettings(AOptions: TAbstractIDEOptions); +var + LazPackage: TLazPackage absolute AOptions; +begin + FLazPackage := LazPackage; + case LazPackage.PackageType of + lptDesignTime: PkgTypeRadioGroup.ItemIndex := 0; + lptRunTime: PkgTypeRadioGroup.ItemIndex := 1; + else + PkgTypeRadioGroup.ItemIndex := 2; + end; + FStoredPkgType := PkgTypeRadioGroup.ItemIndex; + case LazPackage.AutoUpdate of + pupAsNeeded: UpdateRadioGroup.ItemIndex := 0; + pupOnRebuildingAll: UpdateRadioGroup.ItemIndex := 1; + else + UpdateRadioGroup.ItemIndex := 2; + end; + LazDocPathEdit.Text := LazPackage.LazDocPaths; +end; + +function TPackageIntegrationOptionsFrame.ShowMsgPackageTypeMustBeDesign: boolean; +begin + if MessageDlg(lisPckOptsInvalidPackageType, + Format(lisPckOptsThePackageHasTheAutoInstallFlagThisMeans, + ['"', FLazPackage.IDAsString, '"', #13, #13]), mtWarning, + [mbIgnore, mbCancel], 0) <> mrIgnore then + begin + Result := True; + PkgTypeRadioGroup.ItemIndex := FStoredPkgType; + end + else + Result := False; +end; + +function TPackageIntegrationOptionsFrame.Check: Boolean; +var + NewPackageType: TLazPackageType; +begin + case PkgTypeRadioGroup.ItemIndex of + 0: NewPackageType := lptDesignTime; + 1: NewPackageType := lptRunTime; + else + NewPackageType := lptRunAndDesignTime; + end; + if NewPackageType <> FLazPackage.PackageType then + begin + if (NewPackageType = lptRunTime) and (FLazPackage.AutoInstall <> pitNope) then + begin + if ShowMsgPackageTypeMustBeDesign then + Exit(False); + end; + end; + Result := True; +end; + +procedure TPackageIntegrationOptionsFrame.WriteSettings(AOptions: TAbstractIDEOptions); +var + LazPackage: TLazPackage absolute AOptions; + NewPackageType: TLazPackageType; +begin + case PkgTypeRadioGroup.ItemIndex of + 0: NewPackageType := lptDesignTime; + 1: NewPackageType := lptRunTime; + else + NewPackageType := lptRunAndDesignTime; + end; + LazPackage.PackageType := NewPackageType; + case UpdateRadioGroup.ItemIndex of + 2: LazPackage.AutoUpdate := pupManually; + 1: LazPackage.AutoUpdate := pupOnRebuildingAll; + else + LazPackage.AutoUpdate := pupAsNeeded; + end; + + LazPackage.LazDocPaths := LazDocPathEdit.Text; +end; + +class function TPackageIntegrationOptionsFrame.SupportedOptionsClass: TAbstractIDEOptionsClass; +begin + Result := TLazPackage; +end; + +initialization + RegisterIDEOptionsEditor(GroupPackage, TPackageIntegrationOptionsFrame, + PackageOptionsIntegration); +end. +