summaryrefslogtreecommitdiff
path: root/noncore/tools/clock/clock.cpp
Side-by-side diff
Diffstat (limited to 'noncore/tools/clock/clock.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 41c99a8..ecbf12f 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -340,212 +340,213 @@ void Clock::modeSelect( int m )
}
else //clock mode
{
lcd->setNumDigits( 5 );
lcd->setMinimumWidth( lcd->sizeHint().width() );
set->setEnabled( FALSE );
reset->setEnabled( FALSE );
t->start( 1000 );
}
Config config( "Clock" );
config.setGroup( "Mode" );
config.writeEntry( "clockMode", m );
updateClock();
}
//this sets the alarm time
void Clock::slotSetAlarm()
{
if ( !snoozeBtn->isHidden() )
slotToggleAlarm();
Set_Alarm *setAlarmDlg;
setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE );
int result = setAlarmDlg->exec();
if ( result == 1 ) {
Config config( "qpe" );
config.setGroup( "Time" );
QString tmp;
hour = setAlarmDlg->Hour_Slider->value();
minute = setAlarmDlg->Minute_Slider->value();
snoozeTime = setAlarmDlg->SnoozeSlider->value();
if ( ampm ) {
if ( hour == 12 )
hour = 0;
if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 )
hour += 12;
}
config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 );
config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 );
config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 );
config.write();
}
}
void Clock::slotSnooze()
{
bSound = FALSE;
int warn = 0;
QTime t = QTime::currentTime();
QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) );
when = whenl;
AlarmServer::addAlarm( when,
"QPE/Application/clock",
"alarm(QDateTime,int)", warn );
}
//toggles alarm on/off
void Clock::slotToggleAlarm()
{
Config config( "qpe" );
config.setGroup( "Time" );
if ( alarmBool )
{
config.writeEntry( "clockAlarmSet", "FALSE" );
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
snoozeBtn->hide();
alarmBool = FALSE;
alarmOff();
}
else
{
config.writeEntry( "clockAlarmSet", "TRUE" );
alarmOffBtn->setText( tr( "Alarm Is On" ) );
snoozeBtn->show();
alarmBool = TRUE;
alarmOn();
}
config.write();
}
void Clock::alarmOn()
{
QDate d = QDate::currentDate();
QTime tm( ( int ) hour, ( int ) minute, 0 );
qDebug( "Time set " + tm.toString() );
QTime t = QTime::currentTime();
if ( t > tm )
d = d.addDays( 1 );
int warn = 0;
QDateTime whenl( d, tm );
when = whenl;
AlarmServer::addAlarm( when,
"QPE/Application/clock",
"alarm(QDateTime,int)", warn );
- setCaption( "Alarm set: " + whenl.toString() );
+// setCaption( "Alarm set: " + whenl.toString() );
+ setCaption( tr("Alarm set: %1" ).arg(whenl.toString()) );
}
void Clock::alarmOff()
{
int warn = 0;
bSound = FALSE;
AlarmServer::deleteAlarm( when,
"QPE/Application/clock",
"alarm(QDateTime,int)", warn );
qDebug( "Alarm Off " + when.toString() );
- setCaption( "Clock" );
+ setCaption( tr("Clock") );
}
void Clock::clearTimer()
{
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
alarmBool = FALSE;
snoozeBtn->hide();
- setCaption( "Clock" );
+ setCaption( tr("Clock") );
}
void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ )
{
int stopTimer = 0;
int timerStay = 5000;
bSound = TRUE;
qDebug( "Message received in clock" );
if ( msg == "alarm(QDateTime,int)" )
{
Config config( "qpe" );
config.setGroup( "Time" );
if ( config.readBoolEntry( "mp3Alarm", 0 ) )
{
clearTimer();
pthread_t thread;
pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/);
}
else
{
Sound::soundAlarm();
stopTimer = startTimer( timerStay );
}
}
if ( msg == "timerStart()" )
{
slotStartTimer();
}
if ( msg == "timerStop()" )
{
slotStopTimer();
}
if ( msg == "timerReset()" )
{
slotResetTimer();
}
show();
raise();
QPEApplication::setKeepRunning();
setActiveWindow();
}
void Clock::timerEvent( QTimerEvent *e )
{
static int stop = 0;
if ( stop < 120 && bSound )
{
Sound::soundAlarm();
stop++;
}
else
{
stop = 0;
killTimer( e->timerId() );
clearTimer();
setCaption( tr( "Clock: Alarm was missed." ) );
}
}
AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true)
{
bg = Resource::loadPixmap("clock/bg");
}
QSizePolicy AnalogClock::sizePolicy() const
{
return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
}
void AnalogClock::drawContents( QPainter *p )
{
QRect r = contentsRect();
QRect fr;
p->drawPixmap(QPoint(0, 0), bg, r);
if ( r. width ( ) > r. height ( ))
fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( ));
else
fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( ));
QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 );
QPoint l1 ( center. x ( ), fr. y ( ) + 2 );
QPoint l2 ( center. x ( ), fr. y ( ) + 8 );
if ( clear )
{
erase ( r );
p-> setPen ( NoPen );
p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base ));