mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-12 09:59:17 +02:00
IDE: Accept a dropped project info file to Project Wizard. Solves issue #41536.
(cherry picked from commit 63933a901f
)
This commit is contained in:
parent
80b883e644
commit
c2837850e3
@ -6527,7 +6527,7 @@ begin
|
||||
mnuNewProjectClicked(Sender);
|
||||
tpws_open:
|
||||
mnuOpenProjectClicked(Sender);
|
||||
tpws_openRecent:
|
||||
tpws_openRecent, tpws_droppedProject:
|
||||
begin
|
||||
ARecentProject := ExpandFileNameUTF8(ARecentProject);
|
||||
if DoOpenProjectFile(ARecentProject, [ofAddToRecent]) <> mrOk then
|
||||
|
@ -4,14 +4,19 @@ object ProjectWizardDialog: TProjectWizardDialog
|
||||
Top = 322
|
||||
Width = 572
|
||||
ActiveControl = btnNewProject
|
||||
AllowDropFiles = True
|
||||
BorderIcons = [biSystemMenu]
|
||||
Caption = 'Project Wizard '
|
||||
ClientHeight = 294
|
||||
ClientWidth = 572
|
||||
DragMode = dmAutomatic
|
||||
Position = poScreenCenter
|
||||
LCLVersion = '3.99.0.0'
|
||||
LCLVersion = '4.99.0.0'
|
||||
OnClose = FormClose
|
||||
OnCreate = FormCreate
|
||||
OnDragDrop = FormDragDrop
|
||||
OnDragOver = FormDragOver
|
||||
OnDropFiles = FormDropFiles
|
||||
object btnNewProject: TBitBtn
|
||||
AnchorSideTop.Control = Owner
|
||||
AnchorSideRight.Side = asrBottom
|
||||
|
@ -31,6 +31,8 @@ uses
|
||||
Classes, SysUtils,
|
||||
// LCL
|
||||
Forms, Controls, StdCtrls, Graphics, Dialogs, Buttons,
|
||||
// LazUtils
|
||||
LazFileUtils, LazLoggerBase,
|
||||
// BuildIntf
|
||||
PackageIntf,
|
||||
// IdeIntf
|
||||
@ -43,6 +45,7 @@ type
|
||||
tpws_new,
|
||||
tpws_open,
|
||||
tpws_openRecent,
|
||||
tpws_droppedProject,
|
||||
tpws_examples,
|
||||
tpws_convert,
|
||||
tpws_closeIDE
|
||||
@ -66,24 +69,30 @@ type
|
||||
procedure cbRecentProjectsSelect(Sender: TObject);
|
||||
procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure FormDragDrop(Sender, Source: TObject; X, Y: Integer);
|
||||
procedure FormDragOver(Sender, Source: TObject; X, Y: Integer;
|
||||
State: TDragState; var Accept: Boolean);
|
||||
procedure FormDropFiles(Sender: TObject; const FileNames: array of string);
|
||||
private
|
||||
FResult: TProjectWizardSelectionType;
|
||||
FDroppedProjectInfo: string;
|
||||
public
|
||||
property Result: TProjectWizardSelectionType read FResult;
|
||||
end;
|
||||
property DroppedProjectInfo: string read FDroppedProjectInfo;
|
||||
end;
|
||||
|
||||
function ShowProjectWizardDlg(out ARecentProject: String): TProjectWizardSelectionType;
|
||||
function ShowProjectWizardDlg(out AProjectToOpen: String): TProjectWizardSelectionType;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.lfm}
|
||||
|
||||
function ShowProjectWizardDlg(out ARecentProject: String): TProjectWizardSelectionType;
|
||||
function ShowProjectWizardDlg(out AProjectToOpen: String): TProjectWizardSelectionType;
|
||||
var
|
||||
ProjectWizardDialog: TProjectWizardDialog;
|
||||
begin
|
||||
Result := tpws_closeIDE;
|
||||
ARecentProject := '';
|
||||
AProjectToOpen := '';
|
||||
ProjectWizardDialog := TProjectWizardDialog.create(nil);
|
||||
with ProjectWizardDialog do
|
||||
begin
|
||||
@ -110,7 +119,12 @@ begin
|
||||
if ProjectWizardDialog.ShowModal <> mrOk then
|
||||
Exit;
|
||||
Result := ProjectWizardDialog.Result;
|
||||
ARecentProject := ProjectWizardDialog.cbRecentProjects.Text;
|
||||
case Result of
|
||||
tpws_openRecent:
|
||||
AProjectToOpen := ProjectWizardDialog.cbRecentProjects.Text;
|
||||
tpws_droppedProject:
|
||||
AProjectToOpen := ProjectWizardDialog.DroppedProjectInfo;
|
||||
end;
|
||||
finally
|
||||
ProjectWizardDialog.free;
|
||||
end;
|
||||
@ -160,5 +174,34 @@ begin
|
||||
IDEDialogLayoutList.ApplyLayout(self);
|
||||
end;
|
||||
|
||||
// How are FormDragDrop and FormDragOver triggered? Nothing is shown.
|
||||
procedure TProjectWizardDialog.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
|
||||
begin
|
||||
//ShowMessage('TProjectWizardDialog.FormDragDrop: Source=' + Source.ClassName);
|
||||
debugln(['TProjectWizardDialog.FormDragDrop: XY=', X,':',Y, ', Sender', Sender, ', Source=', Source]);
|
||||
end;
|
||||
|
||||
procedure TProjectWizardDialog.FormDragOver(Sender, Source: TObject; X,
|
||||
Y: Integer; State: TDragState; var Accept: Boolean);
|
||||
begin
|
||||
//ShowMessage('TProjectWizardDialog.FormDragOver: Source=' + Source.ClassName + ', State=' + IntToStr(Ord(State)));
|
||||
debugln(['TProjectWizardDialog.FormDragOver: XY=', X,':',Y, ', Sender', Sender,
|
||||
', Source=', Source, ', State=', State, ', Accept=', Accept]);
|
||||
Accept := True;
|
||||
end;
|
||||
|
||||
// This works when AllowDropFiles is enabled.
|
||||
procedure TProjectWizardDialog.FormDropFiles(Sender: TObject;
|
||||
const FileNames: array of string);
|
||||
begin
|
||||
Assert(Length(FileNames)>0, 'TProjectWizardDialog.FormDropFiles: FileNames is empty.');
|
||||
debugln(['TProjectWizardDialog.FormDropFiles File[0]=', FileNames[0]]);
|
||||
if FilenameExtIs(FileNames[0], 'lpi') then begin
|
||||
FDroppedProjectInfo := FileNames[0];
|
||||
FResult := tpws_droppedProject;
|
||||
ModalResult := mrOK;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user