Diffstat (limited to 'noncore/games/minesweep/minesweep.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/minesweep/minesweep.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/noncore/games/minesweep/minesweep.cpp b/noncore/games/minesweep/minesweep.cpp index 7214a73..d707dab 100644 --- a/noncore/games/minesweep/minesweep.cpp +++ b/noncore/games/minesweep/minesweep.cpp | |||
@@ -1,10 +1,10 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of 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 | ** |
@@ -18,17 +18,17 @@ | |||
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "minesweep.h" | 21 | #include "minesweep.h" |
22 | #include "minefield.h" | 22 | #include "minefield.h" |
23 | 23 | ||
24 | #include <qpe/qpeapplication.h> | 24 | #include <qtopia/qpeapplication.h> |
25 | #include <qpe/resource.h> | 25 | #include <qtopia/resource.h> |
26 | #include <qpe/config.h> | 26 | #include <qtopia/config.h> |
27 | 27 | ||
28 | #include <qpe/qpetoolbar.h> | 28 | #include <qtoolbar.h> |
29 | #include <qmenubar.h> | 29 | #include <qmenubar.h> |
30 | #include <qpopupmenu.h> | 30 | #include <qpopupmenu.h> |
31 | #include <qpushbutton.h> | 31 | #include <qpushbutton.h> |
32 | #include <qlcdnumber.h> | 32 | #include <qlcdnumber.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qtimer.h> | 34 | #include <qtimer.h> |
@@ -195,12 +195,13 @@ void ResultIndicator::showResult( QWidget *ref, bool won ) | |||
195 | void ResultIndicator::center() | 195 | void ResultIndicator::center() |
196 | { | 196 | { |
197 | QWidget *w = parentWidget(); | 197 | QWidget *w = parentWidget(); |
198 | 198 | ||
199 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); | 199 | QPoint pp = w->mapToGlobal( QPoint(0,0) ); |
200 | QSize s = sizeHint()*3; | 200 | QSize s = sizeHint()*3; |
201 | s.setWidth( QMIN(s.width(), w->width()) ); | ||
201 | pp = QPoint( pp.x() + w->width()/2 - s.width()/2, | 202 | pp = QPoint( pp.x() + w->width()/2 - s.width()/2, |
202 | pp.y() + w->height()/ 2 - s.height()/2 ); | 203 | pp.y() + w->height()/ 2 - s.height()/2 ); |
203 | 204 | ||
204 | setGeometry( QRect(pp, s) ); | 205 | setGeometry( QRect(pp, s) ); |
205 | 206 | ||
206 | } | 207 | } |
@@ -221,14 +222,17 @@ void ResultIndicator::timerEvent( QTimerEvent *te ) | |||
221 | 222 | ||
222 | 223 | ||
223 | class MineFrame : public QFrame | 224 | class MineFrame : public QFrame |
224 | { | 225 | { |
225 | public: | 226 | public: |
226 | MineFrame( QWidget *parent, const char *name = 0 ) | 227 | MineFrame( QWidget *parent, const char *name = 0 ) |
227 | :QFrame( parent, name ) {} | 228 | :QFrame( parent, name ), field(0) {} |
228 | void setField( MineField *f ) { field = f; } | 229 | void setField( MineField *f ) { |
230 | field = f; | ||
231 | setMinimumSize( field->sizeHint() ); | ||
232 | } | ||
229 | protected: | 233 | protected: |
230 | void resizeEvent( QResizeEvent *e ) { | 234 | void resizeEvent( QResizeEvent *e ) { |
231 | field->setAvailableRect( contentsRect()); | 235 | field->setAvailableRect( contentsRect()); |
232 | QFrame::resizeEvent(e); | 236 | QFrame::resizeEvent(e); |
233 | } | 237 | } |
234 | private: | 238 | private: |
@@ -237,26 +241,29 @@ private: | |||
237 | 241 | ||
238 | 242 | ||
239 | 243 | ||
240 | MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) | 244 | MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) |
241 | : QMainWindow( parent, name, f ) | 245 | : QMainWindow( parent, name, f ) |
242 | { | 246 | { |
243 | QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); | ||
244 | srand(::time(0)); | 247 | srand(::time(0)); |
245 | setCaption( tr("Mine Hunt") ); | 248 | setCaption( tr("Mine Hunt") ); |
246 | setIcon( Resource::loadPixmap( "minesweep_icon" ) ); | 249 | QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff ); |
250 | setIcon( Resource::loadPixmap( "minesweep/MineHunt" ) ); | ||
247 | 251 | ||
248 | QToolBar *toolBar = new QToolBar( this ); | 252 | QToolBar *toolBar = new QToolBar( this ); |
249 | toolBar->setHorizontalStretchable( TRUE ); | 253 | toolBar->setHorizontalStretchable( TRUE ); |
250 | 254 | ||
251 | QMenuBar *menuBar = new QMenuBar( toolBar ); | 255 | QMenuBar *menuBar = new QMenuBar( toolBar ); |
252 | 256 | ||
253 | QPopupMenu *gameMenu = new QPopupMenu( this ); | 257 | QPopupMenu *gameMenu = new QPopupMenu( this ); |
254 | gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); | 258 | gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) ); |
255 | gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); | 259 | gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) ); |
256 | gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); | 260 | |
261 | if (qApp->desktop()->width() >= 240) { | ||
262 | gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) ); | ||
263 | } | ||
257 | 264 | ||
258 | menuBar->insertItem( tr("Game"), gameMenu ); | 265 | menuBar->insertItem( tr("Game"), gameMenu ); |
259 | 266 | ||
260 | guessLCD = new QLCDNumber( toolBar ); | 267 | guessLCD = new QLCDNumber( toolBar ); |
261 | toolBar->setStretchableWidget( guessLCD ); | 268 | toolBar->setStretchableWidget( guessLCD ); |
262 | 269 | ||
@@ -296,18 +303,17 @@ MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f ) | |||
296 | QFont fnt = field->font(); | 303 | QFont fnt = field->font(); |
297 | fnt.setBold( TRUE ); | 304 | fnt.setBold( TRUE ); |
298 | field->setFont( QFont( fnt ) ); | 305 | field->setFont( QFont( fnt ) ); |
299 | field->setFocus(); | 306 | field->setFocus(); |
300 | setCentralWidget( mainframe ); | 307 | setCentralWidget( mainframe ); |
301 | 308 | ||
302 | connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) ); | 309 | connect( field, SIGNAL( gameOver(bool) ), this, SLOT( gameOver(bool) ) ); |
303 | connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) ); | 310 | connect( field, SIGNAL( mineCount(int) ), this, SLOT( setCounter(int) ) ); |
304 | connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); | 311 | connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) ); |
305 | 312 | ||
306 | timer = new QTimer( this ); | 313 | timer = new QTimer( this ); |
307 | |||
308 | connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); | 314 | connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) ); |
309 | 315 | ||
310 | readConfig(); | 316 | readConfig(); |
311 | } | 317 | } |
312 | 318 | ||
313 | MineSweep::~MineSweep() | 319 | MineSweep::~MineSweep() |