summaryrefslogtreecommitdiff
authorjeremy <jeremy>2002-02-15 21:12:53 (UTC)
committer jeremy <jeremy>2002-02-15 21:12:53 (UTC)
commitb0768575b7bc1e4fe477d37a49cccc7e3d92bf85 (patch) (unidiff)
tree4c66c26f74ec710204f3f2e4303a6d6d8968c6a7
parentb15950bcf97b5590d37373ec2beedab80e40ded6 (diff)
downloadopie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.zip
opie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.tar.gz
opie-b0768575b7bc1e4fe477d37a49cccc7e3d92bf85.tar.bz2
Added new QCop support. Desktop now listens on channel QPE/Desktop to the
keyRegister(int key, QString channel, QString message) message. What this will do is allow an app to reiceve keyboard input for a particular key no matter if they have focus or not.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/desktop.cpp56
-rw-r--r--core/launcher/desktop.h4
-rw-r--r--core/launcher/opie-taskbar.control2
3 files changed, 61 insertions, 1 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index d39af25..ce99bad 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -44,15 +44,37 @@
44#include <qgfx_qws.h> 44#include <qgfx_qws.h>
45#include <qmainwindow.h> 45#include <qmainwindow.h>
46#include <qmessagebox.h> 46#include <qmessagebox.h>
47#include <qtimer.h> 47#include <qtimer.h>
48#include <qwindowsystem_qws.h> 48#include <qwindowsystem_qws.h>
49 49
50#include <qvaluelist.h>
51
50#include <stdlib.h> 52#include <stdlib.h>
51#include <unistd.h> 53#include <unistd.h>
52 54
55
56class QCopKeyRegister
57{
58public:
59 QCopKeyRegister() : keyCode(0) { }
60 QCopKeyRegister(int k, const QString &c, const QString &m)
61 : keyCode(k), channel(c), message(m) { }
62
63 int getKeyCode() const { return keyCode; }
64 QString getChannel() const { return channel; }
65 QString getMessage() const { return message; }
66
67private:
68 int keyCode;
69 QString channel, message;
70};
71
72typedef QValueList<QCopKeyRegister> KeyRegisterList;
73KeyRegisterList keyRegisterList;
74
53static Desktop* qpedesktop = 0; 75static Desktop* qpedesktop = 0;
54static int loggedin=0; 76static int loggedin=0;
55static void login(bool at_poweron) 77static void login(bool at_poweron)
56{ 78{
57 if ( !loggedin ) { 79 if ( !loggedin ) {
58 Global::terminateBuiltin("calibrate"); 80 Global::terminateBuiltin("calibrate");
@@ -120,21 +142,41 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type t )
120 142
121 QTimer *t = new QTimer( this ); 143 QTimer *t = new QTimer( this );
122 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 144 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
123 t->start( 10000 ); 145 t->start( 10000 );
124 ps = new PowerStatus; 146 ps = new PowerStatus;
125 pa = new DesktopPowerAlerter( 0 ); 147 pa = new DesktopPowerAlerter( 0 );
148
149 channel = new QCopChannel( "QPE/Desktop", this );
150 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
151 this, SLOT(receive(const QCString&, const QByteArray&)) );
126} 152}
127 153
128 154
129DesktopApplication::~DesktopApplication() 155DesktopApplication::~DesktopApplication()
130{ 156{
131 delete ps; 157 delete ps;
132 delete pa; 158 delete pa;
133} 159}
134 160
161void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
162{
163 QDataStream stream( data, IO_ReadOnly );
164 if (msg == "keyRegister(int key, QString channel, QString message)")
165 {
166 int k;
167 QString c, m;
168
169 stream >> k;
170 stream >> c;
171 stream >> m;
172
173 qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m);
174 keyRegisterList.append(QCopKeyRegister(k,c,m));
175 }
176}
135 177
136enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 178enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
137 179
138#ifdef Q_WS_QWS 180#ifdef Q_WS_QWS
139bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 181bool DesktopApplication::qwsEventFilter( QWSEvent *e )
140{ 182{
@@ -142,12 +184,20 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
142 184
143 if ( e->type == QWSEvent::Key ) { 185 if ( e->type == QWSEvent::Key ) {
144 QWSKeyEvent *ke = (QWSKeyEvent *)e; 186 QWSKeyEvent *ke = (QWSKeyEvent *)e;
145 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 187 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
146 return TRUE; 188 return TRUE;
147 bool press = ke->simpleData.is_press; 189 bool press = ke->simpleData.is_press;
190
191 KeyRegisterList::Iterator it;
192 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
193 {
194 if ((*it).getKeyCode() == ke->simpleData.keycode)
195 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
196 }
197
148 if ( !keyboardGrabbed() ) { 198 if ( !keyboardGrabbed() ) {
149 if ( ke->simpleData.keycode == Key_F9 ) { 199 if ( ke->simpleData.keycode == Key_F9 ) {
150 if ( press ) emit datebook(); 200 if ( press ) emit datebook();
151 return TRUE; 201 return TRUE;
152 } 202 }
153 if ( ke->simpleData.keycode == Key_F10 ) { 203 if ( ke->simpleData.keycode == Key_F10 ) {
@@ -175,12 +225,18 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
175 } 225 }
176 if ( ke->simpleData.keycode == Key_F13 ) { 226 if ( ke->simpleData.keycode == Key_F13 ) {
177 if ( press ) emit email(); 227 if ( press ) emit email();
178 return TRUE; 228 return TRUE;
179 } 229 }
180 } 230 }
231 /*
232 if ( ke->simpleData.keycode == 4096 ) {
233 QCopEnvelope e("QPE/VMemo", "toggleRecord()");
234 return TRUE;
235 }
236 */
181 if ( ke->simpleData.keycode == Key_F34 ) { 237 if ( ke->simpleData.keycode == Key_F34 ) {
182 if ( press ) emit power(); 238 if ( press ) emit power();
183 return TRUE; 239 return TRUE;
184 } 240 }
185 if ( ke->simpleData.keycode == Key_F35 ) { 241 if ( ke->simpleData.keycode == Key_F35 ) {
186 if ( press ) emit backlight(); 242 if ( press ) emit backlight();
diff --git a/core/launcher/desktop.h b/core/launcher/desktop.h
index dfdbeab..f0a7cba 100644
--- a/core/launcher/desktop.h
+++ b/core/launcher/desktop.h
@@ -60,20 +60,24 @@ protected:
60#ifdef Q_WS_QWS 60#ifdef Q_WS_QWS
61 bool qwsEventFilter( QWSEvent * ); 61 bool qwsEventFilter( QWSEvent * );
62#endif 62#endif
63 void shutdown(); 63 void shutdown();
64 void restart(); 64 void restart();
65 65
66public slots:
67 void receive( const QCString &msg, const QByteArray &data );
68
66protected slots: 69protected slots:
67 void shutdown(ShutdownImpl::Type); 70 void shutdown(ShutdownImpl::Type);
68 void psTimeout(); 71 void psTimeout();
69 void sendCard(); 72 void sendCard();
70private: 73private:
71 DesktopPowerAlerter *pa; 74 DesktopPowerAlerter *pa;
72 PowerStatus *ps; 75 PowerStatus *ps;
73 QTimer *cardSendTimer; 76 QTimer *cardSendTimer;
77 QCopChannel *channel;
74}; 78};
75 79
76 80
77class Desktop : public QWidget { 81class Desktop : public QWidget {
78 Q_OBJECT 82 Q_OBJECT
79public: 83public:
diff --git a/core/launcher/opie-taskbar.control b/core/launcher/opie-taskbar.control
index 53daa82..3db0480 100644
--- a/core/launcher/opie-taskbar.control
+++ b/core/launcher/opie-taskbar.control
@@ -1,9 +1,9 @@
1Files: bin/qpe apps/Settings/Calibrate.desktop 1Files: bin/qpe apps/Settings/Calibrate.desktop
2Priority: required 2Priority: required
3Section: opie/system 3Section: opie/system
4Maintainer: Warwick Allison <warwick@trolltech.com> 4Maintainer: Warwick Allison <warwick@trolltech.com>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION.1
7Depends: qt-embedded (>=$QTE_VERSION) 7Depends: qt-embedded (>=$QTE_VERSION)
8Description: Launcher for Opie 8Description: Launcher for Opie
9 The "finder" or "explorer", or whatever you want to call it. 9 The "finder" or "explorer", or whatever you want to call it.