summaryrefslogtreecommitdiff
authorhash <hash>2002-08-22 04:33:16 (UTC)
committer hash <hash>2002-08-22 04:33:16 (UTC)
commitea0d66f137984689c4d4ef6da7dd4b7323760e8c (patch) (side-by-side diff)
tree75332072b67132ef7fd7559578b7f02405d69a88
parentee90b966cfc262770ef5a45c2bad0af6766245a2 (diff)
downloadopie-ea0d66f137984689c4d4ef6da7dd4b7323760e8c.zip
opie-ea0d66f137984689c4d4ef6da7dd4b7323760e8c.tar.gz
opie-ea0d66f137984689c4d4ef6da7dd4b7323760e8c.tar.bz2
fixed nasty bug related to ctrl and alt keys
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp30
1 files changed, 24 insertions, 6 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index d5a7afd..7098a6b 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -209,200 +209,218 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
p.setPen(keycolor_lines);
p.drawLine(x, y, x + width(), y);
for (int col = 0; col < keys->numKeys(row); col++) {
QPixmap *pix = keys->pix(row, col);
int keyWidth = keys->width(row, col);
int keyWidthPix = defaultKeyWidth * keyWidth;
if (keys->pressed(row, col))
p.fillRect(x+1, y+1, keyWidthPix - 1,
keyHeight - 1, keycolor_pressed);
ushort c = keys->uni(row, col);
if (!pix) {
p.setPen(textcolor);
p.drawText(x, y,
keyWidthPix, keyHeight,
AlignCenter, ((shift || lock) && keys->shift(c)) ? (QChar)keys->shift(c) : (QChar)c);
}
else {
// center the image in the middle of the key
p.drawPixmap( x + (keyWidthPix - pix->width())/2,
y + (keyHeight - pix->height())/2 + 1,
QPixmap(*pix) );
}
p.setPen(keycolor_lines);
p.drawLine(x, y, x, y + keyHeight);
x += keyWidthPix;
}
}
p.drawLine(0, height() - 1, width(), height() - 1);
p.drawLine(width() - 1, 0, width() - 1, height());
}
}
/* Keyboard::mousePressEvent {{{1 */
void Keyboard::mousePressEvent(QMouseEvent *e)
{
int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
if (row > 5) row = 5;
// figure out the column
int col = 0;
for (int w = 0; e->x() >= w; col++)
if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
w += keys->width(row,col) * defaultKeyWidth;
else break;
if (col <= 0) return;
col --; // rewind one...
qkeycode = keys->qcode(row, col);
unicode = keys->uni(row, col);
// 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(setMapToDefault()),
this, SLOT(setMapToDefault()));
connect(configdlg, SIGNAL(setMapToFile(QString)),
this, SLOT(setMapToFile(QString)));
connect(configdlg, SIGNAL(pickboardToggled(bool)),
this, SLOT(togglePickboard(bool)));
connect(configdlg, SIGNAL(repeatToggled(bool)),
this, SLOT(toggleRepeat(bool)));
connect(configdlg, SIGNAL(reloadKeyboard()),
this, SLOT(reloadKeyboard()));
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);
+
+ if (ctrl) {
+
+ *ctrl = 0;
+ ctrl = 0;
+
+ } else {
+
+ 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);
+
+ if (alt) {
+ *alt = 0;
+ alt = 0;
+
+ } else {
+
+ 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);
if ('A' <= unicode && unicode <= 'z' && modifiers) {
qkeycode = QChar(unicode).upper();
unicode = qkeycode - '@';
}
QWSServer::sendKeyEvent(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);
}
if (useRepeat) repeatTimer->start( 800 );