summaryrefslogtreecommitdiff
authorharlekin <harlekin>2002-08-29 18:11:07 (UTC)
committer harlekin <harlekin>2002-08-29 18:11:07 (UTC)
commite268d442ac16f94b8575c1f32e0e1962ce8b926f (patch) (unidiff)
tree0e518120be6910893b1f24c2caa7bfa664bca922
parent6707dd2b7abf2fac4aef4025cf8e554577d0891c (diff)
downloadopie-e268d442ac16f94b8575c1f32e0e1962ce8b926f.zip
opie-e268d442ac16f94b8575c1f32e0e1962ce8b926f.tar.gz
opie-e268d442ac16f94b8575c1f32e0e1962ce8b926f.tar.bz2
launch for ipaq 38xx mail on button F11 instead of showing the menu
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp58
1 files changed, 32 insertions, 26 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 5aba8dd..8756d37 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,806 +1,812 @@
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 20
21#include "desktop.h" 21#include "desktop.h"
22#include "info.h" 22#include "info.h"
23#include "launcher.h" 23#include "launcher.h"
24#include "mrulist.h" 24#include "mrulist.h"
25#include "qcopbridge.h" 25#include "qcopbridge.h"
26#include "shutdownimpl.h" 26#include "shutdownimpl.h"
27#include "startmenu.h" 27#include "startmenu.h"
28#include "taskbar.h" 28#include "taskbar.h"
29#include "transferserver.h" 29#include "transferserver.h"
30#include "irserver.h" 30#include "irserver.h"
31#include "packageslave.h" 31#include "packageslave.h"
32 32
33#include <qpe/applnk.h> 33#include <qpe/applnk.h>
34#include <qpe/mimetype.h> 34#include <qpe/mimetype.h>
35#include <qpe/password.h> 35#include <qpe/password.h>
36#include <qpe/config.h> 36#include <qpe/config.h>
37#include <qpe/power.h> 37#include <qpe/power.h>
38#include <qpe/timeconversion.h> 38#include <qpe/timeconversion.h>
39#include <qpe/qcopenvelope_qws.h> 39#include <qpe/qcopenvelope_qws.h>
40#include <qpe/global.h> 40#include <qpe/global.h>
41 41
42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 42#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
43#include <qpe/custom.h> 43#include <qpe/custom.h>
44#endif 44#endif
45 45
46#include <opie/odevice.h> 46#include <opie/odevice.h>
47 47
48#include <qgfx_qws.h> 48#include <qgfx_qws.h>
49#include <qmainwindow.h> 49#include <qmainwindow.h>
50#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qtimer.h> 51#include <qtimer.h>
52#include <qwindowsystem_qws.h> 52#include <qwindowsystem_qws.h>
53 53
54#include <qvaluelist.h> 54#include <qvaluelist.h>
55 55
56#include <stdlib.h> 56#include <stdlib.h>
57#include <unistd.h> 57#include <unistd.h>
58 58
59class QCopKeyRegister 59class QCopKeyRegister
60{ 60{
61public: 61public:
62 QCopKeyRegister() : keyCode(0) { } 62 QCopKeyRegister() : keyCode(0) { }
63 QCopKeyRegister(int k, const QString &c, const QString &m) 63 QCopKeyRegister(int k, const QString &c, const QString &m)
64 : keyCode(k), channel(c), message(m) { } 64 : keyCode(k), channel(c), message(m) { }
65 65
66 int getKeyCode() const { return keyCode; } 66 int getKeyCode() const { return keyCode; }
67 QString getChannel() const { return channel; } 67 QString getChannel() const { return channel; }
68 QString getMessage() const { return message; } 68 QString getMessage() const { return message; }
69 69
70private: 70private:
71 int keyCode; 71 int keyCode;
72 QString channel, message; 72 QString channel, message;
73}; 73};
74 74
75typedef QValueList<QCopKeyRegister> KeyRegisterList; 75typedef QValueList<QCopKeyRegister> KeyRegisterList;
76KeyRegisterList keyRegisterList; 76KeyRegisterList keyRegisterList;
77 77
78static Desktop* qpedesktop = 0; 78static Desktop* qpedesktop = 0;
79static int loggedin=0; 79static int loggedin=0;
80static void login(bool at_poweron) 80static void login(bool at_poweron)
81{ 81{
82 if ( !loggedin ) { 82 if ( !loggedin ) {
83 Global::terminateBuiltin("calibrate"); 83 Global::terminateBuiltin("calibrate");
84 Password::authenticate(at_poweron); 84 Password::authenticate(at_poweron);
85 loggedin=1; 85 loggedin=1;
86 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 86 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
87 } 87 }
88} 88}
89 89
90bool Desktop::screenLocked() 90bool Desktop::screenLocked()
91{ 91{
92 return loggedin == 0; 92 return loggedin == 0;
93} 93}
94 94
95/* 95/*
96 Priority is number of alerts that are needed to pop up 96 Priority is number of alerts that are needed to pop up
97 alert. 97 alert.
98 */ 98 */
99class DesktopPowerAlerter : public QMessageBox 99class DesktopPowerAlerter : public QMessageBox
100{ 100{
101public: 101public:
102 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 102 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
103 : QMessageBox( tr("Battery Status"), "Low Battery", 103 : QMessageBox( tr("Battery Status"), "Low Battery",
104 QMessageBox::Critical, 104 QMessageBox::Critical,
105 QMessageBox::Ok | QMessageBox::Default, 105 QMessageBox::Ok | QMessageBox::Default,
106 QMessageBox::NoButton, QMessageBox::NoButton, 106 QMessageBox::NoButton, QMessageBox::NoButton,
107 parent, name, FALSE ) 107 parent, name, FALSE )
108 { 108 {
109 currentPriority = INT_MAX; 109 currentPriority = INT_MAX;
110 alertCount = 0; 110 alertCount = 0;
111 } 111 }
112 112
113 void alert( const QString &text, int priority ); 113 void alert( const QString &text, int priority );
114 void hideEvent( QHideEvent * ); 114 void hideEvent( QHideEvent * );
115private: 115private:
116 int currentPriority; 116 int currentPriority;
117 int alertCount; 117 int alertCount;
118}; 118};
119 119
120void DesktopPowerAlerter::alert( const QString &text, int priority ) 120void DesktopPowerAlerter::alert( const QString &text, int priority )
121{ 121{
122 alertCount++; 122 alertCount++;
123 if ( alertCount < priority ) 123 if ( alertCount < priority )
124 return; 124 return;
125 if ( priority > currentPriority ) 125 if ( priority > currentPriority )
126 return; 126 return;
127 currentPriority = priority; 127 currentPriority = priority;
128 setText( text ); 128 setText( text );
129 show(); 129 show();
130} 130}
131 131
132 132
133void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 133void DesktopPowerAlerter::hideEvent( QHideEvent *e )
134{ 134{
135 QMessageBox::hideEvent( e ); 135 QMessageBox::hideEvent( e );
136 alertCount = 0; 136 alertCount = 0;
137 currentPriority = INT_MAX; 137 currentPriority = INT_MAX;
138} 138}
139 139
140 140
141 141
142DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) 142DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
143 : QPEApplication( argc, argv, appType ) 143 : QPEApplication( argc, argv, appType )
144{ 144{
145 145
146 QTimer *t = new QTimer( this ); 146 QTimer *t = new QTimer( this );
147 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 147 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
148 t->start( 10000 ); 148 t->start( 10000 );
149 ps = new PowerStatus; 149 ps = new PowerStatus;
150 pa = new DesktopPowerAlerter( 0 ); 150 pa = new DesktopPowerAlerter( 0 );
151 151
152 channel = new QCopChannel( "QPE/Desktop", this ); 152 channel = new QCopChannel( "QPE/Desktop", this );
153 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 153 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
154 this, SLOT(receive(const QCString&, const QByteArray&)) ); 154 this, SLOT(receive(const QCString&, const QByteArray&)) );
155} 155}
156 156
157 157
158DesktopApplication::~DesktopApplication() 158DesktopApplication::~DesktopApplication()
159{ 159{
160 delete ps; 160 delete ps;
161 delete pa; 161 delete pa;
162} 162}
163 163
164void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 164void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
165{ 165{
166 QDataStream stream( data, IO_ReadOnly ); 166 QDataStream stream( data, IO_ReadOnly );
167 if (msg == "keyRegister(int key, QString channel, QString message)") 167 if (msg == "keyRegister(int key, QString channel, QString message)")
168 { 168 {
169 int k; 169 int k;
170 QString c, m; 170 QString c, m;
171 stream >> k; 171 stream >> k;
172 stream >> c; 172 stream >> c;
173 stream >> m; 173 stream >> m;
174 174
175 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m ); 175 qWarning("KeyRegisterReceived: %i, %s, %s", k, (const char*)c, (const char *)m );
176 keyRegisterList.append(QCopKeyRegister(k,c,m)); 176 keyRegisterList.append(QCopKeyRegister(k,c,m));
177 } 177 }
178 else if (msg == "suspend()"){ 178 else if (msg == "suspend()"){
179 emit power(); 179 emit power();
180 } 180 }
181 181
182} 182}
183 183
184enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 184enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
185 185
186#ifdef Q_WS_QWS 186#ifdef Q_WS_QWS
187bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 187bool DesktopApplication::qwsEventFilter( QWSEvent *e )
188{ 188{
189 qpedesktop->checkMemory(); 189 qpedesktop->checkMemory();
190 190
191 if ( e->type == QWSEvent::Key ) { 191 if ( e->type == QWSEvent::Key ) {
192 QWSKeyEvent *ke = (QWSKeyEvent *)e; 192 QWSKeyEvent *ke = (QWSKeyEvent *)e;
193 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 193 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
194 return TRUE; 194 return TRUE;
195 bool press = ke->simpleData.is_press; 195 bool press = ke->simpleData.is_press;
196 bool autoRepeat= ke->simpleData.is_auto_repeat; 196 bool autoRepeat= ke->simpleData.is_auto_repeat;
197 197
198 /* 198 /*
199 app that registers key/message to be sent back to the app, when it doesn't have focus, 199 app that registers key/message to be sent back to the app, when it doesn't have focus,
200 when user presses key, unless keyboard has been requested from app. 200 when user presses key, unless keyboard has been requested from app.
201 will not send multiple repeats if user holds key 201 will not send multiple repeats if user holds key
202 i.e. one shot 202 i.e. one shot
203
204 */ 203 */
205 if (!keyRegisterList.isEmpty()) { 204 if (!keyRegisterList.isEmpty()) {
206 KeyRegisterList::Iterator it; 205 KeyRegisterList::Iterator it;
207 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { 206 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
208 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) { 207 if ((*it).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() && press) {
209 if(press) qDebug("press"); else qDebug("release"); 208 if(press) qDebug("press"); else qDebug("release");
210 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 209 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
211 } 210 }
212 } 211 }
213 } 212 }
214 213
215 if ( !keyboardGrabbed() ) { 214 if ( !keyboardGrabbed() ) {
216 if ( ke->simpleData.keycode == Key_F9 ) { 215 if ( ke->simpleData.keycode == Key_F9 ) {
217 if ( press ) emit datebook(); 216 if ( press ) emit datebook();
218 return TRUE; 217 return TRUE;
219 } 218 }
220 if ( ke->simpleData.keycode == Key_F10 ) { 219 if ( ke->simpleData.keycode == Key_F10 ) {
221 if ( !press && cardSendTimer ) { 220 if ( !press && cardSendTimer ) {
222 emit contacts(); 221 emit contacts();
223 delete cardSendTimer; 222 delete cardSendTimer;
224 } else if ( press ) { 223 } else if ( press ) {
225 cardSendTimer = new QTimer(); 224 cardSendTimer = new QTimer();
226 cardSendTimer->start( 2000, TRUE ); 225 cardSendTimer->start( 2000, TRUE );
227 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 226 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
228 } 227 }
229 return TRUE; 228 return TRUE;
230 } 229 }
231 /* menu key now opens application menu/toolbar 230 /* menu key now opens application menu/toolbar
232 if ( ke->simpleData.keycode == Key_F11 ) { 231 if ( ke->simpleData.keycode == Key_F11 ) {
233 if ( press ) emit menu(); 232 if ( press ) emit menu();
234 return TRUE; 233 return TRUE;
235 } 234 }
236 */ 235 */
237 if ( ke->simpleData.keycode == Key_F12 ) { 236 if ( ke->simpleData.keycode == Key_F12 ) {
238 while( activePopupWidget() ) 237 while( activePopupWidget() )
239 activePopupWidget()->close(); 238 activePopupWidget()->close();
240 if ( press ) emit launch(); 239 if ( press ) emit launch();
241 return TRUE; 240 return TRUE;
242 } 241 }
243 if ( ke->simpleData.keycode == Key_F13 ) { 242 if ( ke->simpleData.keycode == Key_F13 ) {
244 if ( press ) emit email(); 243 if ( press ) emit email();
245 return TRUE; 244 return TRUE;
246 } 245 }
247 } 246 }
248 247
249 if ( ke->simpleData.keycode == Key_F34 ) { 248 if ( ke->simpleData.keycode == Key_F34 ) {
250 if ( press ) emit power(); 249 if ( press ) emit power();
251 return TRUE; 250 return TRUE;
252 } 251 }
253// This was used for the iPAQ PowerButton 252// This was used for the iPAQ PowerButton
254// See main.cpp for new KeyboardFilter 253// See main.cpp for new KeyboardFilter
255// 254//
256// if ( ke->simpleData.keycode == Key_SysReq ) { 255// if ( ke->simpleData.keycode == Key_SysReq ) {
257// if ( press ) emit power(); 256// if ( press ) emit power();
258// return TRUE; 257// return TRUE;
259// } 258// }
260 if ( ke->simpleData.keycode == Key_F35 ) { 259 if ( ke->simpleData.keycode == Key_F35 ) {
261 if ( press ) emit backlight(); 260 if ( press ) emit backlight();
262 return TRUE; 261 return TRUE;
263 } 262 }
264 if ( ke->simpleData.keycode == Key_F32 ) { 263 if ( ke->simpleData.keycode == Key_F32 ) {
265 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 264 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
266 return TRUE; 265 return TRUE;
267 } 266 }
268 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 267 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
269 if ( press ) emit symbol(); 268 if ( press ) emit symbol();
270 return TRUE; 269 return TRUE;
271 } 270 }
272 if ( ke->simpleData.keycode == Key_NumLock ) { 271 if ( ke->simpleData.keycode == Key_NumLock ) {
273 if ( press ) emit numLockStateToggle(); 272 if ( press ) emit numLockStateToggle();
274 } 273 }
275 if ( ke->simpleData.keycode == Key_CapsLock ) { 274 if ( ke->simpleData.keycode == Key_CapsLock ) {
276 if ( press ) emit capsLockStateToggle(); 275 if ( press ) emit capsLockStateToggle();
277 } 276 }
278 if (( press && !autoRepeat ) || ( !press && autoRepeat )) 277 if (( press && !autoRepeat ) || ( !press && autoRepeat ))
279 qpedesktop->keyClick(); 278 qpedesktop->keyClick();
280 } else { 279 } else {
281 if ( e->type == QWSEvent::Mouse ) { 280 if ( e->type == QWSEvent::Mouse ) {
282 QWSMouseEvent *me = (QWSMouseEvent *)e; 281 QWSMouseEvent *me = (QWSMouseEvent *)e;
283 static bool up = TRUE; 282 static bool up = TRUE;
284 if ( me->simpleData.state&LeftButton ) { 283 if ( me->simpleData.state&LeftButton ) {
285 if ( up ) { 284 if ( up ) {
286 up = FALSE; 285 up = FALSE;
287 qpedesktop->screenClick(); 286 qpedesktop->screenClick();
288 } 287 }
289 } else { 288 } else {
290 up = TRUE; 289 up = TRUE;
291 } 290 }
292 } 291 }
293 } 292 }
294 293
295 return QPEApplication::qwsEventFilter( e ); 294 return QPEApplication::qwsEventFilter( e );
296} 295}
297#endif 296#endif
298 297
299void DesktopApplication::psTimeout() 298void DesktopApplication::psTimeout()
300{ 299{
301 qpedesktop->checkMemory(); // in case no events are being generated 300 qpedesktop->checkMemory(); // in case no events are being generated
302 301
303 *ps = PowerStatusManager::readStatus(); 302 *ps = PowerStatusManager::readStatus();
304 303
305 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 304 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
306 pa->alert( tr( "Battery is running very low." ), 6 ); 305 pa->alert( tr( "Battery is running very low." ), 6 );
307 } 306 }
308 307
309 if ( ps->batteryStatus() == PowerStatus::Critical ) { 308 if ( ps->batteryStatus() == PowerStatus::Critical ) {
310 pa->alert( tr( "Battery level is critical!\n" 309 pa->alert( tr( "Battery level is critical!\n"
311 "Keep power off until power restored!" ), 1 ); 310 "Keep power off until power restored!" ), 1 );
312 } 311 }
313 312
314 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 313 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
315 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 314 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
316 } 315 }
317} 316}
318 317
319 318
320void DesktopApplication::sendCard() 319void DesktopApplication::sendCard()
321{ 320{
322 delete cardSendTimer; 321 delete cardSendTimer;
323 cardSendTimer = 0; 322 cardSendTimer = 0;
324 QString card = getenv("HOME"); 323 QString card = getenv("HOME");
325 card += "/Applications/addressbook/businesscard.vcf"; 324 card += "/Applications/addressbook/businesscard.vcf";
326 325
327 if ( QFile::exists( card ) ) { 326 if ( QFile::exists( card ) ) {
328 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 327 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
329 QString mimetype = "text/x-vCard"; 328 QString mimetype = "text/x-vCard";
330 e << tr("business card") << card << mimetype; 329 e << tr("business card") << card << mimetype;
331 } 330 }
332} 331}
333 332
334#if defined(QPE_HAVE_MEMALERTER) 333#if defined(QPE_HAVE_MEMALERTER)
335QPE_MEMALERTER_IMPL 334QPE_MEMALERTER_IMPL
336#endif 335#endif
337 336
338//=========================================================================== 337//===========================================================================
339 338
340Desktop::Desktop() : 339Desktop::Desktop() :
341 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 340 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
342 qcopBridge( 0 ), 341 qcopBridge( 0 ),
343 transferServer( 0 ), 342 transferServer( 0 ),
344 packageSlave( 0 ) 343 packageSlave( 0 )
345{ 344{
346 qpedesktop = this; 345 qpedesktop = this;
347 346
348// bg = new Info( this ); 347// bg = new Info( this );
349 tb = new TaskBar; 348 tb = new TaskBar;
350 349
351 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 350 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
352 351
353 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 352 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
354 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 353 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
355 354
356 int displayw = qApp->desktop()->width(); 355 int displayw = qApp->desktop()->width();
357 int displayh = qApp->desktop()->height(); 356 int displayh = qApp->desktop()->height();
358 357
359 358
360 QSize sz = tb->sizeHint(); 359 QSize sz = tb->sizeHint();
361 360
362 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 361 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
363 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 362 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
364 363
365 tb->show(); 364 tb->show();
366 launcher->showMaximized(); 365 launcher->showMaximized();
367 launcher->show(); 366 launcher->show();
368 launcher->raise(); 367 launcher->raise();
369#if defined(QPE_HAVE_MEMALERTER) 368#if defined(QPE_HAVE_MEMALERTER)
370 initMemalerter(); 369 initMemalerter();
371#endif 370#endif
372 // start services 371 // start services
373 startTransferServer(); 372 startTransferServer();
374 (void) new IrServer( this ); 373 (void) new IrServer( this );
375 rereadVolumes(); 374 rereadVolumes();
376 375
377 packageSlave = new PackageSlave( this ); 376 packageSlave = new PackageSlave( this );
378 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 377 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
379 378
380 qApp->installEventFilter( this ); 379 qApp->installEventFilter( this );
381} 380}
382 381
383void Desktop::show() 382void Desktop::show()
384{ 383{
385 login(TRUE); 384 login(TRUE);
386 QWidget::show(); 385 QWidget::show();
387} 386}
388 387
389Desktop::~Desktop() 388Desktop::~Desktop()
390{ 389{
391 delete launcher; 390 delete launcher;
392 delete tb; 391 delete tb;
393 delete qcopBridge; 392 delete qcopBridge;
394 delete transferServer; 393 delete transferServer;
395} 394}
396 395
397bool Desktop::recoverMemory() 396bool Desktop::recoverMemory()
398{ 397{
399 return tb->recoverMemory(); 398 return tb->recoverMemory();
400} 399}
401 400
402void Desktop::checkMemory() 401void Desktop::checkMemory()
403{ 402{
404#if defined(QPE_HAVE_MEMALERTER) 403#if defined(QPE_HAVE_MEMALERTER)
405 static bool ignoreNormal=FALSE; 404 static bool ignoreNormal=FALSE;
406 static bool existingMessage=FALSE; 405 static bool existingMessage=FALSE;
407 406
408 if(existingMessage) 407 if(existingMessage)
409 return; // don't show a second message while still on first 408 return; // don't show a second message while still on first
410 409
411 existingMessage = TRUE; 410 existingMessage = TRUE;
412 switch ( memstate ) { 411 switch ( memstate ) {
413 case Unknown: 412 case Unknown:
414 break; 413 break;
415 case Low: 414 case Low:
416 memstate = Unknown; 415 memstate = Unknown;
417 if ( recoverMemory() ) 416 if ( recoverMemory() )
418 ignoreNormal = TRUE; 417 ignoreNormal = TRUE;
419 else 418 else
420 QMessageBox::warning( 0 , "Memory Status", 419 QMessageBox::warning( 0 , "Memory Status",
421 "The memory smacks of shortage. \n" 420 "The memory smacks of shortage. \n"
422 "Please save data. " ); 421 "Please save data. " );
423 break; 422 break;
424 case Normal: 423 case Normal:
425 memstate = Unknown; 424 memstate = Unknown;
426 if ( ignoreNormal ) 425 if ( ignoreNormal )
427 ignoreNormal = FALSE; 426 ignoreNormal = FALSE;
428 else 427 else
429 QMessageBox::information ( 0 , "Memory Status", 428 QMessageBox::information ( 0 , "Memory Status",
430 "There is enough memory again." ); 429 "There is enough memory again." );
431 break; 430 break;
432 case VeryLow: 431 case VeryLow:
433 memstate = Unknown; 432 memstate = Unknown;
434 QMessageBox::critical( 0 , "Memory Status", 433 QMessageBox::critical( 0 , "Memory Status",
435 "The memory is very low. \n" 434 "The memory is very low. \n"
436 "Please end this application \n" 435 "Please end this application \n"
437 "immediately." ); 436 "immediately." );
438 recoverMemory(); 437 recoverMemory();
439 } 438 }
440 existingMessage = FALSE; 439 existingMessage = FALSE;
441#endif 440#endif
442} 441}
443 442
444static bool isVisibleWindow(int wid) 443static bool isVisibleWindow(int wid)
445{ 444{
446 const QList<QWSWindow> &list = qwsServer->clientWindows(); 445 const QList<QWSWindow> &list = qwsServer->clientWindows();
447 QWSWindow* w; 446 QWSWindow* w;
448 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 447 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
449 if ( w->winId() == wid ) 448 if ( w->winId() == wid )
450 return !w->isFullyObscured(); 449 return !w->isFullyObscured();
451 } 450 }
452 return FALSE; 451 return FALSE;
453} 452}
454 453
455static bool hasVisibleWindow(const QString& clientname) 454static bool hasVisibleWindow(const QString& clientname)
456{ 455{
457 const QList<QWSWindow> &list = qwsServer->clientWindows(); 456 const QList<QWSWindow> &list = qwsServer->clientWindows();
458 QWSWindow* w; 457 QWSWindow* w;
459 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 458 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
460 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 459 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
461 return TRUE; 460 return TRUE;
462 } 461 }
463 return FALSE; 462 return FALSE;
464} 463}
465 464
466void Desktop::raiseLauncher() 465void Desktop::raiseLauncher()
467{ 466{
468 Config cfg("qpe"); //F12 'Home' 467 Config cfg("qpe"); //F12 'Home'
469 cfg.setGroup("AppsKey"); 468 cfg.setGroup("AppsKey");
470 QString tempItem; 469 QString tempItem;
471 tempItem = cfg.readEntry("Middle","Home"); 470 tempItem = cfg.readEntry("Middle","Home");
472 if(tempItem == "Home" || tempItem.isEmpty()) { 471 if(tempItem == "Home" || tempItem.isEmpty()) {
473 if ( isVisibleWindow(launcher->winId()) ) 472 if ( isVisibleWindow(launcher->winId()) )
474 launcher->nextView(); 473 launcher->nextView();
475 else 474 else
476 launcher->raise(); 475 launcher->raise();
477 } else { 476 } else {
478 QCopEnvelope e("QPE/System","execute(QString)"); 477 QCopEnvelope e("QPE/System","execute(QString)");
479 e << tempItem; 478 e << tempItem;
480 } 479 }
481} 480}
482 481
483void Desktop::executeOrModify(const QString& appLnkFile) 482void Desktop::executeOrModify(const QString& appLnkFile)
484{ 483{
485 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 484 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
486 if ( lnk.isValid() ) { 485 if ( lnk.isValid() ) {
487 QCString app = lnk.exec().utf8(); 486 QCString app = lnk.exec().utf8();
488 Global::terminateBuiltin("calibrate"); 487 Global::terminateBuiltin("calibrate");
489 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 488 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
490 MRUList::addTask(&lnk); 489 MRUList::addTask(&lnk);
491 if ( hasVisibleWindow(app) ) 490 if ( hasVisibleWindow(app) )
492 QCopChannel::send("QPE/Application/" + app, "nextView()"); 491 QCopChannel::send("QPE/Application/" + app, "nextView()");
493 else 492 else
494 QCopChannel::send("QPE/Application/" + app, "raise()"); 493 QCopChannel::send("QPE/Application/" + app, "raise()");
495 } else { 494 } else {
496 lnk.execute(); 495 lnk.execute();
497 } 496 }
498 } 497 }
499} 498}
500 499
501void Desktop::raiseDatebook() 500void Desktop::raiseDatebook()
502{ 501{
503 Config cfg( "qpe" ); //F9 'Activity' 502 Config cfg( "qpe" ); //F9 'Activity'
504 cfg.setGroup( "AppsKey" ); 503 cfg.setGroup( "AppsKey" );
505 QString tempItem; 504 QString tempItem;
506 tempItem = cfg.readEntry( "LeftEnd" , "Calender" ); 505 tempItem = cfg.readEntry( "LeftEnd" , "Calender" );
507 if ( tempItem == "Calender" || tempItem.isEmpty() ) { 506 if ( tempItem == "Calender" || tempItem.isEmpty() ) {
508 tempItem = "datebook"; 507 tempItem = "datebook";
509 } 508 }
510 QCopEnvelope e( "QPE/System", "execute(QString)" ); 509 QCopEnvelope e( "QPE/System", "execute(QString)" );
511 e << tempItem; 510 e << tempItem;
512} 511}
513 512
514void Desktop::raiseContacts() 513void Desktop::raiseContacts()
515{ 514{
516 Config cfg( "qpe" ); //F10, 'Contacts' 515 Config cfg( "qpe" ); //F10, 'Contacts'
517 cfg.setGroup( "AppsKey" ); 516 cfg.setGroup( "AppsKey" );
518 QString tempItem; 517 QString tempItem;
519 tempItem = cfg.readEntry( "Left2nd", "Address Book" ); 518 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
520 if ( tempItem == "Address Book" || tempItem.isEmpty() ) { 519 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
521 tempItem = "addressbook"; 520 tempItem = "addressbook";
522 } 521 }
523 QCopEnvelope e("QPE/System","execute(QString)"); 522 QCopEnvelope e("QPE/System","execute(QString)");
524 e << tempItem; 523 e << tempItem;
525} 524}
526 525
527void Desktop::raiseMenu() 526void Desktop::raiseMenu()
528{ 527{
529 Config cfg( "qpe" ); //F11, 'Menu 528 Config cfg( "qpe" ); //F11, 'Menu
530 cfg.setGroup( "AppsKey" ); 529 cfg.setGroup( "AppsKey" );
531 QString tempItem; 530 QString tempItem;
532 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); 531 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
533 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { 532 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
534 Global::terminateBuiltin("calibrate"); 533 Global::terminateBuiltin( "calibrate" );
535 tb->startMenu()->launch(); 534 tb->startMenu()->launch();
536 } else { 535 } else {
537 QCopEnvelope e("QPE/System","execute(QString)"); 536 QCopEnvelope e("QPE/System","execute(QString)");
538 e << tempItem; 537 e << tempItem;
539 } 538 }
540} 539}
541 540
542void Desktop::raiseEmail() 541void Desktop::raiseEmail()
543{ 542{
544 Config cfg( "qpe" ); //F13, 'Mail' 543 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
545 cfg.setGroup( "AppsKey" ); 544 cfg.setGroup( "AppsKey" );
546 QString tempItem; 545 QString tempItem;
547 tempItem = cfg.readEntry( "RightEnd", "Mail" ); 546 tempItem = cfg.readEntry( "RightEnd", "Mail" );
548 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { 547 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
549 tempItem = "mail"; 548 tempItem = "mail";
550 } 549 }
551 QCopEnvelope e("QPE/System","execute(QString)"); 550 QCopEnvelope e("QPE/System","execute(QString)");
552 e << tempItem; 551 e << tempItem;
553} 552}
554 553
555// autoStarts apps on resume and start 554// autoStarts apps on resume and start
556void Desktop::execAutoStart() { 555void Desktop::execAutoStart()
556{
557 QString appName; 557 QString appName;
558 int delay; 558 int delay;
559 QDateTime now = QDateTime::currentDateTime(); 559 QDateTime now = QDateTime::currentDateTime();
560 Config cfg( "autostart" ); 560 Config cfg( "autostart" );
561 cfg.setGroup( "AutoStart" ); 561 cfg.setGroup( "AutoStart" );
562 appName = cfg.readEntry( "Apps", "" ); 562 appName = cfg.readEntry( "Apps", "" );
563 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 563 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
564 // If the time between suspend and resume was longer then the 564 // If the time between suspend and resume was longer then the
565 // value saved as delay, start the app 565 // value saved as delay, start the app
566 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { 566 if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) {
567 QCopEnvelope e( "QPE/System", "execute(QString)" ); 567 QCopEnvelope e( "QPE/System", "execute(QString)" );
568 e << QString( appName ); 568 e << QString( appName );
569 } 569 }
570} 570}
571 571
572#if defined(QPE_HAVE_TOGGLELIGHT) 572#if defined(QPE_HAVE_TOGGLELIGHT)
573#include <qpe/config.h> 573#include <qpe/config.h>
574 574
575#include <sys/ioctl.h> 575#include <sys/ioctl.h>
576#include <sys/types.h> 576#include <sys/types.h>
577#include <fcntl.h> 577#include <fcntl.h>
578#include <unistd.h> 578#include <unistd.h>
579#include <errno.h> 579#include <errno.h>
580#include <linux/ioctl.h> 580#include <linux/ioctl.h>
581#include <time.h> 581#include <time.h>
582#endif 582#endif
583 583
584static bool blanked=FALSE; 584static bool blanked=FALSE;
585 585
586static void blankScreen() 586static void blankScreen()
587{ 587{
588 if ( !qt_screen ) return; 588 if ( !qt_screen ) return;
589 /* Should use a big black window instead. 589 /* Should use a big black window instead.
590 QGfx* g = qt_screen->screenGfx(); 590 QGfx* g = qt_screen->screenGfx();
591 g->fillRect(0,0,qt_screen->width(),qt_screen->height()); 591 g->fillRect(0,0,qt_screen->width(),qt_screen->height());
592 delete g; 592 delete g;
593 */ 593 */
594 blanked = TRUE; 594 blanked = TRUE;
595} 595}
596 596
597static void darkScreen() 597static void darkScreen()
598{ 598{
599 extern void qpe_setBacklight(int); 599 extern void qpe_setBacklight(int);
600 qpe_setBacklight(0); // force off 600 qpe_setBacklight(0); // force off
601} 601}
602 602
603 603
604void Desktop::togglePower() 604void Desktop::togglePower()
605{ 605{
606 extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop 606 extern void qpe_setBacklight ( int ); // We need to toggle the LCD fast - no time to send a QCop
607 607
608 static bool excllock = false; 608 static bool excllock = false;
609 609
610 if ( excllock ) 610 if ( excllock )
611 return; 611 return;
612 612
613 excllock = true; 613 excllock = true;
614 614
615 bool wasloggedin = loggedin; 615 bool wasloggedin = loggedin;
616 loggedin=0; 616 loggedin=0;
617 suspendTime = QDateTime::currentDateTime(); 617 suspendTime = QDateTime::currentDateTime();
618 618
619 //qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????) 619 //qpe_setBacklight ( 0 ); // force LCD off (sandman: why ????)
620 620
621 if ( wasloggedin ) 621 if ( wasloggedin )
622 blankScreen(); 622 blankScreen();
623 623
624 ODevice::inst ( )-> suspend ( ); 624 ODevice::inst ( )-> suspend ( );
625 625
626 QWSServer::screenSaverActivate ( false ); 626 QWSServer::screenSaverActivate ( false );
627 627
628 qpe_setBacklight ( -3 ); // force LCD on 628 qpe_setBacklight ( -3 ); // force LCD on
629 629
630 { 630 {
631 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep 631 QCopEnvelope("QPE/Card", "mtabChanged()" ); // might have changed while asleep
632 } 632 }
633 633
634 if ( wasloggedin ) 634 if ( wasloggedin )
635 login(TRUE); 635 login(TRUE);
636 636
637 execAutoStart(); 637 execAutoStart();
638 //qcopBridge->closeOpenConnections(); 638 //qcopBridge->closeOpenConnections();
639 639
640 excllock = false; 640 excllock = false;
641} 641}
642 642
643void Desktop::toggleLight() 643void Desktop::toggleLight()
644{ 644{
645 QCopEnvelope e("QPE/System", "setBacklight(int)"); 645 QCopEnvelope e("QPE/System", "setBacklight(int)");
646 e << -2; // toggle 646 e << -2; // toggle
647} 647}
648 648
649void Desktop::toggleSymbolInput() 649void Desktop::toggleSymbolInput()
650{ 650{
651 tb->toggleSymbolInput(); 651 tb->toggleSymbolInput();
652} 652}
653 653
654void Desktop::toggleNumLockState() 654void Desktop::toggleNumLockState()
655{ 655{
656 tb->toggleNumLockState(); 656 tb->toggleNumLockState();
657} 657}
658 658
659void Desktop::toggleCapsLockState() 659void Desktop::toggleCapsLockState()
660{ 660{
661 tb->toggleCapsLockState(); 661 tb->toggleCapsLockState();
662} 662}
663 663
664void Desktop::styleChange( QStyle &s ) 664void Desktop::styleChange( QStyle &s )
665{ 665{
666 QWidget::styleChange( s ); 666 QWidget::styleChange( s );
667 int displayw = qApp->desktop()->width(); 667 int displayw = qApp->desktop()->width();
668 int displayh = qApp->desktop()->height(); 668 int displayh = qApp->desktop()->height();
669 669
670 QSize sz = tb->sizeHint(); 670 QSize sz = tb->sizeHint();
671 671
672 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 672 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
673} 673}
674 674
675void DesktopApplication::shutdown() 675void DesktopApplication::shutdown()
676{ 676{
677 if ( type() != GuiServer ) 677 if ( type() != GuiServer )
678 return; 678 return;
679 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 679 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
680 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 680 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
681 this, SLOT(shutdown(ShutdownImpl::Type)) ); 681 this, SLOT(shutdown(ShutdownImpl::Type)) );
682 sd->showMaximized(); 682 sd->showMaximized();
683} 683}
684 684
685void DesktopApplication::shutdown( ShutdownImpl::Type t ) 685void DesktopApplication::shutdown( ShutdownImpl::Type t )
686{ 686{
687 switch ( t ) { 687 switch ( t ) {
688 case ShutdownImpl::ShutdownSystem: 688 case ShutdownImpl::ShutdownSystem:
689 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 689 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
690 break; 690 break;
691 case ShutdownImpl::RebootSystem: 691 case ShutdownImpl::RebootSystem:
692 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 692 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
693 break; 693 break;
694 case ShutdownImpl::RestartDesktop: 694 case ShutdownImpl::RestartDesktop:
695 restart(); 695 restart();
696 break; 696 break;
697 case ShutdownImpl::TerminateDesktop: 697 case ShutdownImpl::TerminateDesktop:
698 prepareForTermination(FALSE); 698 prepareForTermination(FALSE);
699 699
700 // This is a workaround for a Qt bug 700 // This is a workaround for a Qt bug
701 // clipboard applet has to stop its poll timer, or Qt/E 701 // clipboard applet has to stop its poll timer, or Qt/E
702 // will hang on quit() right before it emits aboutToQuit() 702 // will hang on quit() right before it emits aboutToQuit()
703 emit aboutToQuit ( ); 703 emit aboutToQuit ( );
704 704
705 quit(); 705 quit();
706 break; 706 break;
707 } 707 }
708} 708}
709 709
710void DesktopApplication::restart() 710void DesktopApplication::restart()
711{ 711{
712 prepareForTermination(TRUE); 712 prepareForTermination(TRUE);
713 713
714#ifdef Q_WS_QWS 714#ifdef Q_WS_QWS
715 for ( int fd = 3; fd < 100; fd++ ) 715 for ( int fd = 3; fd < 100; fd++ )
716 close( fd ); 716 close( fd );
717#if defined(QT_DEMO_SINGLE_FLOPPY) 717#if defined(QT_DEMO_SINGLE_FLOPPY)
718 execl( "/sbin/init", "qpe", 0 ); 718 execl( "/sbin/init", "qpe", 0 );
719#elif defined(QT_QWS_CASSIOPEIA) 719#elif defined(QT_QWS_CASSIOPEIA)
720 execl( "/bin/sh", "sh", 0 ); 720 execl( "/bin/sh", "sh", 0 );
721#else 721#else
722 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 722 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
723#endif 723#endif
724 exit(1); 724 exit(1);
725#endif 725#endif
726} 726}
727 727
728void Desktop::startTransferServer() 728void Desktop::startTransferServer()
729{ 729{
730 // start qcop bridge server 730 // start qcop bridge server
731 qcopBridge = new QCopBridge( 4243 ); 731 qcopBridge = new QCopBridge( 4243 );
732 if ( !qcopBridge->ok() ) { 732 if ( !qcopBridge->ok() ) {
733 delete qcopBridge; 733 delete qcopBridge;
734 qcopBridge = 0; 734 qcopBridge = 0;
735 } 735 }
736 // start transfer server 736 // start transfer server
737 transferServer = new TransferServer( 4242 ); 737 transferServer = new TransferServer( 4242 );
738 if ( !transferServer->ok() ) { 738 if ( !transferServer->ok() ) {
739 delete transferServer; 739 delete transferServer;
740 transferServer = 0; 740 transferServer = 0;
741 } 741 }
742 if ( !transferServer || !qcopBridge ) 742 if ( !transferServer || !qcopBridge )
743 startTimer( 2000 ); 743 startTimer( 2000 );
744} 744}
745 745
746void Desktop::timerEvent( QTimerEvent *e ) 746void Desktop::timerEvent( QTimerEvent *e )
747{ 747{
748 killTimer( e->timerId() ); 748 killTimer( e->timerId() );
749 startTransferServer(); 749 startTransferServer();
750} 750}
751 751
752void Desktop::terminateServers() 752void Desktop::terminateServers()
753{ 753{
754 delete transferServer; 754 delete transferServer;
755 delete qcopBridge; 755 delete qcopBridge;
756 transferServer = 0; 756 transferServer = 0;
757 qcopBridge = 0; 757 qcopBridge = 0;
758} 758}
759 759
760void Desktop::rereadVolumes() 760void Desktop::rereadVolumes()
761{ 761{
762 Config cfg("qpe"); 762 Config cfg("qpe");
763 cfg.setGroup("Volume"); 763 cfg.setGroup("Volume");
764 touchclick = cfg.readBoolEntry("TouchSound"); 764 touchclick = cfg.readBoolEntry("TouchSound");
765 keyclick = cfg.readBoolEntry("KeySound"); 765 keyclick = cfg.readBoolEntry("KeySound");
766 alarmsound = cfg.readBoolEntry("AlarmSound"); 766 alarmsound = cfg.readBoolEntry("AlarmSound");
767// Config cfg("Sound");
768// cfg.setGroup("System");
769// touchclick = cfg.readBoolEntry("Touch");
770// keyclick = cfg.readBoolEntry("Key");
771} 767}
772 768
773void Desktop::keyClick() 769void Desktop::keyClick()
774{ 770{
775 if ( keyclick ) 771 if ( keyclick )
776 ODevice::inst ( )-> keySound ( ); 772 ODevice::inst ( )-> keySound ( );
777} 773}
778 774
779void Desktop::screenClick() 775void Desktop::screenClick()
780{ 776{
781 if ( touchclick ) 777 if ( touchclick )
782 ODevice::inst ( )-> touchSound ( ); 778 ODevice::inst ( )-> touchSound ( );
783} 779}
784 780
785void Desktop::soundAlarm() 781void Desktop::soundAlarm()
786{ 782{
787 if ( qpedesktop-> alarmsound ) 783 if ( qpedesktop-> alarmsound )
788 ODevice::inst ( )-> alarmSound ( ); 784 ODevice::inst ( )-> alarmSound ( );
789} 785}
790 786
791bool Desktop::eventFilter( QObject *, QEvent *ev ) 787bool Desktop::eventFilter( QObject *, QEvent *ev )
792{ 788{
793 if ( ev-> type ( ) == QEvent::KeyPress ) { 789 if ( ev-> type ( ) == QEvent::KeyPress ) {
794 QKeyEvent *ke = (QKeyEvent *) ev; 790 QKeyEvent *ke = (QKeyEvent *) ev;
795 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key 791 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
796 QWidget *active = qApp-> activeWindow ( ); 792 QWidget *active = qApp-> activeWindow ( );
797 793
798 if ( active && active-> isPopup ( )) 794 if ( active && active-> isPopup ( ))
799 active->close(); 795 active->close();
800 796
801 raiseMenu ( ); 797 /*
802 return true; 798 * On iPAQ 38xx that key is not the "menu key" but the mail key
799 * To not confuse the users, make it launch the mail app on 38xx
800 */
801 if (ODevice::inst()->model() == OMODEL_iPAQ_H38xx ) {
802 QCopEnvelope e( "QPE/System", "execute(QString)" );
803 e << QString( "mail" );
804 return true;
805 } else {
806 raiseMenu ( );
807 return true;
808 }
809 }
803 } 810 }
804 } 811 return false;
805 return false;
806} 812}