Implementing support for larger pre-scaled widget raster representation.

svn path=/trunk/KDE/kdelibs/; revision=1094534
This commit is contained in:
Adenilson Cavalcanti Da Silva 2010-02-22 21:58:21 +00:00
parent 24ea07b548
commit 04e16a4261
2 changed files with 37 additions and 13 deletions

View File

@ -27,6 +27,7 @@ namespace Plasma
ShadowFake::ShadowFake(QGraphicsItem *parent)
: QGraphicsWidget(parent),
m_iconBig(false),
stack(0),
m_target(0)
{
@ -69,24 +70,37 @@ void ShadowFake::setTarget(QGraphicsWidget *target)
stack = 0;
m_target = target;
setParentItem(target);
resize(target->size());
setTransformOriginPoint(geometry().center());
QSize size(target->size().toSize());
m_iconBig = false;
m_photo = QPixmap(size);
m_photo.fill(Qt::transparent);
if (m_target->property("iconRepresentation").isValid()) {
m_iconBig = true;
m_photo = QPixmap::fromImage(
m_target->property("iconRepresentation").value<QImage>());
resize(m_photo.size());
QPainter painter(&m_photo);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.fillRect(target->rect(), Qt::transparent);
} else {
QStyleOptionGraphicsItem style;
style.exposedRect = target->boundingRect();
style.rect = target->rect().toRect();
resize(target->size());
target->paint(&painter, &style, 0);
paintSubChildren(&painter, &style, target);
painter.end();
m_photo = QPixmap(size);
m_photo.fill(Qt::transparent);
QPainter painter(&m_photo);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.fillRect(target->rect(), Qt::transparent);
QStyleOptionGraphicsItem style;
style.exposedRect = target->boundingRect();
style.rect = target->rect().toRect();
target->paint(&painter, &style, 0);
paintSubChildren(&painter, &style, target);
painter.end();
}
setTransformOriginPoint(geometry().center());
}
QGraphicsWidget *ShadowFake::target() const
@ -94,5 +108,12 @@ QGraphicsWidget *ShadowFake::target() const
return m_target;
}
bool ShadowFake::isIconBigger()
{
return m_iconBig;
}
}

View File

@ -38,10 +38,13 @@ public:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
bool isIconBigger();
private:
void paintSubChildren(QPainter *painter,
const QStyleOptionGraphicsItem *option,
QGraphicsItem *target);
bool m_iconBig;
int stack;
QPixmap m_photo;
QGraphicsWidget *m_target;