Example #1
0
void KeypadInputMethod::commit(const QString &str) {
  if (str.isNull()) {
    commit(QString(1, currentChar()));
  } else {
    sendCommitString(str);
    _state = COMMITTED;
  }
}
Example #2
0
void QPinyinImpl::SendKey(int u , int c)
{
        QString result = QString(QChar(u));
        sendCommitString(result);
        if (m_pinyin_frame->isVisible())
        {
            m_pinyin_frame->releaseKeyboard();
            m_pinyin_frame->resetState();
            //m_pinyin_frame->m_engine.save_table();
        }
}
void SyszuxIM::confirmString(QString gemfield)    //发送已确认的字符
{
    sendCommitString(gemfield);
}
Example #4
0
bool PinyinIM::filter(int unicode, int keycode, int modifiers, 
        bool isPress, bool autoRepeat)
{
    qLog(Input) << "Keycode" << keycode;
    /*if (!isActive)
    return false;*/
    
    bool bUsingPicker = false;

    //NOTE: pinyin picker stays visible as we type
    if (pinyinPicker && pinyinPicker->isVisible()) {
        pinyinPicker->filterKey(unicode, keycode, modifiers, isPress, autoRepeat);

        if (!isPress && Qt::Key_Back == keycode) {
            if (matchHistory.count() <= 2) {    //i.e. if no characters are left after delete
                reset();
                return true;
            }
            matchHistory.pop();
        }

        bUsingPicker = true;
    }

    if (charPicker && charPicker->isVisible()) {
        charPicker->filterKey(unicode, keycode, modifiers, isPress, autoRepeat);

        if (!isPress && Qt::Key_Back == keycode) {
            //charPicker->clearSelection();
            charPicker->hide();
        }
        
        bUsingPicker = true;
    }
    
    if (symbolPicker && symbolPicker->isVisible()) {
        if (!symbolPicker->filterKey(unicode, keycode, modifiers, isPress, autoRepeat))
            symbolPicker->hide();
        return true;
    }

    
    //TODO: a redesign of filterKey would allow for cleaner code here
    switch(keycode) {
        case Qt::Key_Select:
        case Qt::Key_Up:
        case Qt::Key_Down:
        case Qt::Key_Left:
        case Qt::Key_Right:
            return bUsingPicker;
        case Qt::Key_Back:
            if (!bUsingPicker)
                return false;
            break;
        case Qt::Key_1:
        case Qt::Key_Asterisk:
            if (!symbolPicker) {
                symbolPicker = new SymbolPicker();
                connect(symbolPicker, SIGNAL(symbolClicked(int,int)),
                        this, SLOT(symbolSelected(int,int)));
            }
            symbolPicker->setMicroFocus(microX, microY);
            symbolPicker->show();
            return true;
        case Qt::Key_2:
        case Qt::Key_3:
        case Qt::Key_4:
        case Qt::Key_5:
        case Qt::Key_6:
        case Qt::Key_7:
        case Qt::Key_8:
        case Qt::Key_9:
            if (!isPress)
                processDigitKey(keycode);
            break;
        case Qt::Key_0:
            if (!isPress)
                sendCommitString(" ");
            return true;
        default:
            return false;
    }