-rw-r--r-- | noncore/tools/clock/analogclock.cpp | 2 | ||||
-rw-r--r-- | noncore/tools/clock/clock.cpp | 1012 | ||||
-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, 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 | |||
@@ -41,13 +41,13 @@ QSizePolicy AnalogClock::sizePolicy() const | |||
41 | 41 | ||
42 | void AnalogClock::drawContents( QPainter *p ) | 42 | void AnalogClock::drawContents( QPainter *p ) |
43 | { | 43 | { |
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 |
51 | 51 | ||
52 | QRect r = contentsRect(); | 52 | QRect r = contentsRect(); |
53 | 53 | ||
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,10 +1,10 @@ | |||
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 |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
@@ -15,650 +15,792 @@ | |||
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
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> |
27 | #include <qpe/config.h> | 33 | #include <qpe/config.h> |
28 | #include <qpe/timestring.h> | 34 | #include <qpe/timestring.h> |
29 | #include <qpe/alarmserver.h> | 35 | #include <qpe/alarmserver.h> |
30 | #include <qpe/sound.h> | 36 | #include <qpe/sound.h> |
31 | #include <qpe/resource.h> | 37 | #include <qpe/resource.h> |
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> |
51 | #include <sys/types.h> | 68 | #include <sys/types.h> |
52 | 69 | ||
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; | 74 | { |
75 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); | ||
76 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); | ||
77 | } | ||
58 | 78 | ||
59 | using namespace Opie::Ui; | 79 | static void startPlayer() |
60 | void startPlayer() | ||
61 | { | 80 | { |
62 | Config config( "qpe" ); | 81 | Config config( "qpe" ); |
63 | config.setGroup( "Time" ); | 82 | config.setGroup( "Time" ); |
64 | sleep(15); | 83 | sleep(15); |
65 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); | 84 | QCopEnvelope e( "QPE/Application/opieplayer", "setDocument(QString)" ); |
66 | e << config.readEntry( "mp3File", "" ); | 85 | e << config.readEntry( "mp3File", "" ); |
67 | } | 86 | } |
68 | 87 | ||
69 | 88 | class MySpinBox : public QSpinBox | |
70 | static void toggleScreenSaver( bool on ) | ||
71 | { | 89 | { |
72 | QCopEnvelope e( "QPE/System", "setScreenSaverMode(int)" ); | 90 | public: |
73 | e << ( on ? QPEApplication::Enable : QPEApplication::DisableSuspend ); | 91 | QLineEdit *lineEdit() const { |
92 | return editor(); | ||
74 | } | 93 | } |
94 | }; | ||
75 | 95 | ||
76 | Clock::Clock( QWidget * parent, const char * name, WFlags f ) | 96 | // |
77 | : QVBox( parent, name , f ) | 97 | // |
98 | // | ||
99 | AlarmDlg::AlarmDlg(QWidget *parent, const char *name, bool modal, | ||
100 | const QString &txt) : | ||
101 | AlarmDlgBase(parent, name, modal) | ||
78 | { | 102 | { |
79 | setSpacing( 4 ); | 103 | setCaption( tr("Clock") ); |
80 | setMargin( 1 ); | 104 | pixmap->setPixmap( Resource::loadPixmap("alarmbell") ); |
81 | 105 | alarmDlgLabel->setText(txt); | |
82 | |||
83 | snoozeBtn = new QPushButton ( this ); | ||
84 | snoozeBtn->setText( tr( "Snooze" ) ); | ||
85 | |||
86 | aclock = new AnalogClock( this ); | ||
87 | aclock->display( QTime::currentTime() ); | ||
88 | aclock->setLineWidth( 2 ); | ||
89 | |||
90 | QHBox *hb = new QHBox( this ); | ||
91 | hb->setMargin( 0 ); | ||
92 | QWidget *space = new QWidget( hb ); | ||
93 | lcd = new QLCDNumber( hb ); | ||
94 | lcd->setSegmentStyle( QLCDNumber::Flat ); | ||
95 | lcd->setFrameStyle( QFrame::NoFrame ); | ||
96 | lcd->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ) ); | ||
97 | lcd->setFixedHeight( 23 ); | ||
98 | 106 | ||
99 | ampmLabel = new QLabel( tr( "PM" ), hb ); | 107 | connect(snoozeTime, SIGNAL(valueChanged(int)), this, |
100 | ampmLabel->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | 108 | SLOT(changePrompt(int))); |
101 | ampmLabel->setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Preferred ) ); | 109 | connect(cmdOk, SIGNAL(clicked()), this, SLOT(checkSnooze())); |
102 | ampmLabel->setAlignment( AlignLeft | AlignBottom ); | 110 | } |
103 | space = new QWidget( hb ); | ||
104 | 111 | ||
105 | date = new QLabel( this ); | 112 | // |
106 | date->setAlignment( AlignHCenter | AlignVCenter ); | 113 | // |
107 | date->setFont( QFont( "Helvetica", 14, QFont::Bold ) ); | 114 | // |
108 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 115 | void |
116 | AlarmDlg::setText(const QString &txt) | ||
117 | { | ||
118 | alarmDlgLabel->setText(txt); | ||
119 | } | ||
109 | 120 | ||
110 | QWidget *controls = new QWidget( this ); | 121 | // |
111 | QGridLayout *gl = new QGridLayout( controls, 3, 2, 6, 4 ); | 122 | // |
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); | ||
112 | 132 | ||
113 | QButtonGroup *grp = new QButtonGroup( controls ); | 133 | if (snoozeTime->value() > 0) { |
114 | grp->setRadioButtonExclusive( true ); | 134 | QDateTime wake = QDateTime::currentDateTime(); |
115 | grp->hide(); | 135 | wake = wake.addSecs(snoozeTime->value() * 60); // snoozeTime in minutes |
116 | 136 | ||
117 | clockRB = new QRadioButton ( tr( "Clock" ), controls ); | 137 | AlarmServer::addAlarm(wake, "QPE/Application/clock", |
118 | gl->addWidget( clockRB, 0, 0 ); | 138 | "alarm(QDateTime,int)", magic_snooze); |
119 | grp->insert( clockRB ); | 139 | } |
140 | accept(); | ||
141 | } | ||
120 | 142 | ||
121 | swatchRB = new QRadioButton ( tr( "Stopwatch" ), controls ); | ||
122 | gl->addWidget( swatchRB, 1, 0 ); | ||
123 | grp->insert( swatchRB ); | ||
124 | 143 | ||
125 | connect( grp, SIGNAL( clicked(int) ), this, SLOT( modeSelect(int) ) ); | ||
126 | grp->setButton( 0 ); | ||
127 | 144 | ||
128 | set = new QPushButton ( controls ); | 145 | void |
129 | set->setMaximumSize( 50, 30 ); | 146 | AlarmDlg::changePrompt(int mins) |
130 | gl->addWidget( set , 0, 1 ); | 147 | { |
131 | set->setText( tr( "Start" ) ); | 148 | cmdOk->setText(mins > 0 ? tr("Snooze") : tr("Close") ); |
132 | set->setEnabled( FALSE ); | 149 | } |
133 | grp->insert( set ); | ||
134 | 150 | ||
135 | reset = new QPushButton ( controls ); | ||
136 | gl->addWidget( reset, 1, 1 ); | ||
137 | reset->setText( tr( "Reset" ) ); | ||
138 | reset->setEnabled( FALSE ); | ||
139 | grp->insert( reset ); | ||
140 | 151 | ||
141 | alarmOffBtn = new QPushButton ( controls ); | ||
142 | gl->addWidget( alarmOffBtn, 0, 2 ); | ||
143 | 152 | ||
144 | alarmBtn = new QPushButton ( controls ); | 153 | Clock::Clock( QWidget * parent, const char *, WFlags f ) |
145 | gl->addWidget( alarmBtn, 1, 2 ); | 154 | : ClockBase( parent, "clock", f ), swatch_splitms(99), init(FALSE) // No tr |
155 | { | ||
156 | alarmDlg = 0; | ||
157 | swLayout = 0; | ||
158 | dayBtn = new QToolButton * [7]; | ||
146 | 159 | ||
147 | alarmBtn->setText( tr( "Set Alarm" ) ); | 160 | Config config( "qpe" ); |
161 | config.setGroup("Time"); | ||
162 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
163 | onMonday = config.readBoolEntry( "MONDAY" ); | ||
148 | 164 | ||
149 | OClickableLabel *click = new Opie::Ui::OClickableLabel( controls, "label" ); | 165 | connect( tabs, SIGNAL(currentChanged(QWidget*)), |
150 | click->setText( tr( "Set date and time." ) ); | 166 | this, SLOT(tabChanged(QWidget*)) ); |
151 | gl->addMultiCellWidget( click, 3, 3, 0, 2, AlignHCenter ); | ||
152 | connect( click, SIGNAL( clicked() ), this, SLOT( slotAdjustTime() ) ); | ||
153 | 167 | ||
154 | connect( set , SIGNAL( pressed() ), SLOT( slotSet() ) ); | 168 | analogStopwatch = new AnalogClock( swFrame ); |
155 | connect( reset, SIGNAL( clicked() ), SLOT( slotReset() ) ); | 169 | stopwatchLcd = new QLCDNumber( swFrame ); |
170 | stopwatchLcd->setFrameStyle( QFrame::NoFrame ); | ||
171 | stopwatchLcd->setSegmentStyle( QLCDNumber::Flat ); | ||
172 | stopwatchLcd->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred) ); | ||
156 | 173 | ||
157 | connect( alarmBtn, SIGNAL( clicked() ), SLOT( slotSetAlarm() ) ); | 174 | analogClock->display( QTime::currentTime() ); |
158 | connect( snoozeBtn, SIGNAL( clicked() ), SLOT( slotSnooze() ) ); | 175 | clockLcd->setNumDigits( 5 ); |
159 | connect( alarmOffBtn, SIGNAL( clicked() ), SLOT( slotToggleAlarm() ) ); | 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 | } | ||
160 | 184 | ||
161 | connect( qApp, SIGNAL( appMessage(const QCString&,const QByteArray&) ), | 185 | connect( stopStart, SIGNAL(pressed()), SLOT(stopStartStopWatch()) ); |
162 | this, SLOT( appMessage(const QCString&,const QByteArray&) ) ); | 186 | connect( reset, SIGNAL(pressed()), SLOT(resetStopWatch()) ); |
163 | 187 | ||
164 | t = new QTimer( this ); | 188 | t = new QTimer( this ); |
165 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); | 189 | connect( t, SIGNAL( timeout() ), SLOT( updateClock() ) ); |
166 | t->start( 1000 ); | 190 | t->start( 1000 ); |
167 | 191 | ||
192 | applyAlarmTimer = new QTimer( this ); | ||
193 | connect( applyAlarmTimer, SIGNAL(timeout()), | ||
194 | this, SLOT(applyDailyAlarm()) ); | ||
195 | |||
196 | alarmt = new QTimer( this ); | ||
197 | connect( alarmt, SIGNAL(timeout()), SLOT(alarmTimeout()) ); | ||
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 ); | ||
172 | 221 | ||
173 | connect( qApp, SIGNAL( clockChanged(bool) ), this, SLOT( changeClock(bool) ) ); | 222 | reset->setEnabled( FALSE ); |
174 | 223 | ||
224 | lapLcd->setNumDigits( 8+1+sw_prec ); | ||
225 | lapLcd->display( "00:00:00.00" ); | ||
175 | 226 | ||
176 | Config config( "qpe" ); | 227 | splitLcd->setNumDigits( 8+1+sw_prec ); |
177 | config.setGroup( "Time" ); | 228 | splitLcd->display( "00:00:00.00" ); |
178 | ampm = config.readBoolEntry( "AMPM", TRUE ); | ||
179 | 229 | ||
180 | QString tmp = config.readEntry( "clockAlarmHour", "" ); | 230 | lapNumLcd->display( 1 ); |
181 | bool ok; | ||
182 | hour = tmp.toInt( &ok, 10 ); | ||
183 | tmp = config.readEntry( "clockAlarmMinute", "" ); | ||
184 | minute = tmp.toInt( &ok, 10 ); | ||
185 | 231 | ||
186 | if ( config.readEntry( "clockAlarmSet", "FALSE" ) == "TRUE" ) | 232 | lapTimer = new QTimer( this ); |
187 | { | 233 | connect( lapTimer, SIGNAL(timeout()), this, SLOT(lapTimeout()) ); |
188 | alarmOffBtn->setText( tr( "Alarm Is On" ) ); | 234 | |
189 | alarmBool = TRUE; | 235 | for (uint s = 0; s < swatch_splitms.count(); s++ ) |
190 | snoozeBtn->show(); | 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 | } | ||
272 | |||
273 | for ( i = 0; i < 7; i++ ) | ||
274 | dayBtn[dayBtnIdx(i+1)]->setText( days[i] ); | ||
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 | } | ||
283 | |||
284 | bool alarm = cConfig.readBoolEntry("Enabled", FALSE); | ||
285 | bool sound = cConfig.readBoolEntry("SoundEnabled", FALSE ); | ||
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 ); | ||
191 | } | 306 | } |
192 | else | 307 | if (h == 0) h = 12; |
193 | { | 308 | dailyHour->setMinValue( 1 ); |
194 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 309 | dailyHour->setMaxValue( 12 ); |
195 | alarmBool = FALSE; | 310 | } else { |
196 | snoozeBtn->hide(); | 311 | dailyAmPm->hide(); |
197 | } | 312 | } |
313 | dailyHour->setValue( h ); | ||
314 | |||
315 | connect( ((MySpinBox*)dailyHour)->lineEdit(), SIGNAL(textChanged(const QString&)), | ||
316 | this, SLOT(dailyEdited()) ); | ||
317 | connect( ((MySpinBox*)dailyMinute)->lineEdit(), SIGNAL(textChanged(const QString&)), | ||
318 | this, SLOT(dailyEdited()) ); | ||
319 | |||
320 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | ||
321 | connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), | ||
322 | this, SLOT(appMessage(const QCString&,const QByteArray&)) ); | ||
323 | #endif | ||
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 | { | ||
217 | QTime tm = QDateTime::currentDateTime().time(); | 340 | QTime tm = QDateTime::currentDateTime().time(); |
218 | QString s; | 341 | QString s; |
219 | if ( ampm ) | 342 | if ( ampm ) { |
220 | { | ||
221 | int hour = tm.hour(); | 343 | int hour = tm.hour(); |
222 | if ( hour == 0 ) | 344 | if ( hour == 0 ) |
223 | hour = 12; | 345 | hour = 12; |
224 | if ( hour > 12 ) | 346 | if ( hour > 12 ) |
225 | hour -= 12; | 347 | hour -= 12; |
226 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); | 348 | s.sprintf( "%2d%c%02d", hour, ':', tm.minute() ); |
227 | ampmLabel->setText( ( tm.hour() >= 12 ) ? "PM" : "AM" ); | 349 | clockAmPm->setText( (tm.hour() >= 12) ? "PM" : "AM" ); |
228 | ampmLabel->show(); | 350 | clockAmPm->show(); |
229 | } | 351 | } else { |
230 | else | ||
231 | { | ||
232 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); | 352 | s.sprintf( "%2d%c%02d", tm.hour(), ':', tm.minute() ); |
233 | ampmLabel->hide(); | 353 | clockAmPm->hide(); |
234 | } | ||
235 | lcd->display( s ); | ||
236 | lcd->repaint( FALSE ); | ||
237 | aclock->display( QTime::currentTime() ); | ||
238 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | ||
239 | } | 354 | } |
240 | else | 355 | clockLcd->display( s ); |
241 | { | 356 | clockLcd->repaint( FALSE ); |
242 | QTime swatch_time; | 357 | analogClock->display( QTime::currentTime() ); |
243 | QString lcdtext; | 358 | date->setText( TimeString::dateString( QDate::currentDate(), TimeString::currentDateFormat() ) ); |
359 | } else if ( tabs->currentPageIndex() == 1 ) { | ||
244 | int totalms = swatch_totalms; | 360 | int totalms = swatch_totalms; |
245 | if ( swatch_running ) | 361 | if ( swatch_running ) |
246 | totalms += swatch_start.elapsed(); | 362 | totalms += swatch_start.elapsed(); |
247 | swatch_time = QTime( 0, 0, 0 ).addMSecs( totalms ); | 363 | setSwatchLcd( stopwatchLcd, totalms, !swatch_running ); |
248 | QString d = swatch_running ? QString( " " ) | 364 | QTime swatch_time = QTime(0,0,0).addMSecs(totalms); |
249 | : QString::number( totalms % 1000 + 1000 ); | 365 | analogStopwatch->display( swatch_time ); |
250 | lcdtext = swatch_time.toString() + "." + d.right( 3 ).left( sw_prec ); | 366 | if ( swatch_dispLap == swatch_currLap ) { |
251 | lcd->display( lcdtext ); | 367 | swatch_splitms[swatch_currLap] = swatch_totalms; |
252 | lcd->repaint( FALSE ); | 368 | if ( swatch_running ) |
253 | aclock->display( swatch_time ); | 369 | swatch_splitms[swatch_currLap] += swatch_start.elapsed(); |
254 | date->setText( TimeString::longDateString( QDate::currentDate() ) ); | 370 | updateLap(); |
371 | } | ||
372 | } else if ( tabs->currentPageIndex() == 2 ) { | ||
373 | // nothing. | ||
255 | } | 374 | } |
256 | } | 375 | } |
257 | 376 | ||
258 | void Clock::changeClock( bool a ) | 377 | void Clock::changeClock( bool a ) |
259 | { | 378 | { |
379 | if ( ampm != a ) { | ||
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 | } | ||
260 | ampm = a; | 403 | ampm = a; |
261 | updateClock(); | 404 | updateClock(); |
262 | } | 405 | } |
263 | 406 | ||
264 | void Clock::clearClock( void ) | 407 | void Clock::stopStartStopWatch() |
265 | { | ||
266 | lcd->display( QTime( 0, 0, 0 ).toString() ); | ||
267 | aclock->display( QTime( 0, 0, 0 ) ); | ||
268 | } | ||
269 | |||
270 | void Clock::startSWatch() | ||
271 | { | 408 | { |
272 | if(swatch_running) { | 409 | if(swatch_running) { |
273 | stopSWatch(); | 410 | swatch_totalms += swatch_start.elapsed(); |
274 | return; | 411 | swatch_splitms[swatch_currLap] = swatch_totalms; |
275 | } | 412 | stopStart->setText( tr("Start") ); |
276 | qDebug("startSWatch()"); | 413 | reset->setText( tr("Reset") ); |
414 | reset->setEnabled( TRUE ); | ||
415 | t->stop(); | ||
416 | swatch_running = FALSE; | ||
417 | toggleScreenSaver( TRUE ); | ||
418 | updateClock(); | ||
419 | } else { | ||
277 | swatch_start.start(); | 420 | swatch_start.start(); |
278 | set->setText( tr( "Stop" ) ); | 421 | stopStart->setText( tr("Stop") ); |
422 | reset->setText( tr("Lap/Split") ); | ||
423 | reset->setEnabled( swatch_currLap < 98 ); | ||
279 | t->start( 1000 ); | 424 | t->start( 1000 ); |
280 | swatch_running = TRUE; | 425 | swatch_running = TRUE; |
281 | // disable screensaver while stop watch is running | 426 | // disable screensaver while stop watch is running |
282 | toggleScreenSaver( FALSE ); | 427 | toggleScreenSaver( FALSE ); |
283 | } | 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 ); | ||
434 | } | ||
284 | 435 | ||
285 | void Clock::stopSWatch() | 436 | void Clock::resetStopWatch() |
286 | { | 437 | { |
287 | qDebug("stopSWatch()"); | 438 | if ( swatch_running ) { |
288 | swatch_totalms += swatch_start.elapsed(); | 439 | swatch_splitms[swatch_currLap] = swatch_totalms+swatch_start.elapsed(); |
289 | set->setText( tr( "Start" ) ); | 440 | swatch_dispLap = swatch_currLap; |
290 | t->stop(); | 441 | if ( swatch_currLap < 98 ) // allow up to 99 laps |
291 | swatch_running = FALSE; | 442 | swatch_currLap++; |
292 | toggleScreenSaver( TRUE ); | 443 | reset->setEnabled( swatch_currLap < 98 ); |
444 | updateLap(); | ||
445 | lapTimer->start( 2000, TRUE ); | ||
446 | } else { | ||
447 | swatch_start.start(); | ||
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(); | ||
293 | updateClock(); | 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 ); | ||
294 | } | 460 | } |
295 | 461 | ||
296 | 462 | void Clock::prevLap() | |
297 | void Clock::slotSet() | ||
298 | { | ||
299 | if ( t->isActive() ) | ||
300 | { | 463 | { |
301 | startSWatch(); | 464 | if ( swatch_dispLap > 0 ) { |
465 | swatch_dispLap--; | ||
466 | updateLap(); | ||
467 | prevLapBtn->setEnabled( swatch_dispLap ); | ||
468 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); | ||
302 | } | 469 | } |
303 | else | 470 | } |
471 | |||
472 | void Clock::nextLap() | ||
304 | { | 473 | { |
305 | stopSWatch(); | 474 | if ( swatch_dispLap < swatch_currLap ) { |
475 | swatch_dispLap++; | ||
476 | updateLap(); | ||
477 | prevLapBtn->setEnabled( swatch_dispLap ); | ||
478 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); | ||
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 ); |
487 | nextLapBtn->setEnabled( swatch_dispLap < swatch_currLap ); | ||
488 | } | ||
314 | 489 | ||
315 | if ( swatch_running ) | 490 | void Clock::updateLap() |
316 | t->start( 1000 ); | 491 | { |
492 | if ( swatch_running && swatch_currLap == swatch_dispLap ) { | ||
493 | swatch_splitms[swatch_currLap] = swatch_totalms; | ||
494 | swatch_splitms[swatch_currLap] += swatch_start.elapsed(); | ||
495 | } | ||
496 | int split = swatch_splitms[swatch_dispLap]; | ||
497 | int lap; | ||
498 | if ( swatch_dispLap > 0 ) | ||
499 | lap = swatch_splitms[swatch_dispLap] - swatch_splitms[swatch_dispLap-1]; | ||
500 | else | ||
501 | lap = swatch_splitms[swatch_dispLap]; | ||
317 | 502 | ||
318 | updateClock(); | 503 | lapNumLcd->display( swatch_dispLap+1 ); |
504 | bool showMs = !swatch_running || swatch_dispLap!=swatch_currLap; | ||
505 | setSwatchLcd( lapLcd, lap, showMs ); | ||
506 | setSwatchLcd( splitLcd, split, showMs ); | ||
319 | } | 507 | } |
320 | 508 | ||
321 | void Clock::modeSelect( int m ) | 509 | void Clock::setSwatchLcd( QLCDNumber *lcd, int ms, bool showMs ) |
322 | { | 510 | { |
323 | qDebug("Clock::modeSelect( %d) ", m); | 511 | QTime swatch_time = QTime(0,0,0).addMSecs(ms); |
324 | if ( m != 0 ) | 512 | QString d = showMs ? QString::number(ms%1000+1000) : QString(" "); |
325 | { | 513 | QString lcdtext = swatch_time.toString() + "." + d.right(3).left(sw_prec); |
326 | lcd->setNumDigits( 8 + 1 + sw_prec ); | 514 | lcd->display( lcdtext ); |
327 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 515 | lcd->repaint( FALSE ); |
328 | set->setEnabled( TRUE ); | 516 | } |
329 | reset->setEnabled( TRUE ); | ||
330 | ampmLabel->hide(); | ||
331 | 517 | ||
332 | // if(m == 2) { | 518 | bool Clock::eventFilter( QObject *o, QEvent *e ) |
333 | if ( !swatch_running ) { | 519 | { |
334 | t->start( 1000 ); | 520 | if ( o == swFrame && e->type() == QEvent::Resize ) { |
521 | QResizeEvent *re = (QResizeEvent *)e; | ||
522 | delete swLayout; | ||
523 | if ( re->size().height() < 80 || re->size().height()*3 < re->size().width() ) | ||
524 | swLayout = new QHBoxLayout( swFrame ); | ||
525 | else | ||
526 | swLayout = new QVBoxLayout( swFrame ); | ||
527 | swLayout->addWidget( analogStopwatch ); | ||
528 | swLayout->addWidget( stopwatchLcd ); | ||
529 | swLayout->activate(); | ||
335 | } | 530 | } |
336 | // else | 531 | |
337 | // { | 532 | return FALSE; |
338 | // stopSWatch(); | ||
339 | // } | ||
340 | // } | ||
341 | } | 533 | } |
342 | else //clock mode | 534 | |
535 | void Clock::tabChanged( QWidget * ) | ||
343 | { | 536 | { |
344 | lcd->setNumDigits( 5 ); | 537 | if ( tabs->currentPageIndex() == 0 ) { |
345 | lcd->setMinimumWidth( lcd->sizeHint().width() ); | 538 | t->start(1000); |
346 | set->setEnabled( FALSE ); | 539 | } else if ( tabs->currentPageIndex() == 1 ) { |
347 | reset->setEnabled( FALSE ); | 540 | if ( !swatch_running ) |
541 | t->stop(); | ||
542 | stopStart->setAccel( Key_Return ); | ||
543 | } else if ( tabs->currentPageIndex() == 2 ) { | ||
348 | t->start( 1000 ); | 544 | t->start( 1000 ); |
349 | } | 545 | } |
350 | |||
351 | Config config( "Clock" ); | ||
352 | config.setGroup( "Mode" ); | ||
353 | config.writeEntry( "clockMode", m ); | ||
354 | updateClock(); | 546 | updateClock(); |
355 | } | 547 | } |
356 | 548 | ||
357 | //this sets the alarm time | 549 | void Clock::setDailyAmPm(int) |
358 | void Clock::slotSetAlarm() | ||
359 | { | 550 | { |
360 | if ( !snoozeBtn->isHidden() ) | 551 | scheduleApplyDailyAlarm(); |
361 | slotToggleAlarm(); | ||
362 | Set_Alarm *setAlarmDlg; | ||
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 | } | ||
379 | config.writeEntry( "clockAlarmHour", tmp.setNum( hour ), 10 ); | ||
380 | config.writeEntry( "clockAlarmMinute", tmp.setNum( minute ), 10 ); | ||
381 | config.writeEntry( "clockAlarmSnooze", tmp.setNum( snoozeTime ), 10 ); | ||
382 | config.write(); | ||
383 | } | ||
384 | } | 552 | } |
385 | 553 | ||
386 | void Clock::slotSnooze() | 554 | void Clock::setDailyMinute( int m ) |
387 | { | 555 | { |
388 | bSound = FALSE; | 556 | dailyMinute->setPrefix( m <= 9 ? "0" : "" ); |
389 | int warn = 0; | ||
390 | QTime t = QTime::currentTime(); | ||
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 | } | 557 | } |
398 | 558 | ||
399 | //toggles alarm on/off | 559 | void Clock::dailyEdited() |
400 | void Clock::slotToggleAlarm() | ||
401 | { | 560 | { |
402 | Config config( "qpe" ); | 561 | if ( spinBoxValid(dailyMinute) && spinBoxValid(dailyHour) ) |
403 | config.setGroup( "Time" ); | 562 | scheduleApplyDailyAlarm(); |
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 | 563 | else |
413 | { | 564 | applyAlarmTimer->stop(); |
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 | } | 565 | } |
451 | 566 | ||
452 | void Clock::clearTimer() | 567 | void Clock::enableDaily( bool ) |
453 | { | 568 | { |
454 | alarmOffBtn->setText( tr( "Alarm Is Off" ) ); | 569 | scheduleApplyDailyAlarm(); |
455 | alarmBool = FALSE; | ||
456 | snoozeBtn->hide(); | ||
457 | setCaption( tr("Clock") ); | ||
458 | } | 570 | } |
459 | 571 | ||
460 | void Clock::appMessage( const QCString& msg, const QByteArray& /*data*/ ) | 572 | 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 | { | 573 | { |
468 | Config config( "qpe" ); | 574 | if ( msg == "alarm(QDateTime,int)" ) { |
469 | config.setGroup( "Time" ); | 575 | QDataStream ds(data,IO_ReadOnly); |
470 | if ( config.readBoolEntry( "mp3Alarm", 0 ) ) | 576 | QDateTime when; |
471 | { | 577 | int t; |
472 | clearTimer(); | 578 | ds >> when >> t; |
473 | pthread_t thread; | 579 | QTime theTime( when.time() ); |
474 | pthread_create(&thread, NULL, (void * (*) (void *))startPlayer, NULL/* &*/); | 580 | if ( t == magic_daily || t == magic_snooze || |
475 | 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; | ||
476 | } | 590 | } |
477 | else | 591 | if (h == 0) h = 12; |
478 | { | 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; | ||
479 | 597 | ||
598 | if (t == magic_playmp ) { | ||
599 | pthread_t thread; | ||
600 | pthread_create(&thread,NULL, (void * (*) (void *))startPlayer, NULL/* &*/ ); | ||
601 | }else { | ||
480 | Sound::soundAlarm(); | 602 | Sound::soundAlarm(); |
481 | stopTimer = startTimer( timerStay ); | 603 | alarmCount = 0; |
604 | alarmt->start( 5000 ); | ||
482 | } | 605 | } |
606 | if ( !alarmDlg ) { | ||
607 | alarmDlg = new AlarmDlg(this); | ||
483 | } | 608 | } |
609 | alarmDlg->setText(msg); | ||
484 | 610 | ||
485 | if ( msg == "timerStart()" ) | 611 | // Set for tomorrow, so user wakes up every day, even if they |
486 | { | 612 | // don't confirm the dialog. Don't set it again when snoozing. |
487 | slotStartTimer(); | 613 | if (t != magic_snooze) { |
614 | applyDailyAlarm(); | ||
488 | } | 615 | } |
489 | if ( msg == "timerStop()" ) | 616 | |
490 | { | 617 | |
491 | slotStopTimer(); | 618 | if ( !alarmDlg->isVisible() ) { |
619 | QPEApplication::execDialog(alarmDlg); | ||
620 | alarmt->stop(); | ||
492 | } | 621 | } |
493 | if ( msg == "timerReset()" ) | 622 | } else if ( t == magic_countdown ) { |
494 | { | 623 | // countdown |
495 | slotResetTimer(); | 624 | Sound::soundAlarm(); |
496 | } | 625 | } |
497 | 626 | } else if ( msg == "setDailyEnabled(int)" ) { | |
498 | show(); | 627 | QDataStream ds(data,IO_ReadOnly); |
499 | raise(); | 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); | ||
500 | QPEApplication::setKeepRunning(); | 637 | QPEApplication::setKeepRunning(); |
501 | setActiveWindow(); | 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(); | ||
652 | } | ||
502 | } | 653 | } |
503 | 654 | ||
504 | void Clock::timerEvent( QTimerEvent *e ) | 655 | void Clock::alarmTimeout() |
505 | { | ||
506 | static int stop = 0; | ||
507 | if ( stop < 120 && bSound ) | ||
508 | { | 656 | { |
657 | if ( alarmCount < 10 ) { | ||
509 | Sound::soundAlarm(); | 658 | Sound::soundAlarm(); |
510 | stop++; | 659 | alarmCount++; |
511 | } | 660 | } else { |
512 | else | 661 | alarmCount = 0; |
513 | { | 662 | alarmt->stop(); |
514 | stop = 0; | ||
515 | killTimer( e->timerId() ); | ||
516 | clearTimer(); | ||
517 | setCaption( tr( "Clock: Alarm was missed." ) ); | ||
518 | } | 663 | } |
519 | } | 664 | } |
520 | 665 | ||
521 | AnalogClock::AnalogClock(QWidget * parent, const char * name) : QFrame( parent, name ), clear(true) | 666 | QDateTime Clock::nextAlarm( int h, int m ) |
522 | { | 667 | { |
523 | QWidget *d = QApplication::desktop(); | 668 | QDateTime now = QDateTime::currentDateTime(); |
524 | if(d->width() <= 240) | 669 | QTime at( h, m ); |
525 | bg = Resource::loadPixmap("clock/bg"); | 670 | QDateTime when( now.date(), at ); |
671 | int count = 0; | ||
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(); | ||
526 | } | 678 | } |
527 | 679 | ||
528 | QSizePolicy AnalogClock::sizePolicy() const | 680 | return when; |
529 | { | ||
530 | return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); | ||
531 | } | 681 | } |
532 | 682 | ||
533 | void AnalogClock::drawContents( QPainter *p ) | 683 | int Clock::dayBtnIdx( int d ) const |
534 | { | 684 | { |
535 | QRect r = contentsRect(); | 685 | if ( onMonday ) |
536 | QRect fr; | 686 | return d-1; |
537 | 687 | else if ( d == 7 ) | |
538 | p->drawPixmap(QPoint(0, 0), bg, r); | 688 | return 0; |
539 | |||
540 | if ( r. width ( ) > r. height ( )) | ||
541 | fr. setRect (( r. width ( ) - r. height ( )) / 2, r. y ( ), r. height ( ), r. height ( )); | ||
542 | else | 689 | else |
543 | fr. setRect ( r. x ( ), ( r. height ( ) - r. width ( )) / 2, r. width ( ), r. width ( )); | 690 | return d; |
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 | |||
551 | if ( clear ) | ||
552 | { | ||
553 | erase ( r ); | ||
554 | p-> setPen ( NoPen ); | ||
555 | p-> setBrush ( colorGroup ( ). color ( QColorGroup::Base )); | ||
556 | p-> drawEllipse ( fr ); | ||
557 | p-> setBrush ( NoBrush ); | ||
558 | |||
559 | // draw ticks | ||
560 | p->setPen( QPen( colorGroup ( ). color ( QColorGroup::Text ), 1 ) ); | ||
561 | for ( int i = 0; i < 12; i++ ) | ||
562 | p->drawLine( rotate( center, l1, i * 30 ), rotate( center, l2, i * 30 ) ); | ||
563 | } | 691 | } |
564 | else | ||
565 | { | ||
566 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Base ), prevTime, &currTime ); | ||
567 | } | ||
568 | |||
569 | drawPointers ( p, fr, colorGroup ( ). color ( QColorGroup::Text ), currTime ); | ||
570 | 692 | ||
571 | prevTime = currTime; | 693 | void Clock::scheduleApplyDailyAlarm() |
694 | { | ||
695 | applyAlarmTimer->start( 5000, TRUE ); | ||
572 | } | 696 | } |
573 | 697 | ||
574 | void AnalogClock::drawPointers ( QPainter *p, const QRect &r, const QColor &c, const QTime &t, const QTime *t2 ) | 698 | void Clock::applyDailyAlarm() |
575 | { | 699 | { |
576 | QPoint center = r. center ( ); | 700 | if ( !init ) |
577 | 701 | return; | |
578 | QPoint h1( center. x ( ), r. y ( ) + r. height ( ) / 4 ); | ||
579 | QPoint h2( center. x ( ), center. y ( ) ); | ||
580 | 702 | ||
581 | QPoint m1( center. x ( ), r.y() + r.height() / 8 ); | 703 | applyAlarmTimer->stop(); |
582 | QPoint m2( center. x ( ), center. y ( ) ); | 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 | } | ||
583 | 712 | ||
584 | QPoint s1( center. x ( ), r. y ( ) + 8 ); | 713 | Config config( "Clock" ); |
585 | QPoint s2( center. x ( ), center. y ( ) ); | 714 | config.setGroup( "Daily Alarm" ); |
715 | config.writeEntry( "Hour", hour ); | ||
716 | config.writeEntry( "Minute", minute ); | ||
586 | 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 ); | ||
587 | 725 | ||
588 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ) || t. hour ( ) != t2-> hour ( ))) { | 726 | QString exclDays; |
589 | // draw hour pointer | 727 | int exclCount = 0; |
590 | h1 = rotate( center, h1, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); | 728 | for ( int i = 1; i <= 7; i++ ) { |
591 | h2 = rotate( center, h2, 30 * ( t.hour() % 12 ) + t.minute() / 2 ); | 729 | if ( !dayBtn[dayBtnIdx(i)]->isOn() ) { |
592 | p-> setPen ( QPen ( c, 3 )); | 730 | if ( !exclDays.isEmpty() ) |
593 | p-> drawLine ( h1, h2 ); | 731 | exclDays += ","; |
732 | exclDays += QString::number( i ); | ||
733 | exclCount++; | ||
594 | } | 734 | } |
595 | |||
596 | if ( !t2 || ( t. minute ( ) != t2-> minute ( ))) { | ||
597 | // draw minute pointer | ||
598 | m1 = rotate( center, m1, t.minute() * 6 ); | ||
599 | m2 = rotate( center, m2, t.minute() * 6 ); | ||
600 | p-> setPen ( QPen ( c, 2 )); | ||
601 | p-> drawLine ( m1, m2 ); | ||
602 | } | 735 | } |
736 | config.writeEntry( "ExcludeDays", exclDays ); | ||
603 | 737 | ||
604 | if ( !t2 || ( t. second ( ) != t2-> second ( ))) { | 738 | /* try to delete both */ |
605 | // draw second pointer | 739 | AlarmServer::deleteAlarm(QDateTime(), "QPE/Application/clock", |
606 | s1 = rotate( center, s1, t.second() * 6 ); | 740 | "alarm(QDateTime,int)", oldMagic); |
607 | s2 = rotate( center, s2, t.second() * 6 ); | 741 | if ( enableDaily && exclCount < 7 ) { |
608 | p-> setPen ( QPen ( c, 1 )); | 742 | QDateTime when = nextAlarm( hour, minute ); |
609 | p-> drawLine ( s1, s2 ); | 743 | AlarmServer::addAlarm(when, "QPE/Application/clock", |
744 | "alarm(QDateTime,int)", isMagic); | ||
610 | } | 745 | } |
611 | } | 746 | } |
612 | 747 | ||
613 | void AnalogClock::display( const QTime& t ) | 748 | bool Clock::validDaysSelected(void) |
614 | { | 749 | { |
615 | currTime = t; | 750 | for ( int i = 1; i <= 7; i++ ) { |
616 | clear = false; | 751 | if ( dayBtn[dayBtnIdx(i)]->isOn() ) { |
617 | repaint( false ); | 752 | return TRUE; |
618 | clear = true; | ||
619 | } | 753 | } |
620 | 754 | } | |
621 | QPoint AnalogClock::rotate( QPoint c, QPoint p, int a ) | 755 | return FALSE; |
622 | { | ||
623 | double angle = deg2rad * ( - a + 180 ); | ||
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 | } | 756 | } |
630 | 757 | ||
631 | void Clock::slotAdjustTime() | 758 | void Clock::closeEvent( QCloseEvent *e ) |
632 | { | 759 | { |
633 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 760 | if (dailyEnabled->isChecked()) { |
634 | e << QString( "systemtime" ); | 761 | if (!validDaysSelected()) { |
762 | QMessageBox::warning(this, tr("Select Day"), | ||
763 | tr("Daily alarm requires at least\none day to be selected.")); | ||
764 | return; | ||
765 | } | ||
635 | } | 766 | } |
636 | 767 | ||
637 | void Clock::slotStartTimer() | 768 | applyDailyAlarm(); |
638 | { | 769 | ClockBase::closeEvent(e); |
639 | if ( clockRB->isChecked() ) | ||
640 | setSwatchMode( 1); | ||
641 | startSWatch(); | ||
642 | } | 770 | } |
643 | 771 | ||
644 | void Clock::slotStopTimer() | 772 | bool Clock::spinBoxValid( QSpinBox *sb ) |
645 | { | 773 | { |
646 | if ( clockRB->isChecked() ) | 774 | bool valid = TRUE; |
647 | setSwatchMode( 1); | 775 | QString tv = sb->text(); |
648 | stopSWatch(); | 776 | for ( uint i = 0; i < tv.length(); i++ ) { |
777 | if ( !tv[0].isDigit() ) | ||
778 | valid = FALSE; | ||
649 | } | 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; | ||
650 | 786 | ||
651 | void Clock::slotResetTimer() | 787 | return valid; |
652 | { | ||
653 | if ( clockRB->isChecked() ) | ||
654 | setSwatchMode( 1); | ||
655 | slotReset(); | ||
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,10 +1,10 @@ | |||
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 |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
@@ -17,96 +17,100 @@ | |||
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
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; |
70 | int hour, minute, snoozeTime; | 59 | int hour, minute, snoozeTime; |
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 |
112 | 116 | ||
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 | |||
@@ -8,14 +8,14 @@ | |||
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
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"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Clock</string> | 20 | <string>Clock</string> |
21 | </property> | 21 | </property> |
@@ -513,17 +513,17 @@ | |||
513 | <name>title</name> | 513 | <name>title</name> |
514 | <string>Alarm</string> | 514 | <string>Alarm</string> |
515 | </attribute> | 515 | </attribute> |
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> |
527 | <property stdset="1"> | 527 | <property stdset="1"> |
528 | <name>name</name> | 528 | <name>name</name> |
529 | <cstring>dailyGroup</cstring> | 529 | <cstring>dailyGroup</cstring> |
@@ -867,16 +867,83 @@ | |||
867 | <name>segmentStyle</name> | 867 | <name>segmentStyle</name> |
868 | <enum>Flat</enum> | 868 | <enum>Flat</enum> |
869 | </property> | 869 | </property> |
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> |
880 | <enum>Vertical</enum> | 947 | <enum>Vertical</enum> |
881 | </property> | 948 | </property> |
882 | <property stdset="1"> | 949 | <property stdset="1"> |
@@ -915,7 +982,41 @@ | |||
915 | <images> | 982 | <images> |
916 | <image> | 983 | <image> |
917 | <name>image0</name> | 984 | <name>image0</name> |
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,10 +1,10 @@ | |||
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 |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
@@ -16,13 +16,9 @@ | |||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
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> ) |