summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp11
-rw-r--r--noncore/tools/clock/clock.h1
2 files changed, 9 insertions, 3 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 0a21146..9b9e644 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -4,32 +4,33 @@
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// changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002
20 21
21#include "clock.h" 22#include "clock.h"
22#include "setAlarm.h" 23#include "setAlarm.h"
23 24
24#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
25#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
26#include <qpe/config.h> 27#include <qpe/config.h>
27#include <qpe/timestring.h> 28#include <qpe/timestring.h>
28#include <qpe/alarmserver.h> 29#include <qpe/alarmserver.h>
29#include <qpe/sound.h> 30#include <qpe/sound.h>
30#include <qpe/resource.h> 31#include <qpe/resource.h>
31#include <qsound.h> 32#include <qsound.h>
32#include <qtimer.h> 33#include <qtimer.h>
33 34
34#include <opie/oclickablelabel.h> 35#include <opie/oclickablelabel.h>
35 36
@@ -53,32 +54,33 @@ const int sw_prec = 2;
53static void toggleScreenSaver( bool on ) 54static void toggleScreenSaver( bool on )
54{ 55{
55 QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" ); 56 QCopEnvelope e("QPE/System", "setScreenSaverMode(int)" );
56 e << (on ? QPEApplication::Enable: QPEApplication::DisableSuspend ); 57 e << (on ? QPEApplication::Enable: QPEApplication::DisableSuspend );
57} 58}
58 59
59Clock::Clock( QWidget * parent, const char * name, WFlags f ) 60Clock::Clock( QWidget * parent, const char * name, WFlags f )
60 : QVBox( parent, name , f ) 61 : QVBox( parent, name , f )
61{ 62{
62 setSpacing( 4 ); 63 setSpacing( 4 );
63 setMargin( 1 ); 64 setMargin( 1 );
64 65
65 Config config( "qpe" ); 66 Config config( "qpe" );
66 config.setGroup("Time"); 67 config.setGroup("Time");
67 ampm = config.readBoolEntry( "AMPM", TRUE ); 68 ampm = config.readBoolEntry( "AMPM", TRUE );
68 69
70
69 snoozeBtn = new QPushButton ( this); 71 snoozeBtn = new QPushButton ( this);
70 snoozeBtn->setText( tr( "Snooze" ) ); 72 snoozeBtn->setText( tr( "Snooze" ) );
71 73
72 aclock = new AnalogClock( this ); 74 aclock = new AnalogClock( this );
73 aclock->display( QTime::currentTime() ); 75 aclock->display( QTime::currentTime() );
74 aclock->setLineWidth( 2 ); 76 aclock->setLineWidth( 2 );
75 77
76 QHBox *hb = new QHBox( this ); 78 QHBox *hb = new QHBox( this );
77 hb->setMargin( 0 ); 79 hb->setMargin( 0 );
78 QWidget *space = new QWidget( hb ); 80 QWidget *space = new QWidget( hb );
79 lcd = new QLCDNumber( hb ); 81 lcd = new QLCDNumber( hb );
80 lcd->setSegmentStyle( QLCDNumber::Flat ); 82 lcd->setSegmentStyle( QLCDNumber::Flat );
81 lcd->setFrameStyle( QFrame::NoFrame ); 83 lcd->setFrameStyle( QFrame::NoFrame );
82 lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); 84 lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
83 lcd->setFixedHeight( 23 ); 85 lcd->setFixedHeight( 23 );
84 86
@@ -367,36 +369,41 @@ void Clock::alarmOn()
367void Clock::alarmOff() 369void Clock::alarmOff()
368{ 370{
369 int warn = 0; 371 int warn = 0;
370 bSound=FALSE; 372 bSound=FALSE;
371 AlarmServer::deleteAlarm( when, 373 AlarmServer::deleteAlarm( when,
372 "QPE/Application/clock", 374 "QPE/Application/clock",
373 "alarm(QDateTime,int)", warn ); 375 "alarm(QDateTime,int)", warn );
374 qDebug("Alarm Off "+ when.toString()); 376 qDebug("Alarm Off "+ when.toString());
375 setCaption("Clock"); 377 setCaption("Clock");
376} 378}
377 379
378void Clock::appMessage(const QCString& msg, const QByteArray& data) 380void Clock::appMessage(const QCString& msg, const QByteArray& data)
379{ 381{
380 int stopTimer = 0; 382 int stopTimer = 0;
381 int timerStay = 5000; 383 int timerStay = 5000;
382 bSound=TRUE; 384 bSound=TRUE;
385 qDebug("Message received in clock");
383 if ( msg == "alarm(QDateTime,int)" ) { 386 if ( msg == "alarm(QDateTime,int)" ) {
384 Sound::soundAlarm(); 387 Sound::soundAlarm();
385 stopTimer = startTimer( timerStay); 388 stopTimer = startTimer( timerStay);
386 } 389 }
390 show();
391 raise();
392 QPEApplication::setKeepRunning();
393 setActiveWindow();
387} 394}
388 395
389void Clock::timerEvent( QTimerEvent *e ) 396void Clock::timerEvent( QTimerEvent *e )
390{ 397{
391 static int stop = 0; 398 static int stop = 0;
392 if ( stop < 120 && bSound) { 399 if ( stop < 120 && bSound) {
393 Sound::soundAlarm(); 400 Sound::soundAlarm();
394 stop++; 401 stop++;
395 } else { 402 } else {
396 stop = 0; 403 stop = 0;
397 killTimer( e->timerId() ); 404 killTimer( e->timerId() );
398 alarmOffBtn->setText( tr( "Alarm Is Off" ) ); 405 alarmOffBtn->setText( tr( "Alarm Is Off" ) );
399 alarmBool=FALSE; 406 alarmBool=FALSE;
400 snoozeBtn->hide(); 407 snoozeBtn->hide();
401 setCaption("Clock: Alarm was missed."); 408 setCaption("Clock: Alarm was missed.");
402 } 409 }
@@ -472,21 +479,21 @@ void AnalogClock::display( const QTime& t )
472 currTime = t; 479 currTime = t;
473 clear = true; 480 clear = true;
474 repaint( false ); 481 repaint( false );
475 clear = false; 482 clear = false;
476 repaint( false ); 483 repaint( false );
477} 484}
478 485
479QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) 486QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
480{ 487{
481 double angle = deg2rad * ( - a + 180 ); 488 double angle = deg2rad * ( - a + 180 );
482 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - 489 double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
483 ( p.y() - c.y() ) * sin( angle ); 490 ( p.y() - c.y() ) * sin( angle );
484 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + 491 double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
485 ( p.x() - c.x() ) * sin( angle ); 492 ( p.x() - c.x() ) * sin( angle );
486 return QPoint( nx, ny ); 493 return QPoint( nx, ny );
487} 494}
488void Clock::slotAdjustTime() 495
489{ 496void Clock::slotAdjustTime() {
490 QCopEnvelope e("QPE/System", "execute(QString)"); 497 QCopEnvelope e("QPE/System", "execute(QString)");
491 e << QString("systemtime"); 498 e << QString("systemtime");
492} 499}
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index 024dd28..be71b9d 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -64,33 +64,32 @@ public:
64 bool bSound; 64 bool bSound;
65 int hour, minute, snoozeTime; 65 int hour, minute, snoozeTime;
66private slots: 66private slots:
67 void slotSet(); 67 void slotSet();
68 void slotReset(); 68 void slotReset();
69 void modeSelect(int); 69 void modeSelect(int);
70 void updateClock(); 70 void updateClock();
71 void changeClock( bool ); 71 void changeClock( bool );
72 void slotSetAlarm(); 72 void slotSetAlarm();
73 void slotSnooze(); 73 void slotSnooze();
74 void slotToggleAlarm(); 74 void slotToggleAlarm();
75 void alarmOn(); 75 void alarmOn();
76 void alarmOff(); 76 void alarmOff();
77 void appMessage(const QCString& msg, const QByteArray& data); 77 void appMessage(const QCString& msg, const QByteArray& data);
78 void timerEvent( QTimerEvent *e ); 78 void timerEvent( QTimerEvent *e );
79 void slotAdjustTime(); 79 void slotAdjustTime();
80
81private: 80private:
82 void clearClock(); 81 void clearClock();
83 82
84 bool alarmBool; 83 bool alarmBool;
85 QTimer *t; 84 QTimer *t;
86 QLCDNumber *lcd; 85 QLCDNumber *lcd;
87 QLabel *date; 86 QLabel *date;
88 QLabel *ampmLabel; 87 QLabel *ampmLabel;
89 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; 88 QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn;
90 QRadioButton *clockRB, *swatchRB; 89 QRadioButton *clockRB, *swatchRB;
91 AnalogClock *aclock; 90 AnalogClock *aclock;
92 QTime swatch_start; 91 QTime swatch_start;
93 int swatch_totalms; 92 int swatch_totalms;
94 bool swatch_running; 93 bool swatch_running;
95 bool ampm; 94 bool ampm;
96}; 95};