mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-30 07:07:26 +01:00
Opkman: Show download/extract/install progress in the center of the work area.
git-svn-id: trunk@56691 -
This commit is contained in:
parent
687b78901e
commit
f0981a06af
@ -139,10 +139,15 @@ var
|
|||||||
begin
|
begin
|
||||||
MsgFrm := CreateMessageDialog(AMsg, ADlgType, AButtons);
|
MsgFrm := CreateMessageDialog(AMsg, ADlgType, AButtons);
|
||||||
try
|
try
|
||||||
MsgFrm.Position := poDefaultSizeOnly;
|
|
||||||
MsgFrm.FormStyle := fsSystemStayOnTop;
|
MsgFrm.FormStyle := fsSystemStayOnTop;
|
||||||
|
if AParent <> nil then
|
||||||
|
begin
|
||||||
|
MsgFrm.Position := poDefaultSizeOnly;
|
||||||
MsgFrm.Left := AParent.Left + (AParent.Width - MsgFrm.Width) div 2;
|
MsgFrm.Left := AParent.Left + (AParent.Width - MsgFrm.Width) div 2;
|
||||||
MsgFrm.Top := AParent.Top + (AParent.Height - MsgFrm.Height) div 2;
|
MsgFrm.Top := AParent.Top + (AParent.Height - MsgFrm.Height) div 2;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
MsgFrm.Position := poWorkAreaCenter;
|
||||||
Result := MsgFrm.ShowModal;
|
Result := MsgFrm.ShowModal;
|
||||||
finally
|
finally
|
||||||
MsgFrm.Free
|
MsgFrm.Free
|
||||||
|
|||||||
@ -50,20 +50,17 @@ type
|
|||||||
procedure InitOPM;
|
procedure InitOPM;
|
||||||
procedure SynchronizePackages;
|
procedure SynchronizePackages;
|
||||||
procedure AddToInstallList(const AName, AURL: String);
|
procedure AddToInstallList(const AName, AURL: String);
|
||||||
function Download(const ADstDir: String; AParentForm: TForm): TModalResult;
|
function Download(const ADstDir: String): TModalResult;
|
||||||
function Extract(const ASrcDir, ADstDir: String; AParentForm: TForm;
|
function Extract(const ASrcDir, ADstDir: String; const AIsUpdate: Boolean = False): TModalResult;
|
||||||
const AIsUpdate: Boolean = False): TModalResult;
|
function Install(var AInstallStatus: TInstallStatus; var ANeedToRebuild: Boolean): TModalResult;
|
||||||
function Install(AParentForm: TForm; var AInstallStatus: TInstallStatus;
|
|
||||||
var ANeedToRebuild: Boolean): TModalResult;
|
|
||||||
function IsInLinkList(const AName, AURL: String): Boolean;
|
function IsInLinkList(const AName, AURL: String): Boolean;
|
||||||
function ResolveDependencies(AParentForm: TForm): TModalResult;
|
function ResolveDependencies: TModalResult;
|
||||||
function CanInstallPackages(AParentForm: TForm): TModalResult;
|
function CanInstallPackages: TModalResult;
|
||||||
public
|
public
|
||||||
constructor Create;
|
constructor Create;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
public
|
public
|
||||||
function InstallPackages(APkgLinks: TList; AParentForm: TForm;
|
function InstallPackages(APkgLinks: TList; var ANeedToRebuild: Boolean): TModalResult; override;
|
||||||
var ANeedToRebuild: Boolean): TModalResult; override;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -197,7 +194,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TOPMInterfaceEx.ResolveDependencies(AParentForm: TForm): TModalResult;
|
function TOPMInterfaceEx.ResolveDependencies: TModalResult;
|
||||||
var
|
var
|
||||||
I, J: Integer;
|
I, J: Integer;
|
||||||
PackageList: TObjectList;
|
PackageList: TObjectList;
|
||||||
@ -227,9 +224,9 @@ begin
|
|||||||
if (Result = mrNone) or (Result = mrYes) then
|
if (Result = mrNone) or (Result = mrYes) then
|
||||||
begin
|
begin
|
||||||
Msg := Format(rsMainFrm_rsPackageDependency0, [TLazarusPackage(FPackagesToInstall.Items[I]).Name, DependencyPkg.Name]);
|
Msg := Format(rsMainFrm_rsPackageDependency0, [TLazarusPackage(FPackagesToInstall.Items[I]).Name, DependencyPkg.Name]);
|
||||||
Result := MessageDlgEx(Msg, mtConfirmation, [mbYes, mbYesToAll, mbNo, mbNoToAll, mbCancel], AParentForm);
|
Result := MessageDlgEx(Msg, mtConfirmation, [mbYes, mbYesToAll, mbNo, mbNoToAll, mbCancel], nil);
|
||||||
if Result in [mrNo, mrNoToAll] then
|
if Result in [mrNo, mrNoToAll] then
|
||||||
if MessageDlgEx(rsMainFrm_rsPackageDependency1, mtInformation, [mbYes, mbNo], AParentForm) <> mrYes then
|
if MessageDlgEx(rsMainFrm_rsPackageDependency1, mtInformation, [mbYes, mbNo], nil) <> mrYes then
|
||||||
Exit(mrCancel);
|
Exit(mrCancel);
|
||||||
if (Result = mrNoToAll) or (Result = mrCancel) then
|
if (Result = mrNoToAll) or (Result = mrCancel) then
|
||||||
Exit(mrCancel);
|
Exit(mrCancel);
|
||||||
@ -252,17 +249,16 @@ begin
|
|||||||
Result := mrOk;
|
Result := mrOk;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TOPMInterfaceEx.CanInstallPackages(AParentForm: TForm): TModalResult;
|
function TOPMInterfaceEx.CanInstallPackages: TModalResult;
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
LazarusPkg: TLazarusPackage;
|
LazarusPkg: TLazarusPackage;
|
||||||
MetaPkg: TMetaPackage;
|
MetaPkg: TMetaPackage;
|
||||||
begin
|
begin
|
||||||
Result := mrCancel;
|
Result := mrCancel;
|
||||||
IntfPackageListFrm := TIntfPackageListFrm.Create(AParentForm);
|
IntfPackageListFrm := TIntfPackageListFrm.Create(nil);
|
||||||
try
|
try
|
||||||
IntfPackageListFrm.PopupMode := pmExplicit;
|
IntfPackageListFrm.Position := poWorkAreaCenter;
|
||||||
IntfPackageListFrm.PopupParent := AParentForm;
|
|
||||||
IntfPackageListFrm.PopulateTree(FPackagesToInstall);
|
IntfPackageListFrm.PopulateTree(FPackagesToInstall);
|
||||||
IntfPackageListFrm.ShowModal;
|
IntfPackageListFrm.ShowModal;
|
||||||
if IntfPackageListFrm.ModalResult = mrOk then
|
if IntfPackageListFrm.ModalResult = mrOk then
|
||||||
@ -288,10 +284,11 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TOPMInterfaceEx.Download(const ADstDir: String; AParentForm: TForm): TModalResult;
|
function TOPMInterfaceEx.Download(const ADstDir: String): TModalResult;
|
||||||
begin
|
begin
|
||||||
ProgressFrm := TProgressFrm.Create(AParentForm);
|
ProgressFrm := TProgressFrm.Create(nil);
|
||||||
try
|
try
|
||||||
|
ProgressFrm.Position := poWorkAreaCenter;
|
||||||
ProgressFrm.SetupControls(0);
|
ProgressFrm.SetupControls(0);
|
||||||
PackageDownloader.OnPackageDownloadProgress := @ProgressFrm.DoOnPackageDownloadProgress;
|
PackageDownloader.OnPackageDownloadProgress := @ProgressFrm.DoOnPackageDownloadProgress;
|
||||||
PackageDownloader.OnPackageDownloadError := @ProgressFrm.DoOnPackageDownloadError;
|
PackageDownloader.OnPackageDownloadError := @ProgressFrm.DoOnPackageDownloadError;
|
||||||
@ -305,13 +302,14 @@ end;
|
|||||||
|
|
||||||
|
|
||||||
function TOPMInterfaceEx.Extract(const ASrcDir, ADstDir: String;
|
function TOPMInterfaceEx.Extract(const ASrcDir, ADstDir: String;
|
||||||
AParentForm: TForm; const AIsUpdate: Boolean): TModalResult;
|
const AIsUpdate: Boolean): TModalResult;
|
||||||
begin
|
begin
|
||||||
ProgressFrm := TProgressFrm.Create(AParentForm);
|
ProgressFrm := TProgressFrm.Create(nil);
|
||||||
try
|
try
|
||||||
|
ProgressFrm.Position := poWorkAreaCenter;
|
||||||
|
ProgressFrm.SetupControls(1);
|
||||||
PackageUnzipper := TPackageUnzipper.Create;
|
PackageUnzipper := TPackageUnzipper.Create;
|
||||||
try
|
try
|
||||||
ProgressFrm.SetupControls(1);
|
|
||||||
PackageUnzipper.OnZipProgress := @ProgressFrm.DoOnZipProgress;
|
PackageUnzipper.OnZipProgress := @ProgressFrm.DoOnZipProgress;
|
||||||
PackageUnzipper.OnZipError := @ProgressFrm.DoOnZipError;
|
PackageUnzipper.OnZipError := @ProgressFrm.DoOnZipError;
|
||||||
PackageUnzipper.OnZipCompleted := @ProgressFrm.DoOnZipCompleted;
|
PackageUnzipper.OnZipCompleted := @ProgressFrm.DoOnZipCompleted;
|
||||||
@ -326,11 +324,12 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TOPMInterfaceEx.Install(AParentForm: TForm; var AInstallStatus: TInstallStatus;
|
function TOPMInterfaceEx.Install(var AInstallStatus: TInstallStatus;
|
||||||
var ANeedToRebuild: Boolean): TModalResult;
|
var ANeedToRebuild: Boolean): TModalResult;
|
||||||
begin
|
begin
|
||||||
ProgressFrm := TProgressFrm.Create(AParentForm);
|
ProgressFrm := TProgressFrm.Create(nil);
|
||||||
try
|
try
|
||||||
|
ProgressFrm.Position := poWorkAreaCenter;
|
||||||
ProgressFrm.SetupControls(2);
|
ProgressFrm.SetupControls(2);
|
||||||
Result := ProgressFrm.ShowModal;
|
Result := ProgressFrm.ShowModal;
|
||||||
if Result = mrOk then
|
if Result = mrOk then
|
||||||
@ -344,7 +343,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TOPMInterfaceEx.InstallPackages(APkgLinks: TList; AParentForm: TForm;
|
function TOPMInterfaceEx.InstallPackages(APkgLinks: TList;
|
||||||
var ANeedToRebuild: Boolean): TModalResult;
|
var ANeedToRebuild: Boolean): TModalResult;
|
||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
@ -354,11 +353,11 @@ begin
|
|||||||
for I := 0 to APkgLinks.Count - 1 do
|
for I := 0 to APkgLinks.Count - 1 do
|
||||||
AddToInstallList(TPackageLink(APkgLinks.Items[I]).Name + '.lpk', TPackageLink(APkgLinks.Items[I]).LPKUrl);
|
AddToInstallList(TPackageLink(APkgLinks.Items[I]).Name + '.lpk', TPackageLink(APkgLinks.Items[I]).LPKUrl);
|
||||||
|
|
||||||
Result := CanInstallPackages(AParentForm);
|
Result := CanInstallPackages;
|
||||||
if Result = mrCancel then
|
if Result = mrCancel then
|
||||||
Exit;
|
Exit;
|
||||||
|
|
||||||
Result := ResolveDependencies(AParentForm);
|
Result := ResolveDependencies;
|
||||||
if Result = mrCancel then
|
if Result = mrCancel then
|
||||||
Exit;
|
Exit;
|
||||||
for I := 0 to FPackageDependecies.Count - 1 do
|
for I := 0 to FPackageDependecies.Count - 1 do
|
||||||
@ -368,7 +367,7 @@ begin
|
|||||||
PackageAction := paInstall;
|
PackageAction := paInstall;
|
||||||
if SerializablePackages.DownloadCount > 0 then
|
if SerializablePackages.DownloadCount > 0 then
|
||||||
begin
|
begin
|
||||||
Result := Download(Options.LocalRepositoryArchive, AParentForm);
|
Result := Download(Options.LocalRepositoryArchive);
|
||||||
SerializablePackages.GetPackageStates;
|
SerializablePackages.GetPackageStates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -376,7 +375,7 @@ begin
|
|||||||
begin
|
begin
|
||||||
if SerializablePackages.ExtractCount > 0 then
|
if SerializablePackages.ExtractCount > 0 then
|
||||||
begin
|
begin
|
||||||
Result := Extract(Options.LocalRepositoryArchive, Options.LocalRepositoryPackages, AParentForm);
|
Result := Extract(Options.LocalRepositoryArchive, Options.LocalRepositoryPackages);
|
||||||
SerializablePackages.GetPackageStates;
|
SerializablePackages.GetPackageStates;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -388,13 +387,13 @@ begin
|
|||||||
begin
|
begin
|
||||||
InstallStatus := isFailed;
|
InstallStatus := isFailed;
|
||||||
ANeedToRebuild := False;
|
ANeedToRebuild := False;
|
||||||
Result := Install(AParentForm, InstallStatus, ANeedToRebuild);
|
Result := Install(InstallStatus, ANeedToRebuild);
|
||||||
if Result = mrOk then
|
if Result = mrOk then
|
||||||
begin
|
begin
|
||||||
SerializablePackages.MarkRuntimePackages;
|
SerializablePackages.MarkRuntimePackages;
|
||||||
SerializablePackages.GetPackageStates;
|
SerializablePackages.GetPackageStates;
|
||||||
if (ANeedToRebuild) and ((InstallStatus = isSuccess) or (InstallStatus = isPartiallyFailed)) then
|
if (ANeedToRebuild) and ((InstallStatus = isSuccess) or (InstallStatus = isPartiallyFailed)) then
|
||||||
ANeedToRebuild := MessageDlgEx(rsOPMInterfaceRebuildConf, mtConfirmation, [mbYes, mbNo], AParentForm) = mrYes;
|
ANeedToRebuild := MessageDlgEx(rsOPMInterfaceRebuildConf, mtConfirmation, [mbYes, mbNo], nil) = mrYes;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|||||||
@ -9,8 +9,7 @@ object IntfPackageListFrm: TIntfPackageListFrm
|
|||||||
ClientWidth = 688
|
ClientWidth = 688
|
||||||
OnCreate = FormCreate
|
OnCreate = FormCreate
|
||||||
OnDestroy = FormDestroy
|
OnDestroy = FormDestroy
|
||||||
PopupMode = pmExplicit
|
Position = poDefault
|
||||||
Position = poOwnerFormCenter
|
|
||||||
LCLVersion = '1.9.0.0'
|
LCLVersion = '1.9.0.0'
|
||||||
object ButtonPanel1: TButtonPanel
|
object ButtonPanel1: TButtonPanel
|
||||||
Left = 6
|
Left = 6
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user