author | llornkcor <llornkcor> | 2002-04-14 13:09:32 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-04-14 13:09:32 (UTC) |
commit | ac6b7c674438e06fd1c7648aae50539f14a62789 (patch) (unidiff) | |
tree | 268edab34cd30dc1bbb6b23bdbd875870abfb1d4 | |
parent | ac3b5af140135bca092bd442a43b110ed8366e67 (diff) | |
download | opie-ac6b7c674438e06fd1c7648aae50539f14a62789.zip opie-ac6b7c674438e06fd1c7648aae50539f14a62789.tar.gz opie-ac6b7c674438e06fd1c7648aae50539f14a62789.tar.bz2 |
changed char *'s to QStringList for better internationalization
-rw-r--r-- | noncore/games/tictac/tictac.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/noncore/games/tictac/tictac.cpp b/noncore/games/tictac/tictac.cpp index 20cc942..3d727ac 100644 --- a/noncore/games/tictac/tictac.cpp +++ b/noncore/games/tictac/tictac.cpp | |||
@@ -1,44 +1,45 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | #include "tictac.h" | 11 | #include "tictac.h" |
12 | #include <qpe/qpeapplication.h> | 12 | #include <qpe/qpeapplication.h> |
13 | #include <qpainter.h> | 13 | #include <qpainter.h> |
14 | #include <qdrawutil.h> | 14 | #include <qdrawutil.h> |
15 | #include <qcombobox.h> | 15 | #include <qcombobox.h> |
16 | #include <qcheckbox.h> | 16 | #include <qcheckbox.h> |
17 | #include <qlabel.h> | 17 | #include <qlabel.h> |
18 | #include <qlayout.h> | 18 | #include <qlayout.h> |
19 | #include <stdlib.h> // rand() function | 19 | #include <stdlib.h> // rand() function |
20 | #include <qdatetime.h> // seed for rand() | 20 | #include <qdatetime.h> // seed for rand() |
21 | #include <qstringlist.h> //needed for proper internationalization | ||
21 | 22 | ||
22 | 23 | ||
23 | //*************************************************************************** | 24 | //*************************************************************************** |
24 | //* TicTacButton member functions | 25 | //* TicTacButton member functions |
25 | //*************************************************************************** | 26 | //*************************************************************************** |
26 | 27 | ||
27 | // -------------------------------------------------------------------------- | 28 | // -------------------------------------------------------------------------- |
28 | // Creates a TicTacButton | 29 | // Creates a TicTacButton |
29 | // | 30 | // |
30 | 31 | ||
31 | TicTacButton::TicTacButton( QWidget *parent ) : QPushButton( parent ) | 32 | TicTacButton::TicTacButton( QWidget *parent ) : QPushButton( parent ) |
32 | { | 33 | { |
33 | t = Blank; // initial type | 34 | t = Blank; // initial type |
34 | } | 35 | } |
35 | 36 | ||
36 | // -------------------------------------------------------------------------- | 37 | // -------------------------------------------------------------------------- |
37 | // Paints TicTacButton | 38 | // Paints TicTacButton |
38 | // | 39 | // |
39 | 40 | ||
40 | void TicTacButton::drawButtonLabel( QPainter *p ) | 41 | void TicTacButton::drawButtonLabel( QPainter *p ) |
41 | { | 42 | { |
42 | QRect r = rect(); | 43 | QRect r = rect(); |
43 | p->setPen( QPen( white,2 ) ); // set fat pen | 44 | p->setPen( QPen( white,2 ) ); // set fat pen |
44 | if ( t == Circle ) { | 45 | if ( t == Circle ) { |
@@ -348,30 +349,33 @@ void TicTacToe::newGameClicked() | |||
348 | board->newGame(); | 349 | board->newGame(); |
349 | newState(); | 350 | newState(); |
350 | } | 351 | } |
351 | 352 | ||
352 | 353 | ||
353 | // -------------------------------------------------------------------------- | 354 | // -------------------------------------------------------------------------- |
354 | // TicTacToe::gameOver() - SLOT | 355 | // TicTacToe::gameOver() - SLOT |
355 | // | 356 | // |
356 | // This slot is activated when the TicTacGameBoard emits the signal | 357 | // This slot is activated when the TicTacGameBoard emits the signal |
357 | // "finished()", i.e. when a player has won or when it is a draw. | 358 | // "finished()", i.e. when a player has won or when it is a draw. |
358 | // | 359 | // |
359 | 360 | ||
360 | void TicTacToe::gameOver() | 361 | void TicTacToe::gameOver() |
361 | { | 362 | { |
362 | newState(); // update text box | 363 | newState(); // update text box |
363 | } | 364 | } |
364 | 365 | ||
365 | 366 | ||
366 | // -------------------------------------------------------------------------- | 367 | // -------------------------------------------------------------------------- |
367 | // Updates the message to reflect a new state. | 368 | // Updates the message to reflect a new state. |
368 | // | 369 | // |
369 | 370 | ||
370 | void TicTacToe::newState() | 371 | void TicTacToe::newState() |
371 | { | 372 | { |
372 | static const char *msg[] = { // TicTacGameBoard::State texts | 373 | QStringList msg; |
373 | "Click Play to start", "Make your move", | 374 | msg << tr( "Click Play to start") |
374 | "You won!", "Computer won!", "It's a draw" }; | 375 | << tr("Make your move") |
376 | << tr("You won!") | ||
377 | << tr("Computer won!") | ||
378 | << tr("It's a draw"); | ||
375 | message->setText( msg[board->state()] ); | 379 | message->setText( msg[board->state()] ); |
376 | return; | 380 | return; |
377 | } | 381 | } |