pqOutputWidget.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqOutputWidget_h
5 #define pqOutputWidget_h
6 
7 #include <QWidget>
8 
9 #include "pqCoreModule.h" // for exports
10 #include <QScopedPointer> // for QScopedPointer.
11 
12 class pqOutputWidget;
13 
15 {
16 class OutputWindow;
17 };
18 
19 Q_DECLARE_METATYPE(QtMsgType) // NOLINT(performance-no-int-to-ptr)
33 class PQCORE_EXPORT MessageHandler : public QObject
34 {
35  Q_OBJECT
36 public:
37  MessageHandler(QObject* parent = nullptr);
38 
45  static void install(pqOutputWidget* widget);
46 
50  static void handler(QtMsgType type, const QMessageLogContext&, const QString& msg);
51 
55  static void handlerVTK(QtMsgType type, const QString& msg);
56 
57 Q_SIGNALS:
58  void message(QtMsgType type, const QString& msg);
59  void showMessage(QString msg, QtMsgType type);
60 
61 private:
62  static MessageHandler* instance();
63 
64 private Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
65  void displayMessage(QtMsgType type, const QString& msg);
66 };
67 
77 class PQCORE_EXPORT pqOutputWidget : public QWidget
78 {
79  Q_OBJECT
80  typedef QWidget Superclass;
81  Q_PROPERTY(QString settingsKey READ settingsKey WRITE setSettingsKey);
82 
83 public:
84  pqOutputWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
85  ~pqOutputWidget() override;
86 
91  void suppress(const QStringList& substrs);
92 
94 
98  void setSettingsKey(const QString& key);
99  const QString& settingsKey() const;
101 
103 
106  void setFontSize(int fontSize);
108 
112  bool shouldOpenForNewMessages();
113 
114 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
122  bool displayMessage(const QString& message, QtMsgType type = QtInfoMsg);
123 
127  void alwaysOpenForNewMessages(bool val);
128 
132  void showFullMessages(bool val);
133 
137  void copyToClipboard();
138 
142  void saveToFile();
143 
147  void clear();
148 
152  void showEvent(QShowEvent* event) override;
153 
154 Q_SIGNALS:
158  void messageDisplayed(const QString& message, int type);
159 
160 protected:
164  virtual bool suppress(const QString& message, QtMsgType type);
165 
169  virtual QString extractSummary(const QString& message, QtMsgType type);
170 
171 private:
172  Q_DISABLE_COPY(pqOutputWidget)
173 
174  class pqInternals;
175  QScopedPointer<pqInternals> Internals;
176  friend class OutputWidgetInternals::OutputWindow;
177 };
178 
179 #endif
Q_DECLARE_METATYPE(pqSMProxy) static class PQCORE_EXPORT pqSMProxySchwartzCounter
declare pqSMProxy for use with QVariant
Definition: pqSMProxy.h:21
type
widget to show Qt and VTK messages.
void VTKPVADAPTORSCTH_EXPORT handler(int sig)
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
widget to show Qt and VTK messages.