Skip to content
Permalink
Browse files

Issue #411: append search engine's hostname to "Find help" link in er…

…ror dialogs, now that it's customizable
  • Loading branch information...
ansgarbecker committed Apr 30, 2019
1 parent c3da595 commit 0c35a27fec0f0930e95fae04259b692f9f8303ce
Showing with 10 additions and 3 deletions.
  1. +10 −3 source/apphelpers.pas
@@ -2458,7 +2458,7 @@ function MessageDialog(const Title, Msg: string; DlgType: TMsgDlgType; Buttons:
rx: TRegExpr;
KeepAskingValue: Boolean;
Hotkeys: String;
WebSearchUrl: String;
WebSearchUrl, WebSearchHost: String;

procedure AddButton(BtnCaption: String; BtnResult: TModalResult);
var
@@ -2501,7 +2501,7 @@ function MessageDialog(const Title, Msg: string; DlgType: TMsgDlgType; Buttons:
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?://\S+';
Dialog.Text := rx.Replace(Msg, '<a href="$0">$0</a>', True);
rx.Free;

@@ -2513,7 +2513,14 @@ function MessageDialog(const Title, Msg: string; DlgType: TMsgDlgType; Buttons:
Dialog.MainIcon := tdiError;
WebSearchUrl := AppSettings.ReadString(asWebSearchBaseUrl);
WebSearchUrl := StringReplace(WebSearchUrl, '%q', EncodeURLParam(Copy(Msg, 1, 1000)), []);
Dialog.FooterText := '<a href="'+WebSearchUrl+'">'+_('Find some help on this error')+'</a>';
rx := TRegExpr.Create;
rx.Expression := 'https?://(www\.)?([^/]+)/';
if rx.Exec(WebSearchUrl) then
WebSearchHost := rx.Match[2]
else
WebSearchHost := '[unknown host]';
rx.Free;
Dialog.FooterText := '<a href="'+WebSearchUrl+'">'+_('Find some help on this error')+' (=> '+WebSearchHost+')</a>';
Dialog.FooterIcon := tdiInformation;
end;
mtInformation:

0 comments on commit 0c35a27

Please sign in to comment.
You can’t perform that action at this time.