summaryrefslogtreecommitdiffstats
path: root/ktron
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:42:31 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:42:31 +0000
commit576eb4299a00bc053db35414406f46372a0f70f2 (patch)
tree4c030922d533821db464af566188e7d40cc8848c /ktron
parent0718336b6017d1a4fc1d626544180a5a2a29ddec (diff)
downloadtdegames-576eb4299a00bc053db35414406f46372a0f70f2.tar.gz
tdegames-576eb4299a00bc053db35414406f46372a0f70f2.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1157643 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'ktron')
-rw-r--r--ktron/ktron.cpp28
-rw-r--r--ktron/ktron.h6
-rw-r--r--ktron/tron.cpp72
-rw-r--r--ktron/tron.h30
4 files changed, 68 insertions, 68 deletions
diff --git a/ktron/ktron.cpp b/ktron/ktron.cpp
index 67151ff0..c9a5ea77 100644
--- a/ktron/ktron.cpp
+++ b/ktron/ktron.cpp
@@ -42,11 +42,11 @@
/**
* Constuctor
*/
-KTron::KTron(QWidget *parent, const char *name) : KMainWindow(parent, name) {
+KTron::KTron(TQWidget *parent, const char *name) : KMainWindow(parent, name) {
playerPoints[0]=playerPoints[1]=0;
tron=new Tron(this, "Tron");
- connect(tron,SIGNAL(gameEnds(Player)),SLOT(changeStatus(Player)));
+ connect(tron,TQT_SIGNAL(gameEnds(Player)),TQT_SLOT(changeStatus(Player)));
setCentralWidget(tron);
tron->setMinimumSize(200,180);
@@ -81,10 +81,10 @@ KTron::KTron(QWidget *parent, const char *name) : KMainWindow(parent, name) {
tron->setActionCollection(actionCollection());
- KStdGameAction::pause(tron, SLOT(togglePause()), actionCollection());
- KStdGameAction::gameNew( tron, SLOT( newGame() ), actionCollection() );
- KStdGameAction::quit(this, SLOT( close() ), actionCollection());
- KStdAction::preferences(this, SLOT(showSettings()), actionCollection());
+ KStdGameAction::pause(tron, TQT_SLOT(togglePause()), actionCollection());
+ KStdGameAction::gameNew( tron, TQT_SLOT( newGame() ), actionCollection() );
+ KStdGameAction::quit(this, TQT_SLOT( close() ), actionCollection());
+ KStdAction::preferences(this, TQT_SLOT(showSettings()), actionCollection());
setupGUI( KMainWindow::Keys | StatusBar | Save | Create);
loadSettings();
@@ -106,14 +106,14 @@ void KTron::updateStatusbar(){
Player player;
player=(i==0?One:Two);
- QString name;
+ TQString name;
if(tron->isComputer(Both))
name=i18n("Computer(%1)").arg(i+1);
else if(tron->isComputer(player))
name=i18n("Computer");
else
name=playerName[i];
- QString string = QString("%1: %2").arg(name).arg(playerPoints[i]);
+ TQString string = TQString("%1: %2").arg(name).arg(playerPoints[i]);
statusBar()->changeItem(string,ID_STATUS_BASE+i+1);
}
}
@@ -147,18 +147,18 @@ void KTron::showWinner(Player winner){
if(tron->isComputer(Both) || (winner != One && winner != Two))
return;
- QString loserName = i18n("KTron");
+ TQString loserName = i18n("KTron");
int loser = Two;
if(winner == Two)
loser = One;
if(!tron->isComputer(((Player)loser)))
loserName = playerName[loser];
- QString winnerName = i18n("KTron");
+ TQString winnerName = i18n("KTron");
if(!tron->isComputer(winner))
winnerName = playerName[winner];
- QString message=i18n("%1 has won!").arg(winnerName);
+ TQString message=i18n("%1 has won!").arg(winnerName);
statusBar()->message(message,MESSAGE_TIME);
message = i18n("%1 has won versus %2 with %3 : %4 points!");
@@ -169,7 +169,7 @@ void KTron::showWinner(Player winner){
tron->newGame();
}
-void KTron::paletteChange(const QPalette &/*oldPalette*/){
+void KTron::paletteChange(const TQPalette &/*oldPalette*/){
update();
tron->updatePixmap();
tron->update();
@@ -186,8 +186,8 @@ void KTron::showSettings(){
dialog->addPage(new General(0, "General"), i18n("General"), "package_settings");
dialog->addPage(new Ai(0, "Ai"), i18n("A.I."), "personal");
dialog->addPage(new Appearance(0, "Appearance"), i18n("Appearance"), "style");
- connect(dialog, SIGNAL(settingsChanged()), tron, SLOT(loadSettings()));
- connect(dialog, SIGNAL(settingsChanged()), this, SLOT(loadSettings()));
+ connect(dialog, TQT_SIGNAL(settingsChanged()), tron, TQT_SLOT(loadSettings()));
+ connect(dialog, TQT_SIGNAL(settingsChanged()), this, TQT_SLOT(loadSettings()));
dialog->show();
}
diff --git a/ktron/ktron.h b/ktron/ktron.h
index 191f2b44..c61bf42b 100644
--- a/ktron/ktron.h
+++ b/ktron/ktron.h
@@ -41,18 +41,18 @@ class KTron : public KMainWindow {
Q_OBJECT
public:
- KTron(QWidget *parent=0, const char *name=0);
+ KTron(TQWidget *parent=0, const char *name=0);
private:
KAccel *accel;
Tron *tron;
- QString playerName[2];
+ TQString playerName[2];
int playerPoints[2];
void updateStatusbar();
protected:
/** calls tron->updatePixmap to draw frame in the new colors */
- void paletteChange(const QPalette &oldPalette);
+ void paletteChange(const TQPalette &oldPalette);
private slots:
void loadSettings();
diff --git a/ktron/tron.cpp b/ktron/tron.cpp
index 494d96bc..1c7bf72c 100644
--- a/ktron/tron.cpp
+++ b/ktron/tron.cpp
@@ -23,7 +23,7 @@
#include <kmessagebox.h>
// Normal class
-#include <qtimer.h>
+#include <tqtimer.h>
#include <kdebug.h>
#include <klocale.h>
@@ -41,8 +41,8 @@
* init-functions
**/
-Tron::Tron(QWidget *parent,const char *name)
- : QWidget(parent,name)
+Tron::Tron(TQWidget *parent,const char *name)
+ : TQWidget(parent,name)
{
pixmap=0;
playfield=0;
@@ -51,16 +51,16 @@ Tron::Tron(QWidget *parent,const char *name)
random.setSeed(0);
- setFocusPolicy(QWidget::StrongFocus);
+ setFocusPolicy(TQWidget::StrongFocus);
setBackgroundMode(NoBackground);
gameBlocked=false;
rectSize=10;
- timer = new QTimer(this,"timer");
+ timer = new TQTimer(this,"timer");
loadSettings();
- connect(timer, SIGNAL(timeout()), SLOT(doMove()));
- QTimer::singleShot(15000, this,SLOT(showBeginHint()));
+ connect(timer, TQT_SIGNAL(timeout()), TQT_SLOT(doMove()));
+ TQTimer::singleShot(15000, this,TQT_SLOT(showBeginHint()));
}
void Tron::loadSettings(){
@@ -89,13 +89,13 @@ void Tron::loadSettings(){
if(Settings::backgroundImageChoice()){
KURL url ( Settings::backgroundImage() );
if(!url.isEmpty()){
- QString tmpFile;
+ TQString tmpFile;
KIO::NetAccess::download(url, tmpFile, this);
- QPixmap pix(tmpFile);
+ TQPixmap pix(tmpFile);
if(!pix.isNull()){
setBackgroundPix(pix);
} else {
- QString msg=i18n("Wasn't able to load wallpaper\n%1");
+ TQString msg=i18n("Wasn't able to load wallpaper\n%1");
msg=msg.arg(tmpFile);
KMessageBox::sorry(this, msg);
}
@@ -132,11 +132,11 @@ void Tron::createNewPlayfield()
fieldHeight=(height()-2*TRON_FRAMESIZE)/rectSize;
// start positions
- playfield=new QMemArray<int>[fieldWidth];
+ playfield=new TQMemArray<int>[fieldWidth];
for(int i=0;i<fieldWidth;i++)
playfield[i].resize(fieldHeight);
- pixmap=new QPixmap(size());
+ pixmap=new TQPixmap(size());
pixmap->fill(Settings::color_Background());
//int min=(fieldWidth<fieldHeight) ? fieldWidth : fieldHeight;
@@ -150,7 +150,7 @@ void Tron::newGame()
emit gameEnds(Nobody);
reset();
- QTimer::singleShot(15000,this,SLOT(showBeginHint()));
+ TQTimer::singleShot(15000,this,TQT_SLOT(showBeginHint()));
}
void Tron::reset()
@@ -274,7 +274,7 @@ void Tron::showWinner(Player player)
if(isComputer(Both))
{
- QTimer::singleShot(1000,this,SLOT(computerStart()));
+ TQTimer::singleShot(1000,this,TQT_SLOT(computerStart()));
}
}
@@ -299,7 +299,7 @@ void Tron::updatePixmap()
pixmap->fill(Settings::color_Background());
}
- QPainter p;
+ TQPainter p;
p.begin(pixmap);
// alle Pixel prüfen und evt. zeichnen
@@ -313,8 +313,8 @@ void Tron::updatePixmap()
}
// draw frame
- QColor light=parentWidget()->colorGroup().midlight();
- QColor dark=parentWidget()->colorGroup().mid();
+ TQColor light=parentWidget()->colorGroup().midlight();
+ TQColor dark=parentWidget()->colorGroup().mid();
p.setPen(NoPen);
p.setBrush(light);
@@ -330,7 +330,7 @@ void Tron::updatePixmap()
// draw new player rects
void Tron::paintPlayers()
{
- QPainter p;
+ TQPainter p;
p.begin(this);
drawRect(p,players[0].xCoordinate,players[0].yCoordinate);
drawRect(p,players[1].xCoordinate,players[1].yCoordinate);
@@ -342,7 +342,7 @@ void Tron::paintPlayers()
p.end();
}
-void Tron::drawRect(QPainter & p, int x, int y)
+void Tron::drawRect(TQPainter & p, int x, int y)
{
int xOffset=x*rectSize+(width()-fieldWidth*rectSize)/2;
int yOffset=y*rectSize+(height()-fieldHeight*rectSize)/2;
@@ -350,7 +350,7 @@ void Tron::drawRect(QPainter & p, int x, int y)
int type=playfield[x][y];
// find out which color to draw
- QColor toDraw;
+ TQColor toDraw;
int player;
if(type&PLAYER1) // check player bit
{
@@ -427,14 +427,14 @@ void Tron::setActionCollection(KActionCollection *a)
actionCollection = a;
}
-void Tron::setBackgroundPix(QPixmap pix)
+void Tron::setBackgroundPix(TQPixmap pix)
{
bgPix=pix;
if(pixmap!=0){
updatePixmap();
// most pictures have colors, that you can read white text
- setPalette(QColor("black"));
+ setPalette(TQColor("black"));
}
}
@@ -453,7 +453,7 @@ void Tron::setComputerplayer(Player player, bool flag) {
players[1].setComputer(flag);
if(isComputer(Both))
- QTimer::singleShot(1000,this,SLOT(computerStart()));
+ TQTimer::singleShot(1000,this,TQT_SLOT(computerStart()));
}
bool Tron::isComputer(Player player)
@@ -581,16 +581,16 @@ void Tron::updateDirections(int playerNr)
** Events **
** *************************************************************** */
-void Tron::paintEvent(QPaintEvent *e)
+void Tron::paintEvent(TQPaintEvent *e)
{
bitBlt(this,e->rect().topLeft(),pixmap,e->rect());
// if game is paused, print message
if(gamePaused)
{
- QString message=i18n("Game paused");
- QPainter p(this);
- QFontMetrics fm=p.fontMetrics();
+ TQString message=i18n("Game paused");
+ TQPainter p(this);
+ TQFontMetrics fm=p.fontMetrics();
int w=fm.width(message);
p.drawText(width()/2-w/2,height()/2,message);
}
@@ -598,8 +598,8 @@ void Tron::paintEvent(QPaintEvent *e)
// If game ended, print "Crash!"
else if(gameEnded)
{
- QString message=i18n("Crash!");
- QPainter p(this);
+ TQString message=i18n("Crash!");
+ TQPainter p(this);
int w=p.fontMetrics().width(message);
int h=p.fontMetrics().height();
for(int i=0;i<2;i++)
@@ -619,7 +619,7 @@ void Tron::paintEvent(QPaintEvent *e)
// draw begin hint
if(beginHint)
{
- QString hint=i18n("Press any of your direction keys to start!");
+ TQString hint=i18n("Press any of your direction keys to start!");
int x=p.fontMetrics().width(hint);
x=(width()-x)/2;
int y=height()/2;
@@ -629,13 +629,13 @@ void Tron::paintEvent(QPaintEvent *e)
}
}
-void Tron::resizeEvent(QResizeEvent *)
+void Tron::resizeEvent(TQResizeEvent *)
{
createNewPlayfield();
reset();
}
-void Tron::keyPressEvent(QKeyEvent *e)
+void Tron::keyPressEvent(TQKeyEvent *e)
{
KKey key(e);
if(!players[1].computer)
@@ -718,7 +718,7 @@ void Tron::keyPressEvent(QKeyEvent *e)
}
}
-void Tron::keyReleaseEvent(QKeyEvent * e)
+void Tron::keyReleaseEvent(TQKeyEvent * e)
{
KKey key(e);
@@ -785,7 +785,7 @@ void Tron::keyReleaseEvent(QKeyEvent * e)
}
// if playingfield loses keyboard focus, pause game
-void Tron::focusOutEvent(QFocusEvent *)
+void Tron::focusOutEvent(TQFocusEvent *)
{
if(!gameEnded && !gamePaused)
{
@@ -939,7 +939,7 @@ void Tron::doMove()
{
//this is for waiting 0,5s before starting next game
gameBlocked=true;
- QTimer::singleShot(1000,this,SLOT(unblockGame()));
+ TQTimer::singleShot(1000,this,TQT_SLOT(unblockGame()));
return;
}
}
@@ -1056,7 +1056,7 @@ void Tron::doMove()
{
//this is for waiting 1s before starting next game
gameBlocked=true;
- QTimer::singleShot(1000,this,SLOT(unblockGame()));
+ TQTimer::singleShot(1000,this,TQT_SLOT(unblockGame()));
}
}
diff --git a/ktron/tron.h b/ktron/tron.h
index ebfc1d56..188604d8 100644
--- a/ktron/tron.h
+++ b/ktron/tron.h
@@ -26,9 +26,9 @@
#include <config.h>
#endif
-#include <qwidget.h>
-#include <qpainter.h>
-#include <qpixmap.h>
+#include <tqwidget.h>
+#include <tqpainter.h>
+#include <tqpixmap.h>
#include <math.h>
#include <krandomsequence.h>
@@ -48,11 +48,11 @@ class Tron : public QWidget
Q_OBJECT
public:
- Tron(QWidget *parent=0, const char *name=0);
+ Tron(TQWidget *parent=0, const char *name=0);
~Tron();
void setActionCollection(KActionCollection*);
void updatePixmap();
- void setBackgroundPix(QPixmap);
+ void setBackgroundPix(TQPixmap);
void setComputerplayer(Player player, bool);
bool isComputer(Player player);
void setVelocity(int);
@@ -80,21 +80,21 @@ protected:
/** bitBlt´s the rect that has to be updated from the
* bufferpixmap on the screen and writes eventually text
*/
- void paintEvent(QPaintEvent *);
+ void paintEvent(TQPaintEvent *);
/** resets game and creates a new playingfield */
- void resizeEvent(QResizeEvent *);
- void keyPressEvent(QKeyEvent *);
- void keyReleaseEvent(QKeyEvent *);
+ void resizeEvent(TQResizeEvent *);
+ void keyPressEvent(TQKeyEvent *);
+ void keyReleaseEvent(TQKeyEvent *);
/** pauses game */
- void focusOutEvent(QFocusEvent *);
+ void focusOutEvent(TQFocusEvent *);
private:
/** Stores key shortcuts */
KActionCollection* actionCollection;
/** Drawing buffer */
- QPixmap *pixmap;
+ TQPixmap *pixmap;
/** The playingfield */
- QMemArray<int> *playfield;
+ TQMemArray<int> *playfield;
/** game status flag */
bool gamePaused;
/** game status flag */
@@ -107,11 +107,11 @@ private:
int fieldHeight;
/** Width of the playingfield in number of rects*/
int fieldWidth;
- QTimer *timer;
+ TQTimer *timer;
player players[2];
/** Backgroundpixmap **/
- QPixmap bgPix;
+ TQPixmap bgPix;
/** time in ms between two moves */
int velocity;
@@ -137,7 +137,7 @@ private:
/** paints players at current player coordinates */
void paintPlayers();
/** draws a rect in current TronStyle at position x,y of the playingfield */
- void drawRect(QPainter & p, int x, int y);
+ void drawRect(TQPainter & p, int x, int y);
/** emits gameEnds(Player) and displays the winner by changing color*/
void showWinner(Player winner);