IDE, Project: Add config for NSPrincipalClass (MacOS)

git-svn-id: trunk@64837 -
This commit is contained in:
martin 2021-03-19 20:28:42 +00:00
parent 692175a06d
commit 1f29891c35
8 changed files with 95 additions and 35 deletions

View File

@ -491,6 +491,7 @@ type
FCustomSessionData: TStringToStringTree;
FExecutableType: TProjectExecutableType;
FFPDocPackageName: string;
FNSPrincipalClass: string;
FProjectSessionFile: string;
FScaled: Boolean;
FSessionModified: boolean;
@ -502,6 +503,7 @@ type
procedure SetCleanSourcesFileMask(const AValue: string);
procedure SetFPDocPackageName(AValue: string);
procedure SetFPDocPaths(const AValue: string);
procedure SetNSPrincipalClass(AValue: string);
procedure SetScaled(const AScaled: Boolean);
procedure SetUseAppBundle(AValue: Boolean);
protected
@ -586,6 +588,7 @@ type
property CustomData: TStringToStringTree read FCustomData;
property CustomSessionData: TStringToStringTree read FCustomSessionData;
property UseAppBundle: Boolean read FUseAppBundle write SetUseAppBundle;
property NSPrincipalClass: string read FNSPrincipalClass write SetNSPrincipalClass;
property Resources: TObject read FResources; // TAbstractProjectResources
property UseManifest: boolean read GetUseManifest write SetUseManifest;
property RunParameters: TAbstractRunParamsOptions read FRunParameters;
@ -1404,6 +1407,13 @@ begin
Modified:=true;
end;
procedure TLazProject.SetNSPrincipalClass(AValue: string);
begin
if FNSPrincipalClass = AValue then Exit;
FNSPrincipalClass := AValue;
Modified := True;
end;
procedure TLazProject.SetUseAppBundle(AValue: Boolean);
begin
if FUseAppBundle=AValue then Exit;

View File

@ -35,7 +35,7 @@ interface
uses
Classes, SysUtils, Forms, Controls, Dialogs, FileUtil, LazFileUtils,
DialogProcs;
DialogProcs, Project;
type
EApplicationBundleException = Exception;
@ -44,10 +44,10 @@ type
TApplicationPropertyList = class(TStringList)
public
constructor Create(const ExeName: String; Title: String = ''; const Version: String = '0.1');
constructor Create(const ExeName: String; Title: String = ''; const Version: String = '0.1'; AProject: TProject = nil);
end;
function CreateApplicationBundle(const Filename: String; Title: String = ''; Recreate: boolean = false): TModalResult;
function CreateApplicationBundle(const Filename: String; Title: String = ''; Recreate: boolean = false; AProject: TProject = nil): TModalResult;
function CreateAppBundleSymbolicLink(const {%H-}Filename: String; {%H-}Recreate: boolean = false): TModalResult;
const
@ -63,7 +63,8 @@ implementation
{ TApplicationPropertyList }
constructor TApplicationPropertyList.Create(const ExeName: String; Title: String; const Version: String = '0.1');
constructor TApplicationPropertyList.Create(const ExeName: String;
Title: String; const Version: String; AProject: TProject);
begin
inherited Create;
@ -73,6 +74,10 @@ begin
Add('<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">');
Add('<plist version="1.0">');
Add('<dict>');
if (AProject <> nil) and (AProject.NSPrincipalClass <> '') then begin
Add(' <key>NSPrincipalClass</key>');
Add(' <string>' + AProject.NSPrincipalClass + '</string>');
end;
Add(' <key>CFBundleDevelopmentRegion</key>');
Add(' <string>English</string>');
Add(' <key>CFBundleExecutable</key>');
@ -119,7 +124,7 @@ begin
end;
function CreateApplicationBundle(const Filename: String; Title: String;
Recreate: boolean): TModalResult;
Recreate: boolean; AProject: TProject): TModalResult;
var
AppBundleDir: String;
ContentsDir: String;
@ -137,7 +142,7 @@ begin
if Result<>mrOk then exit;
// create Info.plist file
sl:=TApplicationPropertyList.Create(ExtractFileNameOnly(Filename), Title);
sl:=TApplicationPropertyList.Create(ExtractFileNameOnly(Filename), Title, '0.1', AProject);
Result:=SaveStringListToFile(ContentsDir + PropertyListFileName,'Info.plist part of Application bundle',sl);
sl.Free;
if Result<>mrOk then exit;

View File

