summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/tools/clock/analogclock.cpp2
-rw-r--r--noncore/tools/clock/clock.cpp1012
-rw-r--r--noncore/tools/clock/clock.h112
-rw-r--r--noncore/tools/clock/clock.pro9
-rw-r--r--noncore/tools/clock/clockbase.ui111
-rw-r--r--noncore/tools/clock/main.cpp8
6 files changed, 751 insertions, 503 deletions
diff --git a/noncore/tools/clock/analogclock.cpp b/noncore/tools/clock/analogclock.cpp
index bf358e2..c5f0155 100644
--- a/noncore/tools/clock/analogclock.cpp
+++ b/noncore/tools/clock/analogclock.cpp
@@ -43,9 +43,9 @@ void AnalogClock::drawContents( QPainter *p )
{
#if !defined(NO_DEBUG)
static bool first = true;
if ( first ) {
- QTOPIA_PROFILE("first paint event");
+// QTOPIA_PROFILE("first paint event");
first = false;
}
#endif
diff --git a/noncore/tools/clock/clock.cpp b/noncore/tools/clock/clock.cpp
index 485354b..ad422a6 100644
--- a/noncore/tools/clock/clock.cpp
+++ b/noncore/tools/clock/clock.cpp
@@ -1,8 +1,8 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the 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
@@ -17,11 +17,17 @@
** not clear to you.
**
**********************************************************************/
// changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002
+// changes added and Copyright (C) by Holger Freyther 2004
#include "clock.h"
-#include "setAlarm.h"
+
+#include "analogclock.h"
+
+#include <qtabwidget.h>
+
+#include <opie2/ofiledialog.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/config.h>
@@ -31,634 +37,770 @@
#include <qpe/resource.h>
#include <qsound.h>
#include <qtimer.h>
-#include <opie2/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 <qtoolbutton.h>
#include <qpainter.h>
#include <qmessagebox.h>
#include <qdatetime.h>
+#include <qspinbox.h>
+#include <qcombobox.h>
+#include <qcheckbox.h>
+#include <qgroupbox.h>
+#include <qlayout.h>
+#include <qhbox.h>
+#include <qlineedit.h>
+
+static const int sw_prec = 2;
+static const int magic_daily = 2292922;
+static const int magic_countdown = 2292923;
+static const int magic_snooze = 2292924;
+static const int magic_playmp = 2292925;
#include <math.h>
#include <unistd.h>
#include <sys/types.h>
#include <pthread.h>
-const double deg2rad = 0.017453292519943295769; // pi/180
-const int sw_prec = 2;
+static void toggleScreenSaver( bool on )
+{
+ QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" );
+ e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend );
+}
-using namespace Opie::Ui;
-void startPlayer()
+static void startPlayer()
{
Config config( "qpe" );
config.setGroup( "Time" );
sleep(15);
QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" );
e << config.readEntry( "mp3File", "" );
}
-
-static void toggleScreenSaver( bool on )
+class MySpinBox : public QSpinBox
{
- QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" );
- e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend );
+public:
+ QLineEdit *lineEdit() const {
+ return editor();
}
+};
-Clock::Clock( QWidget * parent, const char * name, WFlags f )
- : QVBox( parent, name , f )
+//
+//
+//
+AlarmDlg::AlarmDlg(QWidget *parent, const char *name, bool modal,
+ const QString &txt) :
+ AlarmDlgBase(parent, name, modal)
{
- setSpacing( 4 );
- setMargin( 1 );
-
-
- snoozeBtn = new QPushButton ( this );
- snoozeBtn->setText( tr( "Snooze" ) );
-
- aclock = new AnalogClock( this );
- aclock->display( QTime::currentTime() );
- aclock->setLineWidth( 2 );
-
- QHBox *hb = new QHBox( this );
- hb->setMargin( 0 );
- QWidget *space = new QWidget( hb );
- lcd = new QLCDNumber( hb );
- lcd->setSegmentStyle( QLCDNumber::Flat );
- lcd->setFrameStyle( QFrame::NoFrame );
- lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) );
- lcd->setFixedHeight( 23 );
+ setCaption( tr("Clock") );
+ pixmap->setPixmap( Resource::loadPixmap("alarmbell") );
+ alarmDlgLabel->setText(txt);
- 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 );
+ connect(snoozeTime, SIGNAL(valueChanged(int)), this,
+ SLOT(changePrompt(int)));
+ connect(cmdOk, SIGNAL(clicked()), this, SLOT(checkSnooze()));
+}
- date = new QLabel( this );
- date->setAlignment( AlignHCenter | AlignVCenter );
- date->setFont( QFont( "Helvetica", 14, QFont::Bold ) );
- date->setText( TimeString::longDateString( QDate::currentDate() ) );
+//
+//
+//
+void
+AlarmDlg::setText(const QString &txt)
+{
+ alarmDlgLabel->setText(txt);
+}
- QWidget *controls = new QWidget( this );
- QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 );
+//
+//
+//
+void
+AlarmDlg::checkSnooze(void)
+{
+ //
+ // Ensure we have only one snooze alarm.
+ //
+ AlarmServer::deleteAlarm(QDateTime(), "QPE/Application/clock",
+ "alarm(QDateTime,int)", magic_snooze);
- QButtonGroup *grp = new QButtonGroup( controls );
- grp->setRadioButtonExclusive( true );
- grp->hide();
+ if (snoozeTime->value() > 0) {
+ QDateTime wake = QDateTime::currentDateTime();
+ wake = wake.addSecs(snoozeTime->value() * 60); // snoozeTime in minutes
- clockRB = new QRadioButton ( tr( "Clock" ), controls );
- gl->addWidget( clockRB, 0, 0 );
- grp->insert( clockRB );
+ AlarmServer::addAlarm(wake, "QPE/Application/clock",
+ "alarm(QDateTime,int)", magic_snooze);
+ }
+ accept();
+}
- 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 );
- set = new QPushButton ( controls );
- set->setMaximumSize( 50, 30 );
- gl->addWidget( set , 0, 1 );
- set->setText( tr( "Start" ) );
- set->setEnabled( FALSE );
- grp->insert( set );
+void
+AlarmDlg::changePrompt(int mins)
+{
+ cmdOk->setText(mins > 0 ? tr("Snooze") : tr("Close") );
+}
- reset = new QPushButton ( controls );
- gl->addWidget( reset, 1, 1 );
- reset->setText( tr( "Reset" ) );
- reset->setEnabled( FALSE );
- grp->insert( reset );
- alarmOffBtn = new QPushButton ( controls );
- gl->addWidget( alarmOffBtn, 0, 2 );
- alarmBtn = new QPushButton ( controls );
- gl->addWidget( alarmBtn, 1, 2 );
+Clock::Clock( QWidget * parent, const char *, WFlags f )
+ : ClockBase( parent, "clock", f ), swatch_splitms(99), init(FALSE) // No tr
+{
+ alarmDlg = 0;
+ swLayout = 0;
+ dayBtn = new QToolButton * [7];
- alarmBtn->setText( tr( "Set Alarm" ) );
+ Config config( "qpe" );
+ config.setGroup("Time");
+ ampm = config.readBoolEntry( "AMPM", TRUE );
+ onMonday = config.readBoolEntry( "MONDAY" );
- OClickableLabel *click = new Opie::Ui::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( tabs, SIGNAL(currentChanged(QWidget*)),
+ this, SLOT(tabChanged(QWidget*)) );
- connect( set , SIGNAL( pressed() ), SLOT( slotSet() ) );
- connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) );
+ analogStopwatch = new AnalogClock( swFrame );
+ stopwatchLcd = new QLCDNumber( swFrame );
+ stopwatchLcd->setFrameStyle( QFrame::NoFrame );
+ stopwatchLcd->setSegmentStyle( QLCDNumber::Flat );
+ stopwatchLcd->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred) );
- connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) );
- connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) );
- connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) );
+ analogClock->display( QTime::currentTime() );
+ clockLcd->setNumDigits( 5 );
+ clockLcd->setFixedWidth( clockLcd->sizeHint().width() );
+ date->setText( TimeString::dateString( QDate::currentDate(), TimeString::currentDateFormat() ) );
+ if ( qApp->desktop()->width() < 200 )
+ date->setFont( QFont(date->font().family(), 14, QFont::Bold) );
+ if ( qApp->desktop()->height() > 240 ) {
+ clockLcd->setFixedHeight( 30 );
+ stopwatchLcd->setFixedHeight( 30 );
+ }
- connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ),
- this, SLOT( appMessage(const QCString&,const QByteArray&) ) );
+ connect( stopStart, SIGNAL(pressed()), SLOT(stopStartStopWatch()) );
+ connect( reset, SIGNAL(pressed()), SLOT(resetStopWatch()) );
t = new QTimer( this );
connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) );
t->start( 1000 );
+ applyAlarmTimer = new QTimer( this );
+ connect( applyAlarmTimer, SIGNAL(timeout()),
+ this, SLOT(applyDailyAlarm()) );
+
+ alarmt = new QTimer( this );
+ connect( alarmt, SIGNAL(timeout()), SLOT(alarmTimeout()) );
+
connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) );
+ connect( qApp, SIGNAL(timeChanged()), SLOT(applyDailyAlarm()) );
swatch_running = FALSE;
swatch_totalms = 0;
+ swatch_currLap = 0;
+ swatch_dispLap = 0;
+ stopwatchLcd->setNumDigits( 8+1+sw_prec );
+ stopwatchLcd->display( "00:00:00.00" );
+
+ QVBoxLayout *lvb = new QVBoxLayout( lapFrame );
+ nextLapBtn = new QToolButton( UpArrow, lapFrame );
+ connect( nextLapBtn, SIGNAL(clicked()), this, SLOT(nextLap()) );
+ nextLapBtn->setAccel( Key_Up );
+ lvb->addWidget( nextLapBtn );
+ prevLapBtn = new QToolButton( DownArrow, lapFrame );
+ connect( prevLapBtn, SIGNAL(clicked()), this, SLOT(prevLap()) );
+ prevLapBtn->setAccel( Key_Down );
+ prevLapBtn->setMinimumWidth( 15 );
+ lvb->addWidget( prevLapBtn );
+ prevLapBtn->setEnabled( FALSE );
+ nextLapBtn->setEnabled( FALSE );
- connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( changeClock(bool) ) );
+ reset->setEnabled( FALSE );
+ lapLcd->setNumDigits( 8+1+sw_prec );
+ lapLcd->display( "00:00:00.00" );
- Config config( "qpe" );
- config.setGroup( "Time" );
- ampm = config.readBoolEntry( "AMPM", TRUE );
+ splitLcd->setNumDigits( 8+1+sw_prec );
+ splitLcd->display( "00:00:00.00" );
- QString tmp = config.readEntry( "clockAlarmHour", "" );
- bool ok;
- hour = tmp.toInt( &ok, 10 );
- tmp = config.readEntry( "clockAlarmMinute", "" );
- minute = tmp.toInt( &ok, 10 );
+ lapNumLcd->display( 1 );
- if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" )
- {
- alarmOffBtn->setText( tr( "Alarm Is On" ) );
- alarmBool = TRUE;
- snoozeBtn->show();
+ lapTimer = new QTimer( this );
+ connect( lapTimer, SIGNAL(timeout()), this, SLOT(lapTimeout()) );
+
+ for (uint s = 0; s < swatch_splitms.count(); s++ )
+ swatch_splitms[(int)s] = 0;
+
+ connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
+
+ cdGroup->hide(); // XXX implement countdown timer.
+
+ connect( dailyHour, SIGNAL(valueChanged(int)), this, SLOT(scheduleApplyDailyAlarm()) );
+ connect( dailyMinute, SIGNAL(valueChanged(int)), this, SLOT(setDailyMinute(int)) );
+ connect( dailyAmPm, SIGNAL(activated(int)), this, SLOT(setDailyAmPm(int)) );
+ connect( dailyEnabled, SIGNAL(toggled(bool)), this, SLOT(enableDaily(bool)) );
+ cdLcd->display( "00:00" );
+
+ dailyMinute->setValidator(0);
+
+ Config cConfig( "Clock" ); // No tr
+ cConfig.setGroup( "Daily Alarm" );
+
+ QStringList days;
+ days.append( tr("Mon", "Monday") );
+ days.append( tr("Tue", "Tuesday") );
+ days.append( tr("Wed", "Wednesday") );
+ days.append( tr("Thu", "Thursday") );
+ days.append( tr("Fri", "Friday") );
+ days.append( tr("Sat", "Saturday") );
+ days.append( tr("Sun", "Sunday") );
+
+ int i;
+ QHBoxLayout *hb = new QHBoxLayout( daysFrame );
+ for ( i = 0; i < 7; i++ ) {
+ dayBtn[i] = new QToolButton( daysFrame );
+ hb->addWidget( dayBtn[i] );
+ dayBtn[i]->setToggleButton( TRUE );
+ dayBtn[i]->setOn( TRUE );
+ dayBtn[i]->setFocusPolicy( StrongFocus );
+ connect( dayBtn[i], SIGNAL(toggled(bool)), this, SLOT(scheduleApplyDailyAlarm()) );
+ }
+
+ for ( i = 0; i < 7; i++ )
+ dayBtn[dayBtnIdx(i+1)]->setText( days[i] );
+
+ QStringList exclDays = cConfig.readListEntry( "ExcludeDays", ',' );
+ QStringList::Iterator it;
+ for ( it = exclDays.begin(); it != exclDays.end(); ++it ) {
+ int d = (*it).toInt();
+ if ( d >= 1 && d <= 7 )
+ dayBtn[dayBtnIdx(d)]->setOn( FALSE );
+ }
+
+ bool alarm = cConfig.readBoolEntry("Enabled", FALSE);
+ bool sound = cConfig.readBoolEntry("SoundEnabled", FALSE );
+ dailyEnabled->setChecked( alarm );
+ sndGroup->setEnabled( alarm );
+ sndCheck->setChecked( sound );
+ sndChoose->setEnabled( sound );
+ sndFileName->setEnabled( sound );
+
+ // FIXME ODP migrate to own config class.. merge config options
+ Config cfg_qpe( "qpe" );
+ cfg_qpe.setGroup( "Time" );
+ sndFileName->setText( cfg_qpe.readEntry( "mp3File" ) );
+ //
+
+ int m = cConfig.readNumEntry( "Minute", 0 );
+ dailyMinute->setValue( m );
+// dailyMinute->setPrefix( m <= 9 ? "0" : "" );
+ int h = cConfig.readNumEntry( "Hour", 7 );
+ if ( ampm ) {
+ if (h > 12) {
+ h -= 12;
+ dailyAmPm->setCurrentItem( 1 );
}
- else
- {
- alarmOffBtn->setText( tr( "Alarm Is Off" ) );
- alarmBool = FALSE;
- snoozeBtn->hide();
+ if (h == 0) h = 12;
+ dailyHour->setMinValue( 1 );
+ dailyHour->setMaxValue( 12 );
+ } else {
+ dailyAmPm->hide();
}
+ dailyHour->setValue( h );
+
+ connect( ((MySpinBox*)dailyHour)->lineEdit(), SIGNAL(textChanged(const QString&)),
+ this, SLOT(dailyEdited()) );
+ connect( ((MySpinBox*)dailyMinute)->lineEdit(), SIGNAL(textChanged(const QString&)),
+ this, SLOT(dailyEdited()) );
+
+#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
+ connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)),
+ this, SLOT(appMessage(const QCString&,const QByteArray&)) );
+#endif
QTimer::singleShot( 0, this, SLOT( updateClock() ) );
+ swFrame->installEventFilter( this );
- Config cfg( "Clock" );
- cfg.setGroup( "Mode" );
- int mode = cfg.readBoolEntry( "clockMode");
- setSwatchMode( mode);
- modeSelect( mode);
+ init = TRUE;
}
Clock::~Clock()
{
toggleScreenSaver( true );
+ delete [] dayBtn;
}
void Clock::updateClock()
{
- if ( clockRB->isChecked() )
- {
+ if ( tabs->currentPageIndex() == 0 ) {
QTime tm = QDateTime::currentDateTime().time();
QString s;
- if ( ampm )
- {
+ if ( ampm ) {
int hour = tm.hour();
if ( hour == 0 )
hour = 12;
if ( hour > 12 )
hour -= 12;
s.sprintf( "%2d%c%02d", hour, ':', tm.minute() );
- ampmLabel->setText( ( tm.hour() >= 12 ) ? "PM" : "AM" );
- ampmLabel->show();
- }
- else
- {
+ clockAmPm->setText( (tm.hour() >= 12) ? "PM" : "AM" );
+ clockAmPm->show();
+ } else {
s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() );
- ampmLabel->hide();
- }
- lcd->display( s );
- lcd->repaint( FALSE );
- aclock->display( QTime::currentTime() );
- date->setText( TimeString::longDateString( QDate::currentDate() ) );
+ clockAmPm->hide();
}
- else
- {
- QTime swatch_time;
- QString lcdtext;
+ clockLcd->display( s );
+ clockLcd->repaint( FALSE );
+ analogClock->display( QTime::currentTime() );
+ date->setText( TimeString::dateString( QDate::currentDate(), TimeString::currentDateFormat() ) );
+ } else if ( tabs->currentPageIndex() == 1 ) {
int totalms = swatch_totalms;
if ( swatch_running )
totalms += swatch_start.elapsed();
- swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms );
- QString d = swatch_running ? QString( " " )
- : QString::number( totalms % 1000 + 1000 );
- lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec );
- lcd->display( lcdtext );
- lcd->repaint( FALSE );
- aclock->display( swatch_time );
- date->setText( TimeString::longDateString( QDate::currentDate() ) );
+ setSwatchLcd( stopwatchLcd, totalms, !swatch_running );
+ QTime swatch_time = QTime(0,0,0).addMSecs(totalms);
+ analogStopwatch->display( swatch_time );
+ if ( swatch_dispLap == swatch_currLap ) {
+ swatch_splitms[swatch_currLap] = swatch_totalms;
+ if ( swatch_running )
+ swatch_splitms[swatch_currLap] += swatch_start.elapsed();
+ updateLap();
+ }
+ } else if ( tabs->currentPageIndex() == 2 ) {
+ // nothing.
}
}
void Clock::changeClock( bool a )
{
+ if ( ampm != a ) {
+ int minute = dailyMinute->value();
+ int hour = dailyHour->value();
+ if ( ampm ) {
+ if (hour == 12)
+ hour = 0;
+ if (dailyAmPm->currentItem() == 1 )
+ hour += 12;
+ dailyHour->setMinValue( 0 );
+ dailyHour->setMaxValue( 23 );
+ dailyAmPm->hide();
+ } else {
+ if (hour > 12) {
+ hour -= 12;
+ dailyAmPm->setCurrentItem( 1 );
+ }
+ if (hour == 0) hour = 12;
+ dailyHour->setMinValue( 1 );
+ dailyHour->setMaxValue( 12 );
+ dailyAmPm->show();
+ }
+ dailyMinute->setValue( minute );
+ dailyHour->setValue( hour );
+ }
ampm = a;
updateClock();
}
-void Clock::clearClock( void )
-{
- lcd->display( QTime( 0, 0, 0 ).toString() );
- aclock->display( QTime( 0, 0, 0 ) );
-}
-
-void Clock::startSWatch()
+void Clock::stopStartStopWatch()
{
if(swatch_running) {
- stopSWatch();
- return;
- }
- qDebug("startSWatch()");
+ swatch_totalms += swatch_start.elapsed();
+ swatch_splitms[swatch_currLap] = swatch_totalms;
+ stopStart->setText( tr("Start") );
+ reset->setText( tr("Reset") );
+ reset->setEnabled( TRUE );
+ t->stop();
+ swatch_running = FALSE;
+ toggleScreenSaver( TRUE );
+ updateClock();
+ } else {
swatch_start.start();
- set->setText( tr( "Stop" ) );
+ stopStart->setText( tr("Stop") );
+ reset->setText( tr("Lap/Split") );
+ reset->setEnabled( swatch_currLap < 98 );
t->start( 1000 );
swatch_running = TRUE;
// disable screensaver while stop watch is running
toggleScreenSaver( FALSE );
}
+ swatch_dispLap = swatch_currLap;
+ updateLap();
+ prevLapBtn->setEnabled( swatch_dispLap );
+ nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap );
+ stopStart->setAccel( Key_Return );
+}
-void Clock::stopSWatch()
+void Clock::resetStopWatch()
{
- qDebug("stopSWatch()");
- swatch_totalms += swatch_start.elapsed();
- set->setText( tr( "Start" ) );
- t->stop();
- swatch_running = FALSE;
- toggleScreenSaver( TRUE );
+ if ( swatch_running ) {
+ swatch_splitms[swatch_currLap] = swatch_totalms+swatch_start.elapsed();
+ swatch_dispLap = swatch_currLap;
+ if ( swatch_currLap < 98 ) // allow up to 99 laps
+ swatch_currLap++;
+ reset->setEnabled( swatch_currLap < 98 );
+ updateLap();
+ lapTimer->start( 2000, TRUE );
+ } else {
+ swatch_start.start();
+ swatch_totalms = 0;
+ swatch_currLap = 0;
+ swatch_dispLap = 0;
+ for ( uint i = 0; i < swatch_splitms.count(); i++ )
+ swatch_splitms[(int)i] = 0;
+ updateLap();
updateClock();
+ reset->setText( tr("Lap/Split") );
+ reset->setEnabled( FALSE );
+ }
+ prevLapBtn->setEnabled( swatch_dispLap );
+ nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap );
}
-
-void Clock::slotSet()
-{
- if ( t->isActive() )
+void Clock::prevLap()
{
- startSWatch();
+ if ( swatch_dispLap > 0 ) {
+ swatch_dispLap--;
+ updateLap();
+ prevLapBtn->setEnabled( swatch_dispLap );
+ nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap );
}
- else
+}
+
+void Clock::nextLap()
{
- stopSWatch();
+ if ( swatch_dispLap < swatch_currLap ) {
+ swatch_dispLap++;
+ updateLap();
+ prevLapBtn->setEnabled( swatch_dispLap );
+ nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap );
}
}
-void Clock::slotReset()
+void Clock::lapTimeout()
{
- t->stop();
- swatch_start.start();
- swatch_totalms = 0;
+ swatch_dispLap = swatch_currLap;
+ updateLap();
+ prevLapBtn->setEnabled( swatch_dispLap );
+ nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap );
+}
- if ( swatch_running )
- t->start( 1000 );
+void Clock::updateLap()
+{
+ if ( swatch_running && swatch_currLap == swatch_dispLap ) {
+ swatch_splitms[swatch_currLap] = swatch_totalms;
+ swatch_splitms[swatch_currLap] += swatch_start.elapsed();
+ }
+ int split = swatch_splitms[swatch_dispLap];
+ int lap;
+ if ( swatch_dispLap > 0 )
+ lap = swatch_splitms[swatch_dispLap] - swatch_splitms[swatch_dispLap-1];
+ else
+ lap = swatch_splitms[swatch_dispLap];
- updateClock();
+ lapNumLcd->display( swatch_dispLap+1 );
+ bool showMs = !swatch_running || swatch_dispLap!=swatch_currLap;
+ setSwatchLcd( lapLcd, lap, showMs );
+ setSwatchLcd( splitLcd, split, showMs );
}
-void Clock::modeSelect( int m )
+void Clock::setSwatchLcd( QLCDNumber *lcd, int ms, bool showMs )
{
- qDebug("Clock::modeSelect( %d) ", m);
- if ( m != 0 )
- {
- lcd->setNumDigits( 8 + 1 + sw_prec );
- lcd->setMinimumWidth( lcd->sizeHint().width() );
- set->setEnabled( TRUE );
- reset->setEnabled( TRUE );
- ampmLabel->hide();
+ QTime swatch_time = QTime(0,0,0).addMSecs(ms);
+ QString d = showMs ? QString::number(ms%1000+1000) : QString(" ");
+ QString lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec);
+ lcd->display( lcdtext );
+ lcd->repaint( FALSE );
+}
-// if(m == 2) {
- if ( !swatch_running ) {
- t->start( 1000 );
+bool Clock::eventFilter( QObject *o, QEvent *e )
+{
+ if ( o == swFrame && e->type() == QEvent::Resize ) {
+ QResizeEvent *re = (QResizeEvent *)e;
+ delete swLayout;
+ if ( re->size().height() < 80 || re->size().height()*3 < re->size().width() )
+ swLayout = new QHBoxLayout( swFrame );
+ else
+ swLayout = new QVBoxLayout( swFrame );
+ swLayout->addWidget( analogStopwatch );
+ swLayout->addWidget( stopwatchLcd );
+ swLayout->activate();
}
-// else
-// {
-// stopSWatch();
-// }
-// }
+
+ return FALSE;
}
- else //clock mode
+
+void Clock::tabChanged( QWidget * )
{
- lcd->setNumDigits( 5 );
- lcd->setMinimumWidth( lcd->sizeHint().width() );
- set->setEnabled( FALSE );
- reset->setEnabled( FALSE );
+ if ( tabs->currentPageIndex() == 0 ) {
+ t->start(1000);
+ } else if ( tabs->currentPageIndex() == 1 ) {
+ if ( !swatch_running )
+ t->stop();
+ stopStart->setAccel( Key_Return );
+ } else if ( tabs->currentPageIndex() == 2 ) {
t->start( 1000 );
}
-
- Config config( "Clock" );
- config.setGroup( "Mode" );
- config.writeEntry( "clockMode", m );
updateClock();
}
-//this sets the alarm time
-void Clock::slotSetAlarm()
+void Clock::setDailyAmPm(int)
{
- 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();
- }
+ scheduleApplyDailyAlarm();
}
-void Clock::slotSnooze()
+void Clock::setDailyMinute( int m )
{
- 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 );
-
+ dailyMinute->setPrefix( m <= 9 ? "0" : "" );
}
-//toggles alarm on/off
-void Clock::slotToggleAlarm()
+void Clock::dailyEdited()
{
- Config config( "qpe" );
- config.setGroup( "Time" );
- if ( alarmBool )
- {
- config.writeEntry( "clockAlarmSet", "FALSE" );
- alarmOffBtn->setText( tr( "Alarm Is Off" ) );
- snoozeBtn->hide();
- alarmBool = FALSE;
- alarmOff();
- }
+ if ( spinBoxValid(dailyMinute) && spinBoxValid(dailyHour) )
+ scheduleApplyDailyAlarm();
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( 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( tr("Clock") );
+ applyAlarmTimer->stop();
}
-void Clock::clearTimer()
+void Clock::enableDaily( bool )
{
- alarmOffBtn->setText( tr( "Alarm Is Off" ) );
- alarmBool = FALSE;
- snoozeBtn->hide();
- setCaption( tr("Clock") );
+ scheduleApplyDailyAlarm();
}
-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)" )
+void Clock::appMessage( const QCString &msg, const QByteArray &data )
{
- Config config( "qpe" );
- config.setGroup( "Time" );
- if ( config.readBoolEntry( "mp3Alarm", 0 ) )
- {
- clearTimer();
- pthread_t thread;
- pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/);
-
+ if ( msg == "alarm(QDateTime,int)" ) {
+ QDataStream ds(data,IO_ReadOnly);
+ QDateTime when;
+ int t;
+ ds >> when >> t;
+ QTime theTime( when.time() );
+ if ( t == magic_daily || t == magic_snooze ||
+ t == magic_playmp ) {
+ QString msg = tr("<b>Daily Alarm:</b><p>");
+ QString ts;
+ if ( ampm ) {
+ bool pm = FALSE;
+ int h = theTime.hour();
+ if (h > 12) {
+ h -= 12;
+ pm = TRUE;
}
- else
- {
+ if (h == 0) h = 12;
+ ts.sprintf( "%02d:%02d %s", h, theTime.minute(), pm?"PM":"AM" );
+ } else {
+ ts.sprintf( "%02d:%02d", theTime.hour(), theTime.minute() );
+ }
+ msg += ts;
+ if (t == magic_playmp ) {
+ pthread_t thread;
+ pthread_create(&thread,NULL, (void * (*) (void *))startPlayer, NULL/* &*/ );
+ }else {
Sound::soundAlarm();
- stopTimer = startTimer( timerStay );
+ alarmCount = 0;
+ alarmt->start( 5000 );
}
+ if ( !alarmDlg ) {
+ alarmDlg = new AlarmDlg(this);
}
+ alarmDlg->setText(msg);
- if ( msg == "timerStart()" )
- {
- slotStartTimer();
+ // Set for tomorrow, so user wakes up every day, even if they
+ // don't confirm the dialog. Don't set it again when snoozing.
+ if (t != magic_snooze) {
+ applyDailyAlarm();
}
- if ( msg == "timerStop()" )
- {
- slotStopTimer();
+
+
+ if ( !alarmDlg->isVisible() ) {
+ QPEApplication::execDialog(alarmDlg);
+ alarmt->stop();
}
- if ( msg == "timerReset()" )
- {
- slotResetTimer();
+ } else if ( t == magic_countdown ) {
+ // countdown
+ Sound::soundAlarm();
}
-
- show();
- raise();
+ } else if ( msg == "setDailyEnabled(int)" ) {
+ QDataStream ds(data,IO_ReadOnly);
+ int enableDaily;
+ ds >> enableDaily;
+ dailyEnabled->setChecked( enableDaily );
+ applyDailyAlarm();
+ } else if ( msg == "editDailyAlarm()" ) {
+ tabs->setCurrentPage(2);
+ QPEApplication::setKeepRunning();
+ } else if (msg == "showClock()") {
+ tabs->setCurrentPage(0);
QPEApplication::setKeepRunning();
- setActiveWindow();
+ } else if (msg == "timerStart()" ) {
+ if ( !swatch_running )
+ stopStartStopWatch();
+ tabs->setCurrentPage(1);
+ QPEApplication::setKeepRunning();
+ } else if (msg == "timerStop()" ) {
+ if ( swatch_running )
+ stopStartStopWatch();
+ tabs->setCurrentPage(1);
+ QPEApplication::setKeepRunning();
+ } else if (msg == "timerReset()" ) {
+ resetStopWatch();
+ tabs->setCurrentPage(1);
+ QPEApplication::setKeepRunning();
+ }
}
-void Clock::timerEvent( QTimerEvent *e )
-{
- static int stop = 0;
- if ( stop < 120 && bSound )
+void Clock::alarmTimeout()
{
+ if ( alarmCount < 10 ) {
Sound::soundAlarm();
- stop++;
- }
- else
- {
- stop = 0;
- killTimer( e->timerId() );
- clearTimer();
- setCaption( tr( "Clock: Alarm was missed." ) );
+ alarmCount++;
+ } else {
+ alarmCount = 0;
+ alarmt->stop();
}
}
-AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true)
+QDateTime Clock::nextAlarm( int h, int m )
{
- QWidget *d = QApplication::desktop();
- if(d->width() <= 240)
- bg = Resource::loadPixmap("clock/bg");
+ QDateTime now = QDateTime::currentDateTime();
+ QTime at( h, m );
+ QDateTime when( now.date(), at );
+ int count = 0;
+ int dow = when.date().dayOfWeek();
+ while ( when < now || !dayBtn[dayBtnIdx(dow)]->isOn() ) {
+ when = when.addDays( 1 );
+ dow = when.date().dayOfWeek();
+ if ( ++count > 7 )
+ return QDateTime();
}
-QSizePolicy AnalogClock::sizePolicy() const
-{
- return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
+ return when;
}
-void AnalogClock::drawContents( QPainter *p )
+int Clock::dayBtnIdx( int d ) const
{
- 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 ( ));
+ if ( onMonday )
+ return d-1;
+ else if ( d == 7 )
+ return 0;
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 ));
- p-> drawEllipse ( fr );
- p-> setBrush ( NoBrush );
-
- // draw ticks
- p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) );
- for ( int i = 0; i < 12; i++ )
- p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) );
+ return d;
}
- else
- {
- drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime );
- }
-
- drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime );
- prevTime = currTime;
+void Clock::scheduleApplyDailyAlarm()
+{
+ applyAlarmTimer->start( 5000, TRUE );
}
-void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 )
+void Clock::applyDailyAlarm()
{
- QPoint center = r. center ( );
-
- QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 );
- QPoint h2( center. x ( ), center. y ( ) );
+ if ( !init )
+ return;
- QPoint m1( center. x ( ), r.y() + r.height() / 8 );
- QPoint m2( center. x ( ), center. y ( ) );
+ applyAlarmTimer->stop();
+ int minute = dailyMinute->value();
+ int hour = dailyHour->value();
+ if ( ampm ) {
+ if (hour == 12)
+ hour = 0;
+ if (dailyAmPm->currentItem() == 1 )
+ hour += 12;
+ }
- QPoint s1( center. x ( ), r. y ( ) + 8 );
- QPoint s2( center. x ( ), center. y ( ) );
+ Config config( "Clock" );
+ config.setGroup( "Daily Alarm" );
+ config.writeEntry( "Hour", hour );
+ config.writeEntry( "Minute", minute );
+ bool enableDaily = dailyEnabled->isChecked();
+ bool wasSound = config.readEntry( "SoundEnabled" );
+ bool isSound = sndCheck->isChecked();
+ int oldMagic = wasSound ? magic_playmp : magic_daily;
+ int isMagic = isSound ? magic_playmp : magic_daily;
+ config.writeEntry( "Enabled", enableDaily );
+ config.writeEntry( "SoundEnabled", isSound );
- if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) {
- // draw hour pointer
- h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 );
- h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 );
- p-> setPen ( QPen ( c, 3 ));
- p-> drawLine ( h1, h2 );
+ QString exclDays;
+ int exclCount = 0;
+ for ( int i = 1; i <= 7; i++ ) {
+ if ( !dayBtn[dayBtnIdx(i)]->isOn() ) {
+ if ( !exclDays.isEmpty() )
+ exclDays += ",";
+ exclDays += QString::number( i );
+ exclCount++;
}
-
- if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) {
- // draw minute pointer
- m1 = rotate( center, m1, t.minute() * 6 );
- m2 = rotate( center, m2, t.minute() * 6 );
- p-> setPen ( QPen ( c, 2 ));
- p-> drawLine ( m1, m2 );
}
+ config.writeEntry( "ExcludeDays", exclDays );
- if ( !t2 || ( t. second ( ) != t2-> second ( ))) {
- // draw second pointer
- s1 = rotate( center, s1, t.second() * 6 );
- s2 = rotate( center, s2, t.second() * 6 );
- p-> setPen ( QPen ( c, 1 ));
- p-> drawLine ( s1, s2 );
+ /* try to delete both */
+ AlarmServer::deleteAlarm(QDateTime(), "QPE/Application/clock",
+ "alarm(QDateTime,int)", oldMagic);
+ if ( enableDaily && exclCount < 7 ) {
+ QDateTime when = nextAlarm( hour, minute );
+ AlarmServer::addAlarm(when, "QPE/Application/clock",
+ "alarm(QDateTime,int)", isMagic);
}
}
-void AnalogClock::display( const QTime& t )
+bool Clock::validDaysSelected(void)
{
- currTime = t;
- clear = false;
- repaint( false );
- clear = true;
+ for ( int i = 1; i <= 7; i++ ) {
+ if ( dayBtn[dayBtnIdx(i)]->isOn() ) {
+ return TRUE;
}
-
-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 );
+ }
+ return FALSE;
}
-void Clock::slotAdjustTime()
+void Clock::closeEvent( QCloseEvent *e )
{
- QCopEnvelope e( "QPE/System", "execute(QString)" );
- e << QString( "systemtime" );
+ if (dailyEnabled->isChecked()) {
+ if (!validDaysSelected()) {
+ QMessageBox::warning(this, tr("Select Day"),
+ tr("Daily alarm requires at least\none day to be selected."));
+ return;
+ }
}
-void Clock::slotStartTimer()
-{
- if ( clockRB->isChecked() )
- setSwatchMode( 1);
- startSWatch();
+ applyDailyAlarm();
+ ClockBase::closeEvent(e);
}
-void Clock::slotStopTimer()
+bool Clock::spinBoxValid( QSpinBox *sb )
{
- if ( clockRB->isChecked() )
- setSwatchMode( 1);
- stopSWatch();
+ bool valid = TRUE;
+ QString tv = sb->text();
+ for ( uint i = 0; i < tv.length(); i++ ) {
+ if ( !tv[0].isDigit() )
+ valid = FALSE;
}
+ bool ok = FALSE;
+ int v = tv.toInt( &ok );
+ if ( !ok )
+ valid = FALSE;
+ if ( v < sb->minValue() || v > sb->maxValue() )
+ valid = FALSE;
-void Clock::slotResetTimer()
-{
- if ( clockRB->isChecked() )
- setSwatchMode( 1);
-slotReset();
+ return valid;
}
-void Clock::setSwatchMode(int mode)
-{
- qDebug("Clock::setSwatchMode( %d)", mode);
- swatchRB->setChecked( mode);
- clearClock( );
- modeSelect( mode );
+void Clock::slotBrowseMp3File() {
+ Config config( "qpe" );
+ config.setGroup("Time");
+
+ QMap<QString, QStringList> map;
+ map.insert(tr("All"), QStringList() );
+ QStringList text;
+ text << "audio/*";
+ map.insert(tr("Audio"), text );
+ QString str = Opie::Ui::OFileDialog::getOpenFileName( 2,"/", QString::null, map);
+ if(!str.isEmpty() ) {
+ config.writeEntry("mp3Alarm",1);
+ config.writeEntry("mp3File",str);
+ sndFileName->setText( str );
+ scheduleApplyDailyAlarm();
+ }
}
diff --git a/noncore/tools/clock/clock.h b/noncore/tools/clock/clock.h
index 00d097d..c063a9b 100644
--- a/noncore/tools/clock/clock.h
+++ b/noncore/tools/clock/clock.h
@@ -1,8 +1,8 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the 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
@@ -19,94 +19,98 @@
**********************************************************************/
#ifndef CLOCK_H
#define CLOCK_H
+#include "clockbase.h"
+#include "alarmdlgbase.h"
#include <qdatetime.h>
-#include <qvbox.h>
-#include <qpixmap.h>
-class QLCDNumber;
-class QLabel;
class QTimer;
-class QRadioButton;
-class QPushButton;
-class QDateTime;
+class QLabel;
+class QDialog;
+class AnalogClock;
+class QBoxLayout;
+class QToolButton;
-class AnalogClock : public QFrame
+class AlarmDlg: public AlarmDlgBase
{
Q_OBJECT
public:
- AnalogClock( QWidget * parent = 0, const char * name = 0 );
-
- QSizePolicy sizePolicy() const;
-
- void display( const QTime& time );
-
-
-protected:
- void drawContents( QPainter *p );
-
-private:
+ AlarmDlg(QWidget *parent = 0, const char *name = 0, bool modal = TRUE,
+ const QString &txt = "Alarm");
- QPixmap bg;
- QTime currTime;
- QTime prevTime;
- bool clear;
+ void setText(const QString &txt);
- QPoint rotate( QPoint center, QPoint p, int angle );
- void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 );
+private slots:
+ void checkSnooze(void);
+ void changePrompt(int minutes);
};
-class Clock : public QVBox
+class Clock : public ClockBase
{
Q_OBJECT
public:
- Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 );
+ Clock( QWidget *parent=0, const char *name=0, WFlags fl=0 );
~Clock();
QDateTime when;
bool bSound;
int hour, minute, snoozeTime;
static QString appName() { return QString::fromLatin1("clock"); }
private slots:
- void slotSet();
- void slotReset();
- void modeSelect(int);
+ void stopStartStopWatch();
+ void resetStopWatch();
+ void prevLap();
+ void nextLap();
+ void lapTimeout();
+ void tabChanged(QWidget*);
void updateClock();
void changeClock( bool );
- void slotSetAlarm();
- void slotSnooze();
- void slotToggleAlarm();
- void alarmOn();
- void alarmOff();
+ void setDailyAmPm( int );
+ void setDailyMinute( int );
+ void dailyEdited();
+ void enableDaily( bool );
void appMessage(const QCString& msg, const QByteArray& data);
- void timerEvent( QTimerEvent *e );
- void slotAdjustTime();
+ void alarmTimeout();
+ void applyDailyAlarm();
+ void scheduleApplyDailyAlarm();
+ void slotBrowseMp3File();
+
+protected:
+ QDateTime nextAlarm( int h, int m );
+ int dayBtnIdx( int ) const;
+ void closeEvent( QCloseEvent *e );
+ void updateLap();
+ void setSwatchLcd( QLCDNumber *lcd, int ms, bool showMs );
+ bool eventFilter( QObject *, QEvent * );
+ bool spinBoxValid( QSpinBox *sb );
+ bool validDaysSelected(void);
- void slotStartTimer();
- void slotStopTimer();
- void slotResetTimer();
- void setSwatchMode( int );
private:
- bool alarmBool;
QTimer *t;
- QLCDNumber *lcd;
- QLabel *date;
- QLabel *ampmLabel;
- QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn;
- QRadioButton *clockRB, *swatchRB;
- AnalogClock *aclock;
+ QTimer *alarmt;
QTime swatch_start;
int swatch_totalms;
+ QArray<int> swatch_splitms;
bool swatch_running;
+ int swatch_currLap;
+ int swatch_dispLap;
+ QToolButton *prevLapBtn;
+ QToolButton *nextLapBtn;
+ QTimer *lapTimer;
+ AnalogClock* analogStopwatch;
+ QLCDNumber* stopwatchLcd;
+ QBoxLayout *swLayout;
bool ampm;
- void clearClock();
- void clearTimer();
- void startSWatch();
- void stopSWatch();
+ bool onMonday;
+ int alarmCount;
+ AlarmDlg* alarmDlg;
+ QToolButton **dayBtn;
+ bool init;
+ QTimer *applyAlarmTimer;
};
#endif
diff --git a/noncore/tools/clock/clock.pro b/noncore/tools/clock/clock.pro
index ad5c205..90a8d29 100644
--- a/noncore/tools/clock/clock.pro
+++ b/noncore/tools/clock/clock.pro
@@ -1,10 +1,15 @@
CONFIG = qt warn_on quick-app
-HEADERS = clock.h setAlarm.h
-SOURCES = clock.cpp setAlarm.cpp \
+HEADERS = clock.h analogclock.h
+SOURCES = clock.cpp analogclock.cpp \
main.cpp
+
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe -lopiecore2 -lopieui2 -lpthread
TARGET = clock
+
+INTERFACES = clockbase.ui \
+ alarmdlgbase.ui
+
include ( $(OPIEDIR)/include.pro )
diff --git a/noncore/tools/clock/clockbase.ui b/noncore/tools/clock/clockbase.ui
index 91d0da0..0e1a90e 100644
--- a/noncore/tools/clock/clockbase.ui
+++ b/noncore/tools/clock/clockbase.ui
@@ -10,10 +10,10 @@
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>220</width>
- <height>337</height>
+ <width>287</width>
+ <height>389</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
@@ -515,13 +515,13 @@
</attribute>
<vbox>
<property stdset="1">
<name>margin</name>
- <number>6</number>
+ <number>-1</number>
</property>
<property stdset="1">
<name>spacing</name>
- <number>4</number>
+ <number>-1</number>
</property>
<widget>
<class>QGroupBox</class>
<property stdset="1">
@@ -869,12 +869,79 @@
</property>
</widget>
</grid>
</widget>
+ <widget>
+ <class>QGroupBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>sndGroup</cstring>
+ </property>
+ <property stdset="1">
+ <name>title</name>
+ <string>Play Sound</string>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>sndCheck</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Play File</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout6</cstring>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>sndFileName</cstring>
+ </property>
+ </widget>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>sndChoose</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>...</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
<spacer>
<property>
<name>name</name>
- <cstring>Spacer1</cstring>
+ <cstring>Spacer3</cstring>
</property>
<property stdset="1">
<name>orientation</name>
<enum>Vertical</enum>
@@ -917,5 +984,39 @@
<name>image0</name>
<data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
</image>
</images>
+<connections>
+ <connection>
+ <sender>dailyEnabled</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>sndGroup</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>sndCheck</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>sndFileName</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>sndCheck</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>sndChoose</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+ <connection>
+ <sender>sndChoose</sender>
+ <signal>clicked()</signal>
+ <receiver>ClockBase</receiver>
+ <slot>slotBrowseMp3File()</slot>
+ </connection>
+ <connection>
+ <sender>sndCheck</sender>
+ <signal>stateChanged(int)</signal>
+ <receiver>ClockBase</receiver>
+ <slot>scheduleApplyDailyAlarm()</slot>
+ </connection>
+ <slot access="public">scheduleApplyDailyAlarm()</slot>
+ <slot access="protected">slotBrowseMp3File()</slot>
+</connections>
</UI>
diff --git a/noncore/tools/clock/main.cpp b/noncore/tools/clock/main.cpp
index 237d9f0..380bfeb 100644
--- a/noncore/tools/clock/main.cpp
+++ b/noncore/tools/clock/main.cpp
@@ -1,8 +1,8 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the 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
@@ -18,11 +18,7 @@
**
**********************************************************************/
#include "clock.h"
-
#include <opie2/oapplicationfactory.h>
-
-
-using namespace Opie::Core;
using namespace Opie::Core;
OPIE_EXPORT_APP( OApplicationFactory<Clock> )