-rw-r--r-- | development/keyview/keyboardimpl.cpp | 4 | ||||
-rw-r--r-- | development/keyview/keyview.cpp | 7 | ||||
-rw-r--r-- | development/keyview/keyview.h | 2 |
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 | |||
@@ -135,55 +135,59 @@ KeyboardImpl::~KeyboardImpl() | |||
135 | } | 135 | } |
136 | 136 | ||
137 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) | 137 | QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) |
138 | { | 138 | { |
139 | if ( !input ) | 139 | if ( !input ) |
140 | input = new Keyview( parent, "Keyview", f ); | 140 | input = new Keyview( parent, "Keyview", f ); |
141 | return input; | 141 | return input; |
142 | } | 142 | } |
143 | 143 | ||
144 | void KeyboardImpl::resetState() | 144 | void KeyboardImpl::resetState() |
145 | { | 145 | { |
146 | /* | 146 | /* |
147 | if ( input ) | 147 | if ( input ) |
148 | input->resetState(); | 148 | input->resetState(); |
149 | */ | 149 | */ |
150 | } | 150 | } |
151 | 151 | ||
152 | QPixmap *KeyboardImpl::icon() | 152 | QPixmap *KeyboardImpl::icon() |
153 | { | 153 | { |
154 | if ( !icn ) | 154 | if ( !icn ) |
155 | icn = new QPixmap( (const char **)kb_xpm ); | 155 | icn = new QPixmap( (const char **)kb_xpm ); |
156 | return icn; | 156 | return icn; |
157 | } | 157 | } |
158 | 158 | ||
159 | QString KeyboardImpl::name() | 159 | QString KeyboardImpl::name() |
160 | { | 160 | { |
161 | // return qApp->translate( "InputMethods", "Keyboard" ); | 161 | // return qApp->translate( "InputMethods", "Keyboard" ); |
162 | return "Keyview"; | 162 | return "Keyview"; |
163 | } | 163 | } |
164 | 164 | ||
165 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) | 165 | void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) |
166 | { | 166 | { |
167 | Q_UNUSED( receiver ); | ||
168 | Q_CONST_UNUSED( slot ); | ||
167 | //if ( input ) | 169 | //if ( input ) |
168 | //QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); | 170 | //QObject::connect( input, SIGNAL(key(ushort,ushort,ushort,bool,bool)), receiver, slot ); |
169 | } | 171 | } |
170 | 172 | ||
171 | #ifndef QT_NO_COMPONENT | 173 | #ifndef QT_NO_COMPONENT |
172 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) | 174 | QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) |
173 | { | 175 | { |
174 | *iface = 0; | 176 | *iface = 0; |
175 | if ( uuid == IID_QUnknown ) | 177 | if ( uuid == IID_QUnknown ) |
176 | *iface = this; | 178 | *iface = this; |
177 | else if ( uuid == IID_InputMethod ) | 179 | else if ( uuid == IID_InputMethod ) |
178 | *iface = this; | 180 | *iface = this; |
181 | else | ||
182 | return QS_FALSE; | ||
179 | 183 | ||
180 | if ( *iface ) | 184 | if ( *iface ) |
181 | (*iface)->addRef(); | 185 | (*iface)->addRef(); |
182 | return QS_OK; | 186 | return QS_OK; |
183 | } | 187 | } |
184 | 188 | ||
185 | Q_EXPORT_INTERFACE() | 189 | Q_EXPORT_INTERFACE() |
186 | { | 190 | { |
187 | Q_CREATE_INSTANCE( KeyboardImpl ) | 191 | Q_CREATE_INSTANCE( KeyboardImpl ) |
188 | } | 192 | } |
189 | #endif | 193 | #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 | |||
@@ -36,41 +36,46 @@ Keyview::Keyview( QWidget* parent, const char* name, WFlags fl ) | |||
36 | autoRepeat->setReadOnly(1); | 36 | autoRepeat->setReadOnly(1); |
37 | 37 | ||
38 | // spacer | 38 | // spacer |
39 | l = new QLabel(QString(""), this); | 39 | l = new QLabel(QString(""), this); |
40 | l->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); | 40 | l->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); |
41 | 41 | ||
42 | 42 | ||
43 | KeyFilter *filter = new KeyFilter(this); | 43 | KeyFilter *filter = new KeyFilter(this); |
44 | Opie::Core::OKeyFilter::inst()->addHandler(filter); | 44 | Opie::Core::OKeyFilter::inst()->addHandler(filter); |
45 | odebug << "Creating keyview filter " << oendl; | 45 | odebug << "Creating keyview filter " << oendl; |
46 | 46 | ||
47 | connect(filter, SIGNAL(keyPressed(int,int,int,bool,bool)), | 47 | connect(filter, SIGNAL(keyPressed(int,int,int,bool,bool)), |
48 | this, SLOT(updateItems(int,int,int,bool,bool))); | 48 | this, SLOT(updateItems(int,int,int,bool,bool))); |
49 | } | 49 | } |
50 | 50 | ||
51 | Keyview::~Keyview() | 51 | Keyview::~Keyview() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | ||
55 | void Keyview::updateItems(int u, int k, int m, bool p, bool a) { | 55 | void Keyview::updateItems(int u, int k, int m, bool p, bool a) { |
56 | 56 | ||
57 | unicode->setText("0x" + QString::number(u, 16)); | 57 | unicode->setText("0x" + QString::number(u, 16)); |
58 | keycode->setText("0x" + QString::number(k, 16)); | 58 | keycode->setText("0x" + QString::number(k, 16)); |
59 | modifiers->setText("0x" + QString::number(m, 16)); | 59 | modifiers->setText("0x" + QString::number(m, 16)); |
60 | isPress->setText("0x" + QString::number(p, 16)); | 60 | isPress->setText("0x" + QString::number(p, 16)); |
61 | autoRepeat->setText("0x" + QString::number(a, 16)); | 61 | autoRepeat->setText("0x" + QString::number(a, 16)); |
62 | } | 62 | } |
63 | 63 | ||
64 | KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name ) | 64 | KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name ) |
65 | { | 65 | { |
66 | } | 66 | } |
67 | 67 | ||
68 | KeyFilter::~KeyFilter() { | ||
69 | /* we need to remove the KeyFilter */ | ||
70 | Opie::Core::OKeyFilter::inst()->remHandler( this ); | ||
71 | } | ||
72 | |||
68 | bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress, | 73 | bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress, |
69 | bool autoRepeat) { | 74 | bool autoRepeat) { |
70 | 75 | ||
71 | qDebug( "unicode: %d, keycode: %d, modifiers: %0x, isPress: %d, autoRepeat: %d", | 76 | qDebug( "unicode: %d, keycode: %d, modifiers: %0x, isPress: %d, autoRepeat: %d", |
72 | unicode, keycode, modifiers, isPress ); | 77 | unicode, keycode, modifiers, isPress, autoRepeat ); |
73 | emit keyPressed(unicode, keycode, modifiers, isPress, autoRepeat); | 78 | emit keyPressed(unicode, keycode, modifiers, isPress, autoRepeat); |
74 | return 0; // return 1 to stop key emiting | 79 | return 0; // return 1 to stop key emiting |
75 | 80 | ||
76 | } | 81 | } |
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 @@ | |||
1 | #ifndef KEYVIEW_H | 1 | #ifndef KEYVIEW_H |
2 | #define KEYVIEW_H | 2 | #define KEYVIEW_H |
3 | #include <qgrid.h> | 3 | #include <qgrid.h> |
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qwindowsystem_qws.h> | 5 | #include <qwindowsystem_qws.h> |
6 | 6 | ||
7 | 7 | ||
8 | class Keyview : public QGrid | 8 | class Keyview : public QGrid |
9 | { | 9 | { |
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | Keyview( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 13 | Keyview( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
14 | ~Keyview(); | 14 | ~Keyview(); |
15 | 15 | ||
16 | private slots: | 16 | private slots: |
17 | void updateItems(int, int, int, bool, bool); | 17 | void updateItems(int, int, int, bool, bool); |
18 | 18 | ||
19 | private: | 19 | private: |
20 | 20 | ||
21 | QLineEdit *unicode; | 21 | QLineEdit *unicode; |
22 | QLineEdit *keycode; | 22 | QLineEdit *keycode; |
23 | QLineEdit *modifiers; | 23 | QLineEdit *modifiers; |
24 | QLineEdit *isPress; | 24 | QLineEdit *isPress; |
25 | QLineEdit *autoRepeat; | 25 | QLineEdit *autoRepeat; |
26 | |||
27 | }; | 26 | }; |
28 | 27 | ||
29 | class KeyFilter : public QObject, public QWSServer::KeyboardFilter | 28 | class KeyFilter : public QObject, public QWSServer::KeyboardFilter |
30 | { | 29 | { |
31 | Q_OBJECT | 30 | Q_OBJECT |
32 | 31 | ||
33 | public: | 32 | public: |
34 | KeyFilter( QObject* parent, const char* name = 0); | 33 | KeyFilter( QObject* parent, const char* name = 0); |
34 | virtual ~KeyFilter(); | ||
35 | virtual bool filter(int unicode, int keycode, int modifiers, bool isPress, | 35 | virtual bool filter(int unicode, int keycode, int modifiers, bool isPress, |
36 | bool autoRepeat); | 36 | bool autoRepeat); |
37 | 37 | ||
38 | signals: | 38 | signals: |
39 | void keyPressed(int, int, int, bool, bool); | 39 | void keyPressed(int, int, int, bool, bool); |
40 | 40 | ||
41 | }; | 41 | }; |
42 | 42 | ||
43 | #endif | 43 | #endif |