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.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/noncore/settings/netsystemtime/ntp.cpp b/noncore/settings/netsystemtime/ntp.cpp
index fbd65a2..6f6316c 100644
--- a/noncore/settings/netsystemtime/ntp.cpp
+++ b/noncore/settings/netsystemtime/ntp.cpp
@@ -4,12 +4,15 @@
#include <qtimer.h>
#include <qtable.h>
#include <qlabel.h>
#include <qsocket.h>
#include <qlineedit.h>
#include <qspinbox.h>
+#include <qcheckbox.h>
+#include <qtabwidget.h>
+#include <qlayout.h>
#include <qmessagebox.h>
#include <qmultilineedit.h>
#include <opie/oprocess.h>
#include <qpe/qpeapplication.h>
#include <qpe/config.h>
#include <qpe/global.h>
@@ -36,16 +39,22 @@ Ntp::Ntp( QWidget* parent, const char* name, WFlags fl )
ComboNtpSrv->insertItem( ntpSrvs.readEntry("name") );
}
if ( srvCount==0 ) ComboNtpSrv->insertItem(tr("time.fu-berlin.de"));
Config cfg("ntp",Config::User);
cfg.setGroup("settings");
- SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",41) );
- SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",42) );
+ SpinBoxMinLookupDelay->setValue( cfg.readNumEntry("minLookupDiff",720) );
+ SpinBoxNtpDelay->setValue( cfg.readNumEntry("ntpRefreshFreq",1440) );
ComboNtpSrv->setCurrentItem( cfg.readNumEntry("ntpServer", 0) );
+ bool advMode = cfg.readBoolEntry("advancedFeatures", false );
+ showAdvancedFeatures(advMode);
+ CheckBoxAdvSettings->setChecked( advMode );
+ connect( CheckBoxAdvSettings, SIGNAL( toggled( bool ) ),
+ SLOT( showAdvancedFeatures( bool ) ) );
+
makeChannel();
ntpTimer = new QTimer(this);
ntpProcess = new OProcess( );
connect( SpinBoxNtpDelay, SIGNAL( valueChanged(int) ),
@@ -139,13 +148,13 @@ 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();
return;
}
@@ -274,22 +283,21 @@ void Ntp::slotCheckNtp(int i)
}else{
disconnect(ntpTimer, SIGNAL( timeout() ), this, SLOT(slotRunNtp()) );
connect(ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
}
}else{
preditctTime();
- ButtonSetTime->setText( tr("Set predicted time") );
+ ButtonSetTime->setText( tr("Set predicted time: ")+predictedTime.toString() );
if (i>0)ntpOutPut(tr("Could not connect to server ")+getNtpServer());
connect( ButtonSetTime, SIGNAL(clicked()), SLOT(setPredictTime()) );
connect( ntpTimer, SIGNAL( timeout() ), SLOT(slotProbeNtpServer()) );
}
}
void Ntp::slotProbeNtpServer()
{
- qDebug("Ntp::slotProbeNtpServer()");
ntpSock->connectToHost( getNtpServer() ,123);
}
void Ntp::slotNtpDelayChanged(int delay)
{
ntpTimer->changeInterval( delay*1000*60 );
@@ -327,6 +335,33 @@ void Ntp::receive(const QCString &msg, const QByteArray &arg)
}
void Ntp::setDocument(const QString &fileName)
{
}
+
+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();
+ SpinBoxMinLookupDelay->show();
+ TextLabel2->show();
+ TextLabel3_3->show();
+ SpinBoxNtpDelay->show();
+ }else{
+ TabWidgetMain->removePage( tabPredict );
+ TabWidgetMain->removePage( tabNtp );
+ TextLabel1_2_2->hide();
+ TextLabel2_3->hide();
+ TextLabel3_3_2->hide();
+ TextLabel1_2->hide();
+ SpinBoxMinLookupDelay->hide();
+ TextLabel2->hide();
+ TextLabel3_3->hide();
+ SpinBoxNtpDelay->hide();
+ };
+}