summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@digia.com>2013-02-01 11:41:39 (GMT)
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-02-21 17:19:40 (GMT)
commitc9e96db7879d793d5ea12b6a0a2d6bce74c3e537 (patch)
tree4ae7d9cd9d442d7a1261ded2eee5ca9853c07685
parentb9b3acf39e9e3b5b7288b4f4f8c7246606e16d0d (diff)
downloadQt-c9e96db7879d793d5ea12b6a0a2d6bce74c3e537.zip
Qt-c9e96db7879d793d5ea12b6a0a2d6bce74c3e537.tar.gz
Qt-c9e96db7879d793d5ea12b6a0a2d6bce74c3e537.tar.bz2
Fix text issue with Hiragana characters when stylesheet is applied.
When typing into a QTextEdit or QLineEdit with a Japanese IME on Windows, some characters have both a black foreground and background and hence cannot be seen. This patch fixes the issue by setting the appropriate colors for the text in these scenarios. The change also fixes a similar situation with QSyntaxHighlighter and Hiragana, where the background and foreground colors were the same. Now it will use underlining to highlight the text (like WordPad does, for example). Task-number: QTBUG-29442 Change-Id: I364d327a8f6573a73b227b79cc5f570cd02611c9 Reviewed-by: Andy Shaw <andy.shaw@digia.com> Reviewed-by: Titta Heikkala <titta.heikkala@digia.com> Reviewed-by: David Faure (KDE) <faure@kde.org> Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
-rw-r--r--src/gui/text/qtextcontrol.cpp6
-rw-r--r--src/gui/widgets/qlinecontrol.cpp6
2 files changed, 12 insertions, 0 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp
index 2fee68a..3570504 100644
--- a/src/gui/text/qtextcontrol.cpp
+++ b/src/gui/text/qtextcontrol.cpp
@@ -1981,6 +1981,12 @@ void QTextControlPrivate::inputMethodEvent(QInputMethodEvent *e)
} else if (a.type == QInputMethodEvent::TextFormat) {
QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat();
if (f.isValid()) {
+ if (f.background().color().alphaF() == 1 && f.background().style() == Qt::SolidPattern) {
+ f.setForeground(f.background().color());
+ f.setBackground(Qt::transparent);
+ f.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+ f.setFontUnderline(true);
+ }
QTextLayout::FormatRange o;
o.start = a.start + cursor.position() - block.position();
o.length = a.length;
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp
index 9c2d354..6116e40 100644
--- a/src/gui/widgets/qlinecontrol.cpp
+++ b/src/gui/widgets/qlinecontrol.cpp
@@ -515,6 +515,12 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event)
} else if (a.type == QInputMethodEvent::TextFormat) {
QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat();
if (f.isValid()) {
+ if (f.background().color().alphaF() == 1 && f.background().style() == Qt::SolidPattern) {
+ f.setForeground(f.background().color());
+ f.setBackground(Qt::transparent);
+ f.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+ f.setFontUnderline(true);
+ }
QTextLayout::FormatRange o;
o.start = a.start + m_cursor;
o.length = a.length;