diff --git a/ide/imexportcompileropts.lfm b/ide/imexportcompileropts.lfm index e29fdd91a6..6aadd6246c 100644 --- a/ide/imexportcompileropts.lfm +++ b/ide/imexportcompileropts.lfm @@ -30,40 +30,6 @@ object ImExportCompOptsDlg: TImExportCompOptsDlg TabOrder = 3 ShowButtons = [pbOK, pbCancel, pbHelp] end - object HistoryLabel: TLabel - AnchorSideTop.Control = FileNameEdit - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = FileNameEdit - AnchorSideRight.Side = asrBottom - Left = 407 - Height = 15 - Top = 54 - Width = 38 - Anchors = [akTop, akRight] - BorderSpacing.Top = 6 - Caption = 'History' - ParentColor = False - end - object HistoryButton: TButton - AnchorSideLeft.Control = HistoryLabel - AnchorSideTop.Control = HistoryLabel - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = HistoryLabel - AnchorSideRight.Side = asrBottom - Left = 410 - Height = 25 - Hint = 'Recent files' - Top = 75 - Width = 35 - Anchors = [akTop, akRight] - BorderSpacing.Top = 6 - Caption = '>>' - OnClick = HistoryButtonClick - ParentShowHint = False - PopupMenu = RecentPopupMenu - ShowHint = True - TabOrder = 2 - end object FileLabel: TLabel AnchorSideLeft.Control = Owner AnchorSideTop.Control = Owner @@ -76,33 +42,7 @@ object ImExportCompOptsDlg: TImExportCompOptsDlg Caption = 'File' ParentColor = False end - object FileNameEdit: TFileNameEdit - AnchorSideLeft.Control = FileLabel - AnchorSideTop.Control = FileLabel - AnchorSideTop.Side = asrBottom - AnchorSideRight.Control = Owner - AnchorSideRight.Side = asrBottom - Left = 6 - Height = 23 - Top = 25 - Width = 439 - DialogOptions = [ofExtensionDifferent, ofEnableSizing, ofViewDetail] - Filter = 'XML file (*.xml)|*.xml|Project file (*.lpi)|*.lpi|Package file (*.lpk)|*.lpk|Session file (*.lps)|*.lps|All files (*)|*' - FilterIndex = 0 - HideDirectories = False - ButtonWidth = 45 - NumGlyphs = 1 - Anchors = [akTop, akLeft, akRight] - BorderSpacing.Top = 4 - BorderSpacing.Right = 6 - MaxLength = 0 - ParentShowHint = False - PopupMenu = RecentPopupMenu - TabOrder = 0 - end object ExportRadioGroup: TRadioGroup - AnchorSideLeft.Control = FileNameEdit - AnchorSideTop.Control = FileNameEdit AnchorSideTop.Side = asrBottom Left = 6 Height = 66 @@ -125,13 +65,48 @@ object ImExportCompOptsDlg: TImExportCompOptsDlg 'Current build mode' 'All build modes' ) + TabOrder = 2 + end + object FileNameEdit: TComboBox + AnchorSideLeft.Control = FileLabel + AnchorSideTop.Control = FileLabel + AnchorSideTop.Side = asrBottom + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 6 + Height = 23 + Top = 25 + Width = 378 + BorderSpacing.Top = 4 + BorderSpacing.Right = 6 + ItemHeight = 15 + OnChange = FileNameEditChange + ParentShowHint = False + TabOrder = 0 + end + object ButtonBrowse: TButton + AnchorSideLeft.Control = FileNameEdit + AnchorSideLeft.Side = asrBottom + AnchorSideTop.Control = FileNameEdit + AnchorSideRight.Control = Owner + AnchorSideRight.Side = asrBottom + Left = 390 + Height = 25 + Top = 25 + Width = 55 + Anchors = [akTop, akLeft, akRight] + BorderSpacing.Right = 6 + Caption = '...' + OnClick = ButtonBrowseClick TabOrder = 1 end - object RecentPopupMenu: TPopupMenu - left = 256 - top = 96 - object MenuItem1: TMenuItem - Caption = 'New Item1' - end + object OpenDlg: TOpenDialog + Options = [ofFileMustExist, ofEnableSizing, ofViewDetail] + left = 304 + top = 88 + end + object SaveDlg: TSaveDialog + left = 349 + top = 88 end end diff --git a/ide/imexportcompileropts.pas b/ide/imexportcompileropts.pas index 8519d11f0a..8ea24aae70 100644 --- a/ide/imexportcompileropts.pas +++ b/ide/imexportcompileropts.pas @@ -33,7 +33,7 @@ interface uses Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons, - Menus, ExtCtrls, EditBtn, ButtonPanel, + Menus, ExtCtrls, ButtonPanel, IDEProcs, FileUtil, Laz2_XMLCfg, LazFileCache, LCLType, LazarusIDEStrConsts, IDEOptionsIntf, InputHistory, Project, CompilerOptions; @@ -41,27 +41,23 @@ type { TImExportCompOptsDlg } TImExportCompOptsDlg = class(TForm) + ButtonBrowse: TButton; ButtonPanel1: TButtonPanel; ExportRadioGroup: TRadioGroup; FileLabel: TLabel; - FileNameEdit: TFileNameEdit; - HistoryLabel: TLabel; - MenuItem1: TMenuItem; - HistoryButton: TButton; - RecentPopupMenu: TPopupMenu; - procedure FileNameEditChangeImport(Sender: TObject); - procedure FileNameEditChangeExport(Sender: TObject); + FileNameEdit: TComboBox; + OpenDlg: TOpenDialog; + SaveDlg: TSaveDialog; + procedure ButtonBrowseClick(Sender: TObject); + procedure FileNameEditChange(Sender: TObject); procedure ImExportCompOptsDlgCLOSE(Sender: TObject; var {%H-}CloseAction: TCloseAction); procedure ImExportCompOptsDlgCREATE(Sender: TObject); procedure OpenButtonCLICK(Sender: TObject); - procedure PopupClick(Sender: TObject); - procedure HistoryButtonClick(Sender: TObject); - //procedure RecentSaveButton1Click(Sender: TObject); procedure SaveButtonCLICK(Sender: TObject); private FFilename: string; FParentDialog: TAbstractOptionsEditorDialog; - procedure HideRadioButtons; + FExport: boolean; procedure InitExport; procedure InitImport; procedure LoadRecentList; @@ -249,16 +245,16 @@ end; { TImExportCompOptsDlg } -procedure TImExportCompOptsDlg.HideRadioButtons; -begin - ExportRadioGroup.Enabled:=False; // Enabled is better than visible, nicer dialog -end; - procedure TImExportCompOptsDlg.InitImport; begin + FExport:=false; Caption:=lisIECOImportCompilerOptions; - HideRadioButtons; - FileNameEdit.Filter:= Format( + // ToDo: Later when the XML file is selected, ExportRadioGroup can be made + // Visible but disabled. Then ItemIndex must be set according to file contents. + // If file contains one mode -> ItemIndex:=0. If more modes -> ItemIndex:=1. + ExportRadioGroup.Visible:=False; + + OpenDlg.Filter:=Format( '%s|*.xml|' +'%s|*.lpi|' +'%s|*.lpk|' @@ -270,8 +266,6 @@ begin dlgFilterLazarusSession, dlgFilterAll, GetAllFilesMask]); - FileNameEdit.DialogOptions:=FileNameEdit.DialogOptions+[ofFileMustExist]; - FileNameEdit.OnChange:=@FileNameEditChangeImport; with ButtonPanel1 do begin OKButton.Caption:=lisIECOLoadFromFile; OKButton.LoadGlyphFromStock(idButtonOpen); @@ -284,12 +278,13 @@ end; procedure TImExportCompOptsDlg.InitExport; begin + FExport:=true; Caption:=lisIECOExportCompilerOptions; - FileNameEdit.Filter:='XML file (*.xml)|*.xml|All files (*)|*'; - FileNameEdit.DialogKind:=dkSave; - FileNameEdit.OnChange:=@FileNameEditChangeExport; + SaveDlg.Filter:=Format('%s|*.xml|%s|%s', + [dlgFilterXML, dlgFilterAll, GetAllFilesMask]); + if Project1.BuildModes.Count <= 1 then - HideRadioButtons; + ExportRadioGroup.Enabled:=False; with ButtonPanel1 do begin OKButton.Caption:=lisIECOSaveToFile; OKButton.LoadGlyphFromStock(idButtonSave); @@ -302,8 +297,6 @@ end; procedure TImExportCompOptsDlg.ImExportCompOptsDlgCREATE(Sender: TObject); begin - HistoryLabel.Caption:=lisIECORecentFiles; - HistoryLabel.Hint:=lisIECORecentFiles; FileLabel.Caption:=lisFile; ExportRadioGroup.Caption:=lisIECOCompilerOptionsOf; ExportRadioGroup.Items.Strings[0]:=lisIECOCurrentBuildMode; @@ -311,39 +304,40 @@ begin LoadRecentList; end; -procedure TImExportCompOptsDlg.FileNameEditChangeImport(Sender: TObject); +procedure TImExportCompOptsDlg.ButtonBrowseClick(Sender: TObject); +var + Dlg: TFileDialog; begin - ButtonPanel1.OKButton.Enabled := FileExistsUTF8((Sender as TFileNameEdit).FileName); + if FExport then Dlg:= SaveDlg + else Dlg:= OpenDlg; + + with Dlg do + begin + FileName := ''; + if Execute then + begin + FileNameEdit.Text := FileName; + FileNameEditChange(nil); + end; + end; end; -procedure TImExportCompOptsDlg.FileNameEditChangeExport(Sender: TObject); +procedure TImExportCompOptsDlg.FileNameEditChange(Sender: TObject); begin - ButtonPanel1.OKButton.Enabled := (Sender as TFileNameEdit).FileName <> ''; + if FExport then + ButtonPanel1.OKButton.Enabled := FileNameEdit.Text <> '' + else + ButtonPanel1.OKButton.Enabled := FileExistsUTF8(FileNameEdit.Text); end; procedure TImExportCompOptsDlg.OpenButtonCLICK(Sender: TObject); begin - DoOpenFile(CleanAndExpandFilename(FileNameEdit.FileName)); + DoOpenFile(CleanAndExpandFilename(FileNameEdit.Text)); end; -procedure TImExportCompOptsDlg.PopupClick(Sender: TObject); -begin - FileNameEdit.Text := (Sender as TMenuItem).Caption; -end; - -procedure TImExportCompOptsDlg.HistoryButtonClick(Sender: TObject); -begin - RecentPopupMenu.PopUp; -end; -{ -procedure TImExportCompOptsDlg.RecentSaveButton1Click(Sender: TObject); -begin - RecentPopupMenu.PopUp; -end; -} procedure TImExportCompOptsDlg.SaveButtonCLICK(Sender: TObject); begin - DoSaveFile(CleanAndExpandFilename(FileNameEdit.FileName)); + DoSaveFile(CleanAndExpandFilename(FileNameEdit.Text)); end; procedure TImExportCompOptsDlg.ImExportCompOptsDlgCLOSE(Sender: TObject; var CloseAction: TCloseAction); @@ -352,32 +346,15 @@ begin end; procedure TImExportCompOptsDlg.LoadRecentList; -var - sl: TStringList; - mi: TMenuItem; - i: Integer; begin - sl := TStringList.Create; - try - RecentPopupMenu.Items.Clear; - sl.Assign(InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile)); - for i := 0 to sl.Count-1 do begin - mi := TMenuItem.Create(RecentPopupMenu); - mi.Caption:=sl[i]; - mi.OnClick:=@PopupClick; - RecentPopupMenu.Items.Add(mi); - end; - HistoryLabel.Visible := sl.Count > 0; - HistoryButton.Visible := HistoryLabel.Visible; - finally - sl.Free; - end; + FileNameEdit.Items.Assign( + InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile)); end; { procedure TImExportCompOptsDlg.SaveRecentList; begin InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile).Assign( - RecentListbox.Items); + FileNameEdit.Items); InputHistories.Save; end; }