summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp68
-rw-r--r--noncore/apps/opie-console/function_keyboard.h25
2 files changed, 88 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index a3da5b2..9b036f3 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -2,8 +2,29 @@
#include <qsizepolicy.h>
+#include <qwindowsystem_qws.h>
FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
- QFrame(parent), numRows(2), numCols(15),
+ QFrame(parent), numRows(1), numCols(11),
pressedRow(0), pressedCol(0) {
- setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding));
+ setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
+
+ Config conf("opie-console-keys");
+ conf.setGroup("keys");
+ for (int r = 0; r < numRows; r++)
+ for (int c = 0; c < numCols; c++) {
+
+ QString handle = "r" + QString::number(r) + "c" + QString::number(c);
+ QStringList value_list = conf.readListEntry( handle, '|');
+
+ if (value_list.isEmpty()) continue;
+
+ keys.insert(
+
+ handle,
+ FKey (value_list[0], value_list[1].toUShort(), value_list[2].toUShort())
+ );
+ }
+ qWarning("loaded %d keys", keys.count());
+
+
@@ -21,2 +42,4 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
+ p.setPen(QColor(0,0,0));
+
/* those decimals do count! becomes short if use plain int */
@@ -24,3 +47,2 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
- p.setPen(QColor(0,0,0));
p.drawLine((int)i, 0, (int)i, height());
@@ -28,5 +50,7 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
- for (int i = 0; i <= height(); i += height()/numRows) {
+ // sometimes the last line doesnt get drawn
+ p.drawLine(width() -1, 0, width() -1, height());
+
+ for (int i = 0; i <= height(); i += keyHeight) {
- p.setPen(QColor(0,0,0));
p.drawLine(0, i, width(), i);
@@ -34,2 +58,17 @@ void FunctionKeyboard::paintEvent(QPaintEvent *e) {
+ for (int r = 0; r < numRows; r++) {
+ for (int c = 0; c < numCols; c++) {
+
+ QString handle = "r" + QString::number(r) + "c" + QString::number(c);
+ if (keys.contains(handle)) {
+
+ p.drawText(
+ c * keyWidth + 1, r * keyHeight + 1,
+ keyWidth, keyHeight,
+ Qt::AlignHCenter | Qt::AlignVCenter,
+ keys[handle].getL()
+ );
+ }
+ }
+ }
}
@@ -39,2 +78,3 @@ void FunctionKeyboard::paintKey(int row, int col) {
QPainter p(this);
+
p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
@@ -42,2 +82,9 @@ void FunctionKeyboard::paintKey(int row, int col) {
(pressedRow != -1 && pressedCol != -1 ) ? QColor(97,119,155) : QColor(255,255,255));
+ p.drawText(
+ col * keyWidth + 1, row * keyHeight + 1,
+ keyWidth, keyHeight,
+ Qt::AlignHCenter | Qt::AlignVCenter,
+ keys["r" + QString::number(row) + "c" + QString::number(col)].getL()
+ );
+
}
@@ -50,2 +97,8 @@ void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
paintKey(pressedRow, pressedCol);
+
+ // emit that sucker!
+ FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
+ //QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0);
+ //qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 1, 0);
+ qwsServer->sendKeyEvent(0x41, 0, 0, 1, 0);
}
@@ -59,3 +112,8 @@ void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
paintKey(row, col);
+
+ FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
+ //QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0);
+ //qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0);
}
+
}
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h
index f1ca037..bc3e25c 100644
--- a/noncore/apps/opie-console/function_keyboard.h
+++ b/noncore/apps/opie-console/function_keyboard.h
@@ -3,4 +3,24 @@
+#include <qpe/config.h>
#include <qframe.h>
#include <qpainter.h>
+#include <qmap.h>
+
+class FKey {
+
+public:
+
+ FKey(): qcode(0), unicode(0) {};
+ FKey(const QString &l, ushort q, ushort u): label(l), qcode(q), unicode(u) {};
+
+ QString getL() { return label; }
+ ushort getQ() { return qcode; }
+ ushort getU() { return unicode; }
+
+private:
+
+ QString label;
+ ushort qcode;
+ ushort unicode;
+};
@@ -19,2 +39,3 @@ public:
+
@@ -23,2 +44,6 @@ public:
private:
+
+ // thie key for the map is the row/col
+ QMap<QString, FKey> keys;
+
uint numRows;