summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-04-04 02:55:56 (UTC)
committer llornkcor <llornkcor>2002-04-04 02:55:56 (UTC)
commit431ff3f7fd9996236c6d82a3644b3915bd4c7b38 (patch) (unidiff)
tree693e873c51efc5c43cfa7ebd5dd0755fb254500a
parente18dab7b6b00ad3ba8117666998de6db52257bdb (diff)
downloadopie-431ff3f7fd9996236c6d82a3644b3915bd4c7b38.zip
opie-431ff3f7fd9996236c6d82a3644b3915bd4c7b38.tar.gz
opie-431ff3f7fd9996236c6d82a3644b3915bd4c7b38.tar.bz2
added support for configuring with AppKeys, F9 - F13 (Zaurus' cover buttons)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp450
1 files changed, 246 insertions, 204 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 64043e7..cf33011 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -52,17 +52,17 @@
52#include <stdlib.h> 52#include <stdlib.h>
53#include <unistd.h> 53#include <unistd.h>
54 54
55class QCopKeyRegister 55class QCopKeyRegister
56{ 56{
57public: 57public:
58 QCopKeyRegister() : keyCode(0) { } 58 QCopKeyRegister() : keyCode(0) { }
59 QCopKeyRegister(int k, const QString &c, const QString &m) 59 QCopKeyRegister(int k, const QString &c, const QString &m)
60 : keyCode(k), channel(c), message(m) { } 60 : keyCode(k), channel(c), message(m) { }
61 61
62 int getKeyCode() const { return keyCode; } 62 int getKeyCode() const { return keyCode; }
63 QString getChannel() const { return channel; } 63 QString getChannel() const { return channel; }
64 QString getMessage() const { return message; } 64 QString getMessage() const { return message; }
65 65
66private: 66private:
67 int keyCode; 67 int keyCode;
68 QString channel, message; 68 QString channel, message;
@@ -71,60 +71,60 @@ private:
71typedef QValueList<QCopKeyRegister> KeyRegisterList; 71typedef QValueList<QCopKeyRegister> KeyRegisterList;
72KeyRegisterList keyRegisterList; 72KeyRegisterList keyRegisterList;
73 73
74static Desktop* qpedesktop = 0; 74static Desktop* qpedesktop = 0;
75static int loggedin=0; 75static int loggedin=0;
76static void login(bool at_poweron) 76static void login(bool at_poweron)
77{ 77{
78 if ( !loggedin ) { 78 if ( !loggedin ) {
79 Global::terminateBuiltin("calibrate"); 79 Global::terminateBuiltin("calibrate");
80 Password::authenticate(at_poweron); 80 Password::authenticate(at_poweron);
81 loggedin=1; 81 loggedin=1;
82 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 82 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
83 } 83 }
84} 84}
85 85
86bool Desktop::screenLocked() 86bool Desktop::screenLocked()
87{ 87{
88 return loggedin == 0; 88 return loggedin == 0;
89} 89}
90 90
91/* 91/*
92 Priority is number of alerts that are needed to pop up 92 Priority is number of alerts that are needed to pop up
93 alert. 93 alert.
94 */ 94 */
95class DesktopPowerAlerter : public QMessageBox 95class DesktopPowerAlerter : public QMessageBox
96{ 96{
97public: 97public:
98 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 98 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
99 : QMessageBox( tr("Battery Status"), "Low Battery", 99 : QMessageBox( tr("Battery Status"), "Low Battery",
100 QMessageBox::Critical, 100 QMessageBox::Critical,
101 QMessageBox::Ok | QMessageBox::Default, 101 QMessageBox::Ok | QMessageBox::Default,
102 QMessageBox::NoButton, QMessageBox::NoButton, 102 QMessageBox::NoButton, QMessageBox::NoButton,
103 parent, name, FALSE ) 103 parent, name, FALSE )
104 { 104 {
105 currentPriority = INT_MAX; 105 currentPriority = INT_MAX;
106 alertCount = 0; 106 alertCount = 0;
107 } 107 }
108 108
109 void alert( const QString &text, int priority ); 109 void alert( const QString &text, int priority );
110 void hideEvent( QHideEvent * ); 110 void hideEvent( QHideEvent * );
111private: 111private:
112 int currentPriority; 112 int currentPriority;
113 int alertCount; 113 int alertCount;
114}; 114};
115 115
116void DesktopPowerAlerter::alert( const QString &text, int priority ) 116void DesktopPowerAlerter::alert( const QString &text, int priority )
117{ 117{
118 alertCount++; 118 alertCount++;
119 if ( alertCount < priority ) 119 if ( alertCount < priority )
120 return; 120 return;
121 if ( priority > currentPriority ) 121 if ( priority > currentPriority )
122 return; 122 return;
123 currentPriority = priority; 123 currentPriority = priority;
124 setText( text ); 124 setText( text );
125 show(); 125 show();
126} 126}
127 127
128 128
129void DesktopPowerAlerter::hideEvent( QHideEvent *e ) 129void DesktopPowerAlerter::hideEvent( QHideEvent *e )
130{ 130{
@@ -142,183 +142,183 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type t )
142 QTimer *t = new QTimer( this ); 142 QTimer *t = new QTimer( this );
143 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); 143 connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) );
144 t->start( 10000 ); 144 t->start( 10000 );
145 ps = new PowerStatus; 145 ps = new PowerStatus;
146 pa = new DesktopPowerAlerter( 0 ); 146 pa = new DesktopPowerAlerter( 0 );
147 147
148 channel = new QCopChannel( "QPE/Desktop", this ); 148 channel = new QCopChannel( "QPE/Desktop", this );
149 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 149 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
150 this, SLOT(receive(const QCString&, const QByteArray&)) ); 150 this, SLOT(receive(const QCString&, const QByteArray&)) );
151} 151}
152 152
153 153
154DesktopApplication::~DesktopApplication() 154DesktopApplication::~DesktopApplication()
155{ 155{
156 delete ps; 156 delete ps;
157 delete pa; 157 delete pa;
158} 158}
159 159
160void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) 160void DesktopApplication::receive( const QCString &msg, const QByteArray &data )
161{ 161{
162 QDataStream stream( data, IO_ReadOnly ); 162 QDataStream stream( data, IO_ReadOnly );
163 if (msg == "keyRegister(int key, QString channel, QString message)") 163 if (msg == "keyRegister(int key, QString channel, QString message)")
164 { 164 {
165 int k; 165 int k;
166 QString c, m; 166 QString c, m;
167 167
168 stream >> k; 168 stream >> k;
169 stream >> c; 169 stream >> c;
170 stream >> m; 170 stream >> m;
171 171
172 qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); 172 qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m);
173 keyRegisterList.append(QCopKeyRegister(k,c,m)); 173 keyRegisterList.append(QCopKeyRegister(k,c,m));
174 } 174 }
175 else if (msg == "suspend()"){ 175 else if (msg == "suspend()"){
176 emit power(); 176 emit power();
177 } 177 }
178 178
179} 179}
180 180
181enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; 181enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown;
182 182
183#ifdef Q_WS_QWS 183#ifdef Q_WS_QWS
184bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 184bool DesktopApplication::qwsEventFilter( QWSEvent *e )
185{ 185{
186 qpedesktop->checkMemory(); 186 qpedesktop->checkMemory();
187 187
188 if ( e->type == QWSEvent::Key ) { 188 if ( e->type == QWSEvent::Key ) {
189 QWSKeyEvent *ke = (QWSKeyEvent *)e; 189 QWSKeyEvent *ke = (QWSKeyEvent *)e;
190 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 190 if ( !loggedin && ke->simpleData.keycode != Key_F34 )
191 return TRUE; 191 return TRUE;
192 bool press = ke->simpleData.is_press; 192 bool press = ke->simpleData.is_press;
193 193
194 if (!keyRegisterList.isEmpty()) 194 if (!keyRegisterList.isEmpty())
195 { 195 {
196 KeyRegisterList::Iterator it; 196 KeyRegisterList::Iterator it;
197 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) 197 for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it )
198 { 198 {
199 if ((*it).getKeyCode() == ke->simpleData.keycode) 199 if ((*it).getKeyCode() == ke->simpleData.keycode)
200 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); 200 QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8());
201 } 201 }
202 } 202 }
203 203
204 if ( !keyboardGrabbed() ) { 204 if ( !keyboardGrabbed() ) {
205 if ( ke->simpleData.keycode == Key_F9 ) { 205 if ( ke->simpleData.keycode == Key_F9 ) {
206 if ( press ) emit datebook(); 206 if ( press ) emit datebook();
207 return TRUE; 207 return TRUE;
208 } 208 }
209 if ( ke->simpleData.keycode == Key_F10 ) { 209 if ( ke->simpleData.keycode == Key_F10 ) {
210 if ( !press && cardSendTimer ) { 210 if ( !press && cardSendTimer ) {
211 emit contacts(); 211 emit contacts();
212 delete cardSendTimer; 212 delete cardSendTimer;
213 } else if ( press ) { 213 } else if ( press ) {
214 cardSendTimer = new QTimer(); 214 cardSendTimer = new QTimer();
215 cardSendTimer->start( 2000, TRUE ); 215 cardSendTimer->start( 2000, TRUE );
216 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 216 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
217 } 217 }
218 return TRUE; 218 return TRUE;
219 } 219 }
220 /* menu key now opens application menu/toolbar 220 /* menu key now opens application menu/toolbar
221 if ( ke->simpleData.keycode == Key_F11 ) { 221 if ( ke->simpleData.keycode == Key_F11 ) {
222 if ( press ) emit menu(); 222 if ( press ) emit menu();
223 return TRUE; 223 return TRUE;
224 } 224 }
225 */ 225 */
226 if ( ke->simpleData.keycode == Key_F12 ) { 226 if ( ke->simpleData.keycode == Key_F12 ) {
227 while( activePopupWidget() ) 227 while( activePopupWidget() )
228 activePopupWidget()->close(); 228 activePopupWidget()->close();
229 if ( press ) emit launch(); 229 if ( press ) emit launch();
230 return TRUE; 230 return TRUE;
231 } 231 }
232 if ( ke->simpleData.keycode == Key_F13 ) { 232 if ( ke->simpleData.keycode == Key_F13 ) {
233 if ( press ) emit email(); 233 if ( press ) emit email();
234 return TRUE; 234 return TRUE;
235 } 235 }
236 } 236 }
237 237
238 if ( ke->simpleData.keycode == Key_F34 ) { 238 if ( ke->simpleData.keycode == Key_F34 ) {
239 if ( press ) emit power(); 239 if ( press ) emit power();
240 return TRUE; 240 return TRUE;
241 } 241 }
242 if ( ke->simpleData.keycode == Key_SysReq ) { 242 if ( ke->simpleData.keycode == Key_SysReq ) {
243 if ( press ) emit power(); 243 if ( press ) emit power();
244 return TRUE; 244 return TRUE;
245 } 245 }
246 if ( ke->simpleData.keycode == Key_F35 ) { 246 if ( ke->simpleData.keycode == Key_F35 ) {
247 if ( press ) emit backlight(); 247 if ( press ) emit backlight();
248 return TRUE; 248 return TRUE;
249 } 249 }
250 if ( ke->simpleData.keycode == Key_F32 ) { 250 if ( ke->simpleData.keycode == Key_F32 ) {
251 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 251 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
252 return TRUE; 252 return TRUE;
253 } 253 }
254 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 254 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
255 if ( press ) emit symbol(); 255 if ( press ) emit symbol();
256 return TRUE; 256 return TRUE;
257 } 257 }
258 if ( ke->simpleData.keycode == Key_NumLock ) { 258 if ( ke->simpleData.keycode == Key_NumLock ) {
259 if ( press ) emit numLockStateToggle(); 259 if ( press ) emit numLockStateToggle();
260 } 260 }
261 if ( ke->simpleData.keycode == Key_CapsLock ) { 261 if ( ke->simpleData.keycode == Key_CapsLock ) {
262 if ( press ) emit capsLockStateToggle(); 262 if ( press ) emit capsLockStateToggle();
263 } 263 }
264 if ( press ) 264 if ( press )
265 qpedesktop->keyClick(); 265 qpedesktop->keyClick();
266 } else { 266 } else {
267 if ( e->type == QWSEvent::Mouse ) { 267 if ( e->type == QWSEvent::Mouse ) {
268 QWSMouseEvent *me = (QWSMouseEvent *)e; 268 QWSMouseEvent *me = (QWSMouseEvent *)e;
269 static bool up = TRUE; 269 static bool up = TRUE;
270 if ( me->simpleData.state&LeftButton ) { 270 if ( me->simpleData.state&LeftButton ) {
271 if ( up ) { 271 if ( up ) {
272 up = FALSE; 272 up = FALSE;
273 qpedesktop->screenClick(); 273 qpedesktop->screenClick();
274 } 274 }
275 } else { 275 } else {
276 up = TRUE; 276 up = TRUE;
277 } 277 }
278 } 278 }
279 } 279 }
280 280
281 return QPEApplication::qwsEventFilter( e ); 281 return QPEApplication::qwsEventFilter( e );
282} 282}
283#endif 283#endif
284 284
285void DesktopApplication::psTimeout() 285void DesktopApplication::psTimeout()
286{ 286{
287 qpedesktop->checkMemory(); // in case no events are being generated 287 qpedesktop->checkMemory(); // in case no events are being generated
288 288
289 *ps = PowerStatusManager::readStatus(); 289 *ps = PowerStatusManager::readStatus();
290 290
291 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 291 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
292 pa->alert( tr( "Battery is running very low." ), 6 ); 292 pa->alert( tr( "Battery is running very low." ), 6 );
293 } 293 }
294 294
295 if ( ps->batteryStatus() == PowerStatus::Critical ) { 295 if ( ps->batteryStatus() == PowerStatus::Critical ) {
296 pa->alert( tr( "Battery level is critical!\n" 296 pa->alert( tr( "Battery level is critical!\n"
297 "Keep power off until power restored!" ), 1 ); 297 "Keep power off until power restored!" ), 1 );
298 } 298 }
299 299
300 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 300 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
301 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 301 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
302 } 302 }
303} 303}
304 304
305 305
306void DesktopApplication::sendCard() 306void DesktopApplication::sendCard()
307{ 307{
308 delete cardSendTimer; 308 delete cardSendTimer;
309 cardSendTimer = 0; 309 cardSendTimer = 0;
310 QString card = getenv("HOME"); 310 QString card = getenv("HOME");
311 card += "/Applications/addressbook/businesscard.vcf"; 311 card += "/Applications/addressbook/businesscard.vcf";
312 312
313 if ( QFile::exists( card ) ) { 313 if ( QFile::exists( card ) ) {
314 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 314 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
315 QString mimetype = "text/x-vCard"; 315 QString mimetype = "text/x-vCard";
316 e << tr("business card") << card << mimetype; 316 e << tr("business card") << card << mimetype;
317 } 317 }
318} 318}
319 319
320#if defined(QPE_HAVE_MEMALERTER) 320#if defined(QPE_HAVE_MEMALERTER)
321QPE_MEMALERTER_IMPL 321QPE_MEMALERTER_IMPL
322#endif 322#endif
323 323
324#if defined(CUSTOM_SOUND_IMPL) 324#if defined(CUSTOM_SOUND_IMPL)
@@ -395,118 +395,160 @@ bool Desktop::recoverMemory()
395 395
396void Desktop::checkMemory() 396void Desktop::checkMemory()
397{ 397{
398#if defined(QPE_HAVE_MEMALERTER) 398#if defined(QPE_HAVE_MEMALERTER)
399 static bool ignoreNormal=FALSE; 399 static bool ignoreNormal=FALSE;
400 static bool existingMessage=FALSE; 400 static bool existingMessage=FALSE;
401 401
402 if(existingMessage) 402 if(existingMessage)
403 return; // don't show a second message while still on first 403 return; // don't show a second message while still on first
404 404
405 existingMessage = TRUE; 405 existingMessage = TRUE;
406 switch ( memstate ) { 406 switch ( memstate ) {
407 case Unknown: 407 case Unknown:
408 break; 408 break;
409 case Low: 409 case Low:
410 memstate = Unknown; 410 memstate = Unknown;
411 if ( recoverMemory() ) 411 if ( recoverMemory() )
412 ignoreNormal = TRUE; 412 ignoreNormal = TRUE;
413 else 413 else
414 QMessageBox::warning( 0 , "Memory Status", 414 QMessageBox::warning( 0 , "Memory Status",
415 "The memory smacks of shortage. \n" 415 "The memory smacks of shortage. \n"
416 "Please save data. " ); 416 "Please save data. " );
417 break; 417 break;
418 case Normal: 418 case Normal:
419 memstate = Unknown; 419 memstate = Unknown;
420 if ( ignoreNormal ) 420 if ( ignoreNormal )
421 ignoreNormal = FALSE; 421 ignoreNormal = FALSE;
422 else 422 else
423 QMessageBox::information ( 0 , "Memory Status", 423 QMessageBox::information ( 0 , "Memory Status",
424 "There is enough memory again." ); 424 "There is enough memory again." );
425 break; 425 break;
426 case VeryLow: 426 case VeryLow:
427 memstate = Unknown; 427 memstate = Unknown;
428 QMessageBox::critical( 0 , "Memory Status", 428 QMessageBox::critical( 0 , "Memory Status",
429 "The memory is very low. \n" 429 "The memory is very low. \n"
430 "Please end this application \n" 430 "Please end this application \n"
431 "immediately." ); 431 "immediately." );
432 recoverMemory(); 432 recoverMemory();
433 } 433 }
434 existingMessage = FALSE; 434 existingMessage = FALSE;
435#endif 435#endif
436} 436}
437 437
438static bool isVisibleWindow(int wid) 438static bool isVisibleWindow(int wid)
439{ 439{
440 const QList<QWSWindow> &list = qwsServer->clientWindows(); 440 const QList<QWSWindow> &list = qwsServer->clientWindows();
441 QWSWindow* w; 441 QWSWindow* w;
442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 442 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
443 if ( w->winId() == wid ) 443 if ( w->winId() == wid )
444 return !w->isFullyObscured(); 444 return !w->isFullyObscured();
445 } 445 }
446 return FALSE; 446 return FALSE;
447} 447}
448 448
449static bool hasVisibleWindow(const QString& clientname) 449static bool hasVisibleWindow(const QString& clientname)
450{ 450{
451 const QList<QWSWindow> &list = qwsServer->clientWindows(); 451 const QList<QWSWindow> &list = qwsServer->clientWindows();
452 QWSWindow* w; 452 QWSWindow* w;
453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 453 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
454 if ( w->client()->identity() == clientname && !w->isFullyObscured() ) 454 if ( w->client()->identity() == clientname && !w->isFullyObscured() )
455 return TRUE; 455 return TRUE;
456 } 456 }
457 return FALSE; 457 return FALSE;
458} 458}
459 459
460void Desktop::raiseLauncher() 460void Desktop::raiseLauncher()
461{ 461{
462 if ( isVisibleWindow(launcher->winId()) ) 462 Config cfg("qpe"); //F12 'Home'
463 launcher->nextView(); 463 cfg.setGroup("AppsKey");
464 else 464 QString tempItem;
465 launcher->raise(); 465 tempItem = cfg.readEntry("Middle","Home");
466 if(tempItem == "Home" || tempItem.isEmpty()) {
467 if ( isVisibleWindow(launcher->winId()) )
468 launcher->nextView();
469 else
470 launcher->raise();
471 } else {
472 QCopEnvelope e("QPE/System","execute(QString)");
473 e << tempItem;
474 }
466} 475}
467 476
468void Desktop::executeOrModify(const QString& appLnkFile) 477void Desktop::executeOrModify(const QString& appLnkFile)
469{ 478{
470 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile); 479 AppLnk lnk(MimeType::appsFolderName() + "/" + appLnkFile);
471 if ( lnk.isValid() ) { 480 if ( lnk.isValid() ) {
472 QCString app = lnk.exec().utf8(); 481 QCString app = lnk.exec().utf8();
473 Global::terminateBuiltin("calibrate"); 482 Global::terminateBuiltin("calibrate");
474 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) { 483 if ( QCopChannel::isRegistered("QPE/Application/" + app) ) {
475 MRUList::addTask(&lnk); 484 MRUList::addTask(&lnk);
476 if ( hasVisibleWindow(app) ) 485 if ( hasVisibleWindow(app) )
477 QCopChannel::send("QPE/Application/" + app, "nextView()"); 486 QCopChannel::send("QPE/Application/" + app, "nextView()");
478 else 487 else
479 QCopChannel::send("QPE/Application/" + app, "raise()"); 488 QCopChannel::send("QPE/Application/" + app, "raise()");
480 } else { 489 } else {
481 lnk.execute(); 490 lnk.execute();
482 } 491 }
483 } 492 }
484} 493}
485 494
486void Desktop::raiseDatebook() 495void Desktop::raiseDatebook()
487{ 496{
488 executeOrModify("Applications/datebook.desktop"); 497 Config cfg("qpe"); //F9 'Activity'
498 cfg.setGroup("AppsKey");
499 QString tempItem;
500 tempItem = cfg.readEntry("LeftEnd","Calender");
501 if(tempItem == "Calender" || tempItem.isEmpty()) executeOrModify("Applications/datebook.desktop");
502 else {
503 QCopEnvelope e("QPE/System","execute(QString)");
504 e << tempItem;
505 }
489} 506}
490 507
491void Desktop::raiseContacts() 508void Desktop::raiseContacts()
492{ 509{
493 executeOrModify("Applications/addressbook.desktop"); 510 Config cfg("qpe"); //F10, 'Contacts'
511 cfg.setGroup("AppsKey");
512 QString tempItem;
513 tempItem = cfg.readEntry("Left2nd","Address Book");
514 if(tempItem == "Address Book" || tempItem.isEmpty()) executeOrModify("Applications/addressbook.desktop");
515 else {
516 QCopEnvelope e("QPE/System","execute(QString)");
517 e << tempItem;
518 }
494} 519}
495 520
496void Desktop::raiseMenu() 521void Desktop::raiseMenu()
497{ 522{
523 Config cfg("qpe"); //F11, 'Menu'
524 cfg.setGroup("AppsKey");
525 QString tempItem;
526 tempItem = cfg.readEntry("Right2nd","Popup Menu");
527 if(tempItem == "Popup Menu" || tempItem.isEmpty()) {
498 Global::terminateBuiltin("calibrate"); 528 Global::terminateBuiltin("calibrate");
499 tb->startMenu()->launch(); 529 tb->startMenu()->launch();
530 } else {
531 QCopEnvelope e("QPE/System","execute(QString)");
532 e << tempItem;
533 }
500} 534}
501 535
502void Desktop::raiseEmail() 536void Desktop::raiseEmail()
503{ 537{
504 executeOrModify("Applications/qtmail.desktop"); 538 Config cfg("qpe"); //F13, 'Mail'
539 cfg.setGroup("AppsKey");
540 QString tempItem;
541 tempItem = cfg.readEntry("RightEnd","Mail");
542 if(tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty()) executeOrModify("Applications/qtmail.desktop");
543 else {
544 QCopEnvelope e("QPE/System","execute(QString)");
545 e << tempItem;
546 }
505} 547}
506 548
507// autoStarts apps on resume and start 549// autoStarts apps on resume and start
508void Desktop::execAutoStart() 550void Desktop::execAutoStart()
509{ 551{
510 QString appName; 552 QString appName;
511 Config cfg( "autostart" ); 553 Config cfg( "autostart" );
512 cfg.setGroup( "AutoStart" ); 554 cfg.setGroup( "AutoStart" );
@@ -604,76 +646,76 @@ void Desktop::styleChange( QStyle &s )
604 QSize sz = tb->sizeHint(); 646 QSize sz = tb->sizeHint();
605 647
606 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 648 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
607} 649}
608 650
609void DesktopApplication::shutdown() 651void DesktopApplication::shutdown()
610{ 652{
611 if ( type() != GuiServer ) 653 if ( type() != GuiServer )
612 return; 654 return;
613 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); 655 ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose );
614 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)), 656 connect( sd, SIGNAL(shutdown(ShutdownImpl::Type)),
615 this, SLOT(shutdown(ShutdownImpl::Type)) ); 657 this, SLOT(shutdown(ShutdownImpl::Type)) );
616 sd->showMaximized(); 658 sd->showMaximized();
617} 659}
618 660
619void DesktopApplication::shutdown( ShutdownImpl::Type t ) 661void DesktopApplication::shutdown( ShutdownImpl::Type t )
620{ 662{
621 switch ( t ) { 663 switch ( t ) {
622 case ShutdownImpl::ShutdownSystem: 664 case ShutdownImpl::ShutdownSystem:
623 execlp("shutdown", "shutdown", "-h", "now", (void*)0); 665 execlp("shutdown", "shutdown", "-h", "now", (void*)0);
624 break; 666 break;
625 case ShutdownImpl::RebootSystem: 667 case ShutdownImpl::RebootSystem:
626 execlp("shutdown", "shutdown", "-r", "now", (void*)0); 668 execlp("shutdown", "shutdown", "-r", "now", (void*)0);
627 break; 669 break;
628 case ShutdownImpl::RestartDesktop: 670 case ShutdownImpl::RestartDesktop:
629 restart(); 671 restart();
630 break; 672 break;
631 case ShutdownImpl::TerminateDesktop: 673 case ShutdownImpl::TerminateDesktop:
632 prepareForTermination(FALSE); 674 prepareForTermination(FALSE);
633 quit(); 675 quit();
634 break; 676 break;
635 } 677 }
636} 678}
637 679
638void DesktopApplication::restart() 680void DesktopApplication::restart()
639{ 681{
640 prepareForTermination(TRUE); 682 prepareForTermination(TRUE);
641 683
642#ifdef Q_WS_QWS 684#ifdef Q_WS_QWS
643 for ( int fd = 3; fd < 100; fd++ ) 685 for ( int fd = 3; fd < 100; fd++ )
644 close( fd ); 686 close( fd );
645#if defined(QT_DEMO_SINGLE_FLOPPY) 687#if defined(QT_DEMO_SINGLE_FLOPPY)
646 execl( "/sbin/init", "qpe", 0 ); 688 execl( "/sbin/init", "qpe", 0 );
647#elif defined(QT_QWS_CASSIOPEIA) 689#elif defined(QT_QWS_CASSIOPEIA)
648 execl( "/bin/sh", "sh", 0 ); 690 execl( "/bin/sh", "sh", 0 );
649#else 691#else
650 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 692 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
651#endif 693#endif
652 exit(1); 694 exit(1);
653#endif 695#endif
654} 696}
655 697
656void Desktop::startTransferServer() 698void Desktop::startTransferServer()
657{ 699{
658 // start qcop bridge server 700 // start qcop bridge server
659 qcopBridge = new QCopBridge( 4243 ); 701 qcopBridge = new QCopBridge( 4243 );
660 if ( !qcopBridge->ok() ) { 702 if ( !qcopBridge->ok() ) {
661 delete qcopBridge; 703 delete qcopBridge;
662 qcopBridge = 0; 704 qcopBridge = 0;
663 } 705 }
664 // start transfer server 706 // start transfer server
665 transferServer = new TransferServer( 4242 ); 707 transferServer = new TransferServer( 4242 );
666 if ( !transferServer->ok() ) { 708 if ( !transferServer->ok() ) {
667 delete transferServer; 709 delete transferServer;
668 transferServer = 0; 710 transferServer = 0;
669 } 711 }
670 if ( !transferServer || !qcopBridge ) 712 if ( !transferServer || !qcopBridge )
671 startTimer( 2000 ); 713 startTimer( 2000 );
672} 714}
673 715
674void Desktop::timerEvent( QTimerEvent *e ) 716void Desktop::timerEvent( QTimerEvent *e )
675{ 717{
676 killTimer( e->timerId() ); 718 killTimer( e->timerId() );
677 startTransferServer(); 719 startTransferServer();
678} 720}
679 721
@@ -692,43 +734,43 @@ void Desktop::rereadVolumes()
692 touchclick = cfg.readBoolEntry("Touch"); 734 touchclick = cfg.readBoolEntry("Touch");
693 keyclick = cfg.readBoolEntry("Key"); 735 keyclick = cfg.readBoolEntry("Key");
694} 736}
695 737
696void Desktop::keyClick() 738void Desktop::keyClick()
697{ 739{
698#ifdef CUSTOM_SOUND_KEYCLICK 740#ifdef CUSTOM_SOUND_KEYCLICK
699 if ( keyclick ) 741 if ( keyclick )
700 CUSTOM_SOUND_KEYCLICK; 742 CUSTOM_SOUND_KEYCLICK;
701#endif 743#endif
702} 744}
703 745
704void Desktop::screenClick() 746void Desktop::screenClick()
705{ 747{
706#ifdef CUSTOM_SOUND_TOUCH 748#ifdef CUSTOM_SOUND_TOUCH
707 if ( touchclick ) 749 if ( touchclick )
708 CUSTOM_SOUND_TOUCH; 750 CUSTOM_SOUND_TOUCH;
709#endif 751#endif
710} 752}
711 753
712void Desktop::soundAlarm() 754void Desktop::soundAlarm()
713{ 755{
714#ifdef CUSTOM_SOUND_ALARM 756#ifdef CUSTOM_SOUND_ALARM
715 CUSTOM_SOUND_ALARM; 757 CUSTOM_SOUND_ALARM;
716#endif 758#endif
717} 759}
718 760
719bool Desktop::eventFilter( QObject *w, QEvent *ev ) 761bool Desktop::eventFilter( QObject *w, QEvent *ev )
720{ 762{
721 if ( ev->type() == QEvent::KeyPress ) { 763 if ( ev->type() == QEvent::KeyPress ) {
722 QKeyEvent *ke = (QKeyEvent *)ev; 764 QKeyEvent *ke = (QKeyEvent *)ev;
723 if ( ke->key() == Qt::Key_F11 ) { // menu key 765 if ( ke->key() == Qt::Key_F11 ) { // menu key
724 QWidget *active = qApp->activeWindow(); 766 QWidget *active = qApp->activeWindow();
725 if ( active && active->isPopup() ) { 767 if ( active && active->isPopup() ) {
726 active->close(); 768 active->close();
727 } 769 }
728 raiseMenu(); 770 raiseMenu();
729 return TRUE; 771 return TRUE;
730 } 772 }
731 } 773 }
732 return FALSE; 774 return FALSE;
733} 775}
734 776