@@ -2321,18 +2321,23 @@ function MessageDialog(const Title, Msg: string; DlgType: TMsgDlgType; Buttons:
23212321 end ;
23222322begin
23232323
2324+ { $IFNDEF WINDOWS}
23242325 if (KeepAskingSetting = asUnused) and (FooterText.IsEmpty) then begin
2325- // Show the more native MessageDlg when we don't need additional dialog features
2326+ // Show the more native MessageDlg when we don't need additional dialog features.
2327+ // Especially useful on macOS and Linux where the TTaskDialog looks really different than MessageDlg.
23262328 Result := MessageDlg(Title, Msg, DlgType, Buttons, 0 );
23272329 Exit;
23282330 end ;
2331+ { $ENDIF}
23292332
23302333 // Remember current path and restore it later, so the caller does not try to read from the wrong path after this dialog
23312334 AppSettings.StorePath;
23322335
23332336 Dialog := TTaskDialog.Create(nil );
23342337 Dialog.Flags := [tfEnableHyperlinks, tfAllowDialogCancellation];
23352338 Dialog.CommonButtons := [];
2339+ if Assigned(MainForm) then
2340+ Dialog.OnHyperlinkClicked := MainForm.TaskDialogHyperLinkClicked;
23362341
23372342 // Caption, title and text
23382343 case DlgType of
@@ -2343,15 +2348,33 @@ function MessageDialog(const Title, Msg: string; DlgType: TMsgDlgType; Buttons:
23432348 end ;
23442349 if Title <> Dialog.Caption then
23452350 Dialog.Title := Title;
2346- Dialog.Text := Msg;
2351+ if Assigned(MainForm) and (MainForm.ActiveConnection <> nil ) then
2352+ Dialog.Caption := MainForm.ActiveConnection.Parameters.SessionName + ' : ' + Dialog.Caption;
2353+ rx := TRegExpr.Create;
2354+ rx.Expression := ' https?://[^\s"]+' ;
2355+ if ThemeIsDark then
2356+ Dialog.Text := Msg
2357+ else // See issue #2036
2358+ Dialog.Text := rx.Replace(Msg, ' <a href="$0">$0</a>' , True);
2359+ rx.Free;
23472360
23482361 // Main icon, and footer link
23492362 case DlgType of
23502363 mtWarning:
23512364 Dialog.MainIcon := tdiWarning;
23522365 mtError: begin
23532366 Dialog.MainIcon := tdiError;
2354- Dialog.FooterText := FooterText;
2367+ WebSearchUrl := AppSettings.ReadString(asWebSearchBaseUrl);
2368+ WebSearchUrl := StringReplace(WebSearchUrl, ' %q' , EncodeURLParam(Copy(Msg, 1 , 1000 )), []);
2369+ rx := TRegExpr.Create;
2370+ rx.Expression := ' https?://(www\.)?([^/]+)/' ;
2371+ if rx.Exec(WebSearchUrl) then
2372+ WebSearchHost := rx.Match[2 ]
2373+ else
2374+ WebSearchHost := ' [unknown host]' ;
2375+ rx.Free;
2376+ Dialog.FooterText := IfThen(FooterText.IsEmpty, ' ' , FooterText + sLineBreak + sLineBreak) +
2377+ ' <a href="' +WebSearchUrl+' ">' +_(' Find some help on this error' )+' (=> ' +WebSearchHost+' )</a>' ;
23552378 Dialog.FooterIcon := tdiInformation;
23562379 end ;
23572380 mtInformation:
0 commit comments