Просмотр исходного кода

TDownloadPage: Add new ShowBaseNameInsteadOfUrl property. Also cleanup AbortedByUser property.

Martijn Laan 1 год назад
Родитель
Сommit
a455c8d44e

+ 1 - 0
Examples/CodeDownloadFiles.iss

@@ -38,6 +38,7 @@ end;
 procedure InitializeWizard;
 begin
   DownloadPage := CreateDownloadPage(SetupMessage(msgWizardPreparing), SetupMessage(msgPreparingDesc), @OnDownloadProgress);
+  DownloadPage.ShowBaseNameInsteadOfUrl := True;
 end;
 
 function NextButtonClick(CurPageID: Integer): Boolean;

+ 1 - 0
ISHelp/isxclasses.pas

@@ -764,6 +764,7 @@ TDownloadWizardPage = class(TOutputProgressWizardPage)
   procedure AddEx(const Url, BaseName, RequiredSHA256OfFile, UserName, Password: String);
   procedure Clear;
   function Download: Int64;
+  property ShowBaseNameInsteadOfUrl: Boolean; read write;
 end;
 
 TUIStateForm = class(TForm)

+ 1 - 0
ISHelp/isxfunc.xml

@@ -2570,6 +2570,7 @@ Page := CreateOutputMsgMemoPage(wpWelcome,
 <p>Always put the <tt>Hide</tt> call inside the <tt>finally</tt> part of a <tt>try..finally</tt> language construct, as demonstrated in <i>CodeDownloadFiles.iss</i>. Not calling <tt>Hide</tt> will result in the wizard being permanently stuck on the progress page.</p>
 <p>To add a new file to download, call the <tt>Add</tt> method. Always call the <tt>Clear</tt> method before adding the first file.</p>
 <p>To start the download, call the <tt>Download</tt> method. An exception will be raised if there was an error. Otherwise, <tt>Download</tt> returns the number of bytes downloaded.</p>
+<p>Set the <tt>ShowBaseNameInsteadOfUrl</tt> property to <tt>True</tt> to show the base name of the file which is being downloaded to the user instead of the URL.</p>
 <p>See <link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link> for other considerations and the definition of <tt>TOnDownloadProgress</tt>.</p></remarks>
         <example><p>See <i>CodeDownloadFiles.iss</i> for an example.</p></example>
         <seealso><p><link topic="scriptclasses" anchor="TDownloadWizardPage">TDownloadWizardPage</link><br />

+ 1 - 0
Projects/Src/ScriptClasses_C.pas

@@ -557,6 +557,7 @@ begin
   begin
     RegisterProperty('AbortButton', 'TNewButton', iptr);
     RegisterProperty('AbortedByUser', 'Boolean', iptr);
+    RegisterProperty('ShowBaseNameInsteadOfUrl', 'Boolean', iptrw);
     RegisterMethod('procedure Add(const Url, BaseName, RequiredSHA256OfFile: String)');
     RegisterMethod('procedure AddEx(const Url, BaseName, RequiredSHA256OfFile, UserName, Password: String)');
     RegisterMethod('procedure Clear');

+ 0 - 3
Projects/Src/ScriptClasses_R.pas

@@ -331,13 +331,10 @@ begin
   end;
 end;
 
-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.AddEx, 'AddEx');
     RegisterMethod(@TDownloadWizardPage.Clear, 'Clear');

+ 5 - 2
Projects/Src/ScriptDlg.pas

@@ -175,6 +175,7 @@ type
     private
       FFiles: TObjectList;
       FOnDownloadProgress: TOnDownloadProgress;
+      FShowBaseNameInsteadOfUrl: Boolean;
       FAbortButton: TNewButton;
       FShowProgressControlsOnNextProgress, FAbortedByUser: Boolean;
       procedure AbortButtonClick(Sender: TObject);
@@ -184,7 +185,6 @@ 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 AddEx(const Url, BaseName, RequiredSHA256OfFile, UserName, Password: String);
       procedure Clear;
@@ -193,11 +193,14 @@ type
       procedure Show; override;
     published
       property AbortButton: TNewButton read FAbortButton;
+      property AbortedByUser: Boolean read FAbortedByUser;
+      property ShowBaseNameInsteadOfUrl: Boolean read FShowBaseNameInsteadOfUrl write FShowBaseNameInsteadOfUrl;
   end;
   
 implementation
 
 uses
+  StrUtils,
   Struct, Main, SelFolderForm, Msgs, MsgIDs, PathFunc, CmnFunc, CmnFunc2,
   BrowseFunc, Logging, InstFunc;
 
@@ -938,7 +941,7 @@ begin
     else
       Log(Format('  %d bytes done.', [Progress]));
 
-    FMsg2Label.Caption := Url;
+    FMsg2Label.Caption := IfThen(FShowBaseNameInsteadOfUrl, BaseName, Url);
     if ProgressMax > MaxLongInt then begin
       Progress32 := Round((Progress / ProgressMax) * MaxLongInt);
       ProgressMax32 := MaxLongInt;

+ 1 - 0
whatsnew.htm

@@ -167,6 +167,7 @@ end;</pre>
     <li>Added support functions <tt>LoadStringFromLockedFile</tt> and <tt>LoadStringsFromLockedFile</tt> to read strings from a file even if it's already opened for writing by another program.</li>
     <li>Added support class <tt>TNewLinkLabel</tt> which can display multi-line text with embedded links and internally uses a Windows SysLink control. See the <i>CodeClasses.iss</i> example script for examples.</li>
     <li><tt>TWizardForm</tt>: Added new <tt>AdjustLinkLabelHeight</tt> function.</li>
+    <li><tt>TDownloadPage</tt>: Added new <tt>ShowBaseNameInsteadOfUrl</tt> property.</li>
     <li>It is now possible to write <tt>var S: set of AnsiChar; begin S := ['a', 'b']; end;</tt>. In previous versions this would result in a type mismatch error.</tt>
     <li>It is now possible to write <tt>Stream.ReadBuffer(S, Length(S));</tt> when S is of type <tt>AnsiString</tt>. In previous versions this would compile but not work at run time. Same applies to <tt>Read</tt>, <tt>Write</tt>, and <tt>WriteBuffer</tt>: all four functions now accept any type of string.</li>
     <li>Added example which downloads and unzips a Zip file to the <i>CodeAutomation.iss</i> example script.</li>