author | zecke <zecke> | 2004-04-03 20:10:15 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-04-03 20:10:15 (UTC) |
commit | 1f03371e4c5d9db806e941bf3687b4bf340aa4fa (patch) (unidiff) | |
tree | 08d4855e6babf252493ad677f30e5e35ba7a5751 /noncore | |
parent | 93aeaa0de75ba89bd565c845e79e470a80816b0a (diff) | |
download | opie-1f03371e4c5d9db806e941bf3687b4bf340aa4fa.zip opie-1f03371e4c5d9db806e941bf3687b4bf340aa4fa.tar.gz opie-1f03371e4c5d9db806e941bf3687b4bf340aa4fa.tar.bz2 |
This is the merged Qtopia Clock with our changes included
-Seperate Clock, StopWatch, Alarm
-Allow starting stopping the stop watch by QCOP
-Allow Daily alarms
-Call OpiePlayer on resume
-rw-r--r-- | noncore/tools/clock/analogclock.cpp | 2 | ||||
-rw-r--r-- | noncore/tools/clock/clock.cpp | 1156 | ||||
-rw-r--r-- | noncore/tools/clock/clock.h | 112 | ||||
-rw-r--r-- | noncore/tools/clock/clock.pro | 9 | ||||
-rw-r--r-- | noncore/tools/clock/clockbase.ui | 111 | ||||
-rw-r--r-- | noncore/tools/clock/main.cpp | 8 |
6 files changed, 823 insertions, 575 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 | |||
@@ -44,7 +44,7 @@ void AnalogClock::drawContents( QPainter *p ) | |||
44 | #if !defined(NO_DEBUG) | 44 | #if !defined(NO_DEBUG) |
45 | static bool first = true; | 45 | static bool first = true; |
46 | if ( first ) { | 46 | if ( first ) { |
47 | QTOPIA_PROFILE("first paint event"); | 47 | //QTOPIA_PROFILE("first paint event"); |
48 | first = false; | 48 | first = false; |
49 | } | 49 | } |
50 | #endif | 50 | #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,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
@@ -18,9 +18,15 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | // changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002 | 20 | // changes added and Copyright (C) by L. J. Potter <ljp@llornkcor.com> 2002 |
21 | // changes added and Copyright (C) by Holger Freyther 2004 | ||
21 | 22 | ||
22 | #include "clock.h" | 23 | #include "clock.h" |
23 | #include "setAlarm.h" | 24 | |
25 | #include "analogclock.h" | ||
26 | |||
27 | #include <qtabwidget.h> | ||
28 | |||
29 | #include <opie2/ofiledialog.h> | ||
24 | 30 | ||
25 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/qcopenvelope_qws.h> | 32 | #include <qpe/qcopenvelope_qws.h> |
@@ -32,19 +38,30 @@ | |||
32 | #include <qsound.h> | 38 | #include <qsound.h> |
33 | #include <qtimer.h> | 39 | #include <qtimer.h> |
34 | 40 | ||
35 | #include <opie2/oclickablelabel.h> | 41 | |
36 | 42 | ||
37 | #include <qlcdnumber.h> | 43 | #include <qlcdnumber.h> |
38 | #include <qslider.h> | 44 | #include <qslider.h> |
39 | #include <qlabel.h> | 45 | #include <qlabel.h> |
40 | #include <qlayout.h> | ||
41 | #include <qtimer.h> | 46 | #include <qtimer.h> |
42 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
43 | #include <qradiobutton.h> | 48 | #include <qtoolbutton.h> |
44 | #include <qbuttongroup.h> | ||
45 | #include <qpainter.h> | 49 | #include <qpainter.h> |
46 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
47 | #include <qdatetime.h> | 51 | #include <qdatetime.h> |
52 | #include <qspinbox.h> | ||
53 | #include <qcombobox.h> | ||
54 | #include <qcheckbox.h> | ||
55 | #include <qgroupbox.h> | ||
56 | #include <qlayout.h> | ||
57 | #include <qhbox.h> | ||
58 | #include <qlineedit.h> | ||
59 | |||
60 | static const int sw_prec = 2; | ||
61 | static const int magic_daily = 2292922; | ||
62 | static const int magic_countdown = 2292923; | ||
63 | static const int magic_snooze = 2292924; | ||
64 | static const int magic_playmp = 2292925; | ||
48 | 65 | ||
49 | #include <math.h> | 66 | #include <math.h> |
50 | #include <unistd.h> | 67 | #include <unistd.h> |
@@ -53,612 +70,737 @@ | |||
53 | #include <pthread.h> | 70 | #include <pthread.h> |
54 | 71 | ||
55 | 72 | ||
56 | const double deg2rad = 0.017453292519943295769; // pi/180 | 73 | static void toggleScreenSaver( bool on ) |
57 | const int sw_prec = 2; | ||
58 | |||
59 | using namespace Opie::Ui; | ||
60 | void startPlayer() | ||
61 | { | 74 | { |
62 | Config config( "qpe" ); | 75 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); |
63 | config.setGroup( "Time" ); | 76 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); |
64 | sleep(15); | ||
65 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | ||
66 | e << config.readEntry( "mp3File", "" ); | ||
67 | } | 77 | } |
68 | 78 | ||
69 | 79 | static void startPlayer() | |
70 | static void toggleScreenSaver( bool on ) | ||
71 | { | 80 | { |
72 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); | 81 | Config config( "qpe" ); |
73 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); | 82 | config.setGroup( "Time" ); |
83 | sleep(15); | ||
84 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | ||
85 | e << config.readEntry( "mp3File", "" ); | ||
74 | } | 86 | } |
75 | 87 | ||
76 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) | 88 | class MySpinBox : public QSpinBox |
77 | : QVBox( parent, name , f ) | ||
78 | { | 89 | { |
79 | setSpacing( 4 ); | 90 | public: |
80 | setMargin( 1 ); | 91 | QLineEdit *lineEdit() const { |
81 | 92 | return editor(); | |
82 | 93 | } | |
83 | snoozeBtn = new QPushButton ( this ); | 94 | }; |
84 | snoozeBtn->setText( tr( "Snooze" ) ); | 95 | |
85 | 96 | // | |
86 | aclock = new AnalogClock( this ); | 97 | // |
87 | aclock->display( QTime::currentTime() ); | 98 | // |
88 | aclock->setLineWidth( 2 ); | 99 | AlarmDlg::AlarmDlg(QWidget *parent, const char *name, bool modal, |
89 | 100 | const QString &txt) : | |
90 | QHBox *hb = new QHBox( this ); | 101 | AlarmDlgBase(parent, name, modal) |
91 | hb->setMargin( 0 ); | 102 | { |
92 | QWidget *space = new QWidget( hb ); | 103 | setCaption( tr("Clock") ); |
93 | lcd = new QLCDNumber( hb ); | 104 | pixmap->setPixmap( Resource::loadPixmap("alarmbell") ); |
94 | lcd->setSegmentStyle( QLCDNumber::Flat ); | 105 | alarmDlgLabel->setText(txt); |
95 | lcd->setFrameStyle( QFrame::NoFrame ); | ||
96 | lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); | ||
97 | lcd->setFixedHeight( 23 ); | ||
98 | |||
99 | ampmLabel = new QLabel( tr( "PM" ), hb ); | ||
100 | ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | ||
101 | ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); | ||
102 | ampmLabel->setAlignment( AlignLeft | AlignBottom ); | ||
103 | space = new QWidget( hb ); | ||
104 | |||
105 | date = new QLabel( this ); | ||
106 | date->setAlignment( AlignHCenter | AlignVCenter ); | ||
107 | date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | ||
108 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | ||
109 | |||
110 | QWidget *controls = new QWidget( this ); | ||
111 | QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 ); | ||
112 | 106 | ||
113 | QButtonGroup *grp = new QButtonGroup( controls ); | 107 | connect(snoozeTime, SIGNAL(valueChanged(int)), this, |
114 | grp->setRadioButtonExclusive( true ); | 108 | SLOT(changePrompt(int))); |
115 | grp->hide(); | 109 | connect(cmdOk, SIGNAL(clicked()), this, SLOT(checkSnooze())); |
110 | } | ||
116 | 111 | ||
117 | clockRB = new QRadioButton ( tr( "Clock" ), controls ); | 112 | // |
118 | gl->addWidget( clockRB, 0, 0 ); | 113 | // |
119 | grp->insert( clockRB ); | 114 | // |
115 | void | ||
116 | AlarmDlg::setText(const QString &txt) | ||
117 | { | ||
118 | alarmDlgLabel->setText(txt); | ||
119 | } | ||
120 | 120 | ||
121 | swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); | 121 | // |
122 | gl->addWidget( swatchRB, 1, 0 ); | 122 | // |
123 | grp->insert( swatchRB ); | 123 | // |
124 | void | ||
125 | AlarmDlg::checkSnooze(void) | ||
126 | { | ||
127 | // | ||
128 | // Ensure we have only one snooze alarm. | ||
129 | // | ||
130 | AlarmServer::deleteAlarm(QDateTime(), "QPE/Application/clock", | ||
131 | "alarm(QDateTime,int)", magic_snooze); | ||
132 | |||
133 | if (snoozeTime->value() > 0) { | ||
134 | QDateTime wake = QDateTime::currentDateTime(); | ||
135 | wake = wake.addSecs(snoozeTime->value() * 60); // snoozeTime in minutes | ||
136 | |||
137 | AlarmServer::addAlarm(wake, "QPE/Application/clock", | ||
138 | "alarm(QDateTime,int)", magic_snooze); | ||
139 | } | ||
140 | accept(); | ||
141 | } | ||
124 | 142 | ||
125 | connect( grp, SIGNAL( clicked(int) ), this, SLOT( modeSelect(int) ) ); | ||
126 | grp->setButton( 0 ); | ||
127 | 143 | ||
128 | set = new QPushButton ( controls ); | ||
129 | set->setMaximumSize( 50, 30 ); | ||
130 | gl->addWidget( set , 0, 1 ); | ||
131 | set->setText( tr( "Start" ) ); | ||
132 | set->setEnabled( FALSE ); | ||
133 | grp->insert( set ); | ||
134 | 144 | ||
135 | reset = new QPushButton ( controls ); | 145 | void |
136 | gl->addWidget( reset, 1, 1 ); | 146 | AlarmDlg::changePrompt(int mins) |
137 | reset->setText( tr( "Reset" ) ); | 147 | { |
138 | reset->setEnabled( FALSE ); | 148 | cmdOk->setText(mins > 0 ? tr("Snooze") : tr("Close") ); |
139 | grp->insert( reset ); | 149 | } |
140 | 150 | ||
141 | alarmOffBtn = new QPushButton ( controls ); | ||
142 | gl->addWidget( alarmOffBtn, 0, 2 ); | ||
143 | 151 | ||
144 | alarmBtn = new QPushButton ( controls ); | ||
145 | gl->addWidget( alarmBtn, 1, 2 ); | ||
146 | 152 | ||
147 | alarmBtn->setText( tr( "Set Alarm" ) ); | 153 | Clock::Clock( QWidget * parent, const char *, WFlags f ) |
154 | : ClockBase( parent, "clock", f ), swatch_splitms(99), init(FALSE) // No tr | ||
155 | { | ||
156 | alarmDlg = 0; | ||
157 | swLayout = 0; | ||
158 | dayBtn = new QToolButton * [7]; | ||
148 | 159 | ||
149 | OClickableLabel *click = new Opie::Ui::OClickableLabel( controls, "label" ); | 160 | Config config( "qpe" ); |
150 | click->setText( tr( "Set date and time." ) ); | 161 | config.setGroup("Time"); |
151 | gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter ); | 162 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
152 | connect( click, SIGNAL( clicked() ), this, SLOT( slotAdjustTime() ) ); | 163 | onMonday = config.readBoolEntry( "MONDAY" ); |
164 | |||
165 | connect( tabs, SIGNAL(currentChanged(QWidget*)), | ||
166 | this, SLOT(tabChanged(QWidget*)) ); | ||
167 | |||
168 | analogStopwatch = new AnalogClock( swFrame ); | ||
169 | stopwatchLcd = new QLCDNumber( swFrame ); | ||
170 | stopwatchLcd->setFrameStyle( QFrame::NoFrame ); | ||
171 | stopwatchLcd->setSegmentStyle( QLCDNumber::Flat ); | ||
172 | stopwatchLcd->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred) ); | ||
173 | |||
174 | analogClock->display( QTime::currentTime() ); | ||
175 | clockLcd->setNumDigits( 5 ); | ||
176 | clockLcd->setFixedWidth( clockLcd->sizeHint().width() ); | ||
177 | date->setText( TimeString::dateString( QDate::currentDate(), TimeString::currentDateFormat() ) ); | ||
178 | if ( qApp->desktop()->width() < 200 ) | ||
179 | date->setFont( QFont(date->font().family(), 14, QFont::Bold) ); | ||
180 | if ( qApp->desktop()->height() > 240 ) { | ||
181 | clockLcd->setFixedHeight( 30 ); | ||
182 | stopwatchLcd->setFixedHeight( 30 ); | ||
183 | } | ||
153 | 184 | ||
154 | connect( set , SIGNAL( pressed() ), SLOT( slotSet() ) ); | 185 | connect( stopStart, SIGNAL(pressed()), SLOT(stopStartStopWatch()) ); |
155 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); | 186 | connect( reset, SIGNAL(pressed()), SLOT(resetStopWatch()) ); |
156 | 187 | ||
157 | connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); | 188 | t = new QTimer( this ); |
158 | connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); | 189 | connect( t, SIGNAL(timeout()), SLOT(updateClock()) ); |
159 | connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); | 190 | t->start( 1000 ); |
160 | 191 | ||
161 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 192 | applyAlarmTimer = new QTimer( this ); |
162 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | 193 | connect( applyAlarmTimer, SIGNAL(timeout()), |
194 | this, SLOT(applyDailyAlarm()) ); | ||
163 | 195 | ||
164 | t = new QTimer( this ); | 196 | alarmt = new QTimer( this ); |
165 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); | 197 | connect( alarmt, SIGNAL(timeout()), SLOT(alarmTimeout()) ); |
166 | t->start( 1000 ); | ||
167 | 198 | ||
168 | connect( qApp, SIGNAL( timeChanged() ), SLOT( updateClock() ) ); | 199 | connect( qApp, SIGNAL(timeChanged()), SLOT(updateClock()) ); |
200 | connect( qApp, SIGNAL(timeChanged()), SLOT(applyDailyAlarm()) ); | ||
169 | 201 | ||
170 | swatch_running = FALSE; | 202 | swatch_running = FALSE; |
171 | swatch_totalms = 0; | 203 | swatch_totalms = 0; |
204 | swatch_currLap = 0; | ||
205 | swatch_dispLap = 0; | ||
206 | stopwatchLcd->setNumDigits( 8+1+sw_prec ); | ||
207 | stopwatchLcd->display( "00:00:00.00" ); | ||
208 | |||
209 | QVBoxLayout *lvb = new QVBoxLayout( lapFrame ); | ||
210 | nextLapBtn = new QToolButton( UpArrow, lapFrame ); | ||
211 | connect( nextLapBtn, SIGNAL(clicked()), this, SLOT(nextLap()) ); | ||
212 | nextLapBtn->setAccel( Key_Up ); | ||
213 | lvb->addWidget( nextLapBtn ); | ||
214 | prevLapBtn = new QToolButton( DownArrow, lapFrame ); | ||
215 | connect( prevLapBtn, SIGNAL(clicked()), this, SLOT(prevLap()) ); | ||
216 | prevLapBtn->setAccel( Key_Down ); | ||
217 | prevLapBtn->setMinimumWidth( 15 ); | ||
218 | lvb->addWidget( prevLapBtn ); | ||
219 | prevLapBtn->setEnabled( FALSE ); | ||
220 | nextLapBtn->setEnabled( FALSE ); | ||
221 | |||
222 | reset->setEnabled( FALSE ); | ||
223 | |||
224 | lapLcd->setNumDigits( 8+1+sw_prec ); | ||
225 | lapLcd->display( "00:00:00.00" ); | ||
226 | |||
227 | splitLcd->setNumDigits( 8+1+sw_prec ); | ||
228 | splitLcd->display( "00:00:00.00" ); | ||
229 | |||
230 | lapNumLcd->display( 1 ); | ||
231 | |||
232 | lapTimer = new QTimer( this ); | ||
233 | connect( lapTimer, SIGNAL(timeout()), this, SLOT(lapTimeout()) ); | ||
234 | |||
235 | for (uint s = 0; s < swatch_splitms.count(); s++ ) | ||
236 | swatch_splitms[(int)s] = 0; | ||
237 | |||
238 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); | ||
239 | |||
240 | cdGroup->hide(); // XXX implement countdown timer. | ||
241 | |||
242 | connect( dailyHour, SIGNAL(valueChanged(int)), this, SLOT(scheduleApplyDailyAlarm()) ); | ||
243 | connect( dailyMinute, SIGNAL(valueChanged(int)), this, SLOT(setDailyMinute(int)) ); | ||
244 | connect( dailyAmPm, SIGNAL(activated(int)), this, SLOT(setDailyAmPm(int)) ); | ||
245 | connect( dailyEnabled, SIGNAL(toggled(bool)), this, SLOT(enableDaily(bool)) ); | ||
246 | cdLcd->display( "00:00" ); | ||
247 | |||
248 | dailyMinute->setValidator(0); | ||
249 | |||
250 | Config cConfig( "Clock" ); // No tr | ||
251 | cConfig.setGroup( "Daily Alarm" ); | ||
252 | |||
253 | QStringList days; | ||
254 | days.append( tr("Mon", "Monday") ); | ||
255 | days.append( tr("Tue", "Tuesday") ); | ||
256 | days.append( tr("Wed", "Wednesday") ); | ||
257 | days.append( tr("Thu", "Thursday") ); | ||
258 | days.append( tr("Fri", "Friday") ); | ||
259 | days.append( tr("Sat", "Saturday") ); | ||
260 | days.append( tr("Sun", "Sunday") ); | ||
261 | |||
262 | int i; | ||
263 | QHBoxLayout *hb = new QHBoxLayout( daysFrame ); | ||
264 | for ( i = 0; i < 7; i++ ) { | ||
265 | dayBtn[i] = new QToolButton( daysFrame ); | ||
266 | hb->addWidget( dayBtn[i] ); | ||
267 | dayBtn[i]->setToggleButton( TRUE ); | ||
268 | dayBtn[i]->setOn( TRUE ); | ||
269 | dayBtn[i]->setFocusPolicy( StrongFocus ); | ||
270 | connect( dayBtn[i], SIGNAL(toggled(bool)), this, SLOT(scheduleApplyDailyAlarm()) ); | ||
271 | } | ||
172 | 272 | ||
173 | connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( changeClock(bool) ) ); | 273 | for ( i = 0; i < 7; i++ ) |
274 | dayBtn[dayBtnIdx(i+1)]->setText( days[i] ); | ||
174 | 275 | ||
276 | QStringList exclDays = cConfig.readListEntry( "ExcludeDays", ',' ); | ||
277 | QStringList::Iterator it; | ||
278 | for ( it = exclDays.begin(); it != exclDays.end(); ++it ) { | ||
279 | int d = (*it).toInt(); | ||
280 | if ( d >= 1 && d <= 7 ) | ||
281 | dayBtn[dayBtnIdx(d)]->setOn( FALSE ); | ||
282 | } | ||
175 | 283 | ||
176 | Config config( "qpe" ); | 284 | bool alarm = cConfig.readBoolEntry("Enabled", FALSE); |
177 | config.setGroup( "Time" ); | 285 | bool sound = cConfig.readBoolEntry("SoundEnabled", FALSE ); |
178 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 286 | dailyEnabled->setChecked( alarm ); |
287 | sndGroup->setEnabled( alarm ); | ||
288 | sndCheck->setChecked( sound ); | ||
289 | sndChoose->setEnabled( sound ); | ||
290 | sndFileName->setEnabled( sound ); | ||
291 | |||
292 | // FIXME ODP migrate to own config class.. merge config options | ||
293 | Config cfg_qpe( "qpe" ); | ||
294 | cfg_qpe.setGroup( "Time" ); | ||
295 | sndFileName->setText( cfg_qpe.readEntry( "mp3File" ) ); | ||
296 | // | ||
297 | |||
298 | int m = cConfig.readNumEntry( "Minute", 0 ); | ||
299 | dailyMinute->setValue( m ); | ||
300 | // dailyMinute->setPrefix( m <= 9 ? "0" : "" ); | ||
301 | int h = cConfig.readNumEntry( "Hour", 7 ); | ||
302 | if ( ampm ) { | ||
303 | if (h > 12) { | ||
304 | h -= 12; | ||
305 | dailyAmPm->setCurrentItem( 1 ); | ||
306 | } | ||
307 | if (h == 0) h = 12; | ||
308 | dailyHour->setMinValue( 1 ); | ||
309 | dailyHour->setMaxValue( 12 ); | ||
310 | } else { | ||
311 | dailyAmPm->hide(); | ||
312 | } | ||
313 | dailyHour->setValue( h ); | ||
179 | 314 | ||
180 | QString tmp = config.readEntry( "clockAlarmHour", "" ); | 315 | connect( ((MySpinBox*)dailyHour)->lineEdit(), SIGNAL(textChanged(const QString&)), |
181 | bool ok; | 316 | this, SLOT(dailyEdited()) ); |
182 | hour = tmp.toInt( &ok, 10 ); | 317 | connect( ((MySpinBox*)dailyMinute)->lineEdit(), SIGNAL(textChanged(const QString&)), |
183 | tmp = config.readEntry( "clockAlarmMinute", "" ); | 318 | this, SLOT(dailyEdited()) ); |
184 | minute = tmp.toInt( &ok, 10 ); | ||
185 | 319 | ||
186 | if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) | 320 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
187 | { | 321 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), |
188 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 322 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); |
189 | alarmBool = TRUE; | 323 | #endif |
190 | snoozeBtn->show(); | ||
191 | } | ||
192 | else | ||
193 | { | ||
194 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | ||
195 | alarmBool = FALSE; | ||
196 | snoozeBtn->hide(); | ||
197 | } | ||
198 | 324 | ||
199 | QTimer::singleShot( 0, this, SLOT( updateClock() ) ); | 325 | QTimer::singleShot( 0, this, SLOT(updateClock()) ); |
326 | swFrame->installEventFilter( this ); | ||
200 | 327 | ||
201 | Config cfg( "Clock" ); | 328 | init = TRUE; |
202 | cfg.setGroup( "Mode" ); | ||
203 | int mode = cfg.readBoolEntry( "clockMode"); | ||
204 | setSwatchMode( mode); | ||
205 | modeSelect( mode); | ||
206 | } | 329 | } |
207 | 330 | ||
208 | Clock::~Clock() | 331 | Clock::~Clock() |
209 | { | 332 | { |
210 | toggleScreenSaver( true ); | 333 | toggleScreenSaver( true ); |
334 | delete [] dayBtn; | ||
211 | } | 335 | } |
212 | 336 | ||
213 | void Clock::updateClock() | 337 | void Clock::updateClock() |
214 | { | 338 | { |
215 | if ( clockRB->isChecked() ) | 339 | if ( tabs->currentPageIndex() == 0 ) { |
216 | { | 340 | QTime tm = QDateTime::currentDateTime().time(); |
217 | QTime tm = QDateTime::currentDateTime().time(); | 341 | QString s; |
218 | QString s; | 342 | if ( ampm ) { |
219 | if ( ampm ) | 343 | int hour = tm.hour(); |
220 | { | 344 | if (hour == 0) |
221 | int hour = tm.hour(); | 345 | hour = 12; |
222 | if ( hour == 0 ) | 346 | if (hour > 12) |
223 | hour = 12; | 347 | hour -= 12; |
224 | if ( hour > 12 ) | 348 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); |
225 | hour -= 12; | 349 | clockAmPm->setText( (tm.hour() >= 12) ? "PM" : "AM" ); |
226 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); | 350 | clockAmPm->show(); |
227 | ampmLabel->setText( ( tm.hour() >= 12 ) ? "PM" : "AM" ); | 351 | } else { |
228 | ampmLabel->show(); | 352 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); |
229 | } | 353 | clockAmPm->hide(); |
230 | else | 354 | } |
231 | { | 355 | clockLcd->display( s ); |
232 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); | 356 | clockLcd->repaint( FALSE ); |
233 | ampmLabel->hide(); | 357 | analogClock->display( QTime::currentTime() ); |
234 | } | 358 | date->setText( TimeString::dateString( QDate::currentDate(), TimeString::currentDateFormat() ) ); |
235 | lcd->display( s ); | 359 | } else if ( tabs->currentPageIndex() == 1 ) { |
236 | lcd->repaint( FALSE ); | 360 | int totalms = swatch_totalms; |
237 | aclock->display( QTime::currentTime() ); | 361 | if ( swatch_running ) |
238 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 362 | totalms += swatch_start.elapsed(); |
239 | } | 363 | setSwatchLcd( stopwatchLcd, totalms, !swatch_running ); |
240 | else | 364 | QTime swatch_time = QTime(0,0,0).addMSecs(totalms); |
241 | { | 365 | analogStopwatch->display( swatch_time ); |
242 | QTime swatch_time; | 366 | if ( swatch_dispLap == swatch_currLap ) { |
243 | QString lcdtext; | 367 | swatch_splitms[swatch_currLap] = swatch_totalms; |
244 | int totalms = swatch_totalms; | 368 | if ( swatch_running ) |
245 | if ( swatch_running ) | 369 | swatch_splitms[swatch_currLap] += swatch_start.elapsed(); |
246 | totalms += swatch_start.elapsed(); | 370 | updateLap(); |
247 | swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms ); | 371 | } |
248 | QString d = swatch_running ? QString( " " ) | 372 | } else if ( tabs->currentPageIndex() == 2 ) { |
249 | : QString::number( totalms % 1000 + 1000 ); | 373 | // nothing. |
250 | lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec ); | ||
251 | lcd->display( lcdtext ); | ||
252 | lcd->repaint( FALSE ); | ||
253 | aclock->display( swatch_time ); | ||
254 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | ||
255 | } | 374 | } |
256 | } | 375 | } |
257 | 376 | ||
258 | void Clock::changeClock( bool a ) | 377 | void Clock::changeClock( bool a ) |
259 | { | 378 | { |
260 | ampm = a; | 379 | if ( ampm != a ) { |
261 | updateClock(); | 380 | int minute = dailyMinute->value(); |
381 | int hour = dailyHour->value(); | ||
382 | if ( ampm ) { | ||
383 | if (hour == 12) | ||
384 | hour = 0; | ||
385 | if (dailyAmPm->currentItem() == 1 ) | ||
386 | hour += 12; | ||
387 | dailyHour->setMinValue( 0 ); | ||
388 | dailyHour->setMaxValue( 23 ); | ||
389 | dailyAmPm->hide(); | ||
390 | } else { | ||
391 | if (hour > 12) { | ||
392 | hour -= 12; | ||
393 | dailyAmPm->setCurrentItem( 1 ); | ||
394 | } | ||
395 | if (hour == 0) hour = 12; | ||
396 | dailyHour->setMinValue( 1 ); | ||
397 | dailyHour->setMaxValue( 12 ); | ||
398 | dailyAmPm->show(); | ||
399 | } | ||
400 | dailyMinute->setValue( minute ); | ||
401 | dailyHour->setValue( hour ); | ||
402 | } | ||
403 | ampm = a; | ||
404 | updateClock(); | ||
262 | } | 405 | } |
263 | 406 | ||
264 | void Clock::clearClock( void ) | 407 | void Clock::stopStartStopWatch() |
265 | { | 408 | { |
266 | lcd->display( QTime( 0, 0, 0 ).toString() ); | 409 | if ( swatch_running ) { |
267 | aclock->display( QTime( 0, 0, 0 ) ); | 410 | swatch_totalms += swatch_start.elapsed(); |
411 | swatch_splitms[swatch_currLap] = swatch_totalms; | ||
412 | stopStart->setText( tr("Start") ); | ||
413 | reset->setText( tr("Reset") ); | ||
414 | reset->setEnabled( TRUE ); | ||
415 | t->stop(); | ||
416 | swatch_running = FALSE; | ||
417 | toggleScreenSaver( TRUE ); | ||
418 | updateClock(); | ||
419 | } else { | ||
420 | swatch_start.start(); | ||
421 | stopStart->setText( tr("Stop") ); | ||
422 | reset->setText( tr("Lap/Split") ); | ||
423 | reset->setEnabled( swatch_currLap < 98 ); | ||
424 | t->start( 1000 ); | ||
425 | swatch_running = TRUE; | ||
426 | // disable screensaver while stop watch is running | ||
427 | toggleScreenSaver( FALSE ); | ||
428 | } | ||
429 | swatch_dispLap = swatch_currLap; | ||
430 | updateLap(); | ||
431 | prevLapBtn->setEnabled( swatch_dispLap ); | ||
432 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); | ||
433 | stopStart->setAccel( Key_Return ); | ||
268 | } | 434 | } |
269 | 435 | ||
270 | void Clock::startSWatch() | 436 | void Clock::resetStopWatch() |
271 | { | 437 | { |
272 | if(swatch_running) { | 438 | if ( swatch_running ) { |
273 | stopSWatch(); | 439 | swatch_splitms[swatch_currLap] = swatch_totalms+swatch_start.elapsed(); |
274 | return; | 440 | swatch_dispLap = swatch_currLap; |
275 | } | 441 | if ( swatch_currLap < 98 ) // allow up to 99 laps |
276 | qDebug("startSWatch()"); | 442 | swatch_currLap++; |
277 | swatch_start.start(); | 443 | reset->setEnabled( swatch_currLap < 98 ); |
278 | set->setText( tr( "Stop" ) ); | 444 | updateLap(); |
279 | t->start( 1000 ); | 445 | lapTimer->start( 2000, TRUE ); |
280 | swatch_running = TRUE; | 446 | } else { |
281 | // disable screensaver while stop watch is running | 447 | swatch_start.start(); |
282 | toggleScreenSaver( FALSE ); | 448 | swatch_totalms = 0; |
449 | swatch_currLap = 0; | ||
450 | swatch_dispLap = 0; | ||
451 | for ( uint i = 0; i < swatch_splitms.count(); i++ ) | ||
452 | swatch_splitms[(int)i] = 0; | ||
453 | updateLap(); | ||
454 | updateClock(); | ||
455 | reset->setText( tr("Lap/Split") ); | ||
456 | reset->setEnabled( FALSE ); | ||
457 | } | ||
458 | prevLapBtn->setEnabled( swatch_dispLap ); | ||
459 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); | ||
283 | } | 460 | } |
284 | 461 | ||
285 | void Clock::stopSWatch() | 462 | void Clock::prevLap() |
286 | { | 463 | { |
287 | qDebug("stopSWatch()"); | 464 | if ( swatch_dispLap > 0 ) { |
288 | swatch_totalms += swatch_start.elapsed(); | 465 | swatch_dispLap--; |
289 | set->setText( tr( "Start" ) ); | 466 | updateLap(); |
290 | t->stop(); | 467 | prevLapBtn->setEnabled( swatch_dispLap ); |
291 | swatch_running = FALSE; | 468 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); |
292 | toggleScreenSaver( TRUE ); | 469 | } |
293 | updateClock(); | ||
294 | } | 470 | } |
295 | 471 | ||
296 | 472 | void Clock::nextLap() | |
297 | void Clock::slotSet() | ||
298 | { | 473 | { |
299 | if ( t->isActive() ) | 474 | if ( swatch_dispLap < swatch_currLap ) { |
300 | { | 475 | swatch_dispLap++; |
301 | startSWatch(); | 476 | updateLap(); |
302 | } | 477 | prevLapBtn->setEnabled( swatch_dispLap ); |
303 | else | 478 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); |
304 | { | ||
305 | stopSWatch(); | ||
306 | } | 479 | } |
307 | } | 480 | } |
308 | 481 | ||
309 | void Clock::slotReset() | 482 | void Clock::lapTimeout() |
310 | { | 483 | { |
311 | t->stop(); | 484 | swatch_dispLap = swatch_currLap; |
312 | swatch_start.start(); | 485 | updateLap(); |
313 | swatch_totalms = 0; | 486 | prevLapBtn->setEnabled( swatch_dispLap ); |
314 | 487 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); | |
315 | if ( swatch_running ) | ||
316 | t->start( 1000 ); | ||
317 | |||
318 | updateClock(); | ||
319 | } | ||
320 | |||
321 | void Clock::modeSelect( int m ) | ||
322 | { | ||
323 | qDebug("Clock::modeSelect( %d) ", m); | ||
324 | if ( m != 0 ) | ||
325 | { | ||
326 | lcd->setNumDigits( 8 + 1 + sw_prec ); | ||
327 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | ||
328 | set->setEnabled( TRUE ); | ||
329 | reset->setEnabled( TRUE ); | ||
330 | ampmLabel->hide(); | ||
331 | |||
332 | // if(m == 2) { | ||
333 | if ( !swatch_running ) { | ||
334 | t->start( 1000 ); | ||
335 | } | ||
336 | // else | ||
337 | // { | ||
338 | // stopSWatch(); | ||
339 | // } | ||
340 | // } | ||
341 | } | ||
342 | else //clock mode | ||
343 | { | ||
344 | lcd->setNumDigits( 5 ); | ||
345 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | ||
346 | set->setEnabled( FALSE ); | ||
347 | reset->setEnabled( FALSE ); | ||
348 | t->start( 1000 ); | ||
349 | } | ||
350 | |||
351 | Config config( "Clock" ); | ||
352 | config.setGroup( "Mode" ); | ||
353 | config.writeEntry( "clockMode", m ); | ||
354 | updateClock(); | ||
355 | } | 488 | } |
356 | 489 | ||
357 | //this sets the alarm time | 490 | void Clock::updateLap() |
358 | void Clock::slotSetAlarm() | ||
359 | { | 491 | { |
360 | if ( !snoozeBtn->isHidden() ) | 492 | if ( swatch_running && swatch_currLap == swatch_dispLap ) { |
361 | slotToggleAlarm(); | 493 | swatch_splitms[swatch_currLap] = swatch_totalms; |
362 | Set_Alarm *setAlarmDlg; | 494 | swatch_splitms[swatch_currLap] += swatch_start.elapsed(); |
363 | setAlarmDlg = new Set_Alarm( this, "SetAlarm", TRUE ); | ||
364 | int result = setAlarmDlg->exec(); | ||
365 | if ( result == 1 ) { | ||
366 | Config config( "qpe" ); | ||
367 | config.setGroup( "Time" ); | ||
368 | QString tmp; | ||
369 | hour = setAlarmDlg->Hour_Slider->value(); | ||
370 | minute = setAlarmDlg->Minute_Slider->value(); | ||
371 | snoozeTime = setAlarmDlg->SnoozeSlider->value(); | ||
372 | if ( ampm ) { | ||
373 | if ( hour == 12 ) | ||
374 | hour = 0; | ||
375 | |||
376 | if ( setAlarmDlg->Pm_RadioButton->isChecked() && hour < 12 ) | ||
377 | hour += 12; | ||
378 | } | 495 | } |
379 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); | 496 | int split = swatch_splitms[swatch_dispLap]; |
380 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); | 497 | int lap; |
381 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); | 498 | if ( swatch_dispLap > 0 ) |
382 | config.write(); | 499 | lap = swatch_splitms[swatch_dispLap] - swatch_splitms[swatch_dispLap-1]; |
383 | } | 500 | else |
384 | } | 501 | lap = swatch_splitms[swatch_dispLap]; |
385 | 502 | ||
386 | void Clock::slotSnooze() | 503 | lapNumLcd->display( swatch_dispLap+1 ); |
387 | { | 504 | bool showMs = !swatch_running || swatch_dispLap!=swatch_currLap; |
388 | bSound = FALSE; | 505 | setSwatchLcd( lapLcd, lap, showMs ); |
389 | int warn = 0; | 506 | setSwatchLcd( splitLcd, split, showMs ); |
390 | QTime t = QTime::currentTime(); | 507 | } |
391 | QDateTime whenl( when.date(), t.addSecs( snoozeTime * 60 ) ); | ||
392 | when = whenl; | ||
393 | AlarmServer::addAlarm( when, | ||
394 | "QPE/Application/clock", | ||
395 | "alarm(QDateTime,int)", warn ); | ||
396 | |||
397 | } | ||
398 | |||
399 | //toggles alarm on/off | ||
400 | void Clock::slotToggleAlarm() | ||
401 | { | ||
402 | Config config( "qpe" ); | ||
403 | config.setGroup( "Time" ); | ||
404 | if ( alarmBool ) | ||
405 | { | ||
406 | config.writeEntry( "clockAlarmSet", "FALSE" ); | ||
407 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | ||
408 | snoozeBtn->hide(); | ||
409 | alarmBool = FALSE; | ||
410 | alarmOff(); | ||
411 | } | ||
412 | else | ||
413 | { | ||
414 | config.writeEntry( "clockAlarmSet", "TRUE" ); | ||
415 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | ||
416 | snoozeBtn->show(); | ||
417 | alarmBool = TRUE; | ||
418 | alarmOn(); | ||
419 | } | ||
420 | config.write(); | ||
421 | } | ||
422 | |||
423 | void Clock::alarmOn() | ||
424 | { | ||
425 | QDate d = QDate::currentDate(); | ||
426 | QTime tm( ( int ) hour, ( int ) minute, 0 ); | ||
427 | qDebug( "Time set " + tm.toString() ); | ||
428 | QTime t = QTime::currentTime(); | ||
429 | if ( t > tm ) | ||
430 | d = d.addDays( 1 ); | ||
431 | int warn = 0; | ||
432 | QDateTime whenl( d, tm ); | ||
433 | when = whenl; | ||
434 | AlarmServer::addAlarm( when, | ||
435 | "QPE/Application/clock", | ||
436 | "alarm(QDateTime,int)", warn ); | ||
437 | // setCaption( "Alarm set: " + whenl.toString() ); | ||
438 | setCaption( tr("Alarm set: %1" ).arg(whenl.toString()) ); | ||
439 | } | ||
440 | |||
441 | void Clock::alarmOff() | ||
442 | { | ||
443 | int warn = 0; | ||
444 | bSound = FALSE; | ||
445 | AlarmServer::deleteAlarm( when, | ||
446 | "QPE/Application/clock", | ||
447 | "alarm(QDateTime,int)", warn ); | ||
448 | qDebug( "Alarm Off " + when.toString() ); | ||
449 | setCaption( tr("Clock") ); | ||
450 | } | ||
451 | |||
452 | void Clock::clearTimer() | ||
453 | { | ||
454 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | ||
455 | alarmBool = FALSE; | ||
456 | snoozeBtn->hide(); | ||
457 | setCaption( tr("Clock") ); | ||
458 | } | ||
459 | |||
460 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | ||
461 | { | ||
462 | int stopTimer = 0; | ||
463 | int timerStay = 5000; | ||
464 | bSound = TRUE; | ||
465 | qDebug( "Message received in clock" ); | ||
466 | if ( msg == "alarm(QDateTime,int)" ) | ||
467 | { | ||
468 | Config config( "qpe" ); | ||
469 | config.setGroup( "Time" ); | ||
470 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) | ||
471 | { | ||
472 | clearTimer(); | ||
473 | pthread_t thread; | ||
474 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); | ||
475 | |||
476 | } | ||
477 | else | ||
478 | { | ||
479 | 508 | ||
480 | Sound::soundAlarm(); | 509 | void Clock::setSwatchLcd( QLCDNumber *lcd, int ms, bool showMs ) |
481 | stopTimer = startTimer( timerStay ); | 510 | { |
482 | } | 511 | QTime swatch_time = QTime(0,0,0).addMSecs(ms); |
483 | } | 512 | QString d = showMs ? QString::number(ms%1000+1000) : QString(" "); |
513 | QString lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec); | ||
514 | lcd->display( lcdtext ); | ||
515 | lcd->repaint( FALSE ); | ||
516 | } | ||
484 | 517 | ||
485 | if ( msg == "timerStart()" ) | 518 | bool Clock::eventFilter( QObject *o, QEvent *e ) |
486 | { | 519 | { |
487 | slotStartTimer(); | 520 | if ( o == swFrame && e->type() == QEvent::Resize ) { |
488 | } | 521 | QResizeEvent *re = (QResizeEvent *)e; |
489 | if ( msg == "timerStop()" ) | 522 | delete swLayout; |
490 | { | 523 | if ( re->size().height() < 80 || re->size().height()*3 < re->size().width() ) |
491 | slotStopTimer(); | 524 | swLayout = new QHBoxLayout( swFrame ); |
492 | } | 525 | else |
493 | if ( msg == "timerReset()" ) | 526 | swLayout = new QVBoxLayout( swFrame ); |
494 | { | 527 | swLayout->addWidget( analogStopwatch ); |
495 | slotResetTimer(); | 528 | swLayout->addWidget( stopwatchLcd ); |
529 | swLayout->activate(); | ||
496 | } | 530 | } |
497 | 531 | ||
498 | show(); | 532 | return FALSE; |
499 | raise(); | ||
500 | QPEApplication::setKeepRunning(); | ||
501 | setActiveWindow(); | ||
502 | } | 533 | } |
503 | 534 | ||
504 | void Clock::timerEvent( QTimerEvent *e ) | 535 | void Clock::tabChanged( QWidget * ) |
505 | { | 536 | { |
506 | static int stop = 0; | 537 | if ( tabs->currentPageIndex() == 0 ) { |
507 | if ( stop < 120 && bSound ) | 538 | t->start(1000); |
508 | { | 539 | } else if ( tabs->currentPageIndex() == 1 ) { |
509 | Sound::soundAlarm(); | 540 | if ( !swatch_running ) |
510 | stop++; | 541 | t->stop(); |
511 | } | 542 | stopStart->setAccel( Key_Return ); |
512 | else | 543 | } else if ( tabs->currentPageIndex() == 2 ) { |
513 | { | 544 | t->start(1000); |
514 | stop = 0; | ||
515 | killTimer( e->timerId() ); | ||
516 | clearTimer(); | ||
517 | setCaption( tr( "Clock: Alarm was missed." ) ); | ||
518 | } | 545 | } |
546 | updateClock(); | ||
519 | } | 547 | } |
520 | 548 | ||
521 | AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true) | 549 | void Clock::setDailyAmPm(int) |
522 | { | 550 | { |
523 | QWidget *d = QApplication::desktop(); | 551 | scheduleApplyDailyAlarm(); |
524 | if(d->width() <= 240) | ||
525 | bg = Resource::loadPixmap("clock/bg"); | ||
526 | } | 552 | } |
527 | 553 | ||
528 | QSizePolicy AnalogClock::sizePolicy() const | 554 | void Clock::setDailyMinute( int m ) |
529 | { | 555 | { |
530 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | 556 | dailyMinute->setPrefix( m <= 9 ? "0" : "" ); |
531 | } | 557 | } |
532 | 558 | ||
533 | void AnalogClock::drawContents( QPainter *p ) | 559 | void Clock::dailyEdited() |
534 | { | 560 | { |
535 | QRect r = contentsRect(); | 561 | if ( spinBoxValid(dailyMinute) && spinBoxValid(dailyHour) ) |
536 | QRect fr; | 562 | scheduleApplyDailyAlarm(); |
537 | 563 | else | |
538 | p->drawPixmap(QPoint(0, 0), bg, r); | 564 | applyAlarmTimer->stop(); |
539 | 565 | } | |
540 | if ( r. width ( ) > r. height ( )) | ||
541 | fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); | ||
542 | else | ||
543 | fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); | ||
544 | |||
545 | QPoint center = fr. center ( ); // ( fr.x() + fr.width() / 2, fr.y() + fr.height() / 2 ); | ||
546 | QPoint l1 ( center. x ( ), fr. y ( ) + 2 ); | ||
547 | QPoint l2 ( center. x ( ), fr. y ( ) + 8 ); | ||
548 | |||
549 | |||
550 | 566 | ||
551 | if ( clear ) | 567 | void Clock::enableDaily( bool ) |
552 | { | 568 | { |
553 | erase ( r ); | 569 | scheduleApplyDailyAlarm(); |
554 | p-> setPen ( NoPen ); | 570 | } |
555 | p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); | ||
556 | p-> drawEllipse ( fr ); | ||
557 | p-> setBrush ( NoBrush ); | ||
558 | 571 | ||
559 | // draw ticks | 572 | void Clock::appMessage( const QCString &msg, const QByteArray &data ) |
560 | p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); | 573 | { |
561 | for ( int i = 0; i < 12; i++ ) | 574 | if ( msg == "alarm(QDateTime,int)" ) { |
562 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); | 575 | QDataStream ds(data,IO_ReadOnly); |
563 | } | 576 | QDateTime when; |
564 | else | 577 | int t; |
565 | { | 578 | ds >> when >> t; |
566 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); | 579 | QTime theTime( when.time() ); |
580 | if ( t == magic_daily || t == magic_snooze || | ||
581 | t == magic_playmp ) { | ||
582 | QString msg = tr("<b>Daily Alarm:</b><p>"); | ||
583 | QString ts; | ||
584 | if ( ampm ) { | ||
585 | bool pm = FALSE; | ||
586 | int h = theTime.hour(); | ||
587 | if (h > 12) { | ||
588 | h -= 12; | ||
589 | pm = TRUE; | ||
590 | } | ||
591 | if (h == 0) h = 12; | ||
592 | ts.sprintf( "%02d:%02d %s", h, theTime.minute(), pm?"PM":"AM" ); | ||
593 | } else { | ||
594 | ts.sprintf( "%02d:%02d", theTime.hour(), theTime.minute() ); | ||
595 | } | ||
596 | msg += ts; | ||
597 | |||
598 | if (t == magic_playmp ) { | ||
599 | pthread_t thread; | ||
600 | pthread_create(&thread,NULL, (void * (*) (void *))startPlayer, NULL/* &*/ ); | ||
601 | }else { | ||
602 | Sound::soundAlarm(); | ||
603 | alarmCount = 0; | ||
604 | alarmt->start( 5000 ); | ||
605 | } | ||
606 | if ( !alarmDlg ) { | ||
607 | alarmDlg = new AlarmDlg(this); | ||
608 | } | ||
609 | alarmDlg->setText(msg); | ||
610 | |||
611 | // Set for tomorrow, so user wakes up every day, even if they | ||
612 | // don't confirm the dialog. Don't set it again when snoozing. | ||
613 | if (t != magic_snooze) { | ||
614 | applyDailyAlarm(); | ||
615 | } | ||
616 | |||
617 | |||
618 | if ( !alarmDlg->isVisible() ) { | ||
619 | QPEApplication::execDialog(alarmDlg); | ||
620 | alarmt->stop(); | ||
621 | } | ||
622 | } else if ( t == magic_countdown ) { | ||
623 | // countdown | ||
624 | Sound::soundAlarm(); | ||
625 | } | ||
626 | } else if ( msg == "setDailyEnabled(int)" ) { | ||
627 | QDataStream ds(data,IO_ReadOnly); | ||
628 | int enableDaily; | ||
629 | ds >> enableDaily; | ||
630 | dailyEnabled->setChecked( enableDaily ); | ||
631 | applyDailyAlarm(); | ||
632 | } else if ( msg == "editDailyAlarm()" ) { | ||
633 | tabs->setCurrentPage(2); | ||
634 | QPEApplication::setKeepRunning(); | ||
635 | } else if (msg == "showClock()") { | ||
636 | tabs->setCurrentPage(0); | ||
637 | QPEApplication::setKeepRunning(); | ||
638 | } else if (msg == "timerStart()" ) { | ||
639 | if ( !swatch_running ) | ||
640 | stopStartStopWatch(); | ||
641 | tabs->setCurrentPage(1); | ||
642 | QPEApplication::setKeepRunning(); | ||
643 | } else if (msg == "timerStop()" ) { | ||
644 | if ( swatch_running ) | ||
645 | stopStartStopWatch(); | ||
646 | tabs->setCurrentPage(1); | ||
647 | QPEApplication::setKeepRunning(); | ||
648 | } else if (msg == "timerReset()" ) { | ||
649 | resetStopWatch(); | ||
650 | tabs->setCurrentPage(1); | ||
651 | QPEApplication::setKeepRunning(); | ||
567 | } | 652 | } |
568 | |||
569 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime ); | ||
570 | |||
571 | prevTime = currTime; | ||
572 | } | 653 | } |
573 | 654 | ||
574 | void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 ) | 655 | void Clock::alarmTimeout() |
575 | { | 656 | { |
576 | QPoint center = r. center ( ); | 657 | if ( alarmCount < 10 ) { |
577 | 658 | Sound::soundAlarm(); | |
578 | QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 ); | 659 | alarmCount++; |
579 | QPoint h2( center. x ( ), center. y ( ) ); | 660 | } else { |
580 | 661 | alarmCount = 0; | |
581 | QPoint m1( center. x ( ), r.y() + r.height() / 8 ); | 662 | alarmt->stop(); |
582 | QPoint m2( center. x ( ), center. y ( ) ); | 663 | } |
583 | 664 | } | |
584 | QPoint s1( center. x ( ), r. y ( ) + 8 ); | ||
585 | QPoint s2( center. x ( ), center. y ( ) ); | ||
586 | |||
587 | |||
588 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) { | ||
589 | // draw hour pointer | ||
590 | h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); | ||
591 | h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); | ||
592 | p-> setPen ( QPen ( c, 3 )); | ||
593 | p-> drawLine ( h1, h2 ); | ||
594 | } | ||
595 | 665 | ||
596 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) { | 666 | QDateTime Clock::nextAlarm( int h, int m ) |
597 | // draw minute pointer | 667 | { |
598 | m1 = rotate( center, m1, t.minute() * 6 ); | 668 | QDateTime now = QDateTime::currentDateTime(); |
599 | m2 = rotate( center, m2, t.minute() * 6 ); | 669 | QTime at( h, m ); |
600 | p-> setPen ( QPen ( c, 2 )); | 670 | QDateTime when( now.date(), at ); |
601 | p-> drawLine ( m1, m2 ); | 671 | int count = 0; |
602 | } | 672 | int dow = when.date().dayOfWeek(); |
673 | while ( when < now || !dayBtn[dayBtnIdx(dow)]->isOn() ) { | ||
674 | when = when.addDays( 1 ); | ||
675 | dow = when.date().dayOfWeek(); | ||
676 | if ( ++count > 7 ) | ||
677 | return QDateTime(); | ||
678 | } | ||
603 | 679 | ||
604 | if ( !t2 || ( t. second ( ) != t2-> second ( ))) { | 680 | return when; |
605 | // draw second pointer | ||
606 | s1 = rotate( center, s1, t.second() * 6 ); | ||
607 | s2 = rotate( center, s2, t.second() * 6 ); | ||
608 | p-> setPen ( QPen ( c, 1 )); | ||
609 | p-> drawLine ( s1, s2 ); | ||
610 | } | ||
611 | } | 681 | } |
612 | 682 | ||
613 | void AnalogClock::display( const QTime& t ) | 683 | int Clock::dayBtnIdx( int d ) const |
614 | { | 684 | { |
615 | currTime = t; | 685 | if ( onMonday ) |
616 | clear = false; | 686 | return d-1; |
617 | repaint( false ); | 687 | else if ( d == 7 ) |
618 | clear = true; | 688 | return 0; |
689 | else | ||
690 | return d; | ||
619 | } | 691 | } |
620 | 692 | ||
621 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) | 693 | void Clock::scheduleApplyDailyAlarm() |
622 | { | 694 | { |
623 | double angle = deg2rad * ( - a + 180 ); | 695 | applyAlarmTimer->start( 5000, TRUE ); |
624 | double nx = c.x() - ( p.x() - c.x() ) * cos( angle ) - | ||
625 | ( p.y() - c.y() ) * sin( angle ); | ||
626 | double ny = c.y() - ( p.y() - c.y() ) * cos( angle ) + | ||
627 | ( p.x() - c.x() ) * sin( angle ); | ||
628 | return QPoint( nx, ny ); | ||
629 | } | 696 | } |
630 | 697 | ||
631 | void Clock::slotAdjustTime() | 698 | void Clock::applyDailyAlarm() |
632 | { | 699 | { |
633 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 700 | if ( !init ) |
634 | e << QString( "systemtime" ); | 701 | return; |
702 | |||
703 | applyAlarmTimer->stop(); | ||
704 | int minute = dailyMinute->value(); | ||
705 | int hour = dailyHour->value(); | ||
706 | if ( ampm ) { | ||
707 | if (hour == 12) | ||
708 | hour = 0; | ||
709 | if (dailyAmPm->currentItem() == 1 ) | ||
710 | hour += 12; | ||
711 | } | ||
712 | |||
713 | Config config( "Clock" ); | ||
714 | config.setGroup( "Daily Alarm" ); | ||
715 | config.writeEntry( "Hour", hour ); | ||
716 | config.writeEntry( "Minute", minute ); | ||
717 | |||
718 | bool enableDaily = dailyEnabled->isChecked(); | ||
719 | bool wasSound = config.readEntry( "SoundEnabled" ); | ||
720 | bool isSound = sndCheck->isChecked(); | ||
721 | int oldMagic = wasSound ? magic_playmp : magic_daily; | ||
722 | int isMagic = isSound ? magic_playmp : magic_daily; | ||
723 | config.writeEntry( "Enabled", enableDaily ); | ||
724 | config.writeEntry( "SoundEnabled", isSound ); | ||
725 | |||
726 | QString exclDays; | ||
727 | int exclCount = 0; | ||
728 | for ( int i = 1; i <= 7; i++ ) { | ||
729 | if ( !dayBtn[dayBtnIdx(i)]->isOn() ) { | ||
730 | if ( !exclDays.isEmpty() ) | ||
731 | exclDays += ","; | ||
732 | exclDays += QString::number( i ); | ||
733 | exclCount++; | ||
734 | } | ||
735 | } | ||
736 | config.writeEntry( "ExcludeDays", exclDays ); | ||
737 | |||
738 | /* try to delete both */ | ||
739 | AlarmServer::deleteAlarm(QDateTime(), "QPE/Application/clock", | ||
740 | "alarm(QDateTime,int)", oldMagic); | ||
741 | if ( enableDaily && exclCount < 7 ) { | ||
742 | QDateTime when = nextAlarm( hour, minute ); | ||
743 | AlarmServer::addAlarm(when, "QPE/Application/clock", | ||
744 | "alarm(QDateTime,int)", isMagic); | ||
745 | } | ||
635 | } | 746 | } |
636 | 747 | ||
637 | void Clock::slotStartTimer() | 748 | bool Clock::validDaysSelected(void) |
638 | { | 749 | { |
639 | if ( clockRB->isChecked() ) | 750 | for ( int i = 1; i <= 7; i++ ) { |
640 | setSwatchMode( 1); | 751 | if ( dayBtn[dayBtnIdx(i)]->isOn() ) { |
641 | startSWatch(); | 752 | return TRUE; |
753 | } | ||
754 | } | ||
755 | return FALSE; | ||
642 | } | 756 | } |
643 | 757 | ||
644 | void Clock::slotStopTimer() | 758 | void Clock::closeEvent( QCloseEvent *e ) |
645 | { | 759 | { |
646 | if ( clockRB->isChecked() ) | 760 | if (dailyEnabled->isChecked()) { |
647 | setSwatchMode( 1); | 761 | if (!validDaysSelected()) { |
648 | stopSWatch(); | 762 | QMessageBox::warning(this, tr("Select Day"), |
763 | tr("Daily alarm requires at least\none day to be selected.")); | ||
764 | return; | ||
765 | } | ||
766 | } | ||
767 | |||
768 | applyDailyAlarm(); | ||
769 | ClockBase::closeEvent(e); | ||
649 | } | 770 | } |
650 | 771 | ||
651 | void Clock::slotResetTimer() | 772 | bool Clock::spinBoxValid( QSpinBox *sb ) |
652 | { | 773 | { |
653 | if ( clockRB->isChecked() ) | 774 | bool valid = TRUE; |
654 | setSwatchMode( 1); | 775 | QString tv = sb->text(); |
655 | slotReset(); | 776 | for ( uint i = 0; i < tv.length(); i++ ) { |
777 | if ( !tv[0].isDigit() ) | ||
778 | valid = FALSE; | ||
779 | } | ||
780 | bool ok = FALSE; | ||
781 | int v = tv.toInt( &ok ); | ||
782 | if ( !ok ) | ||
783 | valid = FALSE; | ||
784 | if ( v < sb->minValue() || v > sb->maxValue() ) | ||
785 | valid = FALSE; | ||
786 | |||
787 | return valid; | ||
656 | } | 788 | } |
657 | 789 | ||
658 | void Clock::setSwatchMode(int mode) | 790 | void Clock::slotBrowseMp3File() { |
659 | { | 791 | Config config( "qpe" ); |
660 | qDebug("Clock::setSwatchMode( %d)", mode); | 792 | config.setGroup("Time"); |
661 | swatchRB->setChecked( mode); | 793 | |
662 | clearClock( ); | 794 | QMap<QString, QStringList> map; |
663 | modeSelect( mode ); | 795 | map.insert(tr("All"), QStringList() ); |
796 | QStringList text; | ||
797 | text << "audio/*"; | ||
798 | map.insert(tr("Audio"), text ); | ||
799 | QString str = Opie::Ui::OFileDialog::getOpenFileName( 2,"/", QString::null, map); | ||
800 | if(!str.isEmpty() ) { | ||
801 | config.writeEntry("mp3Alarm",1); | ||
802 | config.writeEntry("mp3File",str); | ||
803 | sndFileName->setText( str ); | ||
804 | scheduleApplyDailyAlarm(); | ||
805 | } | ||
664 | } | 806 | } |
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,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
@@ -20,50 +20,39 @@ | |||
20 | #ifndef CLOCK_H | 20 | #ifndef CLOCK_H |
21 | #define CLOCK_H | 21 | #define CLOCK_H |
22 | 22 | ||
23 | #include "clockbase.h" | ||
24 | #include "alarmdlgbase.h" | ||
23 | #include <qdatetime.h> | 25 | #include <qdatetime.h> |
24 | #include <qvbox.h> | ||
25 | #include <qpixmap.h> | ||
26 | 26 | ||
27 | class QLCDNumber; | ||
28 | class QLabel; | ||
29 | class QTimer; | 27 | class QTimer; |
30 | class QRadioButton; | 28 | class QLabel; |
31 | class QPushButton; | 29 | class QDialog; |
32 | class QDateTime; | 30 | class AnalogClock; |
31 | class QBoxLayout; | ||
32 | class QToolButton; | ||
33 | 33 | ||
34 | class AnalogClock : public QFrame | 34 | class AlarmDlg: public AlarmDlgBase |
35 | { | 35 | { |
36 | Q_OBJECT | 36 | Q_OBJECT |
37 | 37 | ||
38 | public: | 38 | public: |
39 | AnalogClock( QWidget * parent = 0, const char * name = 0 ); | 39 | AlarmDlg(QWidget *parent = 0, const char *name = 0, bool modal = TRUE, |
40 | 40 | const QString &txt = "Alarm"); | |
41 | QSizePolicy sizePolicy() const; | ||
42 | |||
43 | void display( const QTime& time ); | ||
44 | |||
45 | |||
46 | protected: | ||
47 | void drawContents( QPainter *p ); | ||
48 | |||
49 | private: | ||
50 | 41 | ||
51 | QPixmap bg; | 42 | void setText(const QString &txt); |
52 | QTime currTime; | ||
53 | QTime prevTime; | ||
54 | bool clear; | ||
55 | 43 | ||
56 | QPoint rotate( QPoint center, QPoint p, int angle ); | ||
57 | void drawPointers ( QPainter *, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 = 0 ); | ||
58 | 44 | ||
45 | private slots: | ||
46 | void checkSnooze(void); | ||
47 | void changePrompt(int minutes); | ||
59 | }; | 48 | }; |
60 | 49 | ||
61 | class Clock : public QVBox | 50 | class Clock : public ClockBase |
62 | { | 51 | { |
63 | Q_OBJECT | 52 | Q_OBJECT |
64 | 53 | ||
65 | public: | 54 | public: |
66 | Clock( QWidget * parent = 0, const char * name = 0, WFlags f=0 ); | 55 | Clock( QWidget *parent=0, const char *name=0, WFlags fl=0 ); |
67 | ~Clock(); | 56 | ~Clock(); |
68 | QDateTime when; | 57 | QDateTime when; |
69 | bool bSound; | 58 | bool bSound; |
@@ -71,41 +60,56 @@ public: | |||
71 | static QString appName() { return QString::fromLatin1("clock"); } | 60 | static QString appName() { return QString::fromLatin1("clock"); } |
72 | 61 | ||
73 | private slots: | 62 | private slots: |
74 | void slotSet(); | 63 | void stopStartStopWatch(); |
75 | void slotReset(); | 64 | void resetStopWatch(); |
76 | void modeSelect(int); | 65 | void prevLap(); |
66 | void nextLap(); | ||
67 | void lapTimeout(); | ||
68 | void tabChanged(QWidget*); | ||
77 | void updateClock(); | 69 | void updateClock(); |
78 | void changeClock( bool ); | 70 | void changeClock( bool ); |
79 | void slotSetAlarm(); | 71 | void setDailyAmPm( int ); |
80 | void slotSnooze(); | 72 | void setDailyMinute( int ); |
81 | void slotToggleAlarm(); | 73 | void dailyEdited(); |
82 | void alarmOn(); | 74 | void enableDaily( bool ); |
83 | void alarmOff(); | ||
84 | void appMessage(const QCString& msg, const QByteArray& data); | 75 | void appMessage(const QCString& msg, const QByteArray& data); |
85 | void timerEvent( QTimerEvent *e ); | 76 | void alarmTimeout(); |
86 | void slotAdjustTime(); | 77 | void applyDailyAlarm(); |
78 | void scheduleApplyDailyAlarm(); | ||
79 | void slotBrowseMp3File(); | ||
80 | |||
81 | protected: | ||
82 | QDateTime nextAlarm( int h, int m ); | ||
83 | int dayBtnIdx( int ) const; | ||
84 | void closeEvent( QCloseEvent *e ); | ||
85 | void updateLap(); | ||
86 | void setSwatchLcd( QLCDNumber *lcd, int ms, bool showMs ); | ||
87 | bool eventFilter( QObject *, QEvent * ); | ||
88 | bool spinBoxValid( QSpinBox *sb ); | ||
89 | bool validDaysSelected(void); | ||
87 | 90 | ||
88 | void slotStartTimer(); | ||
89 | void slotStopTimer(); | ||
90 | void slotResetTimer(); | ||
91 | void setSwatchMode( int ); | ||
92 | private: | 91 | private: |
93 | bool alarmBool; | ||
94 | QTimer *t; | 92 | QTimer *t; |
95 | QLCDNumber *lcd; | 93 | QTimer *alarmt; |
96 | QLabel *date; | ||
97 | QLabel *ampmLabel; | ||
98 | QPushButton *set, *reset, *alarmBtn, *snoozeBtn, *alarmOffBtn; | ||
99 | QRadioButton *clockRB, *swatchRB; | ||
100 | AnalogClock *aclock; | ||
101 | QTime swatch_start; | 94 | QTime swatch_start; |
102 | int swatch_totalms; | 95 | int swatch_totalms; |
96 | QArray<int> swatch_splitms; | ||
103 | bool swatch_running; | 97 | bool swatch_running; |
98 | int swatch_currLap; | ||
99 | int swatch_dispLap; | ||
100 | QToolButton *prevLapBtn; | ||
101 | QToolButton *nextLapBtn; | ||
102 | QTimer *lapTimer; | ||
103 | AnalogClock* analogStopwatch; | ||
104 | QLCDNumber* stopwatchLcd; | ||
105 | QBoxLayout *swLayout; | ||
104 | bool ampm; | 106 | bool ampm; |
105 | void clearClock(); | 107 | bool onMonday; |
106 | void clearTimer(); | 108 | int alarmCount; |
107 | void startSWatch(); | 109 | AlarmDlg* alarmDlg; |
108 | void stopSWatch(); | 110 | QToolButton **dayBtn; |
111 | bool init; | ||
112 | QTimer *applyAlarmTimer; | ||
109 | }; | 113 | }; |
110 | 114 | ||
111 | #endif | 115 | #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 @@ | |||
1 | CONFIG = qt warn_on quick-app | 1 | CONFIG = qt warn_on quick-app |
2 | HEADERS = clock.h setAlarm.h | 2 | HEADERS = clock.h analogclock.h |
3 | SOURCES = clock.cpp setAlarm.cpp \ | 3 | SOURCES = clock.cpp analogclock.cpp \ |
4 | main.cpp | 4 | main.cpp |
5 | |||
5 | INCLUDEPATH += $(OPIEDIR)/include | 6 | INCLUDEPATH += $(OPIEDIR)/include |
6 | DEPENDPATH += $(OPIEDIR)/include | 7 | DEPENDPATH += $(OPIEDIR)/include |
7 | LIBS += -lqpe -lopiecore2 -lopieui2 -lpthread | 8 | LIBS += -lqpe -lopiecore2 -lopieui2 -lpthread |
8 | TARGET = clock | 9 | TARGET = clock |
9 | 10 | ||
11 | |||
12 | INTERFACES= clockbase.ui \ | ||
13 | alarmdlgbase.ui | ||
14 | |||
10 | include ( $(OPIEDIR)/include.pro ) | 15 | 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 | |||
@@ -11,8 +11,8 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>220</width> | 14 | <width>287</width> |
15 | <height>337</height> | 15 | <height>389</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
@@ -516,11 +516,11 @@ | |||
516 | <vbox> | 516 | <vbox> |
517 | <property stdset="1"> | 517 | <property stdset="1"> |
518 | <name>margin</name> | 518 | <name>margin</name> |
519 | <number>6</number> | 519 | <number>-1</number> |
520 | </property> | 520 | </property> |
521 | <property stdset="1"> | 521 | <property stdset="1"> |
522 | <name>spacing</name> | 522 | <name>spacing</name> |
523 | <number>4</number> | 523 | <number>-1</number> |
524 | </property> | 524 | </property> |
525 | <widget> | 525 | <widget> |
526 | <class>QGroupBox</class> | 526 | <class>QGroupBox</class> |
@@ -870,10 +870,77 @@ | |||
870 | </widget> | 870 | </widget> |
871 | </grid> | 871 | </grid> |
872 | </widget> | 872 | </widget> |
873 | <widget> | ||
874 | <class>QGroupBox</class> | ||
875 | <property stdset="1"> | ||
876 | <name>name</name> | ||
877 | <cstring>sndGroup</cstring> | ||
878 | </property> | ||
879 | <property stdset="1"> | ||
880 | <name>title</name> | ||
881 | <string>Play Sound</string> | ||
882 | </property> | ||
883 | <vbox> | ||
884 | <property stdset="1"> | ||
885 | <name>margin</name> | ||
886 | <number>11</number> | ||
887 | </property> | ||
888 | <property stdset="1"> | ||
889 | <name>spacing</name> | ||
890 | <number>6</number> | ||
891 | </property> | ||
892 | <widget> | ||
893 | <class>QCheckBox</class> | ||
894 | <property stdset="1"> | ||
895 | <name>name</name> | ||
896 | <cstring>sndCheck</cstring> | ||
897 | </property> | ||
898 | <property stdset="1"> | ||
899 | <name>text</name> | ||
900 | <string>Play File</string> | ||
901 | </property> | ||
902 | </widget> | ||
903 | <widget> | ||
904 | <class>QLayoutWidget</class> | ||
905 | <property stdset="1"> | ||
906 | <name>name</name> | ||
907 | <cstring>Layout6</cstring> | ||
908 | </property> | ||
909 | <hbox> | ||
910 | <property stdset="1"> | ||
911 | <name>margin</name> | ||
912 | <number>0</number> | ||
913 | </property> | ||
914 | <property stdset="1"> | ||
915 | <name>spacing</name> | ||
916 | <number>6</number> | ||
917 | </property> | ||
918 | <widget> | ||
919 | <class>QLineEdit</class> | ||
920 | <property stdset="1"> | ||
921 | <name>name</name> | ||
922 | <cstring>sndFileName</cstring> | ||
923 | </property> | ||
924 | </widget> | ||
925 | <widget> | ||
926 | <class>QToolButton</class> | ||
927 | <property stdset="1"> | ||
928 | <name>name</name> | ||
929 | <cstring>sndChoose</cstring> | ||
930 | </property> | ||
931 | <property stdset="1"> | ||
932 | <name>text</name> | ||
933 | <string>...</string> | ||
934 | </property> | ||
935 | </widget> | ||
936 | </hbox> | ||
937 | </widget> | ||
938 | </vbox> | ||
939 | </widget> | ||
873 | <spacer> | 940 | <spacer> |
874 | <property> | 941 | <property> |
875 | <name>name</name> | 942 | <name>name</name> |
876 | <cstring>Spacer1</cstring> | 943 | <cstring>Spacer3</cstring> |
877 | </property> | 944 | </property> |
878 | <property stdset="1"> | 945 | <property stdset="1"> |
879 | <name>orientation</name> | 946 | <name>orientation</name> |
@@ -918,4 +985,38 @@ | |||
918 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | 985 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> |
919 | </image> | 986 | </image> |
920 | </images> | 987 | </images> |
988 | <connections> | ||
989 | <connection> | ||
990 | <sender>dailyEnabled</sender> | ||
991 | <signal>toggled(bool)</signal> | ||
992 | <receiver>sndGroup</receiver> | ||
993 | <slot>setEnabled(bool)</slot> | ||
994 | </connection> | ||
995 | <connection> | ||
996 | <sender>sndCheck</sender> | ||
997 | <signal>toggled(bool)</signal> | ||
998 | <receiver>sndFileName</receiver> | ||
999 | <slot>setEnabled(bool)</slot> | ||
1000 | </connection> | ||
1001 | <connection> | ||
1002 | <sender>sndCheck</sender> | ||
1003 | <signal>toggled(bool)</signal> | ||
1004 | <receiver>sndChoose</receiver> | ||
1005 | <slot>setEnabled(bool)</slot> | ||
1006 | </connection> | ||
1007 | <connection> | ||
1008 | <sender>sndChoose</sender> | ||
1009 | <signal>clicked()</signal> | ||
1010 | <receiver>ClockBase</receiver> | ||
1011 | <slot>slotBrowseMp3File()</slot> | ||
1012 | </connection> | ||
1013 | <connection> | ||
1014 | <sender>sndCheck</sender> | ||
1015 | <signal>stateChanged(int)</signal> | ||
1016 | <receiver>ClockBase</receiver> | ||
1017 | <slot>scheduleApplyDailyAlarm()</slot> | ||
1018 | </connection> | ||
1019 | <slot access="public">scheduleApplyDailyAlarm()</slot> | ||
1020 | <slot access="protected">slotBrowseMp3File()</slot> | ||
1021 | </connections> | ||
921 | </UI> | 1022 | </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,7 +1,7 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
@@ -19,10 +19,6 @@ | |||
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "clock.h" | 21 | #include "clock.h" |
22 | |||
23 | #include <opie2/oapplicationfactory.h> | 22 | #include <opie2/oapplicationfactory.h> |
24 | |||
25 | |||
26 | using namespace Opie::Core; | ||
27 | using namespace Opie::Core; | 23 | using namespace Opie::Core; |
28 | OPIE_EXPORT_APP( OApplicationFactory<Clock> ) | 24 | OPIE_EXPORT_APP( OApplicationFactory<Clock> ) |