summaryrefslogtreecommitdiff
path: root/examples/widgets/richtext
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2021-05-06 21:13:29 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2021-05-07 17:00:20 +0200
commit688602704d5c5226491b0d0ab7f596f9568966d6 (patch)
tree750f50589fe77ebfe214a7a113c7a6d26011d96a /examples/widgets/richtext
parent05f7dd5ead5927ef7b3301380b81d7194d9e0593 (diff)
downloadqtbase-688602704d5c5226491b0d0ab7f596f9568966d6.tar.gz
Support CSS text-decoration-color in underlines, overlines, strikethrough
Also add a feature to the textedit example to set this value. [ChangeLog][QtGui][CSS] The CSS text-decoration-color attribute is now supported in rich text spans with underlines, overlines and strikethrough. Fixes: QTBUG-82114 Task-number: QTBUG-39617 Change-Id: I0065cb5431833da55b0f503ce7ff2b83b74b718a Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'examples/widgets/richtext')
-rw-r--r--examples/widgets/richtext/textedit/images/mac/textundercolor.pngbin0 -> 6916 bytes
-rw-r--r--examples/widgets/richtext/textedit/images/win/textundercolor.pngbin0 -> 6916 bytes
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp15
-rw-r--r--examples/widgets/richtext/textedit/textedit.h2
-rw-r--r--examples/widgets/richtext/textedit/textedit.qrc2
5 files changed, 19 insertions, 0 deletions
diff --git a/examples/widgets/richtext/textedit/images/mac/textundercolor.png b/examples/widgets/richtext/textedit/images/mac/textundercolor.png
new file mode 100644
index 0000000000..30e24e61c3
--- /dev/null
+++ b/examples/widgets/richtext/textedit/images/mac/textundercolor.png
Binary files differ
diff --git a/examples/widgets/richtext/textedit/images/win/textundercolor.png b/examples/widgets/richtext/textedit/images/win/textundercolor.png
new file mode 100644
index 0000000000..30e24e61c3
--- /dev/null
+++ b/examples/widgets/richtext/textedit/images/win/textundercolor.png
Binary files differ
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index 3a1b3321a1..ed91f6e250 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -354,6 +354,10 @@ void TextEdit::setupTextActions()
actionTextColor = menu->addAction(pix, tr("&Color..."), this, &TextEdit::textColor);
tb->addAction(actionTextColor);
+ const QIcon underlineColorIcon(rsrcPath + "/textundercolor.png");
+ actionUnderlineColor = menu->addAction(underlineColorIcon, tr("Underline color..."), this, &TextEdit::underlineColor);
+ tb->addAction(actionUnderlineColor);
+
menu->addSeparator();
const QIcon checkboxIcon = QIcon::fromTheme("status-checkbox-checked", QIcon(rsrcPath + "/checkbox-checked.png"));
@@ -729,6 +733,17 @@ void TextEdit::textColor()
colorChanged(col);
}
+void TextEdit::underlineColor()
+{
+ QColor col = QColorDialog::getColor(Qt::black, this);
+ if (!col.isValid())
+ return;
+ QTextCharFormat fmt;
+ fmt.setUnderlineColor(col);
+ mergeFormatOnWordOrSelection(fmt);
+ colorChanged(col);
+}
+
void TextEdit::textAlign(QAction *a)
{
if (a == actionAlignLeft)
diff --git a/examples/widgets/richtext/textedit/textedit.h b/examples/widgets/richtext/textedit/textedit.h
index 07a307f83d..debc401150 100644
--- a/examples/widgets/richtext/textedit/textedit.h
+++ b/examples/widgets/richtext/textedit/textedit.h
@@ -95,6 +95,7 @@ private slots:
void textSize(const QString &p);
void textStyle(int styleIndex);
void textColor();
+ void underlineColor();
void textAlign(QAction *a);
void setChecked(bool checked);
void indent();
@@ -125,6 +126,7 @@ private:
QAction *actionTextUnderline;
QAction *actionTextItalic;
QAction *actionTextColor;
+ QAction *actionUnderlineColor;
QAction *actionAlignLeft;
QAction *actionAlignCenter;
QAction *actionAlignRight;
diff --git a/examples/widgets/richtext/textedit/textedit.qrc b/examples/widgets/richtext/textedit/textedit.qrc
index 1641acc207..a30d50fdbf 100644
--- a/examples/widgets/richtext/textedit/textedit.qrc
+++ b/examples/widgets/richtext/textedit/textedit.qrc
@@ -22,6 +22,7 @@
<file>images/mac/textleft.png</file>
<file>images/mac/textright.png</file>
<file>images/mac/textunder.png</file>
+ <file>images/mac/textundercolor.png</file>
<file>images/mac/zoomin.png</file>
<file>images/mac/zoomout.png</file>
<file>images/win/checkbox.png</file>
@@ -45,6 +46,7 @@
<file>images/win/textleft.png</file>
<file>images/win/textright.png</file>
<file>images/win/textunder.png</file>
+ <file>images/win/textundercolor.png</file>
<file>images/win/zoomin.png</file>
<file>images/win/zoomout.png</file>
<file>example.html</file>