summaryrefslogtreecommitdiffstats
path: root/kolf/slope.cpp
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 /kolf/slope.cpp
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 'kolf/slope.cpp')
-rw-r--r--kolf/slope.cpp142
1 files changed, 71 insertions, 71 deletions
diff --git a/kolf/slope.cpp b/kolf/slope.cpp
index e2becea1..a6a1abf1 100644
--- a/kolf/slope.cpp
+++ b/kolf/slope.cpp
@@ -1,9 +1,9 @@
-#include <qbitmap.h>
-#include <qcheckbox.h>
-#include <qlabel.h>
-#include <qimage.h>
-#include <qpixmapcache.h>
-#include <qwhatsthis.h>
+#include <tqbitmap.h>
+#include <tqcheckbox.h>
+#include <tqlabel.h>
+#include <tqimage.h>
+#include <tqpixmapcache.h>
+#include <tqwhatsthis.h>
#include <kapplication.h>
#include <kcombobox.h>
@@ -14,8 +14,8 @@
#include "slope.h"
-Slope::Slope(QRect rect, QCanvas *canvas)
- : QCanvasRectangle(rect, canvas), type(KImageEffect::VerticalGradient), grade(4), reversed(false), color(QColor("#327501"))
+Slope::Slope(TQRect rect, TQCanvas *canvas)
+ : TQCanvasRectangle(rect, canvas), type(KImageEffect::VerticalGradient), grade(4), reversed(false), color(TQColor("#327501"))
{
stuckOnGround = false;
showingInfo = false;
@@ -34,17 +34,17 @@ Slope::Slope(QRect rect, QCanvas *canvas)
setZ(-50);
- if (!QPixmapCache::find("grass", grass))
+ if (!TQPixmapCache::find("grass", grass))
{
grass.load(locate("appdata", "pics/grass.png"));
- QPixmapCache::insert("grass", grass);
+ TQPixmapCache::insert("grass", grass);
}
point = new RectPoint(color.light(), this, canvas);
- QFont font(kapp->font());
+ TQFont font(kapp->font());
font.setPixelSize(18);
- text = new QCanvasText(canvas);
+ text = new TQCanvasText(canvas);
text->setZ(99999.99);
text->setFont(font);
text->setColor(white);
@@ -103,9 +103,9 @@ void Slope::clearArrows()
arrows.setAutoDelete(false);
}
-QPtrList<QCanvasItem> Slope::moveableItems() const
+TQPtrList<TQCanvasItem> Slope::moveableItems() const
{
- QPtrList<QCanvasItem> ret;
+ TQPtrList<TQCanvasItem> ret;
ret.append(point);
return ret;
}
@@ -128,7 +128,7 @@ void Slope::newSize(int width, int height)
{
if (type == KImageEffect::EllipticGradient)
{
- QCanvasRectangle::setSize(width, width);
+ TQCanvasRectangle::setSize(width, width);
// move point back to good spot
moveBy(0, 0);
@@ -136,7 +136,7 @@ void Slope::newSize(int width, int height)
game->updateHighlighter();
}
else
- QCanvasRectangle::setSize(width, height);
+ TQCanvasRectangle::setSize(width, height);
updatePixmap();
updateZ();
@@ -144,7 +144,7 @@ void Slope::newSize(int width, int height)
void Slope::moveBy(double dx, double dy)
{
- QCanvasRectangle::moveBy(dx, dy);
+ TQCanvasRectangle::moveBy(dx, dy);
point->dontMove();
point->move(x() + width(), y() + height());
@@ -156,7 +156,7 @@ void Slope::moveBy(double dx, double dy)
void Slope::moveArrow()
{
int xavg = 0, yavg = 0;
- QPointArray r = areaPoints();
+ TQPointArray r = areaPoints();
for (unsigned int i = 0; i < r.size(); ++i)
{
xavg += r[i].x();
@@ -183,14 +183,14 @@ void Slope::editModeChanged(bool changed)
moveBy(0, 0);
}
-void Slope::updateZ(QCanvasRectangle *vStrut)
+void Slope::updateZ(TQCanvasRectangle *vStrut)
{
const int area = (height() * width());
const int defaultz = -50;
double newZ = 0;
- QCanvasRectangle *rect = 0;
+ TQCanvasRectangle *rect = 0;
if (!stuckOnGround)
rect = vStrut? vStrut : onVStrut();
@@ -214,10 +214,10 @@ void Slope::load(KConfig *cfg)
reversed = cfg->readBoolEntry("reversed", reversed);
// bypass updatePixmap which newSize normally does
- QCanvasRectangle::setSize(cfg->readNumEntry("width", width()), cfg->readNumEntry("height", height()));
+ TQCanvasRectangle::setSize(cfg->readNumEntry("width", width()), cfg->readNumEntry("height", height()));
updateZ();
- QString gradientType = cfg->readEntry("gradient", gradientKeys[type]);
+ TQString gradientType = cfg->readEntry("gradient", gradientKeys[type]);
setGradient(gradientType);
}
@@ -231,44 +231,44 @@ void Slope::save(KConfig *cfg)
cfg->writeEntry("stuckOnGround", stuckOnGround);
}
-void Slope::draw(QPainter &painter)
+void Slope::draw(TQPainter &painter)
{
painter.drawPixmap(x(), y(), pixmap);
}
-QPointArray Slope::areaPoints() const
+TQPointArray Slope::areaPoints() const
{
switch (type)
{
case KImageEffect::CrossDiagonalGradient:
{
- QPointArray ret(3);
- ret[0] = QPoint((int)x(), (int)y());
- ret[1] = QPoint((int)x() + width(), (int)y() + height());
- ret[2] = reversed? QPoint((int)x() + width(), y()) : QPoint((int)x(), (int)y() + height());
+ TQPointArray ret(3);
+ ret[0] = TQPoint((int)x(), (int)y());
+ ret[1] = TQPoint((int)x() + width(), (int)y() + height());
+ ret[2] = reversed? TQPoint((int)x() + width(), y()) : TQPoint((int)x(), (int)y() + height());
return ret;
}
case KImageEffect::DiagonalGradient:
{
- QPointArray ret(3);
- ret[0] = QPoint((int)x() + width(), (int)y());
- ret[1] = QPoint((int)x(), (int)y() + height());
- ret[2] = !reversed? QPoint((int)x() + width(), y() + height()) : QPoint((int)x(), (int)y());
+ TQPointArray ret(3);
+ ret[0] = TQPoint((int)x() + width(), (int)y());
+ ret[1] = TQPoint((int)x(), (int)y() + height());
+ ret[2] = !reversed? TQPoint((int)x() + width(), y() + height()) : TQPoint((int)x(), (int)y());
return ret;
}
case KImageEffect::EllipticGradient:
{
- QPointArray ret;
+ TQPointArray ret;
ret.makeEllipse((int)x(), (int)y(), width(), height());
return ret;
}
default:
- return QCanvasRectangle::areaPoints();
+ return TQCanvasRectangle::areaPoints();
}
}
@@ -290,8 +290,8 @@ bool Slope::collision(Ball *ball, long int /*id*/)
slopeAngle = atan((double)width() / (double)height());
else if (circle)
{
- const QPoint start(x() + (int)width() / 2.0, y() + (int)height() / 2.0);
- const QPoint end((int)ball->x(), (int)ball->y());
+ const TQPoint start(x() + (int)width() / 2.0, y() + (int)height() / 2.0);
+ const TQPoint end((int)ball->x(), (int)ball->y());
Vector betweenVector(start, end);
const double factor = betweenVector.magnitude() / ((double)width() / 2.0);
@@ -339,9 +339,9 @@ bool Slope::collision(Ball *ball, long int /*id*/)
return false;
}
-void Slope::setGradient(QString text)
+void Slope::setGradient(TQString text)
{
- for (QMap<KImageEffect::GradientType, QString>::Iterator it = gradientKeys.begin(); it != gradientKeys.end(); ++it)
+ for (TQMap<KImageEffect::GradientType, TQString>::Iterator it = gradientKeys.begin(); it != gradientKeys.end(); ++it)
{
if (it.data() == text)
{
@@ -351,7 +351,7 @@ void Slope::setGradient(QString text)
}
// extra forgiveness ;-) (note it's i18n keys)
- for (QMap<KImageEffect::GradientType, QString>::Iterator it = gradientI18nKeys.begin(); it != gradientI18nKeys.end(); ++it)
+ for (TQMap<KImageEffect::GradientType, TQString>::Iterator it = gradientI18nKeys.begin(); it != gradientI18nKeys.end(); ++it)
{
if (it.data() == text)
{
@@ -385,28 +385,28 @@ void Slope::updatePixmap()
const bool diag = type == KImageEffect::DiagonalGradient || type == KImageEffect::CrossDiagonalGradient;
const bool circle = type == KImageEffect::EllipticGradient;
- const QColor darkColor = color.dark(100 + grade * (circle? 20 : 10));
- const QColor lightColor = diag || circle? color.light(110 + (diag? 5 : .5) * grade) : color;
+ const TQColor darkColor = color.dark(100 + grade * (circle? 20 : 10));
+ const TQColor lightColor = diag || circle? color.light(110 + (diag? 5 : .5) * grade) : color;
// hack only for circles
const bool _reversed = circle? !reversed : reversed;
- QImage gradientImage = KImageEffect::gradient(QSize(width(), height()), _reversed? darkColor : lightColor, _reversed? lightColor : darkColor, type);
+ TQImage gradientImage = KImageEffect::gradient(TQSize(width(), height()), _reversed? darkColor : lightColor, _reversed? lightColor : darkColor, type);
- QPixmap qpixmap(width(), height());
- QPainter p(&qpixmap);
- p.drawTiledPixmap(QRect(0, 0, width(), height()), grass);
+ TQPixmap qpixmap(width(), height());
+ TQPainter p(&qpixmap);
+ p.drawTiledPixmap(TQRect(0, 0, width(), height()), grass);
p.end();
const double length = sqrt(width() * width() + height() * height()) / 4;
if (circle)
{
- const QColor otherLightColor = color.light(110 + 15 * grade);
- const QColor otherDarkColor = darkColor.dark(110 + 20 * grade);
- QImage otherGradientImage = KImageEffect::gradient(QSize(width(), height()), reversed? otherDarkColor : otherLightColor, reversed? otherLightColor : otherDarkColor, KImageEffect::DiagonalGradient);
+ const TQColor otherLightColor = color.light(110 + 15 * grade);
+ const TQColor otherDarkColor = darkColor.dark(110 + 20 * grade);
+ TQImage otherGradientImage = KImageEffect::gradient(TQSize(width(), height()), reversed? otherDarkColor : otherLightColor, reversed? otherLightColor : otherDarkColor, KImageEffect::DiagonalGradient);
- QImage grassImage(qpixmap.convertToImage());
+ TQImage grassImage(qpixmap.convertToImage());
- QImage finalGradientImage = KImageEffect::blend(otherGradientImage, gradientImage, .60);
+ TQImage finalGradientImage = KImageEffect::blend(otherGradientImage, gradientImage, .60);
pixmap.convertFromImage(KImageEffect::blend(grassImage, finalGradientImage, .40));
// make arrows
@@ -475,7 +475,7 @@ void Slope::updatePixmap()
KPixmap kpixmap = qpixmap;
(void) KPixmapEffect::intensity(kpixmap, ratio);
- QImage grassImage(kpixmap.convertToImage());
+ TQImage grassImage(kpixmap.convertToImage());
// okay, now we have a grass image that's
// appropriately lit, and a gradient;
@@ -488,20 +488,20 @@ void Slope::updatePixmap()
arrows.append(arrow);
}
- text->setText(QString::number(grade));
+ text->setText(TQString::number(grade));
if (diag || circle)
{
// make cleared bitmap
- QBitmap bitmap(pixmap.width(), pixmap.height(), true);
- QPainter bpainter(&bitmap);
+ TQBitmap bitmap(pixmap.width(), pixmap.height(), true);
+ TQPainter bpainter(&bitmap);
bpainter.setBrush(color1);
- QPointArray r = areaPoints();
+ TQPointArray r = areaPoints();
// shift all the points
for (unsigned int i = 0; i < r.count(); ++i)
{
- QPoint &p = r[i];
+ TQPoint &p = r[i];
p.setX(p.x() - x());
p.setY(p.y() - y());
}
@@ -517,15 +517,15 @@ void Slope::updatePixmap()
/////////////////////////
-SlopeConfig::SlopeConfig(Slope *slope, QWidget *parent)
+SlopeConfig::SlopeConfig(Slope *slope, TQWidget *parent)
: Config(parent)
{
this->slope = slope;
- QVBoxLayout *layout = new QVBoxLayout(this, marginHint(), spacingHint());
+ TQVBoxLayout *layout = new TQVBoxLayout(this, marginHint(), spacingHint());
KComboBox *gradient = new KComboBox(this);
- QStringList items;
- QString curText;
- for (QMap<KImageEffect::GradientType, QString>::Iterator it = slope->gradientI18nKeys.begin(); it != slope->gradientI18nKeys.end(); ++it)
+ TQStringList items;
+ TQString curText;
+ for (TQMap<KImageEffect::GradientType, TQString>::Iterator it = slope->gradientI18nKeys.begin(); it != slope->gradientI18nKeys.end(); ++it)
{
if (it.key() == slope->curType())
curText = it.data();
@@ -534,31 +534,31 @@ SlopeConfig::SlopeConfig(Slope *slope, QWidget *parent)
gradient->insertStringList(items);
gradient->setCurrentText(curText);
layout->addWidget(gradient);
- connect(gradient, SIGNAL(activated(const QString &)), this, SLOT(setGradient(const QString &)));
+ connect(gradient, TQT_SIGNAL(activated(const TQString &)), this, TQT_SLOT(setGradient(const TQString &)));
layout->addStretch();
- QCheckBox *reversed = new QCheckBox(i18n("Reverse direction"), this);
+ TQCheckBox *reversed = new TQCheckBox(i18n("Reverse direction"), this);
reversed->setChecked(slope->isReversed());
layout->addWidget(reversed);
- connect(reversed, SIGNAL(toggled(bool)), this, SLOT(setReversed(bool)));
+ connect(reversed, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setReversed(bool)));
- QHBoxLayout *hlayout = new QHBoxLayout(layout, spacingHint());
- hlayout->addWidget(new QLabel(i18n("Grade:"), this));
+ TQHBoxLayout *hlayout = new TQHBoxLayout(layout, spacingHint());
+ hlayout->addWidget(new TQLabel(i18n("Grade:"), this));
KDoubleNumInput *grade = new KDoubleNumInput(this);
grade->setRange(0, 8, 1, true);
grade->setValue(slope->curGrade());
hlayout->addWidget(grade);
- connect(grade, SIGNAL(valueChanged(double)), this, SLOT(gradeChanged(double)));
+ connect(grade, TQT_SIGNAL(valueChanged(double)), this, TQT_SLOT(gradeChanged(double)));
- QCheckBox *stuck = new QCheckBox(i18n("Unmovable"), this);
- QWhatsThis::add(stuck, i18n("Whether or not this slope can be moved by other objects, like floaters."));
+ TQCheckBox *stuck = new TQCheckBox(i18n("Unmovable"), this);
+ TQWhatsThis::add(stuck, i18n("Whether or not this slope can be moved by other objects, like floaters."));
stuck->setChecked(slope->isStuckOnGround());
layout->addWidget(stuck);
- connect(stuck, SIGNAL(toggled(bool)), this, SLOT(setStuckOnGround(bool)));
+ connect(stuck, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(setStuckOnGround(bool)));
}
-void SlopeConfig::setGradient(const QString &text)
+void SlopeConfig::setGradient(const TQString &text)
{
slope->setGradient(text);
changed();