-rw-r--r-- | core/launcher/firstuse.cpp | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/core/launcher/firstuse.cpp b/core/launcher/firstuse.cpp index 8344787..8c02ab0 100644 --- a/core/launcher/firstuse.cpp +++ b/core/launcher/firstuse.cpp | |||
@@ -1,61 +1,68 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | This file is part of the Opie Project |
3 | ** | 3 | =. (C) 2000-2002 Trolltech AS |
4 | ** This file is part of the Qtopia Environment. | 4 | .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> |
5 | ** | 5 | .>+-= |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | _;:, .> :=|. This program is free software; you can |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | ** packaging of this file. | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | ** | 10 | - . .-<_> .<> Foundation; version 2 of the License. |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ._= =} : |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | .%`+i> _;_. |
13 | ** | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | ** | 15 | : .. .:, . . . without even the implied warranty of |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | ** not clear to you. | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ** | 18 | ..}^=.= = ; Library General Public License for more |
19 | **********************************************************************/ | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
20 | 28 | ||
21 | // I need access to some things you don't normally get access to. | 29 | // I need access to some things you don't normally get access to. |
22 | |||
23 | #ifndef _MSC_VER | 30 | #ifndef _MSC_VER |
24 | //### revise to allow removal of translators under MSVC | 31 | //### revise to allow removal of translators under MSVC |
25 | #define private public | 32 | #define private public |
26 | #define protected public | 33 | #define protected public |
27 | #endif | 34 | #endif |
28 | #include "firstuse.h" | 35 | #include "firstuse.h" |
29 | #include "inputmethods.h" | 36 | #include "inputmethods.h" |
30 | #include "applauncher.h" | 37 | #include "applauncher.h" |
31 | #include "serverapp.h" | 38 | #include "serverapp.h" |
32 | #include "calibrate.h" | 39 | #include "calibrate.h" |
33 | #include "documentlist.h" | 40 | #include "documentlist.h" |
34 | 41 | ||
35 | /* OPIE */ | 42 | /* OPIE */ |
36 | #include <opie2/odebug.h> | 43 | #include <opie2/odebug.h> |
37 | #include <qtopia/resource.h> | 44 | #include <opie2/oresource.h> |
38 | #include <qtopia/qcopenvelope_qws.h> | 45 | #include <qtopia/qcopenvelope_qws.h> |
39 | #include <qtopia/config.h> | 46 | #include <qtopia/config.h> |
40 | #include <qtopia/fontmanager.h> | 47 | #include <qtopia/fontmanager.h> |
41 | using namespace Opie::Core; | 48 | using namespace Opie::Core; |
42 | 49 | ||
43 | /* QT */ | 50 | /* QT */ |
44 | #include <qfile.h> | 51 | #include <qfile.h> |
45 | #include <qpainter.h> | 52 | #include <qpainter.h> |
46 | #include <qsimplerichtext.h> | 53 | #include <qsimplerichtext.h> |
47 | #include <qpushbutton.h> | 54 | #include <qpushbutton.h> |
48 | #include <qlabel.h> | 55 | #include <qlabel.h> |
49 | #include <qtimer.h> | 56 | #include <qtimer.h> |
50 | 57 | ||
51 | #if defined( Q_WS_QWS ) | 58 | #if defined( Q_WS_QWS ) |
52 | #include <qwsdisplay_qws.h> | 59 | #include <qwsdisplay_qws.h> |
53 | #include <qgfx_qws.h> | 60 | #include <qgfx_qws.h> |
54 | #endif | 61 | #endif |
55 | 62 | ||
56 | /* STD */ | 63 | /* STD */ |
57 | #include <stdlib.h> | 64 | #include <stdlib.h> |
58 | #include <sys/types.h> | 65 | #include <sys/types.h> |
59 | #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) | 66 | #if defined(Q_OS_LINUX) || defined(_OS_LINUX_) |
60 | #include <unistd.h> | 67 | #include <unistd.h> |
61 | #endif | 68 | #endif |
@@ -220,54 +227,52 @@ void FirstUse::calcMaxWindowRect() | |||
220 | #endif | 227 | #endif |
221 | } | 228 | } |
222 | 229 | ||
223 | /* cancel current dialog, and bring up next */ | 230 | /* cancel current dialog, and bring up next */ |
224 | void FirstUse::nextDialog() | 231 | void FirstUse::nextDialog() |
225 | { | 232 | { |
226 | int prevApp = currApp; | 233 | int prevApp = currApp; |
227 | do { | 234 | do { |
228 | currApp++; | 235 | currApp++; |
229 | odebug << "currApp = " << currApp << "" << oendl; | 236 | odebug << "currApp = " << currApp << "" << oendl; |
230 | if ( settingsTable[currApp].app == 0 ) { | 237 | if ( settingsTable[currApp].app == 0 ) { |
231 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { | 238 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { |
232 | // The last application is still running. | 239 | // The last application is still running. |
233 | // Tell it to stop, and when its done we'll come back | 240 | // Tell it to stop, and when its done we'll come back |
234 | // to nextDialog and exit. | 241 | // to nextDialog and exit. |
235 | odebug << "Waiting for " << settingsTable[prevApp].app << " to exit" << oendl; | 242 | odebug << "Waiting for " << settingsTable[prevApp].app << " to exit" << oendl; |
236 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 243 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
237 | settingsTable[prevApp].stop ); | 244 | settingsTable[prevApp].stop ); |
238 | currApp = prevApp; | 245 | currApp = prevApp; |
239 | } else { | 246 | } else { |
240 | odebug << "Done!" << oendl; | 247 | odebug << "Done!" << oendl; |
241 | Config config( "qpe" ); | 248 | Config config( "qpe" ); |
242 | config.setGroup( "Startup" ); | 249 | config.setGroup( "Startup" ); |
243 | config.writeEntry( "FirstUse", FALSE ); | 250 | config.writeEntry( "FirstUse", FALSE ); |
244 | QPixmap pix = Resource::loadPixmap("bigwait"); | 251 | QLabel *lblWait = new QLabel("Please Wait...", 0, "wait hack!", // No tr |
245 | QLabel *lblWait = new QLabel(0, "wait hack!", // No tr | ||
246 | QWidget::WStyle_Customize | QWidget::WDestructiveClose | | 252 | QWidget::WStyle_Customize | QWidget::WDestructiveClose | |
247 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | | 253 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool | |
248 | QWidget::WStyle_StaysOnTop); | 254 | QWidget::WStyle_StaysOnTop); |
249 | lblWait->setPixmap( pix ); | ||
250 | lblWait->setAlignment( QWidget::AlignCenter ); | 255 | lblWait->setAlignment( QWidget::AlignCenter ); |
251 | lblWait->setGeometry( qApp->desktop()->geometry() ); | 256 | lblWait->setGeometry( qApp->desktop()->geometry() ); |
252 | lblWait->show(); | 257 | lblWait->show(); |
253 | qApp->processEvents(); | 258 | qApp->processEvents(); |
254 | QTimer::singleShot( 1000, lblWait, SLOT(close()) ); | 259 | QTimer::singleShot( 1000, lblWait, SLOT(close()) ); |
255 | repaint(); | 260 | repaint(); |
256 | close(); | 261 | close(); |
257 | ServerApplication::allowRestart = TRUE; | 262 | ServerApplication::allowRestart = TRUE; |
258 | } | 263 | } |
259 | return; | 264 | return; |
260 | } | 265 | } |
261 | } while ( !settingsTable[currApp].enabled ); | 266 | } while ( !settingsTable[currApp].enabled ); |
262 | 267 | ||
263 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { | 268 | if ( prevApp >= 0 && appLauncher->isRunning(settingsTable[prevApp].app) ) { |
264 | odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl; | 269 | odebug << "Shutdown: " << settingsTable[prevApp].app << "" << oendl; |
265 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, | 270 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[prevApp].app, |
266 | settingsTable[prevApp].stop ); | 271 | settingsTable[prevApp].stop ); |
267 | waitForExit = prevApp; | 272 | waitForExit = prevApp; |
268 | } else { | 273 | } else { |
269 | odebug << "Startup: " << settingsTable[currApp].app << "" << oendl; | 274 | odebug << "Startup: " << settingsTable[currApp].app << "" << oendl; |
270 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, | 275 | QCopEnvelope e(QCString("QPE/Application/") + settingsTable[currApp].app, |
271 | settingsTable[currApp].start ); | 276 | settingsTable[currApp].start ); |
272 | waitingForLaunch = TRUE; | 277 | waitingForLaunch = TRUE; |
273 | } | 278 | } |
@@ -409,70 +414,63 @@ void FirstUse::reloadLanguages() | |||
409 | owarn << "loading " + tfn << oendl; | 414 | owarn << "loading " + tfn << oendl; |
410 | if ( transLib->load(tfn) ) { | 415 | if ( transLib->load(tfn) ) { |
411 | owarn << "installing translator library" << oendl; | 416 | owarn << "installing translator library" << oendl; |
412 | qApp->installTranslator( transLib ); | 417 | qApp->installTranslator( transLib ); |
413 | } else { | 418 | } else { |
414 | delete transLib; | 419 | delete transLib; |
415 | transLib = 0; | 420 | transLib = 0; |
416 | } | 421 | } |
417 | loadPixmaps(); | 422 | loadPixmaps(); |
418 | //###language/font hack; should look it up somewhere | 423 | //###language/font hack; should look it up somewhere |
419 | #ifdef Q_WS_QWS | 424 | #ifdef Q_WS_QWS |
420 | if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) { | 425 | if ( l == "ja" || l == "zh_CN" || l == "zh_TW" || l == "ko" ) { |
421 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 426 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
422 | qApp->setFont( fn, TRUE ); | 427 | qApp->setFont( fn, TRUE ); |
423 | } else { | 428 | } else { |
424 | qApp->setFont( defaultFont, TRUE ); | 429 | qApp->setFont( defaultFont, TRUE ); |
425 | } | 430 | } |
426 | #endif | 431 | #endif |
427 | #endif | 432 | #endif |
428 | } | 433 | } |
429 | 434 | ||
430 | void FirstUse::paintEvent( QPaintEvent * ) | 435 | void FirstUse::paintEvent( QPaintEvent * ) |
431 | { | 436 | { |
432 | QPainter p( this ); | 437 | QPainter p( this ); |
433 | |||
434 | p.drawPixmap(0,0, splash); | 438 | p.drawPixmap(0,0, splash); |
435 | 439 | ||
436 | QFont f = p.font(); | ||
437 | f.setPointSize(15); | ||
438 | f.setItalic(FALSE); | ||
439 | f.setBold(FALSE); | ||
440 | p.setFont(f); | ||
441 | |||
442 | if ( currApp < 0 ) { | 440 | if ( currApp < 0 ) { |
443 | drawText(p, tr( "Tap anywhere on the screen to continue." )); | 441 | drawText(p, tr( "Tap anywhere on the screen to continue." )); |
444 | } else if ( settingsTable[currApp].app ) { | 442 | } else if ( settingsTable[currApp].app ) { |
445 | if ( waitingForLaunch ) | 443 | if ( waitingForLaunch ) |
446 | drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) ); | 444 | drawText(p, tr("Please wait, loading %1 settings.").arg(tr(settingsTable[currApp].desc)) ); |
447 | } else { | 445 | } else { |
448 | drawText(p, tr("Please wait...")); | 446 | drawText(p, tr("Please wait...")); |
449 | } | 447 | } |
450 | } | 448 | } |
451 | 449 | ||
452 | void FirstUse::loadPixmaps() | 450 | void FirstUse::loadPixmaps() |
453 | { | 451 | { |
454 | splash.convertFromImage( Resource::loadImage("launcher/firstuse") | 452 | splash.convertFromImage( OResource::loadImage("launcher/firstuse", OResource::NoScale ) |
455 | .smoothScale( width(), height() ) ); | 453 | .smoothScale( width(), height() ) ); |
456 | 454 | ||
457 | setBackgroundPixmap(splash); | 455 | setBackgroundPixmap(splash); |
458 | } | 456 | } |
459 | 457 | ||
460 | void FirstUse::drawText(QPainter &p, const QString &text) | 458 | void FirstUse::drawText(QPainter &p, const QString &text) |
461 | { | 459 | { |
462 | QString altered = "<CENTER>" + text + "</CENTER>"; | 460 | QString altered = "<CENTER>" + text + "</CENTER>"; |
463 | 461 | ||
464 | QSimpleRichText rt(altered, p.font()); | 462 | QSimpleRichText rt(altered, p.font()); |
465 | rt.setWidth(width() - 20); | 463 | rt.setWidth(width() - 20); |
466 | 464 | ||
467 | int h = (height() * 3) / 10; // start at 30% | 465 | int h = (height() * 3) / 10; // start at 30% |
468 | if (rt.height() < height() / 2) | 466 | if (rt.height() < height() / 2) |
469 | h += ((height() / 2) - rt.height()) / 2; | 467 | h += ((height() / 2) - rt.height()) / 2; |
470 | rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette()); | 468 | rt.draw(&p, 10, h, QRegion(0,0, width()-20, height()), palette()); |
471 | } | 469 | } |
472 | 470 | ||
473 | void FirstUse::updateButtons() | 471 | void FirstUse::updateButtons() |
474 | { | 472 | { |
475 | if ( currApp >= 0 ) { | 473 | if ( currApp >= 0 ) { |
476 | taskBar->show(); | 474 | taskBar->show(); |
477 | } | 475 | } |
478 | 476 | ||