-rw-r--r-- | noncore/settings/netsystemtime/settime.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/noncore/settings/netsystemtime/settime.cpp b/noncore/settings/netsystemtime/settime.cpp index e3b2ddd..d1dc5b8 100644 --- a/noncore/settings/netsystemtime/settime.cpp +++ b/noncore/settings/netsystemtime/settime.cpp | |||
@@ -175,223 +175,223 @@ SetDateTime::SetDateTime(QWidget *parent, const char *name, WFlags f ) | |||
175 | hb4->addWidget( l, 1 ); | 175 | hb4->addWidget( l, 1 ); |
176 | 176 | ||
177 | clockAppletCombo = new QComboBox( FrameSystemTime ); | 177 | clockAppletCombo = new QComboBox( FrameSystemTime ); |
178 | clockAppletCombo->insertItem( tr("hh:mm"), 0 ); | 178 | clockAppletCombo->insertItem( tr("hh:mm"), 0 ); |
179 | clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); | 179 | clockAppletCombo->insertItem( tr("D/M hh:mm"), 1 ); |
180 | clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); | 180 | clockAppletCombo->insertItem( tr("M/D hh:mm"), 2 ); |
181 | 181 | ||
182 | hb4->addWidget( clockAppletCombo, 2 ); | 182 | hb4->addWidget( clockAppletCombo, 2 ); |
183 | int clockApplet = config.readNumEntry("ClockApplet",0); | 183 | int clockApplet = config.readNumEntry("ClockApplet",0); |
184 | clockAppletCombo->setCurrentItem( clockApplet ); | 184 | clockAppletCombo->setCurrentItem( clockApplet ); |
185 | 185 | ||
186 | vb->addStretch( 0 ); | 186 | vb->addStretch( 0 ); |
187 | 187 | ||
188 | QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), | 188 | QObject::connect( PushButtonSetManualTime, SIGNAL(clicked()), |
189 | this, SLOT(commitTime())); | 189 | this, SLOT(commitTime())); |
190 | 190 | ||
191 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 191 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
192 | timeButton, SLOT( slotTzChange( const QString& ) ) ); | 192 | timeButton, SLOT( slotTzChange( const QString& ) ) ); |
193 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), | 193 | QObject::connect( tz, SIGNAL( signalNewTz( const QString& ) ), |
194 | SLOT( tzChange( const QString& ) ) ); | 194 | SLOT( tzChange( const QString& ) ) ); |
195 | 195 | ||
196 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), | 196 | QObject::connect( weekStartCombo, SIGNAL( activated ( int )), |
197 | SLOT(updateSystem(int ) )); | 197 | SLOT(updateSystem(int ) )); |
198 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), | 198 | QObject::connect( ampmCombo, SIGNAL( activated ( int )), |
199 | SLOT(updateSystem(int ) )); | 199 | SLOT(updateSystem(int ) )); |
200 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), | 200 | QObject::connect( dateFormatCombo, SIGNAL( activated ( int )), |
201 | SLOT(updateSystem(int ) )); | 201 | SLOT(updateSystem(int ) )); |
202 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), | 202 | QObject::connect( clockAppletCombo, SIGNAL( activated ( int )), |
203 | SLOT(updateSystem(int ) )); | 203 | SLOT(updateSystem(int ) )); |
204 | } | 204 | } |
205 | 205 | ||
206 | SetDateTime::~SetDateTime() | 206 | SetDateTime::~SetDateTime() |
207 | { | 207 | { |
208 | writeSettings(); | 208 | writeSettings(); |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | void SetDateTime::writeSettings() | 212 | void SetDateTime::writeSettings() |
213 | { | 213 | { |
214 | Config config("qpe"); | 214 | Config config("qpe"); |
215 | config.setGroup( "Time" ); | 215 | config.setGroup( "Time" ); |
216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); | 216 | config.writeEntry( "AMPM", ampmCombo->currentItem() ); |
217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); | 217 | config.writeEntry( "MONDAY", weekStartCombo->currentItem() ); |
218 | config.setGroup( "Date" ); | 218 | config.setGroup( "Date" ); |
219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; | 219 | DateFormat df = date_formats[dateFormatCombo->currentItem()]; |
220 | config.writeEntry( "Separator", QString(df.separator())); | 220 | config.writeEntry( "Separator", QString(df.separator())); |
221 | config.writeEntry( "ShortOrder", df.shortOrder()); | 221 | config.writeEntry( "ShortOrder", df.shortOrder()); |
222 | config.writeEntry( "LongOrder", df.longOrder()); | 222 | config.writeEntry( "LongOrder", df.longOrder()); |
223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); | 223 | config.writeEntry( "ClockApplet", clockAppletCombo->currentItem() ); |
224 | 224 | ||
225 | Config lconfig("locale"); | 225 | Config lconfig("locale"); |
226 | lconfig.setGroup( "Location" ); | 226 | lconfig.setGroup( "Location" ); |
227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); | 227 | lconfig.writeEntry( "Timezone", tz->currentZone() ); |
228 | 228 | ||
229 | } | 229 | } |
230 | 230 | ||
231 | void SetDateTime::commitTime() | 231 | void SetDateTime::commitTime() |
232 | { | 232 | { |
233 | Config cfg("ntp",Config::User); | 233 | Config cfg("ntp",Config::User); |
234 | cfg.setGroup("lookups"); | 234 | cfg.setGroup("lookups"); |
235 | cfg.writeEntry("lastNtp",false); | 235 | cfg.writeEntry("lastNtp",false); |
236 | tz->setFocus(); | 236 | tz->setFocus(); |
237 | // Need to process the QCOP event generated above before proceeding | 237 | // Need to process the QCOP event generated above before proceeding |
238 | qApp->processEvents(); | 238 | qApp->processEvents(); |
239 | 239 | ||
240 | // before we progress further, set our TZ! | 240 | // before we progress further, set our TZ! |
241 | setenv( "TZ", tz->currentZone(), 1 ); | 241 | setenv( "TZ", tz->currentZone(), 1 ); |
242 | // now set the time... | 242 | // now set the time... |
243 | QDateTime dt( dateButton->date(), timeButton->time() ); | 243 | QDateTime dt( dateButton->date(), timeButton->time() ); |
244 | 244 | ||
245 | if ( dt.isValid() ) setTime(dt); | 245 | if ( dt.isValid() ) setTime(dt); |
246 | } | 246 | } |
247 | 247 | ||
248 | void SetDateTime::setTime(QDateTime dt) | 248 | void SetDateTime::setTime(QDateTime dt) |
249 | { | 249 | { |
250 | // really turn off the screensaver before doing anything | 250 | // really turn off the screensaver before doing anything |
251 | { | 251 | { |
252 | // Needs to be encased in { } so that it deconstructs and sends | 252 | // Needs to be encased in { } so that it deconstructs and sends |
253 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 253 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
254 | disableScreenSaver << 0 << 0 << 0; | 254 | disableScreenSaver << 0 << 0 << 0; |
255 | } | 255 | } |
256 | Config cfg("ntp",Config::User); | 256 | Config cfg("ntp",Config::User); |
257 | cfg.setGroup("correction"); | 257 | cfg.setGroup("correction"); |
258 | int t = TimeConversion::toUTC(dt); | 258 | int t = TimeConversion::toUTC(dt); |
259 | struct timeval myTv; | 259 | struct timeval myTv; |
260 | myTv.tv_sec = t; | 260 | myTv.tv_sec = t; |
261 | cfg.writeEntry("time", t ); | 261 | cfg.writeEntry("time", t ); |
262 | myTv.tv_usec = 0; | 262 | myTv.tv_usec = 0; |
263 | 263 | ||
264 | if ( myTv.tv_sec != -1 ) | 264 | if ( myTv.tv_sec != -1 ) |
265 | ::settimeofday( &myTv, 0 ); | 265 | ::settimeofday( &myTv, 0 ); |
266 | Global::writeHWClock(); | 266 | Global::writeHWClock(); |
267 | // since time has changed quickly load in the datebookdb | 267 | // since time has changed quickly load in the datebookdb |
268 | // to allow the alarm server to get a better grip on itself | 268 | // to allow the alarm server to get a better grip on itself |
269 | // (example re-trigger alarms for when we travel back in time) | 269 | // (example re-trigger alarms for when we travel back in time) |
270 | DateBookDB db; | 270 | DateBookDB db; |
271 | QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); | 271 | //QCopEnvelope timeApplet( "QPE/TaskBar", "reloadApplets()" ); |
272 | timeApplet << ""; | 272 | //timeApplet << ""; |
273 | // Restore screensaver | 273 | // Restore screensaver |
274 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 274 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
275 | enableScreenSaver << -1 << -1 << -1; | 275 | enableScreenSaver << -1 << -1 << -1; |
276 | } | 276 | } |
277 | 277 | ||
278 | void SetDateTime::updateSystem(int i) | 278 | void SetDateTime::updateSystem(int i) |
279 | { | 279 | { |
280 | // really turn off the screensaver before doing anything | 280 | // really turn off the screensaver before doing anything |
281 | { | 281 | { |
282 | // Needs to be encased in { } so that it deconstructs and sends | 282 | // Needs to be encased in { } so that it deconstructs and sends |
283 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 283 | QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
284 | disableScreenSaver << 0 << 0 << 0; | 284 | disableScreenSaver << 0 << 0 << 0; |
285 | } | 285 | } |
286 | qDebug("SetDateTime::updateSystem(int %i)",i); | 286 | qDebug("SetDateTime::updateSystem(int %i)",i); |
287 | writeSettings(); | 287 | writeSettings(); |
288 | 288 | ||
289 | // set the timezone for everyone else... | 289 | // set the timezone for everyone else... |
290 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); | 290 | QCopEnvelope setTimeZone( "QPE/System", "timeChange(QString)" ); |
291 | setTimeZone << tz->currentZone(); | 291 | setTimeZone << tz->currentZone(); |
292 | 292 | ||
293 | // AM/PM setting and notify time changed | 293 | // AM/PM setting and notify time changed |
294 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); | 294 | QCopEnvelope setClock( "QPE/System", "clockChange(bool)" ); |
295 | setClock << ampmCombo->currentItem(); | 295 | setClock << ampmCombo->currentItem(); |
296 | 296 | ||
297 | // Notify everyone what day we prefer to start the week on. | 297 | // Notify everyone what day we prefer to start the week on. |
298 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); | 298 | QCopEnvelope setWeek( "QPE/System", "weekChange(bool)" ); |
299 | setWeek << weekStartCombo->currentItem(); | 299 | setWeek << weekStartCombo->currentItem(); |
300 | 300 | ||
301 | // Notify everyone what date format to use | 301 | // Notify everyone what date format to use |
302 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); | 302 | QCopEnvelope setDateFormat( "QPE/System", "setDateFormat(DateFormat)" ); |
303 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; | 303 | setDateFormat << date_formats[dateFormatCombo->currentItem()]; |
304 | 304 | ||
305 | // Restore screensaver | 305 | // Restore screensaver |
306 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); | 306 | QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); |
307 | enableScreenSaver << -1 << -1 << -1; | 307 | enableScreenSaver << -1 << -1 << -1; |
308 | // since time has changed quickly load in the datebookdb | 308 | // since time has changed quickly load in the datebookdb |
309 | // to allow the alarm server to get a better grip on itself | 309 | // to allow the alarm server to get a better grip on itself |
310 | // (example re-trigger alarms for when we travel back in time) | 310 | // (example re-trigger alarms for when we travel back in time) |
311 | DateBookDB db; | 311 | DateBookDB db; |
312 | 312 | ||
313 | } | 313 | } |
314 | 314 | ||
315 | void SetDateTime::tzChange( const QString &tz ) | 315 | void SetDateTime::tzChange( const QString &tz ) |
316 | { | 316 | { |
317 | // set the TZ get the time and leave gracefully... | 317 | // set the TZ get the time and leave gracefully... |
318 | QString strSave; | 318 | QString strSave; |
319 | strSave = getenv( "TZ" ); | 319 | strSave = getenv( "TZ" ); |
320 | setenv( "TZ", tz, 1 ); | 320 | setenv( "TZ", tz, 1 ); |
321 | 321 | ||
322 | QDate d = QDate::currentDate(); | 322 | QDate d = QDate::currentDate(); |
323 | // reset the time. | 323 | // reset the time. |
324 | if ( !strSave.isNull() ) { | 324 | if ( !strSave.isNull() ) { |
325 | setenv( "TZ", strSave, 1 ); | 325 | setenv( "TZ", strSave, 1 ); |
326 | } | 326 | } |
327 | dateButton->setDate( d ); | 327 | dateButton->setDate( d ); |
328 | updateSystem(); | 328 | updateSystem(); |
329 | } | 329 | } |
330 | 330 | ||
331 | void SetDateTime::formatChanged(int i) | 331 | void SetDateTime::formatChanged(int i) |
332 | { | 332 | { |
333 | dateButton->setDateFormat(date_formats[i]); | 333 | dateButton->setDateFormat(date_formats[i]); |
334 | } | 334 | } |
335 | 335 | ||
336 | static const int ValueAM = 0; | 336 | static const int ValueAM = 0; |
337 | static const int ValuePM = 1; | 337 | static const int ValuePM = 1; |
338 | 338 | ||
339 | 339 | ||
340 | 340 | ||
341 | SetTime::SetTime( QWidget *parent, const char *name ) | 341 | SetTime::SetTime( QWidget *parent, const char *name ) |
342 | : QWidget( parent, name ) | 342 | : QWidget( parent, name ) |
343 | { | 343 | { |
344 | use12hourTime = FALSE; | 344 | use12hourTime = FALSE; |
345 | 345 | ||
346 | QTime currTime = QTime::currentTime(); | 346 | QTime currTime = QTime::currentTime(); |
347 | hour = currTime.hour(); | 347 | hour = currTime.hour(); |
348 | minute = currTime.minute(); | 348 | minute = currTime.minute(); |
349 | 349 | ||
350 | QHBoxLayout *hb2 = new QHBoxLayout( this ); | 350 | QHBoxLayout *hb2 = new QHBoxLayout( this ); |
351 | hb2->setSpacing( 3 ); | 351 | hb2->setSpacing( 3 ); |
352 | 352 | ||
353 | QLabel *l = new QLabel( tr("Hour"), this ); | 353 | QLabel *l = new QLabel( tr("Hour"), this ); |
354 | // l->setAlignment( AlignRight | AlignVCenter ); | 354 | // l->setAlignment( AlignRight | AlignVCenter ); |
355 | hb2->addWidget( l ); | 355 | hb2->addWidget( l ); |
356 | 356 | ||
357 | sbHour = new QSpinBox( this ); | 357 | sbHour = new QSpinBox( this ); |
358 | sbHour->setMinimumWidth( 30 ); | 358 | sbHour->setMinimumWidth( 30 ); |
359 | if(use12hourTime) { | 359 | if(use12hourTime) { |
360 | sbHour->setMinValue(1); | 360 | sbHour->setMinValue(1); |
361 | sbHour->setMaxValue( 12 ); | 361 | sbHour->setMaxValue( 12 ); |
362 | int show_hour = hour; | 362 | int show_hour = hour; |
363 | if (hour > 12) | 363 | if (hour > 12) |
364 | show_hour -= 12; | 364 | show_hour -= 12; |
365 | if (show_hour == 0) | 365 | if (show_hour == 0) |
366 | show_hour = 12; | 366 | show_hour = 12; |
367 | 367 | ||
368 | sbHour->setValue( show_hour ); | 368 | sbHour->setValue( show_hour ); |
369 | } else { | 369 | } else { |
370 | sbHour->setMinValue( 0 ); | 370 | sbHour->setMinValue( 0 ); |
371 | sbHour->setMaxValue( 23 ); | 371 | sbHour->setMaxValue( 23 ); |
372 | sbHour->setValue( hour ); | 372 | sbHour->setValue( hour ); |
373 | } | 373 | } |
374 | sbHour->setWrapping(TRUE); | 374 | sbHour->setWrapping(TRUE); |
375 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); | 375 | connect( sbHour, SIGNAL(valueChanged(int)), this, SLOT(hourChanged(int)) ); |
376 | hb2->addWidget( sbHour ); | 376 | hb2->addWidget( sbHour ); |
377 | 377 | ||
378 | hb2->addStretch( 1 ); | 378 | hb2->addStretch( 1 ); |
379 | 379 | ||
380 | l = new QLabel( tr("Minute"), this ); | 380 | l = new QLabel( tr("Minute"), this ); |
381 | //l->setAlignment( AlignRight | AlignVCenter ); | 381 | //l->setAlignment( AlignRight | AlignVCenter ); |
382 | hb2->addWidget( l ); | 382 | hb2->addWidget( l ); |
383 | 383 | ||
384 | sbMin = new QSpinBox( this ); | 384 | sbMin = new QSpinBox( this ); |
385 | sbMin->setMinValue( 0 ); | 385 | sbMin->setMinValue( 0 ); |
386 | sbMin->setMaxValue( 59 ); | 386 | sbMin->setMaxValue( 59 ); |
387 | sbMin->setWrapping(TRUE); | 387 | sbMin->setWrapping(TRUE); |
388 | sbMin->setValue( minute ); | 388 | sbMin->setValue( minute ); |
389 | sbMin->setMinimumWidth( 30 ); | 389 | sbMin->setMinimumWidth( 30 ); |
390 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); | 390 | connect( sbMin, SIGNAL(valueChanged(int)), this, SLOT(minuteChanged(int)) ); |
391 | hb2->addWidget( sbMin ); | 391 | hb2->addWidget( sbMin ); |
392 | 392 | ||
393 | hb2->addStretch( 1 ); | 393 | hb2->addStretch( 1 ); |
394 | 394 | ||
395 | ampm = new QComboBox( this ); | 395 | ampm = new QComboBox( this ); |
396 | ampm->insertItem( tr("AM"), ValueAM ); | 396 | ampm->insertItem( tr("AM"), ValueAM ); |
397 | ampm->insertItem( tr("PM"), ValuePM ); | 397 | ampm->insertItem( tr("PM"), ValuePM ); |