From 40bc5733f45af6c148e6843bb658184afe8650ea Mon Sep 17 00:00:00 2001 From: mattias Date: Thu, 17 Mar 2011 21:45:16 +0000 Subject: [PATCH] IDE: started setup dialog git-svn-id: trunk@29895 - --- ide/initialsetupdlgs.lfm | 143 ++++++++++++++++++++++++++++++++++++++- ide/initialsetupdlgs.pas | 67 +++++++++++++++++- 2 files changed, 207 insertions(+), 3 deletions(-) diff --git a/ide/initialsetupdlgs.lfm b/ide/initialsetupdlgs.lfm index 4952fc429f..69559acf60 100644 --- a/ide/initialsetupdlgs.lfm +++ b/ide/initialsetupdlgs.lfm @@ -104,10 +104,10 @@ object InitialSetupDialog: TInitialSetupDialog Height = 284 Top = 54 Width = 444 - ActivePage = LazarusTabSheet + ActivePage = LanguageTabSheet Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Right = 6 - TabIndex = 0 + TabIndex = 3 TabOrder = 3 OnChange = PropertiesPageControlChange Options = [nboHidePageListPopup] @@ -178,12 +178,151 @@ object InitialSetupDialog: TInitialSetupDialog end object CompilerTabSheet: TTabSheet Caption = 'CompilerTabSheet' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.HorizontalSpacing = 6 + ChildSizing.VerticalSpacing = 6 + ClientHeight = 251 + ClientWidth = 440 + object CompilerLabel: TLabel + Left = 6 + Height = 18 + Top = 6 + Width = 428 + Align = alTop + Caption = 'CompilerLabel' + ParentColor = False + WordWrap = True + end + object CompilerComboBox: TComboBox + AnchorSideLeft.Control = CompilerTabSheet + AnchorSideTop.Control = CompilerLabel + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = CompilerTabSheet + AnchorSideRight.Side = asrBottom + Left = 6 + Height = 27 + Top = 30 + Width = 428 + Anchors = [akTop, akLeft, akRight] + ItemHeight = 0 + TabOrder = 0 + Text = 'CompilerComboBox' + end + object CompilerBrowseButton: TButton + AnchorSideLeft.Control = CompilerTabSheet + AnchorSideTop.Control = CompilerComboBox + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 27 + Top = 63 + Width = 179 + AutoSize = True + Caption = 'CompilerBrowseButton' + TabOrder = 1 + end + object CompilerMemo: TMemo + AnchorSideLeft.Control = CompilerTabSheet + AnchorSideTop.Control = CompilerBrowseButton + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = CompilerTabSheet + AnchorSideRight.Side = asrBottom + AnchorSideBottom.Control = CompilerTabSheet + AnchorSideBottom.Side = asrBottom + Left = 6 + Height = 149 + Top = 96 + Width = 428 + Anchors = [akTop, akLeft, akRight, akBottom] + Lines.Strings = ( + 'CompilerMemo' + ) + TabOrder = 2 + end end object FPCSourcesTabSheet: TTabSheet Caption = 'FPCSourcesTabSheet' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.HorizontalSpacing = 6 + ChildSizing.VerticalSpacing = 6 + ClientHeight = 251 + ClientWidth = 440 + object FPCSrcDirLabel: TLabel + Left = 6 + Height = 18 + Top = 6 + Width = 428 + Align = alTop + Caption = 'FPCSrcDirLabel' + ParentColor = False + WordWrap = True + end + object FPCSrcDirComboBox: TComboBox + Left = 6 + Height = 27 + Top = 30 + Width = 428 + Align = alTop + ItemHeight = 0 + TabOrder = 0 + Text = 'FPCSrcDirComboBox' + end + object FPCSrcDirBrowseButton: TButton + AnchorSideLeft.Control = FPCSourcesTabSheet + AnchorSideTop.Control = FPCSrcDirComboBox + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 27 + Top = 63 + Width = 185 + AutoSize = True + Caption = 'FPCSrcDirBrowseButton' + TabOrder = 1 + end + object FPCSrcDirMemo: TMemo + AnchorSideTop.Control = FPCSrcDirBrowseButton + AnchorSideTop.Side = asrBottom + Left = 6 + Height = 149 + Top = 96 + Width = 428 + Align = alBottom + Anchors = [akTop, akLeft, akRight, akBottom] + Lines.Strings = ( + 'FPCSrcDirMemo' + ) + TabOrder = 2 + end end object LanguageTabSheet: TTabSheet Caption = 'LanguageTabSheet' + ChildSizing.LeftRightSpacing = 6 + ChildSizing.TopBottomSpacing = 6 + ChildSizing.HorizontalSpacing = 6 + ChildSizing.VerticalSpacing = 6 + ClientHeight = 251 + ClientWidth = 440 + object LangLabel: TLabel + Left = 6 + Height = 18 + Top = 6 + Width = 428 + Align = alTop + Caption = 'LangLabel' + ParentColor = False + WordWrap = True + end + object LangComboBox: TComboBox + Left = 6 + Height = 27 + Top = 30 + Width = 428 + Align = alTop + ItemHeight = 0 + TabOrder = 0 + Text = 'LangComboBox' + end end end object WelcomePaintBox: TPaintBox diff --git a/ide/initialsetupdlgs.pas b/ide/initialsetupdlgs.pas index bb375eea3d..f289a0d398 100644 --- a/ide/initialsetupdlgs.pas +++ b/ide/initialsetupdlgs.pas @@ -69,7 +69,17 @@ type TInitialSetupDialog = class(TForm) BtnPanel: TPanel; + CompilerBrowseButton: TButton; + CompilerComboBox: TComboBox; + CompilerLabel: TLabel; + CompilerMemo: TMemo; + FPCSrcDirBrowseButton: TButton; + FPCSrcDirComboBox: TComboBox; + FPCSrcDirLabel: TLabel; + FPCSrcDirMemo: TMemo; ImageList1: TImageList; + LangComboBox: TComboBox; + LangLabel: TLabel; LazDirBrowseButton: TButton; LazDirLabel: TLabel; LazDirComboBox: TComboBox; @@ -121,6 +131,10 @@ function CheckLazarusDirectoryQuality(ADirectory: string; out Note: string): TSDFilenameQuality; function SearchLazarusDirectoryCandidates(StopIfFits: boolean): TObjectList; +function CheckCompilerQuality(AFilename: string; + out Note: string): TSDFilenameQuality; +function SearchCompilerCandidates(StopIfFits: boolean): TObjectList; + function GetValueFromPrimaryConfig(OptionFilename, Path: string): string; function GetValueFromSecondaryConfig(OptionFilename, Path: string): string; function GetValueFromIDEConfig(OptionFilename, Path: string): string; @@ -285,7 +299,8 @@ var Version: String; begin Result:=sddqInvalid; - if not DirPathExists(ADirectory) then begin + ADirectory:=TrimFilename(ADirectory); + if not DirPathExistsCached(ADirectory) then begin Note:='Directory not found'; exit; end; @@ -397,6 +412,56 @@ begin if CheckDir(Dirs[i],Result) then exit; end; +function CheckCompilerQuality(AFilename: string; out Note: string + ): TSDFilenameQuality; +begin + Result:=sddqInvalid; + AFilename:=TrimFilename(AFilename); + if not FileExistsCached(AFilename) then begin + Note:='File not found'; + exit; + end; + if not FileIsExecutableCached(AFilename) then begin + Note:='File is not executable'; + exit; + end; + +end; + +function SearchCompilerCandidates(StopIfFits: boolean): TObjectList; + + function CheckFile(AFilename: string; var List: TObjectList): boolean; + var + Item: TSDFileInfo; + i: Integer; + begin + Result:=false; + AFilename:=TrimFilename(AFilename); + if AFilename='' then exit; + AFilename:=ExpandFileNameUTF8(AFilename); + // check if already checked + if List<>nil then begin + for i:=0 to List.Count-1 do + if CompareFilenames(AFilename,TSDFileInfo(List[i]).Filename)=0 then exit; + end; + // check if exists + if not FileExistsCached(AFilename) then exit; + // add to list and check quality + Item:=TSDFileInfo.Create; + Item.Filename:=AFilename; + Item.Quality:=CheckCompilerQuality(AFilename,Item.Note); + Item.Caption:=AFilename; + if List=nil then + List:=TObjectList.create(true); + List.Add(Item); + Result:=(Item.Quality=sddqCompatible) and StopIfFits; + end; + +begin + Result:=nil; + +end; + function GetValueFromPrimaryConfig(OptionFilename, Path: string): string; begin if not FilenameIsAbsolute(OptionFilename) then