From 576eb4299a00bc053db35414406f46372a0f70f2 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 31 Jul 2010 19:42:31 +0000 Subject: Trinity Qt initial conversion git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1157643 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- ktron/tron.cpp | 72 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'ktron/tron.cpp') 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 // Normal class -#include +#include #include #include @@ -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[fieldWidth]; + playfield=new TQMemArray[fieldWidth]; for(int i=0;ifill(Settings::color_Background()); //int min=(fieldWidthfill(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())); } } -- cgit v1.2.1