Changeset 769 for trunk/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
- Timestamp:
- Aug 2, 2010, 9:27:30 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.3 (added) merged: 768 /branches/vendor/nokia/qt/current merged: 767 /branches/vendor/nokia/qt/4.6.2 removed
- Property svn:mergeinfo changed
-
trunk/src/gui/inputmethod/qcoefepinputcontext_s60.cpp
r651 r769 59 59 #define QT_EAknActivatePenInputRequest MAknEdStateObserver::EAknEdwinStateEvent(7) 60 60 61 // EAknEditorFlagSelectionVisible is only valid from 3.2 onwards. 62 // Sym^3 AVKON FEP manager expects that this flag is used for FEP-aware editors 63 // that support text selection. 64 #define QT_EAknEditorFlagSelectionVisible 0x100000 65 61 66 QT_BEGIN_NAMESPACE 62 67 … … 72 77 m_formatRetriever(0), 73 78 m_pointerHandler(0), 74 m_longPress(0),75 79 m_cursorPos(0), 76 80 m_hasTempPreeditString(false) 77 81 { 78 82 m_fepState->SetObjectProvider(this); 79 m_fepState->SetFlags(EAknEditorFlagDefault); 83 if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) 84 m_fepState->SetFlags(EAknEditorFlagDefault | QT_EAknEditorFlagSelectionVisible); 85 else 86 m_fepState->SetFlags(EAknEditorFlagDefault); 80 87 m_fepState->SetDefaultInputMode( EAknEditorTextInputMode ); 81 88 m_fepState->SetPermittedInputModes( EAknEditorAllInputModes ); 82 89 m_fepState->SetDefaultCase( EAknEditorLowerCase ); 83 m_fepState->SetPermittedCases( EAknEditor LowerCase|EAknEditorUpperCase);90 m_fepState->SetPermittedCases( EAknEditorAllCaseModes ); 84 91 m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG); 85 92 m_fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap ); … … 102 109 void QCoeFepInputContext::reset() 103 110 { 104 commitCurrentString( false);111 commitCurrentString(true); 105 112 } 106 113 … … 115 122 116 123 // For pre-5.0 SDKs, we don't do text updates on S60 side. 117 if (QSysInfo::s60Version() !=QSysInfo::SV_S60_5_0) {124 if (QSysInfo::s60Version() < QSysInfo::SV_S60_5_0) { 118 125 return; 119 126 } … … 127 134 void QCoeFepInputContext::setFocusWidget(QWidget *w) 128 135 { 129 commitCurrentString( false);136 commitCurrentString(true); 130 137 131 138 QInputContext::setFocusWidget(w); … … 220 227 case Qt::Key_Select: 221 228 if (!m_preeditString.isEmpty()) { 222 commitCurrentString( false);229 commitCurrentString(true); 223 230 return true; 224 231 } … … 232 239 && !keyEvent->text().isEmpty()) { 233 240 // Send some temporary preedit text in order to make text visible for a moment. 241 m_cursorPos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); 234 242 m_preeditString = keyEvent->text(); 235 243 QList<QInputMethodEvent::Attribute> attributes; 236 244 QInputMethodEvent imEvent(m_preeditString, attributes); 237 QApplication::sendEvent(focusWidget(), &imEvent);245 sendEvent(imEvent); 238 246 m_tempPreeditStringTimeout.start(1000, this); 239 247 m_hasTempPreeditString = true; … … 294 302 295 303 if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) { 296 commitCurrentString( false);304 commitCurrentString(true); 297 305 int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); 298 306 … … 433 441 ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateCaseModeUpdate); 434 442 435 flags = 0; 443 if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) 444 flags = QT_EAknEditorFlagSelectionVisible; 445 else 446 flags = 0; 436 447 if (hints & ImhUppercaseOnly && !(hints & ImhLowercaseOnly) 437 448 || hints & ImhLowercaseOnly && !(hints & ImhUppercaseOnly)) { … … 474 485 { 475 486 TCharFormat cFormat; 476 QColor styleTextColor = QApplication::palette("QLineEdit").text().color(); 477 TLogicalRgb tontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); 478 cFormat.iFontPresentation.iTextColor = tontColor; 487 const QColor styleTextColor = focusWidget() ? focusWidget()->palette().text().color() : 488 QApplication::palette("QLineEdit").text().color(); 489 const TLogicalRgb fontColor(TRgb(styleTextColor.red(), styleTextColor.green(), styleTextColor.blue(), styleTextColor.alpha())); 490 cFormat.iFontPresentation.iTextColor = fontColor; 479 491 480 492 TInt numChars = 0; … … 551 563 m_formatRetriever = &aInlineTextFormatRetriever; 552 564 m_pointerHandler = &aPointerEventHandlerDuringInlineEdit; 565 566 // With T9 aInitialInlineText is typically empty when StartFepInlineEditL is called, 567 // but FEP requires that selected text is always removed at StartFepInlineEditL. 568 // Let's remove the selected text if aInitialInlineText is empty and there is selected text 569 if (m_preeditString.isEmpty()) { 570 int anchor = w->inputMethodQuery(Qt::ImAnchorPosition).toInt(); 571 int replacementLength = qAbs(m_cursorPos-anchor); 572 if (replacementLength > 0) { 573 int replacementStart = m_cursorPos < anchor ? 0 : -replacementLength; 574 QList<QInputMethodEvent::Attribute> clearSelectionAttributes; 575 QInputMethodEvent clearSelectionEvent(QLatin1String(""), clearSelectionAttributes); 576 clearSelectionEvent.setCommitString(QLatin1String(""), replacementStart, replacementLength); 577 sendEvent(clearSelectionEvent); 578 } 579 } 553 580 554 581 applyFormat(&attributes); … … 740 767 void QCoeFepInputContext::DoCommitFepInlineEditL() 741 768 { 742 commitCurrentString(true); 743 } 744 745 void QCoeFepInputContext::commitCurrentString(bool triggeredBySymbian) 746 { 769 commitCurrentString(false); 770 if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0) 771 ReportAknEdStateEvent(QT_EAknCursorPositionChanged); 772 773 } 774 775 void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction) 776 { 777 int longPress = 0; 778 747 779 if (m_preeditString.size() == 0) { 748 780 QWidget *w = focusWidget(); 749 if ( triggeredBySymbian && w) {781 if (!cancelFepTransaction && w) { 750 782 // We must replace the last character only if the input box has already accepted one 751 783 if (w->inputMethodQuery(Qt::ImCursorPosition).toInt() != m_cursorPos) 752 m_longPress = 1; 753 } 754 return; 784 longPress = 1; 785 } 755 786 } 756 787 757 788 QList<QInputMethodEvent::Attribute> attributes; 758 789 QInputMethodEvent event(QLatin1String(""), attributes); 759 event.setCommitString(m_preeditString, 0- m_longPress, m_longPress);790 event.setCommitString(m_preeditString, 0-longPress, longPress); 760 791 m_preeditString.clear(); 761 792 sendEvent(event); 762 793 763 794 m_hasTempPreeditString = false; 764 m_longPress = 0;765 766 if ( !triggeredBySymbian) {795 longPress = 0; 796 797 if (cancelFepTransaction) { 767 798 CCoeFep* fep = CCoeEnv::Static()->Fep(); 768 799 if (fep)
Note:
See TracChangeset
for help on using the changeset viewer.