summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/ntp.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/netsystemtime/ntp.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/ntp.cpp38
1 files changed, 33 insertions, 5 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index 40805a0..111f7d4 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -43,12 +43,29 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
Config cfg("ntp",Config::User);
cfg.setGroup("settings");
SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) );
SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) );
ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
+ //make tab order
+
+ TabWidgetMain->removePage( tabMain );
+ TabWidgetMain->removePage( tabManualSetTime );
+ TabWidgetMain->removePage( TabSettings );
+ TabWidgetMain->removePage( tabPredict );
+ TabWidgetMain->removePage( tabNtp );
+
+ TabWidgetMain->insertTab( tabMain, tr( "Main" ) );
+ TabWidgetMain->insertTab( tabManualSetTime, tr( "Manual" ) );
+ TabWidgetMain->insertTab( TabSettings, tr( "Settings" ) );
+ TabWidgetMain->insertTab( tabPredict, tr( "Predict" ) );
+ TabWidgetMain->insertTab( tabNtp, tr( "NTP" ) );
+ NtpBaseLayout->addWidget( TabWidgetMain, 0, 0 );
+
+
+
bool advMode = cfg.readBoolEntry("advancedFeatures", false );
showAdvancedFeatures(advMode);
CheckBoxAdvSettings->setChecked( advMode );
connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ),
SLOT( showAdvancedFeatures( bool ) ) );
@@ -109,13 +126,13 @@ QString Ntp::getNtpServer()
{
return ComboNtpSrv->currentText();
}
void Ntp::slotRunNtp()
{
- if ( !ntpDelayElapsed() )
+ if ( !ntpDelayElapsed() && CheckBoxAdvSettings->isChecked() )
{
switch (
QMessageBox::warning(this, tr("Run NTP?"),
tr("You asked for a delay of ")+SpinBoxNtpDelay->text()+tr(" minutes, but only ")+
QString::number(_lookupDiff/60)+tr(" minutes elapsed since last lookup.")+
"<br>"+tr("Rerun NTP?"),
@@ -130,19 +147,22 @@ void Ntp::slotRunNtp()
ntpOutPut( tr("Running:")+"\nntpdate "+getNtpServer() );
ntpProcess->clearArguments();
*ntpProcess << "ntpdate" << getNtpServer();
bool ret = ntpProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
if ( !ret ) {
+ QMessageBox::critical(this, tr("ntp error"),
+ tr("Error while getting time form network!"));
qDebug("Error while executing ntpdate");
ntpOutPut( tr("Error while executing ntpdate"));
}
}
void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
{
+ if (! proc ) qDebug("Ntp::getNtpOutput OProcess is null");
QString lineStr, lineStrOld;
lineStr = buffer;
lineStr=lineStr.left(buflen);
if (lineStr!=lineStrOld)
{
ntpOutPut(lineStr);
@@ -150,16 +170,22 @@ void Ntp::getNtpOutput(OProcess *proc, char *buffer, int buflen)
}
lineStrOld = lineStr;
}
void Ntp::ntpFinished(OProcess *p)
{
- // qDebug("p->exitStatus() %i",p->exitStatus());
+ qDebug("p->exitStatus() %i",p->exitStatus());
if (p->exitStatus()!=0 || !p->normalExit())
- {
- slotProbeNtpServer();
+ {
+ QMessageBox::critical(this, tr("ntp error"),
+ tr("Error while getting time form\n server")+
+ getNtpServer()+"\n"+
+ _ntpOutput );
+ // TabWidgetMain->setCurrentPage( 1 );
+ TabWidgetMain->showPage( tabManualSetTime );
+
return;
}
Global::writeHWClock();
// since time has changed quickly load in the datebookdb
// to allow the alarm server to get a better grip on itself
@@ -304,12 +330,13 @@ void Ntp::slotNtpDelayChanged(int delay)
{
ntpTimer->changeInterval( delay*1000*60 );
}
void Ntp::ntpOutPut(QString out)
{
+
MultiLineEditntpOutPut->append(out);
MultiLineEditntpOutPut->setCursorPosition(MultiLineEditntpOutPut->numLines() + 1,0,FALSE);
}
void Ntp::makeChannel()
@@ -335,18 +362,19 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg)
qDebug("Ntp::receive: Huh what do ya want");
}
}
void Ntp::setDocument(const QString &fileName)
{
-
+ qDebug("Ntp::setDocument( %s )",fileName.latin1());
}
void Ntp::showAdvancedFeatures(bool advMode)
{
if (advMode) {
+
TabWidgetMain->addTab( tabPredict, tr( "Predict" ) );
TabWidgetMain->addTab( tabNtp, tr( "NTP" ) );
TextLabel1_2_2->show();
TextLabel2_3->show();
TextLabel3_3_2->show();
TextLabel1_2->show();