Implementing support for larger pre-scaled widget raster representation.
svn path=/trunk/KDE/kdelibs/; revision=1094534
This commit is contained in:
parent
24ea07b548
commit
04e16a4261
@ -27,6 +27,7 @@ namespace Plasma
|
|||||||
|
|
||||||
ShadowFake::ShadowFake(QGraphicsItem *parent)
|
ShadowFake::ShadowFake(QGraphicsItem *parent)
|
||||||
: QGraphicsWidget(parent),
|
: QGraphicsWidget(parent),
|
||||||
|
m_iconBig(false),
|
||||||
stack(0),
|
stack(0),
|
||||||
m_target(0)
|
m_target(0)
|
||||||
{
|
{
|
||||||
@ -69,24 +70,37 @@ void ShadowFake::setTarget(QGraphicsWidget *target)
|
|||||||
stack = 0;
|
stack = 0;
|
||||||
m_target = target;
|
m_target = target;
|
||||||
setParentItem(target);
|
setParentItem(target);
|
||||||
resize(target->size());
|
|
||||||
setTransformOriginPoint(geometry().center());
|
|
||||||
QSize size(target->size().toSize());
|
QSize size(target->size().toSize());
|
||||||
|
m_iconBig = false;
|
||||||
|
|
||||||
m_photo = QPixmap(size);
|
if (m_target->property("iconRepresentation").isValid()) {
|
||||||
m_photo.fill(Qt::transparent);
|
m_iconBig = true;
|
||||||
|
m_photo = QPixmap::fromImage(
|
||||||
|
m_target->property("iconRepresentation").value<QImage>());
|
||||||
|
resize(m_photo.size());
|
||||||
|
|
||||||
QPainter painter(&m_photo);
|
} else {
|
||||||
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
|
|
||||||
painter.fillRect(target->rect(), Qt::transparent);
|
|
||||||
|
|
||||||
QStyleOptionGraphicsItem style;
|
resize(target->size());
|
||||||
style.exposedRect = target->boundingRect();
|
|
||||||
style.rect = target->rect().toRect();
|
|
||||||
|
|
||||||
target->paint(&painter, &style, 0);
|
m_photo = QPixmap(size);
|
||||||
paintSubChildren(&painter, &style, target);
|
m_photo.fill(Qt::transparent);
|
||||||
painter.end();
|
|
||||||
|
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
|
QGraphicsWidget *ShadowFake::target() const
|
||||||
@ -94,5 +108,12 @@ QGraphicsWidget *ShadowFake::target() const
|
|||||||
return m_target;
|
return m_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool ShadowFake::isIconBigger()
|
||||||
|
{
|
||||||
|
return m_iconBig;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,10 +38,13 @@ public:
|
|||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
|
||||||
QWidget *widget);
|
QWidget *widget);
|
||||||
|
|
||||||
|
bool isIconBigger();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void paintSubChildren(QPainter *painter,
|
void paintSubChildren(QPainter *painter,
|
||||||
const QStyleOptionGraphicsItem *option,
|
const QStyleOptionGraphicsItem *option,
|
||||||
QGraphicsItem *target);
|
QGraphicsItem *target);
|
||||||
|
bool m_iconBig;
|
||||||
int stack;
|
int stack;
|
||||||
QPixmap m_photo;
|
QPixmap m_photo;
|
||||||
QGraphicsWidget *m_target;
|
QGraphicsWidget *m_target;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user