summaryrefslogtreecommitdiff
path: root/development
authorzecke <zecke>2004-08-14 17:15:44 (UTC)
committer zecke <zecke>2004-08-14 17:15:44 (UTC)
commit74363a9e1d5688d65286e7fea156227b68a28002 (patch) (unidiff)
tree3926a1a3bd42bebb2f67b3334735bc3b3931f796 /development
parent7657b6986a600ec1b3626c83e8f19036bf69e493 (diff)
downloadopie-74363a9e1d5688d65286e7fea156227b68a28002.zip
opie-74363a9e1d5688d65286e7fea156227b68a28002.tar.gz
opie-74363a9e1d5688d65286e7fea156227b68a28002.tar.bz2
-Remove the KeyFilter on destruction
Alwin could we either add a 'QObject' as a owner so that we could use QGuardedPtr or look for the deleteEvent ourselves. Or let us create a KeyFilter ourselves that auto registers (maybe) but cleans up itself in any case?
Diffstat (limited to 'development') (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 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#include <qapplication.h> 20#include <qapplication.h>
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include "keyview.h" 22#include "keyview.h"
23#include "keyboardimpl.h" 23#include "keyboardimpl.h"
24 24
25/* XPM */ 25/* XPM */
26static const char * kb_xpm[] = { 26static const char * kb_xpm[] = {
27"28 13 81 1", 27"28 13 81 1",
28 " c None", 28 " c None",
29 ".c #000000", 29 ".c #000000",
30 "+c #E5E1D5", 30 "+c #E5E1D5",
31 "@c #FFFFFF", 31 "@c #FFFFFF",
32 "#c #DBDBDB", 32 "#c #DBDBDB",
33 "$c #132B07", 33 "$c #132B07",
34 "%c #426362", 34 "%c #426362",
35 "&c #558384", 35 "&c #558384",
36 "*c #6E6D67", 36 "*c #6E6D67",
37 "=c #DCD8CD", 37 "=c #DCD8CD",
38 "-c #929292", 38 "-c #929292",
39 ";c #446463", 39 ";c #446463",
40 ">c #558585", 40 ">c #558585",
41 ",c #466565", 41 ",c #466565",
42 "'c #558685", 42 "'c #558685",
43 ")c #B7B7B7", 43 ")c #B7B7B7",
44 "!c #A2A2A2", 44 "!c #A2A2A2",
45 "~c #9A9A9A", 45 "~c #9A9A9A",
46 "{c #959595", 46 "{c #959595",
47 "]c #939393", 47 "]c #939393",
48 "^c #486767", 48 "^c #486767",
49 "/c #383838", 49 "/c #383838",
50 "(c #303030", 50 "(c #303030",
51 "_c #2C2C2C", 51 "_c #2C2C2C",
52 ":c #2A2A2A", 52 ":c #2A2A2A",
53 "<c #292929", 53 "<c #292929",
54 "[c #333333", 54 "[c #333333",
55 "}c #FFFFE9", 55 "}c #FFFFE9",
56 "|c #FEFFDD", 56 "|c #FEFFDD",
57 "1c #E4E5AD", 57 "1c #E4E5AD",
58 "2c #202020", 58 "2c #202020",
59 "3c #466665", 59 "3c #466665",
60 "4c #2F2F2F", 60 "4c #2F2F2F",
61 "5c #FEFFC1", 61 "5c #FEFFC1",
62 "6c #575742", 62 "6c #575742",
63 "7c #191919", 63 "7c #191919",
64 "8c #2D2D2D", 64 "8c #2D2D2D",
65 "9c #29291F", 65 "9c #29291F",
66 "0c #141414", 66 "0c #141414",
67 "ac #122207", 67 "ac #122207",
68 "bc #548584", 68 "bc #548584",
69 "cc #111111", 69 "cc #111111",
70 "dc #131313", 70 "dc #131313",
71 "ec #1B2514", 71 "ec #1B2514",
72 "fc #112106", 72 "fc #112106",
73 "gc #416160", 73 "gc #416160",
74 "hc #538484", 74 "hc #538484",
75 "ic #2B2B2B", 75 "ic #2B2B2B",
76 "jc #0F0F0F", 76 "jc #0F0F0F",
77 "kc #14190F", 77 "kc #14190F",
78 "lc #192312", 78 "lc #192312",
79 "mc #0F1F06", 79 "mc #0F1F06",
80 "nc #40605F", 80 "nc #40605F",
81 "oc #518483", 81 "oc #518483",
82 "pc #9D9D9D", 82 "pc #9D9D9D",
83 "qc #747474", 83 "qc #747474",
84 "rc #2B2C2B", 84 "rc #2B2C2B",
85 "sc #060704", 85 "sc #060704",
86 "tc #0B0E09", 86 "tc #0B0E09",
87 "uc #12180D", 87 "uc #12180D",
88 "vc #17210F", 88 "vc #17210F",
89 "wc #0E1E04", 89 "wc #0E1E04",
90 "xc #3D5E5D", 90 "xc #3D5E5D",
91 "yc #508382", 91 "yc #508382",
92 "zc #898989", 92 "zc #898989",
93 "Ac #9C9C9C", 93 "Ac #9C9C9C",
94 "Bc #050704", 94 "Bc #050704",
95 "Cc #0A0D08", 95 "Cc #0A0D08",
96 "Dc #10170B", 96 "Dc #10170B",
97 "Ec #141E0C", 97 "Ec #141E0C",
98 "Fc #0C1B04", 98 "Fc #0C1B04",
99 "Gc #395C5A", 99 "Gc #395C5A",
100 "Hc #4F8181", 100 "Hc #4F8181",
101 "Ic #242424", 101 "Ic #242424",
102 "Jc #050604", 102 "Jc #050604",
103 "Kc #090C06", 103 "Kc #090C06",
104 "Lc #0E1509", 104 "Lc #0E1509",
105 "Mc #121C0A", 105 "Mc #121C0A",
106 "Nc #0B1A03", 106 "Nc #0B1A03",
107 "Oc #375A58", 107 "Oc #375A58",
108 "Pc #4D807F", 108 "Pc #4D807F",
109"...........+..@.@@@@@@@#.$%&", 109"...........+..@.@@@@@@@#.$%&",
110"..........*=.@.@.@@@@@##.-;>", 110"..........*=.@.@.@@@@@##.-;>",
111"..............@.@.@@@###.-,'", 111"..............@.@.@@@###.-,'",
112")!~{{]]]{]]].@.@.@@#.##-.-^'", 112")!~{{]]]{]]].@.@.@@#.##-.-^'",
113"/(_::<<<:<<<..@.@@#..#--.-^'", 113"/(_::<<<:<<<..@.@@#..#--.-^'",
114"[}|12}|12}|12.#.@#.-.---.-3'", 114"[}|12}|12}|12.#.@#.-.---.-3'",
115"4|567|567|567..@@...---.--,'", 115"4|567|567|567..@@...---.--,'",
116"81690169016901.@#.----.--a;b", 116"81690169016901.@#.----.--a;b",
117"82700ccc0cccd.@@......--efgh", 117"82700ccc0cccd.@@......--efgh",
118"i}|1c}|1c}|1j.@#.------klmno", 118"i}|1c}|1c}|1j.@#.------klmno",
119"i|56c|56c|56.@#.--pqrstuvwxy", 119"i|56c|56c|56.@#.--pqrstuvwxy",
120"i169c169c16.@#.--zAqrBCDEFGH", 120"i169c169c16.@#.--zAqrBCDEFGH",
121"82700ccc0cj...--IzAqrJKLMNOP"}; 121"82700ccc0cj...--IzAqrJKLMNOP"};
122 122
123 123
124 124
125 125
126KeyboardImpl::KeyboardImpl() 126KeyboardImpl::KeyboardImpl()
127 : input(0), icn(0), ref(0) 127 : input(0), icn(0), ref(0)
128{ 128{
129} 129}
130 130
131KeyboardImpl::~KeyboardImpl() 131KeyboardImpl::~KeyboardImpl()
132{ 132{
133 delete input; 133 delete input;
134 delete icn; 134 delete icn;
135} 135}
136 136
137QWidget *KeyboardImpl::inputMethod( QWidget *parent, Qt::WFlags f ) 137QWidget *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
144void KeyboardImpl::resetState() 144void KeyboardImpl::resetState()
145{ 145{
146 /* 146 /*
147 if ( input ) 147 if ( input )
148 input->resetState(); 148 input->resetState();
149 */ 149 */
150} 150}
151 151
152QPixmap *KeyboardImpl::icon() 152QPixmap *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
159QString KeyboardImpl::name() 159QString 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
165void KeyboardImpl::onKeyPress( QObject *receiver, const char *slot ) 165void 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
172QRESULT KeyboardImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface ) 174QRESULT 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
185Q_EXPORT_INTERFACE() 189Q_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
@@ -1,76 +1,81 @@
1#include "keyview.h" 1#include "keyview.h"
2#include <qgrid.h> 2#include <qgrid.h>
3//#include <iostream.h> 3//#include <iostream.h>
4#include <qlineedit.h> 4#include <qlineedit.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <opie2/okeyfilter.h> 6#include <opie2/okeyfilter.h>
7#include <opie2/odebug.h> 7#include <opie2/odebug.h>
8 8
9Keyview::Keyview( QWidget* parent, const char* name, WFlags fl ) 9Keyview::Keyview( QWidget* parent, const char* name, WFlags fl )
10 : QGrid ( 2, parent, name, fl ) 10 : QGrid ( 2, parent, name, fl )
11{ 11{
12 setCaption( tr("Keyview") ); 12 setCaption( tr("Keyview") );
13 setSpacing(3); 13 setSpacing(3);
14 setMargin(4); 14 setMargin(4);
15 15
16 QLabel *l; 16 QLabel *l;
17 17
18 l = new QLabel(QString("unicode:"), this); 18 l = new QLabel(QString("unicode:"), this);
19 unicode = new QLineEdit(this); 19 unicode = new QLineEdit(this);
20 unicode->setReadOnly(1); 20 unicode->setReadOnly(1);
21 21
22 l = new QLabel(QString("keycode:"), this); 22 l = new QLabel(QString("keycode:"), this);
23 keycode = new QLineEdit(this); 23 keycode = new QLineEdit(this);
24 keycode->setReadOnly(1); 24 keycode->setReadOnly(1);
25 25
26 l = new QLabel(QString("modifiers:"), this); 26 l = new QLabel(QString("modifiers:"), this);
27 modifiers = new QLineEdit(this); 27 modifiers = new QLineEdit(this);
28 modifiers->setReadOnly(1); 28 modifiers->setReadOnly(1);
29 29
30 l = new QLabel(QString("isPress:"), this); 30 l = new QLabel(QString("isPress:"), this);
31 isPress = new QLineEdit(this); 31 isPress = new QLineEdit(this);
32 isPress->setReadOnly(1); 32 isPress->setReadOnly(1);
33 33
34 l = new QLabel(QString("autoRepeat:"), this); 34 l = new QLabel(QString("autoRepeat:"), this);
35 autoRepeat = new QLineEdit(this); 35 autoRepeat = new QLineEdit(this);
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
51Keyview::~Keyview() 51Keyview::~Keyview()
52{ 52{
53} 53}
54 54
55void Keyview::updateItems(int u, int k, int m, bool p, bool a) { 55void 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
64KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name ) 64KeyFilter::KeyFilter(QObject * parent, const char *name) : QObject( parent, name )
65{ 65{
66} 66}
67 67
68KeyFilter::~KeyFilter() {
69 /* we need to remove the KeyFilter */
70 Opie::Core::OKeyFilter::inst()->remHandler( this );
71}
72
68bool KeyFilter::filter(int unicode, int keycode, int modifiers, bool isPress, 73bool 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
8class Keyview : public QGrid 8class Keyview : public QGrid
9{ 9{
10 Q_OBJECT 10 Q_OBJECT
11 11
12public: 12public:
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
16private slots: 16private slots:
17 void updateItems(int, int, int, bool, bool); 17 void updateItems(int, int, int, bool, bool);
18 18
19private: 19private:
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
29class KeyFilter : public QObject, public QWSServer::KeyboardFilter 28class KeyFilter : public QObject, public QWSServer::KeyboardFilter
30{ 29{
31 Q_OBJECT 30 Q_OBJECT
32 31
33public: 32public:
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
38signals: 38signals:
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