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 --- kasteroids/ledmeter.cpp | 4 +- kasteroids/ledmeter.h | 7 ++-- kasteroids/sprites.h | 14 +++---- kasteroids/sprites/rock1/rock1.pov | 2 +- kasteroids/sprites/rock2/rock2.pov | 2 +- kasteroids/sprites/rock3/rock3.pov | 2 +- kasteroids/toplevel.cpp | 76 +++++++++++++++++++------------------- kasteroids/toplevel.h | 1 + kasteroids/view.cpp | 6 +-- kasteroids/view.h | 5 ++- 10 files changed, 61 insertions(+), 58 deletions(-) (limited to 'kasteroids') diff --git a/kasteroids/ledmeter.cpp b/kasteroids/ledmeter.cpp index 1d807d18..d2250c28 100644 --- a/kasteroids/ledmeter.cpp +++ b/kasteroids/ledmeter.cpp @@ -8,7 +8,7 @@ #include "ledmeter.h" #include "ledmeter.moc" -KALedMeter::KALedMeter( TQWidget *parent ) : TQFrame( parent ) +KALedMeter::KALedMeter( TQWidget *tqparent ) : TQFrame( tqparent ) { mCRanges.setAutoDelete( true ); mRange = 100; @@ -76,7 +76,7 @@ void KALedMeter::drawContents( TQPainter *p ) unsigned cidx = 0; int ncol = mCount; - TQColor col = colorGroup().foreground(); + TQColor col = tqcolorGroup().foreground(); if ( !mCRanges.isEmpty() ) { diff --git a/kasteroids/ledmeter.h b/kasteroids/ledmeter.h index 307b5bfc..7547bcd1 100644 --- a/kasteroids/ledmeter.h +++ b/kasteroids/ledmeter.h @@ -11,11 +11,12 @@ #include -class KALedMeter : public QFrame +class KALedMeter : public TQFrame { - Q_OBJECT + Q_OBJECT + TQ_OBJECT public: - KALedMeter( TQWidget *parent ); + KALedMeter( TQWidget *tqparent ); int range() const { return mRange; } void setRange( int r ); diff --git a/kasteroids/sprites.h b/kasteroids/sprites.h index 43dc34ea..1f39e74a 100644 --- a/kasteroids/sprites.h +++ b/kasteroids/sprites.h @@ -31,7 +31,7 @@ #define MAX_POWERUP_AGE 500 #define MAX_MISSILE_AGE 40 -class KMissile : public QCanvasSprite +class KMissile : public TQCanvasSprite { public: KMissile( TQCanvasPixmapArray *s, TQCanvas *c ) : TQCanvasSprite( s, c ) @@ -46,7 +46,7 @@ private: int myAge; }; -class KBit : public QCanvasSprite +class KBit : public TQCanvasSprite { public: KBit( TQCanvasPixmapArray *s, TQCanvas *c ) : TQCanvasSprite( s, c ) @@ -62,7 +62,7 @@ private: int death; }; -class KExhaust : public QCanvasSprite +class KExhaust : public TQCanvasSprite { public: KExhaust( TQCanvasPixmapArray *s, TQCanvas *c ) : TQCanvasSprite( s, c ) @@ -78,7 +78,7 @@ private: int death; }; -class KPowerup : public QCanvasSprite +class KPowerup : public TQCanvasSprite { public: KPowerup( TQCanvasPixmapArray *s, TQCanvas *c, int t ) : TQCanvasSprite( s, c ), @@ -94,7 +94,7 @@ protected: int type; }; -class KRock : public QCanvasSprite +class KRock : public TQCanvasSprite { public: KRock (TQCanvasPixmapArray *s, TQCanvas *c, int t, int sk, int st) : TQCanvasSprite( s, c ) @@ -104,7 +104,7 @@ public: { if (cskip-- <= 0) { setFrame( (frame()+step+frameCount())%frameCount() ); - cskip = QABS(skip); + cskip = TQABS(skip); } } @@ -117,7 +117,7 @@ private: int step; }; -class KShield : public QCanvasSprite +class KShield : public TQCanvasSprite { public: KShield( TQCanvasPixmapArray *s, TQCanvas *c ) diff --git a/kasteroids/sprites/rock1/rock1.pov b/kasteroids/sprites/rock1/rock1.pov index 58298c05..bcf4c8a7 100644 --- a/kasteroids/sprites/rock1/rock1.pov +++ b/kasteroids/sprites/rock1/rock1.pov @@ -1,5 +1,5 @@ #include "colors.inc" -#include "shapes.inc" +#include "tqshapes.inc" #include "textures.inc" // #include "stones.inc" diff --git a/kasteroids/sprites/rock2/rock2.pov b/kasteroids/sprites/rock2/rock2.pov index 2f37a206..625c7854 100644 --- a/kasteroids/sprites/rock2/rock2.pov +++ b/kasteroids/sprites/rock2/rock2.pov @@ -1,5 +1,5 @@ #include "colors.inc" -#include "shapes.inc" +#include "tqshapes.inc" #include "textures.inc" // #include "stones.inc" diff --git a/kasteroids/sprites/rock3/rock3.pov b/kasteroids/sprites/rock3/rock3.pov index 2f37a206..625c7854 100644 --- a/kasteroids/sprites/rock3/rock3.pov +++ b/kasteroids/sprites/rock3/rock3.pov @@ -1,5 +1,5 @@ #include "colors.inc" -#include "shapes.inc" +#include "tqshapes.inc" #include "textures.inc" // #include "stones.inc" diff --git a/kasteroids/toplevel.cpp b/kasteroids/toplevel.cpp index d9a22a2b..ffc6b8e2 100644 --- a/kasteroids/toplevel.cpp +++ b/kasteroids/toplevel.cpp @@ -29,7 +29,7 @@ #include "toplevel.moc" -#if defined Q_WS_X11 && ! defined K_WS_QTONLY +#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY #include #endif #include @@ -102,7 +102,7 @@ KAstTopLevel::KAstTopLevel() label = new TQLabel( i18n("Score"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); - label->setFixedWidth( label->sizeHint().width() ); + label->setFixedWidth( label->tqsizeHint().width() ); hb->addWidget( label ); scoreLCD = new TQLCDNumber( 6, mainWin ); @@ -116,7 +116,7 @@ KAstTopLevel::KAstTopLevel() label = new TQLabel( i18n("Level"), mainWin ); label->setFont( labelFont ); label->setPalette( pal ); - label->setFixedWidth( label->sizeHint().width() ); + label->setFixedWidth( label->tqsizeHint().width() ); hb->addWidget( label ); levelLCD = new TQLCDNumber( 2, mainWin ); @@ -129,7 +129,7 @@ KAstTopLevel::KAstTopLevel() label = new TQLabel( i18n("Ships"), mainWin ); label->setFont( labelFont ); - label->setFixedWidth( label->sizeHint().width() ); + label->setFixedWidth( label->tqsizeHint().width() ); label->setPalette( pal ); hb->addWidget( label ); @@ -151,7 +151,7 @@ KAstTopLevel::KAstTopLevel() vb->addWidget( view, 10 ); -// -- bottom layout: +// -- bottom tqlayout: TQFrame *sep2 = new TQFrame( mainWin ); sep2->setMaximumHeight( 1 ); sep2->setFrameStyle( TQFrame::HLine | TQFrame::Raised ); @@ -168,7 +168,7 @@ KAstTopLevel::KAstTopLevel() /* label = new TQLabel( i18n( "T" ), mainWin ); label->setFont( smallFont ); - label->setFixedWidth( label->sizeHint().width() ); + label->setFixedWidth( label->tqsizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); @@ -184,7 +184,7 @@ KAstTopLevel::KAstTopLevel() TQPixmap pm( sprites_prefix + "powerups/brake.png" ); label = new TQLabel( mainWin ); label->setPixmap( pm ); - label->setFixedWidth( label->sizeHint().width() ); + label->setFixedWidth( label->tqsizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); @@ -200,7 +200,7 @@ KAstTopLevel::KAstTopLevel() pm.load( sprites_prefix + "powerups/shield.png" ); label = new TQLabel( mainWin ); label->setPixmap( pm ); - label->setFixedWidth( label->sizeHint().width() ); + label->setFixedWidth( label->tqsizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); @@ -216,7 +216,7 @@ KAstTopLevel::KAstTopLevel() pm.load( sprites_prefix + "powerups/shoot.png" ); label = new TQLabel( mainWin ); label->setPixmap( pm ); - label->setFixedWidth( label->sizeHint().width() ); + label->setFixedWidth( label->tqsizeHint().width() ); label->setPalette( pal ); hbd->addWidget( label ); @@ -231,7 +231,7 @@ KAstTopLevel::KAstTopLevel() label = new TQLabel( i18n( "Fuel" ), mainWin ); label->setFont( smallFont ); - label->setFixedWidth( label->sizeHint().width() + 10 ); + label->setFixedWidth( label->tqsizeHint().width() + 10 ); label->setPalette( pal ); hbd->addWidget( label ); @@ -252,7 +252,7 @@ KAstTopLevel::KAstTopLevel() setupGUI( KMainWindow::Save | Create ); - setFocusPolicy( StrongFocus ); + setFocusPolicy( TQ_StrongFocus ); setFocus(); #ifdef KA_ENABLE_SOUND @@ -267,7 +267,7 @@ KAstTopLevel::KAstTopLevel() KAstTopLevel::~KAstTopLevel() { -#if defined Q_WS_X11 && ! defined K_WS_QTONLY +#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY XAutoRepeatOn( qt_xdisplay() ); #endif soundDict.setAutoDelete(true); @@ -280,24 +280,24 @@ KAstTopLevel::~KAstTopLevel() void KAstTopLevel::initKAction() { // game - KStdGameAction::gameNew( this, TQT_SLOT( slotNewGame() ), actionCollection() ); - KStdGameAction::highscores( this, TQT_SLOT( slotShowHighscores() ), actionCollection() ); - KStdGameAction::pause( this, TQT_SLOT( slotPause() ), actionCollection() ); - KStdGameAction::quit(this, TQT_SLOT( close() ), actionCollection()); + KStdGameAction::gameNew( TQT_TQOBJECT(this), TQT_SLOT( slotNewGame() ), actionCollection() ); + KStdGameAction::highscores( TQT_TQOBJECT(this), TQT_SLOT( slotShowHighscores() ), actionCollection() ); + KStdGameAction::pause( TQT_TQOBJECT(this), TQT_SLOT( slotPause() ), actionCollection() ); + KStdGameAction::quit(TQT_TQOBJECT(this), TQT_SLOT( close() ), actionCollection()); // settings - KStdAction::keyBindings(this, TQT_SLOT( slotKeyConfig() ), actionCollection()); - KStdAction::preferences(this, TQT_SLOT( slotPref() ), actionCollection()); + KStdAction::keyBindings(TQT_TQOBJECT(this), TQT_SLOT( slotKeyConfig() ), actionCollection()); + KStdAction::preferences(TQT_TQOBJECT(this), TQT_SLOT( slotPref() ), actionCollection()); // keyboard-only actions - keycodes.insert(Thrust, new KAction(i18n("Thrust"), Qt::Key_Up, 0, 0, actionCollection(), "Thrust")); - keycodes.insert(RotateLeft, new KAction(i18n("Rotate Left"), Qt::Key_Left, 0, 0, actionCollection(), "RotateLeft")); - keycodes.insert(RotateRight, new KAction(i18n("Rotate Right"), Qt::Key_Right, 0, 0, actionCollection(), "RotateRight")); - keycodes.insert(Shoot, new KAction(i18n("Shoot"), Qt::Key_Space, 0, 0, actionCollection(), "Shoot")); -// keycodes.insert(Teleport, new KAction(i18n("Teleport"), Qt::Key_Z, 0, 0, actionCollection(), "Teleport")); - keycodes.insert(Brake, new KAction(i18n("Brake"), Qt::Key_X, 0, 0, actionCollection(), "Brake")); - keycodes.insert(Shield, new KAction(i18n("Shield"), Qt::Key_S, 0, 0, actionCollection(), "Shield")); - launchAction = new KAction(i18n("Launch"), Qt::Key_L, this, TQT_SLOT(slotLaunch()), actionCollection(), "Launch"); + keycodes.insert(Thrust, new KAction(i18n("Thrust"), TQt::Key_Up, 0, 0, actionCollection(), "Thrust")); + keycodes.insert(RotateLeft, new KAction(i18n("Rotate Left"), TQt::Key_Left, 0, 0, actionCollection(), "RotateLeft")); + keycodes.insert(RotateRight, new KAction(i18n("Rotate Right"), TQt::Key_Right, 0, 0, actionCollection(), "RotateRight")); + keycodes.insert(Shoot, new KAction(i18n("Shoot"), TQt::Key_Space, 0, 0, actionCollection(), "Shoot")); +// keycodes.insert(Teleport, new KAction(i18n("Teleport"), TQt::Key_Z, 0, 0, actionCollection(), "Teleport")); + keycodes.insert(Brake, new KAction(i18n("Brake"), TQt::Key_X, 0, 0, actionCollection(), "Brake")); + keycodes.insert(Shield, new KAction(i18n("Shield"), TQt::Key_S, 0, 0, actionCollection(), "Shield")); + launchAction = new KAction(i18n("Launch"), TQt::Key_L, TQT_TQOBJECT(this), TQT_SLOT(slotLaunch()), actionCollection(), "Launch"); } @@ -336,7 +336,7 @@ return; // remove this and the above when the sound below is working correctly bool KAstTopLevel::eventFilter( TQObject* /* object */, TQEvent *event ) { - TQKeyEvent *e = static_cast(event); + TQKeyEvent *e = TQT_TQKEYEVENT(event); if (event->type() == TQEvent::AccelOverride) { if (processKeyPress(e)) return true; @@ -457,7 +457,7 @@ bool KAstTopLevel::processKeyRelease( TQKeyEvent *event ) void KAstTopLevel::focusInEvent( TQFocusEvent *e ) { view->pause( false ); -#if defined Q_WS_X11 && ! defined K_WS_QTONLY +#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY XAutoRepeatOff( qt_xdisplay() ); #endif KMainWindow::focusInEvent(e); @@ -466,7 +466,7 @@ void KAstTopLevel::focusInEvent( TQFocusEvent *e ) void KAstTopLevel::focusOutEvent( TQFocusEvent *e ) { view->pause( true ); -#if defined Q_WS_X11 && ! defined K_WS_QTONLY +#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY XAutoRepeatOn( qt_xdisplay() ); #endif KMainWindow::focusOutEvent(e); @@ -484,7 +484,7 @@ void KAstTopLevel::slotNewGame() view->setRockSpeed( levels[0].rockSpeed ); view->addRocks( levels[0].nrocks ); view->showText( i18n( "Press %1 to launch." ) - .arg(launchAction->shortcut().seq(0).toString()), + .tqarg(launchAction->shortcut().seq(0).toString()), yellow ); waitShip = true; gameOver = false; @@ -492,7 +492,7 @@ void KAstTopLevel::slotNewGame() bool KAstTopLevel::queryExit() { -#if defined Q_WS_X11 && ! defined K_WS_QTONLY +#if defined TQ_WS_X11 && ! defined K_WS_TQTONLY XAutoRepeatOn( qt_xdisplay() ); #endif return true; @@ -509,7 +509,7 @@ void KAstTopLevel::slotShipKilled() { waitShip = true; view->showText( i18n( "Ship Destroyed. Press %1 to launch.") - .arg(launchAction->shortcut().seq(0).toString()), + .tqarg(launchAction->shortcut().seq(0).toString()), yellow ); } else @@ -529,7 +529,7 @@ void KAstTopLevel::slotShipKilled() } else { - TQTimer::singleShot(1000, this, TQT_SLOT(slotGameOver())); + TQTimer::singleShot(1000, TQT_TQOBJECT(this), TQT_SLOT(slotGameOver())); } } } @@ -577,7 +577,7 @@ void KAstTopLevel::slotKeyConfig() { KKeyDialog::configure( actionCollection(), this ); if ( waitShip ) view->showText( i18n( "Press %1 to launch." ) - .arg(launchAction->shortcut().seq(0).toString()), + .tqarg(launchAction->shortcut().seq(0).toString()), yellow, false ); } @@ -613,7 +613,7 @@ void KAstTopLevel::slotPref() /* Done */ dialog->addPage(w, i18n("General"), "package_settings"); - connect(dialog, TQT_SIGNAL(settingsChanged()), this, TQT_SLOT(loadSettings())); + connect(dialog, TQT_SIGNAL(settingsChanged()), TQT_TQOBJECT(this), TQT_SLOT(loadSettings())); dialog->show(); } @@ -637,9 +637,9 @@ void KAstTopLevel::doStats() " Hit:\t%2\n" " Missed:\t%3\n" "Hit ratio:\t%4 %\t\t") - .arg(view->shots()).arg(view->hits()) - .arg(view->shots() - view->hits()) - .arg(r); + .tqarg(view->shots()).tqarg(view->hits()) + .tqarg(view->shots() - view->hits()) + .tqarg(r); view->showText( s, green, FALSE ); } diff --git a/kasteroids/toplevel.h b/kasteroids/toplevel.h index c75710eb..54af5130 100644 --- a/kasteroids/toplevel.h +++ b/kasteroids/toplevel.h @@ -23,6 +23,7 @@ class KDialogBase; class KAstTopLevel : public KMainWindow { Q_OBJECT + TQ_OBJECT public: KAstTopLevel(); virtual ~KAstTopLevel(); diff --git a/kasteroids/view.cpp b/kasteroids/view.cpp index e203ffb5..0fea036b 100644 --- a/kasteroids/view.cpp +++ b/kasteroids/view.cpp @@ -63,8 +63,8 @@ kas_animations [] = -KAsteroidsView::KAsteroidsView( TQWidget *parent, const char *name ) - : TQWidget( parent, name ), +KAsteroidsView::KAsteroidsView( TQWidget *tqparent, const char *name ) + : TQWidget( tqparent, name ), field(640, 440), view(&field,this) { @@ -78,7 +78,7 @@ KAsteroidsView::KAsteroidsView( TQWidget *parent, const char *name ) field.setBackgroundColor(black); TQPixmap pm( locate("sprite", IMG_BACKGROUND) ); - field.setBackgroundPixmap( pm ); + field.tqsetBackgroundPixmap( pm ); textSprite = new TQCanvasText( &field ); TQFont font( KGlobalSettings::generalFont().family(), 18 ); diff --git a/kasteroids/view.h b/kasteroids/view.h index 5d62f640..48b72e9f 100644 --- a/kasteroids/view.h +++ b/kasteroids/view.h @@ -17,11 +17,12 @@ #define MAX_POWER_LEVEL 1000 -class KAsteroidsView : public QWidget +class KAsteroidsView : public TQWidget { Q_OBJECT + TQ_OBJECT public: - KAsteroidsView( TQWidget *parent = 0, const char *name = 0 ); + KAsteroidsView( TQWidget *tqparent = 0, const char *name = 0 ); virtual ~KAsteroidsView(); int refreshRate; -- cgit v1.2.1