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 | |||
@@ -17,35 +17,34 @@ | |||
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> |
@@ -155,38 +154,42 @@ FirstUse::FirstUse(QWidget* parent, const char * name, WFlags wf) : | |||
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() |
@@ -217,33 +220,33 @@ void FirstUse::calcMaxWindowRect() | |||
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 ); |
@@ -478,40 +481,39 @@ void FirstUse::updateButtons() | |||
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 | |||
@@ -66,19 +66,20 @@ private: | |||
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 | |||
@@ -185,33 +185,34 @@ static void initKeyboard() | |||
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(); |