refactor: messages::showErrorDialog, use app name in title
construct QString without concat return aftershowing fatal error dialog Enable Translation for user facing strings
This commit is contained in:
@ -36,29 +36,24 @@ void raiseCriticalDialog()
|
|||||||
|
|
||||||
void showErrorDialog(const QString &message, const QString &fileLine, QtMsgType type)
|
void showErrorDialog(const QString &message, const QString &fileLine, QtMsgType type)
|
||||||
{
|
{
|
||||||
auto title = type == QtFatalMsg ? "Fatal error" : "Critical error";
|
auto errorType = QtFatalMsg ? QObject::tr("fatal error") : QObject::tr("error");
|
||||||
QString text;
|
auto title = QStringLiteral("%1 %2").arg(kAppName, errorType);
|
||||||
if (type == QtFatalMsg) {
|
auto text = QObject::tr(
|
||||||
text = "<p>Sorry, a fatal error has occurred and the application must "
|
R"(<p>Please <a href="%1" style="color: %2">report a bug</a>)"
|
||||||
"now exit.</p>";
|
" and copy/paste the following error:</p><pre>v%3\n%4\n%5</pre>"
|
||||||
} else {
|
|
||||||
text = "<p>Sorry, a critical error has occurred.</p>";
|
|
||||||
}
|
|
||||||
|
|
||||||
text += QString(
|
|
||||||
R"(<p>Please <a href="%1" style="color: %2">report a bug</a>)"
|
|
||||||
" and copy/paste the following error:</p>"
|
|
||||||
)
|
)
|
||||||
.arg(kUrlHelp, kColorSecondary);
|
.arg(kUrlHelp, kColorSecondary, kVersion, message, fileLine);
|
||||||
|
|
||||||
text += QString("<pre>v%1\n%2\n%3</pre>").arg(kVersion, message, fileLine);
|
|
||||||
|
|
||||||
if (type == QtFatalMsg) {
|
if (type == QtFatalMsg) {
|
||||||
|
text.prepend(QObject::tr("<p>Sorry, a fatal error has occurred and the application must now exit.</p>\n"));
|
||||||
// create a blocking message box for fatal errors, as we want to wait
|
// create a blocking message box for fatal errors, as we want to wait
|
||||||
// until the dialog is dismissed before aborting the app.
|
// until the dialog is dismissed before aborting the app.
|
||||||
QMessageBox critical(QMessageBox::Critical, title, text, QMessageBox::Abort);
|
QMessageBox::critical(nullptr, title, text, QMessageBox::Abort);
|
||||||
critical.exec();
|
return;
|
||||||
} else if (!Errors::s_ignoredErrors.contains(message)) {
|
}
|
||||||
|
|
||||||
|
text.prepend(QObject::tr("<p>Sorry, a critical error has occurred.</p>\n"));
|
||||||
|
if (!Errors::s_ignoredErrors.contains(message)) {
|
||||||
// prevent message boxes piling up by deleting the last one if it exists.
|
// prevent message boxes piling up by deleting the last one if it exists.
|
||||||
// if none exists yet, then nothing will happen.
|
// if none exists yet, then nothing will happen.
|
||||||
Errors::s_criticalMessage.reset();
|
Errors::s_criticalMessage.reset();
|
||||||
|
|||||||
Reference in New Issue
Block a user