summaryrefslogtreecommitdiffstats
path: root/src/gui/inputmethod
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/inputmethod')
-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;