summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp53
-rw-r--r--noncore/tools/clock/clock.h2
-rw-r--r--noncore/tools/clock/clock.pro2
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
@@ -47,10 +47,25 @@
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
51const double deg2rad = 0.017453292519943295769; // pi/180 56const double deg2rad = 0.017453292519943295769; // pi/180
52const int sw_prec = 2; 57const int sw_prec = 2;
53 58
59void 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
54static void toggleScreenSaver( bool on ) 69static void toggleScreenSaver( bool on )
55{ 70{
56 QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); 71 QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" );
@@ -397,6 +412,14 @@ void Clock::alarmOff()
397 setCaption( "Clock" ); 412 setCaption( "Clock" );
398} 413}
399 414
415void Clock::clearTimer()
416{
417 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
418 alarmBool = FALSE;
419 snoozeBtn->hide();
420 setCaption( "Clock" );
421}
422
400void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) 423void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
401{ 424{
402 int stopTimer = 0; 425 int stopTimer = 0;
@@ -406,12 +429,30 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
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 );
@@ -433,9 +474,7 @@ void Clock::timerEvent( QTimerEvent *e )
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}
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
@@ -80,7 +80,7 @@ private slots:
80 void slotAdjustTime(); 80 void slotAdjustTime();
81private: 81private:
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;
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
@@ -6,7 +6,7 @@ SOURCES = clock.cpp setAlarm.cpp \
6 main.cpp 6 main.cpp
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
8DEPENDPATH += $(OPIEDIR)/include 8DEPENDPATH += $(OPIEDIR)/include
9LIBS += -lqpe -lopie 9LIBS += -lqpe -lopie -lpthread
10INTERFACES = 10INTERFACES =
11TARGET = clock 11TARGET = clock
12 12