-rw-r--r-- | noncore/tools/clock/clock.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp index ea8e8ca..a85cc19 100644 --- a/noncore/tools/clock/clock.cpp +++ b/noncore/tools/clock/clock.cpp @@ -4,48 +4,47 @@ ** This file is part of Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ +// code added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002 #include "clock.h" #include "setAlarm.h" #include <qpe/qpeapplication.h> #include <qpe/qcopenvelope_qws.h> #include <qpe/config.h> #include <qpe/timestring.h> #include <qpe/alarmserver.h> #include <qpe/sound.h> #include <qpe/resource.h> #include <qsound.h> #include <qtimer.h> -#include <opie/oclickablelabel.h> - #include <qlcdnumber.h> #include <qslider.h> #include <qlabel.h> #include <qlayout.h> #include <qtimer.h> #include <qpushbutton.h> #include <qradiobutton.h> #include <qbuttongroup.h> #include <qpainter.h> #include <qmessagebox.h> #include <qdatetime.h> #include <math.h> const double deg2rad = 0.017453292519943295769; // pi/180 const int sw_prec = 2; @@ -81,33 +80,33 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) lcd->setFrameStyle( QFrame::NoFrame ); lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); lcd->setFixedHeight( 23 ); ampmLabel = new QLabel( tr("PM"), hb ); ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); ampmLabel->setAlignment( AlignLeft | AlignBottom ); space = new QWidget( hb ); date = new QLabel( this ); date->setAlignment( AlignHCenter | AlignVCenter ); date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); date->setText( TimeString::longDateString( QDate::currentDate() ) ); QWidget *controls = new QWidget( this ); - QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 ); + QGridLayout *gl = new QGridLayout( controls, 2, 2, 6, 4 ); QButtonGroup *grp = new QButtonGroup( controls ); grp->setRadioButtonExclusive( true ); grp->hide(); clockRB = new QRadioButton ( tr( "Clock" ), controls ); gl->addWidget( clockRB, 0, 0 ); grp->insert( clockRB ); swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); gl->addWidget( swatchRB, 1, 0 ); grp->insert( swatchRB ); connect( grp, SIGNAL(clicked(int)), this, SLOT(modeSelect(int)) ); grp->setButton( 0 ); @@ -120,37 +119,32 @@ Clock::Clock( QWidget * parent, const char * name, WFlags f ) reset = new QPushButton ( controls ); gl->addWidget( reset, 1, 1 ); reset->setText( tr( "Reset" ) ); reset->setEnabled( FALSE ); grp->insert( reset ); alarmOffBtn = new QPushButton ( controls ); // alarmOffBtn->setMaximumSize(60,30); gl->addWidget( alarmOffBtn, 0, 2 ); alarmBtn = new QPushButton ( controls ); // alarmBtn->setMaximumSize(60,30); gl->addWidget( alarmBtn, 1, 2 ); alarmBtn->setText( tr( "Set Alarm" ) ); - OClickableLabel *click = new OClickableLabel(controls, "label" ); - click->setText(tr("Set date and time." ) ); - gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter); - connect( click, SIGNAL(clicked() ), this, SLOT(slotAdjustTime() ) ); - connect( set, SIGNAL( pressed() ), SLOT( slotSet() ) ); connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) ); t = new QTimer( this ); connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); t->start( 1000 ); connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); @@ -348,66 +342,70 @@ void Clock::slotToggleAlarm() } 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; QDateTime whenl(d,tm); when=whenl; AlarmServer::addAlarm( when, "QPE/Application/clock", "alarm(QDateTime,int)", warn ); - QMessageBox::message("Note","Alarm is set for:\n"+ whenl.toString()); + setCaption("Alarm set: "+ whenl.toString()); } void Clock::alarmOff() { int warn; 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; if ( msg == "alarm(QDateTime,int)" ) { Sound::soundAlarm(); stopTimer = startTimer( timerStay); } } void Clock::timerEvent( QTimerEvent *e ) { static int stop = 0; - if ( stop < 10 && bSound) { + 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."); } } 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 ); @@ -468,21 +466,16 @@ 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"); -} |