summaryrefslogtreecommitdiff
path: root/inputmethods/multikey/keyboard.cpp
authorhash <hash>2002-09-06 21:23:05 (UTC)
committer hash <hash>2002-09-06 21:23:05 (UTC)
commitfc4808bea669f75af0c28ba65cf2c638c97e99ba (patch) (side-by-side diff)
tree2ced268c3d31f9dded6d8332698ee8e476a081c0 /inputmethods/multikey/keyboard.cpp
parent15992c5f9b24eaf8df6f90d1993c85d73827b98f (diff)
downloadopie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.zip
opie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.tar.gz
opie-fc4808bea669f75af0c28ba65cf2c638c97e99ba.tar.bz2
french and other stuff fixed
Diffstat (limited to 'inputmethods/multikey/keyboard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp323
1 files changed, 277 insertions, 46 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 4747f59..28d5cab 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -42,4 +42,6 @@
Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
- QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0),
- useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1),
+ QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
+ meta(0), circumflex(0), diaeresis(0),
+ useLargeKeys(TRUE), usePicks(0), useRepeat(0),
+ pressedKeyRow(-1), pressedKeyCol(-1),
unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
@@ -97,3 +99,3 @@ void Keyboard::resizeEvent(QResizeEvent*)
picks->setGeometry( 0, 0, width(), ph );
- keyHeight = (height()-(usePicks ? ph : 0))/5;
+ keyHeight = (height()-(usePicks ? ph : 0))/keys->rows();
@@ -184,8 +186,28 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
if (!pix) {
- if (shift || lock)
- c = keys->shift(c);
- if (meta) {
+ if ((shift || lock) && keys->shift(c))
+
+ if (circumflex && keys->circumflex(keys->shift(c)))
+ c = keys->circumflex(keys->shift(c));
+ else if (diaeresis && keys->diaeresis(keys->shift(c)))
+ c = keys->diaeresis(keys->shift(c));
+ else if (meta && keys->meta(keys->shift(c)))
+ c = keys->meta(keys->shift(c));
+ else
+ c = keys->shift(c);
+ else if (meta && keys->meta(c))
c = keys->meta(c);
+ else if (circumflex && keys->circumflex(c))
+ c = keys->circumflex(c);
+ else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
+
+ // the diaeresis key itself has to be in the diaeresisMap,
+ // or just do this to make it display the diaeresis char.
+
+ if (c == 0x2c6)
+ c = 0xa8;
+ else
+ c = keys->diaeresis(c);
}
+
p.drawText(x, y,
@@ -210,3 +232,3 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
- for (row = 1; row <= 5; row++) {
+ for (row = 1; row <= keys->rows(); row++) {
@@ -235,5 +257,23 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
if ((shift || lock) && keys->shift(c))
- c = keys->shift(c);
+
+ if (circumflex && keys->circumflex(keys->shift(c)))
+ c = keys->circumflex(keys->shift(c));
+ else if (diaeresis && keys->diaeresis(keys->shift(c)))
+ c = keys->diaeresis(keys->shift(c));
+ else if (meta && keys->meta(keys->shift(c)))
+ c = keys->meta(keys->shift(c));
+ else
+ c = keys->shift(c);
+
else if (meta && keys->meta(c))
c = keys->meta(c);
+ else if (circumflex && keys->circumflex(c))
+ c = keys->circumflex(c);
+ else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
+
+ if (c == 0x2c6)
+ c = 0xa8;
+ else
+ c = keys->diaeresis(c);
+ }
@@ -291,2 +331,19 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
+ // circumflex and diaeresis support
+ // messy to have this here, but too hard to implement any other method
+ if (unicode == 0x2c6) {
+
+ unicode = 0;
+ if (shift || lock) {
+
+ // diaeresis
+ qkeycode = 0x2001;
+ }
+ else {
+
+ // circumflex
+ qkeycode = 0x2000;
+ }
+ }
+
if (unicode == 0) { // either Qt char, or nothing
@@ -296,2 +353,3 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
if ( configdlg ) {
+
delete (ConfigDlg *) configdlg;
@@ -311,2 +369,4 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
this, SLOT(reloadKeyboard()));
+ connect(configdlg, SIGNAL(configDlgClosed()),
+ this, SLOT(cleanupConfigDlg()));
configdlg->showMaximized();
@@ -361,7 +421,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
}
- if (meta) {
- *meta = 0;
- meta = 0;
- }
+
+ /*
+ * want to be able to hit circumflex/diaeresis -> shift
+ * to type in shifted circumflex/diaeresis chars.
+ * same thing with meta
+
+ if (meta) { *meta = 0; meta = 0; }
+ if (circumflex) { *circumflex = 0; circumflex = 0; }
+ if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
+
+ */
@@ -376,3 +443,3 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
lock = keys->pressedPtr(row, col);;
- *lock = 1;
+ *lock = true;;
if (shift) {
@@ -382,7 +449,8 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
}
- if (meta) {
- *meta = 0;
- meta = 0;
- }
+ /*
+ if (meta) { *meta = 0; meta = 0; }
+ if (circumflex) { *circumflex = 0; circumflex = 0; }
+ if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
+ */
@@ -398,20 +466,88 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
meta = keys->pressedPtr(row, col);
- need_repaint = TRUE;
- *meta = !keys->pressed(row, col);
+ *meta = true;
}
- if (shift) {
+ // reset all the other keys
+ if (shift) { *shift = 0; shift = 0; }
+ if (lock) { *lock = 0; lock = 0; }
+ if (circumflex) { *circumflex = 0; circumflex = 0; }
+ if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
- *shift = 0;
- shift = 0;
+ // dont need to emit this key... acts same as alt
+ qkeycode = 0;
+
+ // circumflex
+ } else if (qkeycode == 0x2000) {
+ need_repaint = TRUE;
+
+ if (circumflex) {
+
+ *circumflex = 0;
+ circumflex = 0;
+
+ } else {
+ circumflex = keys->pressedPtr(row, col);
+ *circumflex = true;
}
- if (lock) {
- *lock = 0;
- lock = 0;
+ /* no need to turn off shift or lock if circumflex
+ * keys are pressed
+
+ if (shift) { *shift = 0; shift = 0; }
+ if (lock) { *lock = 0; lock = 0; }
+
+ */
+
+ // have to reset all the other keys
+ if (meta) { *meta = 0; meta = 0; }
+ if (diaeresis) {
+
+ // *diaeresis and *circumflex point to the same thing
+ // when diaeresis is enabled and you hit the circumflex
+ // since they are the same key, it should turn off the
+ // key
+
+ *diaeresis = 0;
+ diaeresis = 0;
+ circumflex = 0;
+ }
+
+ qkeycode = 0;
+ // diaeresis
+ } else if (qkeycode == 0x2001) {
+ need_repaint = TRUE;
+
+ if (diaeresis) {
+
+ *diaeresis = 0;
+ diaeresis = 0;
+
+ } else {
+
+ diaeresis = keys->pressedPtr(row, col);
+ *diaeresis = true;
}
- // dont need to emit this key... acts same as alt
+
+ if (shift) { *shift = 0; shift = 0; }
+
+ /*
+ *
+ if (lock) { *lock = 0; lock = 0; }
+ *
+ */
+
+ if (meta) { *meta = 0; meta = 0; }
+ if (circumflex) {
+
+ // *circumflex = 0;
+ //
+ // same thing the diaeresis pointer points too
+
+ circumflex = 0;
+ }
+
+
qkeycode = 0;
@@ -422,7 +558,25 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
if ((shift || lock) && keys->shift(unicode)) {
- unicode = keys->shift(unicode);
+
+ // make diaeresis/circumflex -> shift input shifted
+ // diaeresis/circumflex chars
+
+ if (circumflex && keys->circumflex(keys->shift(unicode)))
+ unicode = keys->circumflex(keys->shift(unicode));
+ else if (diaeresis && keys->diaeresis(keys->shift(unicode)))
+ unicode = keys->diaeresis(keys->shift(unicode));
+ else if (meta && keys->meta(keys->shift(unicode)))
+ unicode = keys->meta(keys->shift(unicode));
+ else
+ unicode = keys->shift(unicode);
}
- if (meta && keys->meta(unicode)) {
+ else if (meta && keys->meta(unicode)) {
unicode = keys->meta(unicode);
}
+ else if (circumflex && keys->circumflex(unicode)) {
+ unicode = keys->circumflex(unicode);
+ }
+ else if (diaeresis && keys->diaeresis(unicode)) {
+
+ unicode = keys->diaeresis(unicode);
+ }
}
@@ -506,3 +660,9 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*)
- } else if (meta && unicode != 0) {
+ }
+
+ /*
+ * do not make the meta key release after being pressed
+ *
+
+ else if (meta && unicode != 0) {
@@ -512,5 +672,6 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*)
}
- else
- clearHighlight();
+ */
+
+ else clearHighlight();
}
@@ -563,3 +724,3 @@ QSize Keyboard::sizeHint() const
- return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1);
+ return QSize( 240, keyHeight * keys->rows() + (usePicks ? picks->sizeHint().height() : 0) + 1);
}
@@ -569,2 +730,8 @@ void Keyboard::resetState()
{
+ if (shift) { *shift = 0; shift = 0; }
+ if (lock) {*lock = 0; lock = 0; }
+ if (meta) { *meta = 0; meta = 0; }
+ if (circumflex) { *circumflex = 0; circumflex = 0; }
+ if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
+
schar = mchar = echar = 0;
@@ -606,2 +773,10 @@ void Keyboard::toggleRepeat(bool on) {
+void Keyboard::cleanupConfigDlg() {
+
+ if ( configdlg ) {
+ delete (ConfigDlg *) configdlg;
+ configdlg = 0;
+ }
+}
+
/* Keyboard::setMapTo ... {{{1 */
@@ -616,3 +791,3 @@ void Keyboard::setMapToDefault() {
- QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
+ QString key_map = QPEApplication::qpeDir() + "share/multikey/"
+ l + ".keymap";
@@ -625,2 +800,4 @@ void Keyboard::setMapToDefault() {
+ int prevRows = keys->rows();
+
delete keys;
@@ -629,3 +806,10 @@ void Keyboard::setMapToDefault() {
// have to repaint the keyboard
- repaint(FALSE);
+ if (prevRows != keys->rows()) {
+
+ QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
+ QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
+
+ } else repaint(FALSE);
+
+ resetState();
}
@@ -641,2 +825,4 @@ void Keyboard::setMapToFile(QString map) {
+ int prevRows = keys->rows();
+
delete keys;
@@ -647,4 +833,10 @@ void Keyboard::setMapToFile(QString map) {
- repaint(FALSE);
+ if (keys->rows() != prevRows) {
+
+ QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
+ QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
+ }
+ else repaint(FALSE);
+ resetState();
}
@@ -1126,2 +1318,27 @@ void Keys::setKeysFromFile(const char * filename) {
+ // circumflex
+ else if (buf.contains(QRegExp("^\\s*c\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
+
+ QTextStream tmp (buf, IO_ReadOnly);
+ ushort lower, shift;
+ QChar c;
+ tmp >> c >> lower >> shift;
+
+ circumflexMap.insert(lower, shift);
+
+ buf = t.readLine();
+ }
+ // diaeresis
+ else if (buf.contains(QRegExp("^\\s*d\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
+
+ QTextStream tmp (buf, IO_ReadOnly);
+ ushort lower, shift;
+ QChar d;
+ tmp >> d >> lower >> shift;
+
+ diaeresisMap.insert(lower, shift);
+
+ buf = t.readLine();
+ }
+
// other variables like lang & title
@@ -1207,2 +1424,14 @@ int Keys::width(const int row, const int col) {
}
+
+int Keys::rows() {
+
+ for (int i = 1; i <= 5; i++) {
+
+ if (keys[i].count() == 0)
+ return i - 1;
+
+ }
+ return 5;
+}
+
ushort Keys::uni(const int row, const int col) {
@@ -1240,20 +1469,22 @@ ushort Keys::shift(const ushort uni) {
- if (shiftMap[uni]) {
+ if (shiftMap[uni]) return shiftMap[uni];
+ else return 0;
+}
- return shiftMap[uni];
- }
- else
- return 0;
+ushort Keys::meta(const ushort uni) {
+ if (metaMap[uni]) return metaMap[uni];
+ else return 0;
}
-ushort Keys::meta(const ushort uni) {
+ushort Keys::circumflex(const ushort uni) {
- if (metaMap[uni]) {
+ if (circumflexMap[uni]) return circumflexMap[uni];
+ else return 0;
+}
- return metaMap[uni];
- }
- else
- return 0;
+ushort Keys::diaeresis(const ushort uni) {
+ if(diaeresisMap[uni]) return diaeresisMap[uni];
+ else return 0;
}