IDE: Add UTF-8 support also for programs by adding dependency for LazUtils.

git-svn-id: trunk@47917 -
This commit is contained in:
juha 2015-02-20 15:16:26 +00:00
parent 222321addf
commit 76f8ed6f80

View File

@ -35,7 +35,8 @@ uses
IDEWindowIntf, IDEOptionsIntf, IDECommands, IDEHelpIntf, ProjectIntf, IDEWindowIntf, IDEOptionsIntf, IDECommands, IDEHelpIntf, ProjectIntf,
CompOptsIntf, IDEDialogs, EnvironmentOpts, LazarusIDEStrConsts, EditorOptions, CompOptsIntf, IDEDialogs, EnvironmentOpts, LazarusIDEStrConsts, EditorOptions,
BuildModesManager, TransferMacros, project_save_options, Project, BuildModesManager, TransferMacros, project_save_options, Project,
ModeMatrixOpts, Compiler_ModeMatrix, Compiler_Other_Options; ModeMatrixOpts, PackageDefs, PackageSystem, Compiler_ModeMatrix,
Compiler_Other_Options;
type type
TIDEOptsDlgAction = ( TIDEOptsDlgAction = (
@ -128,6 +129,26 @@ implementation
uses uses
IDEContextHelpEdit; IDEContextHelpEdit;
const
LazUtilsPkg = 'LazUtils';
function HasLazUtilsDependency: Boolean;
begin
Result := Assigned(Project1.FindDependencyByName('LCL'))
or Assigned(Project1.FindDependencyByName(LazUtilsPkg));
end;
procedure AddLazUtilsDependency;
var
Dep: TPkgDependency;
begin
if HasLazUtilsDependency then Exit;
Project1.AddPackageDependency(LazUtilsPkg);
Dep:=Project1.FindDependencyByName(LazUtilsPkg);
if Assigned(Dep) then
PackageGraph.OpenDependency(Dep,false);
end;
{ TIDEOptionsDialog } { TIDEOptionsDialog }
constructor TIDEOptionsDialog.Create(AOwner: TComponent); constructor TIDEOptionsDialog.Create(AOwner: TComponent);
@ -232,8 +253,9 @@ begin
OtherOptions:=TCompilerOtherOptionsFrame(FindEditor(TCompilerOtherOptionsFrame)); OtherOptions:=TCompilerOtherOptionsFrame(FindEditor(TCompilerOtherOptionsFrame));
ModeMatrix:=TCompOptModeMatrixFrame(FindEditor(TCompOptModeMatrixFrame)); ModeMatrix:=TCompOptModeMatrixFrame(FindEditor(TCompOptModeMatrixFrame));
if Assigned(OtherOptions) and Assigned(ModeMatrix) then if Assigned(OtherOptions) and Assigned(ModeMatrix) then
SetUtf8InRtlButton.Enabled := SetUtf8InRtlButton.Enabled := not (OtherOptions.HasSupportForUtf8Rtl
not (OtherOptions.HasSupportForUtf8Rtl and ModeMatrix.HasSupportForUtf8Rtl); and ModeMatrix.HasSupportForUtf8Rtl
and HasLazUtilsDependency);
end; end;
procedure TIDEOptionsDialog.SetUtf8InRtlButtonClick(Sender: TObject); procedure TIDEOptionsDialog.SetUtf8InRtlButtonClick(Sender: TObject);
@ -248,6 +270,9 @@ begin
OtherOptions.SupportUtf8Rtl; OtherOptions.SupportUtf8Rtl;
// Make FPC default string UTF-8. Assign UTF-8 backends for Ansi...() functions etc. // Make FPC default string UTF-8. Assign UTF-8 backends for Ansi...() functions etc.
ModeMatrix.SupportUtf8Rtl; ModeMatrix.SupportUtf8Rtl;
// Add dependency for LazUtils if the project does not have it yet.
AddLazUtilsDependency;
// Update GUI state and show message.
UpdateUtf8RtlButtonState; UpdateUtf8RtlButtonState;
ShowMessage(Format(lisThisBuildModeNowSetsUTF8InTheRTLFlagsAreInPagesOth, [ ShowMessage(Format(lisThisBuildModeNowSetsUTF8InTheRTLFlagsAreInPagesOth, [
LineEnding])); LineEnding]));