summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index ab71463..85a46b7 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -140,64 +140,66 @@ void MainWindow::accept()
140 // grip on itself (example re-trigger alarms for when we travel back in time). 140 // grip on itself (example re-trigger alarms for when we travel back in time).
141 DateBookDB db; 141 DateBookDB db;
142 142
143 // Turn back on the screensaver 143 // Turn back on the screensaver
144 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 144 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
145 enableScreenSaver << -1 << -1 << -1; 145 enableScreenSaver << -1 << -1 << -1;
146 146
147 // Exit app 147 // Exit app
148 qApp->quit(); 148 qApp->quit();
149} 149}
150 150
151void MainWindow::reject() 151void MainWindow::reject()
152{ 152{
153 // Reset time settings 153 // Reset time settings
154 timeTab->saveSettings( FALSE ); 154 timeTab->saveSettings( FALSE );
155 155
156 // Send notifications but do not save settings 156 // Send notifications but do not save settings
157 formatTab->saveSettings( FALSE ); 157 formatTab->saveSettings( FALSE );
158 158
159 // Exit app 159 // Exit app
160 qApp->quit(); 160 qApp->quit();
161} 161}
162 162
163void MainWindow::runNTP() 163void MainWindow::runNTP()
164{ 164{
165 if ( !ntpDelayElapsed() && ntpInteractive ) 165 if ( !ntpDelayElapsed() && ntpInteractive )
166 { 166 {
167 QString msg = tr( "You asked for a delay of " ); 167 QString msg = tr( "You asked for a delay of " );
168 msg.append( QString::number( ntpDelay ) ); 168 msg.append( QString::number( ntpDelay ) );
169 msg.append( tr( " minutes, but only " ) ); 169 msg.append( tr( " minutes, but only " ) );
170 msg.append( QString::number( _lookupDiff / 60 ) ); 170 msg.append( QString::number( _lookupDiff / 60 ) );
171 msg.append( tr(" minutes elapsed since last lookup.<br>Continue?") ); 171 msg.append( tr(" minutes elapsed since last lookup.<br>Continue?") );
172
173 QString msg = tr( "You asked for a delay of %1 minutes, but only %2 minutes elapsed since last lookup.<br>Continue?" ).arg( QString::number( ntpDelay ) ).arg( QString::number( _lookupDiff / 60 ) );
172 174
173 switch ( 175 switch (
174 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) 176 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No )
175 ) 177 )
176 { 178 {
177 case QMessageBox::Yes: break; 179 case QMessageBox::Yes: break;
178 case QMessageBox::No: return; 180 case QMessageBox::No: return;
179 default: return; 181 default: return;
180 } 182 }
181 } 183 }
182 184
183 QString srv = settingsTab->ntpServer(); 185 QString srv = settingsTab->ntpServer();
184 186
185 // Send information to time server tab if enabled 187 // Send information to time server tab if enabled
186 if ( ntpTabEnabled ) 188 if ( ntpTabEnabled )
187 { 189 {
188 ntpTab->setStartTime( QDateTime::currentDateTime().toString() ); 190 ntpTab->setStartTime( QDateTime::currentDateTime().toString() );
189 QString output = tr( "Running:\nntpdate " ); 191 QString output = tr( "Running:\nntpdate " );
190 output.append( srv ); 192 output.append( srv );
191 ntpTab->addNtpOutput( output ); 193 ntpTab->addNtpOutput( output );
192 } 194 }
193 195
194 if ( !ntpProcess ) 196 if ( !ntpProcess )
195 { 197 {
196 ntpProcess = new OProcess(); 198 ntpProcess = new OProcess();
197 connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), 199 connect( ntpProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
198 this, SLOT(slotNtpOutput(OProcess*,char*,int)) ); 200 this, SLOT(slotNtpOutput(OProcess*,char*,int)) );
199 connect( ntpProcess, SIGNAL(processExited(OProcess*)), 201 connect( ntpProcess, SIGNAL(processExited(OProcess*)),
200 this, SLOT(slotNtpFinished(OProcess*)) ); 202 this, SLOT(slotNtpFinished(OProcess*)) );
201 } 203 }
202 204
203 else 205 else
@@ -312,66 +314,65 @@ void MainWindow::slotNtpFinished( OProcess *p )
312 QMessageBox::critical(this, tr( "Error" ), output ); 314 QMessageBox::critical(this, tr( "Error" ), output );
313 } 315 }
314 // slotCheckNtp(-1); 316 // slotCheckNtp(-1);
315 return; 317 return;
316 } 318 }
317 319
318 // Set controls on time tab to new time value 320 // Set controls on time tab to new time value
319 timeTab->setDateTime( dt ); 321 timeTab->setDateTime( dt );
320 322
321 // Write out lookup information 323 // Write out lookup information
322 Config config( "ntp" ); 324 Config config( "ntp" );
323 config.setGroup( "lookups" ); 325 config.setGroup( "lookups" );
324 int lastLookup = config.readNumEntry( "time", 0 ); 326 int lastLookup = config.readNumEntry( "time", 0 );
325 int lookupCount = config.readNumEntry( "count", 0 ); 327 int lookupCount = config.readNumEntry( "count", 0 );
326 bool lastNtp = config.readBoolEntry( "lastNtp", FALSE ); 328 bool lastNtp = config.readBoolEntry( "lastNtp", FALSE );
327 int time = TimeConversion::toUTC( QDateTime::currentDateTime() ); 329 int time = TimeConversion::toUTC( QDateTime::currentDateTime() );
328 config.writeEntry( "time", time ); 330 config.writeEntry( "time", time );
329 331
330 // Calculate new time/time shift 332 // Calculate new time/time shift
331 QString _offset = "offset"; 333 QString _offset = "offset";
332 QString _sec = "sec"; 334 QString _sec = "sec";
333 QRegExp _reOffset = QRegExp( _offset ); 335 QRegExp _reOffset = QRegExp( _offset );
334 QRegExp _reEndOffset = QRegExp( _sec ); 336 QRegExp _reEndOffset = QRegExp( _sec );
335 int posOffset = _reOffset.match( ntpOutput ); 337 int posOffset = _reOffset.match( ntpOutput );
336 int posEndOffset = _reEndOffset.match( ntpOutput, posOffset ); 338 int posEndOffset = _reEndOffset.match( ntpOutput, posOffset );
337 posOffset += _offset.length() + 1; 339 posOffset += _offset.length() + 1;
338 QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 ); 340 QString diff = ntpOutput.mid( posOffset, posEndOffset - posOffset - 1 );
339 341
340 float timeShift = diff.toFloat(); 342 float timeShift = diff.toFloat();
341 if ( timeShift == 0.0 ) 343 if ( timeShift == 0.0 )
342 return; 344 return;
343 int secsSinceLast = time - lastLookup; 345 int secsSinceLast = time - lastLookup;
344 output = QString::number( timeShift ); 346 output = tr( "%1 seconds").arg(QString::number( timeShift ));
345 output.append( tr( " seconds" ) );
346 347
347 // Display information on time server tab 348 // Display information on time server tab
348 if ( ntpTabEnabled ) 349 if ( ntpTabEnabled )
349 { 350 {
350 ntpTab->setTimeShift( output ); 351 ntpTab->setTimeShift( output );
351 ntpTab->setNewTime( dt.toString() ); 352 ntpTab->setNewTime( dt.toString() );
352 } 353 }
353 354
354 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay ) 355 if ( lastNtp && lastLookup > 0 && secsSinceLast > 60 * ntpDelay )
355 { 356 {
356 QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) ); 357 QString grpname = QString( "lookup_" ).append( QString::number( lookupCount ) );
357 config.setGroup( grpname ); 358 config.setGroup( grpname );
358 lookupCount++; 359 lookupCount++;
359 predictTab->setShiftPerSec( timeShift / secsSinceLast ); 360 predictTab->setShiftPerSec( timeShift / secsSinceLast );
360 config.writeEntry( "secsSinceLast", secsSinceLast ); 361 config.writeEntry( "secsSinceLast", secsSinceLast );
361 config.writeEntry( "timeShift", QString::number( timeShift ) ); 362 config.writeEntry( "timeShift", QString::number( timeShift ) );
362 config.setGroup( "lookups" ); 363 config.setGroup( "lookups" );
363 config.writeEntry( "count", lookupCount ); 364 config.writeEntry( "count", lookupCount );
364 config.writeEntry( "lastNtp", TRUE ); 365 config.writeEntry( "lastNtp", TRUE );
365 } 366 }
366} 367}
367 368
368void MainWindow::slotNTPDelayChanged( int delay ) 369void MainWindow::slotNTPDelayChanged( int delay )
369{ 370{
370 ntpTimer->changeInterval( delay * 1000 * 60 ); 371 ntpTimer->changeInterval( delay * 1000 * 60 );
371 ntpDelay = delay; 372 ntpDelay = delay;
372} 373}
373 374
374void MainWindow::slotCheckNtp( int i ) 375void MainWindow::slotCheckNtp( int i )
375{ 376{
376 if ( i == 0 ) 377 if ( i == 0 )
377 { 378 {