summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime
Unidiff
Diffstat (limited to 'noncore/settings/netsystemtime') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/main.cpp10
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp25
-rw-r--r--noncore/settings/netsystemtime/mainwindow.h3
-rw-r--r--noncore/settings/netsystemtime/netsystemtime.pro7
4 files changed, 19 insertions, 26 deletions
diff --git a/noncore/settings/netsystemtime/main.cpp b/noncore/settings/netsystemtime/main.cpp
index 4b20a61..da98eee 100644
--- a/noncore/settings/netsystemtime/main.cpp
+++ b/noncore/settings/netsystemtime/main.cpp
@@ -26,16 +26,10 @@
26 26
27*/ 27*/
28 28
29#include "mainwindow.h" 29#include "mainwindow.h"
30 30
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <opie/oapplicationfactory.h>
32 33
33int main( int argc, char ** argv )
34{
35 QPEApplication a( argc, argv );
36 34
37 MainWindow mw; 35OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
38 a.showMainWidget( &mw );
39
40 return a.exec();
41}
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 @@
36#include <opie/oprocess.h> 36#include <opie/oprocess.h>
37#include <opie/otabwidget.h> 37#include <opie/otabwidget.h>
38 38
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/datebookdb.h> 40#include <qpe/datebookdb.h>
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42#include <qpe/qpedialog.h>
42 43
43#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 44#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
44#include <qpe/qcopenvelope_qws.h> 45#include <qpe/qcopenvelope_qws.h>
45#endif 46#endif
46 47
47#include <qlayout.h> 48#include <qlayout.h>
48#include <qmessagebox.h> 49#include <qmessagebox.h>
49#include <qsocket.h> 50#include <qsocket.h>
50#include <qstring.h> 51#include <qstring.h>
51#include <qtimer.h> 52#include <qtimer.h>
52 53
53MainWindow::MainWindow() 54MainWindow::MainWindow( QWidget *parent , const char *name, bool modal, WFlags f )
54 : QDialog( 0x0, 0x0, TRUE, 0 ) 55 : QDialog( 0x0, 0x0, TRUE, 0 )
55{ 56{
56 setCaption( tr( "SystemTime" ) ); 57 setCaption( tr( "SystemTime" ) );
57 58
58 QVBoxLayout *layout = new QVBoxLayout( this ); 59 QVBoxLayout *layout = new QVBoxLayout( this );
59 layout->setMargin( 2 ); 60 layout->setMargin( 2 );
@@ -63,29 +64,28 @@ MainWindow::MainWindow()
63 mainWidget = new OTabWidget( this ); 64 mainWidget = new OTabWidget( this );
64 65
65 // Default object pointers to null 66 // Default object pointers to null
66 ntpProcess = 0x0; 67 ntpProcess = 0x0;
67 ntpTab = 0x0; 68 ntpTab = 0x0;
68 69
69 // Add tab widgets 70 // Add tab widgets
70 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); 71 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) );
71 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); 72 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) );
72 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); 73 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) );
73 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); 74 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) );
74 Config config( "ntp" ); 75 Config config( "ntp" );
75 config.setGroup( "settings" ); 76 config.setGroup( "settings" );
76 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); 77 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) );
77 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); 78 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) );
78 79
79 mainWidget->setCurrentTab( tr( "Time" ) ); 80 mainWidget->setCurrentTab( tr( "Time" ) );
80 layout->addWidget( mainWidget ); 81 layout->addWidget( mainWidget );
81 82
82 // Create QCOP channel 83 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)),
83 QCopChannel *channel = new QCopChannel( "QPE/Application/netsystemtime", this ); 84 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
84 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 85
85 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
86 86
87 // Create NTP socket 87 // Create NTP socket
88 ntpSock = new QSocket( this ); 88 ntpSock = new QSocket( this );
89 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); 89 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) );
90 slotProbeNTPServer(); 90 slotProbeNTPServer();
91 91
@@ -107,13 +107,14 @@ MainWindow::MainWindow()
107 107
108 // Do initial time server check 108 // Do initial time server check
109 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); 109 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) );
110 slotCheckNtp( -1 ); 110 slotCheckNtp( -1 );
111 111
112 // Display app 112 // Display app
113 showMaximized(); 113 //showMaximized();
114 (void)new QPEDialogListener(this);
114} 115}
115 116
116MainWindow::~MainWindow() 117MainWindow::~MainWindow()
117{ 118{
118 if ( ntpProcess ) 119 if ( ntpProcess )
119 delete ntpProcess; 120 delete ntpProcess;
@@ -162,13 +163,13 @@ void MainWindow::reject()
162 163
163void MainWindow::runNTP() 164void MainWindow::runNTP()
164{ 165{
165 if ( !ntpDelayElapsed() && ntpInteractive ) 166 if ( !ntpDelayElapsed() && ntpInteractive )
166 { 167 {
167 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 ) ); 168 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 ) );
168 169
169 switch ( 170 switch (
170 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No ) 171 QMessageBox::warning( this, tr( "Continue?" ), msg, QMessageBox::Yes, QMessageBox::No )
171 ) 172 )
172 { 173 {
173 case QMessageBox::Yes: break; 174 case QMessageBox::Yes: break;
174 case QMessageBox::No: return; 175 case QMessageBox::No: return;
@@ -195,14 +196,14 @@ void MainWindow::runNTP()
195 connect( ntpProcess, SIGNAL(processExited(OProcess*)), 196 connect( ntpProcess, SIGNAL(processExited(OProcess*)),
196 this, SLOT(slotNtpFinished(OProcess*)) ); 197 this, SLOT(slotNtpFinished(OProcess*)) );
197 } 198 }
198 199
199 else 200 else
200 ntpProcess->clearArguments(); 201 ntpProcess->clearArguments();
201 202
202 *ntpProcess << "ntpdate" << srv; 203 *ntpProcess << "ntpdate" << srv;
203 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput ); 204 bool ret = ntpProcess->start( OProcess::NotifyOnExit, OProcess::AllOutput );
204 if ( !ret ) 205 if ( !ret )
205 { 206 {
206 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) ); 207 QMessageBox::critical( this, tr( "Error" ), tr( "Error while getting time from network." ) );
207 if ( ntpTabEnabled ) 208 if ( ntpTabEnabled )
208 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) ); 209 ntpTab->addNtpOutput( tr( "Error while executing ntpdate" ) );
@@ -294,13 +295,13 @@ void MainWindow::slotNtpOutput( OProcess *, char *buffer, int buflen )
294} 295}
295 296
296void MainWindow::slotNtpFinished( OProcess *p ) 297void MainWindow::slotNtpFinished( OProcess *p )
297{ 298{
298 QString output; 299 QString output;
299 QDateTime dt = QDateTime::currentDateTime(); 300 QDateTime dt = QDateTime::currentDateTime();
300 301
301 // Verify run was successful 302 // Verify run was successful
302 if ( p->exitStatus() != 0 || !p->normalExit() ) 303 if ( p->exitStatus() != 0 || !p->normalExit() )
303 { 304 {
304 if ( isVisible() && ntpInteractive ) 305 if ( isVisible() && ntpInteractive )
305 { 306 {
306 output = tr( "Error while getting time from\n server: " ); 307 output = tr( "Error while getting time from\n server: " );
@@ -335,13 +336,13 @@ void MainWindow::slotNtpFinished( OProcess *p )
335 336
336 float timeShift = diff.toFloat(); 337 float timeShift = diff.toFloat();
337 if ( timeShift == 0.0 ) 338 if ( timeShift == 0.0 )
338 return; 339 return;
339 int secsSinceLast = time - lastLookup; 340 int secsSinceLast = time - lastLookup;
340 output = tr( "%1 seconds").arg(QString::number( timeShift )); 341 output = tr( "%1 seconds").arg(QString::number( timeShift ));
341 342
342 // Display information on time server tab 343 // Display information on time server tab
343 if ( ntpTabEnabled ) 344 if ( ntpTabEnabled )
344 { 345 {
345 ntpTab->setTimeShift( output ); 346 ntpTab->setTimeShift( output );
346 ntpTab->setNewTime( dt.toString() ); 347 ntpTab->setNewTime( dt.toString() );
347 } 348 }
diff --git a/noncore/settings/netsystemtime/mainwindow.h b/noncore/settings/netsystemtime/mainwindow.h
index fa94335..1cdbc1a 100644
--- a/noncore/settings/netsystemtime/mainwindow.h
+++ b/noncore/settings/netsystemtime/mainwindow.h
@@ -45,14 +45,15 @@ class QTimer;
45 45
46class MainWindow : public QDialog 46class MainWindow : public QDialog
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 49
50public: 50public:
51 MainWindow(); 51 MainWindow( QWidget *parent = 0, const char *name = 0, bool modal = FALSE,WFlags f = 0);
52 ~MainWindow(); 52 ~MainWindow();
53 static QString appName() { return QString::fromLatin1("systemtime"); }
53 54
54protected: 55protected:
55 void accept(); 56 void accept();
56 void reject(); 57 void reject();
57 58
58private: 59private:
diff --git a/noncore/settings/netsystemtime/netsystemtime.pro b/noncore/settings/netsystemtime/netsystemtime.pro
index 7a12dd1..2140f2e 100644
--- a/noncore/settings/netsystemtime/netsystemtime.pro
+++ b/noncore/settings/netsystemtime/netsystemtime.pro
@@ -1,9 +1,7 @@
1 TEMPLATE= app 1 CONFIG = qt warn_on release quick-app
2 CONFIG = qt warn_on debug
3 #CONFIG = qt warn_on release
4 HEADERS = mainwindow.h \ 2 HEADERS = mainwindow.h \
5 timetabwidget.h \ 3 timetabwidget.h \
6 formattabwidget.h \ 4 formattabwidget.h \
7 settingstabwidget.h \ 5 settingstabwidget.h \
8 predicttabwidget.h \ 6 predicttabwidget.h \
9 ntptabwidget.h 7 ntptabwidget.h
@@ -14,14 +12,13 @@ SOURCES = main.cpp \
14 settingstabwidget.cpp \ 12 settingstabwidget.cpp \
15 predicttabwidget.cpp \ 13 predicttabwidget.cpp \
16 ntptabwidget.cpp 14 ntptabwidget.cpp
17 INCLUDEPATH+= $(OPIEDIR)/include 15 INCLUDEPATH+= $(OPIEDIR)/include
18 DEPENDPATH+= $(OPIEDIR)/include 16 DEPENDPATH+= $(OPIEDIR)/include
19 LIBS += -lqpe -lopie 17 LIBS += -lqpe -lopie
20 INTERFACES= 18
21 DESTDIR = $(OPIEDIR)/bin
22 TARGET = systemtime 19 TARGET = systemtime
23 20
24TRANSLATIONS = ../../../i18n/de/systemtime.ts \ 21TRANSLATIONS = ../../../i18n/de/systemtime.ts \
25 ../../../i18n/nl/systemtime.ts \ 22 ../../../i18n/nl/systemtime.ts \
26 ../../../i18n/da/systemtime.ts \ 23 ../../../i18n/da/systemtime.ts \
27 ../../../i18n/xx/systemtime.ts \ 24 ../../../i18n/xx/systemtime.ts \