summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/multikey/configdlg.cpp11
-rw-r--r--inputmethods/multikey/configdlg.h3
-rw-r--r--inputmethods/multikey/keyboard.cpp315
-rw-r--r--inputmethods/multikey/keyboard.h11
4 files changed, 295 insertions, 45 deletions
diff --git a/inputmethods/multikey/configdlg.cpp b/inputmethods/multikey/configdlg.cpp
index 26c9233..a8206b7 100644
--- a/inputmethods/multikey/configdlg.cpp
+++ b/inputmethods/multikey/configdlg.cpp
@@ -3,4 +3,5 @@
* make a font selection thing (size too)
- * make vertical keys possible
* make a keymap editor
+ * make keys translucent
+ * make vertical keys possible
*
@@ -250,2 +251,8 @@ void ConfigDlg::repeatTog() {
+void ConfigDlg::closeEvent(QCloseEvent *) {
+
+ // tell the parent it was closed, so delete me
+ emit configDlgClosed();
+}
+
// ConfigDlg::setMap {{{1
@@ -269,3 +276,3 @@ void ConfigDlg::setMap(int index) {
remove_button->setDisabled(true);
- emit setMapToFile(QPEApplication::qpeDir() + "/share/multikey/" + default_maps[index - 1]);
+ emit setMapToFile(QPEApplication::qpeDir() + "share/multikey/" + default_maps[index - 1]);
diff --git a/inputmethods/multikey/configdlg.h b/inputmethods/multikey/configdlg.h
index 5d6403f..336932b 100644
--- a/inputmethods/multikey/configdlg.h
+++ b/inputmethods/multikey/configdlg.h
@@ -22,2 +22,3 @@ signals:
void reloadKeyboard();
+ void configDlgClosed();
@@ -29,2 +30,4 @@ private slots:
void removeMap();
+ virtual void closeEvent ( QCloseEvent * );
+
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)
+ 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);
- if (meta) {
+ 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))
+
+ 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);
+ *meta = true;
+ }
+
+ // 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; }
+
+ // dont need to emit this key... acts same as alt
+ qkeycode = 0;
+
+ // circumflex
+ } else if (qkeycode == 0x2000) {
need_repaint = TRUE;
- *meta = !keys->pressed(row, col);
+
+ if (circumflex) {
+
+ *circumflex = 0;
+ circumflex = 0;
+
+ } else {
+
+ circumflex = keys->pressedPtr(row, col);
+ *circumflex = true;
}
- if (shift) {
+ /* no need to turn off shift or lock if circumflex
+ * keys are pressed
- *shift = 0;
- shift = 0;
+ 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;
}
- if (lock) {
- *lock = 0;
- lock = 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)) {
+
+ // 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,9 +1469,4 @@ ushort Keys::shift(const ushort uni) {
- if (shiftMap[uni]) {
-
- return shiftMap[uni];
- }
- else
- return 0;
-
+ if (shiftMap[uni]) return shiftMap[uni];
+ else return 0;
}
@@ -1251,9 +1475,16 @@ ushort Keys::meta(const ushort uni) {
- if (metaMap[uni]) {
+ if (metaMap[uni]) return metaMap[uni];
+ else return 0;
+}
+
+ushort Keys::circumflex(const ushort uni) {
- return metaMap[uni];
+ if (circumflexMap[uni]) return circumflexMap[uni];
+ else return 0;
}
- else
- return 0;
+ushort Keys::diaeresis(const ushort uni) {
+
+ if(diaeresisMap[uni]) return diaeresisMap[uni];
+ else return 0;
}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index 1aa7a35..8af80d0 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -58,5 +58,6 @@ public:
~Keys();
+ int width(const int row, const int col);
+ int rows();
ushort uni(const int row, const int col);
int qcode(const int row, const int col);
- int width(const int row, const int col);
bool pressed(const int row, const int col);
@@ -65,2 +66,4 @@ public:
ushort meta(const ushort);
+ ushort circumflex(const ushort);
+ ushort diaeresis(const ushort);
QImage *pix(const int row, const int col);
@@ -89,2 +92,4 @@ private:
QMap<ushort,ushort> metaMap;
+ QMap<ushort,ushort> circumflexMap;
+ QMap<ushort,ushort> diaeresisMap;
@@ -119,2 +124,3 @@ private slots:
void setMapToFile(QString map);
+ void cleanupConfigDlg();
@@ -132,2 +138,5 @@ private:
bool *meta;
+ bool *circumflex;
+ bool *diaeresis;
+
uint useLargeKeys:1;