-rw-r--r-- | noncore/settings/netsystemtime/ntp.cpp | 55 | ||||
-rw-r--r-- | noncore/settings/netsystemtime/ntp.h | 4 |
2 files changed, 40 insertions, 19 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp index 6e74e32..c7e3b52 100644 --- a/noncore/settings/netsystemtime/ntp.cpp +++ b/noncore/settings/netsystemtime/ntp.cpp @@ -32,2 +32,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) { + _interactive = false; Config ntpSrvs(QPEApplication::qpeDir()+"etc/ntpservers",Config::File); @@ -80,4 +81,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) ntpSock = new QSocket( this ); - connect( ntpSock, SIGNAL( error(int) ), - SLOT(slotCheckNtp(int)) ); + connect( ntpSock, SIGNAL( error(int) ),SLOT(slotCheckNtp(int)) ); slotProbeNtpServer(); @@ -88,3 +88,3 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl ) this, SLOT(ntpFinished(OProcess*))); - connect(runNtp, SIGNAL(clicked()), this, SLOT(slotRunNtp())); + connect(runNtp, SIGNAL(clicked()), this, SLOT(slotButtonRunNtp())); connect(PushButtonPredict, SIGNAL(clicked()), this, SLOT(preditctTime())); @@ -98,9 +98,17 @@ Ntp::~Ntp() delete ntpProcess; - Config ntpSrvs("/etc/ntpservers",Config::File); - ntpSrvs.setGroup("servers"); int srvCount = ComboNtpSrv->count(); - ntpSrvs.writeEntry("count", srvCount); + bool serversChanged = true; + QString edit = ComboNtpSrv->currentText(); for (int i = 0; i < srvCount; i++){ - ntpSrvs.setGroup(QString::number(i)); - ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); + if ( edit == ComboNtpSrv->text(i)) serversChanged = false; + } + if (serversChanged){ + Config ntpSrvs("/etc/ntpservers",Config::File); + ntpSrvs.setGroup("servers"); + ntpSrvs.writeEntry("count", srvCount); + for (int i = 0; i < srvCount; i++){ + qDebug("ntpSrvs[%i/%i]=%s",i,srvCount,ComboNtpSrv->text(i).latin1()); + ntpSrvs.setGroup(QString::number(i)); + ntpSrvs.writeEntry( "name", ComboNtpSrv->text(i) ); + } } @@ -129,2 +137,15 @@ QString Ntp::getNtpServer() +void Ntp::slotButtonRunNtp() +{ + _interactive = true; + slotRunNtp(); +} + +void Ntp::slotTimerRunNtp() +{ + _interactive = false; + slotRunNtp(); +} + + void Ntp::slotRunNtp() @@ -178,10 +199,7 @@ void Ntp::ntpFinished(OProcess *p) { - if ( isVisible() ) { - QMessageBox::critical(this, tr("ntp error"), - tr("Error while getting time form\n server")+ - getNtpServer()+"\n"+ - _ntpOutput ); - TabWidgetMain->showPage( tabManualSetTime ); + if ( isVisible() && _interactive ){ + QMessageBox::critical(this, tr("ntp error"),tr("Error while getting time form\n server")+getNtpServer()+"\n"+_ntpOutput ); + TabWidgetMain->showPage( tabManualSetTime ); } - + return; @@ -305,3 +323,3 @@ void Ntp::slotCheckNtp(int i) ButtonSetTime->setText( tr("Get time from network") ); - connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotRunNtp()) ); + connect( ButtonSetTime, SIGNAL(clicked()), SLOT(slotButtonRunNtp()) ); if ( ntpDelayElapsed() ) @@ -310,5 +328,5 @@ void Ntp::slotCheckNtp(int i) disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotProbeNtpServer()) ); - connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotRunNtp()) ); + connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotTimerRunNtp()) ); }else{ - disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) ); + disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotTimerRunNtp()) ); connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) ); @@ -356,2 +374,3 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg) { + _interactive = false; slotRunNtp(); diff --git a/noncore/settings/netsystemtime/ntp.h b/noncore/settings/netsystemtime/ntp.h index f6694c9..15cddbd 100644 --- a/noncore/settings/netsystemtime/ntp.h +++ b/noncore/settings/netsystemtime/ntp.h @@ -34,3 +34,3 @@ private: QCopChannel *channel; - + bool _interactive; float getTimeShift(); @@ -41,2 +41,4 @@ private: private slots: + void slotTimerRunNtp(); + void slotButtonRunNtp(); void slotRunNtp(); |