summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/clock/clock.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 69d8214..e3621d9 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -324,188 +324,188 @@ void Clock::slotSnooze()
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());
}
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");
}
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)){
QCopEnvelope e("QPE/Application/opieplayer","setDocument(QString)");
e<<config.readEntry("mp3File","");
} else {
Sound::soundAlarm();
stopTimer = startTimer( timerStay);
}
}
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() );
alarmOffBtn->setText( tr( "Alarm Is Off" ) );
alarmBool=FALSE;
snoozeBtn->hide();
- setCaption("Clock: Alarm was missed.");
+ setCaption(tr("Clock: Alarm was missed."));
}
}
QSizePolicy AnalogClock::sizePolicy() const
{
return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
}
void AnalogClock::drawContents( QPainter *p )
{
QRect r = contentsRect();
QPoint center( r.x() + r.width() / 2, r.y() + r.height() / 2 );
QPoint l1( r.x() + r.width() / 2, r.y() + 2 );
QPoint l2( r.x() + r.width() / 2, r.y() + 8 );
QPoint h1( r.x() + r.width() / 2, r.y() + r.height() / 4 );
QPoint h2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
QPoint m1( r.x() + r.width() / 2, r.y() + r.height() / 8 );
QPoint m2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
QPoint s1( r.x() + r.width() / 2, r.y() + 8 );
QPoint s2( r.x() + r.width() / 2, r.y() + r.height() / 2 );
QColor color( clear ? backgroundColor() : black );
QTime time = clear ? prevTime : currTime;
if ( clear && prevTime.secsTo(currTime) > 1 ) {
p->eraseRect( rect() );
return;
}
if ( !clear ) {
// draw ticks
p->setPen( QPen( color, 1 ) );
for ( int i = 0; i < 12; i++ )
p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
}
if ( !clear || prevTime.minute() != currTime.minute() ||
prevTime.hour() != currTime.hour() ) {
// draw hour pointer
h1 = rotate( center, h1, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
h2 = rotate( center, h2, 30 * ( time.hour() % 12 ) + time.minute() / 2 );
p->setPen( QPen( color, 3 ) );
p->drawLine( h1, h2 );
}
if ( !clear || prevTime.minute() != currTime.minute() ) {
// draw minute pointer
m1 = rotate( center, m1, time.minute() * 6 );
m2 = rotate( center, m2, time.minute() * 6 );
p->setPen( QPen( color, 2 ) );
p->drawLine( m1, m2 );
}
// draw second pointer
s1 = rotate( center, s1, time.second() * 6 );
s2 = rotate( center, s2, time.second() * 6 );
p->setPen( QPen( color, 1 ) );
p->drawLine( s1, s2 );
if ( !clear )
prevTime = currTime;
}
void AnalogClock::display( const QTime& t )
{
currTime = t;
clear = true;
repaint( false );
clear = false;
repaint( false );
}
QPoint AnalogClock::rotate( QPoint c, QPoint p, int a )
{
double angle = deg2rad * ( - a + 180 );
double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) -
( p.y() - c.y() ) * sin( angle );
double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) +
( p.x() - c.x() ) * sin( angle );
return QPoint( nx, ny );
}
void Clock::slotAdjustTime() {
QCopEnvelope e("QPE/System", "execute(QString)");
e << QString("systemtime");
}