summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--development/keyview/keyboardimpl.cpp4
-rw-r--r--development/keyview/keyview.cpp7
-rw-r--r--development/keyview/keyview.h2
3 files changed, 11 insertions, 2 deletions
diff --git a/development/keyview/keyboardimpl.cpp b/development/keyview/keyboardimpl.cpp
index 673eaa5..0216110 100644
--- a/development/keyview/keyboardimpl.cpp
+++ b/development/keyview/keyboardimpl.cpp
@@ -1,189 +1,193 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include <qapplication.h>
#include <qpixmap.h>
#include "keyview.h"
#include "keyboardimpl.h"
/* XPM */
static const char * kb_xpm[] = {
"28 13 81 1",
" c None",
". c #000000",
"+ c #E5E1D5",
"@ c #FFFFFF",
"# c #DBDBDB",
"$ c #132B07",
"% c #426362",
"& c #558384",
"* c #6E6D67",
"= c #DCD8CD",
"- c #929292",
"; c #446463",
"> c #558585",
", c #466565",
"' c #558685",
") c #B7B7B7",
"! c #A2A2A2",
"~ c #9A9A9A",
"{ c #959595",
"] c #939393",
"^ c #486767",
"/ c #383838",
"( c #303030",
"_ c #2C2C2C",
": c #2A2A2A",
"< c #292929",
"[ c #333333",
"} c #FFFFE9",
"| c #FEFFDD",
"1 c #E4E5AD",
"2 c #202020",
"3 c #466665",
"4 c #2F2F2F",
"5 c #FEFFC1",
"6 c #575742",
"7 c #191919",
"8 c #2D2D2D",
"9 c #29291F",
"0 c #141414",
"a c #122207",
"b c #548584",
"c c #111111",
"d c #131313",
"e c #1B2514",
"f c #112106",
"g c #416160",
"h c #538484",
"i c #2B2B2B",
"j c #0F0F0F",
"k c #14190F",
"l c #192312",
"m c #0F1F06",
"n c #40605F",
"o c #518483",
"p c #9D9D9D",
"q c #747474",
"r c #2B2C2B",
"s c #060704",
"t c #0B0E09",
"u c #12180D",
"v c #17210F",
"w c #0E1E04",
"x c #3D5E5D",
"y c #508382",
"z c #898989",
"A c #9C9C9C",
"B c #050704",
"C c #0A0D08",
"D c #10170B",
"E c #141E0C",
"F c #0C1B04",
"G c #395C5A",
"H c #4F8181",
"I c #242424",
"J c #050604",
"K c #090C06",
"L c #0E1509",
"M c #121C0A",
"N c #0B1A03",
"O c #375A58",
"P c #4D807F",
"...........+..@.@@@@@@@#.$%&",
"..........*=.@.@.@@@@@##.-;>",
"..............@.@.@@@###.-,'",
")!~{{]]]{]]].@.@.@@#.##-.-^'",
"/(_::<<<:<<<..@.@@#..#--.-^'",
"[}|12}|12}|12.#.@#.-.---.-3'",
"4|567|567|567..@@...---.--,'",
"81690169016901.@#.----.--a;b",
"82700ccc0cccd.@@......--efgh",
"i}|1c}|1c}|1j.@#.------klmno",
"i|56c|56c|56.@#.--pqrstuvwxy",
"i169c169c16.@#.--zAqrBCDEFGH",
"82700ccc0cj...--IzAqrJKLMNOP"};
KeyboardImpl::KeyboardImpl()
: input(0), icn(0), ref(0)
{
}
KeyboardImpl::~KeyboardImpl()
{
delete input;
delete icn;
}
QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f )
{
if ( !input )
input = new Keyview( parent, "Keyview", f );
return input;
}
void KeyboardImpl::resetState()
{
/*
if ( input )
input->resetState();
*/
}
QPixmap *KeyboardImpl::icon()
{
if ( !icn )
icn = new QPixmap( (const char **)kb_xpm );
return icn;
}
QString KeyboardImpl::name()
{
// return qApp->translate( "InputMethods", "Keyboard" );
return "Keyview";
}
void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot )
{
+ Q_UNUSED( receiver );
+ Q_CONST_UNUSED( slot );
//if ( input )
//QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot );
}
#ifndef QT_NO_COMPONENT
QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_InputMethod )
*iface = this;
+ else
+ return QS_FALSE;
if ( *iface )
(*iface)->addRef();
return QS_OK;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( KeyboardImpl )
}
#endif
diff --git a/development/keyview/keyview.cpp b/development/keyview/keyview.cpp
index 8187744..cf082a8 100644
--- a/development/keyview/keyview.cpp
+++ b/development/keyview/keyview.cpp
@@ -1,76 +1,81 @@
#include "keyview.h"
#include <qgrid.h>
//#include <iostream.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <opie2/okeyfilter.h>
#include <opie2/odebug.h>
Keyview::Keyview( QWidget* parent, const char* name, WFlags fl )
: QGrid ( 2, parent, name, fl )
{
setCaption( tr("Keyview") );
setSpacing(3);
setMargin(4);
QLabel *l;
l = new QLabel(QString("unicode:"), this);
unicode = new QLineEdit(this);
unicode->setReadOnly(1);
l = new QLabel(QString("keycode:"), this);
keycode = new QLineEdit(this);
keycode->setReadOnly(1);
l = new QLabel(QString("modifiers:"), this);
modifiers = new QLineEdit(this);
modifiers->setReadOnly(1);
l = new QLabel(QString("isPress:"), this);
isPress = new QLineEdit(this);
isPress->setReadOnly(1);
l = new QLabel(QString("autoRepeat:"), this);
autoRepeat = new QLineEdit(this);
autoRepeat->setReadOnly(1);
// spacer
l = new QLabel(QString(""), this);
l->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
KeyFilter *filter = new KeyFilter(this);
Opie::Core::OKeyFilter::inst()->addHandler(filter);
odebug << "Creating keyview filter " << oendl;
connect(filter, SIGNAL(keyPressed(int,int,int,bool,bool)),
this, SLOT(updateItems(int,int,int,bool,bool)));
}
Keyview::~Keyview()
{
}
void Keyview::updateItems(int u, int k, int m, bool p, bool a) {
unicode->setText("0x" + QString::number(u, 16));
keycode->setText("0x" + QString::number(k, 16));
modifiers->setText("0x" + QString::number(m, 16));
isPress->setText("0x" + QString::number(p, 16));
autoRepeat->setText("0x" + QString::number(a, 16));
}
KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name )
{
}
+KeyFilter::~KeyFilter() {
+ /* we need to remove the KeyFilter */
+ Opie::Core::OKeyFilter::inst()->remHandler( this );
+}
+
bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress,
bool autoRepeat) {
qDebug( "unicode: %d, keycode: %d, modifiers: %0x, isPress: %d, autoRepeat: %d",
- unicode, keycode, modifiers, isPress );
+ unicode, keycode, modifiers, isPress, autoRepeat );
emit keyPressed(unicode, keycode, modifiers, isPress, autoRepeat);
return 0; // return 1 to stop key emiting
}
diff --git a/development/keyview/keyview.h b/development/keyview/keyview.h
index 5f1e943..87c0d15 100644
--- a/development/keyview/keyview.h
+++ b/development/keyview/keyview.h
@@ -1,43 +1,43 @@
#ifndef KEYVIEW_H
#define KEYVIEW_H
#include <qgrid.h>
#include <qlineedit.h>
#include <qwindowsystem_qws.h>
class Keyview : public QGrid
{
Q_OBJECT
public:
Keyview( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~Keyview();
private slots:
void updateItems(int, int, int, bool, bool);
private:
QLineEdit *unicode;
QLineEdit *keycode;
QLineEdit *modifiers;
QLineEdit *isPress;
QLineEdit *autoRepeat;
-
};
class KeyFilter : public QObject, public QWSServer::KeyboardFilter
{
Q_OBJECT
public:
KeyFilter( QObject* parent, const char* name = 0);
+ virtual ~KeyFilter();
virtual bool filter(int unicode, int keycode, int modifiers, bool isPress,
bool autoRepeat);
signals:
void keyPressed(int, int, int, bool, bool);
};
#endif