From af7e365b1516d660d271475fdfe0c20ae09e66a8 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 27 Mar 2021 18:52:22 +0200 Subject: [PATCH] qt: Make PACKAGE_BUGREPORT link clickable Co-authored-by: Russell Yanofsky --- src/qt/bitcoin.cpp | 7 ++++++- src/qt/guiutil.cpp | 9 +++++++++ src/qt/guiutil.h | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index fc6d0febc2..aec63ffaf0 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -45,10 +45,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include @@ -417,7 +419,10 @@ void BitcoinApplication::shutdownResult() void BitcoinApplication::handleRunawayException(const QString &message) { - QMessageBox::critical(nullptr, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. %1 can no longer continue safely and will quit.").arg(PACKAGE_NAME) + QString("

") + message); + QMessageBox::critical( + nullptr, tr("Runaway exception"), + tr("A fatal error occurred. %1 can no longer continue safely and will quit.").arg(PACKAGE_NAME) % + QLatin1String("

") % GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT)); ::exit(EXIT_FAILURE); } diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index b4afdbcc22..36fcc4d361 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -54,6 +55,7 @@ #include #include #include +#include #include // for Qt::mightBeRichText #include #include @@ -893,4 +895,11 @@ QImage GetImage(const QLabel* label) #endif } +QString MakeHtmlLink(const QString& source, const QString& link) +{ + return QString(source).replace( + link, + QLatin1String("") % link % QLatin1String("")); +} + } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 6395ec6abd..6ab0a71a96 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -327,6 +327,11 @@ namespace GUIUtil QObject::connect(&source, &QObject::destroyed, object, std::forward(function), connection); } + /** + * Replaces a plain text link with an HTML tagged one. + */ + QString MakeHtmlLink(const QString& source, const QString& link); + } // namespace GUIUtil #endif // BITCOIN_QT_GUIUTIL_H