diff options
Diffstat (limited to 'src/gui/effects')
-rw-r--r-- | src/gui/effects/qgraphicseffect.cpp | 52 | ||||
-rw-r--r-- | src/gui/effects/qgraphicseffect.h | 9 |
2 files changed, 59 insertions, 2 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ee87323..eee9bbf 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -777,7 +777,7 @@ void QGraphicsPixelizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou A blur effect blurs the source. This effect is useful for reducing details, such as when the source loses focus and you want to draw attention to other elements. The level of detail can be modified using the setBlurRadius() - function. + function. Use setBlurHint() to choose the quality or performance blur hints. By default, the blur radius is 5 pixels. @@ -795,7 +795,7 @@ QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) { Q_D(QGraphicsBlurEffect); - d->filter->setQuality(Qt::SmoothTransformation); + d->filter->setBlurHint(QPixmapBlurFilter::PerformanceHint); } /*! @@ -839,6 +839,54 @@ void QGraphicsBlurEffect::setBlurRadius(int radius) */ /*! + \enum QGraphicsBlurEffect::BlurHint + + \since 4.6 + + This enum describes the hint of a blur graphics effect. + + \value PerformanceHint Using this value hints that performance is the + most important factor, at the potential cost of lower quality. + + \value QualityHint Using this value hints that a higher quality blur is + preferred over a fast blur. +*/ + +/*! + \property QGraphicsBlurEffect::blurHint + \brief the blur hint of the effect. + + Use the PerformanceHint blur hint to say that you want a faster blur, + and the QualityHint blur hint to say that you prefer a higher quality blur. + + When animating the blur radius it's recommended to use the PerformanceHint. + + By default, the blur hint is PerformanceHint. +*/ +QGraphicsBlurEffect::BlurHint QGraphicsBlurEffect::blurHint() const +{ + Q_D(const QGraphicsBlurEffect); + return BlurHint(d->filter->blurHint()); +} + +void QGraphicsBlurEffect::setBlurHint(QGraphicsBlurEffect::BlurHint hint) +{ + Q_D(QGraphicsBlurEffect); + if (BlurHint(d->filter->blurHint()) == hint) + return; + + d->filter->setBlurHint(QPixmapBlurFilter::BlurHint(hint)); + emit blurHintChanged(hint); +} + +/*! + \fn void QGraphicsBlurEffect::blurHintChanged(QGraphicsBlurEffect::BlurHint hint) + + This signal is emitted whenever the effect's blur hint changes. + The \a hint parameter holds the effect's new blur hint. +*/ + +/*! \reimp */ QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 5062826..c256381 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -224,18 +224,27 @@ class Q_GUI_EXPORT QGraphicsBlurEffect: public QGraphicsEffect { Q_OBJECT Q_PROPERTY(int blurRadius READ blurRadius WRITE setBlurRadius NOTIFY blurRadiusChanged) + Q_PROPERTY(BlurHint blurHint READ blurHint WRITE setBlurHint NOTIFY blurHintChanged) public: + enum BlurHint { + PerformanceHint, + QualityHint + }; + QGraphicsBlurEffect(QObject *parent = 0); ~QGraphicsBlurEffect(); QRectF boundingRectFor(const QRectF &rect) const; int blurRadius() const; + BlurHint blurHint() const; public Q_SLOTS: void setBlurRadius(int blurRadius); + void setBlurHint(BlurHint blurHint); Q_SIGNALS: void blurRadiusChanged(int blurRadius); + void blurHintChanged(BlurHint blurHint); protected: void draw(QPainter *painter, QGraphicsEffectSource *source); |