summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/widgets/richtext/textedit/example.md10
-rw-r--r--src/gui/text/qtextdocument.h2
-rw-r--r--src/gui/text/qtextmarkdownimporter.cpp6
-rw-r--r--src/gui/text/qtextmarkdownimporter_p.h1
-rw-r--r--tests/auto/gui/text/qtextmarkdownimporter/tst_qtextmarkdownimporter.cpp15
-rw-r--r--tests/auto/gui/text/qtextmarkdownwriter/data/example.md11
6 files changed, 31 insertions, 14 deletions
diff --git a/examples/widgets/richtext/textedit/example.md b/examples/widgets/richtext/textedit/example.md
index a16a9197b4..158728a784 100644
--- a/examples/widgets/richtext/textedit/example.md
+++ b/examples/widgets/richtext/textedit/example.md
@@ -11,10 +11,12 @@ comments in each of the following sections to encourage you to experiment.
## Font and Paragraph Styles
-QTextEdit supports **bold**, *italic*, & ~~strikethrough~~ font styles, and
-can display <span style="font-size:10pt; font-weight:600;
-color:#00007f;">multicolored</span> text. Font families such as <span
-style="font-family:Times New Roman">Times New Roman</span> and `Courier`
+QTextEdit supports **bold**, *italic*, _underline_ &amp; ~~strikethrough~~ font
+styles, and can display
+<span style="font-size:10pt; font-weight:600; color:#00007f;"> multicolored</span>
+text. Font families such as
+<span style="font-family:Times New Roman">Times New Roman</span> and
+<span style="font-family:Courier">Courier</span>
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.*
diff --git a/src/gui/text/qtextdocument.h b/src/gui/text/qtextdocument.h
index 0470ad52e9..23fffc4771 100644
--- a/src/gui/text/qtextdocument.h
+++ b/src/gui/text/qtextdocument.h
@@ -151,7 +151,7 @@ public:
enum MarkdownFeature {
MarkdownNoHTML = 0x0020 | 0x0040,
MarkdownDialectCommonMark = 0,
- MarkdownDialectGitHub = 0x0004 | 0x0008 | 0x0400 | 0x0100 | 0x0200 | 0x0800
+ MarkdownDialectGitHub = 0x0004 | 0x0008 | 0x0400 | 0x0100 | 0x0200 | 0x0800 | 0x4000
};
Q_DECLARE_FLAGS(MarkdownFeatures, MarkdownFeature)
Q_FLAG(MarkdownFeatures)
diff --git a/src/gui/text/qtextmarkdownimporter.cpp b/src/gui/text/qtextmarkdownimporter.cpp
index 97bdef50d7..f0b362f54f 100644
--- a/src/gui/text/qtextmarkdownimporter.cpp
+++ b/src/gui/text/qtextmarkdownimporter.cpp
@@ -69,12 +69,13 @@ static_assert(int(QTextMarkdownImporter::FeatureNoHTMLBlocks) == MD_FLAG_NOHTMLB
static_assert(int(QTextMarkdownImporter::FeatureNoHTMLSpans) == MD_FLAG_NOHTMLSPANS);
static_assert(int(QTextMarkdownImporter::FeatureTables) == MD_FLAG_TABLES);
static_assert(int(QTextMarkdownImporter::FeatureStrikeThrough) == MD_FLAG_STRIKETHROUGH);
+static_assert(int(QTextMarkdownImporter::FeatureUnderline) == MD_FLAG_UNDERLINE);
static_assert(int(QTextMarkdownImporter::FeaturePermissiveWWWAutoLinks) == MD_FLAG_PERMISSIVEWWWAUTOLINKS);
static_assert(int(QTextMarkdownImporter::FeaturePermissiveAutoLinks) == MD_FLAG_PERMISSIVEAUTOLINKS);
static_assert(int(QTextMarkdownImporter::FeatureTasklists) == MD_FLAG_TASKLISTS);
static_assert(int(QTextMarkdownImporter::FeatureNoHTML) == MD_FLAG_NOHTML);
static_assert(int(QTextMarkdownImporter::DialectCommonMark) == MD_DIALECT_COMMONMARK);
-static_assert(int(QTextMarkdownImporter::DialectGitHub) == MD_DIALECT_GITHUB);
+static_assert(int(QTextMarkdownImporter::DialectGitHub) == MD_DIALECT_GITHUB | MD_FLAG_UNDERLINE);
// --------------------------------------------------------
// MD4C callback function wrappers
@@ -397,6 +398,9 @@ int QTextMarkdownImporter::cbEnterSpan(int spanType, void *det)
case MD_SPAN_STRONG:
charFmt.setFontWeight(QFont::Bold);
break;
+ case MD_SPAN_U:
+ charFmt.setFontUnderline(true);
+ break;
case MD_SPAN_A: {
MD_SPAN_A_DETAIL *detail = static_cast<MD_SPAN_A_DETAIL *>(det);
QString url = QString::fromUtf8(detail->href.text, int(detail->href.size));
diff --git a/src/gui/text/qtextmarkdownimporter_p.h b/src/gui/text/qtextmarkdownimporter_p.h
index c05ac68820..12a7c5a3a6 100644
--- a/src/gui/text/qtextmarkdownimporter_p.h
+++ b/src/gui/text/qtextmarkdownimporter_p.h
@@ -80,6 +80,7 @@ public:
FeatureStrikeThrough = 0x0200,
FeaturePermissiveWWWAutoLinks = 0x0400,
FeatureTasklists = 0x0800,
+ FeatureUnderline = 0x4000,
// composite flags
FeaturePermissiveAutoLinks = FeaturePermissiveMailAutoLinks
| FeaturePermissiveURLAutoLinks | FeaturePermissiveWWWAutoLinks,
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.*