From daffafb9fedc3552d489450d4968e9015f7bf752 Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Thu, 15 Apr 2010 18:51:26 +0000 Subject: [PATCH] s/pulsershadow/widgetsnapshot svn path=/trunk/KDE/kdelibs/; revision=1115254 --- CMakeLists.txt | 2 +- animations/pulser.cpp | 5 +-- animations/pulser_p.h | 4 +- .../{pulsershadow.cpp => widgetsnapshot.cpp} | 37 +++++++++++-------- .../{pulsershadow_p.h => widgetsnapshot_p.h} | 27 ++++++++------ 5 files changed, 41 insertions(+), 34 deletions(-) rename animations/{pulsershadow.cpp => widgetsnapshot.cpp} (75%) rename animations/{pulsershadow_p.h => widgetsnapshot_p.h} (71%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7c8093b5c..6ca3d4787 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,7 +56,7 @@ set(plasma_LIB_SRCS animations/slide.cpp animations/pixmaptransition.cpp animations/pulser.cpp - animations/pulsershadow.cpp + animations/widgetsnapshot.cpp animations/rotation.cpp animations/rotationstacked.cpp animations/stackedlayout.cpp diff --git a/animations/pulser.cpp b/animations/pulser.cpp index ed640fbdd..829a6a49a 100644 --- a/animations/pulser.cpp +++ b/animations/pulser.cpp @@ -15,6 +15,7 @@ * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include "widgetsnapshot_p.h" #include "pulser_p.h" #include @@ -25,8 +26,6 @@ #include -#include "pulsershadow_p.h" - namespace Plasma { @@ -63,7 +62,7 @@ void PulseAnimation::setCopy() } if (!m_under.data()) { - m_under = new ShadowFake; + m_under = new WidgetSnapShot; } m_under.data()->setTarget(target); diff --git a/animations/pulser_p.h b/animations/pulser_p.h index be805dfc0..6636999bb 100644 --- a/animations/pulser_p.h +++ b/animations/pulser_p.h @@ -29,7 +29,7 @@ namespace Plasma { -class ShadowFake; +class WidgetSnapShot; /** * @class PulseAnimation plasma/animations/pulser_p.h @@ -96,7 +96,7 @@ private: /** The shadow copy (it really is a QGraphicsWidget with a pixmap * copy of the original widget). */ - QWeakPointer m_under; + QWeakPointer m_under; }; } diff --git a/animations/pulsershadow.cpp b/animations/widgetsnapshot.cpp similarity index 75% rename from animations/pulsershadow.cpp rename to animations/widgetsnapshot.cpp index 13394afae..a6416db52 100644 --- a/animations/pulsershadow.cpp +++ b/animations/widgetsnapshot.cpp @@ -15,18 +15,20 @@ License along with this library. If not, see . */ -#include "pulsershadow_p.h" +#include "widgetsnapshot_p.h" + #include #include #include #include #include + static const int RECURSION_MAX = 20; namespace Plasma { -ShadowFake::ShadowFake(QGraphicsItem *parent) +WidgetSnapShot::WidgetSnapShot(QGraphicsItem *parent) : QGraphicsWidget(parent), m_iconBig(false), stack(0), @@ -34,19 +36,19 @@ ShadowFake::ShadowFake(QGraphicsItem *parent) { } -ShadowFake::~ShadowFake() +WidgetSnapShot::~WidgetSnapShot() { } -void ShadowFake::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) +void WidgetSnapShot::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget); painter->setRenderHint(QPainter::Antialiasing); - painter->drawPixmap(option->exposedRect, m_photo, option->exposedRect); + painter->drawPixmap(option->exposedRect, m_snapShot, option->exposedRect); } -void ShadowFake::paintSubChildren(QPainter *painter, +void WidgetSnapShot::paintSubChildren(QPainter *painter, const QStyleOptionGraphicsItem *option, QGraphicsItem *target) { @@ -69,7 +71,7 @@ void ShadowFake::paintSubChildren(QPainter *painter, --stack; } -void ShadowFake::setTarget(QGraphicsWidget *target) +void WidgetSnapShot::setTarget(QGraphicsWidget *target) { stack = 0; m_target = target; @@ -79,10 +81,10 @@ void ShadowFake::setTarget(QGraphicsWidget *target) if (m_target->property("iconRepresentation").isValid()) { m_iconBig = true; - m_photo = QPixmap::fromImage( + m_snapShot = QPixmap::fromImage( m_target->property("iconRepresentation").value()); - if ((m_photo.height() > 0) && (m_photo.width() > 0)) { - resize(m_photo.size()); + if ((m_snapShot.height() > 0) && (m_snapShot.width() > 0)) { + resize(m_snapShot.size()); setTransformOriginPoint(target->geometry().center()); return; } @@ -90,10 +92,10 @@ void ShadowFake::setTarget(QGraphicsWidget *target) resize(target->size()); - m_photo = QPixmap(size); - m_photo.fill(Qt::transparent); + m_snapShot = QPixmap(size); + m_snapShot.fill(Qt::transparent); - QPainter painter(&m_photo); + QPainter painter(&m_snapShot); painter.setCompositionMode(QPainter::CompositionMode_SourceOver); painter.fillRect(target->rect(), Qt::transparent); @@ -107,17 +109,20 @@ void ShadowFake::setTarget(QGraphicsWidget *target) setTransformOriginPoint(geometry().center()); } -QGraphicsWidget *ShadowFake::target() const +QGraphicsWidget *WidgetSnapShot::target() const { return m_target; } -bool ShadowFake::isIconBigger() +bool WidgetSnapShot::isIconBigger() const { return m_iconBig; } - +QPixmap WidgetSnapShot::snapShot() const +{ + return m_snapShot; } +} diff --git a/animations/pulsershadow_p.h b/animations/widgetsnapshot_p.h similarity index 71% rename from animations/pulsershadow_p.h rename to animations/widgetsnapshot_p.h index 2b54cc688..c65157bf4 100644 --- a/animations/pulsershadow_p.h +++ b/animations/widgetsnapshot_p.h @@ -15,42 +15,45 @@ License along with this library. If not, see . */ -#ifndef PLASMA_PULSERSHADOW_P_H -#define PLASMA_PULSERSHADOW_P_H +#ifndef PLASMA_WIDGETSNAPSHOT_P_H +#define PLASMA_WIDGETSNAPSHOT_P_H #include namespace Plasma { -class ShadowFake: public QGraphicsWidget +class WidgetSnapShot : public QGraphicsWidget { Q_OBJECT Q_PROPERTY(QGraphicsWidget *target READ target WRITE setTarget) public: - explicit ShadowFake(QGraphicsItem *parent = 0); - ~ShadowFake(); + explicit WidgetSnapShot(QGraphicsItem *parent = 0); + virtual ~WidgetSnapShot(); - void setTarget(QGraphicsWidget *target); + virtual void setTarget(QGraphicsWidget *target); QGraphicsWidget *target() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, + virtual void paint(QPainter *painter, + const QStyleOptionGraphicsItem *option, QWidget *widget); - bool isIconBigger(); + bool isIconBigger() const; + + QPixmap snapShot() const; private: void paintSubChildren(QPainter *painter, const QStyleOptionGraphicsItem *option, QGraphicsItem *target); + bool m_iconBig; int stack; - QPixmap m_photo; + QPixmap m_snapShot; QGraphicsWidget *m_target; }; +} // namespace Plasma -} - -#endif // PLASMA_PULSERSHADOW_P_H +#endif // PLASMA_WIDGETSNAPSHOT_P_H