Turn release-download button into a link label, displaying a second link to a message dialog with instructions for a portable update. See https://www.heidisql.com/forum.php?t=37843

This commit is contained in:
Ansgar Becker
2021-05-08 17:21:02 +02:00
parent c5d95c1ce2
commit 976dd6b742
5 changed files with 67 additions and 33 deletions

View File

@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2021-05-08 09:23+0200\n"
"PO-Revision-Date: 2021-05-08 17:18+0200\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/language/en/)\n"
"MIME-Version: 1.0\n"
@@ -6672,3 +6672,9 @@ msgstr "Editor commands"
msgid "Lowercase hexadecimal"
msgstr "Lowercase hexadecimal"
msgid "Update instructions"
msgstr "Update instructions"
msgid "Download the portable package and extract it in %s"
msgstr "Download the portable package and extract it in %s"

View File

@@ -2287,7 +2287,7 @@ begin
if Assigned(MainForm) and (MainForm.ActiveConnection <> nil) then
Dialog.Caption := MainForm.ActiveConnection.Parameters.SessionName + ': ' + Dialog.Caption;
rx := TRegExpr.Create;
rx.Expression := 'https?://\S+';
rx.Expression := '(https?://|[A-Z]\:\\)\S+';
Dialog.Text := rx.Replace(Msg, '<a href="$0">$0</a>', True);
rx.Free;

View File

@@ -2196,7 +2196,7 @@ begin
frm.ReadCheckFile;
// Show the dialog if release is available, or - when wanted - build checks are activated
if (AppSettings.ReadBool(asUpdatecheckBuilds) and frm.btnBuild.Enabled)
or frm.btnRelease.Enabled then begin
or frm.LinkLabelRelease.Enabled then begin
frm.ShowModal;
end;
except

View File

@@ -14,6 +14,7 @@ object frmUpdateCheck: TfrmUpdateCheck
Font.Style = []
OldCreateOrder = False
Position = poOwnerFormCenter
OnClose = FormClose
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
@@ -1184,17 +1185,6 @@ object frmUpdateCheck: TfrmUpdateCheck
DesignSize = (
358
110)
object btnRelease: TButton
Left = 6
Top = 78
Width = 345
Height = 25
Anchors = [akLeft, akRight, akBottom]
Caption = 'Download new release'
ModalResult = 1
TabOrder = 0
OnClick = btnReleaseClick
end
object memoRelease: TMemo
Left = 6
Top = 16
@@ -1207,7 +1197,19 @@ object frmUpdateCheck: TfrmUpdateCheck
'memoRelease')
ReadOnly = True
ScrollBars = ssVertical
TabOrder = 0
end
object LinkLabelRelease: TLinkLabel
Left = 6
Top = 87
Width = 122
Height = 19
Cursor = crHandPoint
Anchors = [akLeft, akRight, akBottom]
Caption = 'Download new release'
TabOrder = 1
UseVisualStyle = True
OnLinkClick = LinkLabelReleaseLinkClick
end
end
end

View File

