summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-06-01 03:24:21 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-06-01 03:24:21 (GMT)
commit08d09e02109f18d2a22fa48f331cd7bcfacc154f (patch)
tree8ad972a3f8992622ea8ea4b0b6a819d842476723
parent785ccda71652de47a161ff31c1a7543ef3cb4953 (diff)
downloadQt-08d09e02109f18d2a22fa48f331cd7bcfacc154f.zip
Qt-08d09e02109f18d2a22fa48f331cd7bcfacc154f.tar.gz
Qt-08d09e02109f18d2a22fa48f331cd7bcfacc154f.tar.bz2
Ensure text color set by S60 input method works for QML Items
and QGraphicsWidgets. For QGraphicsWidgets use palette as per QWidget. For QML items leave the color unset so that the default pen is used. Task-number: QTBUG-10997 Reviewed-by: Sami Merila
-rw-r--r--src/gui/inputmethod/qcoefepinputcontext_s60.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
index d081cfd..4cdc4ad 100644
--- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
+++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
@@ -44,6 +44,9 @@
#include "qcoefepinputcontext_p.h"
#include <qapplication.h>
#include <qtextformat.h>
+#include <qgraphicsview.h>
+#include <qgraphicsscene.h>
+#include <qgraphicswidget.h>
#include <private/qcore_symbian_p.h>
#include <fepitfr.h>
@@ -320,12 +323,14 @@ TCoeInputCapabilities QCoeFepInputContext::inputCapabilities()
return TCoeInputCapabilities(m_textCapabilities, this, 0);
}
-static QTextCharFormat qt_TCharFormat2QTextCharFormat(const TCharFormat &cFormat)
+static QTextCharFormat qt_TCharFormat2QTextCharFormat(const TCharFormat &cFormat, bool validStyleColor)
{
QTextCharFormat qFormat;
- QBrush foreground(QColor(cFormat.iFontPresentation.iTextColor.Internal()));
- qFormat.setForeground(foreground);
+ if (validStyleColor) {
+ QBrush foreground(QColor(cFormat.iFontPresentation.iTextColor.Internal()));
+ qFormat.setForeground(foreground);
+ }
qFormat.setFontStrikeOut(cFormat.iFontPresentation.iStrikethrough == EStrikethroughOn);
qFormat.setFontUnderline(cFormat.iFontPresentation.iUnderline == EUnderlineOn);
@@ -484,10 +489,30 @@ void QCoeFepInputContext::applyHints(Qt::InputMethodHints hints)
void QCoeFepInputContext::applyFormat(QList<QInputMethodEvent::Attribute> *attributes)
{
TCharFormat cFormat;
- const QColor styleTextColor = focusWidget() ? focusWidget()->palette().text().color() :
- QApplication::palette("QLineEdit").text().color();
- const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha()));
- cFormat.iFontPresentation.iTextColor = fontColor;
+ QColor styleTextColor;
+ if (QWidget *focused = focusWidget()) {
+ QGraphicsView *gv = qobject_cast<QGraphicsView*>(focused);
+ if (!gv) // could be either the QGV or its viewport that has focus
+ gv = qobject_cast<QGraphicsView*>(focused->parentWidget());
+ if (gv) {
+ if (QGraphicsScene *scene = gv->scene()) {
+ if (QGraphicsItem *focusItem = scene->focusItem()) {
+ if (focusItem->isWidget()) {
+ styleTextColor = static_cast<QGraphicsWidget*>(focusItem)->palette().text().color();
+ }
+ }
+ }
+ } else {
+ styleTextColor = focused->palette().text().color();
+ }
+ } else {
+ styleTextColor = QApplication::palette("QLineEdit").text().color();
+ }
+
+ if (styleTextColor.isValid()) {
+ const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha()));
+ cFormat.iFontPresentation.iTextColor = fontColor;
+ }
TInt numChars = 0;
TInt charPos = 0;
@@ -501,7 +526,7 @@ void QCoeFepInputContext::applyFormat(QList<QInputMethodEvent::Attribute> *attri
attributes->append(QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat,
charPos,
numChars,
- QVariant(qt_TCharFormat2QTextCharFormat(cFormat))));
+ QVariant(qt_TCharFormat2QTextCharFormat(cFormat, styleTextColor.isValid()))));
charPos += numChars;
if (charPos >= m_preeditString.size()) {
break;