[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/base/plasma/applets/slideInSlideOut
From: Aaron J. Seigo <aseigo () kde ! org>
Date: 2008-09-30 23:38:13
Message-ID: 1222817893.809336.10079.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 866474 by aseigo:
more best practices
M +18 -10 SlideInSlideOut.cpp
M +5 -17 SlideInSlideOut.h
--- trunk/playground/base/plasma/applets/slideInSlideOut/SlideInSlideOut.cpp #866473:866474
@@ -19,10 +19,11 @@
#include "SlideInSlideOut.h"
+#include <QPainter>
+
#include <KDebug>
#include <KLocale>
-#include <plasma/svg.h>
#include <plasma/animator.h>
#include <plasma/corona.h>
#include <plasma/animator.h>
@@ -34,11 +35,10 @@
: Plasma::Applet(parent, args),
m_out(true)
{
- m_theme = new Plasma::Svg(this);
- m_theme->setImagePath("widgets/connection-established");
- t = new QTimer(this);
- connect(t, SIGNAL(timeout()), this, SLOT(moveMyself()));
- resize(100,100);
+ m_theme.setImagePath("widgets/connection-established");
+ t.setInterval(1000);
+ connect(&t, SIGNAL(timeout()), this, SLOT(moveMyself()));
+ resize(100, 100);
}
SlideInSlideOut::~SlideInSlideOut()
@@ -47,13 +47,15 @@
void SlideInSlideOut::init()
{
- t->start(1000);
+ connect(Plasma::Animator::self(), SIGNAL(movementFinished(QGraphicsItem*)),
+ this, SLOT(movementFinished(QGraphicsItem*)));
+ moveMyself();
}
void SlideInSlideOut::constraintsEvent(Plasma::Constraints constraints)
{
if (constraints & Plasma::SizeConstraint) {
- m_theme->resize(contentsRect().size());
+ m_theme.resize(contentsRect().size());
}
}
@@ -63,7 +65,7 @@
Q_UNUSED(option);
QRectF contRect = this->contentsRect();
p->setRenderHint(QPainter::SmoothPixmapTransform);
- m_theme->paint(p, contRect.toRect(), "layer1");
+ m_theme.paint(p, contRect.toRect(), "layer1");
}
void SlideInSlideOut::moveMyself()
@@ -77,8 +79,14 @@
}
m_out = !m_out;
- t->start(1000);
}
+void SlideInSlideOut::movementFinished(QGraphicsItem *item)
+{
+ if (item == this) {
+ t.start();
+ }
+}
+
#include "SlideInSlideOut.moc"
--- trunk/playground/base/plasma/applets/slideInSlideOut/SlideInSlideOut.h #866473:866474
@@ -22,19 +22,12 @@
#include <QTimer>
-#include <QPainter>
#include <plasma/applet.h>
-#include <plasma/dataengine.h>
+#include <plasma/svg.h>
-class QTimer;
+class QPainter;
-
-namespace Plasma
-{
- class Svg;
-}
-
class SlideInSlideOut : public Plasma::Applet
{
Q_OBJECT
@@ -48,17 +41,12 @@
private slots:
void moveMyself();
+ void movementFinished(QGraphicsItem *);
private:
-
- QRectF m_bounds;
- int m_pixelSize;
- QString m_timezone;
- Plasma::Svg* m_theme;
+ QTimer t;
+ Plasma::Svg m_theme;
bool m_out;
- int x;
- int y;
- QTimer *t;
};
K_EXPORT_PLASMA_APPLET(slideInSlideOut, SlideInSlideOut)
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic