Visual Computing Library
Loading...
Searching...
No Matches
message_hider.h
1#ifndef VCL_QT_MESSAGE_HIDER_H
2#define VCL_QT_MESSAGE_HIDER_H
3
4#include <QtMessageHandler>
5
6namespace vcl::qt {
7
9{
10 inline static QtMessageHandler originalHandler = nullptr;
11 inline static bool debug = true;
12 inline static bool info = false;
13 inline static bool warning = false;
14 inline static bool critical = true;
15 inline static bool fatal = true;
16
17 static void message(
18 QtMsgType type,
20 const QString& msg)
21 {
22 switch (type) {
23 case QtMsgType::QtDebugMsg:
24 if (debug)
25 originalHandler(type, context, msg);
26 break;
27 case QtMsgType::QtInfoMsg:
28 if (info)
29 originalHandler(type, context, msg);
30 break;
31 case QtMsgType::QtWarningMsg:
32 if (warning)
33 originalHandler(type, context, msg);
34 break;
35 case QtMsgType::QtCriticalMsg:
36 if (critical)
37 originalHandler(type, context, msg);
38 break;
39 case QtMsgType::QtFatalMsg:
40 if (fatal)
41 originalHandler(type, context, msg);
42 break;
43 }
44 }
45
46public:
47 static void activate()
48 {
49 originalHandler = qInstallMessageHandler(message);
50 }
51
52 static void deactivate() { qInstallMessageHandler(originalHandler); }
53
54 static void hideMessages(
55 bool debug,
56 bool info,
57 bool warning,
58 bool critical,
59 bool fatal)
60 {
61 MessageHider::debug = debug;
62 MessageHider::info = info;
63 MessageHider::warning = warning;
64 MessageHider::critical = critical;
65 MessageHider::fatal = fatal;
66 }
67};
68
69} // namespace vcl::qt
70
71#endif // VCL_QT_MESSAGE_HIDER_H
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
Definition message_hider.h:9