diff --git a/src/Base/Console.h b/src/Base/Console.h
index 51c2ebd80f..6e698fe690 100644
--- a/src/Base/Console.h
+++ b/src/Base/Console.h
@@ -458,7 +458,7 @@ class BaseExport ConsoleObserver
{
public:
ConsoleObserver()
- :bErr(true),bMsg(true),bLog(true),bWrn(true) {}
+ :bErr(true),bMsg(true),bLog(true),bWrn(true),bShow(true) {}
virtual ~ConsoleObserver() {}
/// get calls when a Warning is issued
virtual void Warning(const char *){}
@@ -470,7 +470,7 @@ public:
virtual void Log (const char *){}
virtual const char *Name(void){return 0L;}
- bool bErr,bMsg,bLog,bWrn;
+ bool bErr,bMsg,bLog,bWrn,bShow;
};
diff --git a/src/Gui/DlgReportView.ui b/src/Gui/DlgReportView.ui
index 50503dcf64..52f7f46189 100644
--- a/src/Gui/DlgReportView.ui
+++ b/src/Gui/DlgReportView.ui
@@ -86,6 +86,22 @@
+ -
+
+
+ Show report view on warning or error
+
+
+ true
+
+
+ checkShowReportViewOnWarningOrError
+
+
+ OutputWindow
+
+
+
@@ -469,6 +485,7 @@ from Python console to Report view panel
checkLogging
checkWarning
checkError
+ checkShowReportViewOnWarningOrError
colorText
colorLogging
colorWarning
diff --git a/src/Gui/DlgReportViewImp.cpp b/src/Gui/DlgReportViewImp.cpp
index ead132d5c9..d6baca83f3 100644
--- a/src/Gui/DlgReportViewImp.cpp
+++ b/src/Gui/DlgReportViewImp.cpp
@@ -59,6 +59,7 @@ void DlgReportViewImp::saveSettings()
checkLogging->onSave();
checkWarning->onSave();
checkError->onSave();
+ checkShowReportViewOnWarningOrError->onSave();
colorText->onSave();
colorLogging->onSave();
colorWarning->onSave();
@@ -72,6 +73,7 @@ void DlgReportViewImp::loadSettings()
checkLogging->onRestore();
checkWarning->onRestore();
checkError->onRestore();
+ checkShowReportViewOnWarningOrError->onRestore();
colorText->onRestore();
colorLogging->onRestore();
colorWarning->onRestore();
diff --git a/src/Gui/ReportView.cpp b/src/Gui/ReportView.cpp
index 79b7d24f63..9850eaff33 100644
--- a/src/Gui/ReportView.cpp
+++ b/src/Gui/ReportView.cpp
@@ -37,6 +37,8 @@
#include "PythonConsole.h"
#include "PythonConsolePy.h"
#include "BitmapFactory.h"
+#include "MainWindow.h"
+#include "Application.h"
using namespace Gui;
using namespace Gui::DockWnd;
@@ -148,6 +150,8 @@ void ReportHighlighter::highlightBlock (const QString & text)
ud->block.append(b);
QVector block = ud->block;
+ bool hasErrors = false;
+ bool hasWarnings = false;
int start = 0;
for (QVector::Iterator it = block.begin(); it != block.end(); ++it) {
switch (it->type)
@@ -157,9 +161,11 @@ void ReportHighlighter::highlightBlock (const QString & text)
break;
case Warning:
setFormat(start, it->length-start, warnCol);
+ hasWarnings = true;
break;
case Error:
setFormat(start, it->length-start, errCol);
+ hasErrors = true;
break;
case LogText:
setFormat(start, it->length-start, logCol);
@@ -170,6 +176,22 @@ void ReportHighlighter::highlightBlock (const QString & text)
start = it->length;
}
+ if(hasErrors || hasWarnings){
+ //activate report view unless this is disabled in preferences
+
+ ParameterGrp::handle group = App::GetApplication().GetUserParameter().
+ GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("OutputWindow");
+ bool showReportViewOnWarningOrError = group->GetBool("checkShowReportViewOnWarningOrError", true);
+ if (showReportViewOnWarningOrError){
+ QWidget* reportView = Gui::getMainWindow()->findChild(QString::fromLatin1("Report view"));
+ if (reportView){
+ if (!reportView->isVisible()){
+ reportView->show();
+ }
+ }
+ }
+
+ }
}
void ReportHighlighter::setParagraphType(ReportHighlighter::Paragraph t)
@@ -470,6 +492,10 @@ void ReportOutput::onToggleError()
getWindowParameter()->SetBool( "checkError", bErr );
}
+void ReportOutput::onToggleShowReportViewOnWarningOrError(){
+ bShow = bShow ? false : true;
+ getWindowParameter()->SetBool("checkShowReportViewOnWarningOrError", bShow);
+}
void ReportOutput::onToggleWarning()
{
bWrn = bWrn ? false : true;
diff --git a/src/Gui/ReportView.h b/src/Gui/ReportView.h
index 1ab5038d36..9aaeede88d 100644
--- a/src/Gui/ReportView.h
+++ b/src/Gui/ReportView.h
@@ -171,6 +171,8 @@ public Q_SLOTS:
void onToggleWarning();
/** Toggles the report of log messages. */
void onToggleLogging();
+ /** Toggles whether to show report view on warnings or errors */
+ void onToggleShowReportViewOnWarningOrError();
/** Toggles the redirection of Python stdout. */
void onToggleRedirectPythonStdout();
/** Toggles the redirection of Python stderr. */