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)
20 
34 class PQCORE_EXPORT MessageHandler : public QObject
35 {
36  Q_OBJECT
37 public:
38  MessageHandler(QObject* parent = nullptr);
39 
46  static void install(pqOutputWidget* widget);
47 
51  static void handler(QtMsgType type, const QMessageLogContext&, const QString& msg);
52 
56  static void handlerVTK(QtMsgType type, const QString& msg);
57 
58 Q_SIGNALS:
59  void message(QtMsgType type, const QString& msg);
60  void showMessage(QString msg, QtMsgType type);
61 
62 private:
63  static MessageHandler* instance();
64 
65 private Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
66  void displayMessage(QtMsgType type, const QString& msg);
67 };
68 
78 class PQCORE_EXPORT pqOutputWidget : public QWidget
79 {
80  Q_OBJECT
81  typedef QWidget Superclass;
82  Q_PROPERTY(QString settingsKey READ settingsKey WRITE setSettingsKey);
83 
84 public:
85  pqOutputWidget(QWidget* parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
86  ~pqOutputWidget() override;
87 
92  void suppress(const QStringList& substrs);
93 
95 
99  void setSettingsKey(const QString& key);
100  const QString& settingsKey() const;
102 
104 
107  void setFontSize(int fontSize);
109 
113  bool shouldOpenForNewMessages();
114 
115 public Q_SLOTS: // NOLINT(readability-redundant-access-specifiers)
123  bool displayMessage(const QString& message, QtMsgType type = QtInfoMsg);
124 
128  void alwaysOpenForNewMessages(bool val);
129 
133  void showFullMessages(bool val);
134 
138  void copyToClipboard();
139 
143  void saveToFile();
144 
148  void clear();
149 
153  void showEvent(QShowEvent* event) override;
154 
155 Q_SIGNALS:
159  void messageDisplayed(const QString& message, int type);
160 
161 protected:
165  virtual bool suppress(const QString& message, QtMsgType type);
166 
170  virtual QString extractSummary(const QString& message, QtMsgType type);
171 
172 private:
173  Q_DISABLE_COPY(pqOutputWidget);
174 
175  class pqInternals;
176  QScopedPointer<pqInternals> Internals;
177  friend class OutputWidgetInternals::OutputWindow;
178 };
179 
180 #endif
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.
Q_DECLARE_METATYPE(QtMsgType)