summaryrefslogtreecommitdiff
path: root/core/launcher/desktop.cpp
authorsandman <sandman>2002-12-23 00:07:32 (UTC)
committer sandman <sandman>2002-12-23 00:07:32 (UTC)
commit6f82a7bad0746d37ff1545717be3fe67e2eed17c (patch) (unidiff)
treeeaf5e6b6d7e7fcc648d25ae7021d1785b80122f2 /core/launcher/desktop.cpp
parentc513f413c7d901cc9945714c8e7eb47292f63306 (diff)
downloadopie-6f82a7bad0746d37ff1545717be3fe67e2eed17c.zip
opie-6f82a7bad0746d37ff1545717be3fe67e2eed17c.tar.gz
opie-6f82a7bad0746d37ff1545717be3fe67e2eed17c.tar.bz2
- ported the device button handling to the new ODevice based framework
- removed the key re-grabbing in runningsappbar (not necessary anymore) - added a few new QCops to make all "special" launcher functions available via qcop - added the devicebuttons to the opie-taskbar ipk
Diffstat (limited to 'core/launcher/desktop.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/desktop.cpp352
1 files changed, 144 insertions, 208 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index 6c67056..fa9736f 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -49,51 +49,52 @@
49#include <qgfx_qws.h> 49#include <qgfx_qws.h>
50#include <qmainwindow.h> 50#include <qmainwindow.h>
51#include <qmessagebox.h> 51#include <qmessagebox.h>
52#include <qtimer.h> 52#include <qtimer.h>
53#include <qwindowsystem_qws.h> 53#include <qwindowsystem_qws.h>
54 54
55#include <qvaluelist.h> 55#include <qvaluelist.h>
56 56
57#include <stdlib.h> 57#include <stdlib.h>
58#include <unistd.h> 58#include <unistd.h>
59#include <fcntl.h> 59#include <fcntl.h>
60 60
61
61using namespace Opie; 62using namespace Opie;
62 63
63class QCopKeyRegister 64class QCopKeyRegister
64{ 65{
65public: 66public:
66 QCopKeyRegister() : keyCode( 0 ) 67 QCopKeyRegister() : keyCode( 0 )
67 { } 68 { }
68 QCopKeyRegister( int k, const QString &c, const QString &m ) 69 QCopKeyRegister( int k, const QCString &c, const QCString &m )
69 : keyCode( k ), channel( c ), message( m ) 70 : keyCode( k ), channel( c ), message( m )
70 { } 71 { }
71 72
72 int getKeyCode() const 73 int getKeyCode() const
73 { 74 {
74 return keyCode; 75 return keyCode;
75 } 76 }
76 QString getChannel() const 77 QCString getChannel() const
77 { 78 {
78 return channel; 79 return channel;
79 } 80 }
80 QString getMessage() const 81 QCString getMessage() const
81 { 82 {
82 return message; 83 return message;
83 } 84 }
84 85
85private: 86private:
86 int keyCode; 87 int keyCode;
87 QString channel, message; 88 QCString channel, message;
88}; 89};
89 90
90typedef QValueList<QCopKeyRegister> KeyRegisterList; 91typedef QValueList<QCopKeyRegister> KeyRegisterList;
91KeyRegisterList keyRegisterList; 92KeyRegisterList keyRegisterList;
92 93
93static Desktop* qpedesktop = 0; 94static Desktop* qpedesktop = 0;
94static int loggedin = 0; 95static int loggedin = 0;
95static void login( bool at_poweron ) 96static void login( bool at_poweron )
96{ 97{
97 if ( !loggedin ) { 98 if ( !loggedin ) {
98 Global::terminateBuiltin( "calibrate" ); 99 Global::terminateBuiltin( "calibrate" );
99 Password::authenticate( at_poweron ); 100 Password::authenticate( at_poweron );
@@ -180,42 +181,53 @@ DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType )
180 //cfg.readNumEntry( "checkinterval", 10000 ) 181 //cfg.readNumEntry( "checkinterval", 10000 )
181 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); 182 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
182 m_powerCritical = cfg.readNumEntry( "powercritical", 5 ); 183 m_powerCritical = cfg.readNumEntry( "powercritical", 5 );
183 184
184 m_ps = new PowerStatus; 185 m_ps = new PowerStatus;
185 m_ps_last = new PowerStatus; 186 m_ps_last = new PowerStatus;
186 pa = new DesktopPowerAlerter( 0 ); 187 pa = new DesktopPowerAlerter( 0 );
187 188
188 m_timer = new QTimer( this ); 189 m_timer = new QTimer( this );
189 connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) ); 190 connect( m_timer, SIGNAL( timeout() ), this, SLOT( apmTimeout() ) );
190 m_timer->start( 5000 ); 191 m_timer->start( 5000 );
191 192
192 channel = new QCopChannel( "QPE/Desktop", this ); 193 m_last_button = 0;
193 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 194 m_button_timer = new QTimer ( );
194 this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); 195 connect ( m_button_timer, SIGNAL( timeout ( )), this, SLOT( sendHeldAction ( )));
195 196
196 channel = new QCopChannel( "QPE/System", this ); 197 channel = new QCopChannel( "QPE/System", this );
197 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), 198 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
198 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); 199 this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) );
199 200
201 channel = new QCopChannel( "QPE/Launcher", this );
202 connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ),
203 this, SLOT( launcherMessage( const QCString&, const QByteArray& ) ) );
204
200 m_screensaver = new OpieScreenSaver ( ); 205 m_screensaver = new OpieScreenSaver ( );
201 m_screensaver-> setInterval ( -1 ); 206 m_screensaver-> setInterval ( -1 );
202 QWSServer::setScreenSaver( m_screensaver ); 207 QWSServer::setScreenSaver( m_screensaver );
203 208
209 rereadVolumes();
210 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
211
204 apmTimeout ( ); 212 apmTimeout ( );
213
214 grabKeyboard ( );
205} 215}
206 216
207 217
208DesktopApplication::~DesktopApplication() 218DesktopApplication::~DesktopApplication()
209{ 219{
220 ungrabKeyboard ( );
221
210 delete m_ps; 222 delete m_ps;
211 delete m_ps_last; 223 delete m_ps_last;
212 delete pa; 224 delete pa;
213} 225}
214 226
215void DesktopApplication::apmTimeout() 227void DesktopApplication::apmTimeout()
216{ 228{
217 qpedesktop->checkMemory(); // in case no events are being generated 229 qpedesktop->checkMemory(); // in case no events are being generated
218 230
219 *m_ps_last = *m_ps; 231 *m_ps_last = *m_ps;
220 *m_ps = PowerStatusManager::readStatus(); 232 *m_ps = PowerStatusManager::readStatus();
221 233
@@ -227,39 +239,24 @@ void DesktopApplication::apmTimeout()
227 239
228 if ( bat < m_ps_last-> batteryPercentRemaining ( )) { 240 if ( bat < m_ps_last-> batteryPercentRemaining ( )) {
229 if ( bat <= m_powerCritical ) 241 if ( bat <= m_powerCritical )
230 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 ); 242 pa->alert( tr( "Battery level is critical!\nKeep power off until power restored!" ), 1 );
231 else if ( bat <= m_powerVeryLow ) 243 else if ( bat <= m_powerVeryLow )
232 pa->alert( tr( "Battery is running very low." ), 2 ); 244 pa->alert( tr( "Battery is running very low." ), 2 );
233 } 245 }
234 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow ) 246 if ( m_ps-> backupBatteryStatus ( ) == PowerStatus::VeryLow )
235 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 ); 247 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 2 );
236 } 248 }
237} 249}
238 250
239void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data )
240{
241 QDataStream stream( data, IO_ReadOnly );
242 if ( msg == "keyRegister(int key, QString channel, QString message)" ) {
243 int k;
244 QString c, m;
245 stream >> k;
246 stream >> c;
247 stream >> m;
248
249 qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m );
250 keyRegisterList.append( QCopKeyRegister( k, c, m ) );
251 }
252}
253
254 251
255void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) 252void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data )
256{ 253{
257 QDataStream stream ( data, IO_ReadOnly ); 254 QDataStream stream ( data, IO_ReadOnly );
258 255
259 if ( msg == "setScreenSaverInterval(int)" ) { 256 if ( msg == "setScreenSaverInterval(int)" ) {
260 int time; 257 int time;
261 stream >> time; 258 stream >> time;
262 m_screensaver-> setInterval( time ); 259 m_screensaver-> setInterval( time );
263 } 260 }
264 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 261 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
265 int t1, t2, t3; 262 int t1, t2, t3;
@@ -278,180 +275,203 @@ void DesktopApplication::systemMessage( const QCString & msg, const QByteArray &
278 } 275 }
279 else if ( msg == "reloadPowerWarnSettings()" ) { 276 else if ( msg == "reloadPowerWarnSettings()" ) {
280 reloadPowerWarnSettings(); 277 reloadPowerWarnSettings();
281 } 278 }
282 else if ( msg == "setDisplayState(int)" ) { 279 else if ( msg == "setDisplayState(int)" ) {
283 int state; 280 int state;
284 stream >> state; 281 stream >> state;
285 m_screensaver-> setDisplayState ( state != 0 ); 282 m_screensaver-> setDisplayState ( state != 0 );
286 } 283 }
287 else if ( msg == "suspend()" ) { 284 else if ( msg == "suspend()" ) {
288 emit power(); 285 emit power();
289 } 286 }
287 else if ( msg == "sendBusinessCard()" ) {
288 QString card = ::getenv ( "HOME" );
289 card += "/Applications/addressbook/businesscard.vcf";
290
291 if ( QFile::exists( card ) ) {
292 QCopEnvelope e ( "QPE/Obex", "send(QString,QString,QString)" );
293 QString mimetype = "text/x-vCard";
294 e << tr( "business card" ) << card << mimetype;
295 }
296 }
290} 297}
291 298
292void DesktopApplication::reloadPowerWarnSettings() { 299void DesktopApplication::reloadPowerWarnSettings()
300{
293 Config cfg( "apm" ); 301 Config cfg( "apm" );
294 cfg.setGroup( "Warnings" ); 302 cfg.setGroup( "Warnings" );
295 303
296 // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) ); 304 // m_timer->changeInterval( cfg.readNumEntry( "checkinterval", 10000 ) );
297 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 ); 305 m_powerVeryLow = cfg.readNumEntry( "powerverylow", 10 );
298 m_powerCritical = cfg.readNumEntry( "powervcritical", 5 ); 306 m_powerCritical = cfg.readNumEntry( "powervcritical", 5 );
299} 307}
300 308
301 309
302enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; 310enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown;
303 311
304#ifdef Q_WS_QWS 312
305bool DesktopApplication::qwsEventFilter( QWSEvent *e ) 313void DesktopApplication::launcherMessage( const QCString & msg, const QByteArray & data )
306{ 314{
307 qpedesktop->checkMemory(); 315 QDataStream stream ( data, IO_ReadOnly );
308 316
309 if ( e->type == QWSEvent::Key ) { 317 if ( msg == "deviceButton(int,int,int)" ) {
310 QWSKeyEvent * ke = ( QWSKeyEvent * ) e; 318 int keycode, press, autoRepeat;
311 if ( !loggedin && ke->simpleData.keycode != Key_F34 ) 319 stream >> keycode >> press >> autoRepeat;
312 return TRUE;
313 bool press = ke->simpleData.is_press;
314 bool autoRepeat = ke->simpleData.is_auto_repeat;
315 320
316 /* 321 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( keycode );
317 app that registers key/message to be sent back to the app, when it doesn't have focus, 322
318 when user presses key, unless keyboard has been requested from app. 323 if ( db )
319 will not send multiple repeats if user holds key 324 checkButtonAction ( db, keycode, press, autoRepeat );
320 i.e. one shot
321 */
322 if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) {
323// qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode);
324 KeyRegisterList::Iterator it;
325 for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
326 if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) {
327 if ( press )
328 qDebug( "press" );
329 else
330 qDebug( "release" );
331 QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() );
332 } 325 }
326 else if ( msg == "keyRegister(int,QCString,QCString)" ) {
327 int k;
328 QCString c, m;
329 stream >> k >> c >> m;
330
331 keyRegisterList.append ( QCopKeyRegister ( k, c, m ));
333 } 332 }
334 } 333 }
335 334
336 if ( !keyboardGrabbed() ) { 335void DesktopApplication::sendHeldAction ( )
337 if ( ke->simpleData.keycode == Key_F9 ) { 336{
338 if ( press ) 337 if ( m_last_button ) {
339 emit datebook(); 338 m_last_button-> heldAction ( ). send ( );
340 return TRUE; 339 m_last_button = 0;
341 } 340 }
342 if ( ke->simpleData.keycode == Key_F10 ) {
343 if ( !press && cardSendTimer ) {
344 emit contacts();
345 delete cardSendTimer;
346 } 341 }
347 else if ( press ) { 342
348 cardSendTimer = new QTimer(); 343
349 cardSendTimer->start( 2000, TRUE ); 344
350 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 345void DesktopApplication::checkButtonAction ( const ODeviceButton *db, int keycode, bool press, bool autoRepeat )
346 {
347 if ( db ) {
348 if ( !press && !autoRepeat && m_button_timer-> isActive ( )) {
349 m_button_timer-> stop ( );
350 if ( !db-> pressedAction ( ). channel ( ). isEmpty ( )) {
351 db-> pressedAction ( ). send ( );
351 } 352 }
352 return TRUE;
353 } 353 }
354 else if ( press && !autoRepeat ) {
355 m_button_timer-> stop ( );
354 356
355 if ( ke->simpleData.keycode == Key_F11 ) { 357 if ( !db-> heldAction ( ). channel ( ). isEmpty ( )) {
356 if ( press ) emit menu(); 358 m_last_button = db;
357 return TRUE; 359 m_button_timer-> start ( ODevice::inst ( )-> buttonHoldTime ( ), true );
360 }
361 }
362 }
358 } 363 }
359 364
360 if ( ke->simpleData.keycode == Key_F12 ) { 365bool DesktopApplication::eventFilter ( QObject *o, QEvent *e )
361 while ( activePopupWidget() ) 366{
362 activePopupWidget() ->close(); 367 if ( e-> type ( ) == QEvent::KeyPress || e-> type ( ) == QEvent::KeyRelease ) {
363 if ( press ) 368 QKeyEvent *ke = (QKeyEvent *) e;
364 emit launch(); 369
365 return TRUE; 370 const ODeviceButton *db = ODevice::inst ( )-> buttonForKeycode ( ke-> key ( ));
371
372 if ( db ) {
373 checkButtonAction ( db, ke-> key ( ), e-> type ( ) == QEvent::KeyPress, ke-> isAutoRepeat ( ));
374 return true;
375 }
376 }
377 return QPEApplication::eventFilter ( o, e );
378}
379
380#ifdef Q_WS_QWS
381
382bool DesktopApplication::qwsEventFilter( QWSEvent *e )
383{
384 qpedesktop->checkMemory();
385
386 if ( e->type == QWSEvent::Key ) {
387 QWSKeyEvent * ke = (QWSKeyEvent *) e;
388 ushort keycode = ke-> simpleData. keycode;
389
390 if ( !loggedin && keycode != Key_F34 )
391 return true;
392
393 bool press = ke-> simpleData. is_press;
394 bool autoRepeat = ke-> simpleData. is_auto_repeat;
395
396 if ( !keyboardGrabbed ( )) {
397 // app that registers key/message to be sent back to the app, when it doesn't have focus,
398 // when user presses key, unless keyboard has been requested from app.
399 // will not send multiple repeats if user holds key
400 // i.e. one shot
401
402 if ( keycode != 0 && press && !autoRepeat ) {
403 for ( KeyRegisterList::Iterator it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) {
404 if (( *it ). getKeyCode ( ) == keycode ) {
405 QCopEnvelope (( *it ). getChannel ( ), ( *it ). getMessage ( ));
406 return true;
407 }
366 } 408 }
367 if ( ke->simpleData.keycode == Key_F13 ) {
368 if ( press )
369 emit email();
370 return TRUE;
371 } 409 }
372 } 410 }
373 411
374 if ( ke->simpleData.keycode == Key_F34 ) { 412 if ( keycode == HardKey_Suspend ) {
375 if ( press ) 413 if ( press )
376 emit power(); 414 emit power();
377 return TRUE; 415 return true;
378 } 416 }
379 // This was used for the iPAQ PowerButton 417 else if ( keycode == HardKey_Backlight ) {
380 // See main.cpp for new KeyboardFilter
381 //
382 // if ( ke->simpleData.keycode == Key_SysReq ) {
383 // if ( press ) emit power();
384 // return TRUE;
385 // }
386 if ( ke->simpleData.keycode == Key_F35 ) {
387 if ( press ) 418 if ( press )
388 emit backlight(); 419 emit backlight();
389 return TRUE; 420 return true;
390 } 421 }
391 if ( ke->simpleData.keycode == Key_F32 ) { 422 else if ( keycode == Key_F32 ) {
392 if ( press ) 423 if ( press )
393 QCopEnvelope e( "QPE/Desktop", "startSync()" ); 424 QCopEnvelope e( "QPE/Desktop", "startSync()" );
394 return TRUE; 425 return true;
395 } 426 }
396 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 427 else if ( keycode == Key_F31 && !ke-> simpleData. modifiers ) { // Symbol Key -> show Unicode IM
397 if ( press ) 428 if ( press )
398 emit symbol(); 429 emit symbol();
399 return TRUE; 430 return true;
400 } 431 }
401 if ( ke->simpleData.keycode == Key_NumLock ) { 432 else if ( keycode == Key_NumLock ) {
402 if ( press ) 433 if ( press )
403 emit numLockStateToggle(); 434 emit numLockStateToggle();
404 } 435 }
405 if ( ke->simpleData.keycode == Key_CapsLock ) { 436 else if ( keycode == Key_CapsLock ) {
406 if ( press ) 437 if ( press )
407 emit capsLockStateToggle(); 438 emit capsLockStateToggle();
408 } 439 }
409 if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) 440 if (( press && !autoRepeat ) || ( !press && autoRepeat )) {
410 qpedesktop->keyClick(); 441 if ( m_keyclick_sound )
442 ODevice::inst ( )-> keySound ( );
411 } 443 }
412 else { 444 }
413 if ( e->type == QWSEvent::Mouse ) { 445 else if ( e-> type == QWSEvent::Mouse ) {
414 QWSMouseEvent * me = ( QWSMouseEvent * ) e; 446 QWSMouseEvent * me = ( QWSMouseEvent * ) e;
415 static bool up = TRUE; 447 static bool up = true;
448
416 if ( me->simpleData.state & LeftButton ) { 449 if ( me->simpleData.state & LeftButton ) {
417 if ( up ) { 450 if ( up ) {
418 up = FALSE; 451 up = false;
419 qpedesktop->screenClick(); 452 if ( m_screentap_sound )
453 ODevice::inst ( ) -> touchSound ( );
420 } 454 }
421 } 455 }
422 else { 456 else {
423 up = TRUE; 457 up = true;
424 }
425 } 458 }
426 } 459 }
427 460
428 return QPEApplication::qwsEventFilter( e ); 461 return QPEApplication::qwsEventFilter( e );
429} 462}
430#endif 463#endif
431 464
432 465
433void DesktopApplication::sendCard()
434{
435 delete cardSendTimer;
436 cardSendTimer = 0;
437 QString card = getenv( "HOME" );
438 card += "/Applications/addressbook/businesscard.vcf";
439
440 if ( QFile::exists( card ) ) {
441 QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" );
442 QString mimetype = "text/x-vCard";
443 e << tr( "business card" ) << card << mimetype;
444 }
445}
446 466
447#if defined(QPE_HAVE_MEMALERTER) 467#if defined(QPE_HAVE_MEMALERTER)
448QPE_MEMALERTER_IMPL 468QPE_MEMALERTER_IMPL
449#endif 469#endif
450 470
451//=========================================================================== 471//===========================================================================
452 472
453Desktop::Desktop() : 473Desktop::Desktop() :
454 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 474 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
455 qcopBridge( 0 ), 475 qcopBridge( 0 ),
456 transferServer( 0 ), 476 transferServer( 0 ),
457 packageSlave( 0 ) 477 packageSlave( 0 )
@@ -477,28 +497,26 @@ Desktop::Desktop() :
477 497
478 tb->show(); 498 tb->show();
479 launcher->showMaximized(); 499 launcher->showMaximized();
480 launcher->show(); 500 launcher->show();
481 launcher->raise(); 501 launcher->raise();
482#if defined(QPE_HAVE_MEMALERTER) 502#if defined(QPE_HAVE_MEMALERTER)
483 503
484 initMemalerter(); 504 initMemalerter();
485#endif 505#endif
486 // start services 506 // start services
487 startTransferServer(); 507 startTransferServer();
488 ( void ) new IrServer( this ); 508 ( void ) new IrServer( this );
489 rereadVolumes();
490 509
491 packageSlave = new PackageSlave( this ); 510 packageSlave = new PackageSlave( this );
492 connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) );
493 511
494 qApp->installEventFilter( this ); 512 qApp->installEventFilter( this );
495 513
496 qApp-> setMainWidget ( launcher ); 514 qApp-> setMainWidget ( launcher );
497} 515}
498 516
499void Desktop::show() 517void Desktop::show()
500{ 518{
501 login( TRUE ); 519 login( TRUE );
502 QWidget::show(); 520 QWidget::show();
503} 521}
504 522
@@ -574,121 +592,44 @@ static bool hasVisibleWindow( const QString& clientname )
574{ 592{
575#ifdef QWS 593#ifdef QWS
576 const QList<QWSWindow> &list = qwsServer->clientWindows(); 594 const QList<QWSWindow> &list = qwsServer->clientWindows();
577 QWSWindow* w; 595 QWSWindow* w;
578 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { 596 for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) {
579 if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) 597 if ( w->client() ->identity() == clientname && !w->isFullyObscured() )
580 return TRUE; 598 return TRUE;
581 } 599 }
582#endif 600#endif
583 return FALSE; 601 return FALSE;
584} 602}
585 603
586void Desktop::raiseLauncher()
587{
588 Config cfg( "qpe" ); //F12 'Home'
589 cfg.setGroup( "AppsKey" );
590 QString tempItem;
591 tempItem = cfg.readEntry( "Middle", "Home" );
592 if ( tempItem == "Home" || tempItem.isEmpty() ) {
593 home ( );
594 }
595 else {
596 QCopEnvelope e( "QPE/System", "execute(QString)" );
597 e << tempItem;
598 }
599}
600
601void Desktop::home ( )
602{
603 if ( isVisibleWindow( launcher->winId() ) )
604 launcher->nextView();
605 else
606 launcher->raise();
607}
608 604
609void Desktop::executeOrModify( const QString& appLnkFile ) 605void Desktop::executeOrModify( const QString& appLnkFile )
610{ 606{
611 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); 607 AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile );
612 if ( lnk.isValid() ) { 608 if ( lnk.isValid() ) {
613 QCString app = lnk.exec().utf8(); 609 QCString app = lnk.exec().utf8();
614 Global::terminateBuiltin( "calibrate" ); 610 Global::terminateBuiltin( "calibrate" );
615 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { 611 if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) {
616 // MRUList::addTask( &lnk ); 612 // MRUList::addTask( &lnk );
617 if ( hasVisibleWindow( app ) ) 613 if ( hasVisibleWindow( app ) )
618 QCopChannel::send( "QPE/Application/" + app, "nextView()" ); 614 QCopChannel::send( "QPE/Application/" + app, "nextView()" );
619 else 615 else
620 QCopChannel::send( "QPE/Application/" + app, "raise()" ); 616 QCopChannel::send( "QPE/Application/" + app, "raise()" );
621 } 617 }
622 else { 618 else {
623 lnk.execute(); 619 lnk.execute();
624 } 620 }
625 } 621 }
626} 622}
627 623
628void Desktop::raiseDatebook()
629{
630 Config cfg( "qpe" ); //F9 'Activity'
631 cfg.setGroup( "AppsKey" );
632 QString tempItem;
633 tempItem = cfg.readEntry( "LeftEnd" , "Calendar" );
634 if ( tempItem == "Calendar" || tempItem.isEmpty() ) {
635 tempItem = "datebook";
636 }
637 QCopEnvelope e( "QPE/System", "execute(QString)" );
638 e << tempItem;
639}
640
641void Desktop::raiseContacts()
642{
643 Config cfg( "qpe" ); //F10, 'Contacts'
644 cfg.setGroup( "AppsKey" );
645 QString tempItem;
646 tempItem = cfg.readEntry( "Left2nd", "Address Book" );
647 if ( tempItem == "Address Book" || tempItem.isEmpty() ) {
648 tempItem = "addressbook";
649 }
650 QCopEnvelope e( "QPE/System", "execute(QString)" );
651 e << tempItem;
652}
653
654void Desktop::raiseMenu()
655{
656 Config cfg( "qpe" ); //F11, 'Menu
657 cfg.setGroup( "AppsKey" );
658 QString tempItem;
659 tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" );
660 if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) {
661 Global::terminateBuiltin( "calibrate" );
662 tb->startMenu() ->launch();
663 }
664 else {
665 QCopEnvelope e( "QPE/System", "execute(QString)" );
666 e << tempItem;
667 }
668}
669
670void Desktop::raiseEmail()
671{
672 Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11
673 cfg.setGroup( "AppsKey" );
674 QString tempItem;
675 tempItem = cfg.readEntry( "RightEnd", "Mail" );
676 if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) {
677 tempItem = "mail";
678 }
679 QCopEnvelope e( "QPE/System", "execute(QString)" );
680 e << tempItem;
681}
682
683// autoStarts apps on resume and start 624// autoStarts apps on resume and start
684void Desktop::execAutoStart() 625void Desktop::execAutoStart()
685{ 626{
686 QString appName; 627 QString appName;
687 int delay; 628 int delay;
688 QDateTime now = QDateTime::currentDateTime(); 629 QDateTime now = QDateTime::currentDateTime();
689 Config cfg( "autostart" ); 630 Config cfg( "autostart" );
690 cfg.setGroup( "AutoStart" ); 631 cfg.setGroup( "AutoStart" );
691 appName = cfg.readEntry( "Apps", "" ); 632 appName = cfg.readEntry( "Apps", "" );
692 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); 633 delay = ( cfg.readEntry( "Delay", "0" ) ).toInt();
693 // If the time between suspend and resume was longer then the 634 // If the time between suspend and resume was longer then the
694 // value saved as delay, start the app 635 // value saved as delay, start the app
@@ -718,24 +659,25 @@ void Desktop::togglePower()
718 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); 659 qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 );
719 660
720 if ( excllock ) 661 if ( excllock )
721 return; 662 return;
722 663
723 excllock = true; 664 excllock = true;
724 665
725 bool wasloggedin = loggedin; 666 bool wasloggedin = loggedin;
726 loggedin = 0; 667 loggedin = 0;
727 suspendTime = QDateTime::currentDateTime(); 668 suspendTime = QDateTime::currentDateTime();
728 669
729#ifdef QWS 670#ifdef QWS
671
730 if ( Password::needToAuthenticate ( true ) && qt_screen ) { 672 if ( Password::needToAuthenticate ( true ) && qt_screen ) {
731 // Should use a big black window instead. 673 // Should use a big black window instead.
732 // But this would not show up fast enough 674 // But this would not show up fast enough
733 QGfx *g = qt_screen-> screenGfx ( ); 675 QGfx *g = qt_screen-> screenGfx ( );
734 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); 676 g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( ));
735 delete g; 677 delete g;
736 } 678 }
737#endif 679#endif
738 680
739 ODevice::inst ( )-> suspend ( ); 681 ODevice::inst ( )-> suspend ( );
740 682
741 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call 683 DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call
@@ -867,39 +809,33 @@ void Desktop::timerEvent( QTimerEvent *e )
867 killTimer( e->timerId() ); 809 killTimer( e->timerId() );
868 startTransferServer(); 810 startTransferServer();
869} 811}
870 812
871void Desktop::terminateServers() 813void Desktop::terminateServers()
872{ 814{
873 delete transferServer; 815 delete transferServer;
874 delete qcopBridge; 816 delete qcopBridge;
875 transferServer = 0; 817 transferServer = 0;
876 qcopBridge = 0; 818 qcopBridge = 0;
877} 819}
878 820
879void Desktop::rereadVolumes() 821void DesktopApplication::rereadVolumes()
880{ 822{
881 Config cfg( "qpe" ); 823 Config cfg( "qpe" );
882 cfg.setGroup( "Volume" ); 824 cfg.setGroup( "Volume" );
883 touchclick = cfg.readBoolEntry( "TouchSound" );
884 keyclick = cfg.readBoolEntry( "KeySound" );
885 alarmsound = cfg.readBoolEntry( "AlarmSound" );
886}
887 825
888void Desktop::keyClick() 826 m_screentap_sound = cfg. readBoolEntry ( "TouchSound" );
889{ 827 m_keyclick_sound = cfg. readBoolEntry ( "KeySound" );
890 if ( keyclick ) 828 m_alarm_sound = cfg. readBoolEntry ( "AlarmSound" );
891 ODevice::inst ( ) -> keySound ( );
892} 829}
893 830
894void Desktop::screenClick() 831void DesktopApplication::soundAlarm()
895{ 832{
896 if ( touchclick ) 833 if ( me ( )-> m_alarm_sound )
897 ODevice::inst ( ) -> touchSound ( ); 834 ODevice::inst ( )-> alarmSound ( );
898} 835}
899 836
900void Desktop::soundAlarm() 837DesktopApplication *DesktopApplication::me ( )
901{ 838{
902 if ( qpedesktop-> alarmsound ) 839 return (DesktopApplication *) qApp;
903 ODevice::inst ( ) -> alarmSound ( );
904} 840}
905 841