author | llornkcor <llornkcor> | 2003-03-04 16:50:17 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-03-04 16:50:17 (UTC) |
commit | bb765b9cd286d85eb8fa1d18199dfb7a29d57fc5 (patch) (unidiff) | |
tree | 80d69eef2975d1fb27a758aea7629d34c678a270 | |
parent | 628a783e5d7ec07b5c073c94a77b614439d937ba (diff) | |
download | opie-bb765b9cd286d85eb8fa1d18199dfb7a29d57fc5.zip opie-bb765b9cd286d85eb8fa1d18199dfb7a29d57fc5.tar.gz opie-bb765b9cd286d85eb8fa1d18199dfb7a29d57fc5.tar.bz2 |
added 3 qcop calls. timerStart(), timerStop() and timerReset()
-rw-r--r-- | noncore/tools/clock/clock.cpp | 171 | ||||
-rw-r--r-- | noncore/tools/clock/clock.h | 15 |
2 files changed, 121 insertions, 65 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index 0937362..9898332 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp | |||
@@ -80,6 +80,2 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
80 | 80 | ||
81 | Config config( "qpe" ); | ||
82 | config.setGroup( "Time" ); | ||
83 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
84 | |||
85 | 81 | ||
@@ -130,14 +126,8 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
130 | 126 | ||
131 | set | 127 | set = new QPushButton ( controls ); |
132 | = new QPushButton ( controls ); | 128 | set->setMaximumSize( 50, 30 ); |
133 | set | 129 | gl->addWidget( set , 0, 1 ); |
134 | ->setMaximumSize( 50, 30 ); | 130 | set->setText( tr( "Start" ) ); |
135 | gl->addWidget( set | 131 | set->setEnabled( FALSE ); |
136 | , 0, 1 ); | 132 | grp->insert( set ); |
137 | set | ||
138 | ->setText( tr( "Start" ) ); | ||
139 | set | ||
140 | ->setEnabled( FALSE ); | ||
141 | grp->insert( set | ||
142 | ); | ||
143 | 133 | ||
@@ -150,3 +140,2 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
150 | alarmOffBtn = new QPushButton ( controls ); | 140 | alarmOffBtn = new QPushButton ( controls ); |
151 | // alarmOffBtn->setMaximumSize(60,30); | ||
152 | gl->addWidget( alarmOffBtn, 0, 2 ); | 141 | gl->addWidget( alarmOffBtn, 0, 2 ); |
@@ -154,4 +143,4 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
154 | alarmBtn = new QPushButton ( controls ); | 143 | alarmBtn = new QPushButton ( controls ); |
155 | // alarmBtn->setMaximumSize(60,30); | ||
156 | gl->addWidget( alarmBtn, 1, 2 ); | 144 | gl->addWidget( alarmBtn, 1, 2 ); |
145 | |||
157 | alarmBtn->setText( tr( "Set Alarm" ) ); | 146 | alarmBtn->setText( tr( "Set Alarm" ) ); |
@@ -163,4 +152,3 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
163 | 152 | ||
164 | connect( set | 153 | connect( set , SIGNAL( pressed() ), SLOT( slotSet() ) ); |
165 | , SIGNAL( pressed() ), SLOT( slotSet() ) ); | ||
166 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); | 154 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); |
@@ -185,2 +173,7 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
185 | 173 | ||
174 | |||
175 | Config config( "qpe" ); | ||
176 | config.setGroup( "Time" ); | ||
177 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
178 | |||
186 | QString tmp = config.readEntry( "clockAlarmHour", "" ); | 179 | QString tmp = config.readEntry( "clockAlarmHour", "" ); |
@@ -191,3 +184,4 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
191 | 184 | ||
192 | if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) { | 185 | if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) |
186 | { | ||
193 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 187 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); |
@@ -196,3 +190,4 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
196 | } | 190 | } |
197 | else { | 191 | else |
192 | { | ||
198 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 193 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); |
@@ -203,3 +198,7 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) | |||
203 | QTimer::singleShot( 0, this, SLOT( updateClock() ) ); | 198 | QTimer::singleShot( 0, this, SLOT( updateClock() ) ); |
204 | modeSelect( 0 ); | 199 | |
200 | Config cfg( "Clock" ); | ||
201 | cfg.setGroup( "Mode" ); | ||
202 | int mode = cfg.readBoolEntry( "clockMode");setSwatchMode( mode); | ||
203 | modeSelect( mode); | ||
205 | } | 204 | } |
@@ -213,6 +212,8 @@ void Clock::updateClock() | |||
213 | { | 212 | { |
214 | if ( clockRB->isChecked() ) { | 213 | if ( clockRB->isChecked() ) |
214 | { | ||
215 | QTime tm = QDateTime::currentDateTime().time(); | 215 | QTime tm = QDateTime::currentDateTime().time(); |
216 | QString s; | 216 | QString s; |
217 | if ( ampm ) { | 217 | if ( ampm ) |
218 | { | ||
218 | int hour = tm.hour(); | 219 | int hour = tm.hour(); |
@@ -226,3 +227,4 @@ void Clock::updateClock() | |||
226 | } | 227 | } |
227 | else { | 228 | else |
229 | { | ||
228 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); | 230 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); |
@@ -235,3 +237,4 @@ void Clock::updateClock() | |||
235 | } | 237 | } |
236 | else { | 238 | else |
239 | { | ||
237 | QTime swatch_time; | 240 | QTime swatch_time; |
@@ -266,6 +269,6 @@ void Clock::slotSet() | |||
266 | { | 269 | { |
267 | if ( t->isActive() ) { | 270 | if ( t->isActive() ) |
271 | { | ||
268 | swatch_totalms += swatch_start.elapsed(); | 272 | swatch_totalms += swatch_start.elapsed(); |
269 | set | 273 | set->setText( tr( "Start" ) ); |
270 | ->setText( tr( "Start" ) ); | ||
271 | t->stop(); | 274 | t->stop(); |
@@ -275,6 +278,6 @@ void Clock::slotSet() | |||
275 | } | 278 | } |
276 | else { | 279 | else |
280 | { | ||
277 | swatch_start.start(); | 281 | swatch_start.start(); |
278 | set | 282 | set->setText( tr( "Stop" ) ); |
279 | ->setText( tr( "Stop" ) ); | ||
280 | t->start( 1000 ); | 283 | t->start( 1000 ); |
@@ -300,7 +303,8 @@ void Clock::modeSelect( int m ) | |||
300 | { | 303 | { |
301 | if ( m ) { | 304 | qDebug("Clock::modeSelect( %d) ", m); |
305 | if ( m ) | ||
306 | { | ||
302 | lcd->setNumDigits( 8 + 1 + sw_prec ); | 307 | lcd->setNumDigits( 8 + 1 + sw_prec ); |
303 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 308 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
304 | set | 309 | set->setEnabled( TRUE ); |
305 | ->setEnabled( TRUE ); | ||
306 | reset->setEnabled( TRUE ); | 310 | reset->setEnabled( TRUE ); |
@@ -311,7 +315,7 @@ void Clock::modeSelect( int m ) | |||
311 | } | 315 | } |
312 | else { | 316 | else |
317 | { | ||
313 | lcd->setNumDigits( 5 ); | 318 | lcd->setNumDigits( 5 ); |
314 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 319 | lcd->setMinimumWidth( lcd->sizeHint().width() ); |
315 | set | 320 | set->setEnabled( FALSE ); |
316 | ->setEnabled( FALSE ); | ||
317 | reset->setEnabled( FALSE ); | 321 | reset->setEnabled( FALSE ); |
@@ -319,2 +323,6 @@ void Clock::modeSelect( int m ) | |||
319 | } | 323 | } |
324 | |||
325 | Config config( "Clock" ); | ||
326 | config.setGroup( "Mode" ); | ||
327 | config.writeEntry( "clockMode", m ); | ||
320 | updateClock(); | 328 | updateClock(); |
@@ -369,3 +377,4 @@ void Clock::slotToggleAlarm() | |||
369 | config.setGroup( "Time" ); | 377 | config.setGroup( "Time" ); |
370 | if ( alarmBool ) { | 378 | if ( alarmBool ) |
379 | { | ||
371 | config.writeEntry( "clockAlarmSet", "FALSE" ); | 380 | config.writeEntry( "clockAlarmSet", "FALSE" ); |
@@ -376,3 +385,4 @@ void Clock::slotToggleAlarm() | |||
376 | } | 385 | } |
377 | else { | 386 | else |
387 | { | ||
378 | config.writeEntry( "clockAlarmSet", "TRUE" ); | 388 | config.writeEntry( "clockAlarmSet", "TRUE" ); |
@@ -428,3 +438,4 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | |||
428 | qDebug( "Message received in clock" ); | 438 | qDebug( "Message received in clock" ); |
429 | if ( msg == "alarm(QDateTime,int)" ) { | 439 | if ( msg == "alarm(QDateTime,int)" ) |
440 | { | ||
430 | Config config( "qpe" ); | 441 | Config config( "qpe" ); |
@@ -434,19 +445,4 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | |||
434 | clearTimer(); | 445 | 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; | 446 | pthread_t thread; |
447 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); | 447 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); |
448 | // startPlayer(); | ||
449 | // } | ||
450 | // break; | ||
451 | // }; | ||
452 | 448 | ||
@@ -460,2 +456,16 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | |||
460 | } | 456 | } |
457 | |||
458 | if ( msg == "timerStart()" ) | ||
459 | { | ||
460 | slotStartTimer(); | ||
461 | } | ||
462 | if ( msg == "timerStop()" ) | ||
463 | { | ||
464 | slotStopTimer(); | ||
465 | } | ||
466 | if ( msg == "timerReset()" ) | ||
467 | { | ||
468 | slotResetTimer(); | ||
469 | } | ||
470 | |||
461 | show(); | 471 | show(); |
@@ -469,3 +479,4 @@ void Clock::timerEvent( QTimerEvent *e ) | |||
469 | static int stop = 0; | 479 | static int stop = 0; |
470 | if ( stop < 120 && bSound ) { | 480 | if ( stop < 120 && bSound ) |
481 | { | ||
471 | Sound::soundAlarm(); | 482 | Sound::soundAlarm(); |
@@ -473,3 +484,4 @@ void Clock::timerEvent( QTimerEvent *e ) | |||
473 | } | 484 | } |
474 | else { | 485 | else |
486 | { | ||
475 | stop = 0; | 487 | stop = 0; |
@@ -503,3 +515,4 @@ void AnalogClock::drawContents( QPainter *p ) | |||
503 | 515 | ||
504 | if ( clear ) { | 516 | if ( clear ) |
517 | { | ||
505 | erase ( r ); | 518 | erase ( r ); |
@@ -515,3 +528,4 @@ void AnalogClock::drawContents( QPainter *p ) | |||
515 | } | 528 | } |
516 | else { | 529 | else |
530 | { | ||
517 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); | 531 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); |
@@ -586 +600,36 @@ void Clock::slotAdjustTime() | |||
586 | } | 600 | } |
601 | |||
602 | void Clock::slotStartTimer() | ||
603 | { | ||
604 | Config cfg( "Clock" ); | ||
605 | cfg.setGroup( "Mode" ); | ||
606 | int mode = cfg.readBoolEntry( "clockMode"); | ||
607 | if ( clockRB->isChecked() ) | ||
608 | setSwatchMode( 1); | ||
609 | slotSet(); | ||
610 | } | ||
611 | |||
612 | void Clock::slotStopTimer() | ||
613 | { | ||
614 | Config cfg( "Clock" ); | ||
615 | cfg.setGroup( "Mode" ); | ||
616 | int mode = cfg.readBoolEntry( "clockMode"); | ||
617 | if ( clockRB->isChecked() ) | ||
618 | setSwatchMode( 1); | ||
619 | slotSet(); | ||
620 | } | ||
621 | |||
622 | void Clock::slotResetTimer() | ||
623 | { | ||
624 | if ( clockRB->isChecked() ) | ||
625 | setSwatchMode( 1); | ||
626 | slotReset(); | ||
627 | } | ||
628 | |||
629 | void Clock::setSwatchMode(int mode) | ||
630 | { | ||
631 | qDebug("Clock::setSwatchMode( %d)"), mode; | ||
632 | swatchRB->setChecked( mode); | ||
633 | clearClock( ); | ||
634 | modeSelect( mode ); | ||
635 | } | ||
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h index 23cc143..9b00e28 100644 --- a/noncore/tools/clock/clock.h +++ b/noncore/tools/clock/clock.h | |||
@@ -48,4 +48,2 @@ protected: | |||
48 | private: | 48 | private: |
49 | QPoint rotate( QPoint center, QPoint p, int angle ); | ||
50 | void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); | ||
51 | 49 | ||
@@ -54,2 +52,6 @@ private: | |||
54 | bool clear; | 52 | bool clear; |
53 | |||
54 | QPoint rotate( QPoint center, QPoint p, int angle ); | ||
55 | void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); | ||
56 | |||
55 | }; | 57 | }; |
@@ -80,5 +82,8 @@ private slots: | |||
80 | void slotAdjustTime(); | 82 | void slotAdjustTime(); |
83 | |||
84 | void slotStartTimer(); | ||
85 | void slotStopTimer(); | ||
86 | void slotResetTimer(); | ||
87 | void setSwatchMode( int ); | ||
81 | private: | 88 | private: |
82 | void clearClock(); | ||
83 | void clearTimer(); | ||
84 | bool alarmBool; | 89 | bool alarmBool; |
@@ -95,2 +100,4 @@ private: | |||
95 | bool ampm; | 100 | bool ampm; |
101 | void clearClock(); | ||
102 | void clearTimer(); | ||
96 | }; | 103 | }; |