summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/function_keyboard.cpp43
-rw-r--r--noncore/apps/opie-console/function_keyboard.h9
-rw-r--r--noncore/apps/opie-console/mainwindow.cpp2
3 files changed, 31 insertions, 23 deletions
diff --git a/noncore/apps/opie-console/function_keyboard.cpp b/noncore/apps/opie-console/function_keyboard.cpp
index ac35d1c..4119ad4 100644
--- a/noncore/apps/opie-console/function_keyboard.cpp
+++ b/noncore/apps/opie-console/function_keyboard.cpp
@@ -1,53 +1,54 @@
#include "function_keyboard.h"
#include <qsizepolicy.h>
#include <qevent.h>
#include <qwindowsystem_qws.h>
#include <qapplication.h>
FunctionKeyboard::FunctionKeyboard(QWidget *parent) :
- QFrame(parent), numRows(1), numCols(11),
+ QFrame(parent), numRows(2), numCols(11),
pressedRow(0), pressedCol(0) {
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());
+ //qWarning("loaded %d keys", keys.count());
+ if (keys.isEmpty()) loadDefaults();
}
FunctionKeyboard::~FunctionKeyboard() {
}
void FunctionKeyboard::paintEvent(QPaintEvent *e) {
QPainter p(this);
p.setClipRect(e->rect());
p.fillRect(0, 0, width(), height(), QColor(255,255,255));
p.setPen(QColor(0,0,0));
/* those decimals do count! becomes short if use plain int */
for (double i = 0; i <= width(); i += keyWidth) {
p.drawLine((int)i, 0, (int)i, height());
}
// sometimes the last line doesnt get drawn
@@ -80,73 +81,77 @@ void FunctionKeyboard::paintKey(int row, int col) {
QPainter p(this);
p.fillRect(QRect(QPoint(col * keyWidth + 1, row * keyHeight + 1),
QPoint((col + 1) * keyWidth - 1, row * keyHeight + keyHeight- 1)),
(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()
);
}
void FunctionKeyboard::mousePressEvent(QMouseEvent *e) {
pressedRow = e->y() / keyHeight;
pressedCol = (int) (e->x() / keyWidth);
paintKey(pressedRow, pressedCol);
// emit that sucker!
FKey k = keys["r" + QString::number(pressedRow) + "c" + QString::number(pressedCol)];
emit keyPressed(k.getU(), k.getQ(), 0, 1, 0);
- /*
- *
- 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);
-
- QKeyEvent ke(QEvent::KeyPress, k.getQ(), k.getU(), 0);
- QApplication::sendEvent((QObject *)parent, &ke);
- */
}
void FunctionKeyboard::mouseReleaseEvent(QMouseEvent *) {
if (pressedRow != -1 && pressedRow != -1) {
int row = pressedRow; pressedRow = -1;
int col = pressedCol; pressedCol = -1;
paintKey(row, col);
FKey k = keys["r" + QString::number(row) + "c" + QString::number(col)];
emit keyPressed(k.getU(), k.getQ(), 0, 0, 0);
-
- /*
- QWSServer::sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0);
- qwsServer->sendKeyEvent(k.getU(), k.getQ(), 0, 0, 0);
-
- QKeyEvent ke(QEvent::KeyRelease, k.getQ(), k.getU(), 0);
- QApplication::sendEvent((QObject *)parent, &ke);
- */
}
}
void FunctionKeyboard::resizeEvent(QResizeEvent*) {
/* set he default font height/width */
QFontMetrics fm=fontMetrics();
keyHeight = fm.lineSpacing() + 2;
keyWidth = (double)width()/numCols;
}
QSize FunctionKeyboard::sizeHint() const {
return QSize(width(), keyHeight * numRows + 1);
}
+void FunctionKeyboard::loadDefaults() {
+
+ /* what keys should be default? */
+ keys.insert( "r0c0", FKey ("F1", 4144, 0));
+ keys.insert( "r0c1", FKey ("F2", 4145, 0));
+ keys.insert( "r0c2", FKey ("F3", 4145, 0));
+ keys.insert( "r0c3", FKey ("F4", 4146, 0));
+ keys.insert( "r0c4", FKey ("F5", 4147, 0));
+ keys.insert( "r0c5", FKey ("F6", 4148, 0));
+ keys.insert( "r0c6", FKey ("F7", 4149, 0));
+ keys.insert( "r0c7", FKey ("F8", 4150, 0));
+ keys.insert( "r0c8", FKey ("F9", 4151, 0));
+ keys.insert( "r0c9", FKey ("F10", 4152, 0));
+ keys.insert( "r0c10", FKey ("F11", 4153, 0));
+
+ keys.insert( "r1c7", FKey ("Ho", 4112, 0));
+ keys.insert( "r1c8", FKey ("End", 4113, 0));
+ keys.insert( "r1c9", FKey ("PU", 4118, 0));
+ keys.insert( "r1c10", FKey ("PD", 4119, 0));
+
+}
diff --git a/noncore/apps/opie-console/function_keyboard.h b/noncore/apps/opie-console/function_keyboard.h
index b8420ae..8d05e2b 100644
--- a/noncore/apps/opie-console/function_keyboard.h
+++ b/noncore/apps/opie-console/function_keyboard.h
@@ -1,64 +1,67 @@
#ifndef OPIE_FUNCTION_KEYBOARD_H
#define OPIE_FUNCTION_KEYBOARD_H
#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;
};
class FunctionKeyboard : public QFrame {
Q_OBJECT
public:
FunctionKeyboard(QWidget *parent = 0);
~FunctionKeyboard();
void paintEvent(QPaintEvent *);
void paintKey(int, int);
void mousePressEvent(QMouseEvent*);
void mouseReleaseEvent(QMouseEvent*);
void resizeEvent(QResizeEvent*);
-
-
-
QSize sizeHint() const;
signals:
void keyPressed(ushort, ushort, bool, bool, bool);
private:
+ void loadDefaults();
+
+
+private:
+
// thie key for the map is the row/col
QMap<QString, FKey> keys;
uint numRows;
uint numCols;
uint keyHeight;
double keyWidth; // decimal point matters!
int pressedRow, pressedCol;
QObject *parent;
};
#endif
diff --git a/noncore/apps/opie-console/mainwindow.cpp b/noncore/apps/opie-console/mainwindow.cpp
index 5900785..0c89620 100644
--- a/noncore/apps/opie-console/mainwindow.cpp
+++ b/noncore/apps/opie-console/mainwindow.cpp
@@ -140,49 +140,49 @@ void MainWindow::initUI() {
m_closewindow->addTo( m_console );
connect( m_closewindow, SIGNAL(activated() ),
this, SLOT(slotClose() ) );
/*
* script actions
*/
m_recordScript = new QAction(tr("Record Script"), QString::null, 0, this, 0);
m_recordScript->addTo(m_scripts);
connect(m_recordScript, SIGNAL(activated()), this, SLOT(slotRecordScript()));
m_saveScript = new QAction(tr("Save Script"), QString::null, 0, this, 0);
m_saveScript->addTo(m_scripts);
connect(m_saveScript, SIGNAL(activated()), this, SLOT(slotSaveScript()));
m_runScript = new QAction(tr("Run Script"), QString::null, 0, this, 0);
m_runScript->addTo(m_scripts);
connect(m_runScript, SIGNAL(activated()), this, SLOT(slotRunScript()));
/*
* action that open/closes the keyboard
*/
m_openKeys = new QAction (tr("Open Keyboard..."),
- Resource::loadPixmap( "down" ),
+ Resource::loadPixmap( "console/keyboard_icon.png" ),
QString::null, 0, this, 0);
m_openKeys->setToggleAction(true);
connect (m_openKeys, SIGNAL(toggled(bool)),
this, SLOT(slotOpenKeb(bool)));
m_openKeys->addTo(m_icons);
/*
* action that open/closes the keyboard
*/
m_openButtons = new QAction ( tr( "Open Buttons..." ),
Resource::loadPixmap( "down" ),
QString::null, 0, this, 0 );
m_openButtons->setToggleAction( true );
connect ( m_openButtons, SIGNAL( toggled( bool ) ),
this, SLOT( slotOpenButtons( bool ) ) );
m_openButtons->addTo( m_icons );
/* insert the submenu */