author | zecke <zecke> | 2003-10-04 07:27:33 (UTC) |
---|---|---|
committer | zecke <zecke> | 2003-10-04 07:27:33 (UTC) |
commit | 364d30ca7c212a531b79bb7cbceb8af7a0130f2c (patch) (unidiff) | |
tree | 7c0d70c49a884d02418a7708ce819a8d0b02130f | |
parent | 271ba635536db4a9f4ae1e575194d0f388b1c991 (diff) | |
download | opie-364d30ca7c212a531b79bb7cbceb8af7a0130f2c.zip opie-364d30ca7c212a531b79bb7cbceb8af7a0130f2c.tar.gz opie-364d30ca7c212a531b79bb7cbceb8af7a0130f2c.tar.bz2 |
Check if there is a Mouse Driver
And get rid off the QPE_NEED_CALIBRATION define for defining the need of calibration
We will find out at runtime
SomeOne Apply this to core/server in the BRANCH as well
-rw-r--r-- | core/launcher/firstuse.cpp | 24 | ||||
-rw-r--r-- | core/launcher/firstuse.h | 1 | ||||
-rw-r--r-- | core/launcher/main.cpp | 3 |
3 files changed, 16 insertions, 12 deletions
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp index 2dc6a72..3f769ae 100644 --- a/core/launcher/firstuse.cpp +++ b/core/launcher/firstuse.cpp | |||
@@ -1,329 +1,332 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | // I need access to some things you don't normally get access to. | 21 | // I need access to some things you don't normally get access to. |
22 | 22 | ||
23 | #ifndef _MSC_VER | 23 | #ifndef _MSC_VER |
24 | //### revise to allow removal of translators under MSVC | 24 | //### revise to allow removal of translators under MSVC |
25 | #define private public | 25 | #define private public |
26 | #define protected public | 26 | #define protected public |
27 | #endif | 27 | #endif |
28 | #include "firstuse.h" | 28 | #include "firstuse.h" |
29 | #include "inputmethods.h" | 29 | #include "inputmethods.h" |
30 | #include "applauncher.h" | 30 | #include "applauncher.h" |
31 | #include "serverapp.h" | 31 | #include "serverapp.h" |
32 | #include <qtopia/custom.h> | 32 | #include <qtopia/custom.h> |
33 | #if defined(QPE_NEED_CALIBRATION) | 33 | |
34 | #include "calibrate.h" | 34 | #include "calibrate.h" |
35 | #endif | ||
36 | #include "documentlist.h" | 35 | #include "documentlist.h" |
37 | 36 | ||
38 | #include <qtopia/resource.h> | 37 | #include <qtopia/resource.h> |
39 | #include <qtopia/qcopenvelope_qws.h> | 38 | #include <qtopia/qcopenvelope_qws.h> |
40 | #include <qtopia/qpeapplication.h> | 39 | #include <qtopia/qpeapplication.h> |
41 | #include <qtopia/config.h> | 40 | #include <qtopia/config.h> |
42 | #include <qtopia/applnk.h> | 41 | #include <qtopia/applnk.h> |
43 | #include <qtopia/mimetype.h> | 42 | #include <qtopia/mimetype.h> |
44 | #include <qtopia/fontmanager.h> | 43 | #include <qtopia/fontmanager.h> |
45 | 44 | ||
46 | #include <qapplication.h> | 45 | #include <qapplication.h> |
47 | #include <qfile.h> | 46 | #include <qfile.h> |
48 | #include <qpainter.h> | 47 | #include <qpainter.h> |
49 | #include <qcstring.h> | 48 | #include <qcstring.h> |
50 | #include <qsimplerichtext.h> | 49 | #include <qsimplerichtext.h> |
51 | #include <qcolor.h> | 50 | #include <qcolor.h> |
52 | #include <qpushbutton.h> | 51 | #include <qpushbutton.h> |
53 | #include <qhbox.h> | 52 | #include <qhbox.h> |
54 | #include <qlabel.h> | 53 | #include <qlabel.h> |
55 | #include <qtimer.h> | 54 | #include <qtimer.h> |
56 | 55 | ||
57 | #if defined( Q_WS_QWS ) | 56 | #if defined( Q_WS_QWS ) |
58 | #include <qwsdisplay_qws.h> | 57 | #include <qwsdisplay_qws.h> |
59 | #include <qgfx_qws.h> | 58 | #include <qgfx_qws.h> |
60 | #endif | 59 | #endif |
61 | 60 | ||
62 | #include <qwindowsystem_qws.h> | 61 | #include <qwindowsystem_qws.h> |
63 | 62 | ||
64 | #include <stdlib.h> | 63 | #include <stdlib.h> |
65 | #include <sys/types.h> | 64 | #include <sys/types.h> |
66 | #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) | 65 | #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) |
67 | #include <unistd.h> | 66 | #include <unistd.h> |
68 | #endif | 67 | #endif |
69 | 68 | ||
70 | 69 | ||
71 | struct { | 70 | struct { |
72 | bool enabled; | 71 | bool enabled; |
73 | const char *app; | 72 | const char *app; |
74 | const char *start; | 73 | const char *start; |
75 | const char *stop; | 74 | const char *stop; |
76 | const char *desc; | 75 | const char *desc; |
77 | } | 76 | } |
78 | settingsTable [] = | 77 | settingsTable [] = |
79 | { | 78 | { |
80 | { FALSE, "language", "raise()", "accept()", // No tr | 79 | { FALSE, "language", "raise()", "accept()", // No tr |
81 | QT_TR_NOOP("Language") }, | 80 | QT_TR_NOOP("Language") }, |
82 | #ifndef Q_OS_WIN32 | 81 | #ifndef Q_OS_WIN32 |
83 | { FALSE, "systemtime", "raise()", "accept()", // No tr | 82 | { FALSE, "systemtime", "raise()", "accept()", // No tr |
84 | QT_TR_NOOP("Time and Date") }, | 83 | QT_TR_NOOP("Time and Date") }, |
85 | #endif | 84 | #endif |
86 | { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr | 85 | { FALSE, "addressbook", "editPersonalAndClose()", "accept()", // No tr |
87 | QT_TR_NOOP("Personal Information") }, | 86 | QT_TR_NOOP("Personal Information") }, |
88 | { FALSE, 0, 0, 0, 0 } | 87 | { FALSE, 0, 0, 0, 0 } |
89 | }; | 88 | }; |
90 | 89 | ||
91 | 90 | ||
92 | FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : | 91 | FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : |
93 | QDialog( parent, name, TRUE, wf), | 92 | QDialog( parent, name, TRUE, wf), |
94 | transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1), | 93 | transApp(0), transLib(0), needCalibrate(FALSE), currApp(-1), |
95 | waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE) | 94 | waitForExit(-1), waitingForLaunch(FALSE), needRestart(FALSE) |
96 | { | 95 | { |
97 | ServerApplication::allowRestart = FALSE; | 96 | ServerApplication::allowRestart = FALSE; |
98 | // we force our height beyound the maximum (which we set anyway) | 97 | // we force our height beyound the maximum (which we set anyway) |
99 | QRect desk = qApp->desktop()->geometry(); | 98 | QRect desk = qApp->desktop()->geometry(); |
100 | setGeometry( 0, 0, desk.width(), desk.height() ); | 99 | setGeometry( 0, 0, desk.width(), desk.height() ); |
101 | 100 | ||
102 | connect(qwsServer, SIGNAL(newChannel(const QString&)), | 101 | connect(qwsServer, SIGNAL(newChannel(const QString&)), |
103 | this, SLOT(newQcopChannel(const QString&))); | 102 | this, SLOT(newQcopChannel(const QString&))); |
104 | 103 | ||
105 | // Create a DocumentList so appLauncher has appLnkSet to search | 104 | // Create a DocumentList so appLauncher has appLnkSet to search |
106 | docList = new DocumentList( 0, FALSE ); | 105 | docList = new DocumentList( 0, FALSE ); |
107 | appLauncher = new AppLauncher( this ); | 106 | appLauncher = new AppLauncher( this ); |
108 | connect( appLauncher, SIGNAL(terminated(int, const QString&)), | 107 | connect( appLauncher, SIGNAL(terminated(int, const QString&)), |
109 | this, SLOT(terminated(int, const QString&)) ); | 108 | this, SLOT(terminated(int, const QString&)) ); |
110 | 109 | ||
111 | // more hackery | 110 | // more hackery |
112 | // I will be run as either the main server or as part of the main server | 111 | // I will be run as either the main server or as part of the main server |
113 | QWSServer::setScreenSaverIntervals(0); | 112 | QWSServer::setScreenSaverIntervals(0); |
114 | loadPixmaps(); | 113 | loadPixmaps(); |
115 | 114 | ||
116 | //check if there is a language program | 115 | //check if there is a language program |
117 | #ifndef Q_OS_WIN32 | 116 | #ifndef Q_OS_WIN32 |
118 | QString exeSuffix; | 117 | QString exeSuffix; |
119 | #else | 118 | #else |
120 | QString exeSuffix(".exe"); | 119 | QString exeSuffix(".exe"); |
121 | #endif | 120 | #endif |
122 | 121 | ||
123 | for ( int i = 0; settingsTable[i].app; i++ ) { | 122 | for ( int i = 0; settingsTable[i].app; i++ ) { |
124 | QString file = QPEApplication::qpeDir() + "bin/"; | 123 | QString file = QPEApplication::qpeDir() + "bin/"; |
125 | file += settingsTable[i].app; | 124 | file += settingsTable[i].app; |
126 | file += exeSuffix; | 125 | file += exeSuffix; |
127 | if ( QFile::exists(file) ) | 126 | if ( QFile::exists(file) ) |
128 | settingsTable[i].enabled = TRUE; | 127 | settingsTable[i].enabled = TRUE; |
129 | } | 128 | } |
130 | 129 | ||
131 | setFocusPolicy(NoFocus); | 130 | setFocusPolicy(NoFocus); |
132 | 131 | ||
133 | taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader); | 132 | taskBar = new QWidget(0, 0, WStyle_Tool | WStyle_Customize | WStyle_StaysOnTop | WGroupLeader); |
134 | 133 | ||
135 | inputMethods = new InputMethods(taskBar); | 134 | inputMethods = new InputMethods(taskBar); |
136 | connect(inputMethods, SIGNAL(inputToggled(bool)), | 135 | connect(inputMethods, SIGNAL(inputToggled(bool)), |
137 | this, SLOT(calcMaxWindowRect())); | 136 | this, SLOT(calcMaxWindowRect())); |
138 | 137 | ||
139 | back = new QPushButton(tr("<< Back"), taskBar); | 138 | back = new QPushButton(tr("<< Back"), taskBar); |
140 | back->setFocusPolicy(NoFocus); | 139 | back->setFocusPolicy(NoFocus); |
141 | connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) ); | 140 | connect(back, SIGNAL(clicked()), this, SLOT(previousDialog()) ); |
142 | 141 | ||
143 | next = new QPushButton(tr("Next >>"), taskBar); | 142 | next = new QPushButton(tr("Next >>"), taskBar); |
144 | next->setFocusPolicy(NoFocus); | 143 | next->setFocusPolicy(NoFocus); |
145 | connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) ); | 144 | connect(next, SIGNAL(clicked()), this, SLOT(nextDialog()) ); |
146 | 145 | ||
147 | // need to set the geom to lower corner | 146 | // need to set the geom to lower corner |
148 | QSize sz = inputMethods->sizeHint(); | 147 | QSize sz = inputMethods->sizeHint(); |
149 | int buttonWidth = (width() - sz.width()) / 2; | 148 | int buttonWidth = (width() - sz.width()) / 2; |
150 | int x = 0; | 149 | int x = 0; |
151 | 150 | ||
152 | controlHeight = back->sizeHint().height(); | 151 | controlHeight = back->sizeHint().height(); |
153 | 152 | ||
154 | inputMethods->setGeometry(0,0, sz.width(), controlHeight ); | 153 | inputMethods->setGeometry(0,0, sz.width(), controlHeight ); |
155 | x += sz.width(); | 154 | x += sz.width(); |
156 | 155 | ||
157 | back->setGeometry(x, 0, buttonWidth, controlHeight); | 156 | back->setGeometry(x, 0, buttonWidth, controlHeight); |
158 | x += buttonWidth; | 157 | x += buttonWidth; |
159 | next->setGeometry(x, 0, buttonWidth, controlHeight); | 158 | next->setGeometry(x, 0, buttonWidth, controlHeight); |
160 | 159 | ||
161 | taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight); | 160 | taskBar->setGeometry( 0, height() - controlHeight, desk.width(), controlHeight); |
162 | taskBar->hide(); | 161 | taskBar->hide(); |
163 | 162 | ||
164 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 163 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
165 | qDebug("Setting up QCop to QPE/System"); | 164 | qDebug("Setting up QCop to QPE/System"); |
166 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); | 165 | QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); |
167 | connect(sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 166 | connect(sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
168 | this, SLOT(message(const QCString &, const QByteArray &)) ); | 167 | this, SLOT(message(const QCString &, const QByteArray &)) ); |
169 | #endif | 168 | #endif |
170 | calcMaxWindowRect(); | 169 | calcMaxWindowRect(); |
171 | #if defined(QPE_NEED_CALIBRATION) | 170 | |
172 | if ( !QFile::exists("/etc/pointercal") ) { | 171 | m_calHandler = ( QWSServer::mouseHandler() && QWSServer::mouseHandler()->inherits("QCalibratedMouseHandler") ) ? true : false; |
173 | needCalibrate = TRUE; | 172 | |
174 | grabMouse(); | 173 | if ( m_calHandler) { |
174 | if ( !QFile::exists("/etc/pointercal") ) { | ||
175 | needCalibrate = TRUE; | ||
176 | grabMouse(); | ||
177 | } | ||
175 | } | 178 | } |
176 | #endif | 179 | |
177 | Config config("locale"); | 180 | Config config("locale"); |
178 | config.setGroup( "Language"); | 181 | config.setGroup( "Language"); |
179 | lang = config.readEntry( "Language", "en"); | 182 | lang = config.readEntry( "Language", "en"); |
180 | 183 | ||
181 | defaultFont = font(); | 184 | defaultFont = font(); |
182 | 185 | ||
183 | //###language/font hack; should look it up somewhere | 186 | //###language/font hack; should look it up somewhere |
184 | #ifdef Q_WS_QWS | 187 | #ifdef Q_WS_QWS |
185 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 188 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
186 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 189 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
187 | qApp->setFont( fn, TRUE ); | 190 | qApp->setFont( fn, TRUE ); |
188 | } | 191 | } |
189 | #endif | 192 | #endif |
190 | } | 193 | } |
191 | 194 | ||
192 | FirstUse::~FirstUse() | 195 | FirstUse::~FirstUse() |
193 | { | 196 | { |
194 | delete appLauncher; | 197 | delete appLauncher; |
195 | delete docList; | 198 | delete docList; |
196 | delete taskBar; | 199 | delete taskBar; |
197 | ServerApplication::allowRestart = TRUE; | 200 | ServerApplication::allowRestart = TRUE; |
198 | } | 201 | } |
199 | 202 | ||
200 | void FirstUse::calcMaxWindowRect() | 203 | void FirstUse::calcMaxWindowRect() |
201 | { | 204 | { |
202 | #ifdef Q_WS_QWS | 205 | #ifdef Q_WS_QWS |
203 | QRect wr; | 206 | QRect wr; |
204 | int displayWidth = qApp->desktop()->width(); | 207 | int displayWidth = qApp->desktop()->width(); |
205 | QRect ir = inputMethods->inputRect(); | 208 | QRect ir = inputMethods->inputRect(); |
206 | if ( ir.isValid() ) { | 209 | if ( ir.isValid() ) { |
207 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); | 210 | wr.setCoords( 0, 0, displayWidth-1, ir.top()-1 ); |
208 | } else { | 211 | } else { |
209 | wr.setCoords( 0, 0, displayWidth-1, | 212 | wr.setCoords( 0, 0, displayWidth-1, |
210 | qApp->desktop()->height() - controlHeight-1); | 213 | qApp->desktop()->height() - controlHeight-1); |
211 | } | 214 | } |
212 | 215 | ||
213 | #if QT_VERSION < 0x030000 | 216 | #if QT_VERSION < 0x030000 |
214 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, | 217 | QWSServer::setMaxWindowRect( qt_screen->mapToDevice(wr, |
215 | QSize(qt_screen->width(),qt_screen->height())) | 218 | QSize(qt_screen->width(),qt_screen->height())) |
216 | ); | 219 | ); |
217 | #else | 220 | #else |
218 | QWSServer::setMaxWindowRect( wr ); | 221 | QWSServer::setMaxWindowRect( wr ); |
219 | #endif | 222 | #endif |
220 | #endif | 223 | #endif |
221 | } | 224 | } |
222 | 225 | ||
223 | /* cancel current dialog, and bring up next */ | 226 | /* cancel current dialog, and bring up next */ |
224 | void FirstUse::nextDialog() | 227 | void FirstUse::nextDialog() |
225 | { | 228 | { |
226 | int prevApp = currApp; | 229 | int prevApp = currApp; |
227 | do { | 230 | do { |
228 | currApp++; | 231 | currApp++; |
229 | qDebug( "currApp = %d", currApp ); | 232 | qDebug( "currApp = %d", currApp ); |
230 | if ( settingsTable[currApp].app == 0 ) { | 233 | if ( settingsTable[currApp].app == 0 ) { |
231 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { | 234 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { |
232 | // The last application is still running. | 235 | // The last application is still running. |
233 | // Tell it to stop, and when its done we'll come back | 236 | // Tell it to stop, and when its done we'll come back |
234 | // to nextDialog and exit. | 237 | // to nextDialog and exit. |
235 | qDebug( "Waiting for %s to exit", settingsTable[prevApp].app ); | 238 | qDebug( "Waiting for %s to exit", settingsTable[prevApp].app ); |
236 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 239 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
237 | settingsTable[prevApp].stop ); | 240 | settingsTable[prevApp].stop ); |
238 | currApp = prevApp; | 241 | currApp = prevApp; |
239 | } else { | 242 | } else { |
240 | qDebug( "Done!" ); | 243 | qDebug( "Done!" ); |
241 | Config config( "qpe" ); | 244 | Config config( "qpe" ); |
242 | config.setGroup( "Startup" ); | 245 | config.setGroup( "Startup" ); |
243 | config.writeEntry( "FirstUse", FALSE ); | 246 | config.writeEntry( "FirstUse", FALSE ); |
244 | QPixmap pix = Resource::loadPixmap("bigwait"); | 247 | QPixmap pix = Resource::loadPixmap("bigwait"); |
245 | QLabel *lblWait = new QLabel(0, "wait hack!", // No tr | 248 | QLabel *lblWait = new QLabel(0, "wait hack!", // No tr |
246 | QWidget::WStyle_Customize | QWidget::WDestructiveClose | | 249 | QWidget::WStyle_Customize | QWidget::WDestructiveClose | |
247 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | | 250 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | |
248 | QWidget::WStyle_StaysOnTop); | 251 | QWidget::WStyle_StaysOnTop); |
249 | lblWait->setPixmap( pix ); | 252 | lblWait->setPixmap( pix ); |
250 | lblWait->setAlignment( QWidget::AlignCenter ); | 253 | lblWait->setAlignment( QWidget::AlignCenter ); |
251 | lblWait->setGeometry( qApp->desktop()->geometry() ); | 254 | lblWait->setGeometry( qApp->desktop()->geometry() ); |
252 | lblWait->show(); | 255 | lblWait->show(); |
253 | qApp->processEvents(); | 256 | qApp->processEvents(); |
254 | QTimer::singleShot( 1000, lblWait, SLOT(close()) ); | 257 | QTimer::singleShot( 1000, lblWait, SLOT(close()) ); |
255 | repaint(); | 258 | repaint(); |
256 | close(); | 259 | close(); |
257 | ServerApplication::allowRestart = TRUE; | 260 | ServerApplication::allowRestart = TRUE; |
258 | } | 261 | } |
259 | return; | 262 | return; |
260 | } | 263 | } |
261 | } while ( !settingsTable[currApp].enabled ); | 264 | } while ( !settingsTable[currApp].enabled ); |
262 | 265 | ||
263 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { | 266 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { |
264 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); | 267 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); |
265 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 268 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
266 | settingsTable[prevApp].stop ); | 269 | settingsTable[prevApp].stop ); |
267 | waitForExit = prevApp; | 270 | waitForExit = prevApp; |
268 | } else { | 271 | } else { |
269 | qDebug( "Startup: %s", settingsTable[currApp].app ); | 272 | qDebug( "Startup: %s", settingsTable[currApp].app ); |
270 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, | 273 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, |
271 | settingsTable[currApp].start ); | 274 | settingsTable[currApp].start ); |
272 | waitingForLaunch = TRUE; | 275 | waitingForLaunch = TRUE; |
273 | } | 276 | } |
274 | 277 | ||
275 | updateButtons(); | 278 | updateButtons(); |
276 | } | 279 | } |
277 | 280 | ||
278 | /* accept current dialog and bring up previous */ | 281 | /* accept current dialog and bring up previous */ |
279 | void FirstUse::previousDialog() | 282 | void FirstUse::previousDialog() |
280 | { | 283 | { |
281 | int prevApp = currApp; | 284 | int prevApp = currApp; |
282 | do { | 285 | do { |
283 | currApp--; | 286 | currApp--; |
284 | if ( currApp < 0 ) { | 287 | if ( currApp < 0 ) { |
285 | currApp = prevApp; | 288 | currApp = prevApp; |
286 | return; | 289 | return; |
287 | } | 290 | } |
288 | } while ( !settingsTable[currApp].enabled ); | 291 | } while ( !settingsTable[currApp].enabled ); |
289 | 292 | ||
290 | if ( prevApp >= 0 ) { | 293 | if ( prevApp >= 0 ) { |
291 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); | 294 | qDebug( "Shutdown: %s", settingsTable[prevApp].app ); |
292 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 295 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
293 | settingsTable[prevApp].stop ); | 296 | settingsTable[prevApp].stop ); |
294 | /* | 297 | /* |
295 | if (settingsTable[prevApp].app == QString("systemtime")) | 298 | if (settingsTable[prevApp].app == QString("systemtime")) |
296 | QCopEnvelope e("QPE/Application/citytime", "close()"); | 299 | QCopEnvelope e("QPE/Application/citytime", "close()"); |
297 | */ | 300 | */ |
298 | waitForExit = prevApp; | 301 | waitForExit = prevApp; |
299 | } else { | 302 | } else { |
300 | qDebug( "Startup: %s", settingsTable[currApp].app ); | 303 | qDebug( "Startup: %s", settingsTable[currApp].app ); |
301 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, | 304 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, |
302 | settingsTable[currApp].start ); | 305 | settingsTable[currApp].start ); |
303 | waitingForLaunch = TRUE; | 306 | waitingForLaunch = TRUE; |
304 | } | 307 | } |
305 | 308 | ||
306 | updateButtons(); | 309 | updateButtons(); |
307 | } | 310 | } |
308 | 311 | ||
309 | void FirstUse::message(const QCString &msg, const QByteArray &data) | 312 | void FirstUse::message(const QCString &msg, const QByteArray &data) |
310 | { | 313 | { |
311 | QDataStream stream( data, IO_ReadOnly ); | 314 | QDataStream stream( data, IO_ReadOnly ); |
312 | if ( msg == "timeChange(QString)" ) { | 315 | if ( msg == "timeChange(QString)" ) { |
313 | QString t; | 316 | QString t; |
314 | stream >> t; | 317 | stream >> t; |
315 | if ( t.isNull() ) | 318 | if ( t.isNull() ) |
316 | unsetenv("TZ"); | 319 | unsetenv("TZ"); |
317 | else | 320 | else |
318 | setenv( "TZ", t.latin1(), 1 ); | 321 | setenv( "TZ", t.latin1(), 1 ); |
319 | } | 322 | } |
320 | } | 323 | } |
321 | 324 | ||
322 | void FirstUse::terminated( int, const QString &app ) | 325 | void FirstUse::terminated( int, const QString &app ) |
323 | { | 326 | { |
324 | qDebug( "--- terminated: %s", app.latin1() ); | 327 | qDebug( "--- terminated: %s", app.latin1() ); |
325 | if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) { | 328 | if ( waitForExit != -1 && settingsTable[waitForExit].app == app ) { |
326 | qDebug( "Startup: %s", settingsTable[currApp].app ); | 329 | qDebug( "Startup: %s", settingsTable[currApp].app ); |
327 | if ( settingsTable[waitForExit].app == "language" ) { // No tr | 330 | if ( settingsTable[waitForExit].app == "language" ) { // No tr |
328 | Config config("locale"); | 331 | Config config("locale"); |
329 | config.setGroup( "Language"); | 332 | config.setGroup( "Language"); |
@@ -398,120 +401,119 @@ void FirstUse::reloadLanguages() | |||
398 | qWarning("loading " + tfn); | 401 | qWarning("loading " + tfn); |
399 | if ( transApp->load(tfn) ) { | 402 | if ( transApp->load(tfn) ) { |
400 | qWarning("installing translator"); | 403 | qWarning("installing translator"); |
401 | qApp->installTranslator( transApp ); | 404 | qApp->installTranslator( transApp ); |
402 | } else { | 405 | } else { |
403 | delete transApp; | 406 | delete transApp; |
404 | transApp = 0; | 407 | transApp = 0; |
405 | } | 408 | } |
406 | 409 | ||
407 | transLib = new QTranslator(qApp); | 410 | transLib = new QTranslator(qApp); |
408 | tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm"; | 411 | tfn = QPEApplication::qpeDir() + "i18n/"+l+"/libqpe.qm"; |
409 | qWarning("loading " + tfn); | 412 | qWarning("loading " + tfn); |
410 | if ( transLib->load(tfn) ) { | 413 | if ( transLib->load(tfn) ) { |
411 | qWarning("installing translator library"); | 414 | qWarning("installing translator library"); |
412 | qApp->installTranslator( transLib ); | 415 | qApp->installTranslator( transLib ); |
413 | } else { | 416 | } else { |
414 | delete transLib; | 417 | delete transLib; |
415 | transLib = 0; | 418 | transLib = 0; |
416 | } | 419 | } |
417 | loadPixmaps(); | 420 | loadPixmaps(); |
418 | //###language/font hack; should look it up somewhere | 421 | //###language/font hack; should look it up somewhere |
419 | #ifdef Q_WS_QWS | 422 | #ifdef Q_WS_QWS |
420 | if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) { | 423 | if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) { |
421 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 424 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
422 | qApp->setFont( fn, TRUE ); | 425 | qApp->setFont( fn, TRUE ); |
423 | } else { | 426 | } else { |
424 | qApp->setFont( defaultFont, TRUE ); | 427 | qApp->setFont( defaultFont, TRUE ); |
425 | } | 428 | } |
426 | #endif | 429 | #endif |
427 | #endif | 430 | #endif |
428 | } | 431 | } |
429 | 432 | ||
430 | void FirstUse::paintEvent( QPaintEvent * ) | 433 | void FirstUse::paintEvent( QPaintEvent * ) |
431 | { | 434 | { |
432 | QPainter p( this ); | 435 | QPainter p( this ); |
433 | 436 | ||
434 | p.drawPixmap(0,0, splash); | 437 | p.drawPixmap(0,0, splash); |
435 | 438 | ||
436 | QFont f = p.font(); | 439 | QFont f = p.font(); |
437 | f.setPointSize(15); | 440 | f.setPointSize(15); |
438 | f.setItalic(FALSE); | 441 | f.setItalic(FALSE); |
439 | f.setBold(FALSE); | 442 | f.setBold(FALSE); |
440 | p.setFont(f); | 443 | p.setFont(f); |
441 | 444 | ||
442 | if ( currApp < 0 ) { | 445 | if ( currApp < 0 ) { |
443 | drawText(p, tr( "Tap anywhere on the screen to continue." )); | 446 | drawText(p, tr( "Tap anywhere on the screen to continue." )); |
444 | } else if ( settingsTable[currApp].app ) { | 447 | } else if ( settingsTable[currApp].app ) { |
445 | if ( waitingForLaunch ) | 448 | if ( waitingForLaunch ) |
446 | drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) ); | 449 | drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) ); |
447 | } else { | 450 | } else { |
448 | drawText(p, tr("Please wait...")); | 451 | drawText(p, tr("Please wait...")); |
449 | } | 452 | } |
450 | } | 453 | } |
451 | 454 | ||
452 | void FirstUse::loadPixmaps() | 455 | void FirstUse::loadPixmaps() |
453 | { | 456 | { |
454 | /* create background, tr so can change image with language. | 457 | /* create background, tr so can change image with language. |
455 | images will likely contain text. */ | 458 | images will likely contain text. */ |
456 | splash.convertFromImage( Resource::loadImage(tr("FirstUseBackground")) | 459 | splash.convertFromImage( Resource::loadImage(tr("FirstUseBackground")) |
457 | .smoothScale( width(), height() ) ); | 460 | .smoothScale( width(), height() ) ); |
458 | 461 | ||
459 | setBackgroundPixmap(splash); | 462 | setBackgroundPixmap(splash); |
460 | } | 463 | } |
461 | 464 | ||
462 | void FirstUse::drawText(QPainter &p, const QString &text) | 465 | void FirstUse::drawText(QPainter &p, const QString &text) |
463 | { | 466 | { |
464 | QString altered = "<CENTER>" + text + "</CENTER>"; | 467 | QString altered = "<CENTER>" + text + "</CENTER>"; |
465 | 468 | ||
466 | QSimpleRichText rt(altered, p.font()); | 469 | QSimpleRichText rt(altered, p.font()); |
467 | rt.setWidth(width() - 20); | 470 | rt.setWidth(width() - 20); |
468 | 471 | ||
469 | int h = (height() * 3) / 10; // start at 30% | 472 | int h = (height() * 3) / 10; // start at 30% |
470 | if (rt.height() < height() / 2) | 473 | if (rt.height() < height() / 2) |
471 | h += ((height() / 2) - rt.height()) / 2; | 474 | h += ((height() / 2) - rt.height()) / 2; |
472 | rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette()); | 475 | rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette()); |
473 | } | 476 | } |
474 | 477 | ||
475 | void FirstUse::updateButtons() | 478 | void FirstUse::updateButtons() |
476 | { | 479 | { |
477 | if ( currApp >= 0 ) { | 480 | if ( currApp >= 0 ) { |
478 | taskBar->show(); | 481 | taskBar->show(); |
479 | } | 482 | } |
480 | 483 | ||
481 | int i = currApp-1; | 484 | int i = currApp-1; |
482 | while ( i >= 0 && !settingsTable[i].enabled ) | 485 | while ( i >= 0 && !settingsTable[i].enabled ) |
483 | i--; | 486 | i--; |
484 | back->setText(tr("<< Back")); | 487 | back->setText(tr("<< Back")); |
485 | back->setEnabled( i >= 0 && !waitingForLaunch ); | 488 | back->setEnabled( i >= 0 && !waitingForLaunch ); |
486 | 489 | ||
487 | i = currApp+1; | 490 | i = currApp+1; |
488 | while ( settingsTable[i].app && !settingsTable[i].enabled ) | 491 | while ( settingsTable[i].app && !settingsTable[i].enabled ) |
489 | i++; | 492 | i++; |
490 | if ( !settingsTable[i].app ) | 493 | if ( !settingsTable[i].app ) |
491 | next->setText(tr("Finish")); | 494 | next->setText(tr("Finish")); |
492 | else | 495 | else |
493 | next->setText(tr("Next >>")); | 496 | next->setText(tr("Next >>")); |
497 | |||
494 | next->setEnabled( !waitingForLaunch ); | 498 | next->setEnabled( !waitingForLaunch ); |
495 | } | 499 | } |
496 | 500 | ||
497 | void FirstUse::keyPressEvent( QKeyEvent *e ) | 501 | void FirstUse::keyPressEvent( QKeyEvent *e ) |
498 | { | 502 | { |
499 | // Allow cancelling at first dialog, in case display is broken. | 503 | // Allow cancelling at first dialog, in case display is broken. |
500 | if ( e->key() == Key_Escape && currApp < 0 ) | 504 | if ( e->key() == Key_Escape && currApp < 0 ) |
501 | QDialog::keyPressEvent(e); | 505 | QDialog::keyPressEvent(e); |
502 | } | 506 | } |
503 | 507 | ||
504 | void FirstUse::mouseReleaseEvent( QMouseEvent * ) | 508 | void FirstUse::mouseReleaseEvent( QMouseEvent * ) |
505 | { | 509 | { |
506 | if ( currApp < 0 ) { | 510 | if ( currApp < 0 ) { |
507 | #if defined(QPE_NEED_CALIBRATION) | 511 | if ( m_calHandler && needCalibrate ) { |
508 | if ( needCalibrate ) { | ||
509 | releaseMouse(); | 512 | releaseMouse(); |
510 | Calibrate *cal = new Calibrate; | 513 | Calibrate *cal = new Calibrate; |
511 | cal->exec(); | 514 | cal->exec(); |
512 | delete cal; | 515 | delete cal; |
513 | } | 516 | } |
514 | #endif | ||
515 | nextDialog(); | 517 | nextDialog(); |
516 | } | 518 | } |
517 | } | 519 | } |
diff --git a/core/launcher/firstuse.h b/core/launcher/firstuse.h index 44a95a8..98858f8 100644 --- a/core/launcher/firstuse.h +++ b/core/launcher/firstuse.h | |||
@@ -1,84 +1,85 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qpixmap.h> | 22 | #include <qpixmap.h> |
23 | 23 | ||
24 | class InputMethods; | 24 | class InputMethods; |
25 | class QCString; | 25 | class QCString; |
26 | class QPushButton; | 26 | class QPushButton; |
27 | class QTranslator; | 27 | class QTranslator; |
28 | class AppLauncher; | 28 | class AppLauncher; |
29 | class DocumentList; | 29 | class DocumentList; |
30 | 30 | ||
31 | class FirstUse : public QDialog | 31 | class FirstUse : public QDialog |
32 | { | 32 | { |
33 | Q_OBJECT | 33 | Q_OBJECT |
34 | public: | 34 | public: |
35 | FirstUse(QWidget* parent=0, const char * name=0, WFlags=0); | 35 | FirstUse(QWidget* parent=0, const char * name=0, WFlags=0); |
36 | ~FirstUse(); | 36 | ~FirstUse(); |
37 | 37 | ||
38 | bool restartNeeded() const { return needRestart; } | 38 | bool restartNeeded() const { return needRestart; } |
39 | 39 | ||
40 | private slots: | 40 | private slots: |
41 | void message(const QCString &, const QByteArray &); | 41 | void message(const QCString &, const QByteArray &); |
42 | void calcMaxWindowRect(); | 42 | void calcMaxWindowRect(); |
43 | 43 | ||
44 | void nextDialog(); | 44 | void nextDialog(); |
45 | void previousDialog(); | 45 | void previousDialog(); |
46 | void terminated( int, const QString & ); | 46 | void terminated( int, const QString & ); |
47 | void newQcopChannel(const QString & ); | 47 | void newQcopChannel(const QString & ); |
48 | 48 | ||
49 | private: | 49 | private: |
50 | void paintEvent( QPaintEvent * ); | 50 | void paintEvent( QPaintEvent * ); |
51 | void mouseReleaseEvent( QMouseEvent * ); | 51 | void mouseReleaseEvent( QMouseEvent * ); |
52 | void keyPressEvent( QKeyEvent *e ); | 52 | void keyPressEvent( QKeyEvent *e ); |
53 | 53 | ||
54 | void loadPixmaps(); | 54 | void loadPixmaps(); |
55 | 55 | ||
56 | void reloadLanguages(); | 56 | void reloadLanguages(); |
57 | void drawText(QPainter &p, const QString &text); | 57 | void drawText(QPainter &p, const QString &text); |
58 | void updateButtons(); | 58 | void updateButtons(); |
59 | 59 | ||
60 | private: | 60 | private: |
61 | QPixmap splash; | 61 | QPixmap splash; |
62 | QPixmap buttons; | 62 | QPixmap buttons; |
63 | 63 | ||
64 | InputMethods *inputMethods; | 64 | InputMethods *inputMethods; |
65 | QPushButton *back; | 65 | QPushButton *back; |
66 | QPushButton *next; | 66 | QPushButton *next; |
67 | int controlHeight; | 67 | int controlHeight; |
68 | 68 | ||
69 | QString lang; | 69 | QString lang; |
70 | QTranslator *transApp; | 70 | QTranslator *transApp; |
71 | QTranslator *transLib; | 71 | QTranslator *transLib; |
72 | 72 | ||
73 | bool needCalibrate; | 73 | bool needCalibrate; |
74 | DocumentList *docList; | 74 | DocumentList *docList; |
75 | AppLauncher *appLauncher; | 75 | AppLauncher *appLauncher; |
76 | QWidget *taskBar; | 76 | QWidget *taskBar; |
77 | 77 | ||
78 | int currApp; | 78 | int currApp; |
79 | int waitForExit; | 79 | int waitForExit; |
80 | bool waitingForLaunch; | 80 | bool waitingForLaunch; |
81 | bool needRestart; | 81 | bool needRestart; |
82 | bool m_calHandler : 1; | ||
82 | 83 | ||
83 | QFont defaultFont; | 84 | QFont defaultFont; |
84 | }; | 85 | }; |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 075985d..ad40536 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -105,193 +105,194 @@ static void refreshTimeZoneConfig() | |||
105 | cfg.setGroup( "TimeZones" ); | 105 | cfg.setGroup( "TimeZones" ); |
106 | if (!cfg.hasKey( "Zone0" )){ | 106 | if (!cfg.hasKey( "Zone0" )){ |
107 | // We have no existing timezones use the defaults which are untranslated strings | 107 | // We have no existing timezones use the defaults which are untranslated strings |
108 | QString currTz = TimeZone::current().id(); | 108 | QString currTz = TimeZone::current().id(); |
109 | QStringList zoneDefaults; | 109 | QStringList zoneDefaults; |
110 | zoneDefaults.append( currTz ); | 110 | zoneDefaults.append( currTz ); |
111 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { | 111 | for ( int i = 0; defaultTz[i] && zoneDefaults.count() < 6; i++ ) { |
112 | if ( defaultTz[i] != currTz ) | 112 | if ( defaultTz[i] != currTz ) |
113 | zoneDefaults.append( defaultTz[i] ); | 113 | zoneDefaults.append( defaultTz[i] ); |
114 | } | 114 | } |
115 | zoneIndex = 0; | 115 | zoneIndex = 0; |
116 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ | 116 | for (QStringList::Iterator it = zoneDefaults.begin(); it != zoneDefaults.end() ; ++it){ |
117 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); | 117 | cfg.writeEntry( "Zone" + QString::number( zoneIndex ) , *it); |
118 | zoneIndex++; | 118 | zoneIndex++; |
119 | } | 119 | } |
120 | } | 120 | } |
121 | // We have an existing list of timezones refresh the | 121 | // We have an existing list of timezones refresh the |
122 | // translations of TimeZone name | 122 | // translations of TimeZone name |
123 | zoneIndex = 0; | 123 | zoneIndex = 0; |
124 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ | 124 | while (cfg.hasKey( "Zone"+ QString::number( zoneIndex ))){ |
125 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); | 125 | zoneID = cfg.readEntry( "Zone" + QString::number( zoneIndex )); |
126 | curZone = TimeZone( zoneID ); | 126 | curZone = TimeZone( zoneID ); |
127 | if ( !curZone.isValid() ){ | 127 | if ( !curZone.isValid() ){ |
128 | qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); | 128 | qDebug( "initEnvironment() Invalid TimeZone %s", zoneID.latin1() ); |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); | 131 | cfg.writeEntry( "ZoneName" + QString::number( zoneIndex ), curZone.city() ); |
132 | zoneIndex++; | 132 | zoneIndex++; |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | void initEnvironment() | 137 | void initEnvironment() |
138 | { | 138 | { |
139 | #ifdef Q_OS_WIN32 | 139 | #ifdef Q_OS_WIN32 |
140 | // Config file requires HOME dir which uses QDir which needs the winver | 140 | // Config file requires HOME dir which uses QDir which needs the winver |
141 | qt_init_winver(); | 141 | qt_init_winver(); |
142 | #endif | 142 | #endif |
143 | Config config("locale"); | 143 | Config config("locale"); |
144 | config.setGroup( "Location" ); | 144 | config.setGroup( "Location" ); |
145 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); | 145 | QString tz = config.readEntry( "Timezone", getenv("TZ") ).stripWhiteSpace(); |
146 | 146 | ||
147 | // if not timezone set, pick New York | 147 | // if not timezone set, pick New York |
148 | if (tz.isNull() || tz.isEmpty()) | 148 | if (tz.isNull() || tz.isEmpty()) |
149 | tz = "America/New_York"; | 149 | tz = "America/New_York"; |
150 | 150 | ||
151 | setenv( "TZ", tz, 1 ); | 151 | setenv( "TZ", tz, 1 ); |
152 | config.writeEntry( "Timezone", tz); | 152 | config.writeEntry( "Timezone", tz); |
153 | 153 | ||
154 | config.setGroup( "Language" ); | 154 | config.setGroup( "Language" ); |
155 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); | 155 | QString lang = config.readEntry( "Language", getenv("LANG") ).stripWhiteSpace(); |
156 | if( lang.isNull() || lang.isEmpty()) | 156 | if( lang.isNull() || lang.isEmpty()) |
157 | lang = "en_US"; | 157 | lang = "en_US"; |
158 | 158 | ||
159 | setenv( "LANG", lang, 1 ); | 159 | setenv( "LANG", lang, 1 ); |
160 | config.writeEntry("Language", lang); | 160 | config.writeEntry("Language", lang); |
161 | config.write(); | 161 | config.write(); |
162 | 162 | ||
163 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX) | 163 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_SL5XXX) |
164 | setenv( "QWS_SIZE", "240x320", 0 ); | 164 | setenv( "QWS_SIZE", "240x320", 0 ); |
165 | #endif | 165 | #endif |
166 | 166 | ||
167 | 167 | ||
168 | 168 | ||
169 | QString env(getenv("QWS_DISPLAY")); | 169 | QString env(getenv("QWS_DISPLAY")); |
170 | if (env.contains("Transformed")) { | 170 | if (env.contains("Transformed")) { |
171 | int rot; | 171 | int rot; |
172 | // transformed driver default rotation is controlled by the hardware. | 172 | // transformed driver default rotation is controlled by the hardware. |
173 | Config config("qpe"); | 173 | Config config("qpe"); |
174 | config.setGroup( "Rotation" ); | 174 | config.setGroup( "Rotation" ); |
175 | if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) | 175 | if ( ( rot = config.readNumEntry( "Rot", -1 ) ) == -1 ) |
176 | rot = ODevice::inst ( )-> rotation ( ) * 90; | 176 | rot = ODevice::inst ( )-> rotation ( ) * 90; |
177 | 177 | ||
178 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 178 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); |
179 | QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ | 179 | QPEApplication::defaultRotation ( ); /* to ensure deforient matches reality */ |
180 | } | 180 | } |
181 | } | 181 | } |
182 | 182 | ||
183 | static void initKeyboard() | 183 | static void initKeyboard() |
184 | { | 184 | { |
185 | Config config("qpe"); | 185 | Config config("qpe"); |
186 | 186 | ||
187 | config.setGroup( "Keyboard" ); | 187 | config.setGroup( "Keyboard" ); |
188 | 188 | ||
189 | int ard = config.readNumEntry( "RepeatDelay" ); | 189 | int ard = config.readNumEntry( "RepeatDelay" ); |
190 | int arp = config.readNumEntry( "RepeatPeriod" ); | 190 | int arp = config.readNumEntry( "RepeatPeriod" ); |
191 | if ( ard > 0 && arp > 0 ) | 191 | if ( ard > 0 && arp > 0 ) |
192 | qwsSetKeyboardAutoRepeat( ard, arp ); | 192 | qwsSetKeyboardAutoRepeat( ard, arp ); |
193 | 193 | ||
194 | QString layout = config.readEntry( "Layout", "us101" ); | 194 | QString layout = config.readEntry( "Layout", "us101" ); |
195 | Server::setKeyboardLayout( layout ); | 195 | Server::setKeyboardLayout( layout ); |
196 | } | 196 | } |
197 | 197 | ||
198 | static bool firstUse() | 198 | static bool firstUse() |
199 | { | 199 | { |
200 | bool needFirstUse = FALSE; | 200 | bool needFirstUse = FALSE; |
201 | if ( QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { | 201 | if ( QWSServer::mouseHandler() && |
202 | QWSServer::mouseHandler() ->inherits("QCalibratedMouseHandler") ) { | ||
202 | if ( !QFile::exists( "/etc/pointercal" ) ) | 203 | if ( !QFile::exists( "/etc/pointercal" ) ) |
203 | needFirstUse = TRUE; | 204 | needFirstUse = TRUE; |
204 | } | 205 | } |
205 | 206 | ||
206 | { | 207 | { |
207 | Config config( "qpe" ); | 208 | Config config( "qpe" ); |
208 | config.setGroup( "Startup" ); | 209 | config.setGroup( "Startup" ); |
209 | needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); | 210 | needFirstUse |= config.readBoolEntry( "FirstUse", TRUE ); |
210 | } | 211 | } |
211 | 212 | ||
212 | if ( !needFirstUse ) | 213 | if ( !needFirstUse ) |
213 | return FALSE; | 214 | return FALSE; |
214 | 215 | ||
215 | FirstUse *fu = new FirstUse(); | 216 | FirstUse *fu = new FirstUse(); |
216 | fu->exec(); | 217 | fu->exec(); |
217 | bool rs = fu->restartNeeded(); | 218 | bool rs = fu->restartNeeded(); |
218 | delete fu; | 219 | delete fu; |
219 | return rs; | 220 | return rs; |
220 | } | 221 | } |
221 | 222 | ||
222 | int initApplication( int argc, char ** argv ) | 223 | int initApplication( int argc, char ** argv ) |
223 | { | 224 | { |
224 | cleanup(); | 225 | cleanup(); |
225 | 226 | ||
226 | 227 | ||
227 | initEnvironment(); | 228 | initEnvironment(); |
228 | 229 | ||
229 | //Don't flicker at startup: | 230 | //Don't flicker at startup: |
230 | #ifdef QWS | 231 | #ifdef QWS |
231 | QWSServer::setDesktopBackground( QImage() ); | 232 | QWSServer::setDesktopBackground( QImage() ); |
232 | #endif | 233 | #endif |
233 | ServerApplication a( argc, argv, QApplication::GuiServer ); | 234 | ServerApplication a( argc, argv, QApplication::GuiServer ); |
234 | 235 | ||
235 | refreshTimeZoneConfig(); | 236 | refreshTimeZoneConfig(); |
236 | 237 | ||
237 | initKeyboard(); | 238 | initKeyboard(); |
238 | 239 | ||
239 | // Don't use first use under Windows | 240 | // Don't use first use under Windows |
240 | if ( firstUse() ) { | 241 | if ( firstUse() ) { |
241 | a.restart(); | 242 | a.restart(); |
242 | return 0; | 243 | return 0; |
243 | } | 244 | } |
244 | 245 | ||
245 | ODevice::inst ( )-> setSoftSuspend ( true ); | 246 | ODevice::inst ( )-> setSoftSuspend ( true ); |
246 | 247 | ||
247 | { | 248 | { |
248 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 249 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
249 | e << -3; // Forced on | 250 | e << -3; // Forced on |
250 | } | 251 | } |
251 | 252 | ||
252 | AlarmServer::initialize(); | 253 | AlarmServer::initialize(); |
253 | 254 | ||
254 | 255 | ||
255 | 256 | ||
256 | Server *s = new Server(); | 257 | Server *s = new Server(); |
257 | 258 | ||
258 | (void)new SysFileMonitor(s); | 259 | (void)new SysFileMonitor(s); |
259 | #ifdef QWS | 260 | #ifdef QWS |
260 | Network::createServer(s); | 261 | Network::createServer(s); |
261 | #endif | 262 | #endif |
262 | 263 | ||
263 | s->show(); | 264 | s->show(); |
264 | 265 | ||
265 | /* THE ARM rtc has problem holdings the time on reset */ | 266 | /* THE ARM rtc has problem holdings the time on reset */ |
266 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { | 267 | if ( QDate::currentDate ( ). year ( ) < 2000 ) { |
267 | if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { | 268 | if ( QMessageBox::information ( 0, ServerApplication::tr( "Information" ), ServerApplication::tr( "<p>The system date doesn't seem to be valid.\n(%1)</p><p>Do you want to correct the clock ?</p>" ). arg( TimeString::dateString ( QDate::currentDate ( ))), QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { |
268 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); | 269 | QCopEnvelope e ( "QPE/Application/systemtime", "setDocument(QString)" ); |
269 | e << QString ( ); | 270 | e << QString ( ); |
270 | } | 271 | } |
271 | } | 272 | } |
272 | 273 | ||
273 | int rv = a.exec(); | 274 | int rv = a.exec(); |
274 | 275 | ||
275 | qDebug("exiting..."); | 276 | qDebug("exiting..."); |
276 | delete s; | 277 | delete s; |
277 | 278 | ||
278 | ODevice::inst()->setSoftSuspend( false ); | 279 | ODevice::inst()->setSoftSuspend( false ); |
279 | 280 | ||
280 | return rv; | 281 | return rv; |
281 | } | 282 | } |
282 | 283 | ||
283 | static const char *pidfile_path = "/var/run/opie.pid"; | 284 | static const char *pidfile_path = "/var/run/opie.pid"; |
284 | 285 | ||
285 | void create_pidfile ( ) | 286 | void create_pidfile ( ) |
286 | { | 287 | { |
287 | FILE *f; | 288 | FILE *f; |
288 | 289 | ||
289 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 290 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
290 | ::fprintf ( f, "%d", getpid ( )); | 291 | ::fprintf ( f, "%d", getpid ( )); |
291 | ::fclose ( f ); | 292 | ::fclose ( f ); |
292 | } | 293 | } |
293 | } | 294 | } |
294 | 295 | ||
295 | void remove_pidfile ( ) | 296 | void remove_pidfile ( ) |
296 | { | 297 | { |
297 | ::unlink ( pidfile_path ); | 298 | ::unlink ( pidfile_path ); |