Commit 7bd04af4 authored by Jaswant Panchumarti's avatar Jaswant Panchumarti
Browse files

Suppress Output Messages From Opening Again

- Addresses #12587
- Adds a checkbox (default unchecked) that pops up the Output Messages
window when there are new messages available.
- If the output messages is docked, then this checkbox is disabled.
- This option is also saved into settings.
parent 4e23154b
......@@ -400,6 +400,11 @@ void ParaViewMainWindow::updateFontSize()
void ParaViewMainWindow::handleMessage(const QString&, int type)
{
QDockWidget* dock = this->Internals->outputWidgetDock;
pqOutputWidget* outputWidget = qobject_cast<pqOutputWidget*>(dock->widget());
if (dock->isFloating() && !outputWidget->shouldOpenForNewMessages())
{
return;
}
if (!dock->isVisible() && (type == QtCriticalMsg || type == QtFatalMsg || type == QtWarningMsg))
{
// if dock is not visible, we always pop it up as a floating dialog. This
......
## Add Option To Not Open OutputMessages For New Messages
A checkbox is now provided in the OutputMessages window
to ask it not to reopen itself everytime there is a new message available.
ParaView disables this checkbox when the OutputMessages is docked.
![Checkbox To Control Reopening Of OutputMessages](../img/dev/always-open-for-new-messages.png)
......@@ -61,7 +61,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,0,0,0">
<layout class="QHBoxLayout" name="horizontalLayout" stretch="0,1,0,0,0,0">
<item>
<widget class="QCheckBox" name="showFullMessagesCheckBox">
<property name="toolTip">
......@@ -72,6 +72,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="alwaysOpenForNewMessagesCheckBox">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;If unchecked and the window is closed, the window will remain closed when new messages are available.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Always open for new messages</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="copyButton">
<property name="text">
......
......@@ -41,6 +41,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "vtkOutputWindow.h"
#include <QClipboard>
#include <QDockWidget>
#include <QMutexLocker>
#include <QPointer>
#include <QScopedValueRollback>
......@@ -189,6 +190,7 @@ class pqOutputWidget::pqInternals
}
public:
bool FirstShowFinished = false;
Ui::OutputWidget Ui;
QPointer<QStandardItemModel> Model;
vtkNew<OutputWidgetInternals::OutputWindow> VTKOutputWindow;
......@@ -355,16 +357,17 @@ public:
pqSettings* settings = pqApplicationCore::instance()->settings();
this->Parent->showFullMessages(
settings->value(QString("%1.ShowFullMessages").arg(key), false).toBool());
this->Parent->alwaysOpenForNewMessages(
settings->value(QString("%1.AlwaysOpenForNewMessages").arg(key), false).toBool());
}
}
void saveSettings()
void saveSetting(const QString& settingName, const QVariant& value)
{
if (!this->SettingsKey.isEmpty())
if (!this->SettingsKey.isEmpty() && !settingName.isEmpty())
{
pqSettings* settings = pqApplicationCore::instance()->settings();
settings->setValue(QString("%1.ShowFullMessages").arg(this->SettingsKey),
this->Ui.showFullMessagesCheckBox->isChecked());
settings->setValue(QString("%1.%2").arg(this->SettingsKey).arg(settingName), value);
}
}
......@@ -418,6 +421,8 @@ pqOutputWidget::pqOutputWidget(QWidget* parentObject, Qt::WindowFlags f)
this->connect(
internals.Ui.showFullMessagesCheckBox, SIGNAL(toggled(bool)), SLOT(showFullMessages(bool)));
this->connect(internals.Ui.alwaysOpenForNewMessagesCheckBox, SIGNAL(toggled(bool)),
SLOT(alwaysOpenForNewMessages(bool)));
this->connect(internals.Ui.saveButton, SIGNAL(clicked()), SLOT(saveToFile()));
this->connect(internals.Ui.copyButton, SIGNAL(clicked()), SLOT(copyToClipboard()));
......@@ -528,13 +533,48 @@ QString pqOutputWidget::extractSummary(const QString& message, QtMsgType)
return message.left(message.indexOf('\n'));
}
//-----------------------------------------------------------------------------
void pqOutputWidget::alwaysOpenForNewMessages(bool val)
{
pqInternals& internals = (*this->Internals);
internals.Ui.alwaysOpenForNewMessagesCheckBox->setChecked(val);
internals.saveSetting("AlwaysOpenForNewMessages", val);
}
//-----------------------------------------------------------------------------
bool pqOutputWidget::shouldOpenForNewMessages()
{
pqInternals& internals = (*this->Internals);
return internals.FirstShowFinished ? internals.Ui.alwaysOpenForNewMessagesCheckBox->isChecked()
: true;
}
//-----------------------------------------------------------------------------
void pqOutputWidget::showEvent(QShowEvent* event)
{
this->Superclass::showEvent(event);
pqInternals& internals = (*this->Internals);
internals.FirstShowFinished = true;
// if we're docked, then disable 'Always open for new messages' checkbox
QDockWidget* dock = qobject_cast<QDockWidget*>(this->parentWidget());
if (dock != nullptr && !dock->isFloating())
{
internals.Ui.alwaysOpenForNewMessagesCheckBox->setEnabled(false);
}
else
{
internals.Ui.alwaysOpenForNewMessagesCheckBox->setEnabled(true);
}
}
//-----------------------------------------------------------------------------
void pqOutputWidget::showFullMessages(bool val)
{
pqInternals& internals = (*this->Internals);
internals.Ui.showFullMessagesCheckBox->setChecked(val);
internals.Ui.stackedWidget->setCurrentIndex(val ? 1 : 0);
internals.saveSettings();
internals.saveSetting("ShowFullMessages", val);
}
//-----------------------------------------------------------------------------
......
......@@ -134,6 +134,11 @@ public:
void setFontSize(int fontSize);
//@}
/**
* Get the state of the 'Always open for new messages' checkbox.
*/
bool shouldOpenForNewMessages();
public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
/**
* Display a message in the widget. There's generally no need to use this
......@@ -144,6 +149,11 @@ public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
*/
bool displayMessage(const QString& message, QtMsgType type = QtInfoMsg);
/**
* Always open the messages window for every new message unless it is docked.
*/
void alwaysOpenForNewMessages(bool val);
/**
* Show full messages instead of grouped messages.
*/
......@@ -164,6 +174,11 @@ public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
*/
void clear();
/**
* Record the first ever show event.
*/
void showEvent(QShowEvent* event) override;
Q_SIGNALS:
/**
* Signal fired any time a message is displayed.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment