Patch manager: detailed message box for long logs

This commit is contained in:
Megamouse 2022-04-09 20:54:35 +02:00
parent 4dfb47cdd9
commit 039d19dacf
3 changed files with 48 additions and 4 deletions

View File

@ -835,7 +835,29 @@ void patch_manager_dialog::dropEvent(QDropEvent* event)
else else
{ {
patch_log.error("Errors found in patch file %s", path); patch_log.error("Errors found in patch file %s", path);
QMessageBox::critical(this, tr("Validation failed"), tr("Errors were found in the patch file.\n\nLog:\n%0").arg(QString::fromStdString(log_message.str()))); QString summary = QString::fromStdString(log_message.str());
if (summary.count(QLatin1Char('\n')) < 5)
{
QMessageBox::critical(this, tr("Validation failed"), tr("Errors were found in the patch file.\n\nLog:\n%0").arg(summary));
}
else
{
QString message = tr("Errors were found in the patch file.");
QMessageBox mb(QMessageBox::Icon::Critical, tr("Validation failed"), message, QMessageBox::Ok, this);
mb.setInformativeText(tr("To see the error log, please click \"Show Details\"."));
mb.setDetailedText(tr("%0").arg(summary));
// Smartass hack to make the unresizeable message box wide enough for the changelog
const int log_width = QLabel(summary).sizeHint().width();
while (QLabel(message).sizeHint().width() < log_width)
{
message += " ";
}
mb.setText(message);
mb.exec();
}
} }
} }
} }
@ -1025,7 +1047,29 @@ bool patch_manager_dialog::handle_json(const QByteArray& data)
else else
{ {
patch_log.error("Errors found in downloaded patch file"); patch_log.error("Errors found in downloaded patch file");
QMessageBox::critical(this, tr("Validation failed"), tr("Errors were found in the downloaded patch file.\n\nLog:\n%0").arg(QString::fromStdString(log_message.str()))); QString summary = QString::fromStdString(log_message.str());
if (summary.count(QLatin1Char('\n')) < 5)
{
QMessageBox::critical(this, tr("Validation failed"), tr("Errors were found in the downloaded patch file.\n\nLog:\n%0").arg(summary));
}
else
{
QString message = tr("Errors were found in the downloaded patch file.");
QMessageBox mb(QMessageBox::Icon::Critical, tr("Validation failed"), message, QMessageBox::Ok, this);
mb.setInformativeText(tr("To see the error log, please click \"Show Details\"."));
mb.setDetailedText(tr("%0").arg(summary));
// Smartass hack to make the unresizeable message box wide enough for the changelog
const int log_width = QLabel(message).sizeHint().width();
while (QLabel(message).sizeHint().width() < log_width)
{
message += " ";
}
mb.setText(message);
mb.exec();
}
} }
return true; return true;