Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/inputmethod/qcoefepinputcontext_s60.cpp

    r651 r769  
    5959#define QT_EAknActivatePenInputRequest MAknEdStateObserver::EAknEdwinStateEvent(7)
    6060
     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
    6166QT_BEGIN_NAMESPACE
    6267
     
    7277      m_formatRetriever(0),
    7378      m_pointerHandler(0),
    74       m_longPress(0),
    7579      m_cursorPos(0),
    7680      m_hasTempPreeditString(false)
    7781{
    7882    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);
    8087    m_fepState->SetDefaultInputMode( EAknEditorTextInputMode );
    8188    m_fepState->SetPermittedInputModes( EAknEditorAllInputModes );
    8289    m_fepState->SetDefaultCase( EAknEditorLowerCase );
    83     m_fepState->SetPermittedCases( EAknEditorLowerCase|EAknEditorUpperCase );
     90    m_fepState->SetPermittedCases( EAknEditorAllCaseModes );
    8491    m_fepState->SetSpecialCharacterTableResourceId(R_AVKON_SPECIAL_CHARACTER_TABLE_DIALOG);
    8592    m_fepState->SetNumericKeymap( EAknEditorStandardNumberModeKeymap );
     
    102109void QCoeFepInputContext::reset()
    103110{
    104     commitCurrentString(false);
     111    commitCurrentString(true);
    105112}
    106113
     
    115122
    116123    // 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) {
    118125        return;
    119126    }
     
    127134void QCoeFepInputContext::setFocusWidget(QWidget *w)
    128135{
    129     commitCurrentString(false);
     136    commitCurrentString(true);
    130137
    131138    QInputContext::setFocusWidget(w);
     
    220227        case Qt::Key_Select:
    221228            if (!m_preeditString.isEmpty()) {
    222                 commitCurrentString(false);
     229                commitCurrentString(true);
    223230                return true;
    224231            }
     
    232239            && !keyEvent->text().isEmpty()) {
    233240            // Send some temporary preedit text in order to make text visible for a moment.
     241            m_cursorPos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
    234242            m_preeditString = keyEvent->text();
    235243            QList<QInputMethodEvent::Attribute> attributes;
    236244            QInputMethodEvent imEvent(m_preeditString, attributes);
    237             QApplication::sendEvent(focusWidget(), &imEvent);
     245            sendEvent(imEvent);
    238246            m_tempPreeditStringTimeout.start(1000, this);
    239247            m_hasTempPreeditString = true;
     
    294302
    295303    if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) {
    296         commitCurrentString(false);
     304        commitCurrentString(true);
    297305        int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt();
    298306
     
    433441    ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateCaseModeUpdate);
    434442
    435     flags = 0;
     443    if (QSysInfo::s60Version() > QSysInfo::SV_S60_5_0)
     444        flags = QT_EAknEditorFlagSelectionVisible;
     445    else
     446        flags = 0;
    436447    if (hints & ImhUppercaseOnly && !(hints & ImhLowercaseOnly)
    437448            || hints & ImhLowercaseOnly && !(hints & ImhUppercaseOnly)) {
     
    474485{
    475486    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;
    479491
    480492    TInt numChars = 0;
     
    551563    m_formatRetriever = &aInlineTextFormatRetriever;
    552564    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    }
    553580
    554581    applyFormat(&attributes);
     
    740767void QCoeFepInputContext::DoCommitFepInlineEditL()
    741768{
    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
     775void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction)
     776{
     777    int longPress = 0;
     778
    747779    if (m_preeditString.size() == 0) {
    748780        QWidget *w = focusWidget();
    749         if (triggeredBySymbian && w) {
     781        if (!cancelFepTransaction && w) {
    750782            // We must replace the last character only if the input box has already accepted one
    751783            if (w->inputMethodQuery(Qt::ImCursorPosition).toInt() != m_cursorPos)
    752                 m_longPress = 1;
    753         }
    754         return;
     784                longPress = 1;
     785        }
    755786    }
    756787
    757788    QList<QInputMethodEvent::Attribute> attributes;
    758789    QInputMethodEvent event(QLatin1String(""), attributes);
    759     event.setCommitString(m_preeditString, 0-m_longPress, m_longPress);
     790    event.setCommitString(m_preeditString, 0-longPress, longPress);
    760791    m_preeditString.clear();
    761792    sendEvent(event);
    762793
    763794    m_hasTempPreeditString = false;
    764     m_longPress = 0;
    765 
    766     if (!triggeredBySymbian) {
     795    longPress = 0;
     796
     797    if (cancelFepTransaction) {
    767798        CCoeFep* fep = CCoeEnv::Static()->Fep();
    768799        if (fep)
Note: See TracChangeset for help on using the changeset viewer.