@@ -4,7 +4,7 @@ interface
uses
Windows, Messages, SysUtils, Classes, Forms, StdCtrls, IniFiles, Controls, Graphics,
apphelpers, gnugettext, ExtCtrls, extra_controls, System.StrUtils;
apphelpers, gnugettext, ExtCtrls, extra_controls, System.StrUtils, Vcl.Dialogs;
type
TfrmUpdateCheck = class(TExtForm)
@@ -12,7 +12,7 @@ type
groupBuild: TGroupBox;
btnBuild: TButton;
groupRelease: TGroupBox;
btnRelease: TButton;
LinkLabelRelease: TLinkLabel;
lblStatus: TLabel;
memoRelease: TMemo;
memoBuild: TMemo;
@@ -20,13 +20,15 @@ type
btnChangelog: TButton;
procedure FormCreate(Sender: TObject);
procedure btnBuildClick(Sender: TObject);
procedure btnReleaseClick(Sender: TObject);
procedure LinkLabelReleaseLinkClick(Sender: TObject; const Link: string;
LinkType: TSysLinkType);
procedure FormShow(Sender: TObject);
procedure btnChangelogClick(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
ReleaseURL, BuildURL : String;
BuildURL: String;
FLastStatusUpdate: Cardinal;
procedure Status(txt: String);
procedure DownloadProgress(Sender: TObject);
@@ -65,6 +67,11 @@ begin
AppSettings.WriteInt(asUpdateCheckWindowHeight, Height);
end;
procedure TfrmUpdateCheck.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
{**
Update status text
}
@@ -119,7 +126,7 @@ const
INISECT_BUILD = 'Build';
begin
// Init GUI controls
btnRelease.Enabled := False;
LinkLabelRelease.Enabled := False;
btnBuild.Enabled := False;
memoRelease.Clear;
memoBuild.Clear;
@@ -146,17 +153,22 @@ begin
if Ini.SectionExists(INISECT_RELEASE) then begin
ReleaseVersion := Ini.ReadString(INISECT_RELEASE, 'Version', 'unknown');
ReleaseRevision := Ini.ReadInteger(INISECT_RELEASE, 'Revision', 0);
ReleaseURL := Ini.ReadString(INISECT_RELEASE, 'URL', '');
ReleasePackage := IfThen(AppSettings.PortableMode, 'portable', 'installer');
memoRelease.Lines.Add(f_('Version %s (yours: %s)', [ReleaseVersion, Mainform.AppVersion]));
memoRelease.Lines.Add(f_('Released: %s', [Ini.ReadString(INISECT_RELEASE, 'Date', '')]));
Note := Ini.ReadString(INISECT_RELEASE, 'Note', '');
if Note <> '' then
memoRelease.Lines.Add(_('Notes') + ': ' + Note);
btnRelease.Caption := f_('Download version %s (%s)', [ReleaseVersion, ReleasePackage]);
LinkLabelRelease.Caption := f_('Download version %s (%s)', [ReleaseVersion, ReleasePackage]);
LinkLabelRelease.Caption := '<a id="download">' + LinkLabelRelease.Caption + '</a>';
if AppSettings.PortableMode then begin
LinkLabelRelease.Caption := LinkLabelRelease.Caption + ' <a id="instructions">'+_('Update instructions')+'</a>';
end;
// Enable the download button if the current version is outdated
groupRelease.Enabled := ReleaseRevision > Mainform.AppVerRevision;
btnRelease.Enabled := groupRelease.Enabled;
LinkLabelRelease.Enabled := groupRelease.Enabled;
memoRelease.Enabled := groupRelease.Enabled;
if not memoRelease.Enabled then
memoRelease.Font.Color := GetThemeColor(cl3DDkShadow)
@@ -178,7 +190,7 @@ begin
// A new release should have priority over a new nightly build.
// So the user should not be able to download a newer build here
// before having installed the new release.
btnBuild.Enabled := (Mainform.AppVerRevision = 0) or ((BuildRevision > Mainform.AppVerRevision) and (not btnRelease.Enabled));
btnBuild.Enabled := (Mainform.AppVerRevision = 0) or ((BuildRevision > Mainform.AppVerRevision) and (not LinkLabelRelease.Enabled));
end;
if FileExists(CheckFilename) then
@@ -190,20 +202,34 @@ end;
{**
Download release package via web browser
}
procedure TfrmUpdateCheck.btnReleaseClick(Sender: TObject);
procedure TfrmUpdateCheck.LinkLabelReleaseLinkClick(Sender: TObject;
const Link: string; LinkType: TSysLinkType);
var
DownloadParam: String;
begin
if AppSettings.PortableMode then begin
if GetExecutableBits = 64 then
DownloadParam := 'portable-64'
else
DownloadParam := 'portable';
end else begin
DownloadParam := 'installer';
end;
case LinkType of
ShellExec(APPDOMAIN+'download.php?download='+DownloadParam);
sltURL: ShellExec(Link);
sltID: begin
if Link = 'download' then begin
if AppSettings.PortableMode then begin
if GetExecutableBits = 64 then
DownloadParam := 'portable-64'
else
DownloadParam := 'portable';
end else begin
DownloadParam := 'installer';
end;
ShellExec(APPDOMAIN+'download.php?download='+DownloadParam);
Close;
end
else if Link = 'instructions' then begin
MessageDialog(f_('Download the portable package and extract it in %s', [ExtractFilePath(Application.ExeName)]), mtInformation, [mbOK]);
end;
end;
end;
end;