Vuo  2.3.2
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 
23 void VuoErrorDialog::show(QWidget *parent, QString summary, QString details, QString disclosureDetails)
24 {
25  VUserLog("Error: %s — %s — %s", summary.toUtf8().data(), details.toUtf8().data(), disclosureDetails.toUtf8().data());
26 
28 
29  QMessageBox messageBox(parent);
30  messageBox.setWindowFlags(Qt::Sheet);
31  messageBox.setWindowModality(Qt::WindowModal);
32  messageBox.setFont(fonts->dialogHeadingFont());
33  messageBox.setTextFormat(Qt::RichText);
34  messageBox.setText(QString::fromStdString(VuoStringUtilities::generateHtmlFromMarkdown(summary.toStdString())));
35 
36  // Capitalize, so VuoCompiler exceptions (which typically start with a lowercase letter) look better.
37  details[0] = details[0].toUpper();
38  messageBox.setInformativeText("<style>p{" + fonts->getCSS(fonts->dialogBodyFont()) + "}</style>"
39  + QString::fromStdString(VuoStringUtilities::generateHtmlFromMarkdown(details.toStdString())));
40 
41  messageBox.setDetailedText(disclosureDetails);
42  messageBox.setStandardButtons(QMessageBox::Ok);
43  messageBox.setIconPixmap(VuoEditorUtilities::vuoLogoForDialogs());
44 
45  foreach (QObject *child, messageBox.children())
46  {
47  // Customize the style of the disclosure details text.
48  if (QString(child->metaObject()->className()) == "QMessageBoxDetailsText")
49  {
50  // Match the font of the informative text (child widget with objectName() =="qt_msgbox_informativelabel")
51  (dynamic_cast<QWidget *>(child))->setFont(fonts->dialogBodyFont());
52 
53  // Increase the height of the disclosure details text box so that when a composition has one missing node,
54  // the entire detailed text can be viewed without scrolling.
55  foreach (QObject *grandchild, child->children())
56  {
57  if (dynamic_cast<QTextEdit *>(grandchild))
58  (dynamic_cast<QTextEdit *>(grandchild))->setFixedHeight(110);
59  }
60  }
61  }
62 
63  messageBox.exec();
64 }