diff options
Diffstat (limited to 'src/gui')
80 files changed, 575 insertions, 433 deletions
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index ab02999..5f64698 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -41,56 +41,59 @@ /*! \class QGraphicsEffect - \brief The QGraphicsEffect class is the base class for all graphics effects. + \brief The QGraphicsEffect class is the base class for all graphics + effects. \since 4.6 \ingroup multimedia \ingroup graphicsview-api Effects alter the appearance of elements by hooking into the rendering - pipeline and operating between the source (e.g., a QGraphicsPixmapItem), + pipeline and operating between the source (e.g., a QGraphicsPixmapItem) and the destination device (e.g., QGraphicsView's viewport). Effects can be - disabled by calling setEnabled(); if the effect is disabled, the source is - rendered directly. + disabled by calling setEnabled(false). If effects are disabled, the source + is rendered directly. - If you want to add a visual effect to a e.g. a QGraphicsItem, you can either use - one of the standard effects, or create your own effect by making a subclass - of QGraphicsEffect. The effect can then be installed on the item by calling - QGraphicsItem::setGraphicsEffect. + To add a visual effect to a QGraphicsItem, for example, you can use one of + the standard effects, or alternately, create your own effect by creating a + subclass of QGraphicsEffect. The effect can then be installed on the item + using QGraphicsItem::setGraphicsEffect(). - Qt provides several standard effects, including: + Qt provides the following standard effects: \list - \o QGraphicsGrayScaleEffect - renders the item in shades of gray - \o QGraphicsColorizeEffect - renders the item in shades of any given color - \o QGraphicsPixelizeEffect - pixelizes the item with any pixel size \o QGraphicsBlurEffect - blurs the item by a given radius \o QGraphicsDropShadowEffect - renders a dropshadow behind the item + \o QGraphicsColorizeEffect - renders the item in shades of any given color \o QGraphicsOpacityEffect - renders the item with an opacity - \o QGrahicsShaderEffect - renders the item with a pixel shader fragment + \o QGraphicsPixelizeEffect - pixelizes the item with any pixel size + \o QGraphicsGrayscaleEffect - renders the item in shades of gray + \o QGraphicsShaderEffect - renders the item with a pixel shader fragment \endlist - If all you want is to add an effect to an item, you should visit the - documentation for the specific effect to learn more about how each effect - can be used. - - If you want to create your own custom effect, you can start by creating a - subclass of QGraphicsEffect (or any of the existing effects), and - reimplement the virtual function draw(). This function is called whenever - the effect needs to redraw. draw() has two arguments: the painter, and a - pointer to the source (QGraphicsEffectSource). The source provides extra - context information, such as a pointer to the item that is rendering the - effect, any cached pixmap data, and the device rect bounds. See the draw() - documentation for more details. You can also get a pointer to the current - source by calling source(). - - If your effect changes, you can call update() to request a redraw. If your - custom effect changes the bounding rectangle of the source (e.g., a radial - glow effect may need to apply an extra margin), you can reimplement the + \img graphicseffect-effects.png + \img graphicseffect-widget.png + + For more information on how to use each effect, refer to the specific + effect's documentation. + + To create your own custom effect, create a subclass of QGraphicsEffect (or + any other existing effects) and reimplement the virtual function draw(). + This function is called whenever the effect needs to redraw. The draw() + function accepts two arguments: the painter and a pointer to the source + (QGraphicsEffectSource). The source provides extra context information, + such as a pointer to the item that is rendering the effect, any cached + pixmap data, or the device rectangle bounds. For more information, refer to + the documenation for draw(). To obtain a pointer to the current source, + simply call source(). + + If your effect changes, use update() to request for a redraw. If your + custom effect changes the bounding rectangle of the source, e.g., a radial + glow effect may need to apply an extra margin, you can reimplement the virtual boundingRectFor() function, and call updateBoundingRect() to notify the framework whenever this rectangle changes. The virtual sourceBoundingRectChanged() function is called to notify the effects that - the source's bounding rectangle has changed (e.g., if the source is a - QGraphicsRectItem, then if the rectangle parameters have changed). + the source's bounding rectangle has changed - e.g., if the source is a + QGraphicsRectItem and its rectangle parameters have changed. \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect(), QGraphicsEffectSource @@ -107,33 +110,41 @@ QT_BEGIN_NAMESPACE /*! \class QGraphicsEffectSource - \brief The QGraphicsEffectSource represents the source of which a QGraphicsEffect - is installed on. + \brief The QGraphicsEffectSource class represents the source on which a + QGraphicsEffect is installed on. \since 4.6 - When a QGraphicsEffect is installed on e.g. a QGraphicsItem, this class will act as - a wrapper around QGraphicsItem. E.g. calling update() is effectively the same as - calling QGraphicsItem::update(). + When a QGraphicsEffect is installed on a QGraphicsItem, for example, this + class will act as a wrapper around QGraphicsItem. Then, calling update() is + effectively the same as calling QGraphicsItem::update(). - It also provides a pixmap() function which creates a pixmap with the source - painted into it. + QGraphicsEffectSource also provides a pixmap() function which creates a + pixmap with the source painted into it. - \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect. + \sa QGraphicsItem::setGraphicsEffect(), QWidget::setGraphicsEffect(). +*/ + +/*! + \internal */ QGraphicsEffectSource::QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent) : QObject(dd, parent) {} +/*! + Destroys the effect source. +*/ QGraphicsEffectSource::~QGraphicsEffectSource() {} /*! Returns the bounds of the current painter's device. - This function is useful when you e.g. want to draw something in device coordinates - and want to make sure the size of the pixmap is not bigger than the device's size. + This function is useful when you want to draw something in device + coordinates and ensure the size of the pixmap is not bigger than the size + of the device. - Note that calling QGraphicsEffectSource::pixmap(Qt::DeviceCoordinates) always returns + Calling QGraphicsEffectSource::pixmap(Qt::DeviceCoordinates) always returns a pixmap which is bound to the device's size. \sa pixmap() @@ -144,7 +155,7 @@ QRect QGraphicsEffectSource::deviceRect() const } /*! - Returns the bounding rectangle of the source mapped to the \a system specified. + Returns the bounding rectangle of the source mapped to the given \a system. \sa draw() */ @@ -154,8 +165,8 @@ QRectF QGraphicsEffectSource::boundingRect(Qt::CoordinateSystem system) const } /*! - Returns a pointer to the item if this source is a QGraphicsItem; - otherwise returns 0; + Returns a pointer to the item if this source is a QGraphicsItem; otherwise + returns 0. \sa widget() */ @@ -165,8 +176,8 @@ const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const } /*! - Returns a pointer to the widget if this source is a QWidget; - otherwise returns 0; + Returns a pointer to the widget if this source is a QWidget; otherwise + returns 0. \sa graphicsItem() */ @@ -176,8 +187,8 @@ const QWidget *QGraphicsEffectSource::widget() const } /*! - Returns a pointer to the style options (used when drawing the source) - if available; otherwise returns 0. + Returns a pointer to the style options (used when drawing the source) if + available; otherwise returns 0. \sa graphicsItem(), widget() */ @@ -187,26 +198,27 @@ const QStyleOption *QGraphicsEffectSource::styleOption() const } /*! - Draws the source using the \a painter specified. + Draws the source using the given \a painter. This function should only be called from QGraphicsEffect::draw(). + For example: \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 0 \sa QGraphicsEffect::draw() */ - void QGraphicsEffectSource::draw(QPainter *painter) { d_func()->draw(painter); } /*! - Schedules a redraw of the source. You can call this function whenever the - source needs to be redrawn. + Schedules a redraw of the source. Call this function whenever the source + needs to be redrawn. - \sa QGraphicsEffect::updateBoundingRect(), QWidget::update(), QGraphicsItem::update(), + \sa QGraphicsEffect::updateBoundingRect(), QWidget::update(), + QGraphicsItem::update(), */ void QGraphicsEffectSource::update() { @@ -214,11 +226,12 @@ void QGraphicsEffectSource::update() } /*! - Returns true if the source effectively is a pixmap, e.g. a QGraphicsPixmapItem. + Returns true if the source effectively is a pixmap, e.g., a + QGraphicsPixmapItem. - This function is useful for optimization purposes, e.g. there's no point in - drawing the source in device coordinates to avoid pixmap scaling if this function - returns true; the source pixmap will be scaled anyways. + This function is useful for optimization purposes. For instance, there's no + point in drawing the source in device coordinates to avoid pixmap scaling + if this function returns true - the source pixmap will be scaled anyways. */ bool QGraphicsEffectSource::isPixmap() const { @@ -226,13 +239,14 @@ bool QGraphicsEffectSource::isPixmap() const } /*! - Returns a pixmap with the source painted into it. The \a system specifies which - coordinate system to be used for the source. The optional out parameter - \a offset returns the offset of which the pixmap should be painted - at using the current painter. + Returns a pixmap with the source painted into it. + + The \a system specifies which coordinate system to be used for the source. + The optional \a offset parameter returns the offset where the pixmap should + be painted at using the current painter. - Note that the returned pixmap is bound to the current painter's device - rect when the specified \a system is Qt::DeviceCoordinates. + The returned pixmap is bound to the current painter's device rectangle when + \a system is Qt::DeviceCoordinates. \sa QGraphicsEffect::draw(), boundingRect(), deviceRect() */ @@ -267,9 +281,9 @@ QGraphicsEffect::~QGraphicsEffect() } /*! - Returns the bounding rectangle for this effect (i.e., the bounding + Returns the bounding rectangle for this effect, i.e., the bounding rectangle of the source, adjusted by any margins applied by the effect - itself). + itself. \sa boundingRectFor(), updateBoundingRect() */ @@ -299,13 +313,13 @@ QRectF QGraphicsEffect::boundingRectFor(const QRectF &rect) const \brief whether the effect is enabled or not. If an effect is disabled, the source will be rendered with as normal, with - no interference from the effect. If the effect is enabled (default), the - source will be rendered with the effect applied. + no interference from the effect. If the effect is enabled, the source will + be rendered with the effect applied. - This property is provided so that you can disable certain effects on slow - platforms, in order to ensure that the user interface is responsive. + This property is enabled by default. - \sa enabledChanged() + Using this property, you can disable certain effects on slow platforms, in + order to ensure that the user interface is responsive. */ bool QGraphicsEffect::isEnabled() const { @@ -329,6 +343,7 @@ void QGraphicsEffect::setEnabled(bool enable) \fn void QGraphicsEffect::enabledChanged(bool enabled) This signal is emitted whenever the effect is enabled or disabled. + The \a enabled parameter holds the effects's new enabled state. \sa isEnabled() */ @@ -346,7 +361,7 @@ QGraphicsEffectSource *QGraphicsEffect::source() const } /*! - This function notifies the effect framework that the effect's bounding + This function notifies the effect framework when the effect's bounding rectangle has changed. As a custom effect author, you must call this function whenever you change any parameters that will cause the virtual boundingRectFor() function to return a different value. @@ -364,17 +379,19 @@ void QGraphicsEffect::updateBoundingRect() \fn virtual void QGraphicsEffect::draw(QPainter *painter, QGraphicsEffectSource *source) = 0 - This pure virtual function draws the effect and is called whenever the source() - needs to be drawn. + This pure virtual function draws the effect and is called whenever the + source() needs to be drawn. - Reimplement this function in a QGraphicsEffect subclass to provide the effect's - drawing implementation, using \a painter. The \a source parameter is provided - for convenience; its value is the same as source(). Example: + Reimplement this function in a QGraphicsEffect subclass to provide the + effect's drawing implementation, using \a painter. The \a source parameter + is provided for convenience; its value is the same as source(). + + For example: \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 1 - Note that this function should not be called explicitly by the user, since it's - meant for re-implementation purposes only. + This function should not be called explicitly by the user, since it is + meant for reimplementation purposes only. \sa QGraphicsEffectSource */ @@ -386,7 +403,8 @@ void QGraphicsEffect::updateBoundingRect() \value SourceAttached The effect is installed on a source. \value SourceDetached The effect is uninstalled on a source. - \value SourceBoundingRectChanged The bounding rect of the source has changed. + \value SourceBoundingRectChanged The bounding rect of the source has + changed. \value SourceInvalidated The visual appearance of the source has changed. */ @@ -409,17 +427,31 @@ void QGraphicsEffect::sourceChanged(ChangeFlags flags) A grayscale effect renders the source in shades of gray. - \sa QGraphicsColorizeEffect + \img graphicseffect-grayscale.png + + \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsPixelizeEffect, + QGraphicsColorizeEffect, QGraphicsOpacityEffect +*/ + +/*! + Constructs a new QGraphicsGrayscale instance. + The \a parent parameter is passed to QGraphicsEffect's constructor. */ QGraphicsGrayscaleEffect::QGraphicsGrayscaleEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsGrayscaleEffectPrivate, parent) { } +/*! + Destroys the effect. +*/ QGraphicsGrayscaleEffect::~QGraphicsGrayscaleEffect() { } +/*! + \reimp +*/ void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsGrayscaleEffect); @@ -442,41 +474,48 @@ void QGraphicsGrayscaleEffect::draw(QPainter *painter, QGraphicsEffectSource *so /*! \class QGraphicsColorizeEffect - \brief The QGraphicsColorizeEffect provides a colorize effect. + \brief The QGraphicsColorizeEffect class provides a colorize effect. \since 4.6 - A colorize effect renders the source with a tint of its color(). The - color can be modified using the setColor() function. + A colorize effect renders the source with a tint of its color(). The color + can be modified using the setColor() function. By default, the color is light blue (QColor(0, 0, 192)). - \sa QGraphicsGrayscaleEffect + \img graphicseffect-colorize.png + + \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsPixelizeEffect, + QGraphicsGrayscaleEffect, QGraphicsOpacityEffect +*/ + +/*! + Constructs a new QGraphicsColorizeEffect instance. + The \a parent parameter is passed to QGraphicsEffect's constructor. */ QGraphicsColorizeEffect::QGraphicsColorizeEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsColorizeEffectPrivate, parent) { } +/*! + Destroys the effect. +*/ QGraphicsColorizeEffect::~QGraphicsColorizeEffect() { } /*! - Returns the color. + \property QGraphicsColorizeEffect::color + \brief the color of the effect. - \sa setColor(), colorChanged() -*/ + By default, the color is light blue (QColor(0, 0, 192)). +*/; QColor QGraphicsColorizeEffect::color() const { Q_D(const QGraphicsColorizeEffect); return d->filter->color(); } -/*! - Sets the color to the \a color specified. - - \sa color(), colorChanged() -*/ void QGraphicsColorizeEffect::setColor(const QColor &color) { Q_D(QGraphicsColorizeEffect); @@ -491,8 +530,12 @@ void QGraphicsColorizeEffect::setColor(const QColor &color) \fn void QGraphicsColorizeEffect::colorChanged(const QColor &color) This signal is emitted whenever the effect's color changes. + The \a color parameter holds the effect's new color. */ +/*! + \reimp +*/ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsColorizeEffect); @@ -514,30 +557,45 @@ void QGraphicsColorizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou /*! \class QGraphicsPixelizeEffect - \brief The QGraphicsPixelizeEffect provides a pixelize effect. + \brief The QGraphicsPixelizeEffect class provides a pixelize effect. \since 4.6 - A pixelize effect renders the source in lower resolution. This effect - is useful for reducing details, in e.g. a censorship. The resolution - can be modified using the setPixelSize() function. + A pixelize effect renders the source in lower resolution. This effect is + useful for reducing details, like censorship. The resolution can be + modified using the setPixelSize() function. By default, the pixel size is 3. - \sa QGraphicsBlurEffect + \img graphicseffect-pixelize.png + + \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsGrayscaleEffect, + QGraphicsColorizeEffect, QGraphicsOpacityEffect +*/ + +/*! + Constructs a new QGraphicsPixelizeEffect instance. + The \a parent parameter is passed to QGraphicsEffect's constructor. */ QGraphicsPixelizeEffect::QGraphicsPixelizeEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsPixelizeEffectPrivate, parent) { } +/*! + Destroys the effect. +*/ QGraphicsPixelizeEffect::~QGraphicsPixelizeEffect() { } /*! - Returns the size of a pixel. + \property QGraphicsPixelizeEffect::pixelSize + \brief the size of a pixel in the effect. - \sa setPixelSize(), pixelSizeChanged() + Setting the pixel size to 2 means two pixels in the source will be used to + represent one pixel. Using a bigger size results in lower resolution. + + By default, the pixel size is 3. */ int QGraphicsPixelizeEffect::pixelSize() const { @@ -545,15 +603,6 @@ int QGraphicsPixelizeEffect::pixelSize() const return d->pixelSize; } -/*! - Sets the size of a pixel to the \a size specified. - - Setting the \a size to e.g. 2 means two pixels in the source will - be used to represent one pixel. Using a bigger size results in - lower resolution. - - \sa pixelSize(), pixelSizeChanged() -*/ void QGraphicsPixelizeEffect::setPixelSize(int size) { Q_D(QGraphicsPixelizeEffect); @@ -568,6 +617,7 @@ void QGraphicsPixelizeEffect::setPixelSize(int size) \fn void QGraphicsPixelizeEffect::pixelSizeChanged(int size) This signal is emitted whenever the effect's pixel size changes. + The \a size parameter holds the effect's new pixel size. */ static inline void pixelize(QImage *image, int pixelSize) @@ -591,6 +641,9 @@ static inline void pixelize(QImage *image, int pixelSize) } } +/*! + \reimp +*/ void QGraphicsPixelizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsPixelizeEffect); @@ -623,31 +676,46 @@ void QGraphicsPixelizeEffect::draw(QPainter *painter, QGraphicsEffectSource *sou /*! \class QGraphicsBlurEffect - \brief The QGraphicsBlurEffect provides a blur effect. + \brief The QGraphicsBlurEffect class provides a blur effect. \since 4.6 A blur effect blurs the source. This effect is useful for reducing details, - e.g. when the source loses focus and you want to draw attention to other + 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. By default, the blur radius is 5 pixels. - \sa QGraphicsPixelizeEffect + \img graphicseffect-blur.png + + \sa QGraphicsDropShadowEffect, QGraphicsPixelizeEffect, QGraphicsGrayscaleEffect, + QGraphicsColorizeEffect, QGraphicsOpacityEffect +*/ + +/*! + Constructs a new QGraphicsBlurEffect instance. + The \a parent parameter is passed to QGraphicsEffect's constructor. */ QGraphicsBlurEffect::QGraphicsBlurEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsBlurEffectPrivate, parent) { } +/*! + Destroys the effect. +*/ QGraphicsBlurEffect::~QGraphicsBlurEffect() { } /*! - Returns the blur radius. + \property QGraphicsBlurEffect::blurRadius + \brief the blur radius of the effect. + + Using a smaller radius results in a sharper appearance, whereas a bigger + radius results in a more blurred appearance. - \sa setBlurRadius(), blurRadiusChanged() + By default, the blur radius is 5 pixels. */ int QGraphicsBlurEffect::blurRadius() const { @@ -655,14 +723,6 @@ int QGraphicsBlurEffect::blurRadius() const return d->filter->radius(); } -/*! - Sets the blur radius to the \a radius specified. - - Using a smaller radius results in a sharper appearance, whereas a - bigger radius results in a more blurry appearance. - - \sa blurRadius(), blurRadiusChanged() -*/ void QGraphicsBlurEffect::setBlurRadius(int radius) { Q_D(QGraphicsBlurEffect); @@ -678,14 +738,21 @@ void QGraphicsBlurEffect::setBlurRadius(int radius) \fn void QGraphicsBlurEffect::blurRadiusChanged(int radius) This signal is emitted whenever the effect's blur radius changes. + The \a radius parameter holds the effect's new blur radius. */ +/*! + \reimp +*/ QRectF QGraphicsBlurEffect::boundingRectFor(const QRectF &rect) const { Q_D(const QGraphicsBlurEffect); return d->filter->boundingRectFor(rect); } +/*! + \reimp +*/ void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsBlurEffect); @@ -716,28 +783,44 @@ void QGraphicsBlurEffect::draw(QPainter *painter, QGraphicsEffectSource *source) \since 4.6 A drop shadow effect renders the source with a drop shadow. The color of - the drop shadow can be modified using the setColor() function, the drop - shadow offset can be modified using the setOffset function, and the blur - radius of the drop shadow can be changed through the setBlurRadius() + the drop shadow can be modified using the setColor() function. The drop + shadow offset can be modified using the setOffset() function and the blur + radius of the drop shadow can be changed with the setBlurRadius() function. By default, the drop shadow is a semi-transparent dark gray - (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an - offset of 8 pixels towards the lower right. + (QColor(63, 63, 63, 180)) shadow, blurred with a radius of 1 at an offset + of 8 pixels towards the lower right. + + \img graphicseffect-drop-shadow.png + + \sa QGraphicsBlurEffect, QGraphicsPixelizeEffect, QGraphicsGrayscaleEffect, + QGraphicsColorizeEffect, QGraphicsOpacityEffect +*/ + +/*! + Constructs a new QGraphicsDropShadowEffect instance. + The \a parent parameter is passed to QGraphicsEffect's constructor. */ QGraphicsDropShadowEffect::QGraphicsDropShadowEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsDropShadowEffectPrivate, parent) { } +/*! + Destroys the effect. +*/ QGraphicsDropShadowEffect::~QGraphicsDropShadowEffect() { } /*! - Returns the shadow offset in pixels. + \property QGraphicsDropShadowEffect::offset + \brief the shadow offset in pixels. - \sa setOffset(), blurRadius(), color(), offsetChanged() + By default, the offset is 8 pixels towards the lower right. + + \sa blurRadius(), color() */ QPointF QGraphicsDropShadowEffect::offset() const { @@ -745,11 +828,6 @@ QPointF QGraphicsDropShadowEffect::offset() const return d->filter->offset(); } -/*! - Sets the shadow offset in pixels to the \a offset specified. - - \sa offset(), setBlurRadius(), setColor(), offsetChanged() -*/ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) { Q_D(QGraphicsDropShadowEffect); @@ -762,15 +840,22 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &offset) } /*! - \fn void QGraphicsDropShadowEffect::offsetChanged(const QPoint &offset) + \fn void QGraphicsDropShadowEffect::offsetChanged(const QPointF &offset) This signal is emitted whenever the effect's shadow offset changes. + The \a offset parameter holds the effect's new shadow offset. */ /*! - Returns the radius in pixels of the blur on the drop shadow. + \property QGraphicsDropShadowEffect::blurRadius + \brief the blur radius in pixels of the drop shadow. + + Using a smaller radius results in a sharper shadow, whereas using a bigger + radius results in a more blurred shadow. + + By default, the blur radius is 1 pixel. - \sa setBlurRadius(), color(), offset(), blurRadiusChanged() + \sa color(), offset(). */ int QGraphicsDropShadowEffect::blurRadius() const { @@ -778,15 +863,6 @@ int QGraphicsDropShadowEffect::blurRadius() const return d->filter->blurRadius(); } -/*! - Sets the radius in pixels of the blur on the drop shadow to the - \a blurRadius specified. - - Using a smaller radius results in a sharper shadow, whereas using - a bigger radius results in a more blurry shadow. - - \sa blurRadius(), setColor(), setOffset(), blurRadiusChanged() -*/ void QGraphicsDropShadowEffect::setBlurRadius(int blurRadius) { Q_D(QGraphicsDropShadowEffect); @@ -802,12 +878,17 @@ void QGraphicsDropShadowEffect::setBlurRadius(int blurRadius) \fn void QGraphicsDropShadowEffect::blurRadiusChanged(int blurRadius) This signal is emitted whenever the effect's blur radius changes. + The \a blurRadius parameter holds the effect's new blur radius. */ /*! - Returns the color of the drop shadow. + \property QGraphicsDropShadowEffect::color + \brief the color of the drop shadow. - \sa setColor, offset(), blurRadius(), colorChanged() + By default, the drop color is a semi-transparent dark gray + (QColor(63, 63, 63, 180)). + + \sa offset(), blurRadius() */ QColor QGraphicsDropShadowEffect::color() const { @@ -815,11 +896,6 @@ QColor QGraphicsDropShadowEffect::color() const return d->filter->color(); } -/*! - Sets the color of the drop shadow to the \a color specified. - - \sa color(), setOffset(), setBlurRadius(), colorChanged() -*/ void QGraphicsDropShadowEffect::setColor(const QColor &color) { Q_D(QGraphicsDropShadowEffect); @@ -834,14 +910,21 @@ void QGraphicsDropShadowEffect::setColor(const QColor &color) \fn void QGraphicsDropShadowEffect::colorChanged(const QColor &color) This signal is emitted whenever the effect's color changes. + The \a color parameter holds the effect's new color. */ +/*! + \reimp +*/ QRectF QGraphicsDropShadowEffect::boundingRectFor(const QRectF &rect) const { Q_D(const QGraphicsDropShadowEffect); return d->filter->boundingRectFor(rect); } +/*! + \reimp +*/ void QGraphicsDropShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsDropShadowEffect); @@ -871,25 +954,42 @@ void QGraphicsDropShadowEffect::draw(QPainter *painter, QGraphicsEffectSource *s \brief The QGraphicsOpacityEffect class provides an opacity effect. \since 4.6 - An opacity effects renders the source with an opacity. This effect is useful - for making the source semi-transparent, in e.g. a fade-in/fade-out sequence. - The opacity can be modified using the setOpacity() function. + An opacity effect renders the source with an opacity. This effect is useful + for making the source semi-transparent, similar to a fade-in/fade-out + sequence. The opacity can be modified using the setOpacity() function. By default, the opacity is 0.7. + + \img graphicseffect-opacity.png + + \sa QGraphicsDropShadowEffect, QGraphicsBlurEffect, QGraphicsPixelizeEffect, + QGraphicsGrayscaleEffect, QGraphicsColorizeEffect +*/ + +/*! + Constructs a new QGraphicsOpacityEffect instance. + The \a parent parameter is passed to QGraphicsEffect's constructor. */ QGraphicsOpacityEffect::QGraphicsOpacityEffect(QObject *parent) : QGraphicsEffect(*new QGraphicsOpacityEffectPrivate, parent) { } +/*! + Destroys the effect. +*/ QGraphicsOpacityEffect::~QGraphicsOpacityEffect() { } /*! - Returns the opacity. + \property QGraphicsOpacityEffect::opacity + \brief the opacity of the effect. + + The value should be in the range of 0.0 to 1.0, where 0.0 is + fully transparent and 1.0 is fully opaque. - \sa setOpacity(), opacityChanged() + By default, the opacity is 0.7. */ qreal QGraphicsOpacityEffect::opacity() const { @@ -897,13 +997,6 @@ qreal QGraphicsOpacityEffect::opacity() const return d->opacity; } -/*! - Sets the opacity to the \a opacity specified. The value should be in - the range 0.0 to 1.0, where 0.0 is fully transparent and 1.0 is - fully opaque. - - \sa opacity(), opacityChanged() -*/ void QGraphicsOpacityEffect::setOpacity(qreal opacity) { Q_D(QGraphicsOpacityEffect); @@ -920,8 +1013,12 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity) \fn void QGraphicsOpacityEffect::opacityChanged(qreal opacity) This signal is emitted whenever the effect's opacity changes. + The \a opacity parameter holds the effect's new opacity. */ +/*! + \reimp +*/ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source) { Q_D(QGraphicsOpacityEffect); diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index 56bdef7..fef6531 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -80,8 +80,8 @@ protected: QGraphicsEffectSource(QGraphicsEffectSourcePrivate &dd, QObject *parent = 0); private: - Q_DECLARE_PRIVATE(QGraphicsEffectSource); - Q_DISABLE_COPY(QGraphicsEffectSource); + Q_DECLARE_PRIVATE(QGraphicsEffectSource) + Q_DISABLE_COPY(QGraphicsEffectSource) friend class QGraphicsEffect; friend class QGraphicsEffectPrivate; friend class QGraphicsScenePrivate; @@ -103,7 +103,7 @@ public: SourceBoundingRectChanged = 0x4, SourceInvalidated = 0x8 }; - Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag); + Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) QGraphicsEffect(QObject *parent = 0); virtual ~QGraphicsEffect(); @@ -137,7 +137,7 @@ private: friend class QWidget; friend class QWidgetPrivate; }; -Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags); +Q_DECLARE_OPERATORS_FOR_FLAGS(QGraphicsEffect::ChangeFlags) class QGraphicsGrayscaleEffectPrivate; class Q_GUI_EXPORT QGraphicsGrayscaleEffect: public QGraphicsEffect diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index 175bd99..6ce5cda 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -164,7 +164,7 @@ class QGraphicsOpacityEffectPrivate : public QGraphicsEffectPrivate { Q_DECLARE_PUBLIC(QGraphicsOpacityEffect) public: - QGraphicsOpacityEffectPrivate() : opacity(0.7) {} + QGraphicsOpacityEffectPrivate() : opacity(qreal(0.7)) {} ~QGraphicsOpacityEffectPrivate() {} qreal opacity; diff --git a/src/gui/embedded/qkbd_defaultmap_qws_p.h b/src/gui/embedded/qkbd_defaultmap_qws_p.h index 2903492..a6c2d25 100644 --- a/src/gui/embedded/qkbd_defaultmap_qws_p.h +++ b/src/gui/embedded/qkbd_defaultmap_qws_p.h @@ -53,6 +53,8 @@ // We mean it. // +// no QT_BEGIN_NAMESPACE, since we include it internally... + const QWSKeyboard::Mapping QWSKbPrivate::s_keymap_default[] = { { 1, 0xffff, 0x01000000, 0x00, 0x00, 0x0000 }, { 2, 0x0031, 0x00000031, 0x00, 0x00, 0x0000 }, diff --git a/src/gui/embedded/qkbd_qws_p.h b/src/gui/embedded/qkbd_qws_p.h index df7ce1b..5af8f7c 100644 --- a/src/gui/embedded/qkbd_qws_p.h +++ b/src/gui/embedded/qkbd_qws_p.h @@ -55,6 +55,8 @@ #include <QDataStream> +QT_BEGIN_NAMESPACE + namespace QWSKeyboard { const quint32 FileMagic = 0x514d4150; // 'QMAP' @@ -127,4 +129,6 @@ inline QDataStream &operator<<(QDataStream &ds, const QWSKeyboard::Composing &c) } #endif // QT_NO_DATASTREAM +QT_END_NAMESPACE + #endif // QWSKEYBOARD_H diff --git a/src/gui/embedded/qkbdqnx_qws.cpp b/src/gui/embedded/qkbdqnx_qws.cpp index 4f0b9de..6e147dd 100644 --- a/src/gui/embedded/qkbdqnx_qws.cpp +++ b/src/gui/embedded/qkbdqnx_qws.cpp @@ -49,6 +49,9 @@ #include "qplatformdefs.h" #include <errno.h> + +QT_BEGIN_NAMESPACE + /*! \class QWSQnxKeyboardHandler \preliminary @@ -229,3 +232,5 @@ void QWSQnxKeyboardHandler::socketActivated() // (on QNX, isPress is not set when the key event is repeated). processKeyEvent(unicode, key, modifiers, isPress || isRepeat, isRepeat); } + +QT_END_NAMESPACE diff --git a/src/gui/embedded/qlock.cpp b/src/gui/embedded/qlock.cpp index c32e9b5..9f2d3b8 100644 --- a/src/gui/embedded/qlock.cpp +++ b/src/gui/embedded/qlock.cpp @@ -41,10 +41,11 @@ #include "qlock_p.h" -QT_BEGIN_NAMESPACE #ifdef QT_NO_QWS_MULTIPROCESS +QT_BEGIN_NAMESPACE + /* no multiprocess - use a dummy */ QLock::QLock(const QString & /*filename*/, char /*id*/, bool /*create*/) @@ -77,6 +78,8 @@ bool QLock::locked() const return data; } +QT_END_NAMESPACE + #else // QT_NO_QWS_MULTIPROCESS #include "qwssignalhandler_p.h" @@ -110,6 +113,9 @@ union semun { #include <private/qcore_unix_p.h> // overrides QT_OPEN + +QT_BEGIN_NAMESPACE + #define MAX_LOCKS 200 // maximum simultaneous read locks class QLockData @@ -324,6 +330,7 @@ bool QLock::locked() const return (data->count > 0); } +QT_END_NAMESPACE + #endif // QT_NO_QWS_MULTIPROCESS -QT_END_NAMESPACE diff --git a/src/gui/embedded/qmousetslib_qws.h b/src/gui/embedded/qmousetslib_qws.h index 4dd39b5..71672f0 100644 --- a/src/gui/embedded/qmousetslib_qws.h +++ b/src/gui/embedded/qmousetslib_qws.h @@ -73,8 +73,8 @@ protected: }; -QT_END_NAMESPACE #endif // QT_NO_QWS_MOUSE_TSLIB +QT_END_NAMESPACE QT_END_HEADER #endif // QMOUSETSLIB_QWS_H diff --git a/src/gui/embedded/qscreen_qws.h b/src/gui/embedded/qscreen_qws.h index 275e83f..307c2fd 100644 --- a/src/gui/embedded/qscreen_qws.h +++ b/src/gui/embedded/qscreen_qws.h @@ -50,6 +50,8 @@ #include <QtGui/qimage.h> #include <QtGui/qregion.h> +struct fb_cmap; + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -169,8 +171,6 @@ private: #endif // QT_NO_QWS_CURSOR -struct fb_cmap; - // A (used) chunk of offscreen memory class QPoolEntry diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp index 69e5808..1679ef2 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.cpp +++ b/src/gui/embedded/qscreenlinuxfb_qws.cpp @@ -291,8 +291,8 @@ bool QLinuxFbScreen::connect(const QString &displaySpec) d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY); } - fb_fix_screeninfo finfo; - fb_var_screeninfo vinfo; + ::fb_fix_screeninfo finfo; + ::fb_var_screeninfo vinfo; //####################### // Shut up Valgrind memset(&vinfo, 0, sizeof(vinfo)); @@ -429,7 +429,7 @@ bool QLinuxFbScreen::connect(const QString &displaySpec) if((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4)) { screencols= (vinfo.bits_per_pixel==8) ? 256 : 16; int loopc; - fb_cmap startcmap; + ::fb_cmap startcmap; startcmap.start=0; startcmap.len=screencols; startcmap.red=(unsigned short int *) diff --git a/src/gui/embedded/qscreenlinuxfb_qws.h b/src/gui/embedded/qscreenlinuxfb_qws.h index eb47848..e3c712a 100644 --- a/src/gui/embedded/qscreenlinuxfb_qws.h +++ b/src/gui/embedded/qscreenlinuxfb_qws.h @@ -44,6 +44,11 @@ #include <QtGui/qscreen_qws.h> +struct fb_cmap; +struct fb_var_screeninfo; +struct fb_fix_screeninfo; + + QT_BEGIN_HEADER QT_BEGIN_NAMESPACE @@ -70,9 +75,6 @@ public: }; -struct fb_cmap; -struct fb_var_screeninfo; -struct fb_fix_screeninfo; class QLinuxFbScreenPrivate; class Q_GUI_EXPORT QLinuxFbScreen : public QScreen diff --git a/src/gui/embedded/qscreenproxy_qws.cpp b/src/gui/embedded/qscreenproxy_qws.cpp index b566dc0..b87fdd1 100644 --- a/src/gui/embedded/qscreenproxy_qws.cpp +++ b/src/gui/embedded/qscreenproxy_qws.cpp @@ -45,6 +45,7 @@ #include <qregexp.h> +QT_BEGIN_NAMESPACE #ifndef QT_NO_QWS_CURSOR /*! @@ -629,4 +630,6 @@ QRegion QProxyScreen::region() const return QScreen::region(); } +QT_END_NAMESPACE + #endif // QT_NO_QWS_PROXYSCREEN diff --git a/src/gui/embedded/qscreenqnx_qws.cpp b/src/gui/embedded/qscreenqnx_qws.cpp index 70f6d6b..77fe13e 100644 --- a/src/gui/embedded/qscreenqnx_qws.cpp +++ b/src/gui/embedded/qscreenqnx_qws.cpp @@ -44,6 +44,8 @@ #include <gf/gf.h> +QT_BEGIN_NAMESPACE + // This struct holds all the pointers to QNX's internals struct QQnxScreenContext { @@ -445,3 +447,4 @@ void QQnxScreen::exposeRegion(QRegion r, int changing) gf_draw_end(d->context); } +QT_END_NAMESPACE diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp index 2f5f39a..811943a 100644 --- a/src/gui/embedded/qsoundqss_qws.cpp +++ b/src/gui/embedded/qsoundqss_qws.cpp @@ -67,10 +67,10 @@ #include <qdebug.h> -QT_BEGIN_NAMESPACE - extern int errno; +QT_BEGIN_NAMESPACE + #define QT_QWS_SOUND_16BIT 1 // or 0, or undefined for always 0 #define QT_QWS_SOUND_STEREO 1 // or 0, or undefined for always 0 diff --git a/src/gui/embedded/qwsutils_qws.h b/src/gui/embedded/qwsutils_qws.h index 23e0104..fe959ef 100644 --- a/src/gui/embedded/qwsutils_qws.h +++ b/src/gui/embedded/qwsutils_qws.h @@ -44,6 +44,12 @@ #include <QtCore/QIODevice> +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + #ifndef QT_NO_SXE #define QWS_SOCK_BASE QUnixSocket #define QWS_SOCK_SERVER_BASE QUnixSocketServer @@ -58,12 +64,6 @@ class QTcpServer; class QWSSocket; class QWSServerSocket; -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - /******************************************************************** * * Convenient socket functions diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index 2894c59..b088f12 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -65,8 +65,9 @@ automatically added to the layout, and if items are removed, all their anchors will be automatically removed - \section1 Size Hints and Size Policies in QGraphicsLinearLayout - QGraphicsLinearLayout respects each item's size hints and size policies. However it does + \section1 Size Hints and Size Policies in QGraphicsAnchorLayout + + QGraphicsAnchorLayout respects each item's size hints and size policies. However it does not respect stretch factors currently. This might change in the future, so please refrain from using stretch factors in anchor layout to avoid any future regressions. @@ -228,6 +229,7 @@ void QGraphicsAnchorLayout::setAnchorSpacing(const QGraphicsLayoutItem *firstIte if (!d->setAnchorSize(firstItem, firstEdge, secondItem, secondEdge, &spacing)) { qWarning("setAnchorSpacing: The anchor does not exist."); + return; } invalidate(); } diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 11f6f53..bf5d832 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicslayout_p.h b/src/gui/graphicsview/qgraphicslayout_p.h index 2ad853b..0e43b55 100644 --- a/src/gui/graphicsview/qgraphicslayout_p.h +++ b/src/gui/graphicsview/qgraphicslayout_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicslayoutitem_p.h b/src/gui/graphicsview/qgraphicslayoutitem_p.h index 5bda3ca..4d9a8c9 100644 --- a/src/gui/graphicsview/qgraphicslayoutitem_p.h +++ b/src/gui/graphicsview/qgraphicslayoutitem_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicsproxywidget_p.h b/src/gui/graphicsview/qgraphicsproxywidget_p.h index e2be89c..04fe40a 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget_p.h +++ b/src/gui/graphicsview/qgraphicsproxywidget_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 4b8791e..ffef1c7 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index 27c499d..5cc8449 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -44,8 +44,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicssceneindex_p.h b/src/gui/graphicsview/qgraphicssceneindex_p.h index d922036..00e5f89 100644 --- a/src/gui/graphicsview/qgraphicssceneindex_p.h +++ b/src/gui/graphicsview/qgraphicssceneindex_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicstransform_p.h b/src/gui/graphicsview/qgraphicstransform_p.h index 2c563e4..c9b95fd 100644 --- a/src/gui/graphicsview/qgraphicstransform_p.h +++ b/src/gui/graphicsview/qgraphicstransform_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicsview_p.h b/src/gui/graphicsview/qgraphicsview_p.h index bdf5ddd..a40dfdc 100644 --- a/src/gui/graphicsview/qgraphicsview_p.h +++ b/src/gui/graphicsview/qgraphicsview_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h index 0e1fe46..1ee79e1 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.h +++ b/src/gui/graphicsview/qgraphicswidget_p.h @@ -47,8 +47,8 @@ // ------------- // // This file is not part of the Qt API. It exists for the convenience -// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header -// file may change from version to version without notice, or even be removed. +// of other Qt classes. This header file may change from version to +// version without notice, or even be removed. // // We mean it. // diff --git a/src/gui/graphicsview/qsimplex_p.cpp b/src/gui/graphicsview/qsimplex_p.cpp index dbd8d4f..30a7d5d 100644 --- a/src/gui/graphicsview/qsimplex_p.cpp +++ b/src/gui/graphicsview/qsimplex_p.cpp @@ -293,7 +293,7 @@ int QSimplex::findPivotColumn() int QSimplex::pivotRowForColumn(int column) { - qreal min = 999999999999.0; // ### + qreal min = qreal(999999999999.0); // ### int minIndex = -1; for (int i = 1; i < rows; ++i) { diff --git a/src/gui/image/qpixmap_qws.cpp b/src/gui/image/qpixmap_qws.cpp index e549900..a6c70a7 100644 --- a/src/gui/image/qpixmap_qws.cpp +++ b/src/gui/image/qpixmap_qws.cpp @@ -48,6 +48,9 @@ #include <private/qdrawhelper_p.h> #include <private/qpixmap_raster_p.h> + +QT_BEGIN_NAMESPACE + QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h) { QWidget *widget = QWidget::find(window); @@ -148,3 +151,5 @@ int QPixmap::qwsBytesPerLine() const return 0; } + +QT_END_NAMESPACE diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 7c7bce3..09eda67 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -44,6 +44,7 @@ #include "qcoefepinputcontext_p.h" #include <qapplication.h> #include <qtextformat.h> +#include <private/qcore_symbian_p.h> #include <fepitfr.h> @@ -139,100 +140,14 @@ void QCoeFepInputContext::widgetDestroyed(QWidget *w) } } -/*! - Definition of struct for mapping Symbian to ISO locale - ### REMOVE - See below. -*/ -struct symbianToISO { - int symbian_language; - char iso_name[8]; -}; - -/*! - Mapping from Symbian to ISO locale - ### REMOVE - This was taken from the preliminary QLocale port to S60, and should be - removed once that is finished. -*/ -static const symbianToISO symbian_to_iso_list[] = { - { ELangEnglish, "en_GB" }, - { ELangFrench, "fr_FR" }, - { ELangGerman, "de_DE" }, - { ELangSpanish, "es_ES" }, - { ELangItalian, "it_IT" }, - { ELangSwedish, "sv_SE" }, - { ELangDanish, "da_DK" }, - { ELangNorwegian, "no_NO" }, - { ELangFinnish, "fi_FI" }, - { ELangAmerican, "en_US" }, - { ELangPortuguese, "pt_PT" }, - { ELangTurkish, "tr_TR" }, - { ELangIcelandic, "is_IS" }, - { ELangRussian, "ru_RU" }, - { ELangHungarian, "hu_HU" }, - { ELangDutch, "nl_NL" }, - { ELangBelgianFlemish, "nl_BE" }, - { ELangCzech, "cs_CZ" }, - { ELangSlovak, "sk_SK" }, - { ELangPolish, "pl_PL" }, - { ELangSlovenian, "sl_SI" }, - { ELangTaiwanChinese, "zh_TW" }, - { ELangHongKongChinese, "zh_HK" }, - { ELangPrcChinese, "zh_CN" }, - { ELangJapanese, "ja_JP" }, - { ELangThai, "th_TH" }, - { ELangArabic, "ar_AE" }, - { ELangTagalog, "tl_PH" }, - { ELangBulgarian, "bg_BG" }, - { ELangCatalan, "ca_ES" }, - { ELangCroatian, "hr_HR" }, - { ELangEstonian, "et_EE" }, - { ELangFarsi, "fa_IR" }, - { ELangCanadianFrench, "fr_CA" }, - { ELangGreek, "el_GR" }, - { ELangHebrew, "he_IL" }, - { ELangHindi, "hi_IN" }, - { ELangIndonesian, "id_ID" }, - { ELangLatvian, "lv_LV" }, - { ELangLithuanian, "lt_LT" }, - { ELangMalay, "ms_MY" }, - { ELangBrazilianPortuguese, "pt_BR" }, - { ELangRomanian, "ro_RO" }, - { ELangSerbian, "sr_YU" }, - { ELangLatinAmericanSpanish, "es" }, - { ELangUkrainian, "uk_UA" }, - { ELangUrdu, "ur_PK" }, // India/Pakistan - { ELangVietnamese, "vi_VN" }, -#ifdef __E32LANG_H__ -// 5.0 - { ELangBasque, "eu_ES" }, - { ELangGalician, "gl_ES" }, -#endif - //{ ELangEnglish_Apac, "en" }, - //{ ELangEnglish_Taiwan, "en_TW" }, - //{ ELangEnglish_HongKong, "en_HK" }, - //{ ELangEnglish_Prc, "en_CN" }, - //{ ELangEnglish_Japan, "en_JP"}, - //{ ELangEnglish_Thailand, "en_TH" }, - //{ ELangMalay_Apac, "ms" } -}; - -/*! - Number of Symbian to ISO locale mappings - ### Remove. - See comment for array above. -*/ -static const int symbian_to_iso_count - = sizeof(symbian_to_iso_list)/sizeof(symbianToISO); - QString QCoeFepInputContext::language() { TLanguage lang = m_fepState->LocalLanguage(); - if (lang < symbian_to_iso_count) { - return QLatin1String(symbian_to_iso_list[lang].iso_name); + const QByteArray localeName = qt_symbianLocaleName(lang); + if (!localeName.isEmpty()) { + return QString::fromLatin1(localeName); } else { - return QLatin1String("C"); + return QString::fromLatin1("C"); } } diff --git a/src/gui/inputmethod/qwsinputcontext_qws.cpp b/src/gui/inputmethod/qwsinputcontext_qws.cpp index 5d92e1c..371ff1d 100644 --- a/src/gui/inputmethod/qwsinputcontext_qws.cpp +++ b/src/gui/inputmethod/qwsinputcontext_qws.cpp @@ -111,8 +111,8 @@ void QWSInputContext::setFocusWidget( QWidget *w ) void QWSInputContext::widgetDestroyed(QWidget *w) { - if (w == ::activeWidget) - ::activeWidget = 0; + if (w == QT_PREPEND_NAMESPACE(activeWidget)) + QT_PREPEND_NAMESPACE(activeWidget) = 0; QInputContext::widgetDestroyed(w); } @@ -138,13 +138,13 @@ void QWSInputContext::mouseHandler( int x, QMouseEvent *event) QWidget *QWSInputContext::activeWidget() { - return ::activeWidget; + return QT_PREPEND_NAMESPACE(activeWidget); } bool QWSInputContext::isComposing() const { - return ::activeWidget != 0; + return QT_PREPEND_NAMESPACE(activeWidget) != 0; } bool QWSInputContext::translateIMQueryEvent(QWidget *w, const QWSIMQueryEvent *e) @@ -182,8 +182,8 @@ bool QWSInputContext::translateIMEvent(QWidget *w, const QWSIMEvent *e) stream >> preedit; stream >> commit; - if (preedit.isEmpty() && ::activeWidget) - w = ::activeWidget; + if (preedit.isEmpty() && QT_PREPEND_NAMESPACE(activeWidget)) + w = QT_PREPEND_NAMESPACE(activeWidget); QInputContext *qic = w->inputContext(); if (!qic) @@ -213,9 +213,9 @@ bool QWSInputContext::translateIMEvent(QWidget *w, const QWSIMEvent *e) #endif if (preedit.isEmpty()) - ::activeWidget = 0; + QT_PREPEND_NAMESPACE(activeWidget) = 0; else - ::activeWidget = w; + QT_PREPEND_NAMESPACE(activeWidget) = w; QInputMethodEvent ime(preedit, attrs); diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index bca5df7..ccc57d7 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -1661,9 +1661,6 @@ void QAbstractItemView::mouseReleaseEvent(QMouseEvent *event) EditTrigger trigger = (selectedClicked ? SelectedClicked : NoEditTriggers); bool edited = edit(index, trigger, event); - if (d->selectionModel) - d->selectionModel->select(index, selectionCommand(index, event)); - setState(NoState); if (click) { diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index 8414460..8eb9e21 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -734,14 +734,15 @@ void QItemSelectionModelPrivate::_q_layoutAboutToBeChanged() if (ranges.isEmpty() && currentSelection.count() == 1) { QItemSelectionRange range = currentSelection.first(); QModelIndex parent = range.parent(); - if (range.top() == 0 + tableRowCount = model->rowCount(parent); + tableColCount = model->columnCount(parent); + if (tableRowCount * tableColCount > 100 + && range.top() == 0 && range.left() == 0 - && range.bottom() == model->rowCount(parent) - 1 - && range.right() == model->columnCount(parent) - 1) { + && range.bottom() == tableRowCount - 1 + && range.right() == tableColCount - 1) { tableSelected = true; tableParent = parent; - tableColCount = model->columnCount(parent); - tableRowCount = model->rowCount(parent); return; } } diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 3e9db3b..de2f493 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1715,8 +1715,7 @@ QRect QListViewPrivate::mapToViewport(const QRect &rect, bool extend) const QRect result = extend ? commonListView->mapToViewport(rect) : rect; int dx = -q->horizontalOffset(); int dy = -q->verticalOffset(); - result.adjust(dx, dy, dx, dy); - return result; + return result.adjusted(dx, dy, dx, dy); } QModelIndex QListViewPrivate::closestIndex(const QRect &target, @@ -2287,15 +2286,14 @@ QRect QListModeViewBase::mapToViewport(const QRect &rect) const if (isWrapping()) return rect; // If the listview is in "listbox-mode", the items are as wide as the view. + // But we don't shrink the items. QRect result = rect; - QSize vsize = viewport()->size(); - QSize csize = contentsSize; if (flow() == QListView::TopToBottom) { result.setLeft(spacing()); - result.setWidth(qMax(csize.width(), vsize.width()) - 2 * spacing()); + result.setWidth(qMax(rect.width(), qMax(contentsSize.width(), viewport()->width()) - 2 * spacing())); } else { // LeftToRight result.setTop(spacing()); - result.setHeight(qMax(csize.height(), vsize.height()) - 2 * spacing()); + result.setHeight(qMax(rect.height(), qMax(contentsSize.height(), viewport()->height()) - 2 * spacing())); } return result; } diff --git a/src/gui/itemviews/qtablewidget.cpp b/src/gui/itemviews/qtablewidget.cpp index d44c11c..b7c9703 100644 --- a/src/gui/itemviews/qtablewidget.cpp +++ b/src/gui/itemviews/qtablewidget.cpp @@ -226,6 +226,8 @@ QTableWidgetItem *QTableModel::takeItem(int row, int column) itm->view = 0; itm->d->id = -1; tableItems[i] = 0; + QModelIndex ind = index(itm); + emit dataChanged(ind, ind); } return itm; } diff --git a/src/gui/kernel/qapplication_qws.cpp b/src/gui/kernel/qapplication_qws.cpp index f7a7ab0..5340ae9 100644 --- a/src/gui/kernel/qapplication_qws.cpp +++ b/src/gui/kernel/qapplication_qws.cpp @@ -72,6 +72,7 @@ //#include "qwsregionmanager_qws.h" #include "qwindowsystem_qws.h" #include "private/qwindowsystem_p.h" +#include "qdecorationfactory_qws.h" #include "qwsdisplay_qws.h" #include "private/qwsdisplay_qws_p.h" @@ -122,6 +123,8 @@ #endif #endif +QT_BEGIN_NAMESPACE + #ifndef QT_NO_DIRECTPAINTER class QDirectPainter; extern void qt_directpainter_region(QDirectPainter *dp, const QRegion &alloc, int type); @@ -161,13 +164,9 @@ int qt_servershmid = -1; bool qws_overrideCursor = false; #ifndef QT_NO_QWS_MANAGER -#include "qdecorationfactory_qws.h" extern Q_GUI_EXPORT QWSServer *qwsServer; -QT_BEGIN_NAMESPACE - -QT_USE_NAMESPACE static QDecoration *qws_decoration = 0; #endif @@ -2371,7 +2370,7 @@ void qt_cleanup() QString QApplicationPrivate::appName() const // get application name { - return ::appName; + return QT_PREPEND_NAMESPACE(appName); } /***************************************************************************** diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index b2cde4d..76a3b1e 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1808,7 +1808,6 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam case APPCOMMAND_VOLUME_UP: key = Qt::Key_VolumeUp; break; -#if defined(WINVER) && WINVER >= 0x0501 // Commands new in Windows XP case APPCOMMAND_HELP: key = Qt::Key_Help; @@ -1822,7 +1821,6 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam case APPCOMMAND_MEDIA_PLAY: key = Qt::Key_MediaPlay; break; -#endif default: break; } diff --git a/src/gui/kernel/qclipboard_s60.cpp b/src/gui/kernel/qclipboard_s60.cpp index 26ea844..9a2629c 100644 --- a/src/gui/kernel/qclipboard_s60.cpp +++ b/src/gui/kernel/qclipboard_s60.cpp @@ -49,7 +49,7 @@ #include "qbuffer.h" #include "qwidget.h" #include "qevent.h" -#include "private/qapplication_p.h" +#include "private/qcore_symbian_p.h" #include <QtDebug> // Symbian's clipboard @@ -194,7 +194,7 @@ const QMimeData* QClipboard::mimeData(Mode mode) const if (d) { TRAPD(err,{ - RFs& fs = QCoreApplicationPrivate::fsSession(); + RFs fs = qt_s60GetRFs(); CClipboard* cb = CClipboard::NewForReadingLC(fs); Q_ASSERT(cb); RStoreReadStream stream; @@ -220,7 +220,7 @@ void QClipboard::setMimeData(QMimeData* src, Mode mode) if (d) { TRAPD(err,{ - RFs& fs = QCoreApplicationPrivate::fsSession(); + RFs fs = qt_s60GetRFs(); CClipboard* cb = CClipboard::NewForWritingLC(fs); RStoreWriteStream stream; TStreamId stid = stream.CreateLC(cb->Store()); diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 5a0209d..5ab7ed2 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -976,6 +976,15 @@ extern "C" { return qwidget->focusPolicy() != Qt::NoFocus; } +- (BOOL)resignFirstResponder +{ + // Seems like the following test only triggers if this + // view is inside a QMacNativeWidget: + if (qwidget == QApplication::focusWidget()) + QApplicationPrivate::setFocusWidget(0, Qt::OtherFocusReason); + return YES; +} + - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal { Q_UNUSED(isLocal); diff --git a/src/gui/kernel/qsound_qws.cpp b/src/gui/kernel/qsound_qws.cpp index fa32dcd..83e9c5e 100644 --- a/src/gui/kernel/qsound_qws.cpp +++ b/src/gui/kernel/qsound_qws.cpp @@ -53,16 +53,16 @@ #include "qhash.h" #include "qfileinfo.h" -#ifdef MEDIA_SERVER #include "qbytearray.h" #include "quuid.h" #include "qdatastream.h" #include "qcopchannel_qws.h" #include "qbuffer.h" + QT_BEGIN_NAMESPACE -QT_USE_NAMESPACE +#ifdef MEDIA_SERVER #define SERVER_CHANNEL "QPE/MediaServer" diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5e720df..d39044a 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -187,6 +187,9 @@ QWidgetPrivate::QWidgetPrivate(int version) , extraPaintEngine(0) , polished(0) , graphicsEffect(0) +#if !defined(QT_NO_IM) + , imHints(Qt::ImhNone) +#endif , inheritedFontResolveMask(0) , inheritedPaletteResolveMask(0) , leftmargin(0) @@ -217,7 +220,6 @@ QWidgetPrivate::QWidgetPrivate(int version) , window_event(0) , qd_hd(0) #endif - ,imHints(Qt::ImhNone) { if (!qApp) { qFatal("QWidget: Must construct a QApplication before a QPaintDevice"); @@ -971,7 +973,10 @@ struct QWidgetExceptionCleaner /* this cleans up when the constructor throws an exception */ static inline void cleanup(QWidget *that, QWidgetPrivate *d) { -#ifndef QT_NO_EXCEPTIONS +#ifdef QT_NO_EXCEPTIONS + Q_UNUSED(that); + Q_UNUSED(d); +#else QWidgetPrivate::allWidgets->remove(that); if (d->focus_next != that) { if (d->focus_next) @@ -4965,6 +4970,13 @@ void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys) } #endif // !defined(Q_OS_SYMBIAN) +/*! + Returns a pointer to this widget's effect if it has one; otherwise 0. + + \since 4.6 + + \sa setGraphicsEffect() +*/ QGraphicsEffect *QWidget::graphicsEffect() const { Q_D(const QWidget); @@ -4982,6 +4994,8 @@ QGraphicsEffect *QWidget::graphicsEffect() const \note This function will apply the effect on itself and all its children. \since 4.6 + + \sa graphicsEffect() */ void QWidget::setGraphicsEffect(QGraphicsEffect *effect) { @@ -6231,6 +6245,10 @@ bool QWidget::isActiveWindow() const if(qt_mac_is_macdrawer(tlw) && tlw->parentWidget() && tlw->parentWidget()->isActiveWindow()) return true; + + extern bool qt_mac_insideKeyWindow(const QWidget *); //qwidget_mac.cpp + if (QApplication::testAttribute(Qt::AA_MacPluginApplication) && qt_mac_insideKeyWindow(tlw)) + return true; #endif if(style()->styleHint(QStyle::SH_Widget_ShareActivation, 0, this)) { if(tlw->windowType() == Qt::Tool && diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index ea5a53e..53d1b6e 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -301,6 +301,14 @@ bool qt_mac_is_macdrawer(const QWidget *w) return (w && w->parentWidget() && w->windowType() == Qt::Drawer); } +bool qt_mac_insideKeyWindow(const QWidget *w) +{ +#ifdef QT_MAC_USE_COCOA + return [[reinterpret_cast<NSView *>(w->winId()) window] isKeyWindow]; +#endif + return false; +} + bool qt_mac_set_drawer_preferred_edge(QWidget *w, Qt::DockWidgetArea where) //users of Qt for Mac OS X can use this.. { if(!qt_mac_is_macdrawer(w)) diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index a52a270..b7179a4 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -625,7 +625,7 @@ void QBrush::detach(Qt::BrushStyle newStyle) QBrush &QBrush::operator=(const QBrush &b) { - if (this == &b) + if (d == b.d) return *this; b.d->ref.ref(); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 72bb164..5f6e1d6 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -791,7 +791,7 @@ void QRasterPaintEngine::updatePen(const QPen &pen) if(pen_style == Qt::SolidLine) { s->stroker = &d->basicStroker; } else if (pen_style != Qt::NoPen) { - if (!d->dashStroker.data()) + if (!d->dashStroker) d->dashStroker.reset(new QDashStroker(&d->basicStroker)); if (pen.isCosmetic()) { d->dashStroker->setClipRect(d->deviceRect); diff --git a/src/gui/painting/qpaintengineex_p.h b/src/gui/painting/qpaintengineex_p.h index cf3aad7..1ba2153 100644 --- a/src/gui/painting/qpaintengineex_p.h +++ b/src/gui/painting/qpaintengineex_p.h @@ -204,6 +204,9 @@ public: virtual void sync() {} + virtual void beginNativePainting() {} + virtual void endNativePainting() {} + virtual QPixmapFilter *createPixmapFilter(int /*type*/) const { return 0; } protected: diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index e1a6e80..cba4ad9 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -1889,6 +1889,45 @@ QPaintEngine *QPainter::paintEngine() const return d->engine; } +/*! + Flushes the painting pipeline and prepares for the user issuing + native painting commands. Must be followed by a call to + endNativePainting(). + + \sa endNativePainting() +*/ +void QPainter::beginNativePainting() +{ + Q_D(QPainter); + if (!d->engine) { + qWarning("QPainter::beginNativePainting: Painter not active"); + return; + } + + if (d->extended) + d->extended->beginNativePainting(); +} + +/*! + Restores the painter after manually issuing native painting commands. + Lets the painter restore any native state that it relies on before + calling any other painter commands. + + \sa beginNativePainting() +*/ +void QPainter::endNativePainting() +{ + Q_D(const QPainter); + if (!d->engine) { + qWarning("QPainter::beginNativePainting: Painter not active"); + return; + } + + if (d->extended) + d->extended->endNativePainting(); + else + d->engine->syncState(); +} /*! Returns the font metrics for the painter if the painter is diff --git a/src/gui/painting/qpainter.h b/src/gui/painting/qpainter.h index 14d1cf8..1bb97c6 100644 --- a/src/gui/painting/qpainter.h +++ b/src/gui/painting/qpainter.h @@ -423,6 +423,9 @@ public: static QPaintDevice *redirected(const QPaintDevice *device, QPoint *offset = 0); static void restoreRedirected(const QPaintDevice *device); + void beginNativePainting(); + void endNativePainting(); + #ifdef QT3_SUPPORT inline QT3_SUPPORT void setBackgroundColor(const QColor &color) { setBackground(color); } diff --git a/src/gui/painting/qpainterpath.cpp b/src/gui/painting/qpainterpath.cpp index eb8b964..a10c4cd 100644 --- a/src/gui/painting/qpainterpath.cpp +++ b/src/gui/painting/qpainterpath.cpp @@ -1520,12 +1520,6 @@ QList<QPolygonF> QPainterPath::toSubpathPolygons(const QMatrix &matrix) const return toSubpathPolygons(QTransform(matrix)); } -static inline bool rect_intersects(const QRectF &r1, const QRectF &r2) -{ - return qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) - && qMax(r1.top(), r2.top()) <= qMin(r1.bottom(), r2.bottom()); -} - /*! Converts the path into a list of polygons using the QTransform \a matrix, and returns the list. @@ -1578,7 +1572,7 @@ QList<QPolygonF> QPainterPath::toFillPolygons(const QTransform &matrix) const continue; QRectF cbounds = bounds.at(j); for (int i=0; i<count; ++i) { - if (rect_intersects(cbounds, bounds.at(i))) { + if (cbounds.intersects(bounds.at(i))) { isects[j] << i; } } diff --git a/src/gui/styles/qcleanlooksstyle.cpp b/src/gui/styles/qcleanlooksstyle.cpp index 0a82c9c..426ebfd 100644 --- a/src/gui/styles/qcleanlooksstyle.cpp +++ b/src/gui/styles/qcleanlooksstyle.cpp @@ -1499,7 +1499,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o default: break; } - if (QApplication::layoutDirection() == Qt::RightToLeft) { //reverse layout changes the order of Beginning/end + if (toolbar->direction == Qt::RightToLeft) { //reverse layout changes the order of Beginning/end bool tmp = paintLeftBorder; paintRightBorder=paintLeftBorder; paintLeftBorder=tmp; @@ -4323,7 +4323,7 @@ QRect QCleanlooksStyle::subElementRect(SubElement sr, const QStyleOption *opt, c if (verticalTitleBar) { r.adjust(0, 0, 0, -4); } else { - if (QApplication::layoutDirection() == Qt::LeftToRight) + if (opt->direction == Qt::LeftToRight) r.adjust(4, 0, 0, 0); else r.adjust(0, 0, -4, 0); diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index d4488ec..2dab9b3 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -564,7 +564,7 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q p->translate(opt->rect.x(), opt->rect.y()); if (opt->state & State_Horizontal) { int x = opt->rect.width() / 3; - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (opt->direction == Qt::RightToLeft) x -= 2; if (opt->rect.height() > 4) { qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, @@ -5224,6 +5224,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti Q_UNUSED(sp); #else QPixmap pixmap; + const bool rtl = (option && option->direction == Qt::RightToLeft) || !option && QApplication::isRightToLeft(); if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { switch (sp) { @@ -5382,7 +5383,7 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti switch (sp) { #ifndef QT_NO_IMAGEFORMAT_XPM case SP_ToolBarHorizontalExtensionButton: - if (QApplication::layoutDirection() == Qt::RightToLeft) { + if (rtl) { QImage im(tb_extension_arrow_h_xpm); im = im.convertToFormat(QImage::Format_ARGB32).mirrored(true, false); return QPixmap::fromImage(im); @@ -5398,11 +5399,11 @@ QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *opti #ifndef QT_NO_IMAGEFORMAT_PNG case SP_CommandLink: case SP_ArrowForward: - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (rtl) return proxy()->standardPixmap(SP_ArrowLeft, option, widget); return proxy()->standardPixmap(SP_ArrowRight, option, widget); case SP_ArrowBack: - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (rtl) return proxy()->standardPixmap(SP_ArrowRight, option, widget); return proxy()->standardPixmap(SP_ArrowLeft, option, widget); case SP_ArrowLeft: @@ -5513,6 +5514,7 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons const QWidget *widget) const { QIcon icon; + const bool rtl = (option && option->direction == Qt::RightToLeft) || !option && QApplication::isRightToLeft(); if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { switch (standardIcon) { case SP_DirHomeIcon: @@ -5637,11 +5639,11 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons icon = QIcon::fromTheme(QLatin1String("edit-clear")); break; case SP_ArrowForward: - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (rtl) return standardIconImplementation(SP_ArrowLeft, option, widget); return standardIconImplementation(SP_ArrowRight, option, widget); case SP_ArrowBack: - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (rtl) return standardIconImplementation(SP_ArrowRight, option, widget); return standardIconImplementation(SP_ArrowLeft, option, widget); case SP_FileLinkIcon: @@ -5865,11 +5867,11 @@ QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, cons icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-128.png")); break; case SP_ArrowForward: - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (rtl) return standardIconImplementation(SP_ArrowLeft, option, widget); return standardIconImplementation(SP_ArrowRight, option, widget); case SP_ArrowBack: - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (rtl) return standardIconImplementation(SP_ArrowRight, option, widget); return standardIconImplementation(SP_ArrowLeft, option, widget); case SP_ArrowLeft: diff --git a/src/gui/styles/qplastiquestyle.cpp b/src/gui/styles/qplastiquestyle.cpp index 04559dc..0c3c2a3 100644 --- a/src/gui/styles/qplastiquestyle.cpp +++ b/src/gui/styles/qplastiquestyle.cpp @@ -3749,7 +3749,7 @@ void QPlastiqueStyle::drawControl(ControlElement element, const QStyleOption *op QPixmap pixmap = comboBox->currentIcon.pixmap(comboBox->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(comboBox->iconSize.width() + 5); - iconRect = alignedRect(QApplication::layoutDirection(), + iconRect = alignedRect(comboBox->direction, Qt::AlignLeft | Qt::AlignVCenter, iconRect.size(), editRect); painter->fillRect(iconRect, option->palette.brush(QPalette::Base)); diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 8ac811c..7acb3a6 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -3196,7 +3196,7 @@ void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionC if (subRule.hasDrawable()) { QRect rect = subRule.boxRect(subControlRect(CC_MdiControls, opt, control, w), Margin); subRule.drawRule(p, rect); - QIcon icon = standardIcon(subControlIcon(layoutButton)); + QIcon icon = standardIcon(subControlIcon(layoutButton), opt); icon.paint(p, subRule.contentsRect(rect), Qt::AlignCenter); } else { optCopy.subControls |= control; @@ -3643,9 +3643,9 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); QRect iconRect(editRect); iconRect.setWidth(cb->iconSize.width()); - iconRect = alignedRect(QApplication::layoutDirection(), - Qt::AlignLeft | Qt::AlignVCenter, - iconRect.size(), editRect); + iconRect = alignedRect(cb->direction, + Qt::AlignLeft | Qt::AlignVCenter, + iconRect.size(), editRect); drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); if (cb->direction == Qt::RightToLeft) diff --git a/src/gui/styles/qwindowsstyle.cpp b/src/gui/styles/qwindowsstyle.cpp index e558844..8097a3d 100644 --- a/src/gui/styles/qwindowsstyle.cpp +++ b/src/gui/styles/qwindowsstyle.cpp @@ -1261,7 +1261,7 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, p->translate(opt->rect.x(), opt->rect.y()); if (opt->state & State_Horizontal) { int x = opt->rect.width() / 2 - 4; - if (QApplication::layoutDirection() == Qt::RightToLeft) + if (opt->direction == Qt::RightToLeft) x -= 2; if (opt->rect.height() > 4) { qDrawShadePanel(p, x, 2, 3, opt->rect.height() - 4, @@ -2312,7 +2312,7 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai default: break; } - if(QApplication::layoutDirection() == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end + if(opt->direction == Qt::RightToLeft){ //reverse layout changes the order of Beginning/end bool tmp = paintLeftBorder; paintRightBorder=paintLeftBorder; paintLeftBorder=tmp; @@ -2564,7 +2564,7 @@ QRect QWindowsStyle::subElementRect(SubElement sr, const QStyleOption *opt, cons if (verticalTitleBar) { r.adjust(0, 0, 0, -m); } else { - if (QApplication::layoutDirection() == Qt::LeftToRight) + if (opt->direction == Qt::LeftToRight) r.adjust(m, 0, 0, 0); else r.adjust(0, 0, -m, 0); diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 0e08730..e365873 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -2331,7 +2331,7 @@ void QWindowsXPStyle::drawControl(ControlElement element, const QStyleOption *op bool hasIcon = (ico.cacheKey() != QApplication::windowIcon().cacheKey()); if (hasIcon) { QPixmap pxIco = ico.pixmap(titleHeight); - if (!verticalTitleBar && QApplication::layoutDirection() == Qt::RightToLeft) + if (!verticalTitleBar && dwOpt->direction == Qt::RightToLeft) p->drawPixmap(rect.width() - titleHeight - pxIco.width(), rect.bottom() - titleHeight - 2, pxIco); else p->drawPixmap(fw, rect.bottom() - titleHeight - 2, pxIco); diff --git a/src/gui/text/qfontengine_qpf.cpp b/src/gui/text/qfontengine_qpf.cpp index e05a502..05dea6e 100644 --- a/src/gui/text/qfontengine_qpf.cpp +++ b/src/gui/text/qfontengine_qpf.cpp @@ -66,9 +66,10 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_QWS_QPF2 -QT_BEGIN_INCLUDE_NAMESPACE #include "qpfutil.cpp" +QT_BEGIN_INCLUDE_NAMESPACE + #if defined(Q_WS_QWS) # include "private/qwscommand_qws_p.h" # include "qwsdisplay_qws.h" diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index 173b822..7a9d958 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -327,8 +327,10 @@ QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont BOOL res = GetTextMetrics(hdc, &tm); fontDef.fixedPitch = !(tm.tmPitchAndFamily & TMPF_FIXED_PITCH); - if (!res) + if (!res) { qErrnoWarning("QFontEngineWin: GetTextMetrics failed"); + ZeroMemory(&tm, sizeof(TEXTMETRIC)); + } cache_cost = tm.tmHeight * tm.tmAveCharWidth * 2000; getCMap(); diff --git a/src/gui/util/qsystemtrayicon_win.cpp b/src/gui/util/qsystemtrayicon_win.cpp index 56872ac..ea7fbde 100644 --- a/src/gui/util/qsystemtrayicon_win.cpp +++ b/src/gui/util/qsystemtrayicon_win.cpp @@ -132,15 +132,12 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object) : hIcon(0), q(object), ignoreNextMouseRelease(false) { -#ifdef Q_OS_WINCE - notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE; - maxTipLength = 64; -#elif WINVER <= 0x0500 - notifyIconSize = sizeof(NOTIFYICONDATA); - maxTipLength = 64; -#else +#ifndef Q_OS_WINCE notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, guidItem); // NOTIFYICONDATAW_V2_SIZE; maxTipLength = 128; +#else + notifyIconSize = FIELD_OFFSET(NOTIFYICONDATA, szTip[64]); // NOTIFYICONDATAW_V1_SIZE; + maxTipLength = 64; #endif // For restoring the tray icon after explorer crashes diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp index 28435ef..1b4d41b 100644 --- a/src/gui/widgets/qabstractscrollarea.cpp +++ b/src/gui/widgets/qabstractscrollarea.cpp @@ -51,7 +51,10 @@ #include "qdebug.h" #include "qboxlayout.h" #include "qpainter.h" + +#ifdef Q_WS_WIN #include "qstandardgestures.h" +#endif #include "qabstractscrollarea_p.h" #include <qwidget.h> @@ -1344,6 +1347,7 @@ void QAbstractScrollArea::setupViewport(QWidget *viewport) Q_UNUSED(viewport); } +#ifdef Q_WS_WIN void QAbstractScrollAreaPrivate::_q_gestureTriggered() { Q_Q(QAbstractScrollArea); @@ -1362,6 +1366,7 @@ void QAbstractScrollAreaPrivate::_q_gestureTriggered() vbar->setValue(newY); } } +#endif QT_END_NAMESPACE diff --git a/src/gui/widgets/qabstractscrollarea.h b/src/gui/widgets/qabstractscrollarea.h index 0a3e9c5..0625458 100644 --- a/src/gui/widgets/qabstractscrollarea.h +++ b/src/gui/widgets/qabstractscrollarea.h @@ -128,7 +128,10 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_hslide(int)) Q_PRIVATE_SLOT(d_func(), void _q_vslide(int)) Q_PRIVATE_SLOT(d_func(), void _q_showOrHideScrollBars()) + +#ifdef Q_WS_WIN Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered()) +#endif friend class QStyleSheetStyle; friend class QWidgetPrivate; diff --git a/src/gui/widgets/qabstractscrollarea_p.h b/src/gui/widgets/qabstractscrollarea_p.h index a5acdd1..4362ce9 100644 --- a/src/gui/widgets/qabstractscrollarea_p.h +++ b/src/gui/widgets/qabstractscrollarea_p.h @@ -101,9 +101,9 @@ public: { return q_func()->viewportEvent(event); } QScopedPointer<QObject> viewportFilter; - virtual void _q_gestureTriggered(); #ifdef Q_WS_WIN QPanGesture *panGesture; + virtual void _q_gestureTriggered(); bool singleFingerPanEnabled; void setSingleFingerPanEnabled(bool on = true); #endif diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp index 58edfde..52538e0 100644 --- a/src/gui/widgets/qabstractslider.cpp +++ b/src/gui/widgets/qabstractslider.cpp @@ -687,9 +687,7 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e) Q_D(QAbstractSlider); e->ignore(); if (e->orientation() != d->orientation && !rect().contains(e->pos())) - { return; - } static qreal offset = 0; static QAbstractSlider *offset_owner = 0; if (offset_owner != this){ diff --git a/src/gui/widgets/qcommandlinkbutton.cpp b/src/gui/widgets/qcommandlinkbutton.cpp index 206221f..fd69f55 100644 --- a/src/gui/widgets/qcommandlinkbutton.cpp +++ b/src/gui/widgets/qcommandlinkbutton.cpp @@ -205,7 +205,9 @@ void QCommandLinkButtonPrivate::init() q->setSizePolicy(policy); q->setIconSize(QSize(20, 20)); - q->setIcon(q->style()->standardIcon(QStyle::SP_CommandLink)); + QStyleOptionButton opt; + q->initStyleOption(&opt); + q->setIcon(q->style()->standardIcon(QStyle::SP_CommandLink, &opt)); } // Calculates the height of the description text based on widget width diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index 5a9c7e1..d1ebdf4 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -1643,7 +1643,6 @@ QDateTimeEditPrivate::QDateTimeEditPrivate() cachedDay = -1; currentSectionIndex = FirstSectionIndex; - layoutDirection = QApplication::layoutDirection(); first.type = FirstSection; last.type = LastSection; none.type = NoSection; diff --git a/src/gui/widgets/qdatetimeedit_p.h b/src/gui/widgets/qdatetimeedit_p.h index 7b29e51..33c09c0 100644 --- a/src/gui/widgets/qdatetimeedit_p.h +++ b/src/gui/widgets/qdatetimeedit_p.h @@ -132,7 +132,6 @@ public: mutable bool cacheGuard; QString defaultDateFormat, defaultTimeFormat, defaultDateTimeFormat, unreversedFormat; - Qt::LayoutDirection layoutDirection; mutable QVariant conflictGuard; bool hasHadFocus, formatExplicitlySet, calendarPopup; QStyle::StateFlag arrowState; diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h index 721d990..0db6279 100644 --- a/src/gui/widgets/qlinecontrol_p.h +++ b/src/gui/widgets/qlinecontrol_p.h @@ -78,10 +78,10 @@ class Q_GUI_EXPORT QLineControl : public QObject public: QLineControl(const QString &txt = QString()) - : m_cursor(0), m_preeditCursor(0), m_layoutDirection(Qt::LeftToRight), + : m_cursor(0), m_preeditCursor(0), m_cursorWidth(0), m_layoutDirection(Qt::LeftToRight), m_hideCursor(false), m_separator(0), m_readOnly(0), m_dragEnabled(0), m_echoMode(0), m_textDirty(0), m_selDirty(0), - m_validInput(1), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0), + m_validInput(1), m_blinkStatus(0), m_blinkPeriod(0), m_blinkTimer(0), m_deleteAllTimer(0), m_ascent(0), m_maxLength(32767), m_lastCursorPos(-1), m_tripleClickTimer(0), m_maskData(0), m_modifiedState(0), m_undoState(0), m_selstart(0), m_selend(0), m_passwordEchoEditing(false) @@ -262,10 +262,10 @@ private: uint m_textDirty : 1; uint m_selDirty : 1; uint m_validInput : 1; + uint m_blinkStatus : 1; int m_blinkPeriod; // 0 for non-blinking cursor int m_blinkTimer; int m_deleteAllTimer; - int m_blinkStatus; int m_ascent; int m_maxLength; int m_lastCursorPos; @@ -349,7 +349,7 @@ Q_SIGNALS: protected: virtual void timerEvent(QTimerEvent *event); -private slots: +private Q_SLOTS: void _q_clipboardChanged(); void _q_deleteSelected(); diff --git a/src/gui/widgets/qlineedit.cpp b/src/gui/widgets/qlineedit.cpp index 6b73e21..059aaf1 100644 --- a/src/gui/widgets/qlineedit.cpp +++ b/src/gui/widgets/qlineedit.cpp @@ -1395,8 +1395,7 @@ bool QLineEdit::event(QEvent * e) if (e->type() == QEvent::EnterEditFocus) { end(false); d->setCursorVisible(true); - int cft = QApplication::cursorFlashTime(); - d->control->setCursorBlinkPeriod(cft/2); + d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); } else if (e->type() == QEvent::LeaveEditFocus) { d->setCursorVisible(false); d->control->setCursorBlinkPeriod(0); @@ -1691,8 +1690,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e) #ifdef QT_KEYPAD_NAVIGATION if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){ #endif - int cft = QApplication::cursorFlashTime(); - d->control->setCursorBlinkPeriod(cft/2); + d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()); QStyleOptionFrameV2 opt; initStyleOption(&opt); if((!hasSelectedText() && d->control->preeditAreaText().isEmpty()) @@ -2004,7 +2002,7 @@ QMenu *QLineEdit::createStandardContextMenu() action = popup->addAction(QLineEdit::tr("Delete")); action->setEnabled(!d->control->isReadOnly() && !d->control->text().isEmpty() && d->control->hasSelectedText()); - connect(action, SIGNAL(triggered()), SLOT(_q_deleteSelected())); + connect(action, SIGNAL(triggered()), d->control, SLOT(_q_deleteSelected())); popup->addSeparator(); diff --git a/src/gui/widgets/qlineedit.h b/src/gui/widgets/qlineedit.h index 03d4376..cd37ad0 100644 --- a/src/gui/widgets/qlineedit.h +++ b/src/gui/widgets/qlineedit.h @@ -267,7 +267,6 @@ private: Q_DISABLE_COPY(QLineEdit) Q_DECLARE_PRIVATE(QLineEdit) Q_PRIVATE_SLOT(d_func(), void _q_handleWindowActivate()) - Q_PRIVATE_SLOT(d_func(), void _q_deleteSelected()) Q_PRIVATE_SLOT(d_func(), void _q_textEdited(const QString &)) Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged(int, int)) #ifndef QT_NO_COMPLETER diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index cec34da..4218630 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -93,10 +93,6 @@ void QLineEditPrivate::_q_completionHighlighted(QString newText) #endif // QT_NO_COMPLETER -void QLineEditPrivate::_q_clipboardChanged() -{ -} - void QLineEditPrivate::_q_handleWindowActivate() { Q_Q(QLineEdit); @@ -104,10 +100,6 @@ void QLineEditPrivate::_q_handleWindowActivate() control->deselect(); } -void QLineEditPrivate::_q_deleteSelected() -{ -} - void QLineEditPrivate::_q_textEdited(const QString &text) { Q_Q(QLineEdit); diff --git a/src/gui/widgets/qlineedit_p.h b/src/gui/widgets/qlineedit_p.h index 3ab10fc..260bc19 100644 --- a/src/gui/widgets/qlineedit_p.h +++ b/src/gui/widgets/qlineedit_p.h @@ -84,6 +84,7 @@ public: ~QLineEditPrivate() { + delete control; } QLineControl *control; @@ -121,9 +122,7 @@ public: QRect adjustedContentsRect() const; - void _q_clipboardChanged(); void _q_handleWindowActivate(); - void _q_deleteSelected(); void _q_textEdited(const QString &); void _q_cursorPositionChanged(int, int); #ifdef QT_KEYPAD_NAVIGATION diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 529a225..0ea9b56 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -1463,7 +1463,7 @@ void QMainWindowLayout::setGeometry(const QRect &_r) QSize(r.width(), statusbar->heightForWidth(r.width())) .expandedTo(statusbar->minimumSize())); sbr.moveBottom(r.bottom()); - QRect vr = QStyle::visualRect(QApplication::layoutDirection(), _r, sbr); + QRect vr = QStyle::visualRect(parentWidget()->layoutDirection(), _r, sbr); statusbar->setGeometry(vr); r.setBottom(sbr.top() - 1); } diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 69ccae5..4734d22 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -368,7 +368,9 @@ QRect QMenuPrivate::actionRect(QAction *act) const return actionRects.at(index); } +#if defined(Q_WS_MAC) static const qreal MenuFadeTimeInSec = 0.150; +#endif void QMenuPrivate::hideUpToMenuBar() { @@ -1832,7 +1834,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) if (adjustToDesktop) { //handle popup falling "off screen" - if (QApplication::layoutDirection() == Qt::RightToLeft) { + if (isRightToLeft()) { if(snapToMouse) //position flowing left from the mouse pos.setX(mouse.x()-size.width()); @@ -1870,9 +1872,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction) } setGeometry(QRect(pos, size)); #ifndef QT_NO_EFFECTS - int hGuess = QApplication::layoutDirection() == Qt::RightToLeft ? QEffects::LeftScroll : QEffects::RightScroll; + int hGuess = isRightToLeft() ? QEffects::LeftScroll : QEffects::RightScroll; int vGuess = QEffects::DownScroll; - if (QApplication::layoutDirection() == Qt::RightToLeft) { + if (isRightToLeft()) { if ((snapToMouse && (pos.x() + size.width()/2 > mouse.x())) || (qobject_cast<QMenu*>(d->causedPopup.widget) && pos.x() + size.width()/2 > d->causedPopup.widget->x())) hGuess = QEffects::RightScroll; @@ -2779,6 +2781,8 @@ void QMenu::leaveEvent(QEvent *) d->sloppyAction = 0; if (!d->sloppyRegion.isEmpty()) d->sloppyRegion = QRegion(); + if (!d->activeMenu && d->currentAction) + setActiveAction(0); } /*! diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index d59e1c9..8e28abe 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -607,6 +607,13 @@ static inline void syncNSMenuItemVisiblity(NSMenuItem *menuItem, bool actionVisi [menuItem setHidden:!actionVisibility]; } +static inline void syncNSMenuItemEnabled(NSMenuItem *menuItem, bool enabled) +{ + [menuItem setEnabled:NO]; + [menuItem setEnabled:YES]; + [menuItem setEnabled:enabled]; +} + static inline void syncMenuBarItemsVisiblity(const QMenuBarPrivate::QMacMenuBarPrivate *mac_menubar) { const QList<QMacMenuAction *> &menubarActions = mac_menubar->actionItems; @@ -659,12 +666,12 @@ void qt_mac_set_modal_state_helper_recursive(OSMenuRef menu, OSMenuRef merge, bo // The item should follow what the QAction has. if ([item tag]) { QAction *action = reinterpret_cast<QAction *>([item tag]); - [item setEnabled:action->isEnabled()]; + syncNSMenuItemEnabled(item, action->isEnabled()); } else { - [item setEnabled:YES]; + syncNSMenuItemEnabled(item, YES); } } else { - [item setEnabled:NO]; + syncNSMenuItemEnabled(item, NO); } } } @@ -728,6 +735,9 @@ bool qt_mac_menubar_is_open() void qt_mac_clear_menubar() { + if (QApplication::testAttribute(Qt::AA_MacPluginApplication)) + return; + #ifndef QT_MAC_USE_COCOA MenuRef clear_menu = 0; if (CreateNewMenu(0, 0, &clear_menu) == noErr) { @@ -1754,14 +1764,16 @@ void QMenuBarPrivate::macCreateMenuBar(QWidget *parent) { Q_Q(QMenuBar); - static int checkEnv = -1; + static int dontUseNativeMenuBar = -1; // We call the isNativeMenuBar function here - // becasue that will make sure that local overrides + // because that will make sure that local overrides // are dealt with correctly. bool qt_mac_no_native_menubar = !q->isNativeMenuBar(); - if (qt_mac_no_native_menubar == false && checkEnv < 0) { - checkEnv = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty(); - QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, checkEnv); + if (qt_mac_no_native_menubar == false && dontUseNativeMenuBar < 0) { + bool isPlugin = QApplication::testAttribute(Qt::AA_MacPluginApplication); + bool environmentSaysNo = !qgetenv("QT_MAC_NO_NATIVE_MENUBAR").isEmpty(); + dontUseNativeMenuBar = isPlugin || environmentSaysNo; + QApplication::instance()->setAttribute(Qt::AA_DontUseNativeMenuBar, dontUseNativeMenuBar); qt_mac_no_native_menubar = !q->isNativeMenuBar(); } if (!qt_mac_no_native_menubar) { diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 0967f71..6633f2a 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -132,7 +132,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const result.adjust(hmargin, 0, -hmargin, 0); if (extVisible) { - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) result.setLeft(result.left() + extension->sizeHint().width()); else result.setWidth(result.width() - extension->sizeHint().width()); @@ -140,7 +140,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const if (leftWidget && leftWidget->isVisible()) { QSize sz = leftWidget->sizeHint(); - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) result.setRight(result.right() - sz.width()); else result.setLeft(result.left() + sz.width()); @@ -148,7 +148,7 @@ QRect QMenuBarPrivate::menuRect(bool extVisible) const if (rightWidget && rightWidget->isVisible()) { QSize sz = rightWidget->sizeHint(); - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) result.setLeft(result.left() + sz.width()); else result.setRight(result.right() - sz.width()); @@ -245,7 +245,7 @@ void QMenuBarPrivate::updateGeometries() pop->addActions(hiddenActions); int vmargin = q->style()->pixelMetric(QStyle::PM_MenuBarVMargin, 0, q); - int x = q->layoutDirection() == Qt::RightToLeft + int x = q->isRightToLeft() ? menuRect.left() - extension->sizeHint().width() + 1 : menuRect.right(); extension->setGeometry(x, vmargin, extension->sizeHint().width(), menuRect.height() - vmargin*2); diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 03c36d7..4ea18f8 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -66,7 +66,9 @@ #include <qtexttable.h> #include <qvariant.h> +#ifdef Q_WS_WIN #include <qstandardgestures.h> +#endif #include <qinputcontext.h> @@ -377,7 +379,7 @@ void QPlainTextDocumentLayout::layoutBlock(const QTextBlock &block) tl->beginLayout(); qreal availableWidth = d->width; if (availableWidth <= 0) { - availableWidth = INT_MAX; // similar to text edit with pageSize.width == 0 + availableWidth = qreal(INT_MAX); // similar to text edit with pageSize.width == 0 } availableWidth -= 2*margin + extraMargin; while (1) { @@ -792,8 +794,10 @@ void QPlainTextEditPrivate::init(const QString &txt) viewport->setCursor(Qt::IBeamCursor); #endif originalOffsetY = 0; +#ifdef Q_WS_WIN panGesture = new QPanGesture(q); QObject::connect(panGesture, SIGNAL(triggered()), q, SLOT(_q_gestureTriggered())); +#endif } void QPlainTextEditPrivate::_q_repaintContents(const QRectF &contentsRect) @@ -2918,6 +2922,8 @@ QAbstractTextDocumentLayout::PaintContext QPlainTextEdit::getPaintContext() cons (\a available is true) or unavailable (\a available is false). */ +#ifdef Q_WS_WIN + void QPlainTextEditPrivate::_q_gestureTriggered() { Q_Q(QPlainTextEdit); @@ -2942,6 +2948,8 @@ void QPlainTextEditPrivate::_q_gestureTriggered() } } +#endif + QT_END_NAMESPACE #include "moc_qplaintextedit.cpp" diff --git a/src/gui/widgets/qplaintextedit.h b/src/gui/widgets/qplaintextedit.h index c9652ae..5ec3ed8 100644 --- a/src/gui/widgets/qplaintextedit.h +++ b/src/gui/widgets/qplaintextedit.h @@ -269,7 +269,11 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_adjustScrollbars()) Q_PRIVATE_SLOT(d_func(), void _q_verticalScrollbarActionTriggered(int)) Q_PRIVATE_SLOT(d_func(), void _q_cursorPositionChanged()) + +#ifdef Q_WS_WIN Q_PRIVATE_SLOT(d_func(), void _q_gestureTriggered()) +#endif + friend class QPlainTextEditControl; }; diff --git a/src/gui/widgets/qplaintextedit_p.h b/src/gui/widgets/qplaintextedit_p.h index 608f3cf..e93302c 100644 --- a/src/gui/widgets/qplaintextedit_p.h +++ b/src/gui/widgets/qplaintextedit_p.h @@ -176,12 +176,14 @@ public: #endif void _q_cursorPositionChanged(); - void _q_modificationChanged(bool); - void _q_gestureTriggered(); int originalOffsetY; + +#ifdef Q_WS_WIN + void _q_gestureTriggered(); QPanGesture *panGesture; +#endif }; QT_END_NAMESPACE diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index ef0847b..89e6d7a 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -205,7 +205,7 @@ void QToolBarPrivate::initDrag(const QPoint &pos) state->moving = false; state->widgetItem = 0; - if (q->layoutDirection() == Qt::RightToLeft) + if (q->isRightToLeft()) state->pressPos = QPoint(q->width() - state->pressPos.x(), state->pressPos.y()); } @@ -359,7 +359,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) QPoint pos = event->globalPos(); // if we are right-to-left, we move so as to keep the right edge the same distance // from the mouse - if (q->layoutDirection() == Qt::LeftToRight) + if (q->isLeftToRight()) pos -= state->pressPos; else pos += QPoint(state->pressPos.x() - q->width(), -state->pressPos.y()); @@ -369,14 +369,14 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) } else if (state->moving) { const QPoint rtl(q->width() - state->pressPos.x(), state->pressPos.y()); //for RTL - const QPoint globalPressPos = q->mapToGlobal(q->layoutDirection() == Qt::RightToLeft ? rtl : state->pressPos); + const QPoint globalPressPos = q->mapToGlobal(q->isRightToLeft() ? rtl : state->pressPos); int pos = 0; QPoint delta = event->globalPos() - globalPressPos; if (orientation == Qt::Vertical) { pos = q->y() + delta.y(); } else { - if (q->layoutDirection() == Qt::RightToLeft) { + if (q->isRightToLeft()) { pos = win->width() - q->width() - q->x() - delta.x(); } else { pos = q->x() + delta.x(); @@ -391,7 +391,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) void QToolBarPrivate::unplug(const QRect &_r) { Q_Q(QToolBar); - + layout->setExpanded(false, false); QRect r = _r; r.moveTopLeft(q->mapToGlobal(QPoint(0, 0))); setWindowState(true, true, r); diff --git a/src/gui/widgets/qtoolbarextension.cpp b/src/gui/widgets/qtoolbarextension.cpp index 1f1186c..6a70326 100644 --- a/src/gui/widgets/qtoolbarextension.cpp +++ b/src/gui/widgets/qtoolbarextension.cpp @@ -61,10 +61,12 @@ QToolBarExtension::QToolBarExtension(QWidget *parent) void QToolBarExtension::setOrientation(Qt::Orientation o) { + QStyleOption opt; + opt.init(this); if (o == Qt::Horizontal) { - setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton)); + setIcon(style()->standardIcon(QStyle::SP_ToolBarHorizontalExtensionButton, &opt)); } else { - setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton)); + setIcon(style()->standardIcon(QStyle::SP_ToolBarVerticalExtensionButton, &opt)); } } diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp index d3c5b4b..1f2ca60 100644 --- a/src/gui/widgets/qtoolbarlayout.cpp +++ b/src/gui/widgets/qtoolbarlayout.cpp @@ -642,7 +642,7 @@ QSize QToolBarLayout::expandedSize(const QSize &size) const return result; } -void QToolBarLayout::setExpanded(bool exp) +void QToolBarLayout::setExpanded(bool exp, bool animated) { if (exp == expanded) return; @@ -665,7 +665,7 @@ void QToolBarLayout::setExpanded(bool exp) layoutActions(rect.size()); } } - layout->layoutState.toolBarAreaLayout.apply(true); + layout->layoutState.toolBarAreaLayout.apply(animated); } } diff --git a/src/gui/widgets/qtoolbarlayout_p.h b/src/gui/widgets/qtoolbarlayout_p.h index fe81d2f..bb40e215 100644 --- a/src/gui/widgets/qtoolbarlayout_p.h +++ b/src/gui/widgets/qtoolbarlayout_p.h @@ -111,8 +111,8 @@ public: void updateMarginAndSpacing(); bool hasExpandFlag() const; -public slots: - void setExpanded(bool b); +public Q_SLOTS: + void setExpanded(bool b, bool animated = true); private: QList<QToolBarItem*> items; diff --git a/src/gui/widgets/qwidgetanimator.cpp b/src/gui/widgets/qwidgetanimator.cpp index beb6be2..972e07b 100644 --- a/src/gui/widgets/qwidgetanimator.cpp +++ b/src/gui/widgets/qwidgetanimator.cpp @@ -93,7 +93,7 @@ void QWidgetAnimator::animate(QWidget *widget, const QRect &_final_geometry, boo if (it != m_animation_map.constEnd() && (*it)->endValue().toRect() == final_geometry) return; - QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry"); + QPropertyAnimation *anim = new QPropertyAnimation(widget, "geometry", widget); anim->setDuration(animate ? 200 : 0); anim->setEasingCurve(QEasingCurve::InOutQuad); anim->setEndValue(final_geometry); |