Vuo 2.4.4
Loading...
Searching...
No Matches
VuoErrorDialog.cc
Go to the documentation of this file.
1
10#include "VuoErrorDialog.hh"
11
12#include "VuoEditorUtilities.hh"
13#include "VuoRendererFonts.hh"
14#include "VuoStringUtilities.hh"
15
16QDialog *VuoDialogQueue_activeDialog = nullptr;
17
18QVector<QDialog *> VuoDialogQueue;
19
26void VuoDialogQueue_push(QDialog *dialog)
27{
28 QObject::connect(dialog, &QDialog::finished, [=]() {
29 if (VuoDialogQueue.isEmpty())
31 else
32 {
35 }
36 });
37
39 {
42 }
43 else
44 VuoDialogQueue.append(dialog);
45}
46
57void VuoErrorDialog::show(QWidget *parent, QString summary, QString details, QString disclosureDetails)
58{
59 VUserLog("Error: %s — %s — %s", summary.toUtf8().data(), details.toUtf8().data(), disclosureDetails.toUtf8().data());
60
62
63 auto messageBox = new QMessageBox(parent);
64 messageBox->setWindowFlags(Qt::Sheet);
65 messageBox->setWindowModality(Qt::WindowModal);
66 messageBox->setFont(fonts->dialogHeadingFont());
67 messageBox->setTextFormat(Qt::RichText);
68 messageBox->setText(QString::fromStdString(VuoStringUtilities::generateHtmlFromMarkdown(summary.toStdString())));
69
70 // Capitalize, so VuoCompiler exceptions (which typically start with a lowercase letter) look better.
71 details[0] = details[0].toUpper();
72 messageBox->setInformativeText("<style>p{" + fonts->getCSS(fonts->dialogBodyFont()) + "}</style>"
73 + QString::fromStdString(VuoStringUtilities::generateHtmlFromMarkdown(details.toStdString())));
74
75 messageBox->setDetailedText(disclosureDetails);
76 messageBox->setStandardButtons(QMessageBox::Ok);
77 messageBox->setIconPixmap(VuoEditorUtilities::vuoLogoForDialogs());
78
79 foreach (QObject *child, messageBox->children())
80 {
81 // Customize the style of the disclosure details text.
82 if (QString(child->metaObject()->className()) == "QMessageBoxDetailsText")
83 {
84 // Match the font of the informative text (child widget with objectName() =="qt_msgbox_informativelabel")
85 (dynamic_cast<QWidget *>(child))->setFont(fonts->dialogBodyFont());
86
87 // Increase the height of the disclosure details text box so that when a composition has one missing node,
88 // the entire detailed text can be viewed without scrolling.
89 foreach (QObject *grandchild, child->children())
90 {
91 if (dynamic_cast<QTextEdit *>(grandchild))
92 (dynamic_cast<QTextEdit *>(grandchild))->setFixedHeight(110);
93 }
94 }
95 }
96
97 VuoDialogQueue_push(messageBox);
98}