summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2020-11-03 20:51:57 +0100
committerShawn Rutledge <shawn.rutledge@qt.io>2020-11-07 09:35:11 +0100
commitf5c7799f59ba53c634906b11e2135190093bf87b (patch)
treec170f7ed71df77a3d8baebfb225c9179e58f72bb /tests/auto/gui
parent2106a625e8fa3eabfe2f3a774baacc898c763b44 (diff)
Support the markdown underline extension
MarkdownDialectGitHub now includes this feature, so *emph* is italicized and _emph_ is underlined. This is a better fit for QTextDocument capabilities; until now, _underlined_ markdown could be read, but would be rendered with italics, because in CommonMark, *emphasis* and _emphasis_ are the same. But QTextMarkdownWriter already writes underlining and italics distinctly in this way. [ChangeLog][QtGui][Text] By default (with MarkdownDialectGitHub), markdown _underline_ and *italic* text styles are now distinct. Fixes: QTBUG-84429 Change-Id: Ifc6defa4852abe831949baa4ce28bae5f1a82265 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp15
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/example.md11
2 files changed, 18 insertions, 8 deletions
diff --git a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
index bc9dc1b695..d652db0699 100644
--- a/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
+++ b/tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp
@@ -69,9 +69,10 @@ public:
Normal = 0x0,
Italic = 0x1,
Bold = 0x02,
- Strikeout = 0x04,
- Mono = 0x08,
- Link = 0x10
+ Underlined = 0x04,
+ Strikeout = 0x08,
+ Mono = 0x10,
+ Link = 0x20
};
Q_DECLARE_FLAGS(CharFormats, CharFormat)
};
@@ -252,6 +253,12 @@ void tst_QTextMarkdownImporter::nestedSpans_data()
QTest::newRow("bold italic")
<< "before ***bold italic*** after"
<< 1 << (Bold | Italic);
+ QTest::newRow("bold underlined")
+ << "before **_bold underlined_** after"
+ << 1 << (Bold | Underlined);
+ QTest::newRow("italic underlined")
+ << "before *_italic underlined_* after"
+ << 1 << (Italic | Underlined);
QTest::newRow("bold strikeout")
<< "before **~~bold strikeout~~** after"
<< 1 << (Bold | Strikeout);
@@ -322,12 +329,14 @@ void tst_QTextMarkdownImporter::nestedSpans()
QTextCharFormat fmt = cur.charFormat();
qCDebug(lcTests) << "word" << wordToCheck << cur.selectedText() << "font" << fmt.font()
<< "weight" << fmt.fontWeight() << "italic" << fmt.fontItalic()
+ << "underlined" << fmt.fontUnderline()
<< "strikeout" << fmt.fontStrikeOut() << "anchor" << fmt.isAnchor()
<< "monospace" << QFontInfo(fmt.font()).fixedPitch() // depends on installed fonts (QTBUG-75649)
<< fmt.fontFixedPitch() // returns false even when font family is "monospace"
<< fmt.hasProperty(QTextFormat::FontFixedPitch); // works
QCOMPARE(fmt.fontWeight() > QFont::Normal, expectedFormat.testFlag(Bold));
QCOMPARE(fmt.fontItalic(), expectedFormat.testFlag(Italic));
+ QCOMPARE(fmt.fontUnderline(), expectedFormat.testFlag(Underlined));
QCOMPARE(fmt.fontStrikeOut(), expectedFormat.testFlag(Strikeout));
QCOMPARE(fmt.isAnchor(), expectedFormat.testFlag(Link));
QCOMPARE(fmt.hasProperty(QTextFormat::FontFixedPitch), expectedFormat.testFlag(Mono));
diff --git a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
index 0c3f34e09d..a9a157f25a 100644
--- a/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
+++ b/tests/auto/gui/text/qtextmarkdownwriter/data/example.md
@@ -11,10 +11,11 @@ comments in each of the following sections to encourage you to experiment.
## Font and Paragraph Styles
-QTextEdit supports **bold**, *italic*, and ~~strikethrough~~ font styles, and can
-display multicolored text. Font families such as Times New Roman and `Courier`
-can also be used directly. *If you place the cursor in a region of styled text,
-the controls in the tool bars will change to reflect the current style.*
+QTextEdit supports **bold**, *italic*, _underline_ and ~~strikethrough~~ font
+styles, and can display multicolored text. Font families such as Times New
+Roman and `Courier` can also be used directly. *If you place the cursor in a
+region of styled text, the controls in the tool bars will change to reflect the
+current style.*
Paragraphs can be formatted so that the text is left-aligned, right-aligned,
centered, or fully justified.
@@ -70,7 +71,7 @@ column spans, text formatting within cells, and size constraints for columns.
|9:00 - 11:00 |Introduction to Qt |||
|11:00 - 13:00|Using qmake |Object-oriented Programming|Layouts in Qt |
|13:00 - 15:00|Qt Designer Tutorial |Extreme Programming |Writing Custom Styles |
-|15:00 - 17:00|Qt Linguist and Internationalization|  |  |
+|15:00 - 17:00|Qt Linguist and Internationalization|Test-Driven Development | |
*Try adding text to the cells in the table and experiment with the alignment of
the paragraphs.*