summaryrefslogtreecommitdiff
path: root/noncore/games/minesweep/minesweep.cpp
authorzecke <zecke>2004-02-06 12:28:33 (UTC)
committer zecke <zecke>2004-02-06 12:28:33 (UTC)
commitc0207d7284d0f91a3a20f4abda2c6846c8dd8595 (patch) (side-by-side diff)
treec95157ef87c805d870a68400858ff65b1ded03ac /noncore/games/minesweep/minesweep.cpp
parent0c74629e8f5c12a9b5a282b817f884fa10dee491 (diff)
downloadopie-c0207d7284d0f91a3a20f4abda2c6846c8dd8595.zip
opie-c0207d7284d0f91a3a20f4abda2c6846c8dd8595.tar.gz
opie-c0207d7284d0f91a3a20f4abda2c6846c8dd8595.tar.bz2
Merge with Qtopia sources
Diffstat (limited to 'noncore/games/minesweep/minesweep.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/minesweep/minesweep.cpp34
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,40 +1,40 @@
/**********************************************************************
-** Copyright (C) 2000 Trolltech AS. All rights reserved.
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
-** This file is part of Qtopia Environment.
+** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "minesweep.h"
#include "minefield.h"
-#include <qpe/qpeapplication.h>
-#include <qpe/resource.h>
-#include <qpe/config.h>
+#include <qtopia/qpeapplication.h>
+#include <qtopia/resource.h>
+#include <qtopia/config.h>
-#include <qpe/qpetoolbar.h>
+#include <qtoolbar.h>
#include <qmenubar.h>
#include <qpopupmenu.h>
#include <qpushbutton.h>
#include <qlcdnumber.h>
#include <qmessagebox.h>
#include <qtimer.h>
#include <qpalette.h>
#include <qapplication.h>
#include <qlayout.h>
#include <qlabel.h>
#include <stdlib.h>
@@ -189,24 +189,25 @@ void ResultIndicator::showResult( QWidget *ref, bool won )
r->show();
r->twoStage = TRUE;
r->timerId =r->startTimer(200);
}
}
void ResultIndicator::center()
{
QWidget *w = parentWidget();
QPoint pp = w->mapToGlobal( QPoint(0,0) );
QSize s = sizeHint()*3;
+ s.setWidth( QMIN(s.width(), w->width()) );
pp = QPoint( pp.x() + w->width()/2 - s.width()/2,
pp.y() + w->height()/ 2 - s.height()/2 );
setGeometry( QRect(pp, s) );
}
void ResultIndicator::timerEvent( QTimerEvent *te )
{
if ( te->timerId() != timerId )
return;
killTimer( timerId );
@@ -215,54 +216,60 @@ void ResultIndicator::timerEvent( QTimerEvent *te )
twoStage = FALSE;
timerId = startTimer( 1000 );
} else {
delete this;
}
}
class MineFrame : public QFrame
{
public:
MineFrame( QWidget *parent, const char *name = 0 )
- :QFrame( parent, name ) {}
- void setField( MineField *f ) { field = f; }
+ :QFrame( parent, name ), field(0) {}
+ void setField( MineField *f ) {
+ field = f;
+ setMinimumSize( field->sizeHint() );
+ }
protected:
void resizeEvent( QResizeEvent *e ) {
field->setAvailableRect( contentsRect());
QFrame::resizeEvent(e);
}
private:
MineField *field;
};
MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f )
: QMainWindow( parent, name, f )
{
- QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
srand(::time(0));
setCaption( tr("Mine Hunt") );
- setIcon( Resource::loadPixmap( "minesweep_icon" ) );
+ QPEApplication::setInputMethodHint(this, QPEApplication::AlwaysOff );
+ setIcon( Resource::loadPixmap( "minesweep/MineHunt" ) );
QToolBar *toolBar = new QToolBar( this );
toolBar->setHorizontalStretchable( TRUE );
QMenuBar *menuBar = new QMenuBar( toolBar );
QPopupMenu *gameMenu = new QPopupMenu( this );
gameMenu->insertItem( tr("Beginner"), this, SLOT( beginner() ) );
gameMenu->insertItem( tr("Advanced"), this, SLOT( advanced() ) );
- gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) );
+
+ if (qApp->desktop()->width() >= 240) {
+ gameMenu->insertItem( tr("Expert"), this, SLOT( expert() ) );
+ }
menuBar->insertItem( tr("Game"), gameMenu );
guessLCD = new QLCDNumber( toolBar );
toolBar->setStretchableWidget( guessLCD );
QPalette lcdPal( red );
lcdPal.setColor( QColorGroup::Background, QApplication::palette().active().background() );
lcdPal.setColor( QColorGroup::Button, QApplication::palette().active().button() );
// guessLCD->setPalette( lcdPal );
guessLCD->setSegmentStyle( QLCDNumber::Flat );
@@ -290,30 +297,29 @@ MineSweep::MineSweep( QWidget* parent, const char* name, WFlags f )
mainframe->setFrameShadow( QFrame::Raised );
mainframe->setLineWidth(2);
field = new MineField( mainframe );
mainframe->setField( field );
QFont fnt = field->font();
fnt.setBold( TRUE );
field->setFont( QFont( fnt ) );
field->setFocus();
setCentralWidget( mainframe );
- connect( field, SIGNAL( gameOver( bool ) ), this, SLOT( gameOver( bool ) ) );
- connect( field, SIGNAL( mineCount( int ) ), this, SLOT( setCounter( int ) ) );
+ connect( field, SIGNAL( gameOver(bool) ), this, SLOT( gameOver(bool) ) );
+ connect( field, SIGNAL( mineCount(int) ), this, SLOT( setCounter(int) ) );
connect( field, SIGNAL( gameStarted()), this, SLOT( startPlaying() ) );
timer = new QTimer( this );
-
connect( timer, SIGNAL( timeout() ), this, SLOT( updateTime() ) );
readConfig();
}
MineSweep::~MineSweep()
{
writeConfig();
}
void MineSweep::gameOver( bool won )
{