00001 #include "keyview.h"
00002 #include <qgrid.h>
00003
00004 #include <qlineedit.h>
00005 #include <qlabel.h>
00006 #include <opie2/okeyfilter.h>
00007 #include <opie2/odebug.h>
00008
00009 Keyview::Keyview( QWidget* parent, const char* name, WFlags fl )
00010 : QGrid ( 2, parent, name, fl )
00011 {
00012 setCaption( tr("Keyview") );
00013 setSpacing(3);
00014 setMargin(4);
00015
00016 QLabel *l;
00017
00018 l = new QLabel(QString("unicode:"), this);
00019 unicode = new QLineEdit(this);
00020 unicode->setReadOnly(1);
00021
00022 l = new QLabel(QString("keycode:"), this);
00023 keycode = new QLineEdit(this);
00024 keycode->setReadOnly(1);
00025
00026 l = new QLabel(QString("modifiers:"), this);
00027 modifiers = new QLineEdit(this);
00028 modifiers->setReadOnly(1);
00029
00030 l = new QLabel(QString("isPress:"), this);
00031 isPress = new QLineEdit(this);
00032 isPress->setReadOnly(1);
00033
00034 l = new QLabel(QString("autoRepeat:"), this);
00035 autoRepeat = new QLineEdit(this);
00036 autoRepeat->setReadOnly(1);
00037
00038
00039 l = new QLabel(QString(""), this);
00040 l->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
00041
00042
00043 KeyFilter *filter = new KeyFilter(this);
00044 Opie::Core::OKeyFilter::inst()->addHandler(filter);
00045 odebug << "Creating keyview filter " << oendl;
00046
00047 connect(filter, SIGNAL(keyPressed(int,int,int,bool,bool)),
00048 this, SLOT(updateItems(int,int,int,bool,bool)));
00049 }
00050
00051 Keyview::~Keyview()
00052 {
00053 }
00054
00055 void Keyview::updateItems(int u, int k, int m, bool p, bool a) {
00056
00057 unicode->setText("0x" + QString::number(u, 16));
00058 keycode->setText("0x" + QString::number(k, 16));
00059 modifiers->setText("0x" + QString::number(m, 16));
00060 isPress->setText("0x" + QString::number(p, 16));
00061 autoRepeat->setText("0x" + QString::number(a, 16));
00062 }
00063
00064 KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name )
00065 {
00066 }
00067
00068 KeyFilter::~KeyFilter() {
00069
00070 Opie::Core::OKeyFilter::inst()->remHandler( this );
00071 }
00072
00073 bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress,
00074 bool autoRepeat) {
00075
00076 qDebug( "unicode: %d, keycode: %d, modifiers: %0x, isPress: %d, autoRepeat: %d",
00077 unicode, keycode, modifiers, isPress, autoRepeat );
00078 emit keyPressed(unicode, keycode, modifiers, isPress, autoRepeat);
00079 return 0;
00080
00081 }