Vuo  2.4.0
VuoRendererCommon.cc
Go to the documentation of this file.
1
10#include "VuoRendererCommon.hh"
11
12#include "VuoCompiler.hh"
14#include "VuoNodeClass.hh"
15#include "VuoNodeSet.hh"
16
20void VuoRendererCommon::messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &message)
21{
22 const char *func = context.function;
23 if (!func)
24 {
25 if (type == QtDebugMsg)
26 func = "QMessageLogger::debug";
27 else if (type == QtInfoMsg)
28 func = "QMessageLogger::info";
29 else if (type == QtWarningMsg)
30 func = "QMessageLogger::warning";
31 else if (type == QtCriticalMsg)
32 func = "QMessageLogger::critical";
33 else if (type == QtFatalMsg)
34 func = "QMessageLogger::fatal";
35 else
36 func = "?";
37 }
38
39 if (context.category && strcmp(context.category, "qt.network.ssl") == 0
40 && message == "Error receiving trust for a CA certificate")
41 // Quell this warning; a Qt developer says:
42 // "you can ignore this message … it's a result of some certificates removed on OS X 10.11."
43 // https://bugreports.qt.io/browse/QTBUG-54161
44 return;
45
46 if (type == QtWarningMsg && message.startsWith("QVariant::save: unable to save type 'VuoRendererPublishedPort*' (type id:"))
47 // Quell this warning; VuoRendererPorts only exist within a single editor process lifetime; we don't need to serialize them.
48 return;
49
50 if (type == QtWarningMsg && message.startsWith("Layer-backing can not be explicitly controlled"))
51 // Quell this warning; `QT_MAC_WANTS_LAYER` does still make a difference.
52 // https://b33p.net/kosada/vuo/vuo/-/issues/17855
53 // https://b33p.net/kosada/vuo/vuo/-/issues/13819
54 // https://bugreports.qt.io/browse/QTBUG-81370
55 return;
56
57 if (type == QtWarningMsg && message.startsWith("Display non non-main thread! Deferring to main thread"))
58 // Quell this warning; it's internal to Qt.
59 return;
60
62 context.file ? context.file : (context.category ? context.category : "?"),
63 context.line,
64 func,
65 "%s", message.toUtf8().constData());
66}
67
75QString VuoRendererCommon::externalizeVuoNodeLinks(VuoCompiler *compiler, QString markdownText, bool outputAbsoluteLinks)
76{
77 QString filteredText(markdownText);
78 QRegularExpression vuoNodeLink("\\[(.*)\\](\\(vuo-node://(.*)\\))", QRegularExpression::InvertedGreedinessOption);
79 QRegularExpression vuoNodeSetLink("\\[(.*)\\](\\(vuo-nodeset://(.*)\\))", QRegularExpression::InvertedGreedinessOption);
80
81 QString prefix = "../";
82 if (outputAbsoluteLinks)
83 prefix = "https://doc.vuo.org/" VUO_VERSION_STRING "/node/";
84
85 // Map node class links.
86 size_t startPos = 0;
87 QRegularExpressionMatch match = vuoNodeLink.match(filteredText, startPos);
88 while (match.hasMatch())
89 {
90 QString nodeClassDisplayTitle = match.captured(1);
91 QString nodeClassName = match.captured(3);
92
93 VuoCompilerNodeClass *nodeClass = compiler->getNodeClass(nodeClassName.toStdString());
94 QString nodeSetName = (nodeClass? QString::fromStdString(nodeClass->getBase()->getNodeSet()->getName()) : "");
95 QString mappedLink = QString("[")
96 .append(nodeClassDisplayTitle)
97 .append("](")
98 .append(prefix)
99 .append(nodeSetName)
100 .append("/")
101 .append(nodeClassName)
102 .append(".html)");
103
104 filteredText.replace(match.capturedStart(), match.capturedLength(), mappedLink);
105 startPos = (match.capturedStart() + mappedLink.length());
106 match = vuoNodeLink.match(filteredText, startPos);
107 }
108
109 // Map node set links.
110 startPos = 0;
111 match = vuoNodeSetLink.match(filteredText, startPos);
112 while (match.hasMatch())
113 {
114 QString nodeSetDisplayTitle = match.captured(1);
115 QString nodeSetName = match.captured(3);
116
117 QString mappedLink = QString("[")
118 .append(nodeSetDisplayTitle)
119 .append("](")
120 .append(prefix)
121 .append(nodeSetName)
122 .append("/index.html)");
123
124 filteredText.replace(match.capturedStart(), match.capturedLength(), mappedLink);
125 startPos = (match.capturedStart() + mappedLink.length());
126 match = vuoNodeSetLink.match(filteredText, startPos);
127 }
128
129 return filteredText;
130}
131
136{
137 QFile f(":/Vuo.qss");
138 f.open(QFile::ReadOnly | QFile::Text);
139 QTextStream ts(&f);
140 QString styles = ts.readAll();
141
142 if (isDark)
143 {
144 QFile fDark(":/pro/VuoDark.qss");
145 fDark.open(QFile::ReadOnly | QFile::Text);
146 QTextStream tsDark(&fDark);
147 styles += tsDark.readAll();
148 }
149
150 return styles;
151}