summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/lancelot/paintcommands.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-12-04 19:41:52 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2018-12-04 19:41:52 +0000
commit009a5538ebce4c5517a717a201707f2b79749f64 (patch)
tree9dfd3f3d3b6ab997eeb37215e948b5af7160beb8 /tests/auto/other/lancelot/paintcommands.cpp
parente19df161cdc14f834a278fe0939d50475864a78c (diff)
parent5d5c00c67682bce105197b659687fd1fee8f60cf (diff)
Merge "Merge remote-tracking branch 'origin/5.12' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/other/lancelot/paintcommands.cpp')
-rw-r--r--tests/auto/other/lancelot/paintcommands.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/other/lancelot/paintcommands.cpp b/tests/auto/other/lancelot/paintcommands.cpp
index 65a688ec40..8aa3a035e3 100644
--- a/tests/auto/other/lancelot/paintcommands.cpp
+++ b/tests/auto/other/lancelot/paintcommands.cpp
@@ -36,6 +36,7 @@
#include <qtextlayout.h>
#include <qdebug.h>
#include <QStaticText>
+#include <QTextDocument>
#include <private/qimage_p.h>
#ifndef QT_NO_OPENGL
@@ -441,6 +442,10 @@ void PaintCommands::staticInit()
"^drawStaticText\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
"drawStaticText <x> <y> <text>",
"drawStaticText 10 10 \"my text\"");
+ DECL_PAINTCOMMAND("drawTextDocument", command_drawTextDocument,
+ "^drawTextDocument\\s+(-?\\w*)\\s+(-?\\w*)\\s+\"(.*)\"$",
+ "drawTextDocument <x> <y> <html>",
+ "drawTextDocument 10 10 \"html\"");
DECL_PAINTCOMMAND("drawTiledPixmap", command_drawTiledPixmap,
"^drawTiledPixmap\\s+([\\w.:\\/]*)"
"\\s+(-?\\w*)\\s+(-?\\w*)\\s*(-?\\w*)\\s*(-?\\w*)"
@@ -1295,6 +1300,29 @@ void PaintCommands::command_drawStaticText(QRegularExpressionMatch re)
m_painter->drawStaticText(x, y, QStaticText(txt));
}
+void PaintCommands::command_drawTextDocument(QRegularExpressionMatch re)
+{
+ if (!m_shouldDrawText)
+ return;
+ QStringList caps = re.capturedTexts();
+ int x = convertToInt(caps.at(1));
+ int y = convertToInt(caps.at(2));
+ QString txt = caps.at(3);
+
+ if (m_verboseMode)
+ printf(" -(lance) drawTextDocument(%d, %d, %s)\n", x, y, qPrintable(txt));
+
+ QTextDocument doc;
+ doc.setBaseUrl(QUrl::fromLocalFile(QDir::currentPath() + QLatin1String("/")));
+ doc.setHtml(txt);
+
+ m_painter->save();
+ m_painter->translate(x, y);
+ doc.drawContents(m_painter);
+ m_painter->restore();
+}
+
+
/***************************************************************************************************/
void PaintCommands::command_noop(QRegularExpressionMatch)
{