@ -1749,7 +1749,7 @@ begin
Exit;
TargetExeName := Project1.CompilerOptions.CreateTargetFilename;
if not (CreateApplicationBundle(TargetExeName, Project1.GetTitle, True) in
if not (CreateApplicationBundle(TargetExeName, Project1.GetTitle, True, Project1) in
[mrOk, mrIgnore]) then
Exit;
if not (CreateAppBundleSymbolicLink(TargetExeName, True) in [mrOk, mrIgnore]) then

View File

@ -1,23 +1,23 @@
object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 0
Height = 563
Height = 585
Top = 0
Width = 487
ClientHeight = 563
ClientHeight = 585
ClientWidth = 487
TabOrder = 0
DesignLeft = 437
DesignTop = 182
object AppSettingsGroupBox: TGroupBox
Left = 0
Height = 541
Height = 567
Top = 0
Width = 487
Align = alTop
Anchors = []
AutoSize = True
Caption = 'AppSettingsGroupBox'
ClientHeight = 521
ClientHeight = 547
ClientWidth = 483
TabOrder = 0
object TitleLabel: TLabel
@ -26,7 +26,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 6
Height = 15
Top = 10
Width = 51
Width = 50
BorderSpacing.Left = 6
Caption = 'TitleLabel'
ParentColor = False
@ -49,7 +49,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 240
Height = 15
Top = 161
Width = 79
Width = 78
BorderSpacing.Top = 8
Caption = 'IconTrackLabel'
ParentColor = False
@ -73,9 +73,10 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 6
Height = 19
Top = 465
Width = 150
Width = 151
BorderSpacing.Top = 3
Caption = 'UseAppBundleCheckBox'
OnChange = UseAppBundleCheckBoxChange
TabOrder = 13
end
object UseXPManifestCheckBox: TCheckBox
@ -85,7 +86,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 6
Height = 19
Top = 254
Width = 151
Width = 152
BorderSpacing.Top = 3
Caption = 'UseXPManifestCheckBox'
OnChange = UseXPManifestCheckBoxChange
@ -143,7 +144,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 27
Height = 19
Top = 328
Width = 119
Width = 120
BorderSpacing.Top = 3
Caption = 'UIAccessCheckBox'
TabOrder = 8
@ -154,10 +155,10 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DpiAwareComboBox
AnchorSideRight.Side = asrBottom
Left = 163
Left = 164
Height = 23
Top = 302
Width = 314
Width = 313
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
ItemHeight = 15
@ -171,7 +172,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 27
Height = 15
Top = 306
Width = 106
Width = 107
Caption = 'ExecutionLevelLabel'
ParentColor = False
end
@ -193,11 +194,11 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
end
object CreateAppBundleButton: TBitBtn
AnchorSideLeft.Control = UseAppBundleCheckBox
AnchorSideTop.Control = UseAppBundleCheckBox
AnchorSideTop.Control = EdNSPrincipalClass
AnchorSideTop.Side = asrBottom
Left = 27
Height = 25
Top = 490
Top = 516
Width = 155
AutoSize = True
BorderSpacing.Left = 21
@ -227,10 +228,10 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
Left = 163
Left = 164
Height = 23
Top = 276
Width = 314
Width = 313
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 30
BorderSpacing.Top = 3
@ -245,7 +246,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 6
Height = 19
Top = 211
Width = 149
Width = 150
Caption = 'UseLCLScalingCheckBox'
TabOrder = 4
end
@ -293,10 +294,10 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DpiAwareComboBox
AnchorSideRight.Side = asrBottom
Left = 163
Left = 164
Height = 23
Top = 392
Width = 314
Width = 313
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
TabOrder = 11
@ -308,10 +309,10 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = DpiAwareComboBox
AnchorSideRight.Side = asrBottom
Left = 163
Left = 164
Height = 23
Top = 418
Width = 314
Width = 313
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Top = 3
TabOrder = 12
@ -324,7 +325,7 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Left = 27
Height = 19
Top = 349
Width = 123
Width = 124
BorderSpacing.Top = 2
Caption = 'LongPathCheckBox'
TabOrder = 9
@ -399,13 +400,42 @@ object ProjectApplicationOptionsFrame: TProjectApplicationOptionsFrame
Caption = 'AnsiUTF8CheckBox'
TabOrder = 10
end
object LblNSPrincipalClass: TLabel
AnchorSideLeft.Control = UseAppBundleCheckBox
AnchorSideTop.Control = EdNSPrincipalClass
AnchorSideTop.Side = asrCenter
Left = 27
Height = 15
Top = 491
Width = 104
BorderSpacing.Left = 21
Caption = 'LblNSPrincipalClass'
ParentColor = False
end
object EdNSPrincipalClass: TEdit
AnchorSideLeft.Control = LblNSPrincipalClass
AnchorSideLeft.Side = asrBottom
AnchorSideTop.Control = UseAppBundleCheckBox
AnchorSideTop.Side = asrBottom
AnchorSideRight.Control = TitleEdit
AnchorSideRight.Side = asrBottom
Left = 161
Height = 23
Top = 487
Width = 316
Anchors = [akTop, akLeft, akRight]
BorderSpacing.Left = 30
BorderSpacing.Top = 3
TabOrder = 15
Text = 'EdNSPrincipalClass'
end
end
object OpenPictureDialog1: TOpenPictureDialog
Left = 385
Top = 190
left = 385
top = 190
end
object SavePictureDialog1: TSavePictureDialog
Left = 385
Top = 249
left = 385
top = 249
end
end

View File

@ -26,6 +26,8 @@ type
TProjectApplicationOptionsFrame = class(TAbstractIDEOptionsEditor)
AppSettingsGroupBox: TGroupBox;
DefaultIconButton: TBitBtn;
LblNSPrincipalClass: TLabel;
EdNSPrincipalClass: TEdit;
LongPathCheckBox: TCheckBox;
DarwinDividerBevel: TDividerBevel;
AnsiUTF8CheckBox: TCheckBox;
@ -63,6 +65,7 @@ type
procedure IconTrackChange(Sender: TObject);
procedure LoadIconButtonClick(Sender: TObject);
procedure SaveIconButtonClick(Sender: TObject);
procedure UseAppBundleCheckBoxChange(Sender: TObject);
procedure UseXPManifestCheckBoxChange(Sender: TObject);
private
FProject: TProject;
@ -107,7 +110,7 @@ begin
else
TargetExeName := AProject.CompilerOptions.CreateTargetFilename;
if not (CreateApplicationBundle(TargetExeName, AProject.GetTitle, True) in
if not (CreateApplicationBundle(TargetExeName, AProject.GetTitle, True, AProject) in
[mrOk, mrIgnore]) then
begin
IDEMessageDialog(lisCCOErrorCaption, Format(
@ -191,6 +194,12 @@ begin
IconImage.Picture.SaveToFile(SavePictureDialog1.FileName);
end;
procedure TProjectApplicationOptionsFrame.UseAppBundleCheckBoxChange(
Sender: TObject);
begin
EdNSPrincipalClass.Enabled := UseAppBundleCheckBox.Checked;
end;
procedure TProjectApplicationOptionsFrame.EnableManifest(aEnable: Boolean);
begin
DpiAwareLabel.Enabled := aEnable;
@ -250,6 +259,7 @@ begin
UseLCLScalingCheckBox.Checked := False;
UseAppBundleCheckBox.Caption := dlgPOUseAppBundle;
UseAppBundleCheckBox.Checked := False;
LblNSPrincipalClass.Caption := dlgNSPrincipalClass;
// Windows specific, Manifest
WindowsDividerBevel.Caption := lisForWindows;
@ -310,6 +320,7 @@ begin
else
UseLCLScalingCheckBox.Enabled := False; // Disable for a console program.
UseAppBundleCheckBox.Checked := UseAppBundle;
EdNSPrincipalClass.Text := NSPrincipalClass;
// Manifest
with ProjResources.XPManifest do
begin
@ -352,6 +363,7 @@ begin
end;
end;
UseAppBundle := UseAppBundleCheckBox.Checked;
NSPrincipalClass := EdNSPrincipalClass.Text;
with ProjResources.XPManifest do
begin
UseManifest := UseXPManifestCheckBox.Checked;

View File

@ -2711,6 +2711,7 @@ resourcestring
lisForWindows = 'For Windows';
lisForMacOSDarwin = 'For macOS (Darwin)';
dlgPOUseAppBundle = 'Use Application Bundle for running and debugging';
dlgNSPrincipalClass = 'NSPrincipalClass';
dlgPOCreateAppBundle = 'Create Application Bundle';
dlgPOUseManifest = 'Use manifest resource (and enable themes)';
dlgPODpiAwareness = 'DPI awareness';

View File

@ -7001,7 +7001,7 @@ begin
and ((MainBuildBoss.GetLCLWidgetType=LCLPlatformDirNames[lpCarbon])
or (MainBuildBoss.GetLCLWidgetType=LCLPlatformDirNames[lpCocoa]))
then begin
Result:=CreateApplicationBundle(TargetExeName, Project1.GetTitleOrName);
Result:=CreateApplicationBundle(TargetExeName, Project1.GetTitleOrName, false, Project1);
if not (Result in [mrOk,mrIgnore]) then begin
debugln(['Error: (lazarus) [TMainIDE.DoBuildProject] CreateApplicationBundle "',TargetExeName,'" failed']);
exit;

View File

@ -3127,6 +3127,7 @@ begin
{$IFDEF IDE_MEM_CHECK}CheckHeapWrtMemCnt('TProject.ReadProject C reading values');{$ENDIF}
FFileVersion:= FXMLConfig.GetValue(ProjOptionsPath+'Version/Value',0);
UseAppBundle := FXMLConfig.GetValue(ProjOptionsPath+'General/UseAppBundle/Value', True);
NSPrincipalClass := FXMLConfig.GetValue(ProjOptionsPath+'General/NSPrincipalClass/Value', '');
if FLoadAllOptions then
LoadFromLPI;
// Resources
@ -3316,6 +3317,7 @@ begin
FXMLConfig.SetDeleteValue(Path+'General/Title/Value', Title,'');
FXMLConfig.SetDeleteValue(Path+'General/Scaled/Value', Scaled,False);
FXMLConfig.SetDeleteValue(Path+'General/UseAppBundle/Value', UseAppBundle, True);
FXMLConfig.SetDeleteValue(Path+'General/NSPrincipalClass/Value', NSPrincipalClass, '');
// fpdoc
FXMLConfig.SetDeleteValue(Path+'LazDoc/Paths',