s/pulsershadow/widgetsnapshot
svn path=/trunk/KDE/kdelibs/; revision=1115254
This commit is contained in:
parent
ec3d3774bc
commit
daffafb9fe
@ -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
|
||||
|
@ -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 <QEvent>
|
||||
@ -25,8 +26,6 @@
|
||||
|
||||
#include <kdebug.h>
|
||||
|
||||
#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);
|
||||
|
@ -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<ShadowFake> m_under;
|
||||
QWeakPointer<WidgetSnapShot> m_under;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -15,18 +15,20 @@
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "pulsershadow_p.h"
|
||||
#include "widgetsnapshot_p.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QImage>
|
||||
#include <QPixmap>
|
||||
#include <QStyleOptionGraphicsItem>
|
||||
#include <QDebug>
|
||||
|
||||
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<QImage>());
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
@ -15,42 +15,45 @@
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLASMA_PULSERSHADOW_P_H
|
||||
#define PLASMA_PULSERSHADOW_P_H
|
||||
#ifndef PLASMA_WIDGETSNAPSHOT_P_H
|
||||
#define PLASMA_WIDGETSNAPSHOT_P_H
|
||||
|
||||
#include <QGraphicsWidget>
|
||||
|
||||
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
|
Loading…
Reference in New Issue
Block a user