Ensure formatting tags aren't exported/put on the clipboard. Refs #2382

* When we're formatting text we want just the plain text version to be used.
This commit is contained in:
baldurk
2021-10-06 16:31:43 +01:00
parent 73f0c7681f
commit 73f78bd8a4
2 changed files with 35 additions and 6 deletions
+27 -2
View File
@@ -189,6 +189,8 @@ struct ShaderMessageLink
Q_DECLARE_METATYPE(ShaderMessageLink);
static QRegularExpression htmlRE(lit("<[^>]*>"));
// this is an opaque struct that contains the data to render, hit-test, etc for some text that
// contains links to resources. It will update and cache the names of the resources.
struct RichResourceText
@@ -242,9 +244,24 @@ struct RichResourceText
{
text += lit("EID @%1").arg(v.toUInt());
}
else if(v.userType() == qMetaTypeId<ShaderMessageLink>())
{
ShaderMessageLink link = v.value<ShaderMessageLink>();
text +=
QApplication::translate("qrenderdoc", "%n msg(s)", "Shader messages", link.numMessages);
}
else
{
text += v.toString();
if(forcehtml)
{
// strip html tags and convert any html entities
text += QUrl::fromPercentEncoding(v.toString().replace(htmlRE, QString()).toLatin1());
}
else
{
text += v.toString();
}
}
}
}
@@ -340,7 +357,15 @@ struct RichResourceText
lit("\n"),
lit("</td></tr></table><table><tr><td valign=\"middle\" style=\"line-height: 14px\">"));
text += v.toString();
if(forcehtml)
{
text += QUrl::fromPercentEncoding(v.toString().replace(htmlRE, QString()).toLatin1());
}
else
{
text += v.toString();
}
html += lit("<td valign=\"middle\" style=\"line-height: 14px\">%1</td>").arg(htmlfrag);
numLines += newlines;
+8 -4
View File
@@ -1162,6 +1162,8 @@ private:
}
}
bool forceHTML = false;
if(name.isEmpty())
{
for(const APIEvent &e : action->events)
@@ -1218,10 +1220,7 @@ private:
if(name.isEmpty())
qCritical() << "Couldn't find APIEvent for" << eid;
// force html even for events that don't reference resources etc, to get the italics for
// parameters
if(m_ShowParameterNames)
name = lit("<rdhtml>") + name + lit("</rdhtml>");
forceHTML = m_ShowParameterNames;
}
if(m_MessageCounts.contains(eid))
@@ -1231,6 +1230,11 @@ private:
name += lit(" __rd_msgs::%1:%2").arg(eid).arg(count);
}
// force html even for events that don't reference resources etc, to get the italics for
// parameters
if(forceHTML)
name = lit("<rdhtml>") + name + lit("</rdhtml>");
QVariant v = name;
RichResourceTextInitialise(v, &m_Ctx);