Skip to content

Commit

Permalink
controllers/controllerengine: Use monospace font for script error det…
Browse files Browse the repository at this point in the history
…ails
  • Loading branch information
Holzhaus committed Apr 12, 2020
1 parent 712ced4 commit 0e29507
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/controllers/controllerengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@ void ControllerEngine::scriptErrorDialog(
tr("The script code needs to be fixed.") + QStringLiteral("<p>") +
additionalErrorText + QStringLiteral("</p></html>"));

props->setDetails(detailedError);
// Add "Details" text and set monospace font since they may contain
// backtraces and code.
props->setDetails(detailedError, true);
props->setKey(detailedError); // To prevent multiple windows for the same error

// Allow user to suppress further notifications about this particular error
Expand Down
4 changes: 4 additions & 0 deletions src/errordialoghandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

ErrorDialogProperties::ErrorDialogProperties()
: m_title(Version::applicationName()),
m_detailsUseMonospaceFont(false),
m_modal(true),
m_shouldQuit(false),
m_type(DLG_NONE),
Expand Down Expand Up @@ -161,6 +162,9 @@ void ErrorDialogHandler::errorDialog(ErrorDialogProperties* pProps) {
}
if (!props->m_details.isEmpty()) {
pMsgBox->setDetailedText(props->m_details);
if (props->m_detailsUseMonospaceFont) {
pMsgBox->setStyleSheet("QTextEdit { font-family: monospace; }");
}
}

while (!props->m_buttons.isEmpty()) {
Expand Down
4 changes: 3 additions & 1 deletion src/errordialoghandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ class ErrorDialogProperties {
}

/** Set detailed text (causes "Show Details" button to appear.) */
inline void setDetails(const QString& text) {
inline void setDetails(const QString& text, bool bUseMonospaceFont = false) {
m_details = text;
m_detailsUseMonospaceFont = bUseMonospaceFont;
}

/** Set whether the box is modal (blocks the GUI) or not */
Expand Down Expand Up @@ -112,6 +113,7 @@ class ErrorDialogProperties {
QString m_text;
QString m_infoText;
QString m_details;
bool m_detailsUseMonospaceFont;
bool m_modal;
bool m_shouldQuit;
DialogType m_type;
Expand Down

0 comments on commit 0e29507

Please sign in to comment.