diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | c90c389a8a8d9d8661e9772ec4144c5cf2039f23 (patch) | |
tree | 6d8391395bce9eaea4ad78958617edb20c6a7573 /kolf/objects/poolball/poolball.cpp | |
download | tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.tar.gz tdegames-c90c389a8a8d9d8661e9772ec4144c5cf2039f23.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kolf/objects/poolball/poolball.cpp')
-rw-r--r-- | kolf/objects/poolball/poolball.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/kolf/objects/poolball/poolball.cpp b/kolf/objects/poolball/poolball.cpp new file mode 100644 index 00000000..a5ca80ec --- /dev/null +++ b/kolf/objects/poolball/poolball.cpp @@ -0,0 +1,86 @@ +#include <qbrush.h> +#include <qcolor.h> +#include <qcanvas.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> + +#include <klocale.h> +#include <klibloader.h> +#include <kapplication.h> +#include <kdebug.h> +#include <knuminput.h> +#include <kconfig.h> + +#include <kolf/statedb.h> +#include <kolf/canvasitem.h> +#include "poolball.h" + +K_EXPORT_COMPONENT_FACTORY(libkolfpoolball, PoolBallFactory) +QObject *PoolBallFactory::createObject (QObject *, const char *, const char *, const QStringList &) { return new PoolBallObj; } + +PoolBall::PoolBall(QCanvas *canvas) + : Ball(canvas) +{ + setBrush(black); + m_number = 1; +} + +void PoolBall::save(KConfig *cfg) +{ + cfg->writeEntry("number", number()); +} + +void PoolBall::saveState(StateDB *db) +{ + db->setPoint(QPoint(x(), y())); +} + +void PoolBall::load(KConfig *cfg) +{ + setNumber(cfg->readNumEntry("number", 1)); +} + +void PoolBall::loadState(StateDB *db) +{ + move(db->point().x(), db->point().y()); + setVelocity(0, 0); + setState(Stopped); +} + +void PoolBall::draw(QPainter &p) +{ + // we should draw the number here + Ball::draw(p); +} + +PoolBallConfig::PoolBallConfig(PoolBall *poolBall, QWidget *parent) + : Config(parent), m_poolBall(poolBall) +{ + QVBoxLayout *layout = new QVBoxLayout(this, marginHint(), spacingHint()); + + layout->addStretch(); + + QLabel *num = new QLabel(i18n("Number:"), this); + layout->addWidget(num); + KIntNumInput *slider = new KIntNumInput(m_poolBall->number(), this); + slider->setRange(1, 15); + layout->addWidget(slider); + + layout->addStretch(); + + connect(slider, SIGNAL(valueChanged(int)), this, SLOT(numberChanged(int))); +} + +void PoolBallConfig::numberChanged(int newNumber) +{ + m_poolBall->setNumber(newNumber); + changed(); +} + +Config *PoolBall::config(QWidget *parent) +{ + return new PoolBallConfig(this, parent); +} + +#include "poolball.moc" |