summaryrefslogtreecommitdiff
path: root/noncore/settings/netsystemtime/mainwindow.cpp
Unidiff
Diffstat (limited to 'noncore/settings/netsystemtime/mainwindow.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp11
1 files changed, 6 insertions, 5 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
@@ -30,36 +30,37 @@
30#include "timetabwidget.h" 30#include "timetabwidget.h"
31#include "formattabwidget.h" 31#include "formattabwidget.h"
32#include "settingstabwidget.h" 32#include "settingstabwidget.h"
33#include "ntptabwidget.h" 33#include "ntptabwidget.h"
34#include "predicttabwidget.h" 34#include "predicttabwidget.h"
35 35
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 );
60 layout->setSpacing( 4 ); 61 layout->setSpacing( 4 );
61 62
62 // Create main tabbed control 63 // Create main tabbed control
63 mainWidget = new OTabWidget( this ); 64 mainWidget = new OTabWidget( this );
64 65
65 // Default object pointers to null 66 // Default object pointers to null
@@ -70,29 +71,28 @@ MainWindow::MainWindow()
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 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
85 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) ); 84 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
86 85
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
92 // Create timer for automatic time lookups 92 // Create timer for automatic time lookups
93 ntpTimer = new QTimer( this ); 93 ntpTimer = new QTimer( this );
94 94
95 // Connect everything together 95 // Connect everything together
96 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); 96 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
97 connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) ); 97 connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) );
98 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); 98 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) );
@@ -101,25 +101,26 @@ MainWindow::MainWindow()
101 timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) ); 101 timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) );
102 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); 102 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) );
103 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); 103 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) );
104 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); 104 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) );
105 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); 105 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) );
106 connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) ); 106 connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) );
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;
120} 121}
121 122
122void MainWindow::accept() 123void MainWindow::accept()
123{ 124{
124 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) 125 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends)
125 { 126 {