QTE porting of murphytalk
Quququ QT 18:21:41 read 1161 comments 5 font size: LargeMediumSmall subscription
A year ago, I wanted to use this input method and it could be transplanted to qtopia, but since the Board didn't have a keyboard (the current version didn't contain a soft keyboard)
And quit using qtopia.
A year later, the program was almost written. Because it had to be tested on the board, and the input method was required, the Code with a soft keyboard was downloaded, changed, and finally transplanted to QTE for use.
First, comment out all qpe header files in qpinyinframe. cpp and comment out all the corresponding qpeapplication code.
I used qte3.3.6 to replace the annotated code with the code under the corresponding QTE.
Qpeapplication: grabketboard qwidget: grabkeyboard ()
Qpeapplication: ungrabketboard qwidget: releasekeyboard ()
In this way, qpinyinframe is changed.
The following describes how to write an interface. In qpe, inputmethodface is used as the Plugins method. I have read the pinyinimpl. CPP Code in murphytalk code:
Void qpinyinimpl: onkeypress (qobject * receviter, const char * slot)
{
If (m_pinyin_frame ){
Qobject: connect (m_pinyin_frame, signal (Key (ushort, bool, bool )),
Receviter, slot );
}
}
The key is this connect, which links the input method signal key.
Therefore, you can follow this method to implement the input method interface.
Example code:
// Test. h
# Include <qapplication. h>
# Include <qvbox. h>
# Include <qlineedit. h>
# Include "pinyinframe. H"
Class lineedit: Public qlineedit
{Q_object
Public:
Lineedit (qwidget * parent, const char * name = 0 );
Public slots:
Void interpretkeypress (ushort Unicode, ushort keycode,
Ushort modifiers, bool press, bool repeat );
};
Class main: Public qvbox
{
Public:
Main (qwidget * parent = 0, const char * name = 0, wflags f = 0 );
PRIVATE:
Qlineedit * l;
Qpinyinframe * py;
};
######################################## ##
// Test. cpp
# Include <qwindowsystem_qws.h>
# Include <qapplication. h>
# Include <qlineedit. h>
# Include "test. H"
Lineedit: lineedit (qwidget * parent, const char * Name): qlineedit (parent, name)
{
}
Void lineedit: interpretkeypress (ushort Unicode, ushort keycode,
Ushort modifiers, bool press, bool repeat)
{
If (Press) printf ("input = % d, keycode = % d, modifiers = % d/N", Unicode, keycode );
Qkeyevent Ke (press? Qevent: keypress: qevent: keyrelease,
Keycode, 0, modifiers, qchar (UNICODE), repeat );
If (Press)
Keypressevent (& ke );
Else
Keyreleaseevent (& ke );
}
Main: Main (qwidget * parent, const char * Name, wflags F): qvbox (parent, name, F)
{
L = new lineedit (this );
Py = new qpinyinframe (this );
Qobject: connect (PY, signal (Key (ushort, bool, bool )),
L, slot (interpretkeypress (ushort, bool, bool )));
}
Compiled as follows:
Some Considerations for the input method:
1. The locations of objects, murphytalk. conf) must be placed in pinyinframe. cpp. The positions of one file (murphytalk_phrase.dat) must be placed in pinyinphrase. cpp. You can also change the positions.
2. Murphytalk. conf: Set the Chinese font to efont. Because there is no efont, you can set it to uniont. The font size, keyboard = 0, no keyboard, = 1,
3. If you cannot enter Chinese characters, you can add a sentence to the sendKey (int u, int C) of pinyinframe. cpp.
Emit key (u, C, 0, true, false );
4. If the keys are automatically repeated when you enter Chinese characters, comment repeattimer-> Start (500 );
The modification was too hasty. I don't know whether the function is complete or not. If you are interested, please try it out. You are welcome to ask a question!