mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-11-04 06:59:48 +01:00 
			
		
		
		
	IDE: Revamp the GUI for importing / exporting compiler options.
git-svn-id: trunk@45608 -
This commit is contained in:
		
							parent
							
								
									750993ff2d
								
							
						
					
					
						commit
						3a7d798fa6
					
				@ -48,6 +48,7 @@ type
 | 
			
		||||
    btnShowOptions: TBitBtn;
 | 
			
		||||
    btnCheck: TBitBtn;
 | 
			
		||||
    btnLoadSave: TBitBtn;
 | 
			
		||||
    btnExport: TBitBtn;
 | 
			
		||||
    chkUseAsDefault: TCheckBox;
 | 
			
		||||
    function CheckSearchPath(const Context, ExpandedPath: string;
 | 
			
		||||
      Level: TCheckCompileOptionsMsgLvl): boolean;
 | 
			
		||||
@ -59,7 +60,8 @@ type
 | 
			
		||||
    procedure PathEditBtnExecuted(Sender: TObject);
 | 
			
		||||
    procedure DoShowOptions(Sender: TObject);
 | 
			
		||||
    procedure DoCheck(Sender: TObject);
 | 
			
		||||
    procedure DoLoadSave(Sender: TObject);
 | 
			
		||||
    procedure DoImport(Sender: TObject);
 | 
			
		||||
    procedure DoExport(Sender: TObject);
 | 
			
		||||
  protected
 | 
			
		||||
    procedure DoSaveSettings(AOptions: TAbstractIDEOptions);
 | 
			
		||||
    procedure UpdateTargetFileLabel;
 | 
			
		||||
@ -246,17 +248,22 @@ begin
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TCompilerPathOptionsFrame.DoLoadSave(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  ImportExportResult: TImportExportOptionsResult;
 | 
			
		||||
procedure TCompilerPathOptionsFrame.DoImport(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  DoSaveSettings(FCompilerOpts);
 | 
			
		||||
  if (MainIDEInterface.DoImExportCompilerOptions(ImportExportResult) = mrOK)
 | 
			
		||||
  and (ImportExportResult = ieorImport)
 | 
			
		||||
  if (MainIDEInterface.ImportCompilerOptions = mrOK)
 | 
			
		||||
  and Assigned(OnLoadIDEOptions) then
 | 
			
		||||
    OnLoadIDEOptions(Self, FCompilerOpts);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TCompilerPathOptionsFrame.DoExport(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  DoSaveSettings(FCompilerOpts);
 | 
			
		||||
  if (MainIDEInterface.ExportCompilerOptions = mrOK)
 | 
			
		||||
  and Assigned(OnSaveIDEOptions) then
 | 
			
		||||
    OnSaveIDEOptions(Self, FCompilerOpts);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TCompilerPathOptionsFrame.DoSaveSettings(AOptions: TAbstractIDEOptions);
 | 
			
		||||
begin
 | 
			
		||||
  if Assigned(OnSaveIDEOptions) then
 | 
			
		||||
@ -725,14 +732,22 @@ begin
 | 
			
		||||
  btnShowOptions := CreateButton(dlgCOShowOptions);
 | 
			
		||||
  btnShowOptions.LoadGlyphFromResourceName(HInstance, 'menu_compiler_options');
 | 
			
		||||
  btnShowOptions.OnClick  := @DoShowOptions;
 | 
			
		||||
  // Check
 | 
			
		||||
  btnCheck := CreateButton(lisCompTest);
 | 
			
		||||
  btnCheck.ModalResult := mrNone;
 | 
			
		||||
  btnCheck.OnClick  := @DoCheck;
 | 
			
		||||
  btnCheck.LoadGlyphFromStock(idButtonYes);
 | 
			
		||||
  btnLoadSave := CreateButton(lisLoadSave);
 | 
			
		||||
  btnLoadSave.OnClick  := @DoLoadSave;
 | 
			
		||||
  // Import
 | 
			
		||||
  btnLoadSave := CreateButton(lisImport);
 | 
			
		||||
  btnLoadSave.OnClick  := @DoImport;
 | 
			
		||||
  btnLoadSave.Hint := dlgCOLoadSave;
 | 
			
		||||
  btnLoadSave.LoadGlyphFromStock(idButtonSave);
 | 
			
		||||
  btnLoadSave.LoadGlyphFromStock(idButtonOpen);
 | 
			
		||||
  // Export
 | 
			
		||||
  btnExport := CreateButton(lisExport);
 | 
			
		||||
  btnExport.OnClick  := @DoExport;
 | 
			
		||||
  btnExport.Hint := dlgCOLoadSave;
 | 
			
		||||
  btnExport.LoadGlyphFromStock(idButtonSave);
 | 
			
		||||
 | 
			
		||||
  if btnLoadSave.Glyph.Empty then
 | 
			
		||||
    btnLoadSave.LoadGlyphFromResourceName(HInstance, 'laz_save');
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -1,140 +1,122 @@
 | 
			
		||||
object ImExportCompOptsDlg: TImExportCompOptsDlg
 | 
			
		||||
  Left = 316
 | 
			
		||||
  Height = 235
 | 
			
		||||
  Top = 212
 | 
			
		||||
  Width = 554
 | 
			
		||||
  Left = 416
 | 
			
		||||
  Height = 127
 | 
			
		||||
  Top = 208
 | 
			
		||||
  Width = 687
 | 
			
		||||
  Caption = 'ImExportCompOptsDlg'
 | 
			
		||||
  ClientHeight = 235
 | 
			
		||||
  ClientWidth = 554
 | 
			
		||||
  ClientHeight = 127
 | 
			
		||||
  ClientWidth = 687
 | 
			
		||||
  Constraints.MinHeight = 113
 | 
			
		||||
  Constraints.MinWidth = 658
 | 
			
		||||
  OnClose = ImExportCompOptsDlgCLOSE
 | 
			
		||||
  OnCreate = ImExportCompOptsDlgCREATE
 | 
			
		||||
  LCLVersion = '1.3'
 | 
			
		||||
  object OpenRecentGroupbox: TGroupBox
 | 
			
		||||
    AnchorSideLeft.Control = Owner
 | 
			
		||||
    AnchorSideTop.Control = Owner
 | 
			
		||||
    AnchorSideRight.Control = Owner
 | 
			
		||||
    AnchorSideRight.Side = asrBottom
 | 
			
		||||
    AnchorSideBottom.Control = CancelButton
 | 
			
		||||
  object ButtonPanel1: TButtonPanel
 | 
			
		||||
    Left = 6
 | 
			
		||||
    Height = 191
 | 
			
		||||
    Top = 6
 | 
			
		||||
    Width = 542
 | 
			
		||||
    Anchors = [akTop, akLeft, akRight, akBottom]
 | 
			
		||||
    BorderSpacing.Around = 6
 | 
			
		||||
    Caption = 'OpenRecentGroupbox'
 | 
			
		||||
    ClientHeight = 173
 | 
			
		||||
    ClientWidth = 538
 | 
			
		||||
    Height = 41
 | 
			
		||||
    Top = 80
 | 
			
		||||
    Width = 675
 | 
			
		||||
    OKButton.Name = 'OKButton'
 | 
			
		||||
    OKButton.DefaultCaption = True
 | 
			
		||||
    HelpButton.Name = 'HelpButton'
 | 
			
		||||
    HelpButton.DefaultCaption = True
 | 
			
		||||
    CloseButton.Name = 'CloseButton'
 | 
			
		||||
    CloseButton.DefaultCaption = True
 | 
			
		||||
    CancelButton.Name = 'CancelButton'
 | 
			
		||||
    CancelButton.DefaultCaption = True
 | 
			
		||||
    TabOrder = 0
 | 
			
		||||
    object RecentListbox: TListBox
 | 
			
		||||
      AnchorSideLeft.Control = OpenRecentGroupbox
 | 
			
		||||
      AnchorSideTop.Control = OpenRecentGroupbox
 | 
			
		||||
      AnchorSideRight.Control = OpenRecentGroupbox
 | 
			
		||||
      AnchorSideRight.Side = asrBottom
 | 
			
		||||
      AnchorSideBottom.Control = OpenRecentButton
 | 
			
		||||
      Left = 6
 | 
			
		||||
      Height = 132
 | 
			
		||||
      Top = 6
 | 
			
		||||
      Width = 526
 | 
			
		||||
      Align = alTop
 | 
			
		||||
      Anchors = [akTop, akLeft, akRight, akBottom]
 | 
			
		||||
      BorderSpacing.Around = 6
 | 
			
		||||
      ClickOnSelChange = False
 | 
			
		||||
      ItemHeight = 0
 | 
			
		||||
      OnClick = RecentListboxCLICK
 | 
			
		||||
      OnDblClick = RecentListboxDBLCLICK
 | 
			
		||||
      TabOrder = 0
 | 
			
		||||
    end
 | 
			
		||||
    object OpenRecentButton: TButton
 | 
			
		||||
      AnchorSideLeft.Control = OpenRecentGroupbox
 | 
			
		||||
      AnchorSideBottom.Control = OpenRecentGroupbox
 | 
			
		||||
      AnchorSideBottom.Side = asrBottom
 | 
			
		||||
      Left = 6
 | 
			
		||||
      Height = 23
 | 
			
		||||
      Top = 144
 | 
			
		||||
      Width = 118
 | 
			
		||||
      Anchors = [akLeft, akBottom]
 | 
			
		||||
      AutoSize = True
 | 
			
		||||
      BorderSpacing.Around = 6
 | 
			
		||||
      Caption = 'OpenRecentButton'
 | 
			
		||||
      Constraints.MinWidth = 75
 | 
			
		||||
      OnClick = OpenRecentButtonCLICK
 | 
			
		||||
      TabOrder = 1
 | 
			
		||||
    end
 | 
			
		||||
    object SaveToRecentButton: TButton
 | 
			
		||||
      AnchorSideLeft.Control = OpenRecentButton
 | 
			
		||||
      AnchorSideLeft.Side = asrBottom
 | 
			
		||||
      AnchorSideBottom.Control = OpenRecentGroupbox
 | 
			
		||||
      AnchorSideBottom.Side = asrBottom
 | 
			
		||||
      Left = 130
 | 
			
		||||
      Height = 23
 | 
			
		||||
      Top = 144
 | 
			
		||||
      Width = 130
 | 
			
		||||
      Anchors = [akLeft, akBottom]
 | 
			
		||||
      AutoSize = True
 | 
			
		||||
      BorderSpacing.Around = 6
 | 
			
		||||
      Caption = 'SaveToRecentButton'
 | 
			
		||||
      OnClick = SaveToRecentButtonCLICK
 | 
			
		||||
      TabOrder = 2
 | 
			
		||||
    end
 | 
			
		||||
    ShowButtons = [pbOK, pbCancel, pbHelp]
 | 
			
		||||
  end
 | 
			
		||||
  object OpenButton: TBitBtn
 | 
			
		||||
    AnchorSideTop.Control = CancelButton
 | 
			
		||||
    AnchorSideRight.Control = SaveButton
 | 
			
		||||
    AnchorSideBottom.Control = Owner
 | 
			
		||||
    AnchorSideBottom.Side = asrBottom
 | 
			
		||||
    Left = 293
 | 
			
		||||
    Height = 26
 | 
			
		||||
    Top = 203
 | 
			
		||||
    Width = 84
 | 
			
		||||
    Anchors = [akTop, akRight, akBottom]
 | 
			
		||||
    AutoSize = True
 | 
			
		||||
  object HistoryLabel: TLabel
 | 
			
		||||
    Left = 16
 | 
			
		||||
    Height = 15
 | 
			
		||||
    Top = 16
 | 
			
		||||
    Width = 44
 | 
			
		||||
    Caption = 'History'
 | 
			
		||||
    ParentColor = False
 | 
			
		||||
  end
 | 
			
		||||
  object HistoryButton: TButton
 | 
			
		||||
    AnchorSideLeft.Control = HistoryLabel
 | 
			
		||||
    AnchorSideLeft.Side = asrBottom
 | 
			
		||||
    AnchorSideTop.Control = HistoryLabel
 | 
			
		||||
    AnchorSideTop.Side = asrCenter
 | 
			
		||||
    Left = 66
 | 
			
		||||
    Height = 25
 | 
			
		||||
    Hint = 'Recent files'
 | 
			
		||||
    Top = 11
 | 
			
		||||
    Width = 35
 | 
			
		||||
    BorderSpacing.Left = 6
 | 
			
		||||
    BorderSpacing.Right = 6
 | 
			
		||||
    BorderSpacing.Bottom = 6
 | 
			
		||||
    Caption = 'OpenButton'
 | 
			
		||||
    Constraints.MinWidth = 75
 | 
			
		||||
    NumGlyphs = 0
 | 
			
		||||
    OnClick = OpenButtonCLICK
 | 
			
		||||
    Caption = '>>'
 | 
			
		||||
    OnClick = HistoryButtonClick
 | 
			
		||||
    ParentShowHint = False
 | 
			
		||||
    PopupMenu = RecentPopupMenu
 | 
			
		||||
    ShowHint = True
 | 
			
		||||
    TabOrder = 1
 | 
			
		||||
  end
 | 
			
		||||
  object SaveButton: TBitBtn
 | 
			
		||||
    AnchorSideTop.Control = CancelButton
 | 
			
		||||
    AnchorSideRight.Control = CancelButton
 | 
			
		||||
    AnchorSideBottom.Control = Owner
 | 
			
		||||
    AnchorSideBottom.Side = asrBottom
 | 
			
		||||
    Left = 383
 | 
			
		||||
    Height = 26
 | 
			
		||||
    Top = 203
 | 
			
		||||
    Width = 82
 | 
			
		||||
    Anchors = [akTop, akRight, akBottom]
 | 
			
		||||
    AutoSize = True
 | 
			
		||||
  object FileLabel: TLabel
 | 
			
		||||
    AnchorSideLeft.Control = HistoryLabel
 | 
			
		||||
    AnchorSideTop.Control = HistoryLabel
 | 
			
		||||
    AnchorSideTop.Side = asrBottom
 | 
			
		||||
    Left = 16
 | 
			
		||||
    Height = 15
 | 
			
		||||
    Top = 46
 | 
			
		||||
    Width = 20
 | 
			
		||||
    BorderSpacing.Top = 15
 | 
			
		||||
    Caption = 'File'
 | 
			
		||||
    ParentColor = False
 | 
			
		||||
  end
 | 
			
		||||
  object FileNameEdit: TFileNameEdit
 | 
			
		||||
    AnchorSideLeft.Control = FileLabel
 | 
			
		||||
    AnchorSideLeft.Side = asrBottom
 | 
			
		||||
    AnchorSideTop.Control = FileLabel
 | 
			
		||||
    AnchorSideTop.Side = asrCenter
 | 
			
		||||
    Left = 42
 | 
			
		||||
    Height = 25
 | 
			
		||||
    Top = 41
 | 
			
		||||
    Width = 431
 | 
			
		||||
    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 = 23
 | 
			
		||||
    NumGlyphs = 1
 | 
			
		||||
    BorderSpacing.Left = 6
 | 
			
		||||
    BorderSpacing.Right = 6
 | 
			
		||||
    BorderSpacing.Bottom = 6
 | 
			
		||||
    Caption = 'SaveButton'
 | 
			
		||||
    Constraints.MinWidth = 75
 | 
			
		||||
    NumGlyphs = 0
 | 
			
		||||
    OnClick = SaveButtonCLICK
 | 
			
		||||
    MaxLength = 0
 | 
			
		||||
    ParentShowHint = False
 | 
			
		||||
    PopupMenu = RecentPopupMenu
 | 
			
		||||
    TabOrder = 2
 | 
			
		||||
  end
 | 
			
		||||
  object CancelButton: TBitBtn
 | 
			
		||||
    AnchorSideRight.Control = Owner
 | 
			
		||||
    AnchorSideRight.Side = asrBottom
 | 
			
		||||
    AnchorSideBottom.Control = Owner
 | 
			
		||||
    AnchorSideBottom.Side = asrBottom
 | 
			
		||||
    Left = 471
 | 
			
		||||
    Height = 26
 | 
			
		||||
    Top = 203
 | 
			
		||||
    Width = 77
 | 
			
		||||
    Anchors = [akRight, akBottom]
 | 
			
		||||
    AutoSize = True
 | 
			
		||||
    BorderSpacing.Around = 6
 | 
			
		||||
    Cancel = True
 | 
			
		||||
    Caption = 'Cancel'
 | 
			
		||||
    Constraints.MinWidth = 75
 | 
			
		||||
    Kind = bkCancel
 | 
			
		||||
    ModalResult = 2
 | 
			
		||||
    NumGlyphs = 0
 | 
			
		||||
  object ExportRadioGroup: TRadioGroup
 | 
			
		||||
    AnchorSideLeft.Control = FileNameEdit
 | 
			
		||||
    AnchorSideLeft.Side = asrBottom
 | 
			
		||||
    Left = 488
 | 
			
		||||
    Height = 60
 | 
			
		||||
    Top = 3
 | 
			
		||||
    Width = 185
 | 
			
		||||
    AutoFill = True
 | 
			
		||||
    BorderSpacing.Left = 15
 | 
			
		||||
    Caption = 'Save compiler options of'
 | 
			
		||||
    ChildSizing.LeftRightSpacing = 6
 | 
			
		||||
    ChildSizing.EnlargeHorizontal = crsHomogenousChildResize
 | 
			
		||||
    ChildSizing.EnlargeVertical = crsHomogenousChildResize
 | 
			
		||||
    ChildSizing.ShrinkHorizontal = crsScaleChilds
 | 
			
		||||
    ChildSizing.ShrinkVertical = crsScaleChilds
 | 
			
		||||
    ChildSizing.Layout = cclLeftToRightThenTopToBottom
 | 
			
		||||
    ChildSizing.ControlsPerLine = 1
 | 
			
		||||
    ClientHeight = 41
 | 
			
		||||
    ClientWidth = 181
 | 
			
		||||
    ItemIndex = 0
 | 
			
		||||
    Items.Strings = (
 | 
			
		||||
      'Current build mode'
 | 
			
		||||
      'All build modes'
 | 
			
		||||
    )
 | 
			
		||||
    TabOrder = 3
 | 
			
		||||
    Visible = False
 | 
			
		||||
  end
 | 
			
		||||
  object RecentPopupMenu: TPopupMenu
 | 
			
		||||
    left = 376
 | 
			
		||||
    object MenuItem1: TMenuItem
 | 
			
		||||
      Caption = 'New Item1'
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -32,46 +32,45 @@ unit ImExportCompilerOpts;
 | 
			
		||||
interface
 | 
			
		||||
 | 
			
		||||
uses
 | 
			
		||||
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
 | 
			
		||||
  Buttons, IDEProcs, FileUtil, Laz2_XMLCfg, LazFileCache, LCLType, MainIntf,
 | 
			
		||||
  LazarusIDEStrConsts, InputHistory, Project, CompilerOptions;
 | 
			
		||||
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Buttons,
 | 
			
		||||
  IDEProcs, FileUtil, Laz2_XMLCfg, LazFileCache, LCLType, EditBtn, Menus,
 | 
			
		||||
  ExtCtrls, ButtonPanel, MainIntf, LazarusIDEStrConsts, InputHistory, Project,
 | 
			
		||||
  CompilerOptions;
 | 
			
		||||
 | 
			
		||||
type
 | 
			
		||||
  { TImExportCompOptsDlg }
 | 
			
		||||
 | 
			
		||||
  TImExportCompOptsDlg = class(TForm)
 | 
			
		||||
    CancelButton: TBitBtn;
 | 
			
		||||
    OpenButton: TBitBtn;
 | 
			
		||||
    SaveButton: TBitBtn;
 | 
			
		||||
    SaveToRecentButton: TBUTTON;
 | 
			
		||||
    OpenRecentButton: TBUTTON;
 | 
			
		||||
    RecentListbox: TLISTBOX;
 | 
			
		||||
    OpenRecentGroupbox: TGROUPBOX;
 | 
			
		||||
    ButtonPanel1: TButtonPanel;
 | 
			
		||||
    ExportRadioGroup: TRadioGroup;
 | 
			
		||||
    FileLabel: TLabel;
 | 
			
		||||
    FileNameEdit: TFileNameEdit;
 | 
			
		||||
    HistoryLabel: TLabel;
 | 
			
		||||
    MenuItem1: TMenuItem;
 | 
			
		||||
    HistoryButton: TButton;
 | 
			
		||||
    RecentPopupMenu: TPopupMenu;
 | 
			
		||||
    procedure ImExportCompOptsDlgCLOSE(Sender: TObject; var CloseAction: TCloseAction);
 | 
			
		||||
    procedure ImExportCompOptsDlgCREATE(Sender: TObject);
 | 
			
		||||
    procedure OpenButtonCLICK(Sender: TObject);
 | 
			
		||||
    procedure OpenRecentButtonCLICK(Sender: TObject);
 | 
			
		||||
    procedure RecentListboxCLICK(Sender: TObject);
 | 
			
		||||
    procedure RecentListboxDBLCLICK(Sender: TObject);
 | 
			
		||||
    procedure PopupClick(Sender: TObject);
 | 
			
		||||
    procedure HistoryButtonClick(Sender: TObject);
 | 
			
		||||
    procedure RecentSaveButton1Click(Sender: TObject);
 | 
			
		||||
    procedure SaveButtonCLICK(Sender: TObject);
 | 
			
		||||
    procedure SaveToRecentButtonCLICK(Sender: TObject);
 | 
			
		||||
  private
 | 
			
		||||
    FFilename: string;
 | 
			
		||||
    FImExportResult: TImportExportOptionsResult;
 | 
			
		||||
    procedure InitExport;
 | 
			
		||||
    procedure InitImport;
 | 
			
		||||
    procedure LoadRecentList;
 | 
			
		||||
    procedure SaveRecentList;
 | 
			
		||||
    procedure UpdateRecentButtons;
 | 
			
		||||
    //procedure SaveRecentList;
 | 
			
		||||
    procedure SetFilename(const AValue: string);
 | 
			
		||||
    procedure SetImExportResult(const AValue: TImportExportOptionsResult);
 | 
			
		||||
    procedure DoOpenFile(const AFilename: string);
 | 
			
		||||
    procedure DoSaveFile(const AFilename: string);
 | 
			
		||||
  public
 | 
			
		||||
    property ImExportResult: TImportExportOptionsResult read FImExportResult
 | 
			
		||||
                                                        write SetImExportResult;
 | 
			
		||||
    property Filename: string read FFilename write SetFilename;
 | 
			
		||||
  end;
 | 
			
		||||
 | 
			
		||||
function ShowImExportCompilerOptionsDialog(var Filename: string): TImportExportOptionsResult;
 | 
			
		||||
function ShowImportCompilerOptionsDialog(var Filename: string): TModalResult;
 | 
			
		||||
function ShowExportCompilerOptionsDialog(var Filename: string): TModalResult;
 | 
			
		||||
 | 
			
		||||
function DoImportCompilerOptions(const Filename: string): TModalResult;
 | 
			
		||||
function DoExportCompilerOptions(const Filename: string): TModalResult;
 | 
			
		||||
@ -83,6 +82,36 @@ implementation
 | 
			
		||||
const
 | 
			
		||||
  DefaultCompilerOptPath = 'CompilerOptions/';
 | 
			
		||||
 | 
			
		||||
function ShowImportCompilerOptionsDialog(var Filename: string): TModalResult;
 | 
			
		||||
var
 | 
			
		||||
  ImExportCompOptsDlg: TImExportCompOptsDlg;
 | 
			
		||||
begin
 | 
			
		||||
  ImExportCompOptsDlg := TImExportCompOptsDlg.Create(nil);
 | 
			
		||||
  try
 | 
			
		||||
    ImExportCompOptsDlg.InitImport;
 | 
			
		||||
    Result := ImExportCompOptsDlg.ShowModal;
 | 
			
		||||
    if Result = mrOk then
 | 
			
		||||
      Filename := ImExportCompOptsDlg.Filename;
 | 
			
		||||
  finally
 | 
			
		||||
    ImExportCompOptsDlg.Free;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function ShowExportCompilerOptionsDialog(var Filename: string): TModalResult;
 | 
			
		||||
var
 | 
			
		||||
  ImExportCompOptsDlg: TImExportCompOptsDlg;
 | 
			
		||||
begin
 | 
			
		||||
  ImExportCompOptsDlg := TImExportCompOptsDlg.Create(nil);
 | 
			
		||||
  try
 | 
			
		||||
    ImExportCompOptsDlg.InitExport;
 | 
			
		||||
    Result := ImExportCompOptsDlg.ShowModal;
 | 
			
		||||
    if Result = mrOk then
 | 
			
		||||
      Filename := ImExportCompOptsDlg.Filename;
 | 
			
		||||
  finally
 | 
			
		||||
    ImExportCompOptsDlg.Free;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function ReadIntFromXMLConfig(const Filename, Path: string;
 | 
			
		||||
  DefaultValue, ValueForReadError: integer): integer;
 | 
			
		||||
var
 | 
			
		||||
@ -126,20 +155,6 @@ begin
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function ShowImExportCompilerOptionsDialog(var Filename: string): TImportExportOptionsResult;
 | 
			
		||||
var
 | 
			
		||||
  ImExportCompOptsDlg: TImExportCompOptsDlg;
 | 
			
		||||
begin
 | 
			
		||||
  Result := ieorCancel;
 | 
			
		||||
  ImExportCompOptsDlg := TImExportCompOptsDlg.Create(nil);
 | 
			
		||||
  if ImExportCompOptsDlg.ShowModal = mrOk then
 | 
			
		||||
  begin
 | 
			
		||||
    Result := ImExportCompOptsDlg.ImExportResult;
 | 
			
		||||
    Filename := ImExportCompOptsDlg.Filename;
 | 
			
		||||
  end;
 | 
			
		||||
  ImExportCompOptsDlg.Free;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function DoImportCompilerOptions(const Filename: string): TModalResult;
 | 
			
		||||
var
 | 
			
		||||
  XMLConfig: TXMLConfig;
 | 
			
		||||
@ -192,126 +207,105 @@ end;
 | 
			
		||||
 | 
			
		||||
{ TImExportCompOptsDlg }
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.InitImport;
 | 
			
		||||
begin
 | 
			
		||||
  Caption:=lisIECOImportCompilerOptions;
 | 
			
		||||
  FileNameEdit.Filter:='XML file (*.xml)|*.xml|'
 | 
			
		||||
                      +'Project file (*.lpi)|*.lpi|'
 | 
			
		||||
                      +'Package file (*.lpk)|*.lpk|'
 | 
			
		||||
                      //+'Session file (*.lps)|*.lps|'
 | 
			
		||||
                      +'All files (*)|*';
 | 
			
		||||
  FileNameEdit.DialogOptions:=FileNameEdit.DialogOptions+[ofFileMustExist];
 | 
			
		||||
  ExportRadioGroup.Visible:=False;
 | 
			
		||||
  with ButtonPanel1 do begin
 | 
			
		||||
    OKButton.Caption:=lisIECOLoadFromFile;
 | 
			
		||||
    OKButton.LoadGlyphFromStock(idButtonOpen);
 | 
			
		||||
    if OKButton.Glyph.Empty then
 | 
			
		||||
      OKButton.LoadGlyphFromResourceName(HInstance, 'laz_open');
 | 
			
		||||
    OKButton.OnClick:=@OpenButtonCLICK;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.InitExport;
 | 
			
		||||
begin
 | 
			
		||||
  Caption:=lisIECOExportCompilerOptions;
 | 
			
		||||
  FileNameEdit.Filter:='XML file (*.xml)|*.xml|All files (*)|*';
 | 
			
		||||
  FileNameEdit.DialogKind:=dkSave;
 | 
			
		||||
  with ButtonPanel1 do begin
 | 
			
		||||
    OKButton.Caption:=lisIECOSaveToFile;
 | 
			
		||||
    OKButton.LoadGlyphFromStock(idButtonSave);
 | 
			
		||||
    if OKButton.Glyph.Empty then
 | 
			
		||||
      OKButton.LoadGlyphFromResourceName(HInstance, 'laz_save');
 | 
			
		||||
    OKButton.OnClick:=@SaveButtonCLICK;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.ImExportCompOptsDlgCREATE(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  ImExportResult:=ieorCancel;
 | 
			
		||||
  
 | 
			
		||||
  Caption:=lisIECOLoadOrSaveCompilerOptions;
 | 
			
		||||
  OpenRecentGroupbox.Caption:=lisIECORecentFiles;
 | 
			
		||||
  SaveToRecentButton.Caption:=lisIECOSaveToRecent;
 | 
			
		||||
  OpenRecentButton.Caption:=lisIECOLoadRecent;
 | 
			
		||||
  SaveButton.Caption:=lisIECOSaveToFile;
 | 
			
		||||
  OpenButton.Caption:=lisIECOLoadFromFile;
 | 
			
		||||
  CancelButton.Caption:=lisCancel;
 | 
			
		||||
  OpenButton.LoadGlyphFromStock(idButtonOpen);
 | 
			
		||||
  if OpenButton.Glyph.Empty then
 | 
			
		||||
    OpenButton.LoadGlyphFromResourceName(HInstance, 'laz_open');
 | 
			
		||||
  SaveButton.LoadGlyphFromStock(idButtonSave);
 | 
			
		||||
  if SaveButton.Glyph.Empty then
 | 
			
		||||
    SaveButton.LoadGlyphFromResourceName(HInstance, 'laz_save');
 | 
			
		||||
  HistoryLabel.Caption:=lisIECORecentFiles;
 | 
			
		||||
  HistoryLabel.Hint:=lisIECORecentFiles;
 | 
			
		||||
  FileLabel.Caption:=lisFile;
 | 
			
		||||
  LoadRecentList;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.OpenButtonCLICK(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  AFilename: String;
 | 
			
		||||
  OpenDialog: TOpenDialog;
 | 
			
		||||
begin
 | 
			
		||||
  AFilename:='';
 | 
			
		||||
  OpenDialog:=TOpenDialog.Create(nil);
 | 
			
		||||
  try
 | 
			
		||||
    InputHistories.ApplyFileDialogSettings(OpenDialog);
 | 
			
		||||
    OpenDialog.Title:=lisOpenFile;
 | 
			
		||||
    OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist];
 | 
			
		||||
    if OpenDialog.Execute then begin
 | 
			
		||||
      AFilename:=CleanAndExpandFilename(OpenDialog.Filename);
 | 
			
		||||
      DoOpenFile(AFilename);
 | 
			
		||||
    end;
 | 
			
		||||
    InputHistories.StoreFileDialogSettings(OpenDialog);
 | 
			
		||||
  finally
 | 
			
		||||
    OpenDialog.Free;
 | 
			
		||||
  end;
 | 
			
		||||
  DoOpenFile(CleanAndExpandFilename(FileNameEdit.FileName));
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.OpenRecentButtonCLICK(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  i: Integer;
 | 
			
		||||
procedure TImExportCompOptsDlg.PopupClick(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  i:=RecentListbox.ItemIndex;
 | 
			
		||||
  if i<0 then exit;
 | 
			
		||||
  DoOpenFile(RecentListbox.Items[i]);
 | 
			
		||||
  FileNameEdit.Text := (Sender as TMenuItem).Caption;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.RecentListboxCLICK(Sender: TObject);
 | 
			
		||||
procedure TImExportCompOptsDlg.HistoryButtonClick(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  UpdateRecentButtons;
 | 
			
		||||
  RecentPopupMenu.PopUp;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.RecentListboxDBLCLICK(Sender: TObject);
 | 
			
		||||
procedure TImExportCompOptsDlg.RecentSaveButton1Click(Sender: TObject);
 | 
			
		||||
begin
 | 
			
		||||
  OpenRecentButtonCLICK(Sender);
 | 
			
		||||
  RecentPopupMenu.PopUp;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.SaveButtonCLICK(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  AFilename: String;
 | 
			
		||||
  SaveDialog: TSaveDialog;
 | 
			
		||||
begin
 | 
			
		||||
  AFilename:='';
 | 
			
		||||
  SaveDialog:=TSaveDialog.Create(nil);
 | 
			
		||||
  try
 | 
			
		||||
    InputHistories.ApplyFileDialogSettings(SaveDialog);
 | 
			
		||||
    SaveDialog.Title:=lisOpenFile;
 | 
			
		||||
    if SaveDialog.Execute then begin
 | 
			
		||||
      AFilename:=CleanAndExpandFilename(SaveDialog.Filename);
 | 
			
		||||
      DoSaveFile(AFilename);
 | 
			
		||||
    end;
 | 
			
		||||
    InputHistories.StoreFileDialogSettings(SaveDialog);
 | 
			
		||||
  finally
 | 
			
		||||
    SaveDialog.Free;
 | 
			
		||||
  end;
 | 
			
		||||
  DoSaveFile(CleanAndExpandFilename(FileNameEdit.FileName));
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.SaveToRecentButtonCLICK(Sender: TObject);
 | 
			
		||||
var
 | 
			
		||||
  i: Integer;
 | 
			
		||||
procedure TImExportCompOptsDlg.ImExportCompOptsDlgCLOSE(Sender: TObject; var CloseAction: TCloseAction);
 | 
			
		||||
begin
 | 
			
		||||
  i:=RecentListbox.ItemIndex;
 | 
			
		||||
  if i<0 then exit;
 | 
			
		||||
  DoSaveFile(RecentListbox.Items[i]);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.ImExportCompOptsDlgCLOSE(Sender: TObject;
 | 
			
		||||
  var CloseAction: TCloseAction);
 | 
			
		||||
begin
 | 
			
		||||
  SaveRecentList;
 | 
			
		||||
  //SaveRecentList;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.LoadRecentList;
 | 
			
		||||
var
 | 
			
		||||
  sl: TStringList;
 | 
			
		||||
  mi: TMenuItem;
 | 
			
		||||
  i: Integer;
 | 
			
		||||
begin
 | 
			
		||||
  RecentListbox.Items.Assign(
 | 
			
		||||
    InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile));
 | 
			
		||||
  if RecentListbox.Items.Count>0 then
 | 
			
		||||
    RecentListbox.ItemIndex:=0;
 | 
			
		||||
  UpdateRecentButtons;
 | 
			
		||||
  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;
 | 
			
		||||
  finally
 | 
			
		||||
    sl.Free;
 | 
			
		||||
  end;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
{
 | 
			
		||||
procedure TImExportCompOptsDlg.SaveRecentList;
 | 
			
		||||
begin
 | 
			
		||||
  InputHistories.HistoryLists.GetList(hlCompilerOptsImExport,true,rltFile).Assign(
 | 
			
		||||
    RecentListbox.Items);
 | 
			
		||||
  InputHistories.Save;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.UpdateRecentButtons;
 | 
			
		||||
var
 | 
			
		||||
  RecentSelected: boolean;
 | 
			
		||||
begin
 | 
			
		||||
  RecentSelected:=RecentListbox.ItemIndex>=0;
 | 
			
		||||
  OpenRecentButton.Enabled:=RecentSelected;
 | 
			
		||||
  SaveToRecentButton.Enabled:=RecentSelected;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
procedure TImExportCompOptsDlg.SetFilename(const AValue: string);
 | 
			
		||||
begin
 | 
			
		||||
  if FFilename=AValue then exit;
 | 
			
		||||
@ -320,18 +314,10 @@ begin
 | 
			
		||||
  LoadRecentList;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.SetImExportResult(
 | 
			
		||||
  const AValue: TImportExportOptionsResult);
 | 
			
		||||
begin
 | 
			
		||||
  if FImExportResult=AValue then exit;
 | 
			
		||||
  FImExportResult:=AValue;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TImExportCompOptsDlg.DoOpenFile(const AFilename: string);
 | 
			
		||||
begin
 | 
			
		||||
  if DirPathExists(AFilename) then exit;
 | 
			
		||||
  Filename := AFilename;
 | 
			
		||||
  ImExportResult := ieorImport;
 | 
			
		||||
  ModalResult := mrOk;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
@ -340,15 +326,17 @@ var
 | 
			
		||||
  MsgResult: TModalResult;
 | 
			
		||||
begin
 | 
			
		||||
  if DirPathExists(AFilename) then exit;
 | 
			
		||||
  Filename:=AFilename;
 | 
			
		||||
  if FileExistsUTF8(AFilename) then begin
 | 
			
		||||
  if ExtractFileExt(AFilename) = '' then
 | 
			
		||||
    Filename:=AFilename + '.xml'
 | 
			
		||||
  else
 | 
			
		||||
    Filename:=AFilename;
 | 
			
		||||
  if FileExistsUTF8(Filename) then begin
 | 
			
		||||
    MsgResult:=MessageDlg(lisIECOExportFileExists,
 | 
			
		||||
      Format(lisIECOExportFileExistsOpenFileAndReplaceOnlyCompilerOpti,
 | 
			
		||||
             [AFilename, LineEnding, LineEnding]),
 | 
			
		||||
             [Filename, LineEnding, LineEnding]),
 | 
			
		||||
      mtConfirmation,[mbYes,mbCancel],0);
 | 
			
		||||
    if MsgResult<>mrYes then exit;
 | 
			
		||||
  end;
 | 
			
		||||
  ImExportResult := ieorExport;
 | 
			
		||||
  ModalResult := mrOk;
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -930,14 +930,13 @@ resourcestring
 | 
			
		||||
  lisIECOExportFileExistsOpenFileAndReplaceOnlyCompilerOpti = 'Export file "%s" exists.'
 | 
			
		||||
    +'%sOpen file and replace only compiler options?'
 | 
			
		||||
    +'%s(Other settings will be kept.)';
 | 
			
		||||
  lisIECOLoadOrSaveCompilerOptions = 'Load or Save Compiler Options';
 | 
			
		||||
  lisIECOImportCompilerOptions = 'Import Compiler Options';
 | 
			
		||||
  lisIECOExportCompilerOptions = 'Export Compiler Options';
 | 
			
		||||
  lisIECOErrorAccessingXml = 'Error accessing xml';
 | 
			
		||||
  lisIECOErrorLoadingXml = 'Error loading xml';
 | 
			
		||||
  lisIECOErrorLoadingXmlFile = 'Error loading xml file "%s":%s%s';
 | 
			
		||||
  lisIECOErrorAccessingXmlFile = 'Error accessing xml file "%s":%s%s';
 | 
			
		||||
  lisIECORecentFiles = 'Recent files';
 | 
			
		||||
  lisIECOSaveToRecent = 'Save to recent';
 | 
			
		||||
  lisIECOLoadRecent = 'Load recent';
 | 
			
		||||
  lisIECOSaveToFile = 'Save to file';
 | 
			
		||||
  lisIECOLoadFromFile = 'Load from file';
 | 
			
		||||
  lisLazarusFile = 'Lazarus file';
 | 
			
		||||
@ -2132,7 +2131,6 @@ resourcestring
 | 
			
		||||
  dlgUnitOutp = 'Unit output directory (-FU):';
 | 
			
		||||
  dlgCOShowOptions = '&Show Options';
 | 
			
		||||
  lisCompTest = '&Test';
 | 
			
		||||
  lisLoadSave = 'Load/Save';
 | 
			
		||||
  dlgCOLoadSave = 'Compiler options can be saved to an XML file.';
 | 
			
		||||
  dlgMainViewForms = 'View Project Forms';
 | 
			
		||||
  dlgMainViewUnits = 'View Project Units';
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										27
									
								
								ide/main.pp
									
									
									
									
									
								
							
							
						
						
									
										27
									
								
								ide/main.pp
									
									
									
									
									
								
							@ -818,8 +818,8 @@ type
 | 
			
		||||
                               Flags: TOpenFlags): TModalResult; override;
 | 
			
		||||
    function DoPublishProject(Flags: TSaveFlags;
 | 
			
		||||
                              ShowDialog: boolean): TModalResult; override;
 | 
			
		||||
    function DoImExportCompilerOptions(
 | 
			
		||||
      out ImportExportResult: TImportExportOptionsResult): TModalResult; override;
 | 
			
		||||
    function ImportCompilerOptions: TModalResult; override;
 | 
			
		||||
    function ExportCompilerOptions: TModalResult; override;
 | 
			
		||||
    procedure DoShowProjectInspector(Show: boolean); override;
 | 
			
		||||
    function DoAddActiveUnitToProject: TModalResult;
 | 
			
		||||
    function DoRemoveFromProjectDialog: TModalResult;
 | 
			
		||||
@ -6403,19 +6403,22 @@ begin
 | 
			
		||||
    Project1.ProjectDirectory, MainBuildBoss.GetProjectPublishDir);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function TMainIDE.DoImExportCompilerOptions(
 | 
			
		||||
  out ImportExportResult: TImportExportOptionsResult): TModalResult;
 | 
			
		||||
function TMainIDE.ImportCompilerOptions: TModalResult;
 | 
			
		||||
var
 | 
			
		||||
  //Options: TCompilerOptions;
 | 
			
		||||
  Filename: string;
 | 
			
		||||
begin
 | 
			
		||||
  Result := mrOk;
 | 
			
		||||
  ImportExportResult := ShowImExportCompilerOptionsDialog(Filename);
 | 
			
		||||
  if Filename='' then Exit(mrCancel);
 | 
			
		||||
  case ImportExportResult of
 | 
			
		||||
    ieorImport: Result := DoImportCompilerOptions(Filename);
 | 
			
		||||
    ieorExport: Result := DoExportCompilerOptions(Filename);
 | 
			
		||||
  end;
 | 
			
		||||
  Result := ShowImportCompilerOptionsDialog(Filename);
 | 
			
		||||
  if Result = mrOK then
 | 
			
		||||
    Result := DoImportCompilerOptions(Filename);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
function TMainIDE.ExportCompilerOptions: TModalResult;
 | 
			
		||||
var
 | 
			
		||||
  Filename: string;
 | 
			
		||||
begin
 | 
			
		||||
  Result := ShowExportCompilerOptionsDialog(Filename);
 | 
			
		||||
  if Result = mrOK then
 | 
			
		||||
    Result := DoExportCompilerOptions(Filename);
 | 
			
		||||
end;
 | 
			
		||||
 | 
			
		||||
procedure TMainIDE.DoShowProjectInspector(Show: boolean);
 | 
			
		||||
 | 
			
		||||
@ -108,13 +108,6 @@ type
 | 
			
		||||
    );
 | 
			
		||||
  TCodeToolsFlags = set of TCodeToolsFlag;
 | 
			
		||||
 | 
			
		||||
  // import/export compiler options result
 | 
			
		||||
  TImportExportOptionsResult = (
 | 
			
		||||
    ieorCancel,
 | 
			
		||||
    ieorImport,
 | 
			
		||||
    ieorExport
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
  TJumpToCodePosFlag = (
 | 
			
		||||
    jfAddJumpPoint,
 | 
			
		||||
    jfFocusEditor,
 | 
			
		||||
@ -166,7 +159,8 @@ type
 | 
			
		||||
        const AFilename: string): TModalResult; virtual; abstract;
 | 
			
		||||
 | 
			
		||||
    procedure DoShowProjectInspector(Show: boolean); virtual; abstract;
 | 
			
		||||
    function DoImExportCompilerOptions(out ImportExportResult: TImportExportOptionsResult): TModalResult; virtual; abstract;
 | 
			
		||||
    function ImportCompilerOptions: TModalResult; virtual; abstract;
 | 
			
		||||
    function ExportCompilerOptions: TModalResult; virtual; abstract;
 | 
			
		||||
 | 
			
		||||
    function PrepareForCompile: TModalResult; virtual; abstract; // stop things that interfere with compilation, like debugging
 | 
			
		||||
    function DoSaveBuildIDEConfigs(Flags: TBuildLazarusFlags): TModalResult; virtual; abstract;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user