18 #include "widgetsnapshot_p.h"
23 #include <QStyleOptionGraphicsItem>
31 WidgetSnapShot::WidgetSnapShot(QGraphicsItem *parent)
39 WidgetSnapShot::~WidgetSnapShot()
47 painter->setRenderHint(QPainter::Antialiasing);
48 painter->drawPixmap(option->exposedRect, m_snapShot, option->exposedRect);
51 void WidgetSnapShot::paintSubChildren(QPainter *painter,
53 QGraphicsItem *target)
56 QList<QGraphicsItem *> list = target->childItems();
58 if (list.size() > 0) {
59 for (
int i = 0; i < list.size(); ++i) {
62 if ((tmp->childItems().size() > 0) && (stack <
RECURSION_MAX)) {
63 paintSubChildren(painter, option, tmp);
66 if (tmp->isVisible()) {
67 tmp->paint(painter, option, 0);
78 setParentItem(target);
79 QSize size(target->size().toSize());
82 if (m_target->property(
"iconRepresentation").isValid()) {
84 m_snapShot = QPixmap::fromImage(
85 m_target->property(
"iconRepresentation").value<QImage>());
86 if ((m_snapShot.height() > 0) && (m_snapShot.width() > 0)) {
87 resize(m_snapShot.size());
88 setTransformOriginPoint(target->geometry().center());
93 resize(target->size());
95 m_snapShot = QPixmap(size);
96 m_snapShot.fill(Qt::transparent);
98 QPainter painter(&m_snapShot);
99 painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
100 painter.fillRect(target->rect(), Qt::transparent);
103 style.exposedRect = target->boundingRect();
104 style.rect = target->rect().toRect();
106 target->paint(&painter, &style, 0);
107 paintSubChildren(&painter, &style, target);
109 setTransformOriginPoint(geometry().center());
118 bool WidgetSnapShot::isIconBigger()
const
123 QPixmap WidgetSnapShot::snapShot()
const