2
0
Эх сурвалжийг харах

Added new AbortedByUser property to the TDownloadWizardPage support class.

Martijn Laan 4 жил өмнө
parent
commit
312c0a46c5

+ 4 - 1
Examples/CodeDownloadFiles.iss

@@ -52,7 +52,10 @@ begin
         DownloadPage.Download;
         Result := True;
       except
-        SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
+        if DownloadPage.AbortedByUser then
+          Log('Aborted by user.')
+        else
+          SuppressibleMsgBox(AddPeriod(GetExceptionMessage), mbCriticalError, MB_OK, IDOK);
         Result := False;
       end;
     finally

+ 1 - 0
ISHelp/isxclasses.pas

@@ -733,6 +733,7 @@ end;
 
 TDownloadWizardPage = class(TOutputProgressWizardPage)
   property AbortButton: TNewButton; read;
+  property AbortedByUser: Boolean; read;
   procedure Add(const Url, BaseName, RequiredSHA256OfFile: String);
   procedure Clear;
   function Download: Int64;

+ 1 - 0
Projects/ScriptClasses_C.pas

@@ -545,6 +545,7 @@ begin
   with CL.AddClassN(Cl.FindClass('TOutputProgressWizardPage'),'TDownloadWizardPage') do
   begin
     RegisterProperty('AbortButton', 'TNewButton', iptr);
+    RegisterProperty('AbortedByUser', 'Boolean', iptr);
     RegisterMethod('procedure Add(const Url, BaseName, RequiredSHA256OfFile: String)');
     RegisterMethod('procedure Clear');
     RegisterMethod('function Download: Int64');

+ 3 - 0
Projects/ScriptClasses_R.pas

@@ -321,10 +321,13 @@ begin
 end;
 
 {$IFNDEF PS_NOINT64}
+procedure TDownloadPageAbortedByUser_R(Self: TDownloadWizardPage; var T: Boolean); begin T := Self.AbortedByUser; end;
+
 procedure RegisterDownloadWizardPage_R(CL: TPSRuntimeClassImporter);
 begin
   with CL.Add(TDownloadWizardPage) do
   begin
+    RegisterPropertyHelper(@TDownloadPageAbortedByUser_R,nil,'AbortedByUser');
     RegisterMethod(@TDownloadWizardPage.Add, 'Add');
     RegisterMethod(@TDownloadWizardPage.Clear, 'Clear');
     RegisterMethod(@TDownloadWizardPage.Download, 'Download');

+ 5 - 4
Projects/ScriptDlg.pas

@@ -171,7 +171,7 @@ type
       FFiles: TObjectList;
       FOnDownloadProgress: TOnDownloadProgress;
       FAbortButton: TNewButton;
-      FShowProgressControlsOnNextProgress, FNeedToAbortDownload: Boolean;
+      FShowProgressControlsOnNextProgress, FAbortedByUser: Boolean;
       procedure AbortButtonClick(Sender: TObject);
       function InternalOnDownloadProgress(const Url, BaseName: string; const Progress, ProgressMax: Int64): Boolean;
       procedure ShowProgressControls(const AVisible: Boolean);
@@ -179,6 +179,7 @@ type
       constructor Create(AOwner: TComponent); override;
       destructor Destroy; override;
       procedure Initialize; override;
+      property AbortedByUser: Boolean read FAbortedByUser;
       procedure Add(const Url, BaseName, RequiredSHA256OfFile: String);
       procedure Clear;
       function Download: Int64;
@@ -895,14 +896,14 @@ type
 
 procedure TDownloadWizardPage.AbortButtonClick(Sender: TObject);
 begin
-  FNeedToAbortDownload := LoggedMsgBox(SetupMessages[msgStopDownload], '', mbConfirmation, MB_YESNO, True, ID_YES) = IDYES;
+  FAbortedByUser := LoggedMsgBox(SetupMessages[msgStopDownload], '', mbConfirmation, MB_YESNO, True, ID_YES) = IDYES;
 end;
 
 function TDownloadWizardPage.InternalOnDownloadProgress(const Url, BaseName: string; const Progress, ProgressMax: Int64): Boolean;
 var
   Progress32, ProgressMax32: LongInt;
 begin
-  if FNeedToAbortDownload then begin
+  if FAbortedByUser then begin
     Log('Need to abort download.');
     Result := False;
   end else begin
@@ -1002,7 +1003,7 @@ var
   F: TDownloadFile;
   I: Integer;
 begin
-  FNeedToAbortDownload := False;
+  FAbortedByUser := False;
   
   Result := 0;
   for I := 0 to FFiles.Count-1 do begin

+ 1 - 0
whatsnew.htm

@@ -35,6 +35,7 @@ For conditions of distribution and use, see <a href="https://jrsoftware.org/file
   <ul>
     <li>Added new <tt>ItemFontStyle</tt> and <tt>SubItemFontStyle</tt> properties to the <tt>TNewCheckListBox</tt> support class. See the <i><a href="https://jrsoftware.github.io/issrc/Examples/CodeClasses.iss">CodeClasses.iss</a></i> example script for an example.</li>
     <li>Added new <tt>IsMsiProductInstalled</tt> and <tt>StrToVersion</tt> support functions.</li>
+    <li>Added new <tt>AbortedByUser</tt> property to the <tt>TDownloadWizardPage</tt> support class.</li>
     <li><i>Fix:</i> <tt>CreateDownloadPage</tt>'s progress bar now supports files larger than 2 GB.</li>
   </ul>
   </li>