Skip to content

Commit

Permalink
Gui: add an option to also suppress normal messages
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jul 31, 2020
1 parent a41ad33 commit ed4876a
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 28 deletions.
33 changes: 26 additions & 7 deletions src/Gui/DlgReportView.ui
Expand Up @@ -33,6 +33,25 @@
<number>11</number>
</property>
<item row="0" column="0">
<widget class="Gui::PrefCheckBox" name="checkMessage">
<property name="toolTip">
<string>Normal messages will be recorded</string>
</property>
<property name="text">
<string>Record normal messages</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>checkMessage</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>OutputWindow</cstring>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="Gui::PrefCheckBox" name="checkLogging">
<property name="toolTip">
<string>Log messages will be recorded</string>
Expand All @@ -48,7 +67,7 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="Gui::PrefCheckBox" name="checkWarning">
<property name="toolTip">
<string>Warnings will be recorded</string>
Expand All @@ -67,7 +86,7 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="Gui::PrefCheckBox" name="checkError">
<property name="toolTip">
<string>Error messages will be recorded</string>
Expand All @@ -86,7 +105,7 @@
</property>
</widget>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnError">
<property name="toolTip">
<string>When an error has occurred, the Report View dialog becomes visible
Expand All @@ -106,7 +125,7 @@ on-screen while displaying the error</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnWarning">
<property name="toolTip">
<string>When a warning has occurred, the Report View dialog becomes visible
Expand All @@ -126,7 +145,7 @@ on-screen while displaying the warning</string>
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnNormalMessage">
<property name="toolTip">
<string>When a normal message has occurred, the Report View dialog becomes visible
Expand All @@ -146,7 +165,7 @@ on-screen while displaying the message</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="Gui::PrefCheckBox" name="checkShowReportViewOnLogMessage">
<property name="toolTip">
<string>When a log message has occurred, the Report View dialog becomes visible
Expand All @@ -166,7 +185,7 @@ on-screen while displaying the log message</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="Gui::PrefCheckBox" name="checkShowReportTimecode">
<property name="toolTip">
<string>Include a timecode for each report</string>
Expand Down
2 changes: 2 additions & 0 deletions src/Gui/DlgReportViewImp.cpp
Expand Up @@ -58,6 +58,7 @@ DlgReportViewImp::~DlgReportViewImp()

void DlgReportViewImp::saveSettings()
{
ui->checkMessage->onSave();
ui->checkLogging->onSave();
ui->checkWarning->onSave();
ui->checkError->onSave();
Expand All @@ -76,6 +77,7 @@ void DlgReportViewImp::saveSettings()

void DlgReportViewImp::loadSettings()
{
ui->checkMessage->onRestore();
ui->checkLogging->onRestore();
ui->checkWarning->onRestore();
ui->checkError->onRestore();
Expand Down
57 changes: 38 additions & 19 deletions src/Gui/ReportView.cpp
Expand Up @@ -498,7 +498,11 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e )
displayMenu->setTitle(tr("Display message types"));
optionMenu->addMenu(displayMenu);

QAction* logAct = displayMenu->addAction(tr("Log messages"), this, SLOT(onToggleLogging()));
QAction* logMsg = displayMenu->addAction(tr("Normal messages"), this, SLOT(onToggleNormalMessage()));
logMsg->setCheckable(true);
logMsg->setChecked(bMsg);

QAction* logAct = displayMenu->addAction(tr("Log messages"), this, SLOT(onToggleLogMessage()));
logAct->setCheckable(true);
logAct->setChecked(bLog);

Expand All @@ -512,7 +516,7 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e )

QMenu* showOnMenu = new QMenu (optionMenu);
showOnMenu->setTitle(tr("Show report view on"));
optionMenu->insertMenu(optionMenu->actions().front(), showOnMenu);
optionMenu->addMenu(showOnMenu);

QAction* showNormAct = showOnMenu->addAction(tr("Normal messages"), this, SLOT(onToggleShowReportViewOnNormalMessage()));
showNormAct->setCheckable(true);
Expand Down Expand Up @@ -580,49 +584,64 @@ bool ReportOutput::isWarning() const
return bWrn;
}

bool ReportOutput::isLogging() const
bool ReportOutput::isLogMessage() const
{
return bLog;
}

bool ReportOutput::isNormalMessage() const
{
return bMsg;
}

void ReportOutput::onToggleError()
{
bErr = bErr ? false : true;
getWindowParameter()->SetBool( "checkError", bErr );
}

void ReportOutput::onToggleShowReportViewOnWarning(){
void ReportOutput::onToggleWarning()
{
bWrn = bWrn ? false : true;
getWindowParameter()->SetBool( "checkWarning", bWrn );
}

void ReportOutput::onToggleLogMessage()
{
bLog = bLog ? false : true;
getWindowParameter()->SetBool( "checkLogging", bLog );
}

void ReportOutput::onToggleNormalMessage()
{
bMsg = bMsg ? false : true;
getWindowParameter()->SetBool( "checkMessage", bMsg );
}

void ReportOutput::onToggleShowReportViewOnWarning()
{
bool show = getWindowParameter()->GetBool("checkShowReportViewOnWarning", true);
getWindowParameter()->SetBool("checkShowReportViewOnWarning", !show);
}

void ReportOutput::onToggleShowReportViewOnError(){
void ReportOutput::onToggleShowReportViewOnError()
{
bool show = getWindowParameter()->GetBool("checkShowReportViewOnError", true);
getWindowParameter()->SetBool("checkShowReportViewOnError", !show);
}

void ReportOutput::onToggleShowReportViewOnNormalMessage(){
void ReportOutput::onToggleShowReportViewOnNormalMessage()
{
bool show = getWindowParameter()->GetBool("checkShowReportViewOnNormalMessage", true);
getWindowParameter()->SetBool("checkShowReportViewOnNormalMessage", !show);
}

void ReportOutput::onToggleShowReportViewOnLogMessage(){
void ReportOutput::onToggleShowReportViewOnLogMessage()
{
bool show = getWindowParameter()->GetBool("checkShowReportViewOnLogMessage", true);
getWindowParameter()->SetBool("checkShowReportViewOnLogMessage", !show);
}

void ReportOutput::onToggleWarning()
{
bWrn = bWrn ? false : true;
getWindowParameter()->SetBool( "checkWarning", bWrn );
}

void ReportOutput::onToggleLogging()
{
bLog = bLog ? false : true;
getWindowParameter()->SetBool( "checkLogging", bLog );
}

void ReportOutput::onToggleRedirectPythonStdout()
{
if (d->redirected_stdout) {
Expand Down
8 changes: 6 additions & 2 deletions src/Gui/ReportView.h
Expand Up @@ -148,7 +148,9 @@ class GuiExport ReportOutput : public QTextEdit, public WindowParameter, public
/** Returns true whether warnings are reported. */
bool isWarning() const;
/** Returns true whether log messages are reported. */
bool isLogging() const;
bool isLogMessage() const;
/** Returns true whether normal messages are reported. */
bool isNormalMessage() const;

protected:
/** For internal use only */
Expand All @@ -166,7 +168,9 @@ public Q_SLOTS:
/** Toggles the report of warnings. */
void onToggleWarning();
/** Toggles the report of log messages. */
void onToggleLogging();
void onToggleLogMessage();
/** Toggles the report of normal messages. */
void onToggleNormalMessage();
/** Toggles whether to show report view on warnings*/
void onToggleShowReportViewOnWarning();
/** Toggles whether to show report view on errors*/
Expand Down

0 comments on commit ed4876a

Please sign in to comment.