-rw-r--r-- | core/launcher/desktop.cpp | 132 |
1 files changed, 94 insertions, 38 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 | |||
@@ -49,2 +49,4 @@ | |||
49 | 49 | ||
50 | #include <qvaluelist.h> | ||
51 | |||
50 | #include <stdlib.h> | 52 | #include <stdlib.h> |
@@ -52,2 +54,22 @@ | |||
52 | 54 | ||
55 | |||
56 | class QCopKeyRegister | ||
57 | { | ||
58 | public: | ||
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 | |||
67 | private: | ||
68 | int keyCode; | ||
69 | QString channel, message; | ||
70 | }; | ||
71 | |||
72 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | ||
73 | KeyRegisterList keyRegisterList; | ||
74 | |||
53 | static Desktop* qpedesktop = 0; | 75 | static Desktop* qpedesktop = 0; |
@@ -125,2 +147,6 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) | |||
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 | } |
@@ -134,2 +160,18 @@ DesktopApplication::~DesktopApplication() | |||
134 | 160 | ||
161 | void 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 | ||
@@ -143,10 +185,18 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
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; |
148 | if ( !keyboardGrabbed() ) { | 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 | |||
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 | } |
@@ -156,3 +206,3 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
156 | delete cardSendTimer; | 206 | delete cardSendTimer; |
157 | } else if ( press ) { | 207 | } else if ( press ) { |
158 | cardSendTimer = new QTimer(); | 208 | cardSendTimer = new QTimer(); |
@@ -160,48 +210,54 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
160 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 210 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
161 | } | 211 | } |
162 | return TRUE; | 212 | return TRUE; |
163 | } | 213 | } |
164 | /* menu key now opens application menu/toolbar | 214 | /* menu key now opens application menu/toolbar |
165 | if ( ke->simpleData.keycode == Key_F11 ) { | 215 | if ( ke->simpleData.keycode == Key_F11 ) { |
166 | if ( press ) emit menu(); | 216 | if ( press ) emit menu(); |
167 | return TRUE; | 217 | return TRUE; |
168 | } | 218 | } |
169 | */ | 219 | */ |
170 | if ( ke->simpleData.keycode == Key_F12 ) { | 220 | if ( ke->simpleData.keycode == Key_F12 ) { |
171 | while( activePopupWidget() ) | 221 | while( activePopupWidget() ) |
172 | activePopupWidget()->close(); | 222 | activePopupWidget()->close(); |
173 | if ( press ) emit launch(); | 223 | if ( press ) emit launch(); |
174 | return TRUE; | 224 | return TRUE; |
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 | } |
181 | if ( ke->simpleData.keycode == Key_F34 ) { | 231 | /* |
232 | if ( ke->simpleData.keycode == 4096 ) { | ||
233 | QCopEnvelope e("QPE/VMemo", "toggleRecord()"); | ||
234 | return TRUE; | ||
235 | } | ||
236 | */ | ||
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(); |
187 | return TRUE; | 243 | return TRUE; |
188 | } | 244 | } |
189 | if ( ke->simpleData.keycode == Key_F32 ) { | 245 | if ( ke->simpleData.keycode == Key_F32 ) { |
190 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 246 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
191 | return TRUE; | 247 | return TRUE; |
192 | } | 248 | } |
193 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 249 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
194 | if ( press ) emit symbol(); | 250 | if ( press ) emit symbol(); |
195 | return TRUE; | 251 | return TRUE; |
196 | } | 252 | } |
197 | if ( ke->simpleData.keycode == Key_NumLock ) { | 253 | if ( ke->simpleData.keycode == Key_NumLock ) { |
198 | if ( press ) emit numLockStateToggle(); | 254 | if ( press ) emit numLockStateToggle(); |
199 | } | 255 | } |
200 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 256 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
201 | if ( press ) emit capsLockStateToggle(); | 257 | if ( press ) emit capsLockStateToggle(); |
202 | } | 258 | } |
203 | if ( press ) | 259 | if ( press ) |
204 | qpedesktop->keyClick(); | 260 | qpedesktop->keyClick(); |
205 | } else { | 261 | } else { |
206 | if ( e->type == QWSEvent::Mouse ) { | 262 | if ( e->type == QWSEvent::Mouse ) { |
207 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 263 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
@@ -209,12 +265,12 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
209 | if ( me->simpleData.state&LeftButton ) { | 265 | if ( me->simpleData.state&LeftButton ) { |
210 | if ( up ) { | 266 | if ( up ) { |
211 | up = FALSE; | 267 | up = FALSE; |
212 | qpedesktop->screenClick(); | 268 | qpedesktop->screenClick(); |
213 | } | 269 | } |
214 | } else { | 270 | } else { |
215 | up = TRUE; | 271 | up = TRUE; |
216 | } | 272 | } |
217 | } | 273 | } |
218 | } | 274 | } |
219 | 275 | ||
220 | return QPEApplication::qwsEventFilter( e ); | 276 | return QPEApplication::qwsEventFilter( e ); |