| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/effects/qgraphicseffect.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||||||||
| 3 | ** Copyright (C) 2015 The Qt Company Ltd. | - | ||||||||||||||||||||||||
| 4 | ** Contact: http://www.qt.io/licensing/ | - | ||||||||||||||||||||||||
| 5 | ** | - | ||||||||||||||||||||||||
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL21$ | - | ||||||||||||||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||||||||
| 14 | ** and conditions see http://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||||||||
| 15 | ** information use the contact form at http://www.qt.io/contact-us. | - | ||||||||||||||||||||||||
| 16 | ** | - | ||||||||||||||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||||||||
| 19 | ** General Public License version 2.1 or version 3 as published by the Free | - | ||||||||||||||||||||||||
| 20 | ** Software Foundation and appearing in the file LICENSE.LGPLv21 and | - | ||||||||||||||||||||||||
| 21 | ** LICENSE.LGPLv3 included in the packaging of this file. Please review the | - | ||||||||||||||||||||||||
| 22 | ** following information to ensure the GNU Lesser General Public License | - | ||||||||||||||||||||||||
| 23 | ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and | - | ||||||||||||||||||||||||
| 24 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - | ||||||||||||||||||||||||
| 25 | ** | - | ||||||||||||||||||||||||
| 26 | ** As a special exception, The Qt Company gives you certain additional | - | ||||||||||||||||||||||||
| 27 | ** rights. These rights are described in The Qt Company LGPL Exception | - | ||||||||||||||||||||||||
| 28 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - | ||||||||||||||||||||||||
| 29 | ** | - | ||||||||||||||||||||||||
| 30 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||||||||
| 31 | ** | - | ||||||||||||||||||||||||
| 32 | ****************************************************************************/ | - | ||||||||||||||||||||||||
| 33 | - | |||||||||||||||||||||||||
| 34 | /*! | - | ||||||||||||||||||||||||
| 35 | \class QGraphicsEffect | - | ||||||||||||||||||||||||
| 36 | \brief The QGraphicsEffect class is the base class for all graphics | - | ||||||||||||||||||||||||
| 37 | effects. | - | ||||||||||||||||||||||||
| 38 | \since 4.6 | - | ||||||||||||||||||||||||
| 39 | \ingroup multimedia | - | ||||||||||||||||||||||||
| 40 | \ingroup graphicsview-api | - | ||||||||||||||||||||||||
| 41 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
| 42 | - | |||||||||||||||||||||||||
| 43 | Effects alter the appearance of elements by hooking into the rendering | - | ||||||||||||||||||||||||
| 44 | pipeline and operating between the source (e.g., a QGraphicsPixmapItem) | - | ||||||||||||||||||||||||
| 45 | and the destination device (e.g., QGraphicsView's viewport). Effects can be | - | ||||||||||||||||||||||||
| 46 | disabled by calling setEnabled(false). If effects are disabled, the source | - | ||||||||||||||||||||||||
| 47 | is rendered directly. | - | ||||||||||||||||||||||||
| 48 | - | |||||||||||||||||||||||||
| 49 | To add a visual effect to a QGraphicsItem, for example, you can use one of | - | ||||||||||||||||||||||||
| 50 | the standard effects, or alternately, create your own effect by creating a | - | ||||||||||||||||||||||||
| 51 | subclass of QGraphicsEffect. The effect can then be installed on the item | - | ||||||||||||||||||||||||
| 52 | using QGraphicsItem::setGraphicsEffect(). | - | ||||||||||||||||||||||||
| 53 | - | |||||||||||||||||||||||||
| 54 | Qt provides the following standard effects: | - | ||||||||||||||||||||||||
| 55 | - | |||||||||||||||||||||||||
| 56 | \list | - | ||||||||||||||||||||||||
| 57 | \li QGraphicsBlurEffect - blurs the item by a given radius | - | ||||||||||||||||||||||||
| 58 | \li QGraphicsDropShadowEffect - renders a dropshadow behind the item | - | ||||||||||||||||||||||||
| 59 | \li QGraphicsColorizeEffect - renders the item in shades of any given color | - | ||||||||||||||||||||||||
| 60 | \li QGraphicsOpacityEffect - renders the item with an opacity | - | ||||||||||||||||||||||||
| 61 | \endlist | - | ||||||||||||||||||||||||
| 62 | - | |||||||||||||||||||||||||
| 63 | \table | - | ||||||||||||||||||||||||
| 64 | \row | - | ||||||||||||||||||||||||
| 65 | \li{2,1} \image graphicseffect-plain.png | - | ||||||||||||||||||||||||
| 66 | \row | - | ||||||||||||||||||||||||
| 67 | \li \image graphicseffect-blur.png | - | ||||||||||||||||||||||||
| 68 | \li \image graphicseffect-colorize.png | - | ||||||||||||||||||||||||
| 69 | \row | - | ||||||||||||||||||||||||
| 70 | \li \image graphicseffect-opacity.png | - | ||||||||||||||||||||||||
| 71 | \li \image graphicseffect-drop-shadow.png | - | ||||||||||||||||||||||||
| 72 | \endtable | - | ||||||||||||||||||||||||
| 73 | - | |||||||||||||||||||||||||
| 74 | \image graphicseffect-widget.png | - | ||||||||||||||||||||||||
| 75 | - | |||||||||||||||||||||||||
| 76 | For more information on how to use each effect, refer to the specific | - | ||||||||||||||||||||||||
| 77 | effect's documentation. | - | ||||||||||||||||||||||||
| 78 | - | |||||||||||||||||||||||||
| 79 | To create your own custom effect, create a subclass of QGraphicsEffect (or | - | ||||||||||||||||||||||||
| 80 | any other existing effects) and reimplement the virtual function draw(). | - | ||||||||||||||||||||||||
| 81 | This function is called whenever the effect needs to redraw. The draw() | - | ||||||||||||||||||||||||
| 82 | function takes the painter with which to draw as an argument. For more | - | ||||||||||||||||||||||||
| 83 | information, refer to the documenation for draw(). In the draw() function | - | ||||||||||||||||||||||||
| 84 | you can call sourcePixmap() to get a pixmap of the graphics effect source | - | ||||||||||||||||||||||||
| 85 | which you can then process. | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | If your effect changes, use update() to request for a redraw. If your | - | ||||||||||||||||||||||||
| 88 | custom effect changes the bounding rectangle of the source, e.g., a radial | - | ||||||||||||||||||||||||
| 89 | glow effect may need to apply an extra margin, you can reimplement the | - | ||||||||||||||||||||||||
| 90 | virtual boundingRectFor() function, and call updateBoundingRect() | - | ||||||||||||||||||||||||
| 91 | to notify the framework whenever this rectangle changes. The virtual | - | ||||||||||||||||||||||||
| 92 | sourceChanged() function is called to notify the effects that | - | ||||||||||||||||||||||||
| 93 | the source has changed in some way - e.g., if the source is a | - | ||||||||||||||||||||||||
| 94 | QGraphicsRectItem and its rectangle parameters have changed. | - | ||||||||||||||||||||||||
| 95 | - | |||||||||||||||||||||||||
| 96 | \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect() | - | ||||||||||||||||||||||||
| 97 | */ | - | ||||||||||||||||||||||||
| 98 | - | |||||||||||||||||||||||||
| 99 | #include "qgraphicseffect_p.h" | - | ||||||||||||||||||||||||
| 100 | #include "private/qgraphicsitem_p.h" | - | ||||||||||||||||||||||||
| 101 | - | |||||||||||||||||||||||||
| 102 | #include <QtWidgets/qgraphicsitem.h> | - | ||||||||||||||||||||||||
| 103 | - | |||||||||||||||||||||||||
| 104 | #include <QtGui/qimage.h> | - | ||||||||||||||||||||||||
| 105 | #include <QtGui/qpainter.h> | - | ||||||||||||||||||||||||
| 106 | #include <QtGui/qpaintengine.h> | - | ||||||||||||||||||||||||
| 107 | #include <QtCore/qrect.h> | - | ||||||||||||||||||||||||
| 108 | #include <QtCore/qdebug.h> | - | ||||||||||||||||||||||||
| 109 | #include <private/qdrawhelper_p.h> | - | ||||||||||||||||||||||||
| 110 | - | |||||||||||||||||||||||||
| 111 | #ifndef QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||
| 112 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 113 | - | |||||||||||||||||||||||||
| 114 | QGraphicsEffectPrivate::~QGraphicsEffectPrivate() | - | ||||||||||||||||||||||||
| 115 | { | - | ||||||||||||||||||||||||
| 116 | } | - | ||||||||||||||||||||||||
| 117 | - | |||||||||||||||||||||||||
| 118 | /*! | - | ||||||||||||||||||||||||
| 119 | \internal | - | ||||||||||||||||||||||||
| 120 | \class QGraphicsEffectSource | - | ||||||||||||||||||||||||
| 121 | \brief The QGraphicsEffectSource class represents the source on which a | - | ||||||||||||||||||||||||
| 122 | QGraphicsEffect is installed on. | - | ||||||||||||||||||||||||
| 123 | - | |||||||||||||||||||||||||
| 124 | When a QGraphicsEffect is installed on a QGraphicsItem, for example, this | - | ||||||||||||||||||||||||
| 125 | class will act as a wrapper around QGraphicsItem. Then, calling update() is | - | ||||||||||||||||||||||||
| 126 | effectively the same as calling QGraphicsItem::update(). | - | ||||||||||||||||||||||||
| 127 | - | |||||||||||||||||||||||||
| 128 | QGraphicsEffectSource also provides a pixmap() function which creates a | - | ||||||||||||||||||||||||
| 129 | pixmap with the source painted into it. | - | ||||||||||||||||||||||||
| 130 | - | |||||||||||||||||||||||||
| 131 | \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect() | - | ||||||||||||||||||||||||
| 132 | */ | - | ||||||||||||||||||||||||
| 133 | - | |||||||||||||||||||||||||
| 134 | /*! | - | ||||||||||||||||||||||||
| 135 | \internal | - | ||||||||||||||||||||||||
| 136 | */ | - | ||||||||||||||||||||||||
| 137 | QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent) | - | ||||||||||||||||||||||||
| 138 | : QObject(dd, parent) | - | ||||||||||||||||||||||||
| 139 | {} never executed: end of block | 0 | ||||||||||||||||||||||||
| 140 | - | |||||||||||||||||||||||||
| 141 | /*! | - | ||||||||||||||||||||||||
| 142 | Destroys the effect source. | - | ||||||||||||||||||||||||
| 143 | */ | - | ||||||||||||||||||||||||
| 144 | QGraphicsEffectSource::~QGraphicsEffectSource() | - | ||||||||||||||||||||||||
| 145 | {} | - | ||||||||||||||||||||||||
| 146 | - | |||||||||||||||||||||||||
| 147 | /*! | - | ||||||||||||||||||||||||
| 148 | Returns the bounding rectangle of the source mapped to the given \a system. | - | ||||||||||||||||||||||||
| 149 | - | |||||||||||||||||||||||||
| 150 | \sa draw() | - | ||||||||||||||||||||||||
| 151 | */ | - | ||||||||||||||||||||||||
| 152 | QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const | - | ||||||||||||||||||||||||
| 153 | { | - | ||||||||||||||||||||||||
| 154 | return d_func()->boundingRect(system); never executed: return d_func()->boundingRect(system); | 0 | ||||||||||||||||||||||||
| 155 | } | - | ||||||||||||||||||||||||
| 156 | - | |||||||||||||||||||||||||
| 157 | /*! | - | ||||||||||||||||||||||||
| 158 | Returns the bounding rectangle of the source mapped to the given \a system. | - | ||||||||||||||||||||||||
| 159 | - | |||||||||||||||||||||||||
| 160 | Calling this function with Qt::DeviceCoordinates outside of | - | ||||||||||||||||||||||||
| 161 | QGraphicsEffect::draw() will give undefined results, as there is no device | - | ||||||||||||||||||||||||
| 162 | context available. | - | ||||||||||||||||||||||||
| 163 | - | |||||||||||||||||||||||||
| 164 | \sa draw() | - | ||||||||||||||||||||||||
| 165 | */ | - | ||||||||||||||||||||||||
| 166 | QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const | - | ||||||||||||||||||||||||
| 167 | { | - | ||||||||||||||||||||||||
| 168 | Q_D(const QGraphicsEffect); | - | ||||||||||||||||||||||||
| 169 | if (d->source)
| 0 | ||||||||||||||||||||||||
| 170 | return d->source->boundingRect(system); never executed: return d->source->boundingRect(system); | 0 | ||||||||||||||||||||||||
| 171 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||
| 172 | } | - | ||||||||||||||||||||||||
| 173 | - | |||||||||||||||||||||||||
| 174 | /*! | - | ||||||||||||||||||||||||
| 175 | Returns a pointer to the item if this source is a QGraphicsItem; otherwise | - | ||||||||||||||||||||||||
| 176 | returns 0. | - | ||||||||||||||||||||||||
| 177 | - | |||||||||||||||||||||||||
| 178 | \sa widget() | - | ||||||||||||||||||||||||
| 179 | */ | - | ||||||||||||||||||||||||
| 180 | const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const | - | ||||||||||||||||||||||||
| 181 | { | - | ||||||||||||||||||||||||
| 182 | return d_func()->graphicsItem(); never executed: return d_func()->graphicsItem(); | 0 | ||||||||||||||||||||||||
| 183 | } | - | ||||||||||||||||||||||||
| 184 | - | |||||||||||||||||||||||||
| 185 | /*! | - | ||||||||||||||||||||||||
| 186 | Returns a pointer to the widget if this source is a QWidget; otherwise | - | ||||||||||||||||||||||||
| 187 | returns 0. | - | ||||||||||||||||||||||||
| 188 | - | |||||||||||||||||||||||||
| 189 | \sa graphicsItem() | - | ||||||||||||||||||||||||
| 190 | */ | - | ||||||||||||||||||||||||
| 191 | const QWidget *QGraphicsEffectSource::widget() const | - | ||||||||||||||||||||||||
| 192 | { | - | ||||||||||||||||||||||||
| 193 | return d_func()->widget(); never executed: return d_func()->widget(); | 0 | ||||||||||||||||||||||||
| 194 | } | - | ||||||||||||||||||||||||
| 195 | - | |||||||||||||||||||||||||
| 196 | /*! | - | ||||||||||||||||||||||||
| 197 | Returns a pointer to the style options (used when drawing the source) if | - | ||||||||||||||||||||||||
| 198 | available; otherwise returns 0. | - | ||||||||||||||||||||||||
| 199 | - | |||||||||||||||||||||||||
| 200 | \sa graphicsItem(), widget() | - | ||||||||||||||||||||||||
| 201 | */ | - | ||||||||||||||||||||||||
| 202 | const QStyleOption *QGraphicsEffectSource::styleOption() const | - | ||||||||||||||||||||||||
| 203 | { | - | ||||||||||||||||||||||||
| 204 | return d_func()->styleOption(); never executed: return d_func()->styleOption(); | 0 | ||||||||||||||||||||||||
| 205 | } | - | ||||||||||||||||||||||||
| 206 | - | |||||||||||||||||||||||||
| 207 | /*! | - | ||||||||||||||||||||||||
| 208 | Draws the source using the given \a painter. | - | ||||||||||||||||||||||||
| 209 | - | |||||||||||||||||||||||||
| 210 | This function should only be called from QGraphicsEffect::draw(). | - | ||||||||||||||||||||||||
| 211 | - | |||||||||||||||||||||||||
| 212 | \sa QGraphicsEffect::draw() | - | ||||||||||||||||||||||||
| 213 | */ | - | ||||||||||||||||||||||||
| 214 | void QGraphicsEffectSource::draw(QPainter *painter) | - | ||||||||||||||||||||||||
| 215 | { | - | ||||||||||||||||||||||||
| 216 | Q_D(const QGraphicsEffectSource); | - | ||||||||||||||||||||||||
| 217 | - | |||||||||||||||||||||||||
| 218 | QPixmap pm; | - | ||||||||||||||||||||||||
| 219 | if (QPixmapCache::find(d->m_cacheKey, &pm)) {
| 0 | ||||||||||||||||||||||||
| 220 | QTransform restoreTransform; | - | ||||||||||||||||||||||||
| 221 | if (d->m_cachedSystem == Qt::DeviceCoordinates) {
| 0 | ||||||||||||||||||||||||
| 222 | restoreTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 223 | painter->setWorldTransform(QTransform()); | - | ||||||||||||||||||||||||
| 224 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 225 | - | |||||||||||||||||||||||||
| 226 | painter->drawPixmap(d->m_cachedOffset, pm); | - | ||||||||||||||||||||||||
| 227 | - | |||||||||||||||||||||||||
| 228 | if (d->m_cachedSystem == Qt::DeviceCoordinates)
| 0 | ||||||||||||||||||||||||
| 229 | painter->setWorldTransform(restoreTransform); never executed: painter->setWorldTransform(restoreTransform); | 0 | ||||||||||||||||||||||||
| 230 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 231 | d_func()->draw(painter); | - | ||||||||||||||||||||||||
| 232 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 233 | } | - | ||||||||||||||||||||||||
| 234 | - | |||||||||||||||||||||||||
| 235 | /*! | - | ||||||||||||||||||||||||
| 236 | Draws the source directly using the given \a painter. | - | ||||||||||||||||||||||||
| 237 | - | |||||||||||||||||||||||||
| 238 | This function should only be called from QGraphicsEffect::draw(). | - | ||||||||||||||||||||||||
| 239 | - | |||||||||||||||||||||||||
| 240 | For example: | - | ||||||||||||||||||||||||
| 241 | - | |||||||||||||||||||||||||
| 242 | \snippet code/src_gui_effects_qgraphicseffect.cpp 0 | - | ||||||||||||||||||||||||
| 243 | - | |||||||||||||||||||||||||
| 244 | \sa QGraphicsEffect::draw() | - | ||||||||||||||||||||||||
| 245 | */ | - | ||||||||||||||||||||||||
| 246 | void QGraphicsEffect::drawSource(QPainter *painter) | - | ||||||||||||||||||||||||
| 247 | { | - | ||||||||||||||||||||||||
| 248 | Q_D(const QGraphicsEffect); | - | ||||||||||||||||||||||||
| 249 | if (d->source)
| 0 | ||||||||||||||||||||||||
| 250 | d->source->draw(painter); never executed: d->source->draw(painter); | 0 | ||||||||||||||||||||||||
| 251 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 252 | - | |||||||||||||||||||||||||
| 253 | /*! | - | ||||||||||||||||||||||||
| 254 | Schedules a redraw of the source. Call this function whenever the source | - | ||||||||||||||||||||||||
| 255 | needs to be redrawn. | - | ||||||||||||||||||||||||
| 256 | - | |||||||||||||||||||||||||
| 257 | \sa QGraphicsEffect::updateBoundingRect(), QWidget::update(), | - | ||||||||||||||||||||||||
| 258 | QGraphicsItem::update(), | - | ||||||||||||||||||||||||
| 259 | */ | - | ||||||||||||||||||||||||
| 260 | void QGraphicsEffectSource::update() | - | ||||||||||||||||||||||||
| 261 | { | - | ||||||||||||||||||||||||
| 262 | d_func()->update(); | - | ||||||||||||||||||||||||
| 263 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 264 | - | |||||||||||||||||||||||||
| 265 | /*! | - | ||||||||||||||||||||||||
| 266 | Returns \c true if the source effectively is a pixmap, e.g., a | - | ||||||||||||||||||||||||
| 267 | QGraphicsPixmapItem. | - | ||||||||||||||||||||||||
| 268 | - | |||||||||||||||||||||||||
| 269 | This function is useful for optimization purposes. For instance, there's no | - | ||||||||||||||||||||||||
| 270 | point in drawing the source in device coordinates to avoid pixmap scaling | - | ||||||||||||||||||||||||
| 271 | if this function returns \c true - the source pixmap will be scaled anyways. | - | ||||||||||||||||||||||||
| 272 | */ | - | ||||||||||||||||||||||||
| 273 | bool QGraphicsEffectSource::isPixmap() const | - | ||||||||||||||||||||||||
| 274 | { | - | ||||||||||||||||||||||||
| 275 | return d_func()->isPixmap(); never executed: return d_func()->isPixmap(); | 0 | ||||||||||||||||||||||||
| 276 | } | - | ||||||||||||||||||||||||
| 277 | - | |||||||||||||||||||||||||
| 278 | /*! | - | ||||||||||||||||||||||||
| 279 | Returns \c true if the source effectively is a pixmap, e.g., a | - | ||||||||||||||||||||||||
| 280 | QGraphicsPixmapItem. | - | ||||||||||||||||||||||||
| 281 | - | |||||||||||||||||||||||||
| 282 | This function is useful for optimization purposes. For instance, there's no | - | ||||||||||||||||||||||||
| 283 | point in drawing the source in device coordinates to avoid pixmap scaling | - | ||||||||||||||||||||||||
| 284 | if this function returns \c true - the source pixmap will be scaled anyways. | - | ||||||||||||||||||||||||
| 285 | */ | - | ||||||||||||||||||||||||
| 286 | bool QGraphicsEffect::sourceIsPixmap() const | - | ||||||||||||||||||||||||
| 287 | { | - | ||||||||||||||||||||||||
| 288 | return source() ? source()->isPixmap() : false; never executed: return source() ? source()->isPixmap() : false;
| 0 | ||||||||||||||||||||||||
| 289 | } | - | ||||||||||||||||||||||||
| 290 | - | |||||||||||||||||||||||||
| 291 | /*! | - | ||||||||||||||||||||||||
| 292 | Returns a pixmap with the source painted into it. | - | ||||||||||||||||||||||||
| 293 | - | |||||||||||||||||||||||||
| 294 | The \a system specifies which coordinate system to be used for the source. | - | ||||||||||||||||||||||||
| 295 | The optional \a offset parameter returns the offset where the pixmap should | - | ||||||||||||||||||||||||
| 296 | be painted at using the current painter. | - | ||||||||||||||||||||||||
| 297 | - | |||||||||||||||||||||||||
| 298 | The \a mode determines how much of the effect the pixmap will contain. | - | ||||||||||||||||||||||||
| 299 | By default, the pixmap will contain the whole effect. | - | ||||||||||||||||||||||||
| 300 | - | |||||||||||||||||||||||||
| 301 | The returned pixmap is bound to the current painter's device rectangle when | - | ||||||||||||||||||||||||
| 302 | \a system is Qt::DeviceCoordinates. | - | ||||||||||||||||||||||||
| 303 | - | |||||||||||||||||||||||||
| 304 | \sa QGraphicsEffect::draw(), boundingRect() | - | ||||||||||||||||||||||||
| 305 | */ | - | ||||||||||||||||||||||||
| 306 | QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const | - | ||||||||||||||||||||||||
| 307 | { | - | ||||||||||||||||||||||||
| 308 | Q_D(const QGraphicsEffectSource); | - | ||||||||||||||||||||||||
| 309 | - | |||||||||||||||||||||||||
| 310 | // Shortcut, no cache for childless pixmap items... | - | ||||||||||||||||||||||||
| 311 | const QGraphicsItem *item = graphicsItem(); | - | ||||||||||||||||||||||||
| 312 | if (system == Qt::LogicalCoordinates && mode == QGraphicsEffect::NoPad && item && isPixmap()) {
| 0 | ||||||||||||||||||||||||
| 313 | const QGraphicsPixmapItem *pixmapItem = static_cast<const QGraphicsPixmapItem *>(item); | - | ||||||||||||||||||||||||
| 314 | if (offset)
| 0 | ||||||||||||||||||||||||
| 315 | *offset = pixmapItem->offset().toPoint(); never executed: *offset = pixmapItem->offset().toPoint(); | 0 | ||||||||||||||||||||||||
| 316 | return pixmapItem->pixmap(); never executed: return pixmapItem->pixmap(); | 0 | ||||||||||||||||||||||||
| 317 | } | - | ||||||||||||||||||||||||
| 318 | - | |||||||||||||||||||||||||
| 319 | if (system == Qt::DeviceCoordinates && item
| 0 | ||||||||||||||||||||||||
| 320 | && !static_cast<const QGraphicsItemEffectSourcePrivate *>(d_func())->info) {
| 0 | ||||||||||||||||||||||||
| 321 | qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); | - | ||||||||||||||||||||||||
| 322 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||
| 323 | } | - | ||||||||||||||||||||||||
| 324 | - | |||||||||||||||||||||||||
| 325 | QPixmap pm; | - | ||||||||||||||||||||||||
| 326 | if (item && d->m_cachedSystem == system && d->m_cachedMode == mode)
| 0 | ||||||||||||||||||||||||
| 327 | QPixmapCache::find(d->m_cacheKey, &pm); never executed: QPixmapCache::find(d->m_cacheKey, &pm); | 0 | ||||||||||||||||||||||||
| 328 | - | |||||||||||||||||||||||||
| 329 | if (pm.isNull()) {
| 0 | ||||||||||||||||||||||||
| 330 | pm = d->pixmap(system, &d->m_cachedOffset, mode); | - | ||||||||||||||||||||||||
| 331 | d->m_cachedSystem = system; | - | ||||||||||||||||||||||||
| 332 | d->m_cachedMode = mode; | - | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | d->invalidateCache(); | - | ||||||||||||||||||||||||
| 335 | d->m_cacheKey = QPixmapCache::insert(pm); | - | ||||||||||||||||||||||||
| 336 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 337 | - | |||||||||||||||||||||||||
| 338 | if (offset)
| 0 | ||||||||||||||||||||||||
| 339 | *offset = d->m_cachedOffset; never executed: *offset = d->m_cachedOffset; | 0 | ||||||||||||||||||||||||
| 340 | - | |||||||||||||||||||||||||
| 341 | return pm; never executed: return pm; | 0 | ||||||||||||||||||||||||
| 342 | } | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | /*! | - | ||||||||||||||||||||||||
| 345 | Returns a pixmap with the source painted into it. | - | ||||||||||||||||||||||||
| 346 | - | |||||||||||||||||||||||||
| 347 | The \a system specifies which coordinate system to be used for the source. | - | ||||||||||||||||||||||||
| 348 | The optional \a offset parameter returns the offset where the pixmap should | - | ||||||||||||||||||||||||
| 349 | be painted at using the current painter. For control on how the pixmap is | - | ||||||||||||||||||||||||
| 350 | padded use the \a mode parameter. | - | ||||||||||||||||||||||||
| 351 | - | |||||||||||||||||||||||||
| 352 | The returned pixmap is clipped to the current painter's device rectangle when | - | ||||||||||||||||||||||||
| 353 | \a system is Qt::DeviceCoordinates. | - | ||||||||||||||||||||||||
| 354 | - | |||||||||||||||||||||||||
| 355 | Calling this function with Qt::DeviceCoordinates outside of | - | ||||||||||||||||||||||||
| 356 | QGraphicsEffect::draw() will give undefined results, as there is no device | - | ||||||||||||||||||||||||
| 357 | context available. | - | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | \sa draw(), boundingRect() | - | ||||||||||||||||||||||||
| 360 | */ | - | ||||||||||||||||||||||||
| 361 | QPixmap QGraphicsEffect::sourcePixmap(Qt::CoordinateSystem system, QPoint *offset, QGraphicsEffect::PixmapPadMode mode) const | - | ||||||||||||||||||||||||
| 362 | { | - | ||||||||||||||||||||||||
| 363 | Q_D(const QGraphicsEffect); | - | ||||||||||||||||||||||||
| 364 | if (d->source)
| 0 | ||||||||||||||||||||||||
| 365 | return d->source->pixmap(system, offset, mode); never executed: return d->source->pixmap(system, offset, mode); | 0 | ||||||||||||||||||||||||
| 366 | return QPixmap(); never executed: return QPixmap(); | 0 | ||||||||||||||||||||||||
| 367 | } | - | ||||||||||||||||||||||||
| 368 | - | |||||||||||||||||||||||||
| 369 | QGraphicsEffectSourcePrivate::~QGraphicsEffectSourcePrivate() | - | ||||||||||||||||||||||||
| 370 | { | - | ||||||||||||||||||||||||
| 371 | invalidateCache(); | - | ||||||||||||||||||||||||
| 372 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 373 | - | |||||||||||||||||||||||||
| 374 | void QGraphicsEffectSourcePrivate::setCachedOffset(const QPoint &offset) | - | ||||||||||||||||||||||||
| 375 | { | - | ||||||||||||||||||||||||
| 376 | m_cachedOffset = offset; | - | ||||||||||||||||||||||||
| 377 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 378 | - | |||||||||||||||||||||||||
| 379 | void QGraphicsEffectSourcePrivate::invalidateCache(InvalidateReason reason) const | - | ||||||||||||||||||||||||
| 380 | { | - | ||||||||||||||||||||||||
| 381 | if (m_cachedMode != QGraphicsEffect::PadToEffectiveBoundingRect
| 0 | ||||||||||||||||||||||||
| 382 | && (reason == EffectRectChanged
| 0 | ||||||||||||||||||||||||
| 383 | || (reason == TransformChanged && m_cachedSystem == Qt::LogicalCoordinates))) {
| 0 | ||||||||||||||||||||||||
| 384 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 385 | } | - | ||||||||||||||||||||||||
| 386 | - | |||||||||||||||||||||||||
| 387 | QPixmapCache::remove(m_cacheKey); | - | ||||||||||||||||||||||||
| 388 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 389 | - | |||||||||||||||||||||||||
| 390 | /*! | - | ||||||||||||||||||||||||
| 391 | Constructs a new QGraphicsEffect instance having the | - | ||||||||||||||||||||||||
| 392 | specified \a parent. | - | ||||||||||||||||||||||||
| 393 | */ | - | ||||||||||||||||||||||||
| 394 | QGraphicsEffect::QGraphicsEffect(QObject *parent) | - | ||||||||||||||||||||||||
| 395 | : QObject(*new QGraphicsEffectPrivate, parent) | - | ||||||||||||||||||||||||
| 396 | { | - | ||||||||||||||||||||||||
| 397 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 398 | - | |||||||||||||||||||||||||
| 399 | /*! | - | ||||||||||||||||||||||||
| 400 | \internal | - | ||||||||||||||||||||||||
| 401 | */ | - | ||||||||||||||||||||||||
| 402 | QGraphicsEffect::QGraphicsEffect(QGraphicsEffectPrivate &dd, QObject *parent) | - | ||||||||||||||||||||||||
| 403 | : QObject(dd, parent) | - | ||||||||||||||||||||||||
| 404 | { | - | ||||||||||||||||||||||||
| 405 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 406 | - | |||||||||||||||||||||||||
| 407 | /*! | - | ||||||||||||||||||||||||
| 408 | Removes the effect from the source, and destroys the graphics effect. | - | ||||||||||||||||||||||||
| 409 | */ | - | ||||||||||||||||||||||||
| 410 | QGraphicsEffect::~QGraphicsEffect() | - | ||||||||||||||||||||||||
| 411 | { | - | ||||||||||||||||||||||||
| 412 | Q_D(QGraphicsEffect); | - | ||||||||||||||||||||||||
| 413 | d->setGraphicsEffectSource(0); | - | ||||||||||||||||||||||||
| 414 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 415 | - | |||||||||||||||||||||||||
| 416 | /*! | - | ||||||||||||||||||||||||
| 417 | Returns the effective bounding rectangle for this effect, i.e., the | - | ||||||||||||||||||||||||
| 418 | bounding rectangle of the source in device coordinates, adjusted by | - | ||||||||||||||||||||||||
| 419 | any margins applied by the effect itself. | - | ||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | \sa boundingRectFor(), updateBoundingRect() | - | ||||||||||||||||||||||||
| 422 | */ | - | ||||||||||||||||||||||||
| 423 | QRectF QGraphicsEffect::boundingRect() const | - | ||||||||||||||||||||||||
| 424 | { | - | ||||||||||||||||||||||||
| 425 | Q_D(const QGraphicsEffect); | - | ||||||||||||||||||||||||
| 426 | if (d->source)
| 0 | ||||||||||||||||||||||||
| 427 | return boundingRectFor(d->source->boundingRect()); never executed: return boundingRectFor(d->source->boundingRect()); | 0 | ||||||||||||||||||||||||
| 428 | return QRectF(); never executed: return QRectF(); | 0 | ||||||||||||||||||||||||
| 429 | } | - | ||||||||||||||||||||||||
| 430 | - | |||||||||||||||||||||||||
| 431 | /*! | - | ||||||||||||||||||||||||
| 432 | Returns the effective bounding rectangle for this effect, given the | - | ||||||||||||||||||||||||
| 433 | provided \a rect in the device coordinates. When writing | - | ||||||||||||||||||||||||
| 434 | you own custom effect, you must call updateBoundingRect() whenever any | - | ||||||||||||||||||||||||
| 435 | parameters are changed that may cause this this function to return a | - | ||||||||||||||||||||||||
| 436 | different value. | - | ||||||||||||||||||||||||
| 437 | - | |||||||||||||||||||||||||
| 438 | \sa sourceBoundingRect() | - | ||||||||||||||||||||||||
| 439 | */ | - | ||||||||||||||||||||||||
| 440 | QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const | - | ||||||||||||||||||||||||
| 441 | { | - | ||||||||||||||||||||||||
| 442 | return rect; never executed: return rect; | 0 | ||||||||||||||||||||||||
| 443 | } | - | ||||||||||||||||||||||||
| 444 | - | |||||||||||||||||||||||||
| 445 | /*! | - | ||||||||||||||||||||||||
| 446 | \property QGraphicsEffect::enabled | - | ||||||||||||||||||||||||
| 447 | \brief whether the effect is enabled or not. | - | ||||||||||||||||||||||||
| 448 | - | |||||||||||||||||||||||||
| 449 | If an effect is disabled, the source will be rendered with as normal, with | - | ||||||||||||||||||||||||
| 450 | no interference from the effect. If the effect is enabled, the source will | - | ||||||||||||||||||||||||
| 451 | be rendered with the effect applied. | - | ||||||||||||||||||||||||
| 452 | - | |||||||||||||||||||||||||
| 453 | This property is enabled by default. | - | ||||||||||||||||||||||||
| 454 | - | |||||||||||||||||||||||||
| 455 | Using this property, you can disable certain effects on slow platforms, in | - | ||||||||||||||||||||||||
| 456 | order to ensure that the user interface is responsive. | - | ||||||||||||||||||||||||
| 457 | */ | - | ||||||||||||||||||||||||
| 458 | bool QGraphicsEffect::isEnabled() const | - | ||||||||||||||||||||||||
| 459 | { | - | ||||||||||||||||||||||||
| 460 | Q_D(const QGraphicsEffect); | - | ||||||||||||||||||||||||
| 461 | return d->isEnabled; never executed: return d->isEnabled; | 0 | ||||||||||||||||||||||||
| 462 | } | - | ||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | void QGraphicsEffect::setEnabled(bool enable) | - | ||||||||||||||||||||||||
| 465 | { | - | ||||||||||||||||||||||||
| 466 | Q_D(QGraphicsEffect); | - | ||||||||||||||||||||||||
| 467 | if (d->isEnabled == enable)
| 0 | ||||||||||||||||||||||||
| 468 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | d->isEnabled = enable; | - | ||||||||||||||||||||||||
| 471 | if (d->source) {
| 0 | ||||||||||||||||||||||||
| 472 | d->source->d_func()->effectBoundingRectChanged(); | - | ||||||||||||||||||||||||
| 473 | d->source->d_func()->invalidateCache(); | - | ||||||||||||||||||||||||
| 474 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 475 | emit enabledChanged(enable); | - | ||||||||||||||||||||||||
| 476 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 477 | - | |||||||||||||||||||||||||
| 478 | /*! | - | ||||||||||||||||||||||||
| 479 | \fn void QGraphicsEffect::enabledChanged(bool enabled) | - | ||||||||||||||||||||||||
| 480 | - | |||||||||||||||||||||||||
| 481 | This signal is emitted whenever the effect is enabled or disabled. | - | ||||||||||||||||||||||||
| 482 | The \a enabled parameter holds the effects's new enabled state. | - | ||||||||||||||||||||||||
| 483 | - | |||||||||||||||||||||||||
| 484 | \sa isEnabled() | - | ||||||||||||||||||||||||
| 485 | */ | - | ||||||||||||||||||||||||
| 486 | - | |||||||||||||||||||||||||
| 487 | /*! | - | ||||||||||||||||||||||||
| 488 | Schedules a redraw of the effect. Call this function whenever the effect | - | ||||||||||||||||||||||||
| 489 | needs to be redrawn. This function does not trigger a redraw of the source. | - | ||||||||||||||||||||||||
| 490 | - | |||||||||||||||||||||||||
| 491 | \sa updateBoundingRect() | - | ||||||||||||||||||||||||
| 492 | */ | - | ||||||||||||||||||||||||
| 493 | void QGraphicsEffect::update() | - | ||||||||||||||||||||||||
| 494 | { | - | ||||||||||||||||||||||||
| 495 | Q_D(QGraphicsEffect); | - | ||||||||||||||||||||||||
| 496 | if (d->source)
| 0 | ||||||||||||||||||||||||
| 497 | d->source->update(); never executed: d->source->update(); | 0 | ||||||||||||||||||||||||
| 498 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | /*! | - | ||||||||||||||||||||||||
| 501 | \internal | - | ||||||||||||||||||||||||
| 502 | - | |||||||||||||||||||||||||
| 503 | Returns a pointer to the source, which provides extra context information | - | ||||||||||||||||||||||||
| 504 | that can be useful for the effect. | - | ||||||||||||||||||||||||
| 505 | - | |||||||||||||||||||||||||
| 506 | \sa draw() | - | ||||||||||||||||||||||||
| 507 | */ | - | ||||||||||||||||||||||||
| 508 | QGraphicsEffectSource *QGraphicsEffect::source() const | - | ||||||||||||||||||||||||
| 509 | { | - | ||||||||||||||||||||||||
| 510 | Q_D(const QGraphicsEffect); | - | ||||||||||||||||||||||||
| 511 | return d->source; never executed: return d->source; | 0 | ||||||||||||||||||||||||
| 512 | } | - | ||||||||||||||||||||||||
| 513 | - | |||||||||||||||||||||||||
| 514 | /*! | - | ||||||||||||||||||||||||
| 515 | This function notifies the effect framework when the effect's bounding | - | ||||||||||||||||||||||||
| 516 | rectangle has changed. As a custom effect author, you must call this | - | ||||||||||||||||||||||||
| 517 | function whenever you change any parameters that will cause the virtual | - | ||||||||||||||||||||||||
| 518 | boundingRectFor() function to return a different value. | - | ||||||||||||||||||||||||
| 519 | - | |||||||||||||||||||||||||
| 520 | This function will call update() if this is necessary. | - | ||||||||||||||||||||||||
| 521 | - | |||||||||||||||||||||||||
| 522 | \sa boundingRectFor(), boundingRect(), sourceBoundingRect() | - | ||||||||||||||||||||||||
| 523 | */ | - | ||||||||||||||||||||||||
| 524 | void QGraphicsEffect::updateBoundingRect() | - | ||||||||||||||||||||||||
| 525 | { | - | ||||||||||||||||||||||||
| 526 | Q_D(QGraphicsEffect); | - | ||||||||||||||||||||||||
| 527 | if (d->source) {
| 0 | ||||||||||||||||||||||||
| 528 | d->source->d_func()->effectBoundingRectChanged(); | - | ||||||||||||||||||||||||
| 529 | d->source->d_func()->invalidateCache(QGraphicsEffectSourcePrivate::EffectRectChanged); | - | ||||||||||||||||||||||||
| 530 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 531 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||
| 533 | /*! | - | ||||||||||||||||||||||||
| 534 | \fn virtual void QGraphicsEffect::draw(QPainter *painter) = 0 | - | ||||||||||||||||||||||||
| 535 | - | |||||||||||||||||||||||||
| 536 | This pure virtual function draws the effect and is called whenever the | - | ||||||||||||||||||||||||
| 537 | source needs to be drawn. | - | ||||||||||||||||||||||||
| 538 | - | |||||||||||||||||||||||||
| 539 | Reimplement this function in a QGraphicsEffect subclass to provide the | - | ||||||||||||||||||||||||
| 540 | effect's drawing implementation, using \a painter. | - | ||||||||||||||||||||||||
| 541 | - | |||||||||||||||||||||||||
| 542 | For example: | - | ||||||||||||||||||||||||
| 543 | - | |||||||||||||||||||||||||
| 544 | \snippet code/src_gui_effects_qgraphicseffect.cpp 1 | - | ||||||||||||||||||||||||
| 545 | - | |||||||||||||||||||||||||
| 546 | This function should not be called explicitly by the user, since it is | - | ||||||||||||||||||||||||
| 547 | meant for reimplementation purposes only. | - | ||||||||||||||||||||||||
| 548 | */ | - | ||||||||||||||||||||||||
| 549 | - | |||||||||||||||||||||||||
| 550 | /*! | - | ||||||||||||||||||||||||
| 551 | \enum QGraphicsEffect::ChangeFlag | - | ||||||||||||||||||||||||
| 552 | - | |||||||||||||||||||||||||
| 553 | This enum describes what has changed in QGraphicsEffectSource. | - | ||||||||||||||||||||||||
| 554 | - | |||||||||||||||||||||||||
| 555 | \value SourceAttached The effect is installed on a source. | - | ||||||||||||||||||||||||
| 556 | \value SourceDetached The effect is uninstalled on a source. | - | ||||||||||||||||||||||||
| 557 | \value SourceBoundingRectChanged The bounding rect of the source has | - | ||||||||||||||||||||||||
| 558 | changed. | - | ||||||||||||||||||||||||
| 559 | \value SourceInvalidated The visual appearance of the source has changed. | - | ||||||||||||||||||||||||
| 560 | */ | - | ||||||||||||||||||||||||
| 561 | - | |||||||||||||||||||||||||
| 562 | /*! | - | ||||||||||||||||||||||||
| 563 | \enum QGraphicsEffect::PixmapPadMode | - | ||||||||||||||||||||||||
| 564 | - | |||||||||||||||||||||||||
| 565 | This enum describes how the pixmap returned from sourcePixmap should be | - | ||||||||||||||||||||||||
| 566 | padded. | - | ||||||||||||||||||||||||
| 567 | - | |||||||||||||||||||||||||
| 568 | \value NoPad The pixmap should not receive any additional | - | ||||||||||||||||||||||||
| 569 | padding. | - | ||||||||||||||||||||||||
| 570 | \value PadToTransparentBorder The pixmap should be padded | - | ||||||||||||||||||||||||
| 571 | to ensure it has a completely transparent border. | - | ||||||||||||||||||||||||
| 572 | \value PadToEffectiveBoundingRect The pixmap should be padded to | - | ||||||||||||||||||||||||
| 573 | match the effective bounding rectangle of the effect. | - | ||||||||||||||||||||||||
| 574 | */ | - | ||||||||||||||||||||||||
| 575 | - | |||||||||||||||||||||||||
| 576 | /*! | - | ||||||||||||||||||||||||
| 577 | This virtual function is called by QGraphicsEffect to notify the effect | - | ||||||||||||||||||||||||
| 578 | that the source has changed. If the effect applies any cache, then this | - | ||||||||||||||||||||||||
| 579 | cache must be purged in order to reflect the new appearance of the source. | - | ||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | The \a flags describes what has changed. | - | ||||||||||||||||||||||||
| 582 | */ | - | ||||||||||||||||||||||||
| 583 | void QGraphicsEffect::sourceChanged(ChangeFlags flags) | - | ||||||||||||||||||||||||
| 584 | { | - | ||||||||||||||||||||||||
| 585 | Q_UNUSED(flags); | - | ||||||||||||||||||||||||
| 586 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 587 | - | |||||||||||||||||||||||||
| 588 | /*! | - | ||||||||||||||||||||||||
| 589 | \class QGraphicsColorizeEffect | - | ||||||||||||||||||||||||
| 590 | \brief The QGraphicsColorizeEffect class provides a colorize effect. | - | ||||||||||||||||||||||||
| 591 | \since 4.6 | - | ||||||||||||||||||||||||
| 592 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
| 593 | - | |||||||||||||||||||||||||
| 594 | A colorize effect renders the source with a tint of its color(). The color | - | ||||||||||||||||||||||||
| 595 | can be modified using the setColor() function. | - | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | By default, the color is light blue (QColor(0, 0, 192)). | - | ||||||||||||||||||||||||
| 598 | - | |||||||||||||||||||||||||
| 599 | \image graphicseffect-colorize.png | - | ||||||||||||||||||||||||
| 600 | - | |||||||||||||||||||||||||
| 601 | \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsOpacityEffect | - | ||||||||||||||||||||||||
| 602 | */ | - | ||||||||||||||||||||||||
| 603 | - | |||||||||||||||||||||||||
| 604 | /*! | - | ||||||||||||||||||||||||
| 605 | Constructs a new QGraphicsColorizeEffect instance. | - | ||||||||||||||||||||||||
| 606 | The \a parent parameter is passed to QGraphicsEffect's constructor. | - | ||||||||||||||||||||||||
| 607 | */ | - | ||||||||||||||||||||||||
| 608 | QGraphicsColorizeEffect::QGraphicsColorizeEffect(QObject *parent) | - | ||||||||||||||||||||||||
| 609 | : QGraphicsEffect(*new QGraphicsColorizeEffectPrivate, parent) | - | ||||||||||||||||||||||||
| 610 | { | - | ||||||||||||||||||||||||
| 611 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 612 | - | |||||||||||||||||||||||||
| 613 | /*! | - | ||||||||||||||||||||||||
| 614 | Destroys the effect. | - | ||||||||||||||||||||||||
| 615 | */ | - | ||||||||||||||||||||||||
| 616 | QGraphicsColorizeEffect::~QGraphicsColorizeEffect() | - | ||||||||||||||||||||||||
| 617 | { | - | ||||||||||||||||||||||||
| 618 | } | - | ||||||||||||||||||||||||
| 619 | - | |||||||||||||||||||||||||
| 620 | /*! | - | ||||||||||||||||||||||||
| 621 | \property QGraphicsColorizeEffect::color | - | ||||||||||||||||||||||||
| 622 | \brief the color of the effect. | - | ||||||||||||||||||||||||
| 623 | - | |||||||||||||||||||||||||
| 624 | By default, the color is light blue (QColor(0, 0, 192)). | - | ||||||||||||||||||||||||
| 625 | */ | - | ||||||||||||||||||||||||
| 626 | QColor QGraphicsColorizeEffect::color() const | - | ||||||||||||||||||||||||
| 627 | { | - | ||||||||||||||||||||||||
| 628 | Q_D(const QGraphicsColorizeEffect); | - | ||||||||||||||||||||||||
| 629 | return d->filter->color(); never executed: return d->filter->color(); | 0 | ||||||||||||||||||||||||
| 630 | } | - | ||||||||||||||||||||||||
| 631 | - | |||||||||||||||||||||||||
| 632 | void QGraphicsColorizeEffect::setColor(const QColor &color) | - | ||||||||||||||||||||||||
| 633 | { | - | ||||||||||||||||||||||||
| 634 | Q_D(QGraphicsColorizeEffect); | - | ||||||||||||||||||||||||
| 635 | if (d->filter->color() == color)
| 0 | ||||||||||||||||||||||||
| 636 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 637 | - | |||||||||||||||||||||||||
| 638 | d->filter->setColor(color); | - | ||||||||||||||||||||||||
| 639 | update(); | - | ||||||||||||||||||||||||
| 640 | emit colorChanged(color); | - | ||||||||||||||||||||||||
| 641 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 642 | - | |||||||||||||||||||||||||
| 643 | /*! | - | ||||||||||||||||||||||||
| 644 | \property QGraphicsColorizeEffect::strength | - | ||||||||||||||||||||||||
| 645 | \brief the strength of the effect. | - | ||||||||||||||||||||||||
| 646 | - | |||||||||||||||||||||||||
| 647 | By default, the strength is 1.0. | - | ||||||||||||||||||||||||
| 648 | A strength 0.0 equals to no effect, while 1.0 means full colorization. | - | ||||||||||||||||||||||||
| 649 | */ | - | ||||||||||||||||||||||||
| 650 | qreal QGraphicsColorizeEffect::strength() const | - | ||||||||||||||||||||||||
| 651 | { | - | ||||||||||||||||||||||||
| 652 | Q_D(const QGraphicsColorizeEffect); | - | ||||||||||||||||||||||||
| 653 | return d->filter->strength(); never executed: return d->filter->strength(); | 0 | ||||||||||||||||||||||||
| 654 | } | - | ||||||||||||||||||||||||
| 655 | - | |||||||||||||||||||||||||
| 656 | void QGraphicsColorizeEffect::setStrength(qreal strength) | - | ||||||||||||||||||||||||
| 657 | { | - | ||||||||||||||||||||||||
| 658 | Q_D(QGraphicsColorizeEffect); | - | ||||||||||||||||||||||||
| 659 | if (qFuzzyCompare(d->filter->strength(), strength))
| 0 | ||||||||||||||||||||||||
| 660 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 661 | - | |||||||||||||||||||||||||
| 662 | d->filter->setStrength(strength); | - | ||||||||||||||||||||||||
| 663 | d->opaque = !qFuzzyIsNull(strength); | - | ||||||||||||||||||||||||
| 664 | update(); | - | ||||||||||||||||||||||||
| 665 | emit strengthChanged(strength); | - | ||||||||||||||||||||||||
| 666 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 667 | - | |||||||||||||||||||||||||
| 668 | /*! \fn void QGraphicsColorizeEffect::strengthChanged(qreal strength) | - | ||||||||||||||||||||||||
| 669 | This signal is emitted whenever setStrength() changes the colorize | - | ||||||||||||||||||||||||
| 670 | strength property. \a strength contains the new strength value of | - | ||||||||||||||||||||||||
| 671 | the colorize effect. | - | ||||||||||||||||||||||||
| 672 | */ | - | ||||||||||||||||||||||||
| 673 | - | |||||||||||||||||||||||||
| 674 | /*! | - | ||||||||||||||||||||||||
| 675 | \fn void QGraphicsColorizeEffect::colorChanged(const QColor &color) | - | ||||||||||||||||||||||||
| 676 | - | |||||||||||||||||||||||||
| 677 | This signal is emitted whenever the effect's color changes. | - | ||||||||||||||||||||||||
| 678 | The \a color parameter holds the effect's new color. | - | ||||||||||||||||||||||||
| 679 | */ | - | ||||||||||||||||||||||||
| 680 | - | |||||||||||||||||||||||||
| 681 | /*! | - | ||||||||||||||||||||||||
| 682 | \reimp | - | ||||||||||||||||||||||||
| 683 | */ | - | ||||||||||||||||||||||||
| 684 | void QGraphicsColorizeEffect::draw(QPainter *painter) | - | ||||||||||||||||||||||||
| 685 | { | - | ||||||||||||||||||||||||
| 686 | Q_D(QGraphicsColorizeEffect); | - | ||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | if (!d->opaque) {
| 0 | ||||||||||||||||||||||||
| 689 | drawSource(painter); | - | ||||||||||||||||||||||||
| 690 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 691 | } | - | ||||||||||||||||||||||||
| 692 | - | |||||||||||||||||||||||||
| 693 | QPoint offset; | - | ||||||||||||||||||||||||
| 694 | if (sourceIsPixmap()) {
| 0 | ||||||||||||||||||||||||
| 695 | // No point in drawing in device coordinates (pixmap will be scaled anyways). | - | ||||||||||||||||||||||||
| 696 | const QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, NoPad); | - | ||||||||||||||||||||||||
| 697 | if (!pixmap.isNull())
| 0 | ||||||||||||||||||||||||
| 698 | d->filter->draw(painter, offset, pixmap); never executed: d->filter->draw(painter, offset, pixmap); | 0 | ||||||||||||||||||||||||
| 699 | - | |||||||||||||||||||||||||
| 700 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 701 | } | - | ||||||||||||||||||||||||
| 702 | - | |||||||||||||||||||||||||
| 703 | // Draw pixmap in deviceCoordinates to avoid pixmap scaling. | - | ||||||||||||||||||||||||
| 704 | const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset); | - | ||||||||||||||||||||||||
| 705 | if (pixmap.isNull())
| 0 | ||||||||||||||||||||||||
| 706 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 707 | - | |||||||||||||||||||||||||
| 708 | QTransform restoreTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 709 | painter->setWorldTransform(QTransform()); | - | ||||||||||||||||||||||||
| 710 | d->filter->draw(painter, offset, pixmap); | - | ||||||||||||||||||||||||
| 711 | painter->setWorldTransform(restoreTransform); | - | ||||||||||||||||||||||||
| 712 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 713 | - | |||||||||||||||||||||||||
| 714 | /*! | - | ||||||||||||||||||||||||
| 715 | \class QGraphicsBlurEffect | - | ||||||||||||||||||||||||
| 716 | \brief The QGraphicsBlurEffect class provides a blur effect. | - | ||||||||||||||||||||||||
| 717 | \since 4.6 | - | ||||||||||||||||||||||||
| 718 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
| 719 | - | |||||||||||||||||||||||||
| 720 | A blur effect blurs the source. This effect is useful for reducing details, | - | ||||||||||||||||||||||||
| 721 | such as when the source loses focus and you want to draw attention to other | - | ||||||||||||||||||||||||
| 722 | elements. The level of detail can be modified using the setBlurRadius() | - | ||||||||||||||||||||||||
| 723 | function. Use setBlurHints() to choose the blur hints. | - | ||||||||||||||||||||||||
| 724 | - | |||||||||||||||||||||||||
| 725 | By default, the blur radius is 5 pixels. The blur radius is specified in | - | ||||||||||||||||||||||||
| 726 | device coordinates. | - | ||||||||||||||||||||||||
| 727 | - | |||||||||||||||||||||||||
| 728 | \image graphicseffect-blur.png | - | ||||||||||||||||||||||||
| 729 | - | |||||||||||||||||||||||||
| 730 | \sa QGraphicsDropShadowEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect | - | ||||||||||||||||||||||||
| 731 | */ | - | ||||||||||||||||||||||||
| 732 | - | |||||||||||||||||||||||||
| 733 | /*! | - | ||||||||||||||||||||||||
| 734 | \enum QGraphicsBlurEffect::BlurHint | - | ||||||||||||||||||||||||
| 735 | \since 4.6 | - | ||||||||||||||||||||||||
| 736 | - | |||||||||||||||||||||||||
| 737 | This enum describes the possible hints that can be used to control how | - | ||||||||||||||||||||||||
| 738 | blur effects are applied. The hints might not have an effect in all the | - | ||||||||||||||||||||||||
| 739 | paint engines. | - | ||||||||||||||||||||||||
| 740 | - | |||||||||||||||||||||||||
| 741 | \value PerformanceHint Indicates that rendering performance is the most important factor, | - | ||||||||||||||||||||||||
| 742 | at the potential cost of lower quality. | - | ||||||||||||||||||||||||
| 743 | - | |||||||||||||||||||||||||
| 744 | \value QualityHint Indicates that rendering quality is the most important factor, | - | ||||||||||||||||||||||||
| 745 | at the potential cost of lower performance. | - | ||||||||||||||||||||||||
| 746 | - | |||||||||||||||||||||||||
| 747 | \value AnimationHint Indicates that the blur radius is going to be animated, hinting | - | ||||||||||||||||||||||||
| 748 | that the implementation can keep a cache of blurred verisons of the source. | - | ||||||||||||||||||||||||
| 749 | Do not use this hint if the source is going to be dynamically changing. | - | ||||||||||||||||||||||||
| 750 | - | |||||||||||||||||||||||||
| 751 | \sa blurHints(), setBlurHints() | - | ||||||||||||||||||||||||
| 752 | */ | - | ||||||||||||||||||||||||
| 753 | - | |||||||||||||||||||||||||
| 754 | - | |||||||||||||||||||||||||
| 755 | /*! | - | ||||||||||||||||||||||||
| 756 | Constructs a new QGraphicsBlurEffect instance. | - | ||||||||||||||||||||||||
| 757 | The \a parent parameter is passed to QGraphicsEffect's constructor. | - | ||||||||||||||||||||||||
| 758 | */ | - | ||||||||||||||||||||||||
| 759 | QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) | - | ||||||||||||||||||||||||
| 760 | : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) | - | ||||||||||||||||||||||||
| 761 | { | - | ||||||||||||||||||||||||
| 762 | Q_D(QGraphicsBlurEffect); | - | ||||||||||||||||||||||||
| 763 | d->filter->setBlurHints(QGraphicsBlurEffect::PerformanceHint); | - | ||||||||||||||||||||||||
| 764 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 765 | - | |||||||||||||||||||||||||
| 766 | /*! | - | ||||||||||||||||||||||||
| 767 | Destroys the effect. | - | ||||||||||||||||||||||||
| 768 | */ | - | ||||||||||||||||||||||||
| 769 | QGraphicsBlurEffect::~QGraphicsBlurEffect() | - | ||||||||||||||||||||||||
| 770 | { | - | ||||||||||||||||||||||||
| 771 | } | - | ||||||||||||||||||||||||
| 772 | - | |||||||||||||||||||||||||
| 773 | /*! | - | ||||||||||||||||||||||||
| 774 | \property QGraphicsBlurEffect::blurRadius | - | ||||||||||||||||||||||||
| 775 | \brief the blur radius of the effect. | - | ||||||||||||||||||||||||
| 776 | - | |||||||||||||||||||||||||
| 777 | Using a smaller radius results in a sharper appearance, whereas a bigger | - | ||||||||||||||||||||||||
| 778 | radius results in a more blurred appearance. | - | ||||||||||||||||||||||||
| 779 | - | |||||||||||||||||||||||||
| 780 | By default, the blur radius is 5 pixels. | - | ||||||||||||||||||||||||
| 781 | - | |||||||||||||||||||||||||
| 782 | The radius is given in device coordinates, meaning it is | - | ||||||||||||||||||||||||
| 783 | unaffected by scale. | - | ||||||||||||||||||||||||
| 784 | */ | - | ||||||||||||||||||||||||
| 785 | qreal QGraphicsBlurEffect::blurRadius() const | - | ||||||||||||||||||||||||
| 786 | { | - | ||||||||||||||||||||||||
| 787 | Q_D(const QGraphicsBlurEffect); | - | ||||||||||||||||||||||||
| 788 | return d->filter->radius(); never executed: return d->filter->radius(); | 0 | ||||||||||||||||||||||||
| 789 | } | - | ||||||||||||||||||||||||
| 790 | - | |||||||||||||||||||||||||
| 791 | void QGraphicsBlurEffect::setBlurRadius(qreal radius) | - | ||||||||||||||||||||||||
| 792 | { | - | ||||||||||||||||||||||||
| 793 | Q_D(QGraphicsBlurEffect); | - | ||||||||||||||||||||||||
| 794 | if (qFuzzyCompare(d->filter->radius(), radius))
| 0 | ||||||||||||||||||||||||
| 795 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 796 | - | |||||||||||||||||||||||||
| 797 | d->filter->setRadius(radius); | - | ||||||||||||||||||||||||
| 798 | updateBoundingRect(); | - | ||||||||||||||||||||||||
| 799 | emit blurRadiusChanged(radius); | - | ||||||||||||||||||||||||
| 800 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 801 | - | |||||||||||||||||||||||||
| 802 | /*! | - | ||||||||||||||||||||||||
| 803 | \fn void QGraphicsBlurEffect::blurRadiusChanged(qreal radius) | - | ||||||||||||||||||||||||
| 804 | - | |||||||||||||||||||||||||
| 805 | This signal is emitted whenever the effect's blur radius changes. | - | ||||||||||||||||||||||||
| 806 | The \a radius parameter holds the effect's new blur radius. | - | ||||||||||||||||||||||||
| 807 | */ | - | ||||||||||||||||||||||||
| 808 | - | |||||||||||||||||||||||||
| 809 | /*! | - | ||||||||||||||||||||||||
| 810 | \property QGraphicsBlurEffect::blurHints | - | ||||||||||||||||||||||||
| 811 | \brief the blur hint of the effect. | - | ||||||||||||||||||||||||
| 812 | - | |||||||||||||||||||||||||
| 813 | Use the PerformanceHint hint to say that you want a faster blur, | - | ||||||||||||||||||||||||
| 814 | the QualityHint hint to say that you prefer a higher quality blur, | - | ||||||||||||||||||||||||
| 815 | or the AnimationHint when you want to animate the blur radius. | - | ||||||||||||||||||||||||
| 816 | - | |||||||||||||||||||||||||
| 817 | By default, the blur hint is PerformanceHint. | - | ||||||||||||||||||||||||
| 818 | */ | - | ||||||||||||||||||||||||
| 819 | QGraphicsBlurEffect::BlurHints QGraphicsBlurEffect::blurHints() const | - | ||||||||||||||||||||||||
| 820 | { | - | ||||||||||||||||||||||||
| 821 | Q_D(const QGraphicsBlurEffect); | - | ||||||||||||||||||||||||
| 822 | return d->filter->blurHints(); never executed: return d->filter->blurHints(); | 0 | ||||||||||||||||||||||||
| 823 | } | - | ||||||||||||||||||||||||
| 824 | - | |||||||||||||||||||||||||
| 825 | void QGraphicsBlurEffect::setBlurHints(QGraphicsBlurEffect::BlurHints hints) | - | ||||||||||||||||||||||||
| 826 | { | - | ||||||||||||||||||||||||
| 827 | Q_D(QGraphicsBlurEffect); | - | ||||||||||||||||||||||||
| 828 | if (d->filter->blurHints() == hints)
| 0 | ||||||||||||||||||||||||
| 829 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 830 | - | |||||||||||||||||||||||||
| 831 | d->filter->setBlurHints(hints); | - | ||||||||||||||||||||||||
| 832 | emit blurHintsChanged(hints); | - | ||||||||||||||||||||||||
| 833 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 834 | - | |||||||||||||||||||||||||
| 835 | /*! | - | ||||||||||||||||||||||||
| 836 | \fn void QGraphicsBlurEffect::blurHintsChanged(QGraphicsBlurEffect::BlurHints hints) | - | ||||||||||||||||||||||||
| 837 | - | |||||||||||||||||||||||||
| 838 | This signal is emitted whenever the effect's blur hints changes. | - | ||||||||||||||||||||||||
| 839 | The \a hints parameter holds the effect's new blur hints. | - | ||||||||||||||||||||||||
| 840 | */ | - | ||||||||||||||||||||||||
| 841 | - | |||||||||||||||||||||||||
| 842 | /*! | - | ||||||||||||||||||||||||
| 843 | \reimp | - | ||||||||||||||||||||||||
| 844 | */ | - | ||||||||||||||||||||||||
| 845 | QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const | - | ||||||||||||||||||||||||
| 846 | { | - | ||||||||||||||||||||||||
| 847 | Q_D(const QGraphicsBlurEffect); | - | ||||||||||||||||||||||||
| 848 | return d->filter->boundingRectFor(rect); never executed: return d->filter->boundingRectFor(rect); | 0 | ||||||||||||||||||||||||
| 849 | } | - | ||||||||||||||||||||||||
| 850 | - | |||||||||||||||||||||||||
| 851 | /*! | - | ||||||||||||||||||||||||
| 852 | \reimp | - | ||||||||||||||||||||||||
| 853 | */ | - | ||||||||||||||||||||||||
| 854 | void QGraphicsBlurEffect::draw(QPainter *painter) | - | ||||||||||||||||||||||||
| 855 | { | - | ||||||||||||||||||||||||
| 856 | Q_D(QGraphicsBlurEffect); | - | ||||||||||||||||||||||||
| 857 | if (d->filter->radius() < 1) {
| 0 | ||||||||||||||||||||||||
| 858 | drawSource(painter); | - | ||||||||||||||||||||||||
| 859 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 860 | } | - | ||||||||||||||||||||||||
| 861 | - | |||||||||||||||||||||||||
| 862 | PixmapPadMode mode = PadToEffectiveBoundingRect; | - | ||||||||||||||||||||||||
| 863 | - | |||||||||||||||||||||||||
| 864 | QPoint offset; | - | ||||||||||||||||||||||||
| 865 | QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode); | - | ||||||||||||||||||||||||
| 866 | if (pixmap.isNull())
| 0 | ||||||||||||||||||||||||
| 867 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 868 | - | |||||||||||||||||||||||||
| 869 | d->filter->draw(painter, offset, pixmap); | - | ||||||||||||||||||||||||
| 870 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 871 | - | |||||||||||||||||||||||||
| 872 | /*! | - | ||||||||||||||||||||||||
| 873 | \class QGraphicsDropShadowEffect | - | ||||||||||||||||||||||||
| 874 | \brief The QGraphicsDropShadowEffect class provides a drop shadow effect. | - | ||||||||||||||||||||||||
| 875 | \since 4.6 | - | ||||||||||||||||||||||||
| 876 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||
| 878 | A drop shadow effect renders the source with a drop shadow. The color of | - | ||||||||||||||||||||||||
| 879 | the drop shadow can be modified using the setColor() function. The drop | - | ||||||||||||||||||||||||
| 880 | shadow offset can be modified using the setOffset() function and the blur | - | ||||||||||||||||||||||||
| 881 | radius of the drop shadow can be changed with the setBlurRadius() | - | ||||||||||||||||||||||||
| 882 | function. | - | ||||||||||||||||||||||||
| 883 | - | |||||||||||||||||||||||||
| 884 | By default, the drop shadow is a semi-transparent dark gray | - | ||||||||||||||||||||||||
| 885 | (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset | - | ||||||||||||||||||||||||
| 886 | of 8 pixels towards the lower right. The drop shadow offset is specified | - | ||||||||||||||||||||||||
| 887 | in device coordinates. | - | ||||||||||||||||||||||||
| 888 | - | |||||||||||||||||||||||||
| 889 | \image graphicseffect-drop-shadow.png | - | ||||||||||||||||||||||||
| 890 | - | |||||||||||||||||||||||||
| 891 | \sa QGraphicsBlurEffect, QGraphicsColorizeEffect, QGraphicsOpacityEffect | - | ||||||||||||||||||||||||
| 892 | */ | - | ||||||||||||||||||||||||
| 893 | - | |||||||||||||||||||||||||
| 894 | /*! | - | ||||||||||||||||||||||||
| 895 | Constructs a new QGraphicsDropShadowEffect instance. | - | ||||||||||||||||||||||||
| 896 | The \a parent parameter is passed to QGraphicsEffect's constructor. | - | ||||||||||||||||||||||||
| 897 | */ | - | ||||||||||||||||||||||||
| 898 | QGraphicsDropShadowEffect::QGraphicsDropShadowEffect(QObject *parent) | - | ||||||||||||||||||||||||
| 899 | : QGraphicsEffect(*new QGraphicsDropShadowEffectPrivate, parent) | - | ||||||||||||||||||||||||
| 900 | { | - | ||||||||||||||||||||||||
| 901 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||
| 903 | /*! | - | ||||||||||||||||||||||||
| 904 | Destroys the effect. | - | ||||||||||||||||||||||||
| 905 | */ | - | ||||||||||||||||||||||||
| 906 | QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() | - | ||||||||||||||||||||||||
| 907 | { | - | ||||||||||||||||||||||||
| 908 | } | - | ||||||||||||||||||||||||
| 909 | - | |||||||||||||||||||||||||
| 910 | /*! | - | ||||||||||||||||||||||||
| 911 | \property QGraphicsDropShadowEffect::offset | - | ||||||||||||||||||||||||
| 912 | \brief the shadow offset in pixels. | - | ||||||||||||||||||||||||
| 913 | - | |||||||||||||||||||||||||
| 914 | By default, the offset is 8 pixels towards the lower right. | - | ||||||||||||||||||||||||
| 915 | - | |||||||||||||||||||||||||
| 916 | The offset is given in device coordinates, which means it is | - | ||||||||||||||||||||||||
| 917 | unaffected by scale. | - | ||||||||||||||||||||||||
| 918 | - | |||||||||||||||||||||||||
| 919 | \sa xOffset(), yOffset(), blurRadius(), color() | - | ||||||||||||||||||||||||
| 920 | */ | - | ||||||||||||||||||||||||
| 921 | QPointF QGraphicsDropShadowEffect::offset() const | - | ||||||||||||||||||||||||
| 922 | { | - | ||||||||||||||||||||||||
| 923 | Q_D(const QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 924 | return d->filter->offset(); never executed: return d->filter->offset(); | 0 | ||||||||||||||||||||||||
| 925 | } | - | ||||||||||||||||||||||||
| 926 | - | |||||||||||||||||||||||||
| 927 | void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) | - | ||||||||||||||||||||||||
| 928 | { | - | ||||||||||||||||||||||||
| 929 | Q_D(QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 930 | if (d->filter->offset() == offset)
| 0 | ||||||||||||||||||||||||
| 931 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 932 | - | |||||||||||||||||||||||||
| 933 | d->filter->setOffset(offset); | - | ||||||||||||||||||||||||
| 934 | updateBoundingRect(); | - | ||||||||||||||||||||||||
| 935 | emit offsetChanged(offset); | - | ||||||||||||||||||||||||
| 936 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 937 | - | |||||||||||||||||||||||||
| 938 | /*! | - | ||||||||||||||||||||||||
| 939 | \property QGraphicsDropShadowEffect::xOffset | - | ||||||||||||||||||||||||
| 940 | \brief the horizontal shadow offset in pixels. | - | ||||||||||||||||||||||||
| 941 | - | |||||||||||||||||||||||||
| 942 | By default, the horizontal shadow offset is 8 pixels. | - | ||||||||||||||||||||||||
| 943 | - | |||||||||||||||||||||||||
| 944 | - | |||||||||||||||||||||||||
| 945 | - | |||||||||||||||||||||||||
| 946 | \sa yOffset(), offset() | - | ||||||||||||||||||||||||
| 947 | */ | - | ||||||||||||||||||||||||
| 948 | - | |||||||||||||||||||||||||
| 949 | /*! | - | ||||||||||||||||||||||||
| 950 | \property QGraphicsDropShadowEffect::yOffset | - | ||||||||||||||||||||||||
| 951 | \brief the vertical shadow offset in pixels. | - | ||||||||||||||||||||||||
| 952 | - | |||||||||||||||||||||||||
| 953 | By default, the vertical shadow offset is 8 pixels. | - | ||||||||||||||||||||||||
| 954 | - | |||||||||||||||||||||||||
| 955 | \sa xOffset(), offset() | - | ||||||||||||||||||||||||
| 956 | */ | - | ||||||||||||||||||||||||
| 957 | - | |||||||||||||||||||||||||
| 958 | /*! | - | ||||||||||||||||||||||||
| 959 | \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset) | - | ||||||||||||||||||||||||
| 960 | - | |||||||||||||||||||||||||
| 961 | This signal is emitted whenever the effect's shadow offset changes. | - | ||||||||||||||||||||||||
| 962 | The \a offset parameter holds the effect's new shadow offset. | - | ||||||||||||||||||||||||
| 963 | */ | - | ||||||||||||||||||||||||
| 964 | - | |||||||||||||||||||||||||
| 965 | /*! | - | ||||||||||||||||||||||||
| 966 | \property QGraphicsDropShadowEffect::blurRadius | - | ||||||||||||||||||||||||
| 967 | \brief the blur radius in pixels of the drop shadow. | - | ||||||||||||||||||||||||
| 968 | - | |||||||||||||||||||||||||
| 969 | Using a smaller radius results in a sharper shadow, whereas using a bigger | - | ||||||||||||||||||||||||
| 970 | radius results in a more blurred shadow. | - | ||||||||||||||||||||||||
| 971 | - | |||||||||||||||||||||||||
| 972 | By default, the blur radius is 1 pixel. | - | ||||||||||||||||||||||||
| 973 | - | |||||||||||||||||||||||||
| 974 | \sa color(), offset() | - | ||||||||||||||||||||||||
| 975 | */ | - | ||||||||||||||||||||||||
| 976 | qreal QGraphicsDropShadowEffect::blurRadius() const | - | ||||||||||||||||||||||||
| 977 | { | - | ||||||||||||||||||||||||
| 978 | Q_D(const QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 979 | return d->filter->blurRadius(); never executed: return d->filter->blurRadius(); | 0 | ||||||||||||||||||||||||
| 980 | } | - | ||||||||||||||||||||||||
| 981 | - | |||||||||||||||||||||||||
| 982 | void QGraphicsDropShadowEffect::setBlurRadius(qreal blurRadius) | - | ||||||||||||||||||||||||
| 983 | { | - | ||||||||||||||||||||||||
| 984 | Q_D(QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 985 | if (qFuzzyCompare(d->filter->blurRadius(), blurRadius))
| 0 | ||||||||||||||||||||||||
| 986 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 987 | - | |||||||||||||||||||||||||
| 988 | d->filter->setBlurRadius(blurRadius); | - | ||||||||||||||||||||||||
| 989 | updateBoundingRect(); | - | ||||||||||||||||||||||||
| 990 | emit blurRadiusChanged(blurRadius); | - | ||||||||||||||||||||||||
| 991 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 992 | - | |||||||||||||||||||||||||
| 993 | /*! | - | ||||||||||||||||||||||||
| 994 | \fn void QGraphicsDropShadowEffect::blurRadiusChanged(qreal blurRadius) | - | ||||||||||||||||||||||||
| 995 | - | |||||||||||||||||||||||||
| 996 | This signal is emitted whenever the effect's blur radius changes. | - | ||||||||||||||||||||||||
| 997 | The \a blurRadius parameter holds the effect's new blur radius. | - | ||||||||||||||||||||||||
| 998 | */ | - | ||||||||||||||||||||||||
| 999 | - | |||||||||||||||||||||||||
| 1000 | /*! | - | ||||||||||||||||||||||||
| 1001 | \property QGraphicsDropShadowEffect::color | - | ||||||||||||||||||||||||
| 1002 | \brief the color of the drop shadow. | - | ||||||||||||||||||||||||
| 1003 | - | |||||||||||||||||||||||||
| 1004 | By default, the drop color is a semi-transparent dark gray | - | ||||||||||||||||||||||||
| 1005 | (QColor(63, 63, 63, 180)). | - | ||||||||||||||||||||||||
| 1006 | - | |||||||||||||||||||||||||
| 1007 | \sa offset(), blurRadius() | - | ||||||||||||||||||||||||
| 1008 | */ | - | ||||||||||||||||||||||||
| 1009 | QColor QGraphicsDropShadowEffect::color() const | - | ||||||||||||||||||||||||
| 1010 | { | - | ||||||||||||||||||||||||
| 1011 | Q_D(const QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 1012 | return d->filter->color(); never executed: return d->filter->color(); | 0 | ||||||||||||||||||||||||
| 1013 | } | - | ||||||||||||||||||||||||
| 1014 | - | |||||||||||||||||||||||||
| 1015 | void QGraphicsDropShadowEffect::setColor(const QColor &color) | - | ||||||||||||||||||||||||
| 1016 | { | - | ||||||||||||||||||||||||
| 1017 | Q_D(QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 1018 | if (d->filter->color() == color)
| 0 | ||||||||||||||||||||||||
| 1019 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1020 | - | |||||||||||||||||||||||||
| 1021 | d->filter->setColor(color); | - | ||||||||||||||||||||||||
| 1022 | update(); | - | ||||||||||||||||||||||||
| 1023 | emit colorChanged(color); | - | ||||||||||||||||||||||||
| 1024 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||
| 1026 | /*! | - | ||||||||||||||||||||||||
| 1027 | \fn void QGraphicsDropShadowEffect::colorChanged(const QColor &color) | - | ||||||||||||||||||||||||
| 1028 | - | |||||||||||||||||||||||||
| 1029 | This signal is emitted whenever the effect's color changes. | - | ||||||||||||||||||||||||
| 1030 | The \a color parameter holds the effect's new color. | - | ||||||||||||||||||||||||
| 1031 | */ | - | ||||||||||||||||||||||||
| 1032 | - | |||||||||||||||||||||||||
| 1033 | /*! | - | ||||||||||||||||||||||||
| 1034 | \reimp | - | ||||||||||||||||||||||||
| 1035 | */ | - | ||||||||||||||||||||||||
| 1036 | QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const | - | ||||||||||||||||||||||||
| 1037 | { | - | ||||||||||||||||||||||||
| 1038 | Q_D(const QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 1039 | return d->filter->boundingRectFor(rect); never executed: return d->filter->boundingRectFor(rect); | 0 | ||||||||||||||||||||||||
| 1040 | } | - | ||||||||||||||||||||||||
| 1041 | - | |||||||||||||||||||||||||
| 1042 | /*! | - | ||||||||||||||||||||||||
| 1043 | \reimp | - | ||||||||||||||||||||||||
| 1044 | */ | - | ||||||||||||||||||||||||
| 1045 | void QGraphicsDropShadowEffect::draw(QPainter *painter) | - | ||||||||||||||||||||||||
| 1046 | { | - | ||||||||||||||||||||||||
| 1047 | Q_D(QGraphicsDropShadowEffect); | - | ||||||||||||||||||||||||
| 1048 | if (d->filter->blurRadius() <= 0 && d->filter->offset().isNull()) {
| 0 | ||||||||||||||||||||||||
| 1049 | drawSource(painter); | - | ||||||||||||||||||||||||
| 1050 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||
| 1053 | PixmapPadMode mode = PadToEffectiveBoundingRect; | - | ||||||||||||||||||||||||
| 1054 | - | |||||||||||||||||||||||||
| 1055 | // Draw pixmap in device coordinates to avoid pixmap scaling. | - | ||||||||||||||||||||||||
| 1056 | QPoint offset; | - | ||||||||||||||||||||||||
| 1057 | const QPixmap pixmap = sourcePixmap(Qt::DeviceCoordinates, &offset, mode); | - | ||||||||||||||||||||||||
| 1058 | if (pixmap.isNull())
| 0 | ||||||||||||||||||||||||
| 1059 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1060 | - | |||||||||||||||||||||||||
| 1061 | QTransform restoreTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 1062 | painter->setWorldTransform(QTransform()); | - | ||||||||||||||||||||||||
| 1063 | d->filter->draw(painter, offset, pixmap); | - | ||||||||||||||||||||||||
| 1064 | painter->setWorldTransform(restoreTransform); | - | ||||||||||||||||||||||||
| 1065 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1066 | - | |||||||||||||||||||||||||
| 1067 | /*! | - | ||||||||||||||||||||||||
| 1068 | \class QGraphicsOpacityEffect | - | ||||||||||||||||||||||||
| 1069 | \brief The QGraphicsOpacityEffect class provides an opacity effect. | - | ||||||||||||||||||||||||
| 1070 | \since 4.6 | - | ||||||||||||||||||||||||
| 1071 | \inmodule QtWidgets | - | ||||||||||||||||||||||||
| 1072 | - | |||||||||||||||||||||||||
| 1073 | An opacity effect renders the source with an opacity. This effect is useful | - | ||||||||||||||||||||||||
| 1074 | for making the source semi-transparent, similar to a fade-in/fade-out | - | ||||||||||||||||||||||||
| 1075 | sequence. The opacity can be modified using the setOpacity() function. | - | ||||||||||||||||||||||||
| 1076 | - | |||||||||||||||||||||||||
| 1077 | By default, the opacity is 0.7. | - | ||||||||||||||||||||||||
| 1078 | - | |||||||||||||||||||||||||
| 1079 | \image graphicseffect-opacity.png | - | ||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsColorizeEffect | - | ||||||||||||||||||||||||
| 1082 | */ | - | ||||||||||||||||||||||||
| 1083 | - | |||||||||||||||||||||||||
| 1084 | /*! | - | ||||||||||||||||||||||||
| 1085 | Constructs a new QGraphicsOpacityEffect instance. | - | ||||||||||||||||||||||||
| 1086 | The \a parent parameter is passed to QGraphicsEffect's constructor. | - | ||||||||||||||||||||||||
| 1087 | */ | - | ||||||||||||||||||||||||
| 1088 | QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent) | - | ||||||||||||||||||||||||
| 1089 | : QGraphicsEffect(*new QGraphicsOpacityEffectPrivate, parent) | - | ||||||||||||||||||||||||
| 1090 | { | - | ||||||||||||||||||||||||
| 1091 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1092 | - | |||||||||||||||||||||||||
| 1093 | /*! | - | ||||||||||||||||||||||||
| 1094 | Destroys the effect. | - | ||||||||||||||||||||||||
| 1095 | */ | - | ||||||||||||||||||||||||
| 1096 | QGraphicsOpacityEffect::~QGraphicsOpacityEffect() | - | ||||||||||||||||||||||||
| 1097 | { | - | ||||||||||||||||||||||||
| 1098 | } | - | ||||||||||||||||||||||||
| 1099 | - | |||||||||||||||||||||||||
| 1100 | /*! | - | ||||||||||||||||||||||||
| 1101 | \property QGraphicsOpacityEffect::opacity | - | ||||||||||||||||||||||||
| 1102 | \brief the opacity of the effect. | - | ||||||||||||||||||||||||
| 1103 | - | |||||||||||||||||||||||||
| 1104 | The value should be in the range of 0.0 to 1.0, where 0.0 is | - | ||||||||||||||||||||||||
| 1105 | fully transparent and 1.0 is fully opaque. | - | ||||||||||||||||||||||||
| 1106 | - | |||||||||||||||||||||||||
| 1107 | By default, the opacity is 0.7. | - | ||||||||||||||||||||||||
| 1108 | - | |||||||||||||||||||||||||
| 1109 | \sa setOpacityMask() | - | ||||||||||||||||||||||||
| 1110 | */ | - | ||||||||||||||||||||||||
| 1111 | qreal QGraphicsOpacityEffect::opacity() const | - | ||||||||||||||||||||||||
| 1112 | { | - | ||||||||||||||||||||||||
| 1113 | Q_D(const QGraphicsOpacityEffect); | - | ||||||||||||||||||||||||
| 1114 | return d->opacity; never executed: return d->opacity; | 0 | ||||||||||||||||||||||||
| 1115 | } | - | ||||||||||||||||||||||||
| 1116 | - | |||||||||||||||||||||||||
| 1117 | void QGraphicsOpacityEffect::setOpacity(qreal opacity) | - | ||||||||||||||||||||||||
| 1118 | { | - | ||||||||||||||||||||||||
| 1119 | Q_D(QGraphicsOpacityEffect); | - | ||||||||||||||||||||||||
| 1120 | opacity = qBound(qreal(0.0), opacity, qreal(1.0)); | - | ||||||||||||||||||||||||
| 1121 | - | |||||||||||||||||||||||||
| 1122 | if (qFuzzyCompare(d->opacity, opacity))
| 0 | ||||||||||||||||||||||||
| 1123 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1124 | - | |||||||||||||||||||||||||
| 1125 | d->opacity = opacity; | - | ||||||||||||||||||||||||
| 1126 | if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity)))
| 0 | ||||||||||||||||||||||||
| 1127 | d->isFullyOpaque = 0; never executed: d->isFullyOpaque = 0; | 0 | ||||||||||||||||||||||||
| 1128 | else | - | ||||||||||||||||||||||||
| 1129 | d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); never executed: d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1); | 0 | ||||||||||||||||||||||||
| 1130 | update(); | - | ||||||||||||||||||||||||
| 1131 | emit opacityChanged(opacity); | - | ||||||||||||||||||||||||
| 1132 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1133 | - | |||||||||||||||||||||||||
| 1134 | /*! | - | ||||||||||||||||||||||||
| 1135 | \fn void QGraphicsOpacityEffect::opacityChanged(qreal opacity) | - | ||||||||||||||||||||||||
| 1136 | - | |||||||||||||||||||||||||
| 1137 | This signal is emitted whenever the effect's opacity changes. | - | ||||||||||||||||||||||||
| 1138 | The \a opacity parameter holds the effect's new opacity. | - | ||||||||||||||||||||||||
| 1139 | */ | - | ||||||||||||||||||||||||
| 1140 | - | |||||||||||||||||||||||||
| 1141 | /*! | - | ||||||||||||||||||||||||
| 1142 | \property QGraphicsOpacityEffect::opacityMask | - | ||||||||||||||||||||||||
| 1143 | \brief the opacity mask of the effect. | - | ||||||||||||||||||||||||
| 1144 | - | |||||||||||||||||||||||||
| 1145 | An opacity mask allows you apply opacity to portions of an element. | - | ||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||
| 1147 | For example: | - | ||||||||||||||||||||||||
| 1148 | - | |||||||||||||||||||||||||
| 1149 | \snippet code/src_gui_effects_qgraphicseffect.cpp 2 | - | ||||||||||||||||||||||||
| 1150 | - | |||||||||||||||||||||||||
| 1151 | There is no opacity mask by default. | - | ||||||||||||||||||||||||
| 1152 | - | |||||||||||||||||||||||||
| 1153 | \sa setOpacity() | - | ||||||||||||||||||||||||
| 1154 | */ | - | ||||||||||||||||||||||||
| 1155 | QBrush QGraphicsOpacityEffect::opacityMask() const | - | ||||||||||||||||||||||||
| 1156 | { | - | ||||||||||||||||||||||||
| 1157 | Q_D(const QGraphicsOpacityEffect); | - | ||||||||||||||||||||||||
| 1158 | return d->opacityMask; never executed: return d->opacityMask; | 0 | ||||||||||||||||||||||||
| 1159 | } | - | ||||||||||||||||||||||||
| 1160 | - | |||||||||||||||||||||||||
| 1161 | void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask) | - | ||||||||||||||||||||||||
| 1162 | { | - | ||||||||||||||||||||||||
| 1163 | Q_D(QGraphicsOpacityEffect); | - | ||||||||||||||||||||||||
| 1164 | if (d->opacityMask == mask)
| 0 | ||||||||||||||||||||||||
| 1165 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | d->opacityMask = mask; | - | ||||||||||||||||||||||||
| 1168 | d->hasOpacityMask = (mask.style() != Qt::NoBrush); | - | ||||||||||||||||||||||||
| 1169 | update(); | - | ||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||
| 1171 | emit opacityMaskChanged(mask); | - | ||||||||||||||||||||||||
| 1172 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1173 | - | |||||||||||||||||||||||||
| 1174 | /*! | - | ||||||||||||||||||||||||
| 1175 | \fn void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask) | - | ||||||||||||||||||||||||
| 1176 | - | |||||||||||||||||||||||||
| 1177 | This signal is emitted whenever the effect's opacity mask changes. | - | ||||||||||||||||||||||||
| 1178 | The \a mask parameter holds the effect's new opacity mask. | - | ||||||||||||||||||||||||
| 1179 | */ | - | ||||||||||||||||||||||||
| 1180 | - | |||||||||||||||||||||||||
| 1181 | /*! | - | ||||||||||||||||||||||||
| 1182 | \reimp | - | ||||||||||||||||||||||||
| 1183 | */ | - | ||||||||||||||||||||||||
| 1184 | void QGraphicsOpacityEffect::draw(QPainter *painter) | - | ||||||||||||||||||||||||
| 1185 | { | - | ||||||||||||||||||||||||
| 1186 | Q_D(QGraphicsOpacityEffect); | - | ||||||||||||||||||||||||
| 1187 | - | |||||||||||||||||||||||||
| 1188 | // Transparent; nothing to draw. | - | ||||||||||||||||||||||||
| 1189 | if (d->isFullyTransparent)
| 0 | ||||||||||||||||||||||||
| 1190 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1191 | - | |||||||||||||||||||||||||
| 1192 | // Opaque; draw directly without going through a pixmap. | - | ||||||||||||||||||||||||
| 1193 | if (d->isFullyOpaque && !d->hasOpacityMask) {
| 0 | ||||||||||||||||||||||||
| 1194 | drawSource(painter); | - | ||||||||||||||||||||||||
| 1195 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1196 | } | - | ||||||||||||||||||||||||
| 1197 | - | |||||||||||||||||||||||||
| 1198 | QPoint offset; | - | ||||||||||||||||||||||||
| 1199 | Qt::CoordinateSystem system = sourceIsPixmap() ? Qt::LogicalCoordinates : Qt::DeviceCoordinates;
| 0 | ||||||||||||||||||||||||
| 1200 | QPixmap pixmap = sourcePixmap(system, &offset, QGraphicsEffect::NoPad); | - | ||||||||||||||||||||||||
| 1201 | if (pixmap.isNull())
| 0 | ||||||||||||||||||||||||
| 1202 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 1203 | - | |||||||||||||||||||||||||
| 1204 | painter->save(); | - | ||||||||||||||||||||||||
| 1205 | painter->setOpacity(d->opacity); | - | ||||||||||||||||||||||||
| 1206 | - | |||||||||||||||||||||||||
| 1207 | if (d->hasOpacityMask) {
| 0 | ||||||||||||||||||||||||
| 1208 | QPainter pixmapPainter(&pixmap); | - | ||||||||||||||||||||||||
| 1209 | pixmapPainter.setRenderHints(painter->renderHints()); | - | ||||||||||||||||||||||||
| 1210 | pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn); | - | ||||||||||||||||||||||||
| 1211 | if (system == Qt::DeviceCoordinates) {
| 0 | ||||||||||||||||||||||||
| 1212 | QTransform worldTransform = painter->worldTransform(); | - | ||||||||||||||||||||||||
| 1213 | worldTransform *= QTransform::fromTranslate(-offset.x(), -offset.y()); | - | ||||||||||||||||||||||||
| 1214 | pixmapPainter.setWorldTransform(worldTransform); | - | ||||||||||||||||||||||||
| 1215 | pixmapPainter.fillRect(sourceBoundingRect(), d->opacityMask); | - | ||||||||||||||||||||||||
| 1216 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1217 | pixmapPainter.translate(-offset); | - | ||||||||||||||||||||||||
| 1218 | pixmapPainter.fillRect(pixmap.rect(), d->opacityMask); | - | ||||||||||||||||||||||||
| 1219 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1220 | } | - | ||||||||||||||||||||||||
| 1221 | - | |||||||||||||||||||||||||
| 1222 | if (system == Qt::DeviceCoordinates)
| 0 | ||||||||||||||||||||||||
| 1223 | painter->setWorldTransform(QTransform()); never executed: painter->setWorldTransform(QTransform()); | 0 | ||||||||||||||||||||||||
| 1224 | - | |||||||||||||||||||||||||
| 1225 | painter->drawPixmap(offset, pixmap); | - | ||||||||||||||||||||||||
| 1226 | painter->restore(); | - | ||||||||||||||||||||||||
| 1227 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1228 | - | |||||||||||||||||||||||||
| 1229 | - | |||||||||||||||||||||||||
| 1230 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| 1231 | - | |||||||||||||||||||||||||
| 1232 | #include "moc_qgraphicseffect.cpp" | - | ||||||||||||||||||||||||
| 1233 | #include "moc_qgraphicseffect_p.cpp" | - | ||||||||||||||||||||||||
| 1234 | - | |||||||||||||||||||||||||
| 1235 | #endif //QT_NO_GRAPHICSEFFECT | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |