summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp171
-rw-r--r--noncore/tools/clock/clock.h15
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 )
- Config config( "qpe" );
- config.setGroup( "Time" );
- ampm = config.readBoolEntry( "AMPM", TRUE );
-
@@ -130,14 +126,8 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
- set
- = new QPushButton ( controls );
- set
- ->setMaximumSize( 50, 30 );
- gl->addWidget( set
- , 0, 1 );
- set
- ->setText( tr( "Start" ) );
- set
- ->setEnabled( FALSE );
- grp->insert( set
- );
+ set = new QPushButton ( controls );
+ set->setMaximumSize( 50, 30 );
+ gl->addWidget( set , 0, 1 );
+ set->setText( tr( "Start" ) );
+ set->setEnabled( FALSE );
+ grp->insert( set );
@@ -150,3 +140,2 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
alarmOffBtn = new QPushButton ( controls );
- // alarmOffBtn->setMaximumSize(60,30);
gl->addWidget( alarmOffBtn, 0, 2 );
@@ -154,4 +143,4 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
alarmBtn = new QPushButton ( controls );
- // alarmBtn->setMaximumSize(60,30);
gl->addWidget( alarmBtn, 1, 2 );
+
alarmBtn->setText( tr( "Set Alarm" ) );
@@ -163,4 +152,3 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
- connect( set
- , SIGNAL( pressed() ), SLOT( slotSet() ) );
+ connect( set , SIGNAL( pressed() ), SLOT( slotSet() ) );
connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) );
@@ -185,2 +173,7 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
+
+ Config config( "qpe" );
+ config.setGroup( "Time" );
+ ampm = config.readBoolEntry( "AMPM", TRUE );
+
QString tmp = config.readEntry( "clockAlarmHour", "" );
@@ -191,3 +184,4 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
- if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) {
+ if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" )
+ {
alarmOffBtn->setText( tr( "Alarm Is On" ) );
@@ -196,3 +190,4 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
}
- else {
+ else
+ {
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
@@ -203,3 +198,7 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f )
QTimer::singleShot( 0, this, SLOT( updateClock() ) );
- modeSelect( 0 );
+
+ Config cfg( "Clock" );
+ cfg.setGroup( "Mode" );
+ int mode = cfg.readBoolEntry( "clockMode");setSwatchMode( mode);
+ modeSelect( mode);
}
@@ -213,6 +212,8 @@ void Clock::updateClock()
{
- if ( clockRB->isChecked() ) {
+ if ( clockRB->isChecked() )
+ {
QTime tm = QDateTime::currentDateTime().time();
QString s;
- if ( ampm ) {
+ if ( ampm )
+ {
int hour = tm.hour();
@@ -226,3 +227,4 @@ void Clock::updateClock()
}
- else {
+ else
+ {
s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() );
@@ -235,3 +237,4 @@ void Clock::updateClock()
}
- else {
+ else
+ {
QTime swatch_time;
@@ -266,6 +269,6 @@ void Clock::slotSet()
{
- if ( t->isActive() ) {
+ if ( t->isActive() )
+ {
swatch_totalms += swatch_start.elapsed();
- set
- ->setText( tr( "Start" ) );
+ set->setText( tr( "Start" ) );
t->stop();
@@ -275,6 +278,6 @@ void Clock::slotSet()
}
- else {
+ else
+ {
swatch_start.start();
- set
- ->setText( tr( "Stop" ) );
+ set->setText( tr( "Stop" ) );
t->start( 1000 );
@@ -300,7 +303,8 @@ void Clock::modeSelect( int m )
{
- if ( m ) {
+ qDebug("Clock::modeSelect( %d) ", m);
+ if ( m )
+ {
lcd->setNumDigits( 8 + 1 + sw_prec );
lcd->setMinimumWidth( lcd->sizeHint().width() );
- set
- ->setEnabled( TRUE );
+ set->setEnabled( TRUE );
reset->setEnabled( TRUE );
@@ -311,7 +315,7 @@ void Clock::modeSelect( int m )
}
- else {
+ else
+ {
lcd->setNumDigits( 5 );
lcd->setMinimumWidth( lcd->sizeHint().width() );
- set
- ->setEnabled( FALSE );
+ set->setEnabled( FALSE );
reset->setEnabled( FALSE );
@@ -319,2 +323,6 @@ void Clock::modeSelect( int m )
}
+
+ Config config( "Clock" );
+ config.setGroup( "Mode" );
+ config.writeEntry( "clockMode", m );
updateClock();
@@ -369,3 +377,4 @@ void Clock::slotToggleAlarm()
config.setGroup( "Time" );
- if ( alarmBool ) {
+ if ( alarmBool )
+ {
config.writeEntry( "clockAlarmSet", "FALSE" );
@@ -376,3 +385,4 @@ void Clock::slotToggleAlarm()
}
- else {
+ else
+ {
config.writeEntry( "clockAlarmSet", "TRUE" );
@@ -428,3 +438,4 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
qDebug( "Message received in clock" );
- if ( msg == "alarm(QDateTime,int)" ) {
+ if ( msg == "alarm(QDateTime,int)" )
+ {
Config config( "qpe" );
@@ -434,19 +445,4 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
clearTimer();
-// pid_t pid;
-// switch(pid = fork())
-// {
-// case -1:
-// {//failed
-// }
-// break;
-// case 0:
-// {//child
-// QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" );
-// e << config.readEntry( "mp3File", "" );
pthread_t thread;
pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/);
-// startPlayer();
-// }
-// break;
-// };
@@ -460,2 +456,16 @@ void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
}
+
+ if ( msg == "timerStart()" )
+ {
+ slotStartTimer();
+ }
+ if ( msg == "timerStop()" )
+ {
+ slotStopTimer();
+ }
+ if ( msg == "timerReset()" )
+ {
+ slotResetTimer();
+ }
+
show();
@@ -469,3 +479,4 @@ void Clock::timerEvent( QTimerEvent *e )
static int stop = 0;
- if ( stop < 120 && bSound ) {
+ if ( stop < 120 && bSound )
+ {
Sound::soundAlarm();
@@ -473,3 +484,4 @@ void Clock::timerEvent( QTimerEvent *e )
}
- else {
+ else
+ {
stop = 0;
@@ -503,3 +515,4 @@ void AnalogClock::drawContents( QPainter *p )
- if ( clear ) {
+ if ( clear )
+ {
erase ( r );
@@ -515,3 +528,4 @@ void AnalogClock::drawContents( QPainter *p )
}
- else {
+ else
+ {
drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime );
@@ -586 +600,36 @@ void Clock::slotAdjustTime()
}
+
+void Clock::slotStartTimer()
+{
+ Config cfg( "Clock" );
+ cfg.setGroup( "Mode" );
+ int mode = cfg.readBoolEntry( "clockMode");
+ if ( clockRB->isChecked() )
+ setSwatchMode( 1);
+ slotSet();
+}
+
+void Clock::slotStopTimer()
+{
+ Config cfg( "Clock" );
+ cfg.setGroup( "Mode" );
+ int mode = cfg.readBoolEntry( "clockMode");
+ if ( clockRB->isChecked() )
+ setSwatchMode( 1);
+slotSet();
+}
+
+void Clock::slotResetTimer()
+{
+ if ( clockRB->isChecked() )
+ setSwatchMode( 1);
+slotReset();
+}
+
+void Clock::setSwatchMode(int mode)
+{
+ qDebug("Clock::setSwatchMode( %d)"), mode;
+ swatchRB->setChecked( mode);
+ clearClock( );
+ modeSelect( mode );
+}
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:
private:
- QPoint rotate( QPoint center, QPoint p, int angle );
- void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 );
@@ -54,2 +52,6 @@ private:
bool clear;
+
+ QPoint rotate( QPoint center, QPoint p, int angle );
+ void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 );
+
};
@@ -80,5 +82,8 @@ private slots:
void slotAdjustTime();
+
+ void slotStartTimer();
+ void slotStopTimer();
+ void slotResetTimer();
+ void setSwatchMode( int );
private:
- void clearClock();
- void clearTimer();
bool alarmBool;
@@ -95,2 +100,4 @@ private:
bool ampm;
+ void clearClock();
+ void clearTimer();
};