summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/mainwindow.cpp
Side-by-side diff
Diffstat (limited to 'noncore/settings/netsystemtime/mainwindow.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp25
1 files changed, 13 insertions, 12 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index 2d240ba..66e1ca3 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -36,24 +36,25 @@
#include <opie/oprocess.h>
#include <opie/otabwidget.h>
#include <qpe/config.h>
#include <qpe/datebookdb.h>
#include <qpe/qpeapplication.h>
+#include <qpe/qpedialog.h>
#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
#include <qpe/qcopenvelope_qws.h>
#endif
#include <qlayout.h>
#include <qmessagebox.h>
#include <qsocket.h>
#include <qstring.h>
#include <qtimer.h>
-MainWindow::MainWindow()
+MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f )
: QDialog( 0x0, 0x0, TRUE, 0 )
{
setCaption( tr( "SystemTime" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
layout->setMargin( 2 );
@@ -63,29 +64,28 @@ MainWindow::MainWindow()
mainWidget = new OTabWidget( this );
// Default object pointers to null
ntpProcess = 0x0;
ntpTab = 0x0;
- // Add tab widgets
+ // Add tab widgets
mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) );
mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) );
mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) );
mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) );
Config config( "ntp" );
config.setGroup( "settings" );
slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) );
slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) );
mainWidget->setCurrentTab( tr( "Time" ) );
layout->addWidget( mainWidget );
- // Create QCOP channel
- QCopChannel *channel = new QCopChannel( "QPE/Application/netsystemtime", this );
- connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
- this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
+ connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
+ this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
+
// Create NTP socket
ntpSock = new QSocket( this );
connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) );
slotProbeNTPServer();
@@ -107,13 +107,14 @@ MainWindow::MainWindow()
// Do initial time server check
slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) );
slotCheckNtp( -1 );
// Display app
- showMaximized();
+ //showMaximized();
+ (void)new QPEDialogListener(this);
}
MainWindow::~MainWindow()
{
if ( ntpProcess )
delete ntpProcess;
@@ -162,13 +163,13 @@ void MainWindow::reject()
void MainWindow::runNTP()
{
if ( !ntpDelayElapsed() && ntpInteractive )
{
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 ) );
-
+
switch (
QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No )
)
{
case QMessageBox::Yes: break;
case QMessageBox::No: return;
@@ -195,14 +196,14 @@ void MainWindow::runNTP()
connect( ntpProcess, SIGNAL(processExited(OProcess*)),
this, SLOT(slotNtpFinished(OProcess*)) );
}
else
ntpProcess->clearArguments();
-
- *ntpProcess << "ntpdate" << srv;
+
+ *ntpProcess << "ntpdate" << srv;
bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput );
if ( !ret )
{
QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) );
if ( ntpTabEnabled )
ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) );
@@ -294,13 +295,13 @@ void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen )
}
void MainWindow::slotNtpFinished( OProcess *p )
{
QString output;
QDateTime dt = QDateTime::currentDateTime();
-
+
// Verify run was successful
if ( p->exitStatus() != 0 || !p->normalExit() )
{
if ( isVisible() && ntpInteractive )
{
output = tr( "Error while getting time from\n server: " );
@@ -335,13 +336,13 @@ void MainWindow::slotNtpFinished( OProcess *p )
float timeShift = diff.toFloat();
if ( timeShift == 0.0 )
return;
int secsSinceLast = time - lastLookup;
output = tr( "%1 seconds").arg(QString::number( timeShift ));
-
+
// Display information on time server tab
if ( ntpTabEnabled )
{
ntpTab->setTimeShift( output );
ntpTab->setNewTime( dt.toString() );
}