summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp148
-rw-r--r--inputmethods/multikey/keyboard.h6
2 files changed, 153 insertions, 1 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 28d5cab..1dd8ca1 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -40,9 +40,9 @@
/* Keyboard::Keyboard {{{1 */
Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0),
- meta(0), circumflex(0), diaeresis(0),
+ meta(0), circumflex(0), diaeresis(0), baccent(0), accent(0),
useLargeKeys(TRUE), usePicks(0), useRepeat(0),
pressedKeyRow(-1), pressedKeyCol(-1),
unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
configdlg(0)
@@ -189,8 +189,12 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
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 (baccent && keys->baccent(keys->shift(c)))
+ c = keys->baccent(keys->shift(c));
+ else if (accent && keys->accent(keys->shift(c)))
+ c = keys->accent(keys->shift(c));
else if (meta && keys->meta(keys->shift(c)))
c = keys->meta(keys->shift(c));
else
c = keys->shift(c);
@@ -198,8 +202,12 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
else if (meta && keys->meta(c))
c = keys->meta(c);
else if (circumflex && keys->circumflex(c))
c = keys->circumflex(c);
+ else if (baccent && keys->baccent(c))
+ c = keys->baccent(c);
+ else if (accent && keys->accent(c))
+ c = keys->accent(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.
@@ -259,8 +267,12 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
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 (baccent && keys->baccent(keys->shift(c)))
+ c = keys->baccent(keys->shift(c));
+ else if (accent && keys->accent(keys->shift(c)))
+ c = keys->accent(keys->shift(c));
else if (meta && keys->meta(keys->shift(c)))
c = keys->meta(keys->shift(c));
else
c = keys->shift(c);
@@ -268,8 +280,12 @@ void Keyboard::drawKeyboard(QPainter &p, int row, int col)
else if (meta && keys->meta(c))
c = keys->meta(c);
else if (circumflex && keys->circumflex(c))
c = keys->circumflex(c);
+ else if (baccent && keys->baccent(c))
+ c = keys->baccent(c);
+ else if (accent && keys->accent(c))
+ c = keys->accent(c);
else if (diaeresis && (keys->diaeresis(c) || c == 0x2c6)) {
if (c == 0x2c6)
c = 0xa8;
@@ -345,8 +361,43 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
qkeycode = 0x2000;
}
}
+ // Back accent character support
+
+ if (unicode == 0x60) {
+
+ unicode = 0;
+ if (shift || lock) {
+
+ // circumblex
+ qkeycode = 0x2000;
+ }
+ else {
+
+ // back accent
+ qkeycode = 0x2002;
+ }
+ }
+
+ // Accent character support
+
+ if (unicode == 0xb4) {
+
+ unicode = 0;
+ if (shift || lock) {
+
+ // diaeresis
+ qkeycode = 0x2001;
+ }
+ else {
+
+ // accent
+ qkeycode = 0x2003;
+ }
+ }
+
+
if (unicode == 0) { // either Qt char, or nothing
if (qkeycode == Qt::Key_F1) { // toggle the pickboard
@@ -471,8 +522,10 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
if (shift) { *shift = 0; shift = 0; }
if (lock) { *lock = 0; lock = 0; }
if (circumflex) { *circumflex = 0; circumflex = 0; }
if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
+ if (baccent) { *baccent = 0; baccent = 0; }
+ if (accent) { *accent = 0; accent = 0; }
// dont need to emit this key... acts same as alt
qkeycode = 0;
@@ -550,8 +603,52 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
}
qkeycode = 0;
+
+ // Back accent
+ } else if (qkeycode == 0x2002) {
+ need_repaint = TRUE;
+
+ if (baccent) {
+
+ *baccent = 0;
+ baccent = 0;
+
+ } else {
+
+ baccent = keys->pressedPtr(row, col);
+ *baccent = true;
+ }
+
+
+ if (shift) { *shift = 0; shift = 0; }
+ if (meta) { *meta = 0; meta = 0; }
+ if (accent) { *accent = 0; accent = 0; }
+
+ qkeycode = 0;
+
+ // Accent
+ } else if (qkeycode == 0x2003) {
+ need_repaint = TRUE;
+
+ if (accent) {
+
+ *accent = 0;
+ accent = 0;
+
+ } else {
+
+ accent = keys->pressedPtr(row, col);
+ *accent = true;
+ }
+
+
+ if (shift) { *shift = 0; shift = 0; }
+ if (meta) { *meta = 0; meta = 0; }
+ if (baccent) { *baccent = 0; }
+
+ qkeycode = 0;
}
}
else { // normal char
@@ -563,8 +660,12 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
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 (baccent && keys->baccent(keys->shift(unicode)))
+ unicode = keys->baccent(keys->shift(unicode));
+ else if (accent && keys->accent(keys->shift(unicode)))
+ unicode = keys->accent(keys->shift(unicode));
else if (meta && keys->meta(keys->shift(unicode)))
unicode = keys->meta(keys->shift(unicode));
else
unicode = keys->shift(unicode);
@@ -578,8 +679,14 @@ void Keyboard::mousePressEvent(QMouseEvent *e)
else if (diaeresis && keys->diaeresis(unicode)) {
unicode = keys->diaeresis(unicode);
}
+ else if (baccent && keys->baccent(unicode)) {
+ unicode = keys->baccent(unicode);
+ }
+ else if (accent && keys->accent(unicode)) {
+ unicode = keys->accent(unicode);
+ }
}
// korean parsing
if (keys->lang == "ko") {
@@ -732,8 +839,10 @@ void Keyboard::resetState()
if (lock) {*lock = 0; lock = 0; }
if (meta) { *meta = 0; meta = 0; }
if (circumflex) { *circumflex = 0; circumflex = 0; }
if (diaeresis) { *diaeresis = 0; diaeresis = 0; }
+ if (baccent) { *baccent = 0; baccent = 0; }
+ if (accent) { *accent = 0; accent = 0; }
schar = mchar = echar = 0;
picks->resetState();
}
@@ -1339,8 +1448,33 @@ void Keys::setKeysFromFile(const char * filename) {
diaeresisMap.insert(lower, shift);
buf = t.readLine();
}
+ // back accent
+ else if (buf.contains(QRegExp("^\\s*b\\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;
+
+ baccentMap.insert(lower, shift);
+
+ qDebug ("Estoy añadiendo %i con %i", lower, shift);
+ buf = t.readLine();
+ }
+ // accent
+ else if (buf.contains(QRegExp("^\\s*a\\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;
+
+ accentMap.insert(lower, shift);
+
+ buf = t.readLine();
+ }
// other variables like lang & title
else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
@@ -1488,8 +1622,20 @@ ushort Keys::diaeresis(const ushort uni) {
if(diaeresisMap[uni]) return diaeresisMap[uni];
else return 0;
}
+ushort Keys::baccent(const ushort uni) {
+
+ if(baccentMap[uni]) return baccentMap[uni];
+ else return 0;
+}
+
+ushort Keys::accent(const ushort uni) {
+
+ if(accentMap[uni]) return accentMap[uni];
+ else return 0;
+}
+
bool *Keys::pressedPtr(const int row, const int col) {
return keys[row].at(col)->pressed;
}
diff --git a/inputmethods/multikey/keyboard.h b/inputmethods/multikey/keyboard.h
index 8af80d0..bc74e71 100644
--- a/inputmethods/multikey/keyboard.h
+++ b/inputmethods/multikey/keyboard.h
@@ -65,8 +65,10 @@ public:
ushort shift(const ushort);
ushort meta(const ushort);
ushort circumflex(const ushort);
ushort diaeresis(const ushort);
+ ushort baccent(const ushort);
+ ushort accent(const ushort);
QImage *pix(const int row, const int col);
int numKeys(const int row);
void setKeysFromFile(const char *filename);
void setKey(const int row, const int qcode, const ushort unicode,
@@ -91,8 +93,10 @@ private:
QMap<ushort,ushort> shiftMap;
QMap<ushort,ushort> metaMap;
QMap<ushort,ushort> circumflexMap;
QMap<ushort,ushort> diaeresisMap;
+ QMap<ushort,ushort> baccentMap;
+ QMap<ushort,ushort> accentMap;
};
class Keyboard : public QFrame
@@ -137,8 +141,10 @@ private:
bool *alt;
bool *meta;
bool *circumflex;
bool *diaeresis;
+ bool *baccent;
+ bool *accent;
uint useLargeKeys:1;
uint usePicks:1;
uint useRepeat:1;