From 942c6910d1bab87aebb258d4076386c00ce041ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Wed, 20 Aug 2014 17:19:26 +0200 Subject: iOS: Get rid of markedTextFormat global static variable in IME Preperation for IME refactor. Change-Id: I0832c174d05d019d69ef7c01c45aaedc6e4d9468 Reviewed-by: Richard Moe Gustavsen --- src/plugins/platforms/ios/quiview_textinput.mm | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/plugins/platforms/ios') diff --git a/src/plugins/platforms/ios/quiview_textinput.mm b/src/plugins/platforms/ios/quiview_textinput.mm index 2280b8259a..6b2707e706 100644 --- a/src/plugins/platforms/ios/quiview_textinput.mm +++ b/src/plugins/platforms/ios/quiview_textinput.mm @@ -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 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]; } -- cgit v1.2.3