summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp58
-rw-r--r--core/launcher/main.cpp13
-rw-r--r--core/launcher/taskbar.cpp47
-rw-r--r--core/launcher/taskbar.h4
4 files changed, 53 insertions, 69 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp
index ab4f14a..7662e48 100644
--- a/core/launcher/desktop.cpp
+++ b/core/launcher/desktop.cpp
@@ -1,109 +1,111 @@
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>
47
46#include <qgfx_qws.h> 48#include <qgfx_qws.h>
47#include <qmainwindow.h> 49#include <qmainwindow.h>
48#include <qmessagebox.h> 50#include <qmessagebox.h>
49#include <qtimer.h> 51#include <qtimer.h>
50#include <qwindowsystem_qws.h> 52#include <qwindowsystem_qws.h>
51 53
52#include <qvaluelist.h> 54#include <qvaluelist.h>
53 55
54#include <stdlib.h> 56#include <stdlib.h>
55#include <unistd.h> 57#include <unistd.h>
56 58
57class QCopKeyRegister 59class QCopKeyRegister
58{ 60{
59public: 61public:
60 QCopKeyRegister() : keyCode(0) { } 62 QCopKeyRegister() : keyCode(0) { }
61 QCopKeyRegister(int k, const QString &c, const QString &m) 63 QCopKeyRegister(int k, const QString &c, const QString &m)
62 : keyCode(k), channel(c), message(m) { } 64 : keyCode(k), channel(c), message(m) { }
63 65
64 int getKeyCode() const { return keyCode; } 66 int getKeyCode() const { return keyCode; }
65 QString getChannel() const { return channel; } 67 QString getChannel() const { return channel; }
66 QString getMessage() const { return message; } 68 QString getMessage() const { return message; }
67 69
68private: 70private:
69 int keyCode; 71 int keyCode;
70 QString channel, message; 72 QString channel, message;
71}; 73};
72 74
73typedef QValueList<QCopKeyRegister> KeyRegisterList; 75typedef QValueList<QCopKeyRegister> KeyRegisterList;
74KeyRegisterList keyRegisterList; 76KeyRegisterList keyRegisterList;
75 77
76static Desktop* qpedesktop = 0; 78static Desktop* qpedesktop = 0;
77static int loggedin=0; 79static int loggedin=0;
78static void login(bool at_poweron) 80static void login(bool at_poweron)
79{ 81{
80 if ( !loggedin ) { 82 if ( !loggedin ) {
81 Global::terminateBuiltin("calibrate"); 83 Global::terminateBuiltin("calibrate");
82 Password::authenticate(at_poweron); 84 Password::authenticate(at_poweron);
83 loggedin=1; 85 loggedin=1;
84 QCopEnvelope e( "QPE/Desktop", "unlocked()" ); 86 QCopEnvelope e( "QPE/Desktop", "unlocked()" );
85 } 87 }
86} 88}
87 89
88bool Desktop::screenLocked() 90bool Desktop::screenLocked()
89{ 91{
90 return loggedin == 0; 92 return loggedin == 0;
91} 93}
92 94
93/* 95/*
94 Priority is number of alerts that are needed to pop up 96 Priority is number of alerts that are needed to pop up
95 alert. 97 alert.
96 */ 98 */
97class DesktopPowerAlerter : public QMessageBox 99class DesktopPowerAlerter : public QMessageBox
98{ 100{
99public: 101public:
100 DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) 102 DesktopPowerAlerter( QWidget *parent, const char *name = 0 )
101 : QMessageBox( tr("Battery Status"), "Low Battery", 103 : QMessageBox( tr("Battery Status"), "Low Battery",
102 QMessageBox::Critical, 104 QMessageBox::Critical,
103 QMessageBox::Ok | QMessageBox::Default, 105 QMessageBox::Ok | QMessageBox::Default,
104 QMessageBox::NoButton, QMessageBox::NoButton, 106 QMessageBox::NoButton, QMessageBox::NoButton,
105 parent, name, FALSE ) 107 parent, name, FALSE )
106 { 108 {
107 currentPriority = INT_MAX; 109 currentPriority = INT_MAX;
108 alertCount = 0; 110 alertCount = 0;
109 } 111 }
@@ -206,204 +208,196 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
206 208
207 if ( !keyboardGrabbed() ) { 209 if ( !keyboardGrabbed() ) {
208 if ( ke->simpleData.keycode == Key_F9 ) { 210 if ( ke->simpleData.keycode == Key_F9 ) {
209 if ( press ) emit datebook(); 211 if ( press ) emit datebook();
210 return TRUE; 212 return TRUE;
211 } 213 }
212 if ( ke->simpleData.keycode == Key_F10 ) { 214 if ( ke->simpleData.keycode == Key_F10 ) {
213 if ( !press && cardSendTimer ) { 215 if ( !press && cardSendTimer ) {
214 emit contacts(); 216 emit contacts();
215 delete cardSendTimer; 217 delete cardSendTimer;
216 } else if ( press ) { 218 } else if ( press ) {
217 cardSendTimer = new QTimer(); 219 cardSendTimer = new QTimer();
218 cardSendTimer->start( 2000, TRUE ); 220 cardSendTimer->start( 2000, TRUE );
219 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); 221 connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) );
220 } 222 }
221 return TRUE; 223 return TRUE;
222 } 224 }
223 /* menu key now opens application menu/toolbar 225 /* menu key now opens application menu/toolbar
224 if ( ke->simpleData.keycode == Key_F11 ) { 226 if ( ke->simpleData.keycode == Key_F11 ) {
225 if ( press ) emit menu(); 227 if ( press ) emit menu();
226 return TRUE; 228 return TRUE;
227 } 229 }
228 */ 230 */
229 if ( ke->simpleData.keycode == Key_F12 ) { 231 if ( ke->simpleData.keycode == Key_F12 ) {
230 while( activePopupWidget() ) 232 while( activePopupWidget() )
231 activePopupWidget()->close(); 233 activePopupWidget()->close();
232 if ( press ) emit launch(); 234 if ( press ) emit launch();
233 return TRUE; 235 return TRUE;
234 } 236 }
235 if ( ke->simpleData.keycode == Key_F13 ) { 237 if ( ke->simpleData.keycode == Key_F13 ) {
236 if ( press ) emit email(); 238 if ( press ) emit email();
237 return TRUE; 239 return TRUE;
238 } 240 }
239 } 241 }
240 242
241 if ( ke->simpleData.keycode == Key_F34 ) { 243 if ( ke->simpleData.keycode == Key_F34 ) {
242 if ( press ) emit power(); 244 if ( press ) emit power();
243 return TRUE; 245 return TRUE;
244 } 246 }
245// This was used for the iPAQ PowerButton 247// This was used for the iPAQ PowerButton
246// See main.cpp for new KeyboardFilter 248// See main.cpp for new KeyboardFilter
247// 249//
248// if ( ke->simpleData.keycode == Key_SysReq ) { 250// if ( ke->simpleData.keycode == Key_SysReq ) {
249// if ( press ) emit power(); 251// if ( press ) emit power();
250// return TRUE; 252// return TRUE;
251// } 253// }
252 if ( ke->simpleData.keycode == Key_F35 ) { 254 if ( ke->simpleData.keycode == Key_F35 ) {
253 if ( press ) emit backlight(); 255 if ( press ) emit backlight();
254 return TRUE; 256 return TRUE;
255 } 257 }
256 if ( ke->simpleData.keycode == Key_F32 ) { 258 if ( ke->simpleData.keycode == Key_F32 ) {
257 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 259 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
258 return TRUE; 260 return TRUE;
259 } 261 }
260 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 262 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
261 if ( press ) emit symbol(); 263 if ( press ) emit symbol();
262 return TRUE; 264 return TRUE;
263 } 265 }
264 if ( ke->simpleData.keycode == Key_NumLock ) { 266 if ( ke->simpleData.keycode == Key_NumLock ) {
265 if ( press ) emit numLockStateToggle(); 267 if ( press ) emit numLockStateToggle();
266 } 268 }
267 if ( ke->simpleData.keycode == Key_CapsLock ) { 269 if ( ke->simpleData.keycode == Key_CapsLock ) {
268 if ( press ) emit capsLockStateToggle(); 270 if ( press ) emit capsLockStateToggle();
269 } 271 }
270 if ( press ) 272 if (( press && !autoRepeat ) || ( !press && autoRepeat ))
271 qpedesktop->keyClick(); 273 qpedesktop->keyClick();
272 } else { 274 } else {
273 if ( e->type == QWSEvent::Mouse ) { 275 if ( e->type == QWSEvent::Mouse ) {
274 QWSMouseEvent *me = (QWSMouseEvent *)e; 276 QWSMouseEvent *me = (QWSMouseEvent *)e;
275 static bool up = TRUE; 277 static bool up = TRUE;
276 if ( me->simpleData.state&LeftButton ) { 278 if ( me->simpleData.state&LeftButton ) {
277 if ( up ) { 279 if ( up ) {
278 up = FALSE; 280 up = FALSE;
279 qpedesktop->screenClick(); 281 qpedesktop->screenClick();
280 } 282 }
281 } else { 283 } else {
282 up = TRUE; 284 up = TRUE;
283 } 285 }
284 } 286 }
285 } 287 }
286 288
287 return QPEApplication::qwsEventFilter( e ); 289 return QPEApplication::qwsEventFilter( e );
288} 290}
289#endif 291#endif
290 292
291void DesktopApplication::psTimeout() 293void DesktopApplication::psTimeout()
292{ 294{
293 qpedesktop->checkMemory(); // in case no events are being generated 295 qpedesktop->checkMemory(); // in case no events are being generated
294 296
295 *ps = PowerStatusManager::readStatus(); 297 *ps = PowerStatusManager::readStatus();
296 298
297 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { 299 if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) {
298 pa->alert( tr( "Battery is running very low." ), 6 ); 300 pa->alert( tr( "Battery is running very low." ), 6 );
299 } 301 }
300 302
301 if ( ps->batteryStatus() == PowerStatus::Critical ) { 303 if ( ps->batteryStatus() == PowerStatus::Critical ) {
302 pa->alert( tr( "Battery level is critical!\n" 304 pa->alert( tr( "Battery level is critical!\n"
303 "Keep power off until power restored!" ), 1 ); 305 "Keep power off until power restored!" ), 1 );
304 } 306 }
305 307
306 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { 308 if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) {
307 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); 309 pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 );
308 } 310 }
309} 311}
310 312
311 313
312void DesktopApplication::sendCard() 314void DesktopApplication::sendCard()
313{ 315{
314 delete cardSendTimer; 316 delete cardSendTimer;
315 cardSendTimer = 0; 317 cardSendTimer = 0;
316 QString card = getenv("HOME"); 318 QString card = getenv("HOME");
317 card += "/Applications/addressbook/businesscard.vcf"; 319 card += "/Applications/addressbook/businesscard.vcf";
318 320
319 if ( QFile::exists( card ) ) { 321 if ( QFile::exists( card ) ) {
320 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); 322 QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)");
321 QString mimetype = "text/x-vCard"; 323 QString mimetype = "text/x-vCard";
322 e << tr("business card") << card << mimetype; 324 e << tr("business card") << card << mimetype;
323 } 325 }
324} 326}
325 327
326#if defined(QPE_HAVE_MEMALERTER) 328#if defined(QPE_HAVE_MEMALERTER)
327QPE_MEMALERTER_IMPL 329QPE_MEMALERTER_IMPL
328#endif 330#endif
329 331
330#if defined(CUSTOM_SOUND_IMPL)
331CUSTOM_SOUND_IMPL
332#endif
333
334//=========================================================================== 332//===========================================================================
335 333
336Desktop::Desktop() : 334Desktop::Desktop() :
337 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), 335 QWidget( 0, 0, WStyle_Tool | WStyle_Customize ),
338 qcopBridge( 0 ), 336 qcopBridge( 0 ),
339 transferServer( 0 ), 337 transferServer( 0 ),
340 packageSlave( 0 ) 338 packageSlave( 0 )
341{ 339{
342#ifdef CUSTOM_SOUND_INIT
343 CUSTOM_SOUND_INIT;
344#endif
345
346 qpedesktop = this; 340 qpedesktop = this;
347 341
348// bg = new Info( this ); 342// bg = new Info( this );
349 tb = new TaskBar; 343 tb = new TaskBar;
350 344
351 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); 345 launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader );
352 346
353 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); 347 connect(launcher, SIGNAL(busy()), tb, SLOT(startWait()));
354 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); 348 connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&)));
355 349
356 int displayw = qApp->desktop()->width(); 350 int displayw = qApp->desktop()->width();
357 int displayh = qApp->desktop()->height(); 351 int displayh = qApp->desktop()->height();
358 352
359 353
360 QSize sz = tb->sizeHint(); 354 QSize sz = tb->sizeHint();
361 355
362 setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 356 setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
363 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); 357 tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() );
364 358
365 tb->show(); 359 tb->show();
366 launcher->showMaximized(); 360 launcher->showMaximized();
367 launcher->show(); 361 launcher->show();
368 launcher->raise(); 362 launcher->raise();
369#if defined(QPE_HAVE_MEMALERTER) 363#if defined(QPE_HAVE_MEMALERTER)
370 initMemalerter(); 364 initMemalerter();
371#endif 365#endif
372 // start services 366 // start services
373 startTransferServer(); 367 startTransferServer();
374 (void) new IrServer( this ); 368 (void) new IrServer( this );
375 rereadVolumes(); 369 rereadVolumes();
376 370
377 packageSlave = new PackageSlave( this ); 371 packageSlave = new PackageSlave( this );
378 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); 372 connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes()));
379 373
380 qApp->installEventFilter( this ); 374 qApp->installEventFilter( this );
381} 375}
382 376
383void Desktop::show() 377void Desktop::show()
384{ 378{
385 login(TRUE); 379 login(TRUE);
386 QWidget::show(); 380 QWidget::show();
387} 381}
388 382
389Desktop::~Desktop() 383Desktop::~Desktop()
390{ 384{
391 delete launcher; 385 delete launcher;
392 delete tb; 386 delete tb;
393 delete qcopBridge; 387 delete qcopBridge;
394 delete transferServer; 388 delete transferServer;
395} 389}
396 390
397bool Desktop::recoverMemory() 391bool Desktop::recoverMemory()
398{ 392{
399 return tb->recoverMemory(); 393 return tb->recoverMemory();
400} 394}
401 395
402void Desktop::checkMemory() 396void Desktop::checkMemory()
403{ 397{
404#if defined(QPE_HAVE_MEMALERTER) 398#if defined(QPE_HAVE_MEMALERTER)
405 static bool ignoreNormal=FALSE; 399 static bool ignoreNormal=FALSE;
406 static bool existingMessage=FALSE; 400 static bool existingMessage=FALSE;
407 401
408 if(existingMessage) 402 if(existingMessage)
409 return; // don't show a second message while still on first 403 return; // don't show a second message while still on first
@@ -695,102 +689,96 @@ void DesktopApplication::restart()
695{ 689{
696 prepareForTermination(TRUE); 690 prepareForTermination(TRUE);
697 691
698#ifdef Q_WS_QWS 692#ifdef Q_WS_QWS
699 for ( int fd = 3; fd < 100; fd++ ) 693 for ( int fd = 3; fd < 100; fd++ )
700 close( fd ); 694 close( fd );
701#if defined(QT_DEMO_SINGLE_FLOPPY) 695#if defined(QT_DEMO_SINGLE_FLOPPY)
702 execl( "/sbin/init", "qpe", 0 ); 696 execl( "/sbin/init", "qpe", 0 );
703#elif defined(QT_QWS_CASSIOPEIA) 697#elif defined(QT_QWS_CASSIOPEIA)
704 execl( "/bin/sh", "sh", 0 ); 698 execl( "/bin/sh", "sh", 0 );
705#else 699#else
706 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 ); 700 execl( (qpeDir()+"/bin/qpe").latin1(), "qpe", 0 );
707#endif 701#endif
708 exit(1); 702 exit(1);
709#endif 703#endif
710} 704}
711 705
712void Desktop::startTransferServer() 706void Desktop::startTransferServer()
713{ 707{
714 // start qcop bridge server 708 // start qcop bridge server
715 qcopBridge = new QCopBridge( 4243 ); 709 qcopBridge = new QCopBridge( 4243 );
716 if ( !qcopBridge->ok() ) { 710 if ( !qcopBridge->ok() ) {
717 delete qcopBridge; 711 delete qcopBridge;
718 qcopBridge = 0; 712 qcopBridge = 0;
719 } 713 }
720 // start transfer server 714 // start transfer server
721 transferServer = new TransferServer( 4242 ); 715 transferServer = new TransferServer( 4242 );
722 if ( !transferServer->ok() ) { 716 if ( !transferServer->ok() ) {
723 delete transferServer; 717 delete transferServer;
724 transferServer = 0; 718 transferServer = 0;
725 } 719 }
726 if ( !transferServer || !qcopBridge ) 720 if ( !transferServer || !qcopBridge )
727 startTimer( 2000 ); 721 startTimer( 2000 );
728} 722}
729 723
730void Desktop::timerEvent( QTimerEvent *e ) 724void Desktop::timerEvent( QTimerEvent *e )
731{ 725{
732 killTimer( e->timerId() ); 726 killTimer( e->timerId() );
733 startTransferServer(); 727 startTransferServer();
734} 728}
735 729
736void Desktop::terminateServers() 730void Desktop::terminateServers()
737{ 731{
738 delete transferServer; 732 delete transferServer;
739 delete qcopBridge; 733 delete qcopBridge;
740 transferServer = 0; 734 transferServer = 0;
741 qcopBridge = 0; 735 qcopBridge = 0;
742} 736}
743 737
744void Desktop::rereadVolumes() 738void Desktop::rereadVolumes()
745{ 739{
746 Config cfg("qpe"); 740 Config cfg("qpe");
747 cfg.setGroup("Volume"); 741 cfg.setGroup("Volume");
748 touchclick = cfg.readBoolEntry("TouchSound"); 742 touchclick = cfg.readBoolEntry("TouchSound");
749 keyclick = cfg.readBoolEntry("KeySound"); 743 keyclick = cfg.readBoolEntry("KeySound");
750 alarmsound = cfg.readBoolEntry("AlarmSound"); 744 alarmsound = cfg.readBoolEntry("AlarmSound");
751// Config cfg("Sound"); 745// Config cfg("Sound");
752// cfg.setGroup("System"); 746// cfg.setGroup("System");
753// touchclick = cfg.readBoolEntry("Touch"); 747// touchclick = cfg.readBoolEntry("Touch");
754// keyclick = cfg.readBoolEntry("Key"); 748// keyclick = cfg.readBoolEntry("Key");
755} 749}
756 750
757void Desktop::keyClick() 751void Desktop::keyClick()
758{ 752{
759#ifdef CUSTOM_SOUND_KEYCLICK 753 if ( keyclick )
760 if ( keyclick ) 754 ODevice::inst ( )-> keySound ( );
761 CUSTOM_SOUND_KEYCLICK;
762#endif
763} 755}
764 756
765void Desktop::screenClick() 757void Desktop::screenClick()
766{ 758{
767#ifdef CUSTOM_SOUND_TOUCH 759 if ( touchclick )
768 if ( touchclick ) 760 ODevice::inst ( )-> touchSound ( );
769 CUSTOM_SOUND_TOUCH;
770#endif
771} 761}
772 762
773void Desktop::soundAlarm() 763void Desktop::soundAlarm()
774{ 764{
775#ifdef CUSTOM_SOUND_ALARM 765 if ( qpedesktop-> alarmsound )
776 if (qpedesktop->alarmsound) 766 ODevice::inst ( )-> alarmSound ( );
777 CUSTOM_SOUND_ALARM;
778#endif
779} 767}
780 768
781bool Desktop::eventFilter( QObject *w, QEvent *ev ) 769bool Desktop::eventFilter( QObject *, QEvent *ev )
782{ 770{
783 if ( ev->type() == QEvent::KeyPress ) { 771 if ( ev-> type ( ) == QEvent::KeyPress ) {
784 QKeyEvent *ke = (QKeyEvent *)ev; 772 QKeyEvent *ke = (QKeyEvent *) ev;
785 if ( ke->key() == Qt::Key_F11 ) { // menu key 773 if ( ke-> key ( ) == Qt::Key_F11 ) { // menu key
786 QWidget *active = qApp->activeWindow(); 774 QWidget *active = qApp-> activeWindow ( );
787 if ( active && active->isPopup() ) { 775
788 active->close(); 776 if ( active && active-> isPopup ( ))
789 } 777 active->close();
790 raiseMenu();
791 return TRUE;
792 }
793 }
794 return FALSE;
795}
796 778
779 raiseMenu ( );
780 return true;
781 }
782 }
783 return false;
784}
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp
index 347eee9..b3c331b 100644
--- a/core/launcher/main.cpp
+++ b/core/launcher/main.cpp
@@ -1,102 +1,102 @@
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 "taskbar.h" 22#include "taskbar.h"
23#include "stabmon.h" 23#include "stabmon.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/network.h> 26#include <qpe/network.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 28#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
29#include <qpe/custom.h> 29#include <qpe/custom.h>
30#endif 30#endif
31 31
32#include <opie/odevice.h>
33
32#include <qfile.h> 34#include <qfile.h>
33#include <qwindowsystem_qws.h> 35#include <qwindowsystem_qws.h>
34#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
35#include <qpe/alarmserver.h> 37#include <qpe/alarmserver.h>
36 38
37#include <opie/ohwinfo.h>
38
39#include <stdlib.h> 39#include <stdlib.h>
40#include <stdio.h> 40#include <stdio.h>
41#include <signal.h> 41#include <signal.h>
42#include <unistd.h> 42#include <unistd.h>
43 43
44#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 44#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
45#include "../calibrate/calibrate.h" 45#include "../calibrate/calibrate.h"
46#endif 46#endif
47 47
48#ifdef QT_QWS_LOGIN 48#ifdef QT_QWS_LOGIN
49#include "../login/qdmdialogimpl.h" 49#include "../login/qdmdialogimpl.h"
50#endif 50#endif
51 51
52#ifdef QT_QWS_CASSIOPEIA 52#ifdef QT_QWS_CASSIOPEIA
53static void ignoreMessage( QtMsgType, const char * ) 53static void ignoreMessage( QtMsgType, const char * )
54{ 54{
55} 55}
56#include <sys/mount.h> 56#include <sys/mount.h>
57#include <sys/types.h> 57#include <sys/types.h>
58#include <sys/stat.h> 58#include <sys/stat.h>
59#include <sys/time.h> 59#include <sys/time.h>
60#include <fcntl.h> 60#include <fcntl.h>
61#include <qdatetime.h> 61#include <qdatetime.h>
62 62
63void initCassiopeia() 63void initCassiopeia()
64{ 64{
65 // MIPSEL-specific init - make sure /proc exists for shm 65 // MIPSEL-specific init - make sure /proc exists for shm
66/* 66/*
67 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) { 67 if ( mount("/dev/ram0", "/", "ext2", MS_REMOUNT | MS_MGC_VAL, 0 ) ) {
68 perror("Remounting - / read/write"); 68 perror("Remounting - / read/write");
69 } 69 }
70*/ 70*/
71 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) { 71 if ( mount("none", "/tmp", "ramfs", 0, 0 ) ) {
72 perror("mounting ramfs /tmp"); 72 perror("mounting ramfs /tmp");
73 } else { 73 } else {
74 fprintf( stderr, "mounted /tmp\n" ); 74 fprintf( stderr, "mounted /tmp\n" );
75 } 75 }
76 if ( mount("none", "/home", "ramfs", 0, 0 ) ) { 76 if ( mount("none", "/home", "ramfs", 0, 0 ) ) {
77 perror("mounting ramfs /home"); 77 perror("mounting ramfs /home");
78 } else { 78 } else {
79 fprintf( stderr, "mounted /home\n" ); 79 fprintf( stderr, "mounted /home\n" );
80 } 80 }
81 if ( mount("none","/proc","proc",0,0) ) { 81 if ( mount("none","/proc","proc",0,0) ) {
82 perror("Mounting - /proc"); 82 perror("Mounting - /proc");
83 } else { 83 } else {
84 fprintf( stderr, "mounted /proc\n" ); 84 fprintf( stderr, "mounted /proc\n" );
85 } 85 }
86 if ( mount("none","/mnt","shm",0,0) ) { 86 if ( mount("none","/mnt","shm",0,0) ) {
87 perror("Mounting - shm"); 87 perror("Mounting - shm");
88 } 88 }
89 setenv( "QTDIR", "/", 1 ); 89 setenv( "QTDIR", "/", 1 );
90 setenv( "OPIEDIR", "/", 1 ); 90 setenv( "OPIEDIR", "/", 1 );
91 setenv( "HOME", "/home", 1 ); 91 setenv( "HOME", "/home", 1 );
92 mkdir( "/home/Documents", 0755 ); 92 mkdir( "/home/Documents", 0755 );
93 93
94 // set a reasonable starting date 94 // set a reasonable starting date
95 QDateTime dt( QDate( 2001, 3, 15 ) ); 95 QDateTime dt( QDate( 2001, 3, 15 ) );
96 QDateTime now = QDateTime::currentDateTime(); 96 QDateTime now = QDateTime::currentDateTime();
97 int change = now.secsTo( dt ); 97 int change = now.secsTo( dt );
98 98
99 time_t t = ::time(0); 99 time_t t = ::time(0);
100 t += change; 100 t += change;
101 stime(&t); 101 stime(&t);
102 102
@@ -132,205 +132,204 @@ static void disableAPM()
132 exit(errno); 132 exit(errno);
133 } 133 }
134 134
135 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON); 135 ret = ioctl(fd, APM_IOCSEVTSRC, cur_val & ~APM_EVT_POWER_BUTTON);
136 if (ret == -1) { 136 if (ret == -1) {
137 perror("ioctl"); 137 perror("ioctl");
138 return; 138 return;
139 } 139 }
140 close(fd); 140 close(fd);
141} 141}
142 142
143static void initAPM() 143static void initAPM()
144{ 144{
145 // So that we have to do it ourself, but better. 145 // So that we have to do it ourself, but better.
146 disableAPM(); 146 disableAPM();
147} 147}
148#endif 148#endif
149 149
150#ifdef QT_DEMO_SINGLE_FLOPPY 150#ifdef QT_DEMO_SINGLE_FLOPPY
151#include <sys/mount.h> 151#include <sys/mount.h>
152 152
153void initFloppy() 153void initFloppy()
154{ 154{
155 mount("none","/proc","proc",0,0); 155 mount("none","/proc","proc",0,0);
156 setenv( "QTDIR", "/", 0 ); 156 setenv( "QTDIR", "/", 0 );
157 setenv( "HOME", "/root", 0 ); 157 setenv( "HOME", "/root", 0 );
158 setenv( "QWS_SIZE", "240x320", 0 ); 158 setenv( "QWS_SIZE", "240x320", 0 );
159} 159}
160#endif 160#endif
161 161
162 162
163void initEnvironment() 163void initEnvironment()
164{ 164{
165 Config config("locale"); 165 Config config("locale");
166 config.setGroup( "Location" ); 166 config.setGroup( "Location" );
167 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 167 QString tz = config.readEntry( "Timezone", getenv("TZ") );
168 168
169 // if not timezone set, pick New York 169 // if not timezone set, pick New York
170 if (tz.isNull()) 170 if (tz.isNull())
171 tz = "America/New_York"; 171 tz = "America/New_York";
172 172
173 setenv( "TZ", tz, 1 ); 173 setenv( "TZ", tz, 1 );
174 config.writeEntry( "Timezone", tz); 174 config.writeEntry( "Timezone", tz);
175 175
176 config.setGroup( "Language" ); 176 config.setGroup( "Language" );
177 QString lang = config.readEntry( "Language", getenv("LANG") ); 177 QString lang = config.readEntry( "Language", getenv("LANG") );
178 if ( !lang.isNull() ) 178 if ( !lang.isNull() )
179 setenv( "LANG", lang, 1 ); 179 setenv( "LANG", lang, 1 );
180} 180}
181 181
182static void initBacklight() 182static void initBacklight()
183{ 183{
184 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 184 QCopEnvelope e("QPE/System", "setBacklight(int)" );
185 e << -3; // Forced on 185 e << -3; // Forced on
186} 186}
187 187
188 188
189class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter 189class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter
190{ 190{
191public: 191public:
192 ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) 192 ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" )
193 { 193 {
194 bool doinst = false; 194 bool doinst = false;
195 195
196 m_model = OHwInfo::inst ( )-> model ( ); 196 m_model = ODevice::inst ( )-> model ( );
197 m_power_timer = 0; 197 m_power_timer = 0;
198 198
199 switch ( m_model ) { 199 switch ( m_model ) {
200 case OMODEL_iPAQ_H31xx: 200 case OMODEL_iPAQ_H31xx:
201 case OMODEL_iPAQ_H36xx: 201 case OMODEL_iPAQ_H36xx:
202 case OMODEL_iPAQ_H37xx: 202 case OMODEL_iPAQ_H37xx:
203 case OMODEL_iPAQ_H38xx: doinst = true; 203 case OMODEL_iPAQ_H38xx: doinst = true;
204 break; 204 break;
205 default : break; 205 default : break;
206 } 206 }
207 if ( doinst ) 207 if ( doinst )
208 QWSServer::setKeyboardFilter ( this ); 208 QWSServer::setKeyboardFilter ( this );
209 } 209 }
210 210
211 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) 211 virtual bool filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
212 { 212 {
213 bool kill = false; 213 bool kill = false;
214 214
215 // Rotate cursor keys 180° 215 // Rotate cursor keys 180°
216 switch ( m_model ) { 216 switch ( m_model ) {
217 case OMODEL_iPAQ_H31xx: 217 case OMODEL_iPAQ_H31xx:
218 case OMODEL_iPAQ_H38xx: { 218 case OMODEL_iPAQ_H38xx: {
219 int newkeycode = keycode; 219 int newkeycode = keycode;
220 220
221 switch ( keycode ) { 221 switch ( keycode ) {
222 case Key_Left : newkeycode = Key_Right; break; 222 case Key_Left : newkeycode = Key_Right; break;
223 case Key_Right: newkeycode = Key_Left; break; 223 case Key_Right: newkeycode = Key_Left; break;
224 case Key_Up : newkeycode = Key_Down; break; 224 case Key_Up : newkeycode = Key_Down; break;
225 case Key_Down : newkeycode = Key_Up; break; 225 case Key_Down : newkeycode = Key_Up; break;
226 } 226 }
227 if ( newkeycode != keycode ) { 227 if ( newkeycode != keycode ) {
228 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 228 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
229 kill = true; 229 kill = true;
230 } 230 }
231 break; 231 break;
232 } 232 }
233 default: break; 233 default: break;
234 } 234 }
235 235
236 // map Power Button short/long press to F34/F35 236 // map Power Button short/long press to F34/F35
237 switch ( m_model ) { 237 switch ( m_model ) {
238 case OMODEL_iPAQ_H31xx: 238 case OMODEL_iPAQ_H31xx:
239 case OMODEL_iPAQ_H36xx: 239 case OMODEL_iPAQ_H36xx:
240 case OMODEL_iPAQ_H37xx: 240 case OMODEL_iPAQ_H37xx:
241 case OMODEL_iPAQ_H38xx: { 241 case OMODEL_iPAQ_H38xx: {
242 if ( keycode == Key_SysReq ) { 242 if ( keycode == Key_SysReq ) {
243 if ( isPress ) { 243 if ( isPress ) {
244 m_power_timer = startTimer ( 500 ); 244 m_power_timer = startTimer ( 500 );
245 } 245 }
246 else if ( m_power_timer ) { 246 else if ( m_power_timer ) {
247 killTimer ( m_power_timer ); 247 killTimer ( m_power_timer );
248 m_power_timer = 0; 248 m_power_timer = 0;
249 QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); 249 QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false );
250 QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); 250 QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false );
251 } 251 }
252 kill = true; 252 kill = true;
253 } 253 }
254 break; 254 break;
255 } 255 }
256 default: break; 256 default: break;
257 } 257 }
258 return kill; 258 return kill;
259 } 259 }
260 260
261 virtual void timerEvent ( QTimerEvent * ) 261 virtual void timerEvent ( QTimerEvent * )
262 { 262 {
263 killTimer ( m_power_timer ); 263 killTimer ( m_power_timer );
264 m_power_timer = 0; 264 m_power_timer = 0;
265 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); 265 QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false );
266 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); 266 QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false );
267 } 267 }
268 268
269private: 269private:
270 OHwModel m_model; 270 OModel m_model;
271 bool m_power_press; 271 int m_power_timer;
272 int m_power_timer;
273}; 272};
274 273
275 274
276 275
277int initApplication( int argc, char ** argv ) 276int initApplication( int argc, char ** argv )
278{ 277{
279#ifdef QT_QWS_CASSIOPEIA 278#ifdef QT_QWS_CASSIOPEIA
280 initCassiopeia(); 279 initCassiopeia();
281#endif 280#endif
282 281
283#ifdef QPE_OWNAPM 282#ifdef QPE_OWNAPM
284 initAPM(); 283 initAPM();
285#endif 284#endif
286 285
287#ifdef QT_DEMO_SINGLE_FLOPPY 286#ifdef QT_DEMO_SINGLE_FLOPPY
288 initFloppy(); 287 initFloppy();
289#endif 288#endif
290 289
291 initEnvironment(); 290 initEnvironment();
292 291
293#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 292#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
294 setenv( "QWS_SIZE", "240x320", 0 ); 293 setenv( "QWS_SIZE", "240x320", 0 );
295#endif 294#endif
296 295
297 //Don't flicker at startup: 296 //Don't flicker at startup:
298 QWSServer::setDesktopBackground( QImage() ); 297 QWSServer::setDesktopBackground( QImage() );
299 DesktopApplication a( argc, argv, QApplication::GuiServer ); 298 DesktopApplication a( argc, argv, QApplication::GuiServer );
300 299
301 (void) new ModelKeyFilter ( ); 300 (void) new ModelKeyFilter ( );
302 301
303 initBacklight(); 302 initBacklight();
304 303
305 AlarmServer::initialize(); 304 AlarmServer::initialize();
306 305
307#if defined(QT_QWS_LOGIN) 306#if defined(QT_QWS_LOGIN)
308 for( int i=0; i<a.argc(); i++ ) 307 for( int i=0; i<a.argc(); i++ )
309 if( strcmp( a.argv()[i], "-login" ) == 0 ) { 308 if( strcmp( a.argv()[i], "-login" ) == 0 ) {
310 QDMDialogImpl::login( ); 309 QDMDialogImpl::login( );
311 return 0; 310 return 0;
312 } 311 }
313#endif 312#endif
314 313
315 Desktop *d = new Desktop(); 314 Desktop *d = new Desktop();
316 315
317 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); 316 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) );
318 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); 317 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) );
319 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); 318 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) );
320 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); 319 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) );
321 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 320 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
322 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 321 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
323 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 322 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
324 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 323 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
325 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 324 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
326 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 325 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );
327 326
328 (void)new SysFileMonitor(d); 327 (void)new SysFileMonitor(d);
329 Network::createServer(d); 328 Network::createServer(d);
330 329
331#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 330#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
332 if ( !QFile::exists( "/etc/pointercal" ) ) { 331 if ( !QFile::exists( "/etc/pointercal" ) ) {
333 // Make sure calibration widget starts on top. 332 // Make sure calibration widget starts on top.
334 Calibrate *cal = new Calibrate; 333 Calibrate *cal = new Calibrate;
335 cal->exec(); 334 cal->exec();
336 delete cal; 335 delete cal;
diff --git a/core/launcher/taskbar.cpp b/core/launcher/taskbar.cpp
index 5e95c99..e38b9fe 100644
--- a/core/launcher/taskbar.cpp
+++ b/core/launcher/taskbar.cpp
@@ -1,103 +1,105 @@
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 "startmenu.h" 21#include "startmenu.h"
22#include "inputmethods.h" 22#include "inputmethods.h"
23#include "mrulist.h" 23#include "mrulist.h"
24#include "systray.h" 24#include "systray.h"
25#include "calibrate.h" 25#include "calibrate.h"
26#include "wait.h" 26#include "wait.h"
27#include "appicons.h" 27#include "appicons.h"
28 28
29#include "taskbar.h" 29#include "taskbar.h"
30#include "desktop.h" 30#include "desktop.h"
31 31
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/qcopenvelope_qws.h> 33#include <qpe/qcopenvelope_qws.h>
34#include <qpe/global.h> 34#include <qpe/global.h>
35 35
36#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 36#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
37#include <qpe/custom.h> 37#include <qpe/custom.h>
38#endif 38#endif
39 39
40#include <opie/odevice.h>
41
40#include <qlabel.h> 42#include <qlabel.h>
41#include <qlayout.h> 43#include <qlayout.h>
42#include <qtimer.h> 44#include <qtimer.h>
43#include <qwindowsystem_qws.h> 45#include <qwindowsystem_qws.h>
44#include <qwidgetstack.h> 46#include <qwidgetstack.h>
45 47
46#if defined( Q_WS_QWS ) 48#if defined( Q_WS_QWS )
47#include <qwsdisplay_qws.h> 49#include <qwsdisplay_qws.h>
48#include <qgfx_qws.h> 50#include <qgfx_qws.h>
49#endif 51#endif
50 52
51 53
52#define FACTORY(T) \ 54#define FACTORY(T) \
53 static QWidget *new##T( bool maximized ) { \ 55 static QWidget *new##T( bool maximized ) { \
54 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \ 56 QWidget *w = new T( 0, "test", QWidget::WDestructiveClose | QWidget::WGroupLeader ); \
55 if ( maximized ) { \ 57 if ( maximized ) { \
56 if ( qApp->desktop()->width() <= 350 ) { \ 58 if ( qApp->desktop()->width() <= 350 ) { \
57 w->showMaximized(); \ 59 w->showMaximized(); \
58 } else { \ 60 } else { \
59 w->resize( QSize( 300, 300 ) ); \ 61 w->resize( QSize( 300, 300 ) ); \
60 } \ 62 } \
61 } \ 63 } \
62 w->show(); \ 64 w->show(); \
63 return w; \ 65 return w; \
64 } 66 }
65 67
66 68
67#ifdef SINGLE_APP 69#ifdef SINGLE_APP
68#define APP(a,b,c,d) FACTORY(b) 70#define APP(a,b,c,d) FACTORY(b)
69#include "../launcher/apps.h" 71#include "../launcher/apps.h"
70#undef APP 72#undef APP
71#endif // SINGLE_APP 73#endif // SINGLE_APP
72 74
73static Global::Command builtins[] = { 75static Global::Command builtins[] = {
74 76
75#ifdef SINGLE_APP 77#ifdef SINGLE_APP
76#define APP(a,b,c,d) { a, new##b, c }, 78#define APP(a,b,c,d) { a, new##b, c },
77#include "../launcher/apps.h" 79#include "../launcher/apps.h"
78#undef APP 80#undef APP
79#endif 81#endif
80 82
81#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX) 83#if defined(QT_QWS_IPAQ) || defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_EBX)
82 { "calibrate", TaskBar::calibrate, 1, 0 }, 84 { "calibrate", TaskBar::calibrate, 1, 0 },
83#endif 85#endif
84#if !defined(QT_QWS_CASSIOPEIA) 86#if !defined(QT_QWS_CASSIOPEIA)
85 { "shutdown", Global::shutdown, 1, 0 }, 87 { "shutdown", Global::shutdown, 1, 0 },
86// { "run", run, 1, 0 }, 88// { "run", run, 1, 0 },
87#endif 89#endif
88 90
89 { 0, TaskBar::calibrate, 0, 0 }, 91 { 0, TaskBar::calibrate, 0, 0 },
90}; 92};
91 93
92static bool initNumLock() 94static bool initNumLock()
93{ 95{
94#ifdef QPE_INITIAL_NUMLOCK_STATE 96#ifdef QPE_INITIAL_NUMLOCK_STATE
95 QPE_INITIAL_NUMLOCK_STATE 97 QPE_INITIAL_NUMLOCK_STATE
96#endif 98#endif
97 return FALSE; 99 return FALSE;
98} 100}
99 101
100class LockKeyState : public QWidget 102class LockKeyState : public QWidget
101{ 103{
102public: 104public:
103 LockKeyState( QWidget *parent ) : 105 LockKeyState( QWidget *parent ) :
@@ -192,124 +194,123 @@ void TaskBar::setStatusMessage( const QString &text )
192} 194}
193 195
194void TaskBar::clearStatusBar() 196void TaskBar::clearStatusBar()
195{ 197{
196 label->clear(); 198 label->clear();
197 stack->raiseWidget( mru ); 199 stack->raiseWidget( mru );
198} 200}
199 201
200void TaskBar::startWait() 202void TaskBar::startWait()
201{ 203{
202 waitIcon->setWaiting( true ); 204 waitIcon->setWaiting( true );
203 // a catchall stop after 10 seconds... 205 // a catchall stop after 10 seconds...
204 waitTimer->start( 10 * 1000, true ); 206 waitTimer->start( 10 * 1000, true );
205} 207}
206 208
207void TaskBar::stopWait(const QString& app) 209void TaskBar::stopWait(const QString& app)
208{ 210{
209 waitTimer->stop(); 211 waitTimer->stop();
210 mru->addTask(sm->execToLink(app)); 212 mru->addTask(sm->execToLink(app));
211 waitIcon->setWaiting( false ); 213 waitIcon->setWaiting( false );
212} 214}
213 215
214void TaskBar::stopWait() 216void TaskBar::stopWait()
215{ 217{
216 waitTimer->stop(); 218 waitTimer->stop();
217 waitIcon->setWaiting( false ); 219 waitIcon->setWaiting( false );
218} 220}
219 221
220void TaskBar::resizeEvent( QResizeEvent *e ) 222void TaskBar::resizeEvent( QResizeEvent *e )
221{ 223{
222 QHBox::resizeEvent( e ); 224 QHBox::resizeEvent( e );
223 calcMaxWindowRect(); 225 calcMaxWindowRect();
224} 226}
225 227
226void TaskBar::styleChange( QStyle &s ) 228void TaskBar::styleChange( QStyle &s )
227{ 229{
228 QHBox::styleChange( s ); 230 QHBox::styleChange( s );
229 calcMaxWindowRect(); 231 calcMaxWindowRect();
230} 232}
231 233
232void TaskBar::calcMaxWindowRect() 234void TaskBar::calcMaxWindowRect()
233{ 235{
234#ifdef Q_WS_QWS 236#ifdef Q_WS_QWS
235 QRect wr; 237 QRect wr;
236 int displayWidth = qApp->desktop()->width(); 238 int displayWidth = qApp->desktop()->width();
237 QRect ir = inputMethods->inputRect(); 239 QRect ir = inputMethods->inputRect();
238 if ( ir.isValid() ) { 240 if ( ir.isValid() ) {
239 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); 241 wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 );
240 } else { 242 } else {
241 wr.setCoords( 0, 0, displayWidth-1, y()-1 ); 243 wr.setCoords( 0, 0, displayWidth-1, y()-1 );
242 } 244 }
243 245
244#if QT_VERSION < 300 246#if QT_VERSION < 300
245 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, 247 QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr,
246 QSize(qt_screen->width(),qt_screen->height())) 248 QSize(qt_screen->width(),qt_screen->height()))
247 ); 249 );
248#else 250#else
249 QWSServer::setMaxWindowRect( wr ); 251 QWSServer::setMaxWindowRect( wr );
250#endif 252#endif
251#endif 253#endif
252} 254}
253 255
254void TaskBar::receive( const QCString &msg, const QByteArray &data ) 256void TaskBar::receive( const QCString &msg, const QByteArray &data )
255{ 257{
256 QDataStream stream( data, IO_ReadOnly ); 258 QDataStream stream( data, IO_ReadOnly );
257 if ( msg == "message(QString)" ) { 259 if ( msg == "message(QString)" ) {
258 QString text; 260 QString text;
259 stream >> text; 261 stream >> text;
260 setStatusMessage( text ); 262 setStatusMessage( text );
261 } else if ( msg == "hideInputMethod()" ) { 263 } else if ( msg == "hideInputMethod()" ) {
262 inputMethods->hideInputMethod(); 264 inputMethods->hideInputMethod();
263 } else if ( msg == "showInputMethod()" ) { 265 } else if ( msg == "showInputMethod()" ) {
264 inputMethods->showInputMethod(); 266 inputMethods->showInputMethod();
265 } else if ( msg == "reloadInputMethods()" ) { 267 } else if ( msg == "reloadInputMethods()" ) {
266 inputMethods->loadInputMethods(); 268 inputMethods->loadInputMethods();
267 } else if ( msg == "reloadApplets()" ) { 269 } else if ( msg == "reloadApplets()" ) {
268 sysTray->loadApplets(); 270 sysTray->loadApplets();
269 } else if ( msg == "soundAlarm()" ) { 271 } else if ( msg == "soundAlarm()" ) {
270 Desktop::soundAlarm(); 272 Desktop::soundAlarm();
271 } 273 }
272#ifdef CUSTOM_LEDS 274 else if ( msg == "setLed(int,bool)" ) {
273 else if ( msg == "setLed(int,bool)" ) { 275 int led, status;
274 int led, status; 276 stream >> led >> status;
275 stream >> led >> status; 277
276 CUSTOM_LEDS( led, status ); 278 ODevice::inst ( )-> setLed ( led, status ? OLED_BlinkSlow : OLED_Off );
277 } 279 }
278#endif
279} 280}
280 281
281QWidget *TaskBar::calibrate(bool) 282QWidget *TaskBar::calibrate(bool)
282{ 283{
283#ifdef Q_WS_QWS 284#ifdef Q_WS_QWS
284 Calibrate *c = new Calibrate; 285 Calibrate *c = new Calibrate;
285 c->show(); 286 c->show();
286 return c; 287 return c;
287#else 288#else
288 return 0; 289 return 0;
289#endif 290#endif
290} 291}
291 292
292void TaskBar::toggleNumLockState() 293void TaskBar::toggleNumLockState()
293{ 294{
294 if ( lockState ) lockState->toggleNumLockState(); 295 if ( lockState ) lockState->toggleNumLockState();
295} 296}
296 297
297void TaskBar::toggleCapsLockState() 298void TaskBar::toggleCapsLockState()
298{ 299{
299 if ( lockState ) lockState->toggleCapsLockState(); 300 if ( lockState ) lockState->toggleCapsLockState();
300} 301}
301 302
302void TaskBar::toggleSymbolInput() 303void TaskBar::toggleSymbolInput()
303{ 304{
304 if ( inputMethods->currentShown() == "Unicode" ) { 305 if ( inputMethods->currentShown() == "Unicode" ) {
305 inputMethods->hideInputMethod(); 306 inputMethods->hideInputMethod();
306 } else { 307 } else {
307 inputMethods->showInputMethod("Unicode"); 308 inputMethods->showInputMethod("Unicode");
308 } 309 }
309} 310}
310 311
311bool TaskBar::recoverMemory() 312bool TaskBar::recoverMemory()
312{ 313{
313 return mru->quitOldApps(); 314 return mru->quitOldApps();
314} 315}
315 316
diff --git a/core/launcher/taskbar.h b/core/launcher/taskbar.h
index 78c4722..40983af 100644
--- a/core/launcher/taskbar.h
+++ b/core/launcher/taskbar.h
@@ -1,86 +1,82 @@
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#ifndef __TASKBAR_H__ 21#ifndef __TASKBAR_H__
22#define __TASKBAR_H__ 22#define __TASKBAR_H__
23 23
24#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
25#include <qpe/custom.h>
26#endif
27
28#include <qhbox.h> 24#include <qhbox.h>
29 25
30class QLabel; 26class QLabel;
31class QTimer; 27class QTimer;
32class InputMethods; 28class InputMethods;
33class Wait; 29class Wait;
34class SysTray; 30class SysTray;
35class MRUList; 31class MRUList;
36class QWidgetStack; 32class QWidgetStack;
37class QTimer; 33class QTimer;
38class QLabel; 34class QLabel;
39class StartMenu; 35class StartMenu;
40class LockKeyState; 36class LockKeyState;
41 37
42class TaskBar : public QHBox { 38class TaskBar : public QHBox {
43 Q_OBJECT 39 Q_OBJECT
44public: 40public:
45 TaskBar(); 41 TaskBar();
46 ~TaskBar(); 42 ~TaskBar();
47 43
48 static QWidget *calibrate( bool ); 44 static QWidget *calibrate( bool );
49 45
50 bool recoverMemory(); 46 bool recoverMemory();
51 47
52 StartMenu *startMenu() const { return sm; } 48 StartMenu *startMenu() const { return sm; }
53public slots: 49public slots:
54 void startWait(); 50 void startWait();
55 void stopWait(const QString&); 51 void stopWait(const QString&);
56 void stopWait(); 52 void stopWait();
57 void clearStatusBar(); 53 void clearStatusBar();
58 void toggleNumLockState(); 54 void toggleNumLockState();
59 void toggleCapsLockState(); 55 void toggleCapsLockState();
60 void toggleSymbolInput(); 56 void toggleSymbolInput();
61 57
62protected: 58protected:
63 void resizeEvent( QResizeEvent * ); 59 void resizeEvent( QResizeEvent * );
64 void styleChange( QStyle & ); 60 void styleChange( QStyle & );
65 void setStatusMessage( const QString &text ); 61 void setStatusMessage( const QString &text );
66 62
67private slots: 63private slots:
68 void calcMaxWindowRect(); 64 void calcMaxWindowRect();
69 void receive( const QCString &msg, const QByteArray &data ); 65 void receive( const QCString &msg, const QByteArray &data );
70 66
71private: 67private:
72 68
73 QTimer *waitTimer; 69 QTimer *waitTimer;
74 Wait *waitIcon; 70 Wait *waitIcon;
75 InputMethods *inputMethods; 71 InputMethods *inputMethods;
76 SysTray *sysTray; 72 SysTray *sysTray;
77 MRUList *mru; 73 MRUList *mru;
78 QWidgetStack *stack; 74 QWidgetStack *stack;
79 QTimer *clearer; 75 QTimer *clearer;
80 QLabel *label; 76 QLabel *label;
81 LockKeyState* lockState; 77 LockKeyState* lockState;
82 StartMenu *sm; 78 StartMenu *sm;
83}; 79};
84 80
85 81
86#endif // __TASKBAR_H__ 82#endif // __TASKBAR_H__