From c45dfb7a56901b18b6cf65f91d65f5597dc596a9 Mon Sep 17 00:00:00 2001 From: Juha Date: Sun, 18 Dec 2022 09:49:15 +0200 Subject: [PATCH] IDE: Show Widgetset display name instead of dir name in selection list for project. Issue #40040, patch by theo222. --- ide/frames/compiler_modematrix.pas | 12 ++++-------- lcl/lclplatformdef.pas | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/ide/frames/compiler_modematrix.pas b/ide/frames/compiler_modematrix.pas index 2abf4c5a2e..a6112362b8 100644 --- a/ide/frames/compiler_modematrix.pas +++ b/ide/frames/compiler_modematrix.pas @@ -35,18 +35,13 @@ unit Compiler_ModeMatrix; interface uses - //Classes, SysUtils, types, LazLoggerBase, LazUTF8, Controls, Graphics, ComCtrls, - //Menus, LCLProc, IDEOptionsIntf, IDEImagesIntf, CompOptsIntf, EnvironmentOpts, - //PackageSystem, PackageDefs, Project, LazarusIDEStrConsts, TransferMacros, - //ModeMatrixOpts, ModeMatrixCtrl, compiler_config_target; Classes, SysUtils, types, // LazUtils LazLoggerBase, LazUTF8, // LCL - LCLProc, Controls, Graphics, ComCtrls, Menus, + LCLPlatformDef, Controls, Graphics, ComCtrls, Menus, // IdeIntf - IDEOptionsIntf, IDEOptEditorIntf, IDEImagesIntf, CompOptsIntf, - KeywordFuncLists, + IDEOptionsIntf, IDEOptEditorIntf, IDEImagesIntf, CompOptsIntf, KeywordFuncLists, // IDE EnvironmentOpts, PackageSystem, PackageDefs, Project, LazarusIDEStrConsts, TransferMacros, ModeMatrixOpts, ModeMatrixCtrl, compiler_config_target; @@ -514,6 +509,7 @@ var begin ValueMenuItem:=Sender as TMenuItem; Value:=GetCaptionValue(ValueMenuItem.Caption,fCaptionPatternMacroValue); + Value:=DisplayNameToDirName(Value); CreateNewOption(BuildMatrixOptionTypeCaption(bmotIDEMacro),'LCLWidgetType:='+Value); // Update LCLWidgetType to Config and Target page. ToDo: update also when deleting or changing. TargetFrame := TCompilerConfigTargetFrame(FDialog.FindEditor(TCompilerConfigTargetFrame)); @@ -618,7 +614,7 @@ begin if i=ParentMenu.Items.Count then ParentMenu.Items.Add(TMenuItem.Create(Self)); ValueMI:=ParentMenu.Items[i]; - ValueMI.Caption:=Format(fCaptionPatternMacroValue,[Mcr.Values[i]]); + ValueMI.Caption:=Format(fCaptionPatternMacroValue,[DirNameToDisplayName(Mcr.Values[i])]); ValueMI.OnClick:=@OnAddLCLWidgetTypeClick; end; end; diff --git a/lcl/lclplatformdef.pas b/lcl/lclplatformdef.pas index a6232bc715..ceb5d7aa94 100644 --- a/lcl/lclplatformdef.pas +++ b/lcl/lclplatformdef.pas @@ -39,6 +39,8 @@ type TLCLPlatforms = set of TLCLPlatform; function DirNameToLCLPlatform(const ADirName: string): TLCLPlatform; + function DirNameToDisplayName(const ADirName: string): String; + function DisplayNameToDirName(const ADisplayName: String): String; function GetBuildLCLWidgetType: TLCLPlatform; const @@ -106,6 +108,21 @@ begin Result:=lpGtk2; end; +function DirNameToDisplayName(const ADirName: string): String; +begin + Result:=LCLPlatformDisplayNames[DirNameToLCLPlatform(ADirName)]; +end; + +function DisplayNameToDirName(const ADisplayName: String): String; +var + PlatForm: TLCLPlatform; +begin + for PlatForm:=Low(TLCLPlatform) to High(TLCLPlatform) do + if CompareText(ADisplayName,LCLPlatformDisplayNames[PlatForm])=0 then + exit(LCLPlatformDirNames[PlatForm]); + Result:='gtk2'; +end; + function GetBuildLCLWidgetType: TLCLPlatform; begin Result:=BuildLCLWidgetType;