コード例 #1
0
ファイル: quiminputcontext.cpp プロジェクト: DirtYiCE/uim
void QUimInputContext::updatePreedit()
{
    QString newString = getPreeditString();
    int cursor = getPreeditCursorPosition();
    int selLength = getPreeditSelectionLength();

    if ( newString.isEmpty() && ! isComposing() )
        return ;

    // Activating the IM
    if ( ! newString.isEmpty() && ! isComposing() )
        sendIMEvent( QEvent::IMStart );

    if ( ! newString.isEmpty() )
    {
#ifdef ENABLE_DEBUG
        qDebug( "cursor = %d, length = %d", cursor, newString.length() );
#endif
        sendIMEvent( QEvent::IMCompose, newString, cursor, selLength );
    }

    // Preedit's length is Zero, we should deactivate IM and
    // cancel the inputting, that is, sending IMEnd event with
    // empty string.
    if ( newString.isEmpty() && isComposing() )
        sendIMEvent( QEvent::IMEnd );
}
コード例 #2
0
ファイル: composeim.cpp プロジェクト: cherry-wb/quietheart
/*
   Filters key events from qwsServer.  Returns FALSE if event should be
   sent on as is, otherwise returns FALSE.

   \a unicode is the text of the event. \a keycode is the Qt Key for the event
   as described in qnamespace.h. \a modifiers is a combination of zero or
   more of the following OR'ed together: Qt::ShiftButton, Qt::ControlButton
   and Qt::AltButton. If used, \a autoRepeat would be FALSE if the event
   comes from the intial press of the button, and TRUE if it comes from event
   generated from holding the button down for a period of time.
*/
bool ComposeIM::filter(int unicode, int keycode, int modifiers, 
  bool isPress, bool /*autoRepeat*/)
{
    if ( isPress && keycode == Qt::Key_Space && 
	 modifiers & Qt::ShiftButton ) {
	//switch to opposite state
	if ( state == On ) {
	    sendIMEvent( QWSServer::IMEnd, QString::null, 0 );
	    composed = "";
	    state = Off; //reset and remove text
	} else {
	    state = On;
	}
	return TRUE; //block event
    } else if ( state == On ) {
	if ( isPress ) {
	    if ( keycode == Qt::Key_Return ) {
		//accept text and remain active
		sendIMEvent( QWSServer::IMEnd, composed, composed.length() );
		composed = "";
	    } else if ( keycode == Qt::Key_Backspace ) {
		if ( composed.length() > 0 )
		    composed = composed.left( composed.length() - 1 );
		sendIMEvent( QWSServer::IMCompose, composed, composed.length(), 0 );
	    } else if ( unicode > 0 && unicode < 0xffff) {
		composed += QChar( unicode );
		compose( composed );
		sendIMEvent( QWSServer::IMCompose, composed, composed.length(), 0 );
	    }
	}
	return TRUE; //block event
    }  
    return FALSE; //pass keystroke normally.
}
コード例 #3
0
ファイル: quiminputcontext.cpp プロジェクト: DirtYiCE/uim
void QUimInputContext::commitString( const QString& str )
{
    if ( !isComposing() )
    {
        sendIMEvent( QEvent::IMStart );
    }

    sendIMEvent( QEvent::IMEnd, str );
}
コード例 #4
0
ファイル: composeim.cpp プロジェクト: cherry-wb/quietheart
/*
   Confirms current input, then resets ComposeIM and sets state to Off
*/
void ComposeIM::reset()
{
    if ( state == On ) {
	state = Off;
	sendIMEvent( QWSServer::IMEnd, composed, 0 );
	composed = "";
    }
}
コード例 #5
0
bool QGCINInputContext::x11FilterEvent( QWidget *keywidget, XEvent *event )
{
#ifndef QT_NO_GCIN
    KeySym keysym;
    char static_buffer[256];
    char *buffer = static_buffer;
    int buffer_size = sizeof(static_buffer) - 1;

    if (event->type != KeyPress && event->type != KeyRelease)
        return TRUE;

    XKeyEvent *keve = (XKeyEvent *) event;

    XLookupString (keve, buffer, buffer_size, &keysym, NULL);
    int result;
    char *rstr = NULL;
    unsigned int state = keve->state;


    if (event->type == KeyPress) {
        result = gcin_im_client_forward_key_press(gcin_ch,
          keysym, state, &rstr);

        if (rstr) {
            QString inputText = QString::fromUtf8(rstr);

            sendIMEvent( QEvent::IMStart );
            sendIMEvent( QEvent::IMEnd, inputText );
        }
    } else {
       result = gcin_im_client_forward_key_release(gcin_ch,
         keysym, state, &rstr);
    }


    if (rstr)
        free(rstr);

    return result;
}
コード例 #6
0
ファイル: quiminputcontext.cpp プロジェクト: DirtYiCE/uim
void QUimInputContext::saveContext()
{
    // just send IMEnd and keep preedit string
    if ( isComposing() )
        sendIMEvent( QEvent::IMEnd );
}