pas2js: browse buttons

This commit is contained in:
mattias 2024-04-05 10:45:43 +02:00
parent 8b0b1fba22
commit 53321a2b49
2 changed files with 108 additions and 11 deletions

View File

@ -1,7 +1,7 @@
object Pas2jsInstallerDialog: TPas2jsInstallerDialog object Pas2jsInstallerDialog: TPas2jsInstallerDialog
Left = 317 Left = 126
Height = 547 Height = 547
Top = 243 Top = 129
Width = 574 Width = 574
Caption = 'Pas2jsInstallerDialog' Caption = 'Pas2jsInstallerDialog'
ClientHeight = 547 ClientHeight = 547
@ -52,6 +52,7 @@ object Pas2jsInstallerDialog: TPas2jsInstallerDialog
Caption = 'Apply' Caption = 'Apply'
Constraints.MinWidth = 75 Constraints.MinWidth = 75
TabOrder = 1 TabOrder = 1
OnClick = ApplyButtonClick
end end
end end
object Pas2jsSrcDirGroupBox: TGroupBox object Pas2jsSrcDirGroupBox: TGroupBox
@ -114,6 +115,7 @@ object Pas2jsInstallerDialog: TPas2jsInstallerDialog
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 1 TabOrder = 1
OnClick = Pas2jsSrcDirBrowseBtnClick
end end
end end
object FPCGroupBox: TGroupBox object FPCGroupBox: TGroupBox
@ -167,6 +169,7 @@ object Pas2jsInstallerDialog: TPas2jsInstallerDialog
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 1 TabOrder = 1
OnClick = FPCExeBrowseButtonClick
end end
object FPCSrcDirVersionLabel: TLabel object FPCSrcDirVersionLabel: TLabel
AnchorSideLeft.Control = FPCGroupBox AnchorSideLeft.Control = FPCGroupBox
@ -213,6 +216,7 @@ object Pas2jsInstallerDialog: TPas2jsInstallerDialog
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 3 TabOrder = 3
OnClick = FPCSrcDirBrowseButtonClick
end end
object FPCExeLabel: TLabel object FPCExeLabel: TLabel
AnchorSideTop.Control = FPCGroupBox AnchorSideTop.Control = FPCGroupBox

View File

@ -6,7 +6,7 @@ interface
uses uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls, Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
StrPas2JSDesign, PJSDsgnOptions, IDEUtils, LazFileUtils; StrPas2JSDesign, PJSDsgnOptions, PJSController, IDEUtils, LazFileUtils;
type type
@ -33,9 +33,13 @@ type
Pas2jsSrcDirComboBox: TComboBox; Pas2jsSrcDirComboBox: TComboBox;
Pas2jsSrcDirGroupBox: TGroupBox; Pas2jsSrcDirGroupBox: TGroupBox;
Pas2jsSrcVersionLabel: TLabel; Pas2jsSrcVersionLabel: TLabel;
procedure ApplyButtonClick(Sender: TObject);
procedure CloseButtonClick(Sender: TObject); procedure CloseButtonClick(Sender: TObject);
procedure FormCreate(Sender: TObject); procedure FormCreate(Sender: TObject);
procedure FPCExeBrowseButtonClick(Sender: TObject);
procedure FPCSrcDirBrowseButtonClick(Sender: TObject);
procedure Pas2jsExeBrowseButtonClick(Sender: TObject); procedure Pas2jsExeBrowseButtonClick(Sender: TObject);
procedure Pas2jsSrcDirBrowseBtnClick(Sender: TObject);
private private
FLastCheckedPas2jsExe: String; FLastCheckedPas2jsExe: String;
FLastCheckedPas2jsSrcDir: String; FLastCheckedPas2jsSrcDir: String;
@ -96,6 +100,48 @@ begin
CloseButton.Caption:='Close'; CloseButton.Caption:='Close';
end; end;
procedure TPas2jsInstallerDialog.FPCExeBrowseButtonClick(Sender: TObject);
var
aDialog: TOpenDialog;
AFilename: String;
begin
aDialog:=TOpenDialog.Create(nil);
try
//InputHistories.ApplyFileDialogSettings(aDialog);
aDialog.Options:=aDialog.Options+[ofPathMustExist];
aDialog.Title:='Select Free Pascal Compiler executable';
if aDialog.Execute then begin
AFilename:=CleanAndExpandFilename(aDialog.Filename);
SetComboBoxText(FPCExeComboBox,AFilename,cstFilename,30);
// ToDo CheckCompiler([mbOk]);
UpdateButtons;
end;
finally
aDialog.Free;
end;
end;
procedure TPas2jsInstallerDialog.FPCSrcDirBrowseButtonClick(Sender: TObject);
var
aDialog: TSelectDirectoryDialog;
AFilename: String;
begin
aDialog:=TSelectDirectoryDialog.Create(nil);
try
//InputHistories.ApplyFileDialogSettings(aDialog);
aDialog.Options:=aDialog.Options+[ofPathMustExist];
aDialog.Title:='Select Free Pascal source directory';
if aDialog.Execute then begin
AFilename:=CleanAndExpandDirectory(aDialog.Filename);
SetComboBoxText(FPCSrcDirComboBox,AFilename,cstFilename,30);
// ToDo CheckCompiler([mbOk]);
UpdateButtons;
end;
finally
aDialog.Free;
end;
end;
procedure TPas2jsInstallerDialog.CloseButtonClick(Sender: TObject); procedure TPas2jsInstallerDialog.CloseButtonClick(Sender: TObject);
begin begin
// restore options // restore options
@ -112,23 +158,68 @@ begin
ModalResult:=mrCancel; ModalResult:=mrCancel;
end; end;
procedure TPas2jsInstallerDialog.ApplyButtonClick(Sender: TObject);
var
CurPas2jsExe, CurPas2jsSrcDir, CurFPCExe, CurFPCSrcDir: TCaption;
begin
CurPas2jsExe:=Pas2jsExeComboBox.Text;
CurPas2jsSrcDir:=Pas2jsSrcDirComboBox.Text;
CurFPCExe:=FPCExeComboBox.Text;
CurFPCSrcDir:=FPCSrcDirComboBox.Text;
// todo: sanity check
PJSOptions.CompilerFilename:=CurPas2jsExe;
PJSOptions.Pas2jsSrcDir:=CurPas2jsSrcDir;
PJSOptions.FPCExe:=CurFPCExe;
PJSOptions.FPCSrcDir:=CurFPCSrcDir;
TPJSController.Instance.StoreMacros;
If PJSOptions.Modified then
PJSOptions.Save;
UpdateButtons;
end;
procedure TPas2jsInstallerDialog.Pas2jsExeBrowseButtonClick(Sender: TObject); procedure TPas2jsInstallerDialog.Pas2jsExeBrowseButtonClick(Sender: TObject);
var var
OpenDialog: TOpenDialog; aDialog: TOpenDialog;
AFilename: String; AFilename: String;
begin begin
OpenDialog:=TOpenDialog.Create(nil); aDialog:=TOpenDialog.Create(nil);
try try
//InputHistories.ApplyFileDialogSettings(OpenDialog); //InputHistories.ApplyFileDialogSettings(aDialog);
OpenDialog.Options:=OpenDialog.Options+[ofPathMustExist]; aDialog.Options:=aDialog.Options+[ofPathMustExist];
OpenDialog.Title:=pjsdSelectPas2jsExecutable; aDialog.Title:=pjsdSelectPas2jsExecutable;
if OpenDialog.Execute then begin if aDialog.Execute then begin
AFilename:=CleanAndExpandFilename(OpenDialog.Filename); AFilename:=CleanAndExpandFilename(aDialog.Filename);
SetComboBoxText(Pas2jsExeComboBox,AFilename,cstFilename,30); SetComboBoxText(Pas2jsExeComboBox,AFilename,cstFilename,30);
// ToDo CheckCompiler([mbOk]); // ToDo CheckCompiler([mbOk]);
UpdateButtons;
end; end;
finally finally
OpenDialog.Free; aDialog.Free;
end;
end;
procedure TPas2jsInstallerDialog.Pas2jsSrcDirBrowseBtnClick(Sender: TObject);
var
aDialog: TSelectDirectoryDialog;
AFilename: String;
begin
aDialog:=TSelectDirectoryDialog.Create(nil);
try
//InputHistories.ApplyFileDialogSettings(aDialog);
aDialog.Options:=aDialog.Options+[ofPathMustExist];
aDialog.Title:='Select pas2js source directory';
if aDialog.Execute then begin
AFilename:=CleanAndExpandDirectory(aDialog.Filename);
SetComboBoxText(Pas2jsSrcDirComboBox,AFilename,cstFilename,30);
// ToDo CheckCompiler([mbOk]);
UpdateButtons;
end;
finally
aDialog.Free;
end; end;
end; end;
@ -191,6 +282,8 @@ begin
SetComboBoxText(FPCSrcDirComboBox,PJSOptions.FPCSrcDir,cstFilename,30); SetComboBoxText(FPCSrcDirComboBox,PJSOptions.FPCSrcDir,cstFilename,30);
UpdateButtons; UpdateButtons;
end; end;
end. end.