author | llornkcor <llornkcor> | 2003-02-17 01:22:21 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-02-17 01:22:21 (UTC) |
commit | a5e3911518d00ae327d3fe29871c03354344f086 (patch) (unidiff) | |
tree | 15b4a17d942283a98bd7f482c380ef54220d2fa8 | |
parent | 0c50793d0ef839e90b9b2dea5001c3170971fc06 (diff) | |
download | opie-a5e3911518d00ae327d3fe29871c03354344f086.zip opie-a5e3911518d00ae327d3fe29871c03354344f086.tar.gz opie-a5e3911518d00ae327d3fe29871c03354344f086.tar.bz2 |
attempt to fix bug 586 - new thread and sleep 15 sec for cards to mount for mp3 alarm
-rw-r--r-- | noncore/tools/clock/clock.cpp | 53 | ||||
-rw-r--r-- | noncore/tools/clock/clock.h | 2 | ||||
-rw-r--r-- | noncore/tools/clock/clock.pro | 2 |
3 files changed, 48 insertions, 9 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index 2f81c3a..0937362 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -38,28 +38,43 @@ | |||
38 | #include <qslider.h> | 38 | #include <qslider.h> |
39 | #include <qlabel.h> | 39 | #include <qlabel.h> |
40 | #include <qlayout.h> | 40 | #include <qlayout.h> |
41 | #include <qtimer.h> | 41 | #include <qtimer.h> |
42 | #include <qpushbutton.h> | 42 | #include <qpushbutton.h> |
43 | #include <qradiobutton.h> | 43 | #include <qradiobutton.h> |
44 | #include <qbuttongroup.h> | 44 | #include <qbuttongroup.h> |
45 | #include <qpainter.h> | 45 | #include <qpainter.h> |
46 | #include <qmessagebox.h> | 46 | #include <qmessagebox.h> |
47 | #include <qdatetime.h> | 47 | #include <qdatetime.h> |
48 | 48 | ||
49 | #include <math.h> | 49 | #include <math.h> |
50 | #include <unistd.h> | ||
51 | #include <sys/types.h> | ||
52 | |||
53 | #include <pthread.h> | ||
54 | |||
50 | 55 | ||
51 | const double deg2rad = 0.017453292519943295769; // pi/180 | 56 | const double deg2rad = 0.017453292519943295769; // pi/180 |
52 | const int sw_prec = 2; | 57 | const int sw_prec = 2; |
53 | 58 | ||
59 | void startPlayer() | ||
60 | { | ||
61 | Config config( "qpe" ); | ||
62 | config.setGroup( "Time" ); | ||
63 | sleep(15); | ||
64 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | ||
65 | e << config.readEntry( "mp3File", "" ); | ||
66 | } | ||
67 | |||
68 | |||
54 | static void toggleScreenSaver( bool on ) | 69 | static void toggleScreenSaver( bool on ) |
55 | { | 70 | { |
56 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); | 71 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); |
57 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); | 72 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); |
58 | } | 73 | } |
59 | 74 | ||
60 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) | 75 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) |
61 | : QVBox( parent, name , f ) | 76 | : QVBox( parent, name , f ) |
62 | { | 77 | { |
63 | setSpacing( 4 ); | 78 | setSpacing( 4 ); |
64 | setMargin( 1 ); | 79 | setMargin( 1 ); |
65 | 80 | ||
@@ -388,63 +403,87 @@ void Clock::alarmOn() | |||
388 | 403 | ||
389 | void Clock::alarmOff() | 404 | void Clock::alarmOff() |
390 | { | 405 | { |
391 | int warn = 0; | 406 | int warn = 0; |
392 | bSound = FALSE; | 407 | bSound = FALSE; |
393 | AlarmServer::deleteAlarm( when, | 408 | AlarmServer::deleteAlarm( when, |
394 | "QPE/Application/clock", | 409 | "QPE/Application/clock", |
395 | "alarm(QDateTime,int)", warn ); | 410 | "alarm(QDateTime,int)", warn ); |
396 | qDebug( "Alarm Off " + when.toString() ); | 411 | qDebug( "Alarm Off " + when.toString() ); |
397 | setCaption( "Clock" ); | 412 | setCaption( "Clock" ); |
398 | } | 413 | } |
399 | 414 | ||
415 | void Clock::clearTimer() | ||
416 | { | ||
417 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | ||
418 | alarmBool = FALSE; | ||
419 | snoozeBtn->hide(); | ||
420 | setCaption( "Clock" ); | ||
421 | } | ||
422 | |||
400 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | 423 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) |
401 | { | 424 | { |
402 | int stopTimer = 0; | 425 | int stopTimer = 0; |
403 | int timerStay = 5000; | 426 | int timerStay = 5000; |
404 | bSound = TRUE; | 427 | bSound = TRUE; |
405 | qDebug( "Message received in clock" ); | 428 | qDebug( "Message received in clock" ); |
406 | if ( msg == "alarm(QDateTime,int)" ) { | 429 | if ( msg == "alarm(QDateTime,int)" ) { |
407 | Config config( "qpe" ); | 430 | Config config( "qpe" ); |
408 | config.setGroup( "Time" ); | 431 | config.setGroup( "Time" ); |
409 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) { | 432 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) |
433 | { | ||
434 | clearTimer(); | ||
435 | // pid_t pid; | ||
436 | // switch(pid = fork()) | ||
437 | // { | ||
438 | // case -1: | ||
439 | // {//failed | ||
440 | // } | ||
441 | // break; | ||
442 | // case 0: | ||
443 | // {//child | ||
444 | // QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | ||
445 | // e << config.readEntry( "mp3File", "" ); | ||
446 | pthread_t thread; | ||
447 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); | ||
448 | // startPlayer(); | ||
449 | // } | ||
450 | // break; | ||
451 | // }; | ||
410 | 452 | ||
411 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | ||
412 | e << config.readEntry( "mp3File", "" ); | ||
413 | } | 453 | } |
414 | else { | 454 | else |
455 | { | ||
415 | 456 | ||
416 | Sound::soundAlarm(); | 457 | Sound::soundAlarm(); |
417 | stopTimer = startTimer( timerStay ); | 458 | stopTimer = startTimer( timerStay ); |
418 | } | 459 | } |
419 | } | 460 | } |
420 | show(); | 461 | show(); |
421 | raise(); | 462 | raise(); |
422 | QPEApplication::setKeepRunning(); | 463 | QPEApplication::setKeepRunning(); |
423 | setActiveWindow(); | 464 | setActiveWindow(); |
424 | } | 465 | } |
425 | 466 | ||
426 | void Clock::timerEvent( QTimerEvent *e ) | 467 | void Clock::timerEvent( QTimerEvent *e ) |
427 | { | 468 | { |
428 | static int stop = 0; | 469 | static int stop = 0; |
429 | if ( stop < 120 && bSound ) { | 470 | if ( stop < 120 && bSound ) { |
430 | Sound::soundAlarm(); | 471 | Sound::soundAlarm(); |
431 | stop++; | 472 | stop++; |
432 | } | 473 | } |
433 | else { | 474 | else { |
434 | stop = 0; | 475 | stop = 0; |
435 | killTimer( e->timerId() ); | 476 | killTimer( e->timerId() ); |
436 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 477 | clearTimer(); |
437 | alarmBool = FALSE; | ||
438 | snoozeBtn->hide(); | ||
439 | setCaption( tr( "Clock: Alarm was missed." ) ); | 478 | setCaption( tr( "Clock: Alarm was missed." ) ); |
440 | } | 479 | } |
441 | } | 480 | } |
442 | 481 | ||
443 | 482 | ||
444 | QSizePolicy AnalogClock::sizePolicy() const | 483 | QSizePolicy AnalogClock::sizePolicy() const |
445 | { | 484 | { |
446 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | 485 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); |
447 | } | 486 | } |
448 | 487 | ||
449 | void AnalogClock::drawContents( QPainter *p ) | 488 | void AnalogClock::drawContents( QPainter *p ) |
450 | { | 489 | { |
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h index 092d84f..23cc143 100644 --- a/noncore/tools/clock/clock.h +++ b/noncore/tools/clock/clock.h | |||
@@ -71,25 +71,25 @@ private slots: | |||
71 | void updateClock(); | 71 | void updateClock(); |
72 | void changeClock( bool ); | 72 | void changeClock( bool ); |
73 | void slotSetAlarm(); | 73 | void slotSetAlarm(); |
74 | void slotSnooze(); | 74 | void slotSnooze(); |
75 | void slotToggleAlarm(); | 75 | void slotToggleAlarm(); |
76 | void alarmOn(); | 76 | void alarmOn(); |
77 | void alarmOff(); | 77 | void alarmOff(); |
78 | void appMessage(const QCString& msg, const QByteArray& data); | 78 | void appMessage(const QCString& msg, const QByteArray& data); |
79 | void timerEvent( QTimerEvent *e ); | 79 | void timerEvent( QTimerEvent *e ); |
80 | void slotAdjustTime(); | 80 | void slotAdjustTime(); |
81 | private: | 81 | private: |
82 | void clearClock(); | 82 | void clearClock(); |
83 | 83 | void clearTimer(); | |
84 | bool alarmBool; | 84 | bool alarmBool; |
85 | QTimer *t; | 85 | QTimer *t; |
86 | QLCDNumber *lcd; | 86 | QLCDNumber *lcd; |
87 | QLabel *date; | 87 | QLabel *date; |
88 | QLabel *ampmLabel; | 88 | QLabel *ampmLabel; |
89 | QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; | 89 | QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; |
90 | QRadioButton *clockRB, *swatchRB; | 90 | QRadioButton *clockRB, *swatchRB; |
91 | AnalogClock *aclock; | 91 | AnalogClock *aclock; |
92 | QTime swatch_start; | 92 | QTime swatch_start; |
93 | int swatch_totalms; | 93 | int swatch_totalms; |
94 | bool swatch_running; | 94 | bool swatch_running; |
95 | bool ampm; | 95 | bool ampm; |
diff --git a/noncore/tools/clock/clock.pro b/noncore/tools/clock/clock.pro index 29dd52b..8b92118 100644 --- a/noncore/tools/clock/clock.pro +++ b/noncore/tools/clock/clock.pro | |||
@@ -1,21 +1,21 @@ | |||
1 | TEMPLATE = app | 1 | TEMPLATE = app |
2 | CONFIG = qt warn_on release | 2 | CONFIG = qt warn_on release |
3 | DESTDIR = $(OPIEDIR)/bin | 3 | DESTDIR = $(OPIEDIR)/bin |
4 | HEADERS = clock.h setAlarm.h | 4 | HEADERS = clock.h setAlarm.h |
5 | SOURCES = clock.cpp setAlarm.cpp \ | 5 | SOURCES = clock.cpp setAlarm.cpp \ |
6 | main.cpp | 6 | main.cpp |
7 | INCLUDEPATH += $(OPIEDIR)/include | 7 | INCLUDEPATH += $(OPIEDIR)/include |
8 | DEPENDPATH += $(OPIEDIR)/include | 8 | DEPENDPATH += $(OPIEDIR)/include |
9 | LIBS += -lqpe -lopie | 9 | LIBS += -lqpe -lopie -lpthread |
10 | INTERFACES = | 10 | INTERFACES = |
11 | TARGET = clock | 11 | TARGET = clock |
12 | 12 | ||
13 | TRANSLATIONS = ../../../i18n/de/clock.ts \ | 13 | TRANSLATIONS = ../../../i18n/de/clock.ts \ |
14 | ../../../i18n/xx/clock.ts \ | 14 | ../../../i18n/xx/clock.ts \ |
15 | ../../../i18n/en/clock.ts \ | 15 | ../../../i18n/en/clock.ts \ |
16 | ../../../i18n/es/clock.ts \ | 16 | ../../../i18n/es/clock.ts \ |
17 | ../../../i18n/fr/clock.ts \ | 17 | ../../../i18n/fr/clock.ts \ |
18 | ../../../i18n/hu/clock.ts \ | 18 | ../../../i18n/hu/clock.ts \ |
19 | ../../../i18n/ja/clock.ts \ | 19 | ../../../i18n/ja/clock.ts \ |
20 | ../../../i18n/ko/clock.ts \ | 20 | ../../../i18n/ko/clock.ts \ |
21 | ../../../i18n/no/clock.ts \ | 21 | ../../../i18n/no/clock.ts \ |