diff options
author | Marco Bubke <marco.bubke@digia.com> | 2013-09-17 18:26:01 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@digia.com> | 2013-09-18 12:03:24 +0200 |
commit | 2d8c0dd4804a841c3f0649aecb16f44beeb78467 (patch) | |
tree | 736ad6ce7b3113b5c939e886316f673132bb8bfa /src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp | |
parent | 6a6264db25fc7f1261f17bcfff74ddba655ea5fa (diff) |
QmlDesigner: Add blur render image
To give the impression that the content is non editable.
Change-Id: I1869d02a27b2d1a7c2c12abb9a8d8d24068adf22
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
Diffstat (limited to 'src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp')
-rw-r--r-- | src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp index efc4ad080b..9ee8f86be4 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstance.cpp @@ -34,6 +34,10 @@ #include <QDebug> +QT_BEGIN_NAMESPACE +void qt_blurImage(QPainter *painter, QImage &blurImage, qreal radius, bool quality, bool alphaOnly, int transposed = 0); +QT_END_NAMESPACE + namespace QmlDesigner { class ProxyNodeInstanceData @@ -75,6 +79,8 @@ public: QHash<PropertyName, TypeName> instanceTypes; QPixmap renderPixmap; + QPixmap blurredRenderPixmap; + QHash<PropertyName, QPair<PropertyName, qint32> > anchors; }; @@ -256,12 +262,6 @@ int NodeInstance::penWidth() const return 1; } -void NodeInstance::paint(QPainter *painter) -{ - if (isValid() && !d->renderPixmap.isNull()) - painter->drawPixmap(boundingRect().topLeft(), d->renderPixmap); -} - QVariant NodeInstance::property(const PropertyName &name) const { if (isValid()) @@ -320,10 +320,24 @@ QPixmap NodeInstance::renderPixmap() const return d->renderPixmap; } +QPixmap NodeInstance::blurredRenderPixmap() const +{ + if (d->blurredRenderPixmap.isNull()) { + d->blurredRenderPixmap = QPixmap(d->renderPixmap.size()); + QPainter blurPainter(&d->blurredRenderPixmap); + QImage renderImage = d->renderPixmap.toImage(); + qt_blurImage(&blurPainter, renderImage, 8.0, false, false); + } + + return d->blurredRenderPixmap; +} + void NodeInstance::setRenderPixmap(const QImage &image) { - if (!image.isNull()) + if (!image.isNull()) { d->renderPixmap = QPixmap::fromImage(image); + d->blurredRenderPixmap = QPixmap(); + } } void NodeInstance::setParentId(qint32 instanceId) |