From 838baf3f99ec5ab81b063eb5449a3381d860f377 Mon Sep 17 00:00:00 2001 From: tpearson Date: Sat, 11 Jun 2011 04:58:26 +0000 Subject: TQt4 port kdegames This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1236074 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kspaceduel/defines.h | 2 +- kspaceduel/dialogs.cpp | 18 +++++++++--------- kspaceduel/dialogs.h | 8 +++++--- kspaceduel/general.ui | 46 +++++++++++++++++++++++----------------------- kspaceduel/mainview.cpp | 40 ++++++++++++++++++++-------------------- kspaceduel/mainview.h | 7 ++++--- kspaceduel/playerinfo.cpp | 10 +++++----- kspaceduel/playerinfo.h | 5 +++-- kspaceduel/sprites.cpp | 2 +- kspaceduel/sprites.h | 8 ++++---- kspaceduel/topwidget.cpp | 32 ++++++++++++++++---------------- kspaceduel/topwidget.h | 1 + 12 files changed, 92 insertions(+), 87 deletions(-) (limited to 'kspaceduel') diff --git a/kspaceduel/defines.h b/kspaceduel/defines.h index edd4835e..b04a6685 100644 --- a/kspaceduel/defines.h +++ b/kspaceduel/defines.h @@ -63,4 +63,4 @@ #define SHOTDIST 14 #define EPSILON 0.1 -#define GAME_START_SHORTCUT Qt::Key_Space +#define GAME_START_SHORTCUT TQt::Key_Space diff --git a/kspaceduel/dialogs.cpp b/kspaceduel/dialogs.cpp index c8ec2632..843e93ee 100644 --- a/kspaceduel/dialogs.cpp +++ b/kspaceduel/dialogs.cpp @@ -113,8 +113,8 @@ int ConfigSetup::Position[EditNum]= const int LCDLen=6; -ConfigSetup::ConfigSetup(SConfig *custom,TQWidget *parent,const char *name) - :TQWidget( parent, name ) +ConfigSetup::ConfigSetup(SConfig *custom,TQWidget *tqparent,const char *name) + :TQWidget( tqparent, name ) { TQLabel *label[EditNum]; TQGridLayout *stacklayout[TabNum]; @@ -130,7 +130,7 @@ ConfigSetup::ConfigSetup(SConfig *custom,TQWidget *parent,const char *name) //box=new TQGroupBox(i18n("Config"),this); //setMainWidget( box ); - TQVBoxLayout *boxlayout = new TQVBoxLayout( this, 6 ); + TQVBoxLayout *boxtqlayout = new TQVBoxLayout( this, 6 ); tabs=new TQTabWidget(this); for(i=0;isetFrameStyle(TQFrame::NoFrame); @@ -157,9 +157,9 @@ ConfigSetup::ConfigSetup(SConfig *custom,TQWidget *parent,const char *name) configCombo->insertItem(i18n(predefinedConfigName[i])); configCombo->insertItem(i18n("Custom")); - boxlayout->addSpacing( 2 * 6 ); - boxlayout->addWidget(configCombo); - boxlayout->addWidget(tabs); + boxtqlayout->addSpacing( 2 * 6 ); + boxtqlayout->addWidget(configCombo); + boxtqlayout->addWidget(tabs); for(i=0;i General - + General - + 0 0 @@ -16,7 +16,7 @@ unnamed - + groupBox3 @@ -33,7 +33,7 @@ unnamed - + lCDNumber2 @@ -44,7 +44,7 @@ 99 - + lCDNumber1 @@ -55,7 +55,7 @@ 99 - + textLabel3 @@ -63,7 +63,7 @@ Red player: - + textLabel4 @@ -71,7 +71,7 @@ Blue player: - + kcfg_StartHitPoints1 @@ -82,7 +82,7 @@ Horizontal - + kcfg_StartHitPoints0 @@ -95,7 +95,7 @@ - + groupBox4 @@ -106,7 +106,7 @@ unnamed - + textLabel5 @@ -114,7 +114,7 @@ Refresh time: - + kcfg_RefreshTime @@ -131,7 +131,7 @@ Horizontal - + lCDNumber3 @@ -154,14 +154,14 @@ Expanding - + 20 91 - + groupBox1 @@ -172,7 +172,7 @@ unnamed - + kcfg_Player0IsAi @@ -180,7 +180,7 @@ Player is AI - + textLabel1 @@ -191,7 +191,7 @@ Difficulty: - + Trainee @@ -224,7 +224,7 @@ - + groupBox2 @@ -235,7 +235,7 @@ unnamed - + kcfg_Player1IsAi @@ -243,7 +243,7 @@ Player is AI - + textLabel2 @@ -254,7 +254,7 @@ Difficulty: - + Trainee @@ -333,5 +333,5 @@ setEnabled(bool) - + diff --git a/kspaceduel/mainview.cpp b/kspaceduel/mainview.cpp index 5448c1a3..ea17594d 100644 --- a/kspaceduel/mainview.cpp +++ b/kspaceduel/mainview.cpp @@ -18,8 +18,8 @@ KToggleAction *MyMainView::pauseAction = 0; -MyMainView::MyMainView(TQWidget *parent) - :TQWidget(parent), +MyMainView::MyMainView(TQWidget *tqparent) + :TQWidget(tqparent), field(DEF_WIDTH,DEF_HEIGHT), view(&field,this) { @@ -27,7 +27,7 @@ MyMainView::MyMainView(TQWidget *parent) setMinimumSize(600,400); random.setSeed(0); TQPixmap backgr(locate("appdata", MV_BACKGROUND)); - field.setBackgroundPixmap(backgr); + field.tqsetBackgroundPixmap(backgr); view.setResizePolicy(TQScrollView::AutoOne); view.setHScrollBarMode(TQScrollView::AlwaysOff); @@ -99,7 +99,7 @@ MyMainView::MyMainView(TQWidget *parent) MyMainView::~MyMainView() { - killTimers(); + TQT_TQOBJECT(this)->killTimers(); writeConfig(); } @@ -340,7 +340,7 @@ void MyMainView::pause() pauseAction->setChecked( true ); waitForStart=true; - killTimers(); + TQT_TQOBJECT(this)->killTimers(); emit setStatusText(i18n(" paused "), IDS_PAUSE); } } @@ -375,7 +375,7 @@ void MyMainView::stop() pauseAction->setEnabled( false ); pauseAction->setChecked( false ); - killTimers(); + TQT_TQOBJECT(this)->killTimers(); waitForStart = true; } @@ -444,7 +444,7 @@ void MyMainView::newRound() timeToNextPowerup=random.getDouble() * config.powerupRefreshTime; powerups.clear(); - killTimers(); + TQT_TQOBJECT(this)->killTimers(); mx=width()/2.0; my=height()/2.0; ship[0]->move(mx+config.startPosX,my+config.startPosY); @@ -492,7 +492,7 @@ void MyMainView::newRound() field.update(); TQString str = i18n("Press %1 to start") - .arg(KShortcut(GAME_START_SHORTCUT).toString()); + .tqarg(KShortcut(GAME_START_SHORTCUT).toString()); emit(setStatusText(str,IDS_MAIN)); emit( setStatusText( "", IDS_PAUSE ) ); stop( ); @@ -517,7 +517,7 @@ void MyMainView::timerEvent(TQTimerEvent *event) if(event->timerId()==timerID) { - killTimers(); + TQT_TQOBJECT(this)->killTimers(); if(gameEnd>0.0) { gameEnd-=1.0; @@ -534,7 +534,7 @@ void MyMainView::timerEvent(TQTimerEvent *event) textSprite=new TQCanvasText(&field); textSprite->move(width()/2,height()/2-90); textSprite->setTextFlags(AlignCenter); - textSprite->setColor(qRgb(255,160,0)); + textSprite->setColor(tqRgb(255,160,0)); textSprite->setFont(TQFont(KGlobalSettings::generalFont().family(),14)); textSprite->show( ); if(ship[0]->getHitPoints()==0) @@ -557,7 +557,7 @@ void MyMainView::timerEvent(TQTimerEvent *event) emit(wins(0,w)); } TQString str = i18n("Press %1 for new round") - .arg(KShortcut(GAME_START_SHORTCUT).toString()); + .tqarg(KShortcut(GAME_START_SHORTCUT).toString()); emit(setStatusText(str,IDS_MAIN)); stop( ); } @@ -815,7 +815,7 @@ void MyMainView::collisions() if((sprite->rtti()!=S_EXPLOSION) && !((sprite->rtti()!=S_SUN)&&(ship[pl]->getHitPoints()==0))) if(ship[pl]->collidesWith(sprite)) - if(!hitlist.contains(sprite)) + if(!hitlist.tqcontains(sprite)) hitlist.append(sprite); } @@ -906,7 +906,7 @@ void MyMainView::collisions() sprite = (*it); if(sprite->rtti()==S_BULLET) if(mine->collidesWith(sprite)) - if(!hitlist.contains(sprite)) + if(!hitlist.tqcontains(sprite)) hitlist.append(sprite); } if(hitlist.count()>0) @@ -932,13 +932,13 @@ void MyMainView::collisions() { case S_BULLET: if(sun->collidesWith(sprite)) - if(!hitlist.contains(sprite)) + if(!hitlist.tqcontains(sprite)) hitlist.append(sprite); break; case S_MINE: if(!((MobileSprite*)sprite)->isStopped()) if(sun->collidesWith(sprite)) - if(!hitlist.contains(sprite)) + if(!hitlist.tqcontains(sprite)) hitlist.append(sprite); break; } @@ -1002,12 +1002,12 @@ void MyMainView::closeSettings(){ } TQCanvasPixmapArray* MyMainView::loadOldPixmapSequence(const TQString& datapattern, - const TQString& maskpattern, int framecount) + const TQString& tqmaskpattern, int framecount) { int image; TQPtrList pixmaplist; TQPtrList pointlist; - TQString dataname, maskname; + TQString dataname, tqmaskname; TQPixmap *pix; TQBitmap *bitmap; int hotx=0, hoty=0; @@ -1015,9 +1015,9 @@ TQCanvasPixmapArray* MyMainView::loadOldPixmapSequence(const TQString& datapatte for( image=0; image < framecount; image++ ) { - // #### Why is this a QString?? + // #### Why is this a TQString?? dataname.sprintf( datapattern.ascii(), image ); - maskname.sprintf( maskpattern.ascii(), image ); + tqmaskname.sprintf( tqmaskpattern.ascii(), image ); TQFile file(dataname); if( file.open( IO_ReadOnly ) ) @@ -1039,7 +1039,7 @@ TQCanvasPixmapArray* MyMainView::loadOldPixmapSequence(const TQString& datapatte } pix = new TQPixmap( dataname ); - bitmap = new TQBitmap( maskname ); + bitmap = new TQBitmap( tqmaskname ); pix->setMask( *bitmap ); pixmaplist.append( pix ); diff --git a/kspaceduel/mainview.h b/kspaceduel/mainview.h index c56a4f12..ab4a4fcc 100644 --- a/kspaceduel/mainview.h +++ b/kspaceduel/mainview.h @@ -16,11 +16,12 @@ class Ai; #undef sun #endif -class MyMainView:public QWidget +class MyMainView:public TQWidget { Q_OBJECT + TQ_OBJECT public: - MyMainView(TQWidget *parent=0); + MyMainView(TQWidget *tqparent=0); ~MyMainView(); static KToggleAction *pauseAction; @@ -51,7 +52,7 @@ protected: virtual void keyReleaseEvent(TQKeyEvent *event); SConfig modifyConfig(SConfig conf); TQCanvasPixmapArray* loadOldPixmapSequence(const TQString& datapattern, - const TQString& maskpattern, int framecount=1); + const TQString& tqmaskpattern, int framecount=1); void moveShips(); void moveBullets(); void moveMines(); diff --git a/kspaceduel/playerinfo.cpp b/kspaceduel/playerinfo.cpp index 2e1ef91d..07020fb3 100644 --- a/kspaceduel/playerinfo.cpp +++ b/kspaceduel/playerinfo.cpp @@ -5,8 +5,8 @@ #include -PlayerInfo::PlayerInfo(int pnr,TQWidget *parent,const char *name) - :TQFrame(parent,name), +PlayerInfo::PlayerInfo(int pnr,TQWidget *tqparent,const char *name) + :TQFrame(tqparent,name), lplayer(this),lenergy(this),lwins(this), hitpoints(2,this),energy(2,this),wins(2,this) { @@ -34,9 +34,9 @@ PlayerInfo::PlayerInfo(int pnr,TQWidget *parent,const char *name) for(i=0;i<4;i++) { - str = TQString::fromLatin1("sprites/playerinfo/ship%1%2.pnm") - .arg(pnr+1) - .arg(i); + str = TQString::tqfromLatin1("sprites/playerinfo/ship%1%2.pnm") + .tqarg(pnr+1) + .tqarg(i); pix[i]=new TQPixmap(locate("appdata", str)); } diff --git a/kspaceduel/playerinfo.h b/kspaceduel/playerinfo.h index 022d533e..0963b405 100644 --- a/kspaceduel/playerinfo.h +++ b/kspaceduel/playerinfo.h @@ -7,11 +7,12 @@ class TQPixmap; #include #include -class PlayerInfo:public QFrame +class PlayerInfo:public TQFrame { Q_OBJECT + TQ_OBJECT public: - PlayerInfo(int pnr,TQWidget *parent=0,const char *name=0); + PlayerInfo(int pnr,TQWidget *tqparent=0,const char *name=0); public slots: void setHitpoints(int h); void setEnergy(int e); diff --git a/kspaceduel/sprites.cpp b/kspaceduel/sprites.cpp index ba163429..5c408e46 100644 --- a/kspaceduel/sprites.cpp +++ b/kspaceduel/sprites.cpp @@ -6,7 +6,7 @@ SunSprite::SunSprite(TQCanvasPixmapArray *seq, TQCanvas* canvas) :TQCanvasSprite(seq, canvas) { - // doesn't work with Qt 2.2.2 anymore + // doesn't work with TQt 2.2.2 anymore // setZ(0); } diff --git a/kspaceduel/sprites.h b/kspaceduel/sprites.h index 8011301e..e05c8674 100644 --- a/kspaceduel/sprites.h +++ b/kspaceduel/sprites.h @@ -14,7 +14,7 @@ struct AiSprite bool sun, border; }; -class SunSprite:public QCanvasSprite +class SunSprite:public TQCanvasSprite { public: SunSprite(TQCanvasPixmapArray* seq, TQCanvas* canvas); @@ -22,7 +22,7 @@ public: }; -class PowerupSprite:public QCanvasSprite +class PowerupSprite:public TQCanvasSprite { public: enum {PowerupMine=0, PowerupBullet, PowerupShield, PowerupEnergy, @@ -38,7 +38,7 @@ private: int type; }; -class MobileSprite:public QCanvasSprite +class MobileSprite:public TQCanvasSprite { public: MobileSprite(TQCanvasPixmapArray* array, TQCanvas* canvas, int pn); @@ -126,7 +126,7 @@ private: double activateTime,fuel,timeToGo,explosiontime; }; -class ExplosionSprite:public QCanvasSprite +class ExplosionSprite:public TQCanvasSprite { public: ExplosionSprite(TQCanvasPixmapArray *seq, TQCanvas* field, MobileSprite *sp); diff --git a/kspaceduel/topwidget.cpp b/kspaceduel/topwidget.cpp index 510da675..999f546b 100644 --- a/kspaceduel/topwidget.cpp +++ b/kspaceduel/topwidget.cpp @@ -25,21 +25,21 @@ void MyTopLevelWidget::initGameWidgets( ){ playerinfo[1]=new PlayerInfo(1,w); playfield=new MyMainView(w); - TQBoxLayout *toplayout=new TQHBoxLayout(w); - toplayout->addWidget(playerinfo[0]); - toplayout->addWidget(playfield); - toplayout->addWidget(playerinfo[1]); - toplayout->activate(); + TQBoxLayout *toptqlayout=new TQHBoxLayout(w); + toptqlayout->addWidget(playerinfo[0]); + toptqlayout->addWidget(playfield); + toptqlayout->addWidget(playerinfo[1]); + toptqlayout->activate(); - playfield->setFocusPolicy(TQWidget::StrongFocus); + playfield->setFocusPolicy(TQ_StrongFocus); playfield->setFocus(); - TQObject::connect(playfield,TQT_SIGNAL(energy(int,int)), + TQT_BASE_OBJECT_NAME::connect(TQT_TQOBJECT(playfield),TQT_SIGNAL(energy(int,int)), TQT_SLOT(energy(int,int))); - TQObject::connect(playfield,TQT_SIGNAL(hitPoints(int,int)), + TQT_BASE_OBJECT_NAME::connect(TQT_TQOBJECT(playfield),TQT_SIGNAL(hitPoints(int,int)), TQT_SLOT(hitPoints(int,int))); - TQObject::connect(playfield,TQT_SIGNAL(wins(int,int)),TQT_SLOT(wins(int,int))); - TQObject::connect(playfield,TQT_SIGNAL(setStatusText(const TQString &,int)), + TQT_BASE_OBJECT_NAME::connect(TQT_TQOBJECT(playfield),TQT_SIGNAL(wins(int,int)),TQT_SLOT(wins(int,int))); + TQT_BASE_OBJECT_NAME::connect(TQT_TQOBJECT(playfield),TQT_SIGNAL(setStatusText(const TQString &,int)), TQT_SLOT(setStatusText(const TQString &,int))); setCentralWidget(w); @@ -62,18 +62,18 @@ void MyTopLevelWidget::wins(int pn,int w) void MyTopLevelWidget::initActions( ) { - KStdGameAction::quit(this, TQT_SLOT(close()), actionCollection()); - KStdGameAction::gameNew(playfield, TQT_SLOT(newGame()), actionCollection()); + KStdGameAction::quit(TQT_TQOBJECT(this), TQT_SLOT(close()), actionCollection()); + KStdGameAction::gameNew(TQT_TQOBJECT(playfield), TQT_SLOT(newGame()), actionCollection()); ( void )new KAction( i18n( "&New Round" ), "spnewround", - CTRL + Key_R, playfield, TQT_SLOT( newRound( ) ), + CTRL + Key_R, TQT_TQOBJECT(playfield), TQT_SLOT( newRound( ) ), actionCollection( ), "new_round" ); MyMainView::pauseAction = - KStdGameAction::pause(playfield, TQT_SLOT(togglePause()), actionCollection()); + KStdGameAction::pause(TQT_TQOBJECT(playfield), TQT_SLOT(togglePause()), actionCollection()); MyMainView::pauseAction->setChecked( false ); KAction* gameStart = new KAction( i18n( "Start" ), GAME_START_SHORTCUT, - playfield, TQT_SLOT( start( ) ), actionCollection( ), "game_start" ); + TQT_TQOBJECT(playfield), TQT_SLOT( start( ) ), actionCollection( ), "game_start" ); - KStdAction::preferences(playfield, TQT_SLOT(gameSetup()), actionCollection()); + KStdAction::preferences(TQT_TQOBJECT(playfield), TQT_SLOT(gameSetup()), actionCollection()); KAccel* acc = new KAccel(this); gameStart->plugAccel(acc); diff --git a/kspaceduel/topwidget.h b/kspaceduel/topwidget.h index 7c86a39c..9563fe35 100644 --- a/kspaceduel/topwidget.h +++ b/kspaceduel/topwidget.h @@ -9,6 +9,7 @@ class MyMainView; class MyTopLevelWidget:public KMainWindow { Q_OBJECT + TQ_OBJECT public: MyTopLevelWidget(); void start(); -- cgit v1.2.3