iOS: Get rid of markedTextFormat global static variable in IME
Preperation for IME refactor. Change-Id: I0832c174d05d019d69ef7c01c45aaedc6e4d9468 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
This commit is contained in:
parent
fea21655a8
commit
942c6910d1
@ -49,19 +49,11 @@ class StaticVariables
|
||||
public:
|
||||
QInputMethodQueryEvent inputMethodQueryEvent;
|
||||
bool inUpdateKeyboardLayout;
|
||||
QTextCharFormat markedTextFormat;
|
||||
|
||||
StaticVariables()
|
||||
: inputMethodQueryEvent(Qt::ImQueryInput)
|
||||
, inUpdateKeyboardLayout(false)
|
||||
{
|
||||
// There seems to be no way to query how the preedit text
|
||||
// should be drawn. So we need to hard-code the color.
|
||||
QSysInfo::MacVersion iosVersion = QSysInfo::MacintoshVersion;
|
||||
if (iosVersion < QSysInfo::MV_IOS_7_0)
|
||||
markedTextFormat.setBackground(QColor(235, 239, 247));
|
||||
else
|
||||
markedTextFormat.setBackground(QColor(206, 221, 238));
|
||||
}
|
||||
};
|
||||
|
||||
@ -301,8 +293,19 @@ Q_GLOBAL_STATIC(StaticVariables, staticVariables);
|
||||
|
||||
m_markedText = markedText ? QString::fromNSString(markedText) : QString();
|
||||
|
||||
static QTextCharFormat markedTextFormat;
|
||||
if (markedTextFormat.isEmpty()) {
|
||||
// There seems to be no way to query how the preedit text
|
||||
// should be drawn. So we need to hard-code the color.
|
||||
QSysInfo::MacVersion iosVersion = QSysInfo::MacintoshVersion;
|
||||
if (iosVersion < QSysInfo::MV_IOS_7_0)
|
||||
markedTextFormat.setBackground(QColor(235, 239, 247));
|
||||
else
|
||||
markedTextFormat.setBackground(QColor(206, 221, 238));
|
||||
}
|
||||
|
||||
QList<QInputMethodEvent::Attribute> attrs;
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, markedText.length, staticVariables()->markedTextFormat);
|
||||
attrs << QInputMethodEvent::Attribute(QInputMethodEvent::TextFormat, 0, markedText.length, markedTextFormat);
|
||||
QInputMethodEvent e(m_markedText, attrs);
|
||||
[self sendEventToFocusObject:e];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user