summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
Side-by-side diff
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 1d91b82..b793391 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -266,385 +266,385 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
// might need to repaint if two or more of the same keys.
// should be faster if just paint one key even though multiple keys exist.
bool need_repaint = FALSE;
if (unicode == 0) { // either Qt char, or nothing
if (qkeycode == Qt::Key_F1) { // toggle the pickboard
if ( configdlg ) {
delete (ConfigDlg *) configdlg;
configdlg = 0;
}
else {
configdlg = new ConfigDlg ();
connect(configdlg, SIGNAL(pickboardToggled(bool)),
this, SLOT(togglePickboard(bool)));
connect(configdlg, SIGNAL(setMapToDefault()),
this, SLOT(setMapToDefault()));
connect(configdlg, SIGNAL(setMapToFile(QString)),
this, SLOT(setMapToFile(QString)));
configdlg->showMaximized();
configdlg->show();
configdlg->raise();
}
} else if (qkeycode == Qt::Key_Control) {
ctrl = keys->pressedPtr(row, col);
need_repaint = TRUE;
*ctrl = !keys->pressed(row, col);
} else if (qkeycode == Qt::Key_Alt) {
alt = keys->pressedPtr(row, col);
need_repaint = TRUE;
*alt = !keys->pressed(row, col);
} else if (qkeycode == Qt::Key_Shift) {
need_repaint = TRUE;
if (shift) {
*shift = 0;
shift = 0;
}
else {
shift = keys->pressedPtr(row, col);
*shift = 1;
if (lock) {
*lock = 0;
lock = 0;
}
}
} else if (qkeycode == Qt::Key_CapsLock) {
need_repaint = TRUE;
if (lock) {
*lock = 0;
lock = 0;
}
else {
lock = keys->pressedPtr(row, col);;
*lock = 1;
if (shift) {
*shift = 0;
shift = 0;
}
}
}
}
else { // normal char
if ((shift || lock) && keys->shift(unicode)) {
unicode = keys->shift(unicode);
}
}
// korean parsing
if (keys->lang == "ko") {
unicode = parseKoreanInput(unicode);
}
modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
emit key(unicode, qkeycode, modifiers, true, false);
// pickboard stuff
if (usePicks) {
KeyboardConfig *dc = picks->dc;
if (dc) {
if (qkeycode == Qt::Key_Backspace) {
dc->input.remove(dc->input.last()); // remove last input
dc->decBackspaces();
} else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
dc->input.clear();
dc->resetBackspaces();
} else {
dc->add(QString(QChar(unicode)));
dc->incBackspaces();
}
}
picks->repaint();
}
// painting
pressed = TRUE;
pressedKeyRow = row;
pressedKeyCol = col;
if (need_repaint) repaint(FALSE);
else { // just paint the one key pressed
QPainter p(this);
drawKeyboard(p, row, col);
}
pressTid = startTimer(80);
}
/* Keyboard::mouseReleaseEvent {{{1 */
void Keyboard::mouseReleaseEvent(QMouseEvent*)
{
pressed = FALSE;
if ( pressTid == 0 )
#if defined(Q_WS_QWS) || defined(_WS_QWS_)
if ( unicode != -1 ) {
emit key( unicode, qkeycode, modifiers, false, false );
repeatTimer->stop();
}
#endif
if (shift && unicode != 0) {
*shift = 0; // unpress shift key
shift = 0; // reset the shift pointer
repaint(FALSE);
}
else
clearHighlight();
}
/* Keyboard::timerEvent {{{1 */
/*
void Keyboard::timerEvent(QTimerEvent* e)
{
if ( e->timerId() == pressTid ) {
killTimer(pressTid);
pressTid = 0;
if ( !pressed )
cout << "calling clearHighlight from timerEvent\n";
clearHighlight();
}
}
*/
void Keyboard::repeat()
{
repeatTimer->start( 200 );
emit key( unicode, 0, modifiers, true, true );
}
void Keyboard::clearHighlight()
{
if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
int tmpRow = pressedKeyRow;
int tmpCol = pressedKeyCol;
pressedKeyRow = -1;
pressedKeyCol = -1;
QPainter p(this);
drawKeyboard(p, tmpRow, tmpCol);
}
}
/* Keyboard::sizeHint {{{1 */
QSize Keyboard::sizeHint() const
{
QFontMetrics fm=fontMetrics();
- int keyHeight = fm.lineSpacing();
+ int keyHeight = fm.lineSpacing() + 2;
return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1);
}
void Keyboard::resetState()
{
schar = mchar = echar = 0;
picks->resetState();
}
/* Keyboard::togglePickboard {{{1 */
void Keyboard::togglePickboard(bool on_off)
{
usePicks = on_off;
if (usePicks) {
picks->show();
//move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
//adjustSize();
QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
} else {
picks->hide();
picks->resetState();
//move(x(), y() + picks->height());
//adjustSize();
QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
}
/*
* this closes && opens the input method
*/
QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
}
/* Keyboard::setMapTo ... {{{1 */
void Keyboard::setMapToDefault() {
/* load current locale language map */
Config *config = new Config("locale");
config->setGroup( "Language" );
QString l = config->readEntry( "Language" , "en" );
delete config;
QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
+ l + ".keymap";
/* save change to multikey config file */
config = new Config("multikey");
config->setGroup ("keymaps");
config->writeEntry ("current", key_map); // default closed
delete config;
delete keys;
keys = new Keys(key_map);
// have to repaint the keyboard
repaint(FALSE);
}
void Keyboard::setMapToFile(QString file) {
/* save change to multikey config file */
Config *config = new Config("multikey");
config->setGroup ("keymaps");
config->writeEntry ("current", file); // default closed
delete config;
delete keys;
keys = new Keys(file);
repaint(FALSE);
}
/* korean input functions {{{1
*
* TODO
* one major problem with this implementation is that you can't move the
* cursor after inputing korean chars, otherwise it will eat up and replace
* the char before the cursor you move to. fix that
*
* make backspace delete one single char, not the whole thing if still
* editing.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* how korean input works
*
* all following chars means unicode char value and are in hex
*
* ÃÊÀ½ = schar (start char)
* ÁßÀ½ = mchar (middle char)
* ³¡À½ = echar (end char)
*
* there are 19 schars. unicode position is at 1100 - 1112
* there are 21 mchars. unicode position is at 1161 - 1175
* there are 27 echars. unicode position is at 11a8 - 11c2
*
* the map with everything combined is at ac00 - d7a3
*
*/
ushort Keyboard::parseKoreanInput (ushort c) {
if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
||
(c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
&& qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
schar = 0, mchar = 0, echar = 0;
return c;
}
if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
if (schar == 0 || (schar != 0 && mchar == 0)) {
schar = c; mchar = 0; echar = 0;
return c;
}
else if (mchar != 0) {
if (echar == 0) {
if (!(echar = constoe(c))) {
schar = c; mchar = 0; echar = 0;
return c;
}
}
else { // must figure out what the echar is
if (echar == 0x11a8) { // ¤¡
if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡
else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ
else {
schar = c; mchar = 0; echar = 0;
return c;
}
} else if (echar == 0x11ab) { // ¤¤
if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
else {
schar = c; mchar = 0; echar = 0;
return c;
}
} else if (echar == 0x11af) { // ¤©
if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
else {
schar = c; mchar = 0; echar = 0;
return c;
}
} else if (echar == 0x11b8) { // ¤²
if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
else {
schar = c; mchar = 0; echar = 0;
return c;
}
} else if (echar == 0x11ba) { // ¤µ
if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
else {
schar = c; mchar = 0; echar = 0;
return c;
}
} else { // if any other char, cannot combine chars
schar = c; mchar = 0; echar = 0;
return c;
}
unicode = echar;
}