summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/netsystemtime/mainwindow.cpp1
1 files changed, 0 insertions, 1 deletions
diff --git a/noncore/settings/netsystemtime/mainwindow.cpp b/noncore/settings/netsystemtime/mainwindow.cpp
index 306117a..ab71463 100644
--- a/noncore/settings/netsystemtime/mainwindow.cpp
+++ b/noncore/settings/netsystemtime/mainwindow.cpp
@@ -1,163 +1,162 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 =. 3 =.
4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?> 4             .=l. Copyright (c) 2002 OPIE team <opie@handhelds.org?>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "mainwindow.h" 29#include "mainwindow.h"
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#include "systemtimeconfig.h"
36 35
37#include <opie/oprocess.h> 36#include <opie/oprocess.h>
38#include <opie/otabwidget.h> 37#include <opie/otabwidget.h>
39 38
40#include <qpe/config.h> 39#include <qpe/config.h>
41#include <qpe/datebookdb.h> 40#include <qpe/datebookdb.h>
42#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
43 42
44#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 43#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
45#include <qpe/qcopenvelope_qws.h> 44#include <qpe/qcopenvelope_qws.h>
46#endif 45#endif
47 46
48#include <qlayout.h> 47#include <qlayout.h>
49#include <qmessagebox.h> 48#include <qmessagebox.h>
50#include <qsocket.h> 49#include <qsocket.h>
51#include <qstring.h> 50#include <qstring.h>
52#include <qtimer.h> 51#include <qtimer.h>
53 52
54MainWindow::MainWindow() 53MainWindow::MainWindow()
55 : QDialog( 0x0, 0x0, TRUE, 0 ) 54 : QDialog( 0x0, 0x0, TRUE, 0 )
56{ 55{
57 setCaption( tr( "SystemTime" ) ); 56 setCaption( tr( "SystemTime" ) );
58 57
59 QVBoxLayout *layout = new QVBoxLayout( this ); 58 QVBoxLayout *layout = new QVBoxLayout( this );
60 layout->setMargin( 2 ); 59 layout->setMargin( 2 );
61 layout->setSpacing( 4 ); 60 layout->setSpacing( 4 );
62 61
63 // Create main tabbed control 62 // Create main tabbed control
64 mainWidget = new OTabWidget( this ); 63 mainWidget = new OTabWidget( this );
65 64
66 // Default object pointers to null 65 // Default object pointers to null
67 ntpProcess = 0x0; 66 ntpProcess = 0x0;
68 ntpTab = 0x0; 67 ntpTab = 0x0;
69 68
70 // Add tab widgets 69 // Add tab widgets
71 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) ); 70 mainWidget->addTab( timeTab = new TimeTabWidget( mainWidget ), "netsystemtime/DateTime", tr( "Time" ) );
72 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) ); 71 mainWidget->addTab( formatTab = new FormatTabWidget( mainWidget ), "netsystemtime/formattab", tr( "Format" ) );
73 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) ); 72 mainWidget->addTab( settingsTab = new SettingsTabWidget( mainWidget ), "SettingsIcon", tr( "Settings" ) );
74 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) ); 73 mainWidget->addTab( predictTab = new PredictTabWidget( mainWidget ), "netsystemtime/predicttab", tr( "Predict" ) );
75 Config config( "ntp" ); 74 Config config( "ntp" );
76 config.setGroup( "settings" ); 75 config.setGroup( "settings" );
77 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) ); 76 slotDisplayNTPTab( config.readBoolEntry( "displayNtpTab", FALSE ) );
78 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) ); 77 slotDisplayPredictTab( config.readBoolEntry( "displayPredictTab", FALSE ) );
79 78
80 mainWidget->setCurrentTab( tr( "Time" ) ); 79 mainWidget->setCurrentTab( tr( "Time" ) );
81 layout->addWidget( mainWidget ); 80 layout->addWidget( mainWidget );
82 81
83 // Create QCOP channel 82 // Create QCOP channel
84 QCopChannel *channel = new QCopChannel( "QPE/Application/netsystemtime", this ); 83 QCopChannel *channel = new QCopChannel( "QPE/Application/netsystemtime", this );
85 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 84 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)),
86 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) ); 85 this, SLOT(slotQCopReceive(const QCString&, const QByteArray&)) );
87 86
88 // Create NTP socket 87 // Create NTP socket
89 ntpSock = new QSocket( this ); 88 ntpSock = new QSocket( this );
90 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) ); 89 connect( ntpSock, SIGNAL(error(int)),SLOT(slotCheckNtp(int)) );
91 slotProbeNTPServer(); 90 slotProbeNTPServer();
92 91
93 // Create timer for automatic time lookups 92 // Create timer for automatic time lookups
94 ntpTimer = new QTimer( this ); 93 ntpTimer = new QTimer( this );
95 94
96 // Connect everything together 95 // Connect everything together
97 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) ); 96 connect( timeTab, SIGNAL(getNTPTime()), this, SLOT(slotGetNTPTime()) );
98 connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) ); 97 connect( timeTab, SIGNAL(tzChanged(const QString &)), predictTab, SLOT(slotTZChanged(const QString &)) );
99 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) ); 98 connect( timeTab, SIGNAL(getPredictedTime()), predictTab, SLOT(slotSetPredictedTime()) );
100 connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) ); 99 connect( formatTab, SIGNAL(show12HourTime(int)), timeTab, SLOT(slotUse12HourTime( int )) );
101 connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)), 100 connect( formatTab, SIGNAL(dateFormatChanged(const DateFormat &)),
102 timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) ); 101 timeTab, SLOT(slotDateFormatChanged(const DateFormat &)) );
103 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) ); 102 connect( formatTab, SIGNAL(weekStartChanged(int)), timeTab, SLOT(slotWeekStartChanged(int)) );
104 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) ); 103 connect( settingsTab, SIGNAL(ntpDelayChanged(int)), this, SLOT(slotNTPDelayChanged(int)) );
105 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) ); 104 connect( settingsTab, SIGNAL(displayNTPTab(bool)), this, SLOT(slotDisplayNTPTab(bool)) );
106 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) ); 105 connect( settingsTab, SIGNAL(displayPredictTab(bool)), this, SLOT(slotDisplayPredictTab(bool)) );
107 connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) ); 106 connect( predictTab, SIGNAL(setTime(const QDateTime &)), this, SLOT(slotSetTime(const QDateTime &)) );
108 107
109 // Do initial time server check 108 // Do initial time server check
110 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) ); 109 slotNTPDelayChanged( config.readNumEntry( "ntpRefreshFreq", 1440 ) );
111 slotCheckNtp( -1 ); 110 slotCheckNtp( -1 );
112 111
113 // Display app 112 // Display app
114 showMaximized(); 113 showMaximized();
115} 114}
116 115
117MainWindow::~MainWindow() 116MainWindow::~MainWindow()
118{ 117{
119 if ( ntpProcess ) 118 if ( ntpProcess )
120 delete ntpProcess; 119 delete ntpProcess;
121} 120}
122 121
123void MainWindow::accept() 122void MainWindow::accept()
124{ 123{
125 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends) 124 // Turn off the screensaver (Note: needs to be encased in { } so that it deconstructs and sends)
126 { 125 {
127 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 126 QCopEnvelope disableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
128 disableScreenSaver << 0 << 0 << 0; 127 disableScreenSaver << 0 << 0 << 0;
129 } 128 }
130 129
131 // Update the systemtime 130 // Update the systemtime
132 timeTab->saveSettings( TRUE ); 131 timeTab->saveSettings( TRUE );
133 132
134 // Save format options 133 // Save format options
135 formatTab->saveSettings( TRUE ); 134 formatTab->saveSettings( TRUE );
136 135
137 // Save settings options 136 // Save settings options
138 settingsTab->saveSettings(); 137 settingsTab->saveSettings();
139 138
140 // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better 139 // Since time has changed quickly load in the DateBookDB to allow the alarm server to get a better
141 // grip on itself (example re-trigger alarms for when we travel back in time). 140 // grip on itself (example re-trigger alarms for when we travel back in time).
142 DateBookDB db; 141 DateBookDB db;
143 142
144 // Turn back on the screensaver 143 // Turn back on the screensaver
145 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" ); 144 QCopEnvelope enableScreenSaver( "QPE/System", "setScreenSaverIntervals(int,int,int)" );
146 enableScreenSaver << -1 << -1 << -1; 145 enableScreenSaver << -1 << -1 << -1;
147 146
148 // Exit app 147 // Exit app
149 qApp->quit(); 148 qApp->quit();
150} 149}
151 150
152void MainWindow::reject() 151void MainWindow::reject()
153{ 152{
154 // Reset time settings 153 // Reset time settings
155 timeTab->saveSettings( FALSE ); 154 timeTab->saveSettings( FALSE );
156 155
157 // Send notifications but do not save settings 156 // Send notifications but do not save settings
158 formatTab->saveSettings( FALSE ); 157 formatTab->saveSettings( FALSE );
159 158
160 // Exit app 159 // Exit app
161 qApp->quit(); 160 qApp->quit();
162} 161}
163 162