summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorYann Bodson <yann.bodson@nokia.com>2009-08-31 00:29:56 (GMT)
committerYann Bodson <yann.bodson@nokia.com>2009-08-31 00:29:56 (GMT)
commitf5c0745622a914003aa75aaaa1e828854c1c85ba (patch)
tree6f9c27a22d5987a8bddd512222ab29dfeda5caf3 /src/gui
parent9cc59a858d116f75c19a782602ab8679405d9764 (diff)
parent9dade8d2e57655019ed4dc2fcdc4e226401138a2 (diff)
downloadQt-f5c0745622a914003aa75aaaa1e828854c1c85ba.zip
Qt-f5c0745622a914003aa75aaaa1e828854c1c85ba.tar.gz
Qt-f5c0745622a914003aa75aaaa1e828854c1c85ba.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/accessible/qaccessible_mac_cocoa.mm13
-rw-r--r--src/gui/effects/qgraphicseffect.cpp469
-rw-r--r--src/gui/effects/qgraphicseffect.h5
-rw-r--r--src/gui/effects/qgraphicseffect_p.h7
-rw-r--r--src/gui/embedded/qkbd_defaultmap_qws_p.h2
-rw-r--r--src/gui/embedded/qkbd_qws_p.h4
-rw-r--r--src/gui/embedded/qkbdqnx_qws.cpp5
-rw-r--r--src/gui/embedded/qlock.cpp11
-rw-r--r--src/gui/embedded/qmousetslib_qws.h2
-rw-r--r--src/gui/embedded/qscreen_qws.h4
-rw-r--r--src/gui/embedded/qscreenlinuxfb_qws.cpp6
-rw-r--r--src/gui/embedded/qscreenlinuxfb_qws.h8
-rw-r--r--src/gui/embedded/qscreenproxy_qws.cpp3
-rw-r--r--src/gui/embedded/qscreenqnx_qws.cpp3
-rw-r--r--src/gui/embedded/qsoundqss_qws.cpp4
-rw-r--r--src/gui/embedded/qwsutils_qws.h12
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout.cpp45
-rw-r--r--src/gui/graphicsview/qgraphicsanchorlayout_p.cpp2
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp124
-rw-r--r--src/gui/graphicsview/qgraphicsitem.h6
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h10
-rw-r--r--src/gui/graphicsview/qgraphicslayout.cpp4
-rw-r--r--src/gui/graphicsview/qgraphicslayout_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicslayoutitem_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicslinearlayout.cpp3
-rw-r--r--src/gui/graphicsview/qgraphicsproxywidget_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp250
-rw-r--r--src/gui/graphicsview/qgraphicsscene.h3
-rw-r--r--src/gui/graphicsview/qgraphicsscene_p.h7
-rw-r--r--src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicssceneevent.cpp8
-rw-r--r--src/gui/graphicsview/qgraphicssceneindex_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicstransform_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicsview_p.h4
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp19
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h4
-rw-r--r--src/gui/graphicsview/qgridlayoutengine.cpp22
-rw-r--r--src/gui/graphicsview/qgridlayoutengine_p.h4
-rw-r--r--src/gui/graphicsview/qsimplex_p.cpp2
-rw-r--r--src/gui/image/qpixmap.cpp2
-rw-r--r--src/gui/image/qpixmap_qws.cpp5
-rw-r--r--src/gui/image/qpixmapfilter.cpp4
-rw-r--r--src/gui/inputmethod/qinputcontext.cpp39
-rw-r--r--src/gui/inputmethod/qwininputcontext_p.h1
-rw-r--r--src/gui/inputmethod/qwininputcontext_win.cpp49
-rw-r--r--src/gui/inputmethod/qwsinputcontext_qws.cpp16
-rw-r--r--src/gui/itemviews/qabstractitemview.cpp3
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.cpp11
-rw-r--r--src/gui/itemviews/qsortfilterproxymodel.h1
-rw-r--r--src/gui/kernel/qapplication_p.h5
-rw-r--r--src/gui/kernel/qapplication_qws.cpp9
-rw-r--r--src/gui/kernel/qapplication_win.cpp25
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm11
-rw-r--r--src/gui/kernel/qcocoaview_mac_p.h1
-rw-r--r--src/gui/kernel/qevent.cpp68
-rw-r--r--src/gui/kernel/qevent_p.h2
-rw-r--r--src/gui/kernel/qmime_mac.cpp13
-rw-r--r--src/gui/kernel/qsound_qws.cpp4
-rw-r--r--src/gui/kernel/qstandardgestures.cpp231
-rw-r--r--src/gui/kernel/qstandardgestures.h48
-rw-r--r--src/gui/kernel/qstandardgestures_p.h39
-rw-r--r--src/gui/kernel/qwidget.cpp35
-rw-r--r--src/gui/kernel/qwidget_mac.mm11
-rw-r--r--src/gui/math3d/qmatrix4x4.cpp2
-rw-r--r--src/gui/painting/qbackingstore.cpp3
-rw-r--r--src/gui/painting/qpaintengine_raster.cpp2
-rw-r--r--src/gui/painting/qpaintengineex_p.h3
-rw-r--r--src/gui/painting/qpainter.cpp42
-rw-r--r--src/gui/painting/qpainter.h3
-rw-r--r--src/gui/styles/images/defaults60theme.blobbin0 -> 74127 bytes
-rw-r--r--src/gui/styles/qcommonstyle.cpp167
-rw-r--r--src/gui/styles/qcommonstyle_p.h3
-rw-r--r--src/gui/styles/qmacstyle_mac.mm13
-rw-r--r--src/gui/styles/qs60style.cpp192
-rw-r--r--src/gui/styles/qs60style.h2
-rw-r--r--src/gui/styles/qs60style_p.h6
-rw-r--r--src/gui/styles/qs60style_s60.cpp3
-rw-r--r--src/gui/styles/qs60style_simulated.cpp3
-rw-r--r--src/gui/styles/qstyle_s60_simulated.qrc2
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp26
-rw-r--r--src/gui/styles/styles.pri3
-rw-r--r--src/gui/text/qfontdatabase_s60.cpp11
-rw-r--r--src/gui/text/qfontengine_qpf.cpp3
-rw-r--r--src/gui/text/qfontengine_s60.cpp9
-rw-r--r--src/gui/text/qfontengine_s60_p.h4
-rw-r--r--src/gui/text/qfontengine_win.cpp4
-rw-r--r--src/gui/util/qsystemtrayicon_win.cpp9
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp2
-rw-r--r--src/gui/widgets/qcocoatoolbardelegate_mac.mm6
-rw-r--r--src/gui/widgets/qlinecontrol_p.h2
-rw-r--r--src/gui/widgets/qlineedit.cpp6
-rw-r--r--src/gui/widgets/qlineedit.h1
-rw-r--r--src/gui/widgets/qlineedit_p.cpp8
-rw-r--r--src/gui/widgets/qlineedit_p.h2
-rw-r--r--src/gui/widgets/qmenu.cpp2
-rw-r--r--src/gui/widgets/qmenu_mac.mm13
-rw-r--r--src/gui/widgets/qplaintextedit.cpp4
-rw-r--r--src/gui/widgets/qtabbar.cpp16
-rw-r--r--src/gui/widgets/qtoolbar.cpp2
-rw-r--r--src/gui/widgets/qtoolbarlayout.cpp4
-rw-r--r--src/gui/widgets/qtoolbarlayout_p.h4
101 files changed, 1552 insertions, 767 deletions
diff --git a/src/gui/accessible/qaccessible_mac_cocoa.mm b/src/gui/accessible/qaccessible_mac_cocoa.mm
index 502827c..41a2566 100644
--- a/src/gui/accessible/qaccessible_mac_cocoa.mm
+++ b/src/gui/accessible/qaccessible_mac_cocoa.mm
@@ -59,9 +59,9 @@ QT_BEGIN_NAMESPACE
//#define MAC_ACCESSIBILTY_DEVELOPER_MODE
#ifdef MAC_ACCESSIBILTY_DEVELOPER_MODE
-#define MAC_ACCESSIBILTY_DEBUG qDebug
+#define MAC_ACCESSIBILTY_DEBUG QT_PREPEND_NAMESPACE(qDebug)
#else
-#define MAC_ACCESSIBILTY_DEBUG if (0) qDebug
+#define MAC_ACCESSIBILTY_DEBUG if (0) QT_PREPEND_NAMESPACE(qDebug)
#endif
typedef QMap<QAccessible::Role, NSString *> QMacAccessibiltyRoleMap;
@@ -195,13 +195,13 @@ QT_END_NAMESPACE
- (BOOL)accessibilityIsIgnored
{
- QAInterface interface = interfaceForView(self);
+ QT_PREPEND_NAMESPACE(QAInterface) interface = QT_PREPEND_NAMESPACE(interfaceForView)(self);
return isInterfaceIgnored(interface);
}
- (NSArray *)accessibilityAttributeNames
{
- QAInterface interface = interfaceForView(self);
+ QT_PREPEND_NAMESPACE(QAInterface) interface = QT_PREPEND_NAMESPACE(interfaceForView)(self);
static NSArray *attributes = nil;
if (attributes == nil) {
@@ -213,9 +213,10 @@ QT_END_NAMESPACE
- (id)accessibilityAttributeValue:(NSString *)attribute
{
- MAC_ACCESSIBILTY_DEBUG() << "accessibilityAttributeValue" << self << QCFString::toQString(reinterpret_cast<CFStringRef>(attribute));
+ MAC_ACCESSIBILTY_DEBUG() << "accessibilityAttributeValue" << self <<
+ QT_PREPEND_NAMESPACE(QCFString)::toQString(reinterpret_cast<CFStringRef>(attribute));
- QAInterface interface = interfaceForView(self);
+ QT_PREPEND_NAMESPACE(QAInterface) interface = QT_PREPEND_NAMESPACE(interfaceForView)(self);
// Switch on the attribute name and call the appropriate handler function.
// Pass the call on to the NSView class for attributes we don't handle.
diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp
index a6aef52..50644ff 100644
--- a/src/gui/effects/qgraphicseffect.cpp
+++ b/src/gui/effects/qgraphicseffect.cpp
@@ -61,15 +61,17 @@
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
+ \img graphicseffect-effects.png
+ \img graphicseffect-widget.png
For more information on how to use each effect, refer to the specific
effect's documentation.
@@ -108,33 +110,41 @@ QT_BEGIN_NAMESPACE
/*!
\class QGraphicsEffectSource
- \brief The QGraphicsEffectSource represents the source on which a
+ \brief The QGraphicsEffectSource class represents the source on which a
QGraphicsEffect is installed on.
\since 4.6
- When a QGraphicsEffect is installed on a QGraphicsItem, for example, 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()
@@ -145,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()
*/
@@ -155,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()
*/
@@ -166,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()
*/
@@ -177,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()
*/
@@ -188,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()
{
@@ -215,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
{
@@ -227,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()
*/
@@ -268,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()
*/
@@ -300,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
{
@@ -330,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()
*/
@@ -347,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.
@@ -365,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
*/
@@ -387,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.
*/
@@ -410,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);
@@ -443,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);
@@ -492,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);
@@ -515,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
{
@@ -546,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);
@@ -569,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)
@@ -592,6 +641,9 @@ static inline void pixelize(QImage *image, int pixelSize)
}
}
+/*!
+ \reimp
+*/
void QGraphicsPixelizeEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
{
Q_D(QGraphicsPixelizeEffect);
@@ -624,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.
- \sa setBlurRadius(), blurRadiusChanged()
+ Using a smaller radius results in a sharper appearance, whereas a bigger
+ radius results in a more blurred appearance.
+
+ By default, the blur radius is 5 pixels.
*/
int QGraphicsBlurEffect::blurRadius() const
{
@@ -656,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);
@@ -679,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);
@@ -717,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
{
@@ -746,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);
@@ -766,12 +843,19 @@ void QGraphicsDropShadowEffect::setOffset(const QPointF &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
{
@@ -779,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);
@@ -803,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
{
@@ -816,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);
@@ -835,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);
@@ -872,25 +954,44 @@ 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.
+
+ \sa setOpacityMask()
*/
qreal QGraphicsOpacityEffect::opacity() const
{
@@ -898,13 +999,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);
@@ -914,6 +1008,10 @@ void QGraphicsOpacityEffect::setOpacity(qreal opacity)
return;
d->opacity = opacity;
+ if ((d->isFullyTransparent = qFuzzyIsNull(d->opacity)))
+ d->isFullyOpaque = 0;
+ else
+ d->isFullyOpaque = qFuzzyIsNull(d->opacity - 1);
emit opacityChanged(opacity);
}
@@ -921,18 +1019,61 @@ 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.
*/
+/*!
+ \property QGraphicsOpacityEffect::opacityMask
+ \brief the opacity mask of the effect.
+
+ An opacity mask allows you apply opacity to portions of an element.
+
+ For example:
+
+ \snippet doc/src/snippets/code/src_gui_effects_qgraphicseffect.cpp 2
+
+ There is no opacity mask by default.
+
+ \sa setOpacity()
+*/
+QBrush QGraphicsOpacityEffect::opacityMask() const
+{
+ Q_D(const QGraphicsOpacityEffect);
+ return d->opacityMask;
+}
+
+void QGraphicsOpacityEffect::setOpacityMask(const QBrush &mask)
+{
+ Q_D(QGraphicsOpacityEffect);
+ if (d->opacityMask == mask)
+ return;
+
+ d->opacityMask = mask;
+ d->hasOpacityMask = (mask.style() != Qt::NoBrush);
+
+ emit opacityMaskChanged(mask);
+}
+
+/*!
+ \fn void QGraphicsOpacityEffect::opacityMaskChanged(const QBrush &mask)
+
+ This signal is emitted whenever the effect's opacity mask changes.
+ The \a mask parameter holds the effect's new opacity mask.
+*/
+
+/*!
+ \reimp
+*/
void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *source)
{
Q_D(QGraphicsOpacityEffect);
// Transparent; nothing to draw.
- if (qFuzzyIsNull(d->opacity))
+ if (d->isFullyTransparent)
return;
// Opaque; draw directly without going through a pixmap.
- if (qFuzzyIsNull(d->opacity - 1)) {
+ if (d->isFullyOpaque && !d->hasOpacityMask) {
source->draw(painter);
return;
}
@@ -943,13 +1084,55 @@ void QGraphicsOpacityEffect::draw(QPainter *painter, QGraphicsEffectSource *sour
QPoint offset;
if (source->isPixmap()) {
// No point in drawing in device coordinates (pixmap will be scaled anyways).
- const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset);
- painter->drawPixmap(offset, pixmap);
+ if (!d->hasOpacityMask) {
+ const QPixmap pixmap = source->pixmap(Qt::LogicalCoordinates, &offset);
+ painter->drawPixmap(offset, pixmap);
+ } else {
+ QRectF srcBrect = source->boundingRect();
+ QPixmap pixmap(srcBrect.size().toSize());
+ pixmap.fill(Qt::transparent);
+
+ QPainter pixmapPainter(&pixmap);
+ pixmapPainter.setRenderHints(painter->renderHints());
+ pixmapPainter.translate(-srcBrect.topLeft());
+ source->draw(&pixmapPainter);
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ pixmapPainter.fillRect(srcBrect, d->opacityMask);
+ pixmapPainter.end();
+
+ painter->drawPixmap(srcBrect.topLeft(), pixmap);
+ }
} else {
// Draw pixmap in device coordinates to avoid pixmap scaling;
- const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
- painter->setWorldTransform(QTransform());
- painter->drawPixmap(offset, pixmap);
+ if (!d->hasOpacityMask) {
+ const QPixmap pixmap = source->pixmap(Qt::DeviceCoordinates, &offset);
+ painter->setWorldTransform(QTransform());
+ painter->drawPixmap(offset, pixmap);
+ } else {
+ QTransform worldTransform = painter->worldTransform();
+
+ // Calculate source bounding rect in logical and device coordinates.
+ QRectF srcBrect = source->boundingRect();
+ QRect srcDeviceBrect = worldTransform.mapRect(srcBrect).toAlignedRect();
+ srcDeviceBrect &= source->deviceRect();
+
+ offset = srcDeviceBrect.topLeft();
+ worldTransform *= QTransform::fromTranslate(-srcDeviceBrect.x(), -srcDeviceBrect.y());
+
+ QPixmap pixmap(srcDeviceBrect.size());
+ pixmap.fill(Qt::transparent);
+
+ QPainter pixmapPainter(&pixmap);
+ pixmapPainter.setRenderHints(painter->renderHints());
+ pixmapPainter.setWorldTransform(worldTransform);
+ source->draw(&pixmapPainter);
+ pixmapPainter.setCompositionMode(QPainter::CompositionMode_DestinationIn);
+ pixmapPainter.fillRect(srcBrect, d->opacityMask);
+ pixmapPainter.end();
+
+ painter->setWorldTransform(QTransform());
+ painter->drawPixmap(offset, pixmap);
+ }
}
painter->restore();
diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h
index fef6531..a53357b 100644
--- a/src/gui/effects/qgraphicseffect.h
+++ b/src/gui/effects/qgraphicseffect.h
@@ -46,6 +46,7 @@
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
#include <QtGui/qcolor.h>
+#include <QtGui/qbrush.h>
QT_BEGIN_HEADER
@@ -274,17 +275,21 @@ class Q_GUI_EXPORT QGraphicsOpacityEffect: public QGraphicsEffect
{
Q_OBJECT
Q_PROPERTY(int opacity READ opacity WRITE setOpacity NOTIFY opacityChanged)
+ Q_PROPERTY(QBrush opacityMask READ opacityMask WRITE setOpacityMask NOTIFY opacityMaskChanged)
public:
QGraphicsOpacityEffect(QObject *parent = 0);
~QGraphicsOpacityEffect();
qreal opacity() const;
+ QBrush opacityMask() const;
public Q_SLOTS:
void setOpacity(qreal opacity);
+ void setOpacityMask(const QBrush &mask);
Q_SIGNALS:
void opacityChanged(qreal opacity);
+ void opacityMaskChanged(const QBrush &mask);
protected:
void draw(QPainter *painter, QGraphicsEffectSource *source);
diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h
index 175bd99..c902b67 100644
--- a/src/gui/effects/qgraphicseffect_p.h
+++ b/src/gui/effects/qgraphicseffect_p.h
@@ -164,10 +164,15 @@ class QGraphicsOpacityEffectPrivate : public QGraphicsEffectPrivate
{
Q_DECLARE_PUBLIC(QGraphicsOpacityEffect)
public:
- QGraphicsOpacityEffectPrivate() : opacity(0.7) {}
+ QGraphicsOpacityEffectPrivate()
+ : opacity(qreal(0.7)), isFullyTransparent(0), isFullyOpaque(0), hasOpacityMask(0) {}
~QGraphicsOpacityEffectPrivate() {}
qreal opacity;
+ QBrush opacityMask;
+ uint isFullyTransparent : 1;
+ uint isFullyOpaque : 1;
+ uint hasOpacityMask : 1;
};
QT_END_NAMESPACE
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..95561b7 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.
@@ -83,6 +84,10 @@
QT_BEGIN_NAMESPACE
+/*!
+ Constructs a QGraphicsAnchorLayout instance. \a parent is passed to
+ QGraphicsLayout's constructor.
+ */
QGraphicsAnchorLayout::QGraphicsAnchorLayout(QGraphicsLayoutItem *parent)
: QGraphicsLayout(*new QGraphicsAnchorLayoutPrivate(), parent)
{
@@ -90,6 +95,9 @@ QGraphicsAnchorLayout::QGraphicsAnchorLayout(QGraphicsLayoutItem *parent)
d->createLayoutEdges();
}
+/*!
+ Destroys the QGraphicsAnchorLayout object.
+*/
QGraphicsAnchorLayout::~QGraphicsAnchorLayout()
{
Q_D(QGraphicsAnchorLayout);
@@ -187,32 +195,41 @@ void QGraphicsAnchorLayout::addCornerAnchors(QGraphicsLayoutItem *firstItem,
}
/*!
- \fn QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstEdge, QGraphicsLayoutItem *secondEdge)
+ \fn QGraphicsAnchorLayout::addLeftAndRightAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem)
+
+ Anchors the left and right edges of \a firstItem to the same edges of
+ \a secondItem.
This convenience function is equivalent to calling
\code
- l->addAnchor(firstEdge, Qt::AnchorLeft, secondEdge, Qt::AnchorLeft);
- l->addAnchor(firstEdge, Qt::AnchorRight, secondEdge, Qt::AnchorRight);
+ l->addAnchor(firstItem, Qt::AnchorLeft, secondItem, Qt::AnchorLeft);
+ l->addAnchor(firstItem, Qt::AnchorRight, secondItem, Qt::AnchorRight);
\endcode
*/
/*!
- \fn QGraphicsAnchorLayout::addTopAndBottomAnchors(QGraphicsLayoutItem *firstEdge, QGraphicsLayoutItem *secondEdge)
+ \fn QGraphicsAnchorLayout::addTopAndBottomAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem)
+
+ Anchors the top and bottom edges of \a firstItem to the same edges of
+ \a secondItem.
This convenience function is equivalent to calling
\code
- l->addAnchor(firstEdge, Qt::AnchorTop, secondEdge, Qt::AnchorTop);
- l->addAnchor(firstEdge, Qt::AnchorBottom, secondEdge, Qt::AnchorBottom);
+ l->addAnchor(firstItem, Qt::AnchorTop, secondItem, Qt::AnchorTop);
+ l->addAnchor(firstItem, Qt::AnchorBottom, secondItem, Qt::AnchorBottom);
\endcode
*/
/*!
- \fn QGraphicsAnchorLayout::addAllAnchors(QGraphicsLayoutItem *firstEdge, QGraphicsLayoutItem *secondEdge)
+ \fn QGraphicsAnchorLayout::addAllAnchors(QGraphicsLayoutItem *firstItem, QGraphicsLayoutItem *secondItem)
+
+ Anchors all edges (left, right, top and bottom) of \a firstItem to the same edges of
+ \a secondItem.
This convenience function is equivalent to calling
\code
- l->addLeftAndRightAnchors(firstEdge, secondEdge);
- l->addTopAndBottomAnchors(firstEdge, secondEdge);
+ l->addLeftAndRightAnchors(firstItem, secondItem);
+ l->addTopAndBottomAnchors(firstItem, secondItem);
\endcode
*/
@@ -228,6 +245,7 @@ void QGraphicsAnchorLayout::setAnchorSpacing(const QGraphicsLayoutItem *firstIte
if (!d->setAnchorSize(firstItem, firstEdge, secondItem, secondEdge, &spacing)) {
qWarning("setAnchorSpacing: The anchor does not exist.");
+ return;
}
invalidate();
}
@@ -369,7 +387,12 @@ void QGraphicsAnchorLayout::setGeometry(const QRectF &geom)
}
/*!
+ Removes the layout item at \a index without destroying it. Ownership of
+ the item is transferred to the caller.
+
Removing an item will also remove any of the anchors associated with it.
+
+ \sa itemAt(), count()
*/
void QGraphicsAnchorLayout::removeAt(int index)
{
diff --git a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
index c965712..d4afa5b 100644
--- a/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
+++ b/src/gui/graphicsview/qgraphicsanchorlayout_p.cpp
@@ -554,7 +554,7 @@ bool QGraphicsAnchorLayoutPrivate::simplifyGraphIteration(QGraphicsAnchorLayoutP
qDebug("candidate list for sequential simplification:\n[%s]", qPrintable(strPath));
#endif
- bool forward;
+ bool forward = true;
AnchorVertex *prev = beforeSequence;
int intervalFrom = 0;
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index ead5aee..e1e95b1 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -331,6 +331,13 @@
\value ItemNegativeZStacksBehindParent The item automatically stacks behind
it's parent if it's z-value is negative. This flag enables setZValue() to
toggle ItemStacksBehindParent.
+
+ \value ItemIsPanel. The item is a panel. A panel provides activation and
+ contained focus handling. Only one panel can be active at a time (see
+ QGraphicsItem::isActive()). When no panel is active, QGraphicsScene
+ activates all non-panel items. Window items (i.e.,
+ QGraphicsItem::isWindow() returns true) are panels. This flag was
+ introduced in Qt 4.6.
*/
/*!
@@ -1341,14 +1348,29 @@ QGraphicsWidget *QGraphicsItem::topLevelWidget() const
*/
QGraphicsWidget *QGraphicsItem::window() const
{
- if (isWidget() && static_cast<const QGraphicsWidget *>(this)->isWindow())
- return static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this));
- if (QGraphicsWidget *parent = parentWidget())
- return parent->window();
+ QGraphicsItem *p = panel();
+ if (p && p->isWindow())
+ return static_cast<QGraphicsWidget *>(p);
return 0;
}
/*!
+ \since 4.6
+
+ Returns the item's panel, or 0 if this item does not have a panel. If the
+ item is a panel, it will return itself. Otherwise it will return the
+ closest ancestor that is a panel.
+
+ \sa isPanel(), ItemIsPanel
+*/
+QGraphicsItem *QGraphicsItem::panel() const
+{
+ if (d_ptr->flags & ItemIsPanel)
+ return const_cast<QGraphicsItem *>(this);
+ return d_ptr->parent ? d_ptr->parent->panel() : 0;
+}
+
+/*!
\since 4.6
Return the graphics item cast to a QGraphicsObject, if the class is actually a
@@ -1434,6 +1456,17 @@ bool QGraphicsItem::isWindow() const
}
/*!
+ \since 4.6
+ Returns true if the item is a panel; otherwise returns false.
+
+ \sa QGraphicsItem::panel(), ItemIsPanel
+*/
+bool QGraphicsItem::isPanel() const
+{
+ return d_ptr->flags & ItemIsPanel;
+}
+
+/*!
Returns this item's flags. The flags describe what configurable features
of the item are enabled and not. For example, if the flags include
ItemIsFocusable, the item can accept input focus.
@@ -1496,6 +1529,9 @@ static void _q_qgraphicsItemSetFlag(QGraphicsItem *item, QGraphicsItem::Graphics
*/
void QGraphicsItem::setFlags(GraphicsItemFlags flags)
{
+ if (isWindow())
+ flags |= ItemIsPanel;
+
// Notify change and check for adjustment.
if (quint32(d_ptr->flags) == quint32(flags))
return;
@@ -1850,16 +1886,16 @@ void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, bo
q->ungrabKeyboard();
}
if (q_ptr->hasFocus() && scene) {
- // Hiding the closest non-window ancestor of the focus item
+ // Hiding the closest non-panel ancestor of the focus item
QGraphicsItem *focusItem = scene->focusItem();
bool clear = true;
- if (isWidget && !focusItem->isWindow()) {
+ if (isWidget && !focusItem->isPanel()) {
do {
if (focusItem == q_ptr) {
clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
break;
}
- } while ((focusItem = focusItem->parentWidget()) && !focusItem->isWindow());
+ } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
}
if (clear)
q_ptr->clearFocus();
@@ -1981,17 +2017,17 @@ void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bo
if (scene && scene->mouseGrabberItem() == q_ptr)
q_ptr->ungrabMouse();
if (q_ptr->hasFocus()) {
- // Disabling the closest non-window ancestor of the focus item
+ // Disabling the closest non-panel ancestor of the focus item
// causes focus to pop to the next item, otherwise it's cleared.
QGraphicsItem *focusItem = scene->focusItem();
bool clear = true;
- if (isWidget && !focusItem->isWindow() && q_ptr->isAncestorOf(focusItem)) {
+ if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) {
do {
if (focusItem == q_ptr) {
clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
break;
}
- } while ((focusItem = focusItem->parentWidget()) && !focusItem->isWindow());
+ } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
}
if (clear)
q_ptr->clearFocus();
@@ -2588,12 +2624,33 @@ void QGraphicsItem::setHandlesChildEvents(bool enabled)
d_ptr->handlesChildEvents = enabled;
d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
}
+/*!
+ \since 4.6
+ Returns true if this item is active; otherwise returns false.
+
+ An item can only be active if the scene is active. An item is active
+ if it is, or is a descendent of, an active panel. Items in non-active
+ panels are not active.
+
+ Items that are not part of a panel follow scene activation when the
+ scene has no active panel.
+
+ Only active items can gain input focus.
+
+ \sa QGraphicsScene::isActive(), QGraphicsScene::activePanel(), panel(), isPanel()
+*/
+bool QGraphicsItem::isActive() const
+{
+ if (!d_ptr->scene || !d_ptr->scene->isActive())
+ return false;
+ return panel() == d_ptr->scene->activePanel();
+}
/*!
- Returns true if this item or its \l{focusProxy()}{focus proxy} has keyboard
- input focus; otherwise, returns false.
+ Returns true if this item is active, and it or its \l{focusProxy()}{focus
+ proxy} has keyboard input focus; otherwise, returns false.
- \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem()
+ \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem(), isActive()
*/
bool QGraphicsItem::hasFocus() const
{
@@ -2610,9 +2667,10 @@ bool QGraphicsItem::hasFocus() const
Only enabled items that set the ItemIsFocusable flag can accept keyboard
focus.
- If this item is not visible, or not associated with a scene, it will not
- gain immediate input focus. However, it will be registered as the preferred
- focus item for its subtree of items, should it later become visible.
+ If this item is not visible, not active, or not associated with a scene,
+ it will not gain immediate input focus. However, it will be registered as
+ the preferred focus item for its subtree of items, should it later become
+ visible.
As a result of calling this function, this item will receive a
\l{focusInEvent()}{focus in event} with \a focusReason. If another item
@@ -2655,8 +2713,8 @@ void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
}
d_ptr->setItemFocusedInScope(false);
- QGraphicsWidget *w = window();
- if (!w || w->isActiveWindow()) {
+ QGraphicsItem *p = panel();
+ if (!p || p->isActive()) {
// Visible items immediately gain focus from scene.
d_ptr->scene->d_func()->setFocusItemHelper(f, focusReason);
}
@@ -2668,8 +2726,8 @@ void QGraphicsItem::setFocus(Qt::FocusReason focusReason)
/*!
Takes keyboard input focus from the item.
- If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this item
- to tell it that it is about to lose the focus.
+ If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this
+ item to tell it that it is about to lose the focus.
Only items that set the ItemIsFocusable flag, or widgets that set an
appropriate focus policy, can accept keyboard focus.
@@ -4783,7 +4841,7 @@ void QGraphicsItemPrivate::setSubFocus()
bool hidden = !visible;
do {
parent->d_func()->subFocusItem = item;
- } while (!parent->isWindow() && (parent = parent->d_ptr->parent) && (!hidden || !parent->d_func()->visible) && !(parent->d_ptr->flags & QGraphicsItem::ItemIsFocusScope));
+ } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (!hidden || !parent->d_func()->visible) && !(parent->d_ptr->flags & QGraphicsItem::ItemIsFocusScope));
}
/*!
@@ -4797,7 +4855,7 @@ void QGraphicsItemPrivate::clearSubFocus()
if (parent->d_ptr->subFocusItem != q_ptr)
break;
parent->d_ptr->subFocusItem = 0;
- } while (!parent->isWindow() && (parent = parent->d_ptr->parent));
+ } while (!parent->isPanel() && (parent = parent->d_ptr->parent));
}
/*!
@@ -6048,6 +6106,17 @@ bool QGraphicsItem::sceneEvent(QEvent *event)
case QEvent::InputMethod:
inputMethodEvent(static_cast<QInputMethodEvent *>(event));
break;
+ case QEvent::WindowActivate:
+ case QEvent::WindowDeactivate:
+ // Propagate panel activation.
+ if (d_ptr->scene) {
+ for (int i = 0; i < d_ptr->children.size(); ++i) {
+ QGraphicsItem *child = d_ptr->children.at(i);
+ if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
+ d_ptr->scene->sendEvent(child, event);
+ }
+ }
+ break;
default:
return false;
}
@@ -10214,10 +10283,8 @@ void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)
info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform,
info->drawItem);
} else {
- QTransform effectTransform = painter->worldTransform();
- effectTransform *= info->painter->worldTransform().inverted();
- if (info->effectTransform)
- effectTransform *= *info->effectTransform;
+ QTransform effectTransform = info->painter->worldTransform().inverted();
+ effectTransform *= painter->worldTransform();
scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
info->drawItem);
@@ -10453,6 +10520,9 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)
case QGraphicsItem::ItemIsFocusScope:
str = "ItemIsFocusScope";
break;
+ case QGraphicsItem::ItemIsPanel:
+ str = "ItemIsPanel";
+ break;
}
debug << str;
return debug;
@@ -10462,7 +10532,7 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags)
{
debug << '(';
bool f = false;
- for (int i = 0; i < 9; ++i) {
+ for (int i = 0; i < 16; ++i) {
if (flags & (1 << i)) {
if (f)
debug << '|';
diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h
index b76f5ac..59659c9 100644
--- a/src/gui/graphicsview/qgraphicsitem.h
+++ b/src/gui/graphicsview/qgraphicsitem.h
@@ -103,8 +103,9 @@ public:
ItemHasNoContents = 0x400,
ItemSendsGeometryChanges = 0x800,
ItemAcceptsInputMethod = 0x1000,
+ ItemIsFocusScope = 0x2000,
ItemNegativeZStacksBehindParent = 0x4000,
- ItemIsFocusScope = 0x8000
+ ItemIsPanel = 0x8000
// NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag.
};
Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag)
@@ -161,11 +162,13 @@ public:
QGraphicsWidget *parentWidget() const;
QGraphicsWidget *topLevelWidget() const;
QGraphicsWidget *window() const;
+ QGraphicsItem *panel() const;
void setParentItem(QGraphicsItem *parent);
QList<QGraphicsItem *> children() const; // ### obsolete
QList<QGraphicsItem *> childItems() const;
bool isWidget() const;
bool isWindow() const;
+ bool isPanel() const;
QGraphicsObject *toGraphicsObject();
const QGraphicsObject *toGraphicsObject() const;
@@ -231,6 +234,7 @@ public:
bool handlesChildEvents() const;
void setHandlesChildEvents(bool enabled);
+ bool isActive() const;
bool hasFocus() const;
void setFocus(Qt::FocusReason focusReason = Qt::OtherFocusReason);
void clearFocus();
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index 7abd7f5..60db4a7 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.
//
@@ -498,7 +498,7 @@ public:
quint32 needSortChildren : 1;
quint32 allChildrenDirty : 1;
- // New 32 bits
+ // Packed 32 bits
quint32 fullUpdatePending : 1;
quint32 flags : 16;
quint32 dirtyChildrenBoundingRect : 1;
@@ -516,8 +516,10 @@ public:
quint32 notifyBoundingRectChanged : 1;
quint32 notifyInvalidated : 1;
quint32 mouseSetsFocus : 1;
+
+ // New 32 bits
quint32 itemIsFocusedInScope : 1;
- quint32 unused : 1; // feel free to use
+ quint32 unused : 31; // feel free to use
// Optional stacking order
int globalStackingOrder;
diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/gui/graphicsview/qgraphicslayout.cpp
index 58c174c..df6be90 100644
--- a/src/gui/graphicsview/qgraphicslayout.cpp
+++ b/src/gui/graphicsview/qgraphicslayout.cpp
@@ -390,8 +390,10 @@ void QGraphicsLayout::widgetEvent(QEvent *e)
QGraphicsLayout to return a pointer to the item at index \a i. The
reimplementation can assume that \a i is valid (i.e., it respects the
value of count()).
+ Together with count(), it is provided as a means of iterating over all items in a layout.
- The subclass is free to decide how to store the items.
+ The subclass is free to decide how to store the items, and the visual arrangement
+ does not have to be reflected through this function.
\sa count(), removeAt()
*/
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/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp
index 185780a..1b271e5 100644
--- a/src/gui/graphicsview/qgraphicslinearlayout.cpp
+++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp
@@ -277,7 +277,7 @@ void QGraphicsLinearLayout::insertItem(int index, QGraphicsLayoutItem *item)
Q_ASSERT(item);
d->fixIndex(&index);
d->engine.insertRow(index, d->orientation);
- new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index));
+ new QGridLayoutItem(&d->engine, item, d->gridRow(index), d->gridColumn(index), 1, 1, 0, index);
invalidate();
}
@@ -471,6 +471,7 @@ int QGraphicsLinearLayout::count() const
/*!
\reimp
+ When iterating from 0 and up, it will return the items in the visual arranged order.
*/
QGraphicsLayoutItem *QGraphicsLinearLayout::itemAt(int index) const
{
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.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index af137e7..3efb511 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -288,7 +288,8 @@ QGraphicsScenePrivate::QGraphicsScenePrivate()
focusItem(0),
lastFocusItem(0),
tabFocusFirst(0),
- activeWindow(0),
+ activePanel(0),
+ lastActivePanel(0),
activationRefCount(0),
lastMouseGrabberItem(0),
lastMouseGrabberItemHasImplicitMouseGrab(false),
@@ -516,10 +517,12 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item)
focusItem = 0;
if (item == lastFocusItem)
lastFocusItem = 0;
- if (item == activeWindow) {
+ if (item == activePanel) {
// ### deactivate...
- activeWindow = 0;
+ activePanel = 0;
}
+ if (item == lastActivePanel)
+ lastActivePanel = 0;
// Disable selectionChanged() for individual items
++selectionChanging;
@@ -672,8 +675,8 @@ void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDyin
if (focusItem && popupWidgets.isEmpty()) {
QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason);
sendEvent(focusItem, &event);
- } else {
- ungrabKeyboard((QGraphicsItem *)widget, itemIsDying);
+ } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) {
+ ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying);
}
if (!itemIsDying && widget->isVisible()) {
widget->hide();
@@ -1078,8 +1081,9 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
}
// Update window activation.
- QGraphicsWidget *newActiveWindow = windowForItem(cachedItemsUnderMouse.value(0));
- if (newActiveWindow != activeWindow)
+ QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);
+ QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0;
+ if (newActiveWindow != q->activeWindow())
q->setActiveWindow(newActiveWindow);
// Set focus on the topmost enabled item that can take focus.
@@ -1114,7 +1118,7 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
// check if the item we are sending to are disabled (before we send the event)
bool disabled = !item->isEnabled();
- bool isWindow = item->isWindow();
+ bool isPanel = item->isPanel();
if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick
&& item != lastMouseGrabberItem && lastMouseGrabberItem) {
// If this item is different from the item that received the last
@@ -1155,8 +1159,8 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
}
ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
- // Don't propagate through windows.
- if (isWindow)
+ // Don't propagate through panels.
+ if (isPanel)
break;
}
@@ -1178,18 +1182,6 @@ void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mou
}
}
-QGraphicsWidget *QGraphicsScenePrivate::windowForItem(const QGraphicsItem *item) const
-{
- if (!item)
- return 0;
- do {
- if (item->isWidget())
- return static_cast<const QGraphicsWidget *>(item)->window();
- item = item->parentItem();
- } while (item);
- return 0;
-}
-
/*!
\internal
@@ -2236,6 +2228,9 @@ void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group)
moved to this scene), QGraphicsScene will send an addition notification as
the item is removed from its previous scene.
+ If the item is a panel, the scene is active, and there is no active panel
+ in the scene, then the item will be activated.
+
\sa removeItem(), addEllipse(), addLine(), addPath(), addPixmap(),
addRect(), addText(), addWidget()
*/
@@ -2368,9 +2363,9 @@ void QGraphicsScenePrivate::addItem(QGraphicsItem *item,
// Deliver post-change notification
item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
- // Auto-activate the first inactive window if the scene is active.
- if (activationRefCount > 0 && !activeWindow && item->isWindow())
- q->setActiveWindow(static_cast<QGraphicsWidget *>(item));
+ // Auto-activate the first inactive panel if the scene is active.
+ if (q->isActive() && !activePanel && item->isPanel())
+ q->setActivePanel(item);
// Ensure that newly added items that have subfocus set, gain
// focus automatically if there isn't a focus item already.
@@ -3143,40 +3138,43 @@ bool QGraphicsScene::event(QEvent *event)
case QEvent::InputMethod:
inputMethodEvent(static_cast<QInputMethodEvent *>(event));
break;
- case QEvent::WindowActivate: {
+ case QEvent::WindowActivate:
if (!d->activationRefCount++) {
- // Notify all non-window widgets.
- foreach (QGraphicsItem *item, items()) {
- if (item->isWidget() && item->isVisible() && !item->isWindow() && !item->parentWidget()) {
- QEvent event(QEvent::WindowActivate);
- QApplication::sendEvent(static_cast<QGraphicsWidget *>(item), &event);
+ if (d->lastActivePanel) {
+ // Activate the last panel.
+ setActivePanel(d->lastActivePanel);
+ } else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) {
+ // Activate the panel of the first item in the tab focus
+ // chain.
+ setActivePanel(d->tabFocusFirst);
+ } else {
+ // Activate all toplevel items.
+ QEvent event(QEvent::WindowActivate);
+ foreach (QGraphicsItem *item, items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ sendEvent(item, &event);
}
}
-
- // Restore window activation.
- QGraphicsItem *nextFocusItem = d->focusItem ? d->focusItem : d->lastFocusItem;
- if (nextFocusItem && nextFocusItem->window())
- setActiveWindow(static_cast<QGraphicsWidget *>(nextFocusItem));
- else if (d->tabFocusFirst && d->tabFocusFirst->isWindow())
- setActiveWindow(d->tabFocusFirst);
}
break;
- }
- case QEvent::WindowDeactivate: {
+ case QEvent::WindowDeactivate:
if (!--d->activationRefCount) {
- // Remove window activation.
- setActiveWindow(0);
-
- // Notify all non-window widgets.
- foreach (QGraphicsItem *item, items()) {
- if (item->isWidget() && item->isVisible() && !item->isWindow() && !item->parentWidget()) {
- QEvent event(QEvent::WindowDeactivate);
- QApplication::sendEvent(static_cast<QGraphicsWidget *>(item), &event);
+ if (d->activePanel) {
+ // Deactivate the active panel (but keep it so we can
+ // reactivate it later).
+ QGraphicsItem *lastActivePanel = d->activePanel;
+ setActivePanel(0);
+ d->lastActivePanel = lastActivePanel;
+ } else {
+ // Activate all toplevel items.
+ QEvent event(QEvent::WindowDeactivate);
+ foreach (QGraphicsItem *item, items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ sendEvent(item, &event);
}
}
}
break;
- }
case QEvent::ApplicationFontChange: {
// Resolve the existing scene font.
d->resolveFont();
@@ -3539,8 +3537,8 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.last()) : 0;
while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
commonAncestorItem = commonAncestorItem->parentItem();
- if (commonAncestorItem && commonAncestorItem->window() != item->window()) {
- // The common ancestor isn't in the same window as the two hovered
+ if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
+ // The common ancestor isn't in the same panel as the two hovered
// items.
commonAncestorItem = 0;
}
@@ -3561,8 +3559,8 @@ bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEv
QGraphicsItem *parent = item;
while (parent && parent != commonAncestorItem) {
parents.prepend(parent);
- if (parent->isWindow()) {
- // Stop at the window - we don't deliver beyond this point.
+ if (parent->isPanel()) {
+ // Stop at the panel - we don't deliver beyond this point.
break;
}
parent = parent->parentItem();
@@ -3639,7 +3637,7 @@ void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent)
// is filtered out, stop propagating it.
if (!d->sendEvent(p, keyEvent))
break;
- } while (!keyEvent->isAccepted() && !p->isWindow() && (p = p->parentItem()));
+ } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
} else {
keyEvent->ignore();
}
@@ -3669,7 +3667,7 @@ void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent)
// is filtered out, stop propagating it.
if (!d->sendEvent(p, keyEvent))
break;
- } while (!keyEvent->isAccepted() && !p->isWindow() && (p = p->parentItem()));
+ } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
} else {
keyEvent->ignore();
}
@@ -3831,9 +3829,9 @@ void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent)
wheelEvent->setPos(item->d_ptr->genericMapFromScene(wheelEvent->scenePos(),
wheelEvent->widget()));
wheelEvent->accept();
- bool isWindow = item->isWindow();
+ bool isPanel = item->isPanel();
d->sendEvent(item, wheelEvent);
- if (isWindow || wheelEvent->isAccepted())
+ if (isPanel || wheelEvent->isAccepted())
break;
}
}
@@ -4892,7 +4890,7 @@ bool QGraphicsScene::focusNextPrevChild(bool next)
if (widget->flags() & QGraphicsItem::ItemIsFocusable
&& widget->isEnabled() && widget->isVisibleTo(0)
&& (widget->focusPolicy() & Qt::TabFocus)
- && (!item || !item->isWindow() || item->isAncestorOf(widget))
+ && (!item || !item->isPanel() || item->isAncestorOf(widget))
) {
setFocusItem(widget, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
return true;
@@ -5079,84 +5077,150 @@ void QGraphicsScene::setPalette(const QPalette &palette)
}
/*!
- \since 4.4
+ \since 4.6
- Returns the current active window, or 0 if there is no window is currently
- active.
+ Returns true if the scene is active (e.g., it's viewed by
+ at least one QGraphicsView that is active); otherwise returns false.
- \sa QGraphicsScene::setActiveWindow()
+ \sa QGraphicsItem::isActive(), QWidget::isActiveWindow()
*/
-QGraphicsWidget *QGraphicsScene::activeWindow() const
+bool QGraphicsScene::isActive() const
{
Q_D(const QGraphicsScene);
- return d->activeWindow;
+ return d->activationRefCount > 0;
}
/*!
- \since 4.4
- Activates \a widget, which must be a widget in this scene. You can also
- pass 0 for \a widget, in which case QGraphicsScene will deactivate any
- currently active window.
+ \since 4.6
+ Returns the current active panel, or 0 if no panel is currently active.
- \sa activeWindow(), QGraphicsWidget::isActiveWindow()
+ \sa QGraphicsScene::setActivePanel()
*/
-void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget)
+QGraphicsItem *QGraphicsScene::activePanel() const
+{
+ Q_D(const QGraphicsScene);
+ return d->activePanel;
+}
+
+/*!
+ \since 4.6
+ Activates \a item, which must be an item in this scene. You
+ can also pass 0 for \a item, in which case QGraphicsScene will
+ deactivate any currently active panel.
+
+ \sa activePanel(), isActive(), QGraphicsItem::isActive()
+*/
+void QGraphicsScene::setActivePanel(QGraphicsItem *item)
{
Q_D(QGraphicsScene);
- if (widget && widget->scene() != this) {
- qWarning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene",
- widget);
+ if (item && item->scene() != this) {
+ qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene",
+ item);
return;
}
- // Activate the widget's window.
- QGraphicsWidget *window = widget ? widget->window() : 0;
- if (window == d->activeWindow)
+ // Find the item's panel.
+ QGraphicsItem *panel = item ? item->panel() : 0;
+ d->lastActivePanel = panel ? d->activePanel : 0;
+ if (panel == d->activePanel)
return;
- // Deactivate the last active window.
- if (d->activeWindow) {
- if (QGraphicsWidget *fw = d->activeWindow->focusWidget()) {
+ // Deactivate the last active panel.
+ if (d->activePanel) {
+ if (QGraphicsItem *fi = d->activePanel->focusItem()) {
// Remove focus from the current focus item.
- if (fw == focusItem())
+ if (fi == focusItem())
setFocusItem(0, Qt::ActiveWindowFocusReason);
}
QEvent event(QEvent::WindowDeactivate);
- QApplication::sendEvent(d->activeWindow, &event);
+ sendEvent(d->activePanel, &event);
+ } else if (panel) {
+ // Deactivate the scene if changing activation to a panel.
+ QEvent event(QEvent::WindowDeactivate);
+ foreach (QGraphicsItem *item, items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ sendEvent(item, &event);
+ }
}
// Update activate state.
- d->activeWindow = window;
+ d->activePanel = panel;
QEvent event(QEvent::ActivationChange);
QApplication::sendEvent(this, &event);
// Activate
- if (window) {
+ if (panel) {
QEvent event(QEvent::WindowActivate);
- QApplication::sendEvent(window, &event);
+ sendEvent(panel, &event);
+ // Set focus on the panel's focus item.
+ if (QGraphicsItem *focusItem = panel->focusItem())
+ focusItem->setFocus(Qt::ActiveWindowFocusReason);
+ } else if (isActive()) {
+ // Activate the scene
+ QEvent event(QEvent::WindowActivate);
+ foreach (QGraphicsItem *item, items()) {
+ if (item->isVisible() && !item->isPanel() && !item->parentItem())
+ sendEvent(item, &event);
+ }
+ }
+}
+
+/*!
+ \since 4.4
+
+ Returns the current active window, or 0 if there is no window is currently
+ active.
+
+ \sa QGraphicsScene::setActiveWindow()
+*/
+QGraphicsWidget *QGraphicsScene::activeWindow() const
+{
+ Q_D(const QGraphicsScene);
+ if (d->activePanel && d->activePanel->isWindow())
+ return static_cast<QGraphicsWidget *>(d->activePanel);
+ return 0;
+}
+
+/*!
+ \since 4.4
+ Activates \a widget, which must be a widget in this scene. You can also
+ pass 0 for \a widget, in which case QGraphicsScene will deactivate any
+ currently active window.
+
+ \sa activeWindow(), QGraphicsWidget::isActiveWindow()
+*/
+void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget)
+{
+ if (widget && widget->scene() != this) {
+ qWarning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene",
+ widget);
+ return;
+ }
+
+ // Activate the widget's panel (all windows are panels).
+ QGraphicsItem *panel = widget ? widget->panel() : 0;
+ setActivePanel(panel);
+
+ // Raise
+ if (panel) {
QList<QGraphicsItem *> siblingWindows;
- QGraphicsItem *parent = window->parentItem();
+ QGraphicsItem *parent = panel->parentItem();
// Raise ### inefficient for toplevels
foreach (QGraphicsItem *sibling, parent ? parent->children() : items()) {
- if (sibling != window && sibling->isWidget()
- && static_cast<QGraphicsWidget *>(sibling)->isWindow()) {
+ if (sibling != panel && sibling->isWindow())
siblingWindows << sibling;
- }
}
// Find the highest z value.
- qreal z = window->zValue();
+ qreal z = panel->zValue();
for (int i = 0; i < siblingWindows.size(); ++i)
z = qMax(z, siblingWindows.at(i)->zValue());
// This will probably never overflow.
const qreal litt = qreal(0.001);
- window->setZValue(z + litt);
-
- if (QGraphicsWidget *focusChild = window->focusWidget())
- focusChild->setFocus(Qt::ActiveWindowFocusReason);
+ panel->setZValue(z + litt);
}
}
diff --git a/src/gui/graphicsview/qgraphicsscene.h b/src/gui/graphicsview/qgraphicsscene.h
index 26cb1c2..9478879 100644
--- a/src/gui/graphicsview/qgraphicsscene.h
+++ b/src/gui/graphicsview/qgraphicsscene.h
@@ -243,6 +243,9 @@ public:
QPalette palette() const;
void setPalette(const QPalette &palette);
+ bool isActive() const;
+ QGraphicsItem *activePanel() const;
+ void setActivePanel(QGraphicsItem *item);
QGraphicsWidget *activeWindow() const;
void setActiveWindow(QGraphicsWidget *widget);
diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h
index 9e62901..def6f46 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.
//
@@ -131,7 +131,8 @@ public:
QGraphicsItem *focusItem;
QGraphicsItem *lastFocusItem;
QGraphicsWidget *tabFocusFirst;
- QGraphicsWidget *activeWindow;
+ QGraphicsItem *activePanel;
+ QGraphicsItem *lastActivePanel;
int activationRefCount;
void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason);
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/qgraphicssceneevent.cpp b/src/gui/graphicsview/qgraphicssceneevent.cpp
index 3ec14c3..afcc4e1 100644
--- a/src/gui/graphicsview/qgraphicssceneevent.cpp
+++ b/src/gui/graphicsview/qgraphicssceneevent.cpp
@@ -87,9 +87,11 @@
\since 4.2
\ingroup graphicsview-api
- When a QGraphicsView receives a QMouseEvent, it translates it to
- a QGraphicsSceneMouseEvent. The event is then forwarded to the
- QGraphicsScene associated with the view.
+ When a QGraphicsView receives a QMouseEvent, it translates it to a
+ QGraphicsSceneMouseEvent. The event is then forwarded to the
+ QGraphicsScene associated with the view. If the event is not
+ handled by the scene, the view may use it, e.g., for the
+ \l{QGraphicsView::}{DragMode}.
In addition to containing the item, scene, and screen coordinates
of the event (as pos(), scenePos(), and screenPos()), mouse
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.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 7f9fe65..40addf6 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -1285,10 +1285,6 @@ bool QGraphicsWidget::event(QEvent *event)
case QEvent::WindowActivate:
case QEvent::WindowDeactivate:
update();
- foreach (QGraphicsItem *child, childItems()) {
- if (child->isWidget())
- QApplication::sendEvent(static_cast<QGraphicsWidget *>(child), event);
- }
break;
// Taken from QWidget::event
case QEvent::ActivationChange:
@@ -1598,6 +1594,8 @@ void QGraphicsWidget::ungrabKeyboardEvent(QEvent *event)
/*!
Returns the widgets window type.
+
+ \sa windowFlags(), isWindow(), isPanel()
*/
Qt::WindowType QGraphicsWidget::windowType() const
{
@@ -1613,6 +1611,13 @@ Qt::WindowType QGraphicsWidget::windowType() const
is platform-dependent.
By default, this property contains no window flags.
+
+ Windows are panels. If you set the Qt::Window flag, the ItemIsPanel flag
+ will be set automatically. If you clear the Qt::Window flag, the
+ ItemIsPanel flag is also cleared. Note that the ItemIsPanel flag can be
+ set independently of Qt::Window.
+
+ \sa isWindow(), isPanel()
*/
Qt::WindowFlags QGraphicsWidget::windowFlags() const
{
@@ -1631,6 +1636,8 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
if (!d->setWindowFrameMargins)
unsetWindowFrameMargins();
+ setFlag(ItemIsPanel, d->windowFlags & Qt::Window);
+
bool isPopup = (d->windowFlags & Qt::WindowType_Mask) == Qt::Popup;
if (d->scene && isVisible() && wasPopup != isPopup) {
// Popup state changed; update implicit mouse grab.
@@ -1654,7 +1661,7 @@ void QGraphicsWidget::setWindowFlags(Qt::WindowFlags wFlags)
The active window is the window that either contains a child widget that
currently has input focus, or that itself has input focus.
- \sa QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow()
+ \sa QGraphicsScene::activeWindow(), QGraphicsScene::setActiveWindow(), isActive()
*/
bool QGraphicsWidget::isActiveWindow() const
{
@@ -1662,7 +1669,7 @@ bool QGraphicsWidget::isActiveWindow() const
if (!d->scene)
return false;
const QGraphicsWidget *w = window();
- return (!w && d->scene->d_func()->activationRefCount) || (w && d->scene->activeWindow() == w);
+ return (!w && d->scene->isActive()) || (w && d->scene->activeWindow() == w);
}
/*!
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/qgridlayoutengine.cpp b/src/gui/graphicsview/qgridlayoutengine.cpp
index 5ad6ac9..beb9cb0 100644
--- a/src/gui/graphicsview/qgridlayoutengine.cpp
+++ b/src/gui/graphicsview/qgridlayoutengine.cpp
@@ -461,7 +461,7 @@ void QGridLayoutRowData::dump(int indent) const
QGridLayoutItem::QGridLayoutItem(QGridLayoutEngine *engine, QGraphicsLayoutItem *layoutItem,
int row, int column, int rowSpan, int columnSpan,
- Qt::Alignment alignment)
+ Qt::Alignment alignment, int itemAtIndex)
: q_engine(engine), q_layoutItem(layoutItem), q_alignment(alignment)
{
q_firstRows[Hor] = column;
@@ -471,7 +471,7 @@ QGridLayoutItem::QGridLayoutItem(QGridLayoutEngine *engine, QGraphicsLayoutItem
q_stretches[Hor] = -1;
q_stretches[Ver] = -1;
- q_engine->addItem(this);
+ q_engine->insertItem(this, itemAtIndex);
}
int QGridLayoutItem::firstRow(Qt::Orientation orientation) const
@@ -937,11 +937,20 @@ Qt::Alignment QGridLayoutEngine::effectiveAlignment(const QGridLayoutItem *layou
return align;
}
-void QGridLayoutEngine::addItem(QGridLayoutItem *item)
+/*!
+ \internal
+ The \a index is only used by QGraphicsLinearLayout to ensure that itemAt() reflects the order
+ of visual arrangement. Strictly speaking it does not have to, but most people expect it to.
+ (And if it didn't we would have to add itemArrangedAt(int index) or something..)
+ */
+void QGridLayoutEngine::insertItem(QGridLayoutItem *item, int index)
{
maybeExpandGrid(item->lastRow(), item->lastColumn());
- q_items.append(item);
+ if (index == -1)
+ q_items.append(item);
+ else
+ q_items.insert(index, item);
for (int i = item->firstRow(); i <= item->lastRow(); ++i) {
for (int j = item->firstColumn(); j <= item->lastColumn(); ++j) {
@@ -952,6 +961,11 @@ void QGridLayoutEngine::addItem(QGridLayoutItem *item)
}
}
+void QGridLayoutEngine::addItem(QGridLayoutItem *item)
+{
+ insertItem(item, -1);
+}
+
void QGridLayoutEngine::removeItem(QGridLayoutItem *item)
{
Q_ASSERT(q_items.contains(item));
diff --git a/src/gui/graphicsview/qgridlayoutengine_p.h b/src/gui/graphicsview/qgridlayoutengine_p.h
index 8f3eb13..aab695a 100644
--- a/src/gui/graphicsview/qgridlayoutengine_p.h
+++ b/src/gui/graphicsview/qgridlayoutengine_p.h
@@ -267,7 +267,8 @@ class QGridLayoutItem
{
public:
QGridLayoutItem(QGridLayoutEngine *engine, QGraphicsLayoutItem *layoutItem, int row, int column,
- int rowSpan = 1, int columnSpan = 1, Qt::Alignment alignment = 0);
+ int rowSpan = 1, int columnSpan = 1, Qt::Alignment alignment = 0,
+ int itemAtIndex = -1);
inline int firstRow() const { return q_firstRows[Ver]; }
inline int firstColumn() const { return q_firstRows[Hor]; }
@@ -378,6 +379,7 @@ public:
Qt::Alignment effectiveAlignment(const QGridLayoutItem *layoutItem) const;
+ void insertItem(QGridLayoutItem *item, int index);
void addItem(QGridLayoutItem *item);
void removeItem(QGridLayoutItem *item);
QGridLayoutItem *findLayoutItem(QGraphicsLayoutItem *layoutItem) const;
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.cpp b/src/gui/image/qpixmap.cpp
index 658b8e0..155474f 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -322,6 +322,8 @@ QPixmap::QPixmap(const char * const xpm[])
QPixmap::~QPixmap()
{
+ if (data->is_cached && data->ref == 1)
+ QImagePixmapCleanupHooks::executePixmapHooks(this);
}
/*!
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/image/qpixmapfilter.cpp b/src/gui/image/qpixmapfilter.cpp
index bc14b5e..4b2f365 100644
--- a/src/gui/image/qpixmapfilter.cpp
+++ b/src/gui/image/qpixmapfilter.cpp
@@ -580,8 +580,6 @@ Qt::TransformationMode QPixmapBlurFilter::quality() const
}
/*!
- \reimp
-
\internal
*/
QRectF QPixmapBlurFilter::boundingRectFor(const QRectF &rect) const
@@ -657,8 +655,6 @@ static QImage blurred(const QImage& image, const QRect& rect, int radius)
}
/*!
- \reimp
-
\internal
*/
void QPixmapBlurFilter::draw(QPainter *painter, const QPointF &p, const QPixmap &src, const QRectF &srcRect) const
diff --git a/src/gui/inputmethod/qinputcontext.cpp b/src/gui/inputmethod/qinputcontext.cpp
index 35f1b65..992bc78 100644
--- a/src/gui/inputmethod/qinputcontext.cpp
+++ b/src/gui/inputmethod/qinputcontext.cpp
@@ -105,25 +105,27 @@ QT_BEGIN_NAMESPACE
\header \o Context \o Functions
\row \o Receiving information \o
- x11FilterEvent(),
- filterEvent(),
- mouseHandler()
+ x11FilterEvent(),
+ filterEvent(),
+ mouseHandler()
\row \o Sending back composed text \o
- sendEvent()
+ sendEvent()
\row \o State change notification \o
- setFocusWidget(),
- reset()
+ setFocusWidget(),
+ reset()
\row \o Context information \o
- identifierName(),
- language(),
- font(),
- isComposing()
+ identifierName(),
+ language(),
+ font(),
+ isComposing()
\endtable
+ \section1 Licensing Information
+
\legalese
Copyright (C) 2003-2004 immodule for Qt Project. All rights reserved.
@@ -154,16 +156,17 @@ QInputContext::~QInputContext()
}
/*!
- \internal
Returns the widget that has an input focus for this input
- context. Ordinary input methods should not call this function
- directly to keep platform independence and flexible configuration
- possibility.
+ context.
The return value may differ from holderWidget() if the input
context is shared between several text widgets.
- \sa setFocusWidget(), holderWidget()
+ \warning To ensure platform independence and support flexible
+ configuration of widgets, ordinary input methods should not call
+ this function directly.
+
+ \sa setFocusWidget()
*/
QWidget *QInputContext::focusWidget() const
{
@@ -173,9 +176,9 @@ QWidget *QInputContext::focusWidget() const
/*!
- \internal
- Sets the widget that has an input focus for this input
- context. Ordinary input methods must not call this function
+ Sets the widget that has an input focus for this input context.
+
+ \warning Ordinary input methods must not call this function
directly.
\sa focusWidget()
diff --git a/src/gui/inputmethod/qwininputcontext_p.h b/src/gui/inputmethod/qwininputcontext_p.h
index eff223b..767fc33 100644
--- a/src/gui/inputmethod/qwininputcontext_p.h
+++ b/src/gui/inputmethod/qwininputcontext_p.h
@@ -79,6 +79,7 @@ public:
bool startComposition();
bool endComposition();
bool composition(LPARAM lparam);
+ int reconvertString(RECONVERTSTRING *reconv);
static void TranslateMessage(const MSG *msg);
static LRESULT DefWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
diff --git a/src/gui/inputmethod/qwininputcontext_win.cpp b/src/gui/inputmethod/qwininputcontext_win.cpp
index 684f325..d917cb3 100644
--- a/src/gui/inputmethod/qwininputcontext_win.cpp
+++ b/src/gui/inputmethod/qwininputcontext_win.cpp
@@ -47,6 +47,7 @@
#include "qapplication.h"
#include "qevent.h"
#include "qtextformat.h"
+#include "qtextboundaryfinder.h"
//#define Q_IME_DEBUG
@@ -810,4 +811,52 @@ QString QWinInputContext::language()
return QString();
}
+int QWinInputContext::reconvertString(RECONVERTSTRING *reconv)
+{
+ QWidget *w = focusWidget();
+ if(!w)
+ return -1;
+
+ Q_ASSERT(w->testAttribute(Qt::WA_WState_Created));
+ QString surroundingText = qvariant_cast<QString>(w->inputMethodQuery(Qt::ImSurroundingText));
+ int memSize = sizeof(RECONVERTSTRING)+(surroundingText.length()+1)*sizeof(ushort);
+ // If memory is not allocated, return the required size.
+ if (!reconv) {
+ if (surroundingText.isEmpty())
+ return -1;
+ else
+ return memSize;
+ }
+ int pos = qvariant_cast<int>(w->inputMethodQuery(Qt::ImCursorPosition));
+ // find the word in the surrounding text.
+ QTextBoundaryFinder bounds(QTextBoundaryFinder::Word, surroundingText);
+ bounds.setPosition(pos);
+ if (bounds.isAtBoundary()) {
+ if (QTextBoundaryFinder::EndWord == bounds.boundaryReasons())
+ bounds.toPreviousBoundary();
+ } else {
+ bounds.toPreviousBoundary();
+ }
+ int startPos = bounds.position();
+ bounds.toNextBoundary();
+ int endPos = bounds.position();
+ // select the text, this will be overwritten by following ime events.
+ QList<QInputMethodEvent::Attribute> attrs;
+ attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, startPos, endPos-startPos, QVariant());
+ QInputMethodEvent e(QString(), attrs);
+ qt_sendSpontaneousEvent(w, &e);
+
+ reconv->dwSize = memSize;
+ reconv->dwVersion = 0;
+
+ reconv->dwStrLen = surroundingText.length();
+ reconv->dwStrOffset = sizeof(RECONVERTSTRING);
+ reconv->dwCompStrLen = endPos-startPos;
+ reconv->dwCompStrOffset = startPos*sizeof(ushort);
+ reconv->dwTargetStrLen = reconv->dwCompStrLen;
+ reconv->dwTargetStrOffset = reconv->dwCompStrOffset;
+ memcpy((char*)(reconv+1), surroundingText.utf16(), surroundingText.length()*sizeof(ushort));
+ return memSize;
+}
+
QT_END_NAMESPACE
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/qsortfilterproxymodel.cpp b/src/gui/itemviews/qsortfilterproxymodel.cpp
index d173efe..18fbf7b 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.cpp
+++ b/src/gui/itemviews/qsortfilterproxymodel.cpp
@@ -174,6 +174,7 @@ public:
const QModelIndex &source_bottom_right);
void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end);
+ void _q_sourceAboutToBeReset();
void _q_sourceReset();
void _q_sourceLayoutAboutToBeChanged();
@@ -1148,11 +1149,17 @@ void QSortFilterProxyModelPrivate::_q_sourceHeaderDataChanged(Qt::Orientation or
emit q->headerDataChanged(orientation, proxy_start, proxy_end);
}
+void QSortFilterProxyModelPrivate::_q_sourceAboutToBeReset()
+{
+ Q_Q(QSortFilterProxyModel);
+ q->beginResetModel();
+}
+
void QSortFilterProxyModelPrivate::_q_sourceReset()
{
Q_Q(QSortFilterProxyModel);
// All internal structures are deleted in clear()
- q->reset();
+ q->endResetModel();
update_source_sort_column();
if (dynamic_sortfilter)
sort();
@@ -1499,6 +1506,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
disconnect(d->model, SIGNAL(layoutChanged()),
this, SLOT(_q_sourceLayoutChanged()));
+ disconnect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
disconnect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
QAbstractProxyModel::setSourceModel(sourceModel);
@@ -1539,6 +1547,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
connect(d->model, SIGNAL(layoutChanged()),
this, SLOT(_q_sourceLayoutChanged()));
+ connect(d->model, SIGNAL(modelAboutToBeReset()), this, SLOT(_q_sourceAboutToBeReset()));
connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset()));
d->clear_mapping();
diff --git a/src/gui/itemviews/qsortfilterproxymodel.h b/src/gui/itemviews/qsortfilterproxymodel.h
index 12baa19..0314aec 100644
--- a/src/gui/itemviews/qsortfilterproxymodel.h
+++ b/src/gui/itemviews/qsortfilterproxymodel.h
@@ -177,6 +177,7 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_sourceDataChanged(const QModelIndex &source_top_left, const QModelIndex &source_bottom_right))
Q_PRIVATE_SLOT(d_func(), void _q_sourceHeaderDataChanged(Qt::Orientation orientation, int start, int end))
+ Q_PRIVATE_SLOT(d_func(), void _q_sourceAboutToBeReset())
Q_PRIVATE_SLOT(d_func(), void _q_sourceReset())
Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutAboutToBeChanged())
Q_PRIVATE_SLOT(d_func(), void _q_sourceLayoutChanged())
diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h
index e839617..f7f8ce9 100644
--- a/src/gui/kernel/qapplication_p.h
+++ b/src/gui/kernel/qapplication_p.h
@@ -264,12 +264,15 @@ typedef struct tagGESTURECONFIG
class QPanGesture;
class QPinchGesture;
+class QSwipeGesture;
+
struct QStandardGestures
{
QPanGesture *pan;
QPinchGesture *pinch;
+ QSwipeGesture *swipe;
- QStandardGestures() : pan(0), pinch(0) { }
+ QStandardGestures() : pan(0), pinch(0), swipe(0) { }
};
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 76a3b1e..b92bf03 100644
--- a/src/gui/kernel/qapplication_win.cpp
+++ b/src/gui/kernel/qapplication_win.cpp
@@ -171,6 +171,10 @@ typedef struct tagTOUCHINPUT
#include <mywinsock.h>
#endif
+#ifndef IMR_CONFIRMRECONVERTSTRING
+#define IMR_CONFIRMRECONVERTSTRING 0x0005
+#endif
+
QT_BEGIN_NAMESPACE
#ifdef Q_WS_WINCE
@@ -2263,7 +2267,26 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam
}
break;
}
-
+ case WM_IME_REQUEST: {
+ QWidget *fw = QApplication::focusWidget();
+ QWinInputContext *im = fw ? qobject_cast<QWinInputContext *>(fw->inputContext()) : 0;
+ if (fw && im) {
+ if(wParam == IMR_RECONVERTSTRING) {
+ int ret = im->reconvertString((RECONVERTSTRING *)lParam);
+ if (ret == -1) {
+ result = false;
+ } else {
+ return ret;
+ }
+ } else if (wParam == IMR_CONFIRMRECONVERTSTRING) {
+ RETURN(TRUE);
+ } else {
+ // in all other cases, call DefWindowProc()
+ result = false;
+ }
+ }
+ break;
+ }
#ifndef Q_WS_WINCE
case WM_CHANGECBCHAIN:
case WM_DRAWCLIPBOARD:
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index 5ab7ed2..0a45ce9 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -892,7 +892,7 @@ extern "C" {
qNGEvent.gestureType = QNativeGestureEvent::Rotate;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
- qNGEvent.percentage = [event rotation];
+ qNGEvent.percentage = -[event rotation];
qt_sendSpontaneousEvent(qwidget, &qNGEvent);
}
@@ -905,7 +905,14 @@ extern "C" {
qNGEvent.gestureType = QNativeGestureEvent::Swipe;
NSPoint p = [[event window] convertBaseToScreen:[event locationInWindow]];
qNGEvent.position = flipPoint(p).toPoint();
- qNGEvent.direction = QSize(-[event deltaX], -[event deltaY]);
+ if ([event deltaX] == 1)
+ qNGEvent.angle = 180.0f;
+ else if ([event deltaX] == -1)
+ qNGEvent.angle = 0.0f;
+ else if ([event deltaY] == 1)
+ qNGEvent.angle = 90.0f;
+ else if ([event deltaY] == -1)
+ qNGEvent.angle = 270.0f;
qt_sendSpontaneousEvent(qwidget, &qNGEvent);
}
diff --git a/src/gui/kernel/qcocoaview_mac_p.h b/src/gui/kernel/qcocoaview_mac_p.h
index d93fa2f..443a118 100644
--- a/src/gui/kernel/qcocoaview_mac_p.h
+++ b/src/gui/kernel/qcocoaview_mac_p.h
@@ -59,6 +59,7 @@ QT_FORWARD_DECLARE_CLASS(QWidgetPrivate);
QT_FORWARD_DECLARE_CLASS(QWidget);
QT_FORWARD_DECLARE_CLASS(QEvent);
QT_FORWARD_DECLARE_CLASS(QCocoaDropData);
+QT_FORWARD_DECLARE_CLASS(QString);
QT_FORWARD_DECLARE_CLASS(QStringList);
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 76d52c7..8d98223 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -1080,8 +1080,17 @@ Qt::FocusReason QFocusEvent::reason() const
rect() that is the bounding rectangle of that region. Both are
provided because many widgets can't make much use of region(),
and rect() can be much faster than region().boundingRect().
+
+ \section1 Automatic Clipping
+
Painting is clipped to region() during the processing of a paint
- event.
+ event. This clipping is performed by Qt's paint system and is
+ independent of any clipping that may be applied to a QPainter used to
+ draw on the paint device.
+
+ As a result, the value returned by QPainter::clipRegion() on
+ a newly-constructed QPainter will not reflect the clip region that is
+ used by the paint system.
\sa QPainter, QWidget::update(), QWidget::repaint(),
QWidget::paintEvent()
@@ -3544,7 +3553,8 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
#endif
-/*! \class QTouchEvent
+/*!
+ \class QTouchEvent
\brief The QTouchEvent class contains parameters that describe a touch event.
\since 4.6
\ingroup events
@@ -3556,27 +3566,19 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
\l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
- Note: when using QAbstractScrollArea based widgets, you should enabled the
- Qt::WA_AcceptTouchEvents attribute on the scroll area's
- \l{QAbstractScrollArea::viewport()}{viewport}.
+ When using QAbstractScrollArea based widgets, you should enabled the Qt::WA_AcceptTouchEvents
+ attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
- \section1 Event Delivery and Propagation
+ Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
+ widget, and the widget will receive all updates for the touch point until it is released.
+ Note that it is possible for a widget to receive events for multiple touch points, and that
+ multiple widgets may be receiving touch events at the same time.
+
+ \section1 Event Handling
All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, or QEvent::TouchEnd.
Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for widgets and
- QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events. By default,
- QWidget::event() translates the first non-primary touch point in a QTouchEvent into a
- QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
- normally handle QTouchEvent. See below for information on some special considerations needed
- when doing this.
-
- QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
- contains a special accept flag that indicates whether the receiver wants the event. By default,
- the event is accepted. You should call ignore() if the touch event is not handled by your
- widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
- accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
- QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
- propagation for QGraphicsItems).
+ QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
@@ -3587,10 +3589,20 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
Information about each touch point can be retrieved using the QTouchEvent::TouchPoint class.
The Qt::TouchPointState enum describes the different states that a touch point may have.
- Similar to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
- widget; the widget will receive all updates for the touch point until it is released. Note that
- it is possible for a widget to receive events for multiple touch points, and that multiple
- widgets may be receiving touch events at the same time.
+ \section1 Event Delivery and Propagation
+
+ By default, QWidget::event() translates the first non-primary touch point in a QTouchEvent into
+ a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
+ normally handle QTouchEvent. See below for information on some special considerations needed
+ when doing this.
+
+ QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
+ contains a special accept flag that indicates whether the receiver wants the event. By default,
+ the event is accepted. You should call ignore() if the touch event is not handled by your
+ widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
+ accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
+ QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
+ propagation for QGraphicsItems).
\section1 Touch Point Grouping
@@ -3604,7 +3616,7 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
\list
\i When the first touch point is detected, the destination widget is determined firstly by the
- location on screen first and secondly by the propagation rules.
+ location on screen and secondly by the propagation rules.
\i When additional touch points are detected, Qt first looks to see if there are any active
touch points on any ancestor or descendent of the widget under the new touch point. If there
@@ -3637,17 +3649,17 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
this gives you great flexibility in designing multi-touch user interfaces. Be aware of the
implications. For example, is is possible that the user is moving a QSlider with one finger and
- pressing a QPushButton with another. The signals are emitted from these widgets will be
+ pressing a QPushButton with another. The signals emitted by these widgets will be
interleaved.
- \i Recursion into the event loop using one of the exec() methods (e.g. QDialog::exec() or
+ \i Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
recipients, unexpected recursion may cause problems, including but not limited to lost events
and unexpected infinite recursion.
\i QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
- \l{QApplication::activePopupWidget()}{active popup widget}. The behavior of QTouchEvents is
- undefined when opening a popup or grabbing the mouse while there are multiple active touch
+ \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
+ undefined when opening a pop-up or grabbing the mouse while there are multiple active touch
points.
\endlist
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index a26f585..11d3138 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_p.h
@@ -143,7 +143,7 @@ public:
Type gestureType;
float percentage;
QPoint position;
- QSize direction;
+ float angle;
#ifdef Q_WS_WIN
ulong sequenceId;
quint64 argument;
diff --git a/src/gui/kernel/qmime_mac.cpp b/src/gui/kernel/qmime_mac.cpp
index 9e8de67..2e9514d 100644
--- a/src/gui/kernel/qmime_mac.cpp
+++ b/src/gui/kernel/qmime_mac.cpp
@@ -68,6 +68,12 @@
#include "qmap.h"
#include <private/qt_mac_p.h>
+
+#ifdef Q_WS_MAC32
+#include <QuickTime/QuickTime.h>
+#include <qlibrary.h>
+#endif
+
QT_BEGIN_NAMESPACE
extern CGImageRef qt_mac_createCGImageFromQImage(const QImage &img, const QImage **imagePtr = 0); // qpaintengine_mac.cpp
@@ -503,9 +509,6 @@ QList<QByteArray> QMacPasteboardMimeHTMLText::convertFromMime(const QString &mim
// This can be removed once 10.6 is the minimum (or we have to require 64-bit) whichever comes first.
-#include <QuickTime/QuickTime.h>
-#include <qlibrary.h>
-
typedef ComponentResult (*PtrGraphicsImportSetDataHandle)(GraphicsImportComponent, Handle);
typedef ComponentResult (*PtrGraphicsImportCreateCGImage)(GraphicsImportComponent, CGImageRef*, UInt32);
typedef ComponentResult (*PtrGraphicsExportSetInputCGImage)(GraphicsExportComponent, CGImageRef);
@@ -636,7 +639,9 @@ QList<QByteArray> QMacPasteboardMimePict::convertFromMime(const QString &mime, Q
DisposeHandle(pic);
return ret;
}
-#endif
+
+
+#endif //Q_WS_MAC32
class QMacPasteboardMimeTiff : public QMacPasteboardMime {
public:
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/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index d798d32..de6e7c7 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -72,6 +72,7 @@ QWidgetPrivate *qt_widget_private(QWidget *widget);
QPanGesture::QPanGesture(QWidget *gestureTarget, QObject *parent)
: QGesture(*new QPanGesturePrivate, gestureTarget, parent)
{
+ setObjectName(QLatin1String("QPanGesture"));
}
void QPanGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
@@ -80,16 +81,22 @@ void QPanGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
if (gestureTarget && gestureTarget->isWidgetType()) {
QWidget *w = static_cast<QWidget*>(gestureTarget.data());
QApplicationPrivate::instance()->widgetGestures[w].pan = 0;
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN)
qt_widget_private(w)->winSetupGestures();
+#elif defined(Q_WS_MAC)
+ w->setAttribute(Qt::WA_AcceptTouchEvents, false);
+ w->setAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents, false);
#endif
}
if (newGestureTarget && newGestureTarget->isWidgetType()) {
QWidget *w = static_cast<QWidget*>(newGestureTarget);
QApplicationPrivate::instance()->widgetGestures[w].pan = q;
-#ifdef Q_WS_WIN
+#if defined(Q_WS_WIN)
qt_widget_private(w)->winSetupGestures();
+#elif defined(Q_WS_MAC)
+ w->setAttribute(Qt::WA_AcceptTouchEvents);
+ w->setAttribute(Qt::WA_TouchPadAcceptSingleTouchEvents);
#endif
}
QGesturePrivate::setupGestureTarget(newGestureTarget);
@@ -98,15 +105,13 @@ void QPanGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
/*! \internal */
bool QPanGesture::event(QEvent *event)
{
-#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
+#if defined(QT_MAC_USE_COCOA)
Q_D(QPanGesture);
if (event->type() == QEvent::Timer) {
const QTimerEvent *te = static_cast<QTimerEvent *>(event);
- if (te->timerId() == d->panFinishedTimer) {
- killTimer(d->panFinishedTimer);
- d->panFinishedTimer = 0;
- d->lastOffset = QSize(0, 0);
- updateState(Qt::GestureFinished);
+ if (te->timerId() == d->singleTouchPanTimer.timerId()) {
+ d->singleTouchPanTimer.stop();
+ updateState(Qt::GestureStarted);
}
}
#endif
@@ -164,8 +169,10 @@ bool QPanGesture::eventFilter(QObject *receiver, QEvent *event)
/*! \internal */
bool QPanGesture::filterEvent(QEvent *event)
{
+#if defined(Q_WS_WIN)
Q_D(QPanGesture);
const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
+
if (event->type() == QEvent::TouchBegin) {
QTouchEvent::TouchPoint p = ev->touchPoints().at(0);
d->lastPosition = p.pos().toPoint();
@@ -197,33 +204,55 @@ bool QPanGesture::filterEvent(QEvent *event)
}
}
}
-#ifdef Q_OS_MAC
- else if (event->type() == QEvent::Wheel) {
- // On Mac, there is really no native panning gesture. Instead, a two
- // finger pan is delivered as mouse wheel events. Otoh, on Windows, you
- // either get mouse wheel events or pan events. We have decided to make this
- // the Qt behaviour as well, meaning that on Mac, wheel
- // events will be masked away when listening for pan events.
-#ifndef QT_MAC_USE_COCOA
- // In Carbon we receive neither touch-, nor pan gesture events.
- // So we create pan gestures by converting wheel events. After all, this
- // is how things are supposed to work on mac in the first place.
- const QWheelEvent *wev = static_cast<const QWheelEvent*>(event);
- int offset = wev->delta() / -120;
- d->lastOffset = wev->orientation() == Qt::Horizontal ? QSize(offset, 0) : QSize(0, offset);
+#elif defined(QT_MAC_USE_COCOA)
+ // The following implements single touch
+ // panning on Mac:
+ Q_D(QPanGesture);
+ const int panBeginDelay = 300;
+ const int panBeginRadius = 3;
+ const QTouchEvent *ev = static_cast<const QTouchEvent*>(event);
- if (state() == Qt::NoGesture) {
- d->totalOffset = d->lastOffset;
- } else {
- d->totalOffset += d->lastOffset;
+ switch (event->type()) {
+ case QEvent::TouchBegin: {
+ if (ev->touchPoints().size() == 1) {
+ d->lastPosition = QCursor::pos();
+ d->singleTouchPanTimer.start(panBeginDelay, this);
}
-
- killTimer(d->panFinishedTimer);
- d->panFinishedTimer = startTimer(200);
- updateState(Qt::GestureUpdated);
-#endif
- return true;
+ break;}
+ case QEvent::TouchEnd: {
+ if (state() != Qt::NoGesture)
+ updateState(Qt::GestureFinished);
+ reset();
+ break;}
+ case QEvent::TouchUpdate: {
+ if (ev->touchPoints().size() == 1) {
+ if (state() == Qt::NoGesture) {
+ // INVARIANT: The singleTouchTimer has still not fired.
+ // Lets check if the user moved his finger so much from
+ // the starting point that it makes sense to cancel:
+ const QPointF startPos = ev->touchPoints().at(0).startPos().toPoint();
+ const QPointF p = ev->touchPoints().at(0).pos().toPoint();
+ if ((startPos - p).manhattanLength() > panBeginRadius)
+ reset();
+ else
+ d->lastPosition = QCursor::pos();
+ } else {
+ QPointF mousePos = QCursor::pos();
+ QPointF dist = mousePos - d->lastPosition;
+ d->lastPosition = mousePos;
+ d->lastOffset = QSizeF(dist.x(), dist.y());
+ d->totalOffset += d->lastOffset;
+ updateState(Qt::GestureUpdated);
+ }
+ } else if (state() == Qt::NoGesture) {
+ reset();
+ }
+ break;}
+ default:
+ return false;
}
+#else
+ Q_UNUSED(event);
#endif
return false;
}
@@ -232,14 +261,14 @@ bool QPanGesture::filterEvent(QEvent *event)
void QPanGesture::reset()
{
Q_D(QPanGesture);
- d->lastOffset = d->totalOffset = QSize();
- d->lastPosition = QPoint();
-#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
- if (d->panFinishedTimer) {
- killTimer(d->panFinishedTimer);
- d->panFinishedTimer = 0;
- }
+ d->lastOffset = d->totalOffset = QSize(0, 0);
+ d->lastPosition = QPoint(0, 0);
+
+#if defined(QT_MAC_USE_COCOA)
+ d->singleTouchPanTimer.stop();
+ d->prevMousePos = QPointF(0, 0);
#endif
+
QGesture::reset();
}
@@ -248,7 +277,7 @@ void QPanGesture::reset()
Specifies a total pan offset since the start of the gesture.
*/
-QSize QPanGesture::totalOffset() const
+QSizeF QPanGesture::totalOffset() const
{
Q_D(const QPanGesture);
return d->totalOffset;
@@ -260,12 +289,13 @@ QSize QPanGesture::totalOffset() const
Specifies a pan offset since the last time the gesture was
triggered.
*/
-QSize QPanGesture::lastOffset() const
+QSizeF QPanGesture::lastOffset() const
{
Q_D(const QPanGesture);
return d->lastOffset;
}
+//////////////////////////////////////////////////////////////////////////////
/*!
\class QPinchGesture
@@ -285,6 +315,7 @@ QSize QPanGesture::lastOffset() const
QPinchGesture::QPinchGesture(QWidget *gestureTarget, QObject *parent)
: QGesture(*new QPinchGesturePrivate, gestureTarget, parent)
{
+ setObjectName(QLatin1String("QPinchGesture"));
}
void QPinchGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
@@ -338,12 +369,13 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event)
d->state = Qt::NoGesture;
d->scaleFactor = d->lastScaleFactor = 1;
d->rotationAngle = d->lastRotationAngle = 0;
- d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPoint();
+ d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPointF();
#if defined(Q_WS_WIN)
d->initialDistance = 0;
#endif
return false;
case QNativeGestureEvent::Rotate:
+ d->scaleFactor = 0;
d->lastRotationAngle = d->rotationAngle;
#if defined(Q_WS_WIN)
d->rotationAngle = -1 * GID_ROTATE_ANGLE_FROM_ARGUMENT(ev->argument);
@@ -354,6 +386,7 @@ bool QPinchGesture::eventFilter(QObject *receiver, QEvent *event)
event->accept();
break;
case QNativeGestureEvent::Zoom:
+ d->rotationAngle = 0;
#if defined(Q_WS_WIN)
if (d->initialDistance != 0) {
d->lastScaleFactor = d->scaleFactor;
@@ -402,7 +435,7 @@ void QPinchGesture::reset()
Q_D(QPinchGesture);
d->scaleFactor = d->lastScaleFactor = 0;
d->rotationAngle = d->lastRotationAngle = 0;
- d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPoint();
+ d->startCenterPoint = d->centerPoint = d->lastCenterPoint = QPointF();
QGesture::reset();
}
@@ -452,7 +485,7 @@ qreal QPinchGesture::lastRotationAngle() const
Specifies a center point of the gesture. The point can be used as a center
point that the object is rotated around.
*/
-QPoint QPinchGesture::centerPoint() const
+QPointF QPinchGesture::centerPoint() const
{
return d_func()->centerPoint;
}
@@ -462,7 +495,7 @@ QPoint QPinchGesture::centerPoint() const
Specifies a previous center point of the gesture.
*/
-QPoint QPinchGesture::lastCenterPoint() const
+QPointF QPinchGesture::lastCenterPoint() const
{
return d_func()->lastCenterPoint;
}
@@ -474,11 +507,117 @@ QPoint QPinchGesture::lastCenterPoint() const
startCenterPoint and the centerPoint is the distance at which pinching
fingers has shifted.
*/
-QPoint QPinchGesture::startCenterPoint() const
+QPointF QPinchGesture::startCenterPoint() const
{
return d_func()->startCenterPoint;
}
+//////////////////////////////////////////////////////////////////////////////
+
+/*!
+ \class QSwipeGesture
+ \since 4.6
+
+ \brief The QSwipeGesture class represents a swipe gesture,
+ providing additional information related to swiping.
+*/
+
+/*!
+ Creates a new Swipe gesture handler object and marks it as a child of \a
+ parent.
+
+ On some platform like Windows it's necessary to provide a non-null widget
+ as \a parent to get native gesture support.
+*/
+QSwipeGesture::QSwipeGesture(QWidget *gestureTarget, QObject *parent)
+ : QGesture(*new QSwipeGesturePrivate, gestureTarget, parent)
+{
+ setObjectName(QLatin1String("QSwipeGesture"));
+}
+
+void QSwipeGesturePrivate::setupGestureTarget(QObject *newGestureTarget)
+{
+ Q_Q(QSwipeGesture);
+ if (gestureTarget && gestureTarget->isWidgetType()) {
+ QWidget *w = static_cast<QWidget*>(gestureTarget.data());
+ QApplicationPrivate::instance()->widgetGestures[w].swipe = 0;
+#if defined(Q_WS_WIN)
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
+
+ if (newGestureTarget && newGestureTarget->isWidgetType()) {
+ QWidget *w = static_cast<QWidget*>(newGestureTarget);
+ QApplicationPrivate::instance()->widgetGestures[w].swipe = q;
+#if defined(Q_WS_WIN)
+ qt_widget_private(w)->winSetupGestures();
+#endif
+ }
+ QGesturePrivate::setupGestureTarget(newGestureTarget);
+}
+
+qreal QSwipeGesture::swipeAngle() const
+{
+ Q_D(const QSwipeGesture);
+ return d->swipeAngle;
+}
+
+QSwipeGesture::SwipeDirection QSwipeGesture::horizontalDirection() const
+{
+ Q_D(const QSwipeGesture);
+ if (d->swipeAngle < 0 || d->swipeAngle == 90 || d->swipeAngle == 270)
+ return QSwipeGesture::NoDirection;
+ else if (d->swipeAngle < 90 || d->swipeAngle > 270)
+ return QSwipeGesture::Right;
+ else
+ return QSwipeGesture::Left;
+}
+
+QSwipeGesture::SwipeDirection QSwipeGesture::verticalDirection() const
+{
+ Q_D(const QSwipeGesture);
+ if (d->swipeAngle <= 0 || d->swipeAngle == 180)
+ return QSwipeGesture::NoDirection;
+ else if (d->swipeAngle < 180)
+ return QSwipeGesture::Up;
+ else
+ return QSwipeGesture::Down;
+}
+
+bool QSwipeGesture::eventFilter(QObject *receiver, QEvent *event)
+{
+ Q_D(QSwipeGesture);
+ if (receiver->isWidgetType() && event->type() == QEvent::NativeGesture) {
+ QNativeGestureEvent *ev = static_cast<QNativeGestureEvent*>(event);
+ switch (ev->gestureType) {
+ case QNativeGestureEvent::Swipe:
+ d->swipeAngle = ev->angle;
+ updateState(Qt::GestureStarted);
+ updateState(Qt::GestureUpdated);
+ updateState(Qt::GestureFinished);
+ break;
+ default:
+ return false;
+ }
+ return true;
+ }
+ return QGesture::eventFilter(receiver, event);
+}
+
+/*! \internal */
+bool QSwipeGesture::filterEvent(QEvent *)
+{
+ return false;
+}
+
+/*! \internal */
+void QSwipeGesture::reset()
+{
+ Q_D(QSwipeGesture);
+ d->swipeAngle = -1;
+ QGesture::reset();
+}
+
QT_END_NAMESPACE
#include "moc_qstandardgestures.cpp"
diff --git a/src/gui/kernel/qstandardgestures.h b/src/gui/kernel/qstandardgestures.h
index 0eb9d92..029e6dc 100644
--- a/src/gui/kernel/qstandardgestures.h
+++ b/src/gui/kernel/qstandardgestures.h
@@ -59,16 +59,16 @@ class Q_GUI_EXPORT QPanGesture : public QGesture
Q_OBJECT
Q_DECLARE_PRIVATE(QPanGesture)
- Q_PROPERTY(QSize totalOffset READ totalOffset)
- Q_PROPERTY(QSize lastOffset READ lastOffset)
+ Q_PROPERTY(QSizeF totalOffset READ totalOffset)
+ Q_PROPERTY(QSizeF lastOffset READ lastOffset)
public:
QPanGesture(QWidget *gestureTarget, QObject *parent = 0);
bool filterEvent(QEvent *event);
- QSize totalOffset() const;
- QSize lastOffset() const;
+ QSizeF totalOffset() const;
+ QSizeF lastOffset() const;
protected:
void reset();
@@ -92,9 +92,9 @@ class Q_GUI_EXPORT QPinchGesture : public QGesture
Q_PROPERTY(qreal rotationAngle READ rotationAngle)
Q_PROPERTY(qreal lastRotationAngle READ lastRotationAngle)
- Q_PROPERTY(QPoint startCenterPoint READ startCenterPoint)
- Q_PROPERTY(QPoint lastCenterPoint READ lastCenterPoint)
- Q_PROPERTY(QPoint centerPoint READ centerPoint)
+ Q_PROPERTY(QPointF startCenterPoint READ startCenterPoint)
+ Q_PROPERTY(QPointF lastCenterPoint READ lastCenterPoint)
+ Q_PROPERTY(QPointF centerPoint READ centerPoint)
public:
QPinchGesture(QWidget *gestureTarget, QObject *parent = 0);
@@ -102,9 +102,9 @@ public:
bool filterEvent(QEvent *event);
void reset();
- QPoint startCenterPoint() const;
- QPoint lastCenterPoint() const;
- QPoint centerPoint() const;
+ QPointF startCenterPoint() const;
+ QPointF lastCenterPoint() const;
+ QPointF centerPoint() const;
qreal scaleFactor() const;
qreal lastScaleFactor() const;
@@ -119,6 +119,34 @@ private:
friend class QWidget;
};
+class QSwipeGesturePrivate;
+class Q_GUI_EXPORT QSwipeGesture : public QGesture
+{
+ Q_OBJECT
+ Q_ENUMS(SwipeDirection)
+
+ Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection)
+ Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection)
+ Q_PROPERTY(qreal swipeAngle READ swipeAngle)
+
+ Q_DECLARE_PRIVATE(QSwipeGesture)
+
+public:
+ enum SwipeDirection { NoDirection, Left, Right, Up, Down };
+ QSwipeGesture(QWidget *gestureTarget, QObject *parent = 0);
+
+ bool filterEvent(QEvent *event);
+ void reset();
+
+ SwipeDirection horizontalDirection() const;
+ SwipeDirection verticalDirection() const;
+ qreal swipeAngle() const;
+
+private:
+ bool eventFilter(QObject *receiver, QEvent *event);
+
+ friend class QWidget;
+};
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/gui/kernel/qstandardgestures_p.h b/src/gui/kernel/qstandardgestures_p.h
index 5fbcc5d..9829cf0 100644
--- a/src/gui/kernel/qstandardgestures_p.h
+++ b/src/gui/kernel/qstandardgestures_p.h
@@ -61,6 +61,7 @@
#include "qgesture_p.h"
#include "qstandardgestures.h"
+#include "qbasictimer.h"
QT_BEGIN_NAMESPACE
@@ -69,21 +70,15 @@ class QPanGesturePrivate : public QGesturePrivate
Q_DECLARE_PUBLIC(QPanGesture)
public:
- QPanGesturePrivate()
- {
-#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
- panFinishedTimer = 0;
-#endif
- }
-
void setupGestureTarget(QObject *o);
- QSize totalOffset;
- QSize lastOffset;
- QPoint lastPosition;
+ QSizeF totalOffset;
+ QSizeF lastOffset;
+ QPointF lastPosition;
-#if defined(Q_OS_MAC) && !defined(QT_MAC_USE_COCOA)
- int panFinishedTimer;
+#if defined(QT_MAC_USE_COCOA)
+ QBasicTimer singleTouchPanTimer;
+ QPointF prevMousePos;
#endif
};
@@ -107,14 +102,28 @@ public:
qreal lastScaleFactor;
qreal rotationAngle;
qreal lastRotationAngle;
- QPoint startCenterPoint;
- QPoint lastCenterPoint;
- QPoint centerPoint;
+ QPointF startCenterPoint;
+ QPointF lastCenterPoint;
+ QPointF centerPoint;
#ifdef Q_WS_WIN
int initialDistance;
#endif
};
+class QSwipeGesturePrivate : public QGesturePrivate
+{
+ Q_DECLARE_PUBLIC(QSwipeGesture)
+
+public:
+ QSwipeGesturePrivate()
+ : swipeAngle(-1)
+ {
+ }
+
+ void setupGestureTarget(QObject *o);
+ qreal swipeAngle;
+};
+
QT_END_NAMESPACE
#endif // QSTANDARDGESTURES_P_H
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index 6ffac2c..38b09ee 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)
@@ -4172,6 +4177,10 @@ QPalette::ColorRole QWidget::backgroundRole() const
If \a role is QPalette::NoRole, then the widget inherits its
parent's background role.
+ Note that styles are free to choose any color from the palette.
+ You can modify the palette or set a style sheet if you don't
+ achieve the result you want with setBackgroundRole().
+
\sa backgroundRole(), foregroundRole()
*/
@@ -4234,6 +4243,10 @@ QPalette::ColorRole QWidget::foregroundRole() const
If \a role is QPalette::NoRole, the widget uses a foreground role
that contrasts with the background role.
+ Note that styles are free to choose any color from the palette.
+ You can modify the palette or set a style sheet if you don't
+ achieve the result you want with setForegroundRole().
+
\sa foregroundRole(), backgroundRole()
*/
void QWidget::setForegroundRole(QPalette::ColorRole role)
@@ -4965,6 +4978,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 +5002,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)
{
@@ -11824,10 +11846,9 @@ const QList<QAction*>& QWidget::softKeys() const
\preliminary
\since 4.6
- Sets the softkey \a softkey to this widget's list of softkeys,
+ Sets the softkey \a softKey to this widget's list of softkeys.
Setting 0 as softkey will clear all the existing softkeys set
- to the widget
- A QWidget can have 0 or more softkeys
+ to the widget. A QWidget can have 0 or more softkeys.
\sa softKeys(), setSoftKeys()
*/
@@ -11844,8 +11865,8 @@ void QWidget::setSoftKey(QAction *softKey)
}
/*!
- Sets the list of softkeys \a softkeys to this widget's list of softkeys,
- A QWidget can have 0 or more softkeys
+ Sets the list of softkeys \a softKeys to this widget's list of softkeys.
+ A QWidget can have 0 or more softkeys.
\sa softKeys(), setSoftKey()
*/
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 53d1b6e..cdf0706 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -1064,7 +1064,7 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event,
break;
}
qNGEvent.gestureType = QNativeGestureEvent::Rotate;
- qNGEvent.percentage = float(amount);
+ qNGEvent.percentage = float(-amount);
break; }
case kEventGestureSwipe: {
HIPoint swipeDirection;
@@ -1074,7 +1074,14 @@ OSStatus QWidgetPrivate::qt_window_event(EventHandlerCallRef er, EventRef event,
break;
}
qNGEvent.gestureType = QNativeGestureEvent::Swipe;
- qNGEvent.direction = QSize(-swipeDirection.x, -swipeDirection.y);
+ if (swipeDirection.x == 1)
+ qNGEvent.angle = 180.0f;
+ else if (swipeDirection.x == -1)
+ qNGEvent.angle = 0.0f;
+ else if (swipeDirection.y == 1)
+ qNGEvent.angle = 90.0f;
+ else if (swipeDirection.y == -1)
+ qNGEvent.angle = 270.0f;
break; }
case kEventGestureMagnify: {
CGFloat amount;
diff --git a/src/gui/math3d/qmatrix4x4.cpp b/src/gui/math3d/qmatrix4x4.cpp
index 36ffcbe..eb87052 100644
--- a/src/gui/math3d/qmatrix4x4.cpp
+++ b/src/gui/math3d/qmatrix4x4.cpp
@@ -1450,7 +1450,7 @@ static const qreal inv_dist_to_plane = 1. / 1024.;
value of 1024 corresponds to the projection factor used
by QTransform::rotate() for the x and y axes.
- If \a distToPlane is zero, then the returned QTransform
+ If \a distanceToPlane is zero, then the returned QTransform
is formed by simply dropping the third row and third column
of the QMatrix4x4. This is suitable for implementing
orthographic projections where the z co-ordinate should
diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp
index 0fffaef..4665b66 100644
--- a/src/gui/painting/qbackingstore.cpp
+++ b/src/gui/painting/qbackingstore.cpp
@@ -1544,7 +1544,8 @@ void QWidgetPrivate::repaint_sys(const QRegion &rgn)
// QGLWidget does not support partial updates if:
// 1) The context is double buffered
// 2) The context is single buffered and auto-fill background is enabled.
- const bool noPartialUpdateSupport = (engine && engine->type() == QPaintEngine::OpenGL)
+ const bool noPartialUpdateSupport = (engine && (engine->type() == QPaintEngine::OpenGL
+ || engine->type() == QPaintEngine::OpenGL2))
&& (usesDoubleBufferedGLContext || q->autoFillBackground());
QRegion toBePainted(noPartialUpdateSupport ? q->rect() : rgn);
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..699de4d 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
@@ -7169,7 +7208,8 @@ QPoint QPainter::xFormDev(const QPoint &p) const
QRect transformed = painter.xFormDev(rectangle);
\newcode
QPainter painter(this);
- QRect transformed = painter.combinedTransform().inverted(rectangle);
+ QRegion region = QRegion(rectangle) * painter.combinedTransform().inverted();
+ QRect transformed = region.boundingRect();
\endcode
*/
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/styles/images/defaults60theme.blob b/src/gui/styles/images/defaults60theme.blob
new file mode 100644
index 0000000..f3a5952
--- /dev/null
+++ b/src/gui/styles/images/defaults60theme.blob
Binary files differ
diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp
index 2dab9b3..ee9827e 100644
--- a/src/gui/styles/qcommonstyle.cpp
+++ b/src/gui/styles/qcommonstyle.cpp
@@ -870,7 +870,6 @@ int QCommonStylePrivate::lookupToolButtonStyle() const
#ifndef QT_NO_ITEMVIEWS
-
QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, int role) const
{
Q_Q(const QCommonStyle);
@@ -1158,6 +1157,75 @@ void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRe
}
#endif // QT_NO_ITEMVIEWS
+
+#ifndef QT_NO_TABBAR
+/*! \internal
+ Compute the textRect and the pixmapRect from the opt rect
+
+ Uses the same computation than in QTabBar::tabSizeHint
+ */
+void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const
+{
+ Q_ASSERT(textRect);
+ Q_ASSERT(iconRect);
+ QRect tr = opt->rect;
+ bool verticalTabs = opt->shape == QTabBar::RoundedEast
+ || opt->shape == QTabBar::RoundedWest
+ || opt->shape == QTabBar::TriangularEast
+ || opt->shape == QTabBar::TriangularWest;
+ if (verticalTabs)
+ tr.setRect(0, 0, tr.height(), tr.width()); //0, 0 as we will have a translate transform
+
+ int verticalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftVertical, opt, widget);
+ int horizontalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, opt, widget);
+ int hpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2;
+ int vpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabVSpace, opt, widget) / 2;
+ if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth)
+ verticalShift = -verticalShift;
+ tr.adjust(hpadding, vpadding, horizontalShift - hpadding, verticalShift - vpadding);
+ bool selected = opt->state & QStyle::State_Selected;
+ if (selected) {
+ tr.setBottom(tr.bottom() - verticalShift);
+ tr.setRight(tr.right() - horizontalShift);
+ }
+
+ // left widget
+ if (!opt->leftButtonSize.isEmpty()) {
+ tr.setLeft(tr.left() + 4 +
+ (verticalTabs ? opt->leftButtonSize.height() : opt->leftButtonSize.width()));
+ }
+ // right widget
+ if (!opt->rightButtonSize.isEmpty()) {
+ tr.setRight(tr.right() - 4 -
+ (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width()));
+ }
+
+ // icon
+ if (!opt->icon.isNull()) {
+ QSize iconSize = opt->iconSize;
+ if (!iconSize.isValid()) {
+ int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize);
+ iconSize = QSize(iconExtent, iconExtent);
+ }
+ QSize tabIconSize = opt->icon.actualSize(iconSize,
+ (opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled,
+ (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off );
+
+ *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2,
+ tabIconSize.width(), tabIconSize .height());
+ if (!verticalTabs)
+ *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect);
+ tr.setLeft(tr.left() + tabIconSize.width() + 4);
+ }
+
+ if (!verticalTabs)
+ tr = proxyStyle->visualRect(opt->direction, opt->rect, tr);
+
+ *textRect = tr;
+}
+#endif //QT_NO_TABBAR
+
+
/*!
\reimp
*/
@@ -1840,38 +1908,20 @@ void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt,
newY = tr.y() + tr.height();
newRot = -90;
}
- tr.setRect(0, 0, tr.height(), tr.width());
QTransform m = QTransform::fromTranslate(newX, newY);
m.rotate(newRot);
p->setTransform(m, true);
}
- tr = subElementRect(SE_TabBarTabText, opt, widget);
+ QRect iconRect;
+ d->tabLayout(&tabV2, widget, &tr, &iconRect);
+ tr = proxy()->subElementRect(SE_TabBarTabText, opt, widget); //we compute tr twice because the style may override subElementRect
if (!tabV2.icon.isNull()) {
- QSize iconSize = tabV2.iconSize;
- if (!iconSize.isValid()) {
- int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
- iconSize = QSize(iconExtent, iconExtent);
- }
- QSize tabIconSize = tabV2.icon.actualSize(iconSize,
- (tabV2.state & State_Enabled) ? QIcon::Normal
- : QIcon::Disabled);
- QPixmap tabIcon = tabV2.icon.pixmap(iconSize,
+ QPixmap tabIcon = tabV2.icon.pixmap(tabV2.iconSize,
(tabV2.state & State_Enabled) ? QIcon::Normal
: QIcon::Disabled,
(tabV2.state & State_Selected) ? QIcon::On
: QIcon::Off);
-
- int offset = 4;
- int left = opt->rect.left();
- if (tabV2.leftButtonSize.isEmpty())
- offset += 2;
- else
- left += tabV2.leftButtonSize.width() + (6 + 2) + 2;
- QRect iconRect = QRect(left + offset, tr.center().y() - tabIcon.height() / 2,
- tabIconSize.width(), tabIconSize.height());
- if (!verticalTabs)
- iconRect = visualRect(opt->direction, opt->rect, iconRect);
p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon);
}
@@ -2718,65 +2768,10 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
}
break;
case SE_TabBarTabText:
- // ### consider merging this with CE_TabBarTabLabel
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
- QStyleOptionTabV3 tabV2(*tab);
- QRect tr = tabV2.rect;
- bool verticalTabs = tabV2.shape == QTabBar::RoundedEast
- || tabV2.shape == QTabBar::RoundedWest
- || tabV2.shape == QTabBar::TriangularEast
- || tabV2.shape == QTabBar::TriangularWest;
- if (verticalTabs)
- tr.setRect(0, 0, tr.height(), tr.width());
- int verticalShift = pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget);
- int horizontalShift = pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget);
- int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2;
- int vpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabVSpace, opt, widget) / 2;
- if (tabV2.shape == QTabBar::RoundedSouth || tabV2.shape == QTabBar::TriangularSouth)
- verticalShift = -verticalShift;
- tr.adjust(hpadding, vpadding, horizontalShift - hpadding, verticalShift - vpadding);
- bool selected = tabV2.state & State_Selected;
- if (selected) {
- tr.setBottom(tr.bottom() - verticalShift);
- tr.setRight(tr.right() - horizontalShift);
- }
-
- // left widget
- if (!tabV2.leftButtonSize.isEmpty()) {
- tr.setLeft(tr.left() + 6 + 2 +
- (verticalTabs ? tabV2.leftButtonSize.height() : tabV2.leftButtonSize.width()));
- }
-
- // icon
- if (!tabV2.icon.isNull()) {
- QSize iconSize = tabV2.iconSize;
- if (!iconSize.isValid()) {
- int iconExtent = proxy()->pixelMetric(PM_SmallIconSize);
- iconSize = QSize(iconExtent, iconExtent);
- }
- QSize tabIconSize = tabV2.icon.actualSize(iconSize,
- (tabV2.state & State_Enabled) ? QIcon::Normal
- : QIcon::Disabled);
- int offset = 4;
- if (tabV2.leftButtonSize.isEmpty())
- offset += 2;
-
- QRect iconRect = QRect(tr.left() + offset, tr.center().y() - tabIconSize.height() / 2,
- tabIconSize.width(), tabIconSize .height());
- if (!verticalTabs)
- iconRect = visualRect(opt->direction, opt->rect, iconRect);
- tr.setLeft(tr.left() + tabIconSize.width() + offset + 2);
- }
-
- // right widget
- if (!tabV2.rightButtonSize.isEmpty()) {
- tr.setRight(tr.right() - 6 - 2 -
- (verticalTabs ? tabV2.rightButtonSize.height() : tabV2.rightButtonSize.width()));
- }
-
- if (!verticalTabs)
- tr = visualRect(opt->direction, opt->rect, tr);
- r = tr;
+ QStyleOptionTabV3 tabV3(*tab);
+ QRect dummyIconRect;
+ d->tabLayout(&tabV3, widget, &r, &dummyIconRect);
}
break;
case SE_TabBarTabLeftButton:
@@ -2785,6 +2780,8 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
bool selected = tab->state & State_Selected;
int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget);
int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget);
+ int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2;
+ hpadding = qMax(hpadding, 4); //workaround KStyle returning 0 because they workaround an old bug in Qt
bool verticalTabs = tab->shape == QTabBar::RoundedEast
|| tab->shape == QTabBar::RoundedWest
@@ -2827,16 +2824,16 @@ QRect QCommonStyle::subElementRect(SubElement sr, const QStyleOption *opt,
break;
default:
if (sr == SE_TabBarTabLeftButton)
- r = QRect(6 + tab->rect.x(), midHeight, w, h);
+ r = QRect(tab->rect.x() + hpadding, midHeight, w, h);
else
- r = QRect(tab->rect.right() - 6 - w, midHeight, w, h);
+ r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h);
r = visualRect(tab->direction, tab->rect, r);
}
if (verticalTabs) {
if (atTheTop)
- r = QRect(midWidth, tr.y() + tab->rect.height() - 6 - h, w, h);
+ r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h);
else
- r = QRect(midWidth, tr.y() + 6, w, h);
+ r = QRect(midWidth, tr.y() + hpadding, w, h);
}
}
diff --git a/src/gui/styles/qcommonstyle_p.h b/src/gui/styles/qcommonstyle_p.h
index 7e58b37..14f5558 100644
--- a/src/gui/styles/qcommonstyle_p.h
+++ b/src/gui/styles/qcommonstyle_p.h
@@ -123,6 +123,9 @@ public:
#endif
mutable QIcon tabBarcloseButtonIcon;
int lookupToolButtonStyle() const;
+#ifndef QT_NO_TABBAR
+ void tabLayout(const QStyleOptionTabV3 *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
+#endif
};
QT_END_NAMESPACE
diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm
index 08b6ad8..905044c 100644
--- a/src/gui/styles/qmacstyle_mac.mm
+++ b/src/gui/styles/qmacstyle_mac.mm
@@ -5318,16 +5318,23 @@ QRect QMacStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *op
case SC_ComboBoxArrow:{
ret = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
ret.setX(ret.x() + ret.width());
- ret.setWidth(combo->rect.width() - ret.width() - ret.x());
+ ret.setWidth(combo->rect.right() - ret.right());
break; }
case SC_ComboBoxListBoxPopup:{
if (combo->editable) {
HIRect inner = QMacStylePrivate::comboboxInnerBounds(qt_hirectForQRect(combo->rect), bdi.kind);
QRect editRect = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
- ret.adjust(qRound(inner.origin.x), 0, qRound(inner.origin.x + inner.size.width), editRect.y() + editRect.height() + 2);
+ const int comboTop = combo->rect.top();
+ ret = QRect(qRound(inner.origin.x),
+ comboTop,
+ qRound(inner.origin.x - combo->rect.left() + inner.size.width),
+ editRect.bottom() - comboTop + 2);
} else {
QRect editRect = QMacStylePrivate::comboboxEditBounds(combo->rect, bdi);
- ret.adjust(4 - 11, 1, editRect.width() + 10 + 11, 1);
+ ret = QRect(combo->rect.x() + 4 - 11,
+ combo->rect.y() + 1,
+ editRect.width() + 10 + 11,
+ 1);
}
break; }
default:
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index b05a1e9..3230c17 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -67,6 +67,7 @@
#include "qtoolbar.h"
#include "qtoolbutton.h"
#include "qtreeview.h"
+#include "qfocusframe.h"
#include "private/qtoolbarextension_p.h"
#include "private/qcombobox_p.h"
@@ -86,6 +87,8 @@ const QS60StylePrivate::SkinElementFlags QS60StylePrivate::KDefaultSkinElementFl
static const QByteArray propertyKeyLayouts = "layouts";
static const QByteArray propertyKeyCurrentlayout = "currentlayout";
+static const qreal goldenRatio = 1.618;
+
const layoutHeader QS60StylePrivate::m_layoutHeaders[] = {
// *** generated layout data ***
{240,320,1,14,true,"QVGA Landscape Mirrored"},
@@ -508,11 +511,6 @@ void QS60StylePrivate::deleteBackground()
}
}
-int QS60StylePrivate::focusRectPenWidth()
-{
- return pixelMetric(QS60Style::PM_DefaultFrameWidth);
-}
-
void QS60StylePrivate::setCurrentLayout(int index)
{
m_pmPointer = data[index];
@@ -950,13 +948,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
const QS60StylePrivate::SkinElements handleElement =
horizontal ? QS60StylePrivate::SE_SliderHandleHorizontal : QS60StylePrivate::SE_SliderHandleVertical;
QS60StylePrivate::drawSkinElement(handleElement, painter, sliderHandle, flags);
-
- if (optionSlider->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*optionSlider);
- fropt.rect = subElementRect(SE_SliderFocusRect, optionSlider, widget);
- drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
}
break;
#endif // QT_NO_SLIDER
@@ -991,17 +982,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget);
painter->restore();
}
-
- if (cmb->subControls & SC_ComboBoxEditField) {
- if (cmb->state & State_HasFocus && !cmb->editable) {
- QStyleOptionFocusRect focus;
- focus.QStyleOption::operator=(*cmb);
- focus.rect = cmbxEditField;
- focus.state |= State_FocusAtBorder;
- focus.backgroundColor = cmb->palette.highlight().color();
- drawPrimitive(PE_FrameFocusRect, &focus, painter, widget);
- }
- }
}
break;
#endif // QT_NO_COMBOBOX
@@ -1079,13 +1059,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
}
}
}
- if (toolBtn->state & State_HasFocus) {
- QStyleOptionFocusRect fr;
- fr.QStyleOption::operator=(*toolBtn);
- const int frameWidth = pixelMetric(PM_DefaultFrameWidth, option, widget);
- fr.rect.adjust(frameWidth, frameWidth, -frameWidth, -frameWidth);
- drawPrimitive(PE_FrameFocusRect, &fr, painter, widget);
- }
if (toolBtn->features & QStyleOptionToolButton::Arrow) {
QStyle::PrimitiveElement pe;
@@ -1209,13 +1182,6 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom
groupBox->palette, groupBox->state & State_Enabled, groupBox->text,
textColor.isValid() ? QPalette::NoRole : QPalette::WindowText);
painter->restore();
-
- if (groupBox->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*groupBox);
- fropt.rect = textRect;
- drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
}
// Draw checkbox
@@ -1249,12 +1215,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
drawControl(CE_PushButtonLabel, &subopt, painter, widget);
- if (btn->state & State_HasFocus) {
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*btn);
- fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget);
- drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
}
break;
case CE_PushButtonBevel:
@@ -1612,18 +1572,6 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
if (verticalTabs)
painter->restore();
- if (optionTab.state & State_HasFocus) {
- const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
- const int leftBorder = optionTab.rect.left();
- const int rightBorder = optionTab.rect.right() - 1;
-
- QStyleOptionFocusRect fropt;
- fropt.QStyleOption::operator=(*tab);
- fropt.rect.setRect(leftBorder + 1 + OFFSET, optionTab.rect.y() + OFFSET,
- rightBorder - leftBorder - 2*OFFSET, optionTab.rect.height() - 2*OFFSET);
- drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);
- }
-
painter->restore();
}
break;
@@ -1875,11 +1823,48 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option,
} else if (qobject_cast<const QFrame *>(widget)) {
QCommonStyle::drawControl(element, option, painter, widget);
}
- if (option->state & State_HasFocus)
- drawPrimitive(PE_FrameFocusRect, option, painter, widget);
break;
case CE_MenuScroller:
break;
+ case CE_FocusFrame:
+ {
+ // The pen width should nearly fill the layoutspacings around the widget
+ const int penWidth =
+ qMin(pixelMetric(QS60Style::PM_LayoutVerticalSpacing), pixelMetric(QS60Style::PM_LayoutHorizontalSpacing))
+ - 2; // But keep 1 pixel distance to the focus widget and 1 pixel to the adjacent widgets
+
+#ifdef QT_KEYPAD_NAVIGATION
+ bool editFocus = false;
+ if (const QFocusFrame *focusFrame = qobject_cast<const QFocusFrame*>(widget)) {
+ if (focusFrame->widget() && focusFrame->widget()->hasEditFocus())
+ editFocus = true;
+ }
+ const qreal opacity = editFocus ? 0.65 : 0.45; // Trial and error factors. Feel free to improve.
+#else
+ const qreal opacity = 0.5;
+#endif
+ // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred.
+ const qreal rectAdjustment = (penWidth % 2) ? -.5 : 0;
+
+ // Make sure that the pen stroke is inside the rect
+ const QRectF adjustedRect =
+ QRectF(option->rect).adjusted(
+ rectAdjustment + penWidth,
+ rectAdjustment + penWidth,
+ -rectAdjustment - penWidth,
+ -rectAdjustment - penWidth
+ );
+
+ const qreal roundRectRadius = penWidth * goldenRatio;
+
+ painter->save();
+ painter->setRenderHint(QPainter::Antialiasing);
+ painter->setOpacity(opacity);
+ painter->setPen(QPen(option->palette.color(QPalette::Highlight), penWidth));
+ painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius);
+ painter->restore();
+ }
+ break;
default:
QCommonStyle::drawControl(element, option, painter, widget);
}
@@ -1901,9 +1886,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
#endif
QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_FrameLineEdit,
painter, option->rect, flags);
-
- if (lineEdit->state & State_HasFocus)
- drawPrimitive(PE_FrameFocusRect, lineEdit, painter, widget);
}
break;
#endif // QT_NO_LINEEDIT
@@ -2030,50 +2012,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
#endif //QT_NO_COMBOBOX
break;
#endif //QT_NO_SPINBOX
- case PE_FrameFocusRect:
-// Calendar widget and combox both do not use styled itemDelegate
- if (widget && !(false
-#ifndef QT_NO_CALENDARWIDGET
- || qobject_cast<const QCalendarWidget *>(widget->parent())
-#endif //QT_NO_CALENDARWIDGET
-#ifndef QT_NO_COMBOBOX
- || qobject_cast<const QComboBoxListView *>(widget)
-#endif //QT_NO_COMBOBOX
- )) {
- // no focus selection for touch
- if (option->state & State_HasFocus && !QS60StylePrivate::isTouchSupported()) {
- painter->save();
- const int penWidth = QS60StylePrivate::focusRectPenWidth();
-#ifdef QT_KEYPAD_NAVIGATION
- const Qt::PenStyle penStyle = widget->hasEditFocus() ? Qt::SolidLine :Qt::DashLine;
- const qreal opacity = widget->hasEditFocus() ? 0.6 : 0.4;
-#else
- const Qt::PenStyle penStyle = Qt::SolidLine;
- const qreal opacity = 0.5;
-#endif
- painter->setRenderHint(QPainter::Antialiasing);
- painter->setOpacity(opacity);
- // Because of Qts coordinate system, we need to tweak the rect by .5 pixels, otherwise it gets blurred.
- const qreal rectAdjustment = penWidth % 2?.5:0;
- // Also we try to stay inside the option->rect, with penWidth > 1. Therefore these +1/-1
- const QRectF adjustedRect = QRectF(option->rect).adjusted(
- rectAdjustment + penWidth - 1,
- rectAdjustment + penWidth - 1,
- -rectAdjustment - penWidth + 1,
- -rectAdjustment - penWidth + 1);
- const qreal roundRectRadius = penWidth * 1.5;
-#ifdef QT_KEYPAD_NAVIGATION
- if (penStyle != Qt::SolidLine) {
- painter->setPen(QPen(option->palette.color(QPalette::HighlightedText), penWidth, Qt::SolidLine));
- painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius);
- }
-#endif
- painter->setPen(QPen((option->palette.color(QPalette::Text), penWidth, penStyle)));
- painter->drawRoundedRect(adjustedRect, roundRectRadius, roundRectRadius);
- painter->restore();
- }
- }
- break;
case PE_Widget:
if (QS60StylePrivate::drawsOwnThemeBackground(widget)
#ifndef QT_NO_COMBOBOX
@@ -2118,8 +2056,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti
Q_ASSERT(false);
break;
case PE_Frame:
- if (const QStyleOptionFrameV3 *frame = qstyleoption_cast<const QStyleOptionFrameV3 *>(option))
- drawPrimitive(PE_FrameFocusRect, frame, painter, widget);
break;
#ifndef QT_NO_ITEMVIEWS
case PE_PanelItemViewItem:
@@ -2668,16 +2604,6 @@ QRect QS60Style::subElementRect(SubElement element, const QStyleOption *opt, con
}
ret = visualRect(opt->direction, opt->rect, ret);
break;
- case SE_FrameContents:
- if (QS60StylePrivate::isTouchSupported()) {
- return QCommonStyle::subElementRect(element, opt, widget);
- } else if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) {
- // We shrink the frame contents by focusFrameWidth, so that we can draw the frame around it in keypad navigation mode.
- const int frameWidth = QS60StylePrivate::focusRectPenWidth();
- ret = opt->rect.adjusted(frameWidth, frameWidth, -frameWidth, -frameWidth);
- ret = visualRect(opt->direction, opt->rect, ret);
- }
- break;
default:
ret = QCommonStyle::subElementRect(element, opt, widget);
}
@@ -2778,6 +2704,40 @@ QVariant QS60Style::styleProperty(const char *name) const
return d->styleProperty_specific(name);
}
+bool QS60Style::event(QEvent *e)
+{
+#ifdef QT_KEYPAD_NAVIGATION
+ if (QS60StylePrivate::isTouchSupported())
+ return false;
+ Q_D(QS60Style);
+ switch (e->type()) {
+ case QEvent::FocusIn:
+ if (QWidget *focusWidget = QApplication::focusWidget()) {
+ if (!d->m_focusFrame)
+ d->m_focusFrame = new QFocusFrame(focusWidget);
+ d->m_focusFrame->setWidget(focusWidget);
+ } else if (d->m_focusFrame) {
+ d->m_focusFrame->setWidget(0);
+ }
+ break;
+ case QEvent::FocusOut:
+ if (d->m_focusFrame)
+ d->m_focusFrame->setWidget(0);
+ break;
+ case QEvent::EnterEditFocus:
+ case QEvent::LeaveEditFocus:
+ if (d->m_focusFrame)
+ d->m_focusFrame->update();
+ break;
+ default:
+ break;
+ }
+#else
+ Q_UNUSED(e)
+#endif
+ return false;
+}
+
QIcon QS60Style::standardIconImplementation(StandardPixmap standardIcon,
const QStyleOption *option, const QWidget *widget) const
{
diff --git a/src/gui/styles/qs60style.h b/src/gui/styles/qs60style.h
index a03803b..c01c40a 100644
--- a/src/gui/styles/qs60style.h
+++ b/src/gui/styles/qs60style.h
@@ -80,6 +80,8 @@ public:
void setStyleProperty(const char *name, const QVariant &value);
QVariant styleProperty(const char *name) const;
+ bool event(QEvent *e);
+
#ifndef Q_WS_S60
static QStringList partKeys();
static QStringList colorListKeys();
diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h
index 2e661c0..ed0abfa 100644
--- a/src/gui/styles/qs60style_p.h
+++ b/src/gui/styles/qs60style_p.h
@@ -292,6 +292,8 @@ public:
};
};
+class QFocusFrame;
+
// Private class
#ifdef Q_OS_SYMBIAN
NONSHARABLE_CLASS (QS60StylePrivate)
@@ -430,8 +432,6 @@ public:
//access to theme palette
static QPalette* themePalette();
- static int focusRectPenWidth();
-
static const layoutHeader m_layoutHeaders[];
static const short data[][MAX_PIXELMETRICS];
@@ -499,6 +499,8 @@ private:
// defined theme palette
static QPalette *m_themePalette;
QPalette m_originalPalette;
+
+ QPointer<QFocusFrame> m_focusFrame;
};
QT_END_NAMESPACE
diff --git a/src/gui/styles/qs60style_s60.cpp b/src/gui/styles/qs60style_s60.cpp
index bc218cd..1cf47cc 100644
--- a/src/gui/styles/qs60style_s60.cpp
+++ b/src/gui/styles/qs60style_s60.cpp
@@ -1350,9 +1350,6 @@ void QS60StyleModeSpecifics::colorGroupAndIndex(
}
}
-/*!
- Constructs a QS60Style object.
-*/
QS60Style::QS60Style()
: QCommonStyle(*new QS60StylePrivate)
{
diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp
index 350ef51..2d185bd 100644
--- a/src/gui/styles/qs60style_simulated.cpp
+++ b/src/gui/styles/qs60style_simulated.cpp
@@ -366,8 +366,7 @@ QFont QS60StylePrivate::s60Font_specific(QS60StyleEnums::FontCategories fontCate
QS60Style::QS60Style()
: QCommonStyle(*new QS60StylePrivate)
{
- // Assume, that the resource system has a ':/s60Stylethemes/Default.blob'
- const QString defaultBlob = QString::fromLatin1(":/s60Stylethemes/Default.blob");
+ const QString defaultBlob = QString::fromLatin1(":/trolltech/styles/s60style/images/defaults60theme.blob");
if (QFile::exists(defaultBlob))
loadS60ThemeFromBlob(defaultBlob);
}
diff --git a/src/gui/styles/qstyle_s60_simulated.qrc b/src/gui/styles/qstyle_s60_simulated.qrc
index 72aab9e..969732e 100644
--- a/src/gui/styles/qstyle_s60_simulated.qrc
+++ b/src/gui/styles/qstyle_s60_simulated.qrc
@@ -1,6 +1,6 @@
<!DOCTYPE RCC>
<RCC version="1.0">
<qresource prefix="/trolltech/styles/s60style">
- <file>images/s60themes.dat</file>
+ <file>images/defaults60theme.blob</file>
</qresource>
</RCC>
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 7acb3a6..da71ced 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -214,6 +214,7 @@ enum PseudoElement {
PseudoElement_ViewItemText,
PseudoElement_ViewItemIndicator,
PseudoElement_ScrollAreaCorner,
+ PseudoElement_TabBarTabCloseButton,
NumPseudoElements
};
@@ -223,7 +224,7 @@ struct PseudoElementInfo {
};
static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = {
- { QStyle::SC_None, "", },
+ { QStyle::SC_None, "" },
{ QStyle::SC_None, "down-arrow" },
{ QStyle::SC_None, "up-arrow" },
{ QStyle::SC_None, "left-arrow" },
@@ -300,8 +301,9 @@ static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = {
{ QStyle::SC_None, "item" },
{ QStyle::SC_None, "icon" },
{ QStyle::SC_None, "text" },
- { QStyle::SC_None, "indicator" } ,
- { QStyle::SC_None, "corner" }
+ { QStyle::SC_None, "indicator" },
+ { QStyle::SC_None, "corner" },
+ { QStyle::SC_None, "close-button" },
};
@@ -4370,6 +4372,12 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op
case PE_IndicatorSpinPlus:
pseudoElement = PseudoElement_SpinBoxUpArrow;
break;
+#ifndef QT_NO_TABBAR
+ case PE_IndicatorTabClose:
+ if (w)
+ w = w->parentWidget(); //match on the QTabBar instead of the CloseButton
+ pseudoElement = PseudoElement_TabBarTabCloseButton;
+#endif
default:
break;
@@ -5104,6 +5112,18 @@ int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWi
#endif // QT_NO_TABWIDGET
s = QLatin1String("alignment");
break;
+#ifndef QT_NO_TABBAR
+ case SH_TabBar_CloseButtonPosition:
+ rule = renderRule(w, opt, PseudoElement_TabBarTabCloseButton);
+ if (rule.hasPosition()) {
+ Qt::Alignment align = rule.position()->position;
+ if (align & Qt::AlignLeft || align & Qt::AlignTop)
+ return QTabBar::LeftSide;
+ if (align & Qt::AlignRight || align & Qt::AlignBottom)
+ return QTabBar::RightSide;
+ }
+ break;
+#endif
case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break;
case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break;
case SH_ComboBox_PopupFrameStyle:
diff --git a/src/gui/styles/styles.pri b/src/gui/styles/styles.pri
index 70ac6cb..767ade0 100644
--- a/src/gui/styles/styles.pri
+++ b/src/gui/styles/styles.pri
@@ -168,11 +168,10 @@ contains( styles, s60 ):contains(QT_CONFIG, s60) {
SOURCES += styles/qs60style.cpp
symbian {
SOURCES += styles/qs60style_s60.cpp
- # TODO: fix the following LIBS hack. Line 1 is for armv5, 2 for winscw
- LIBS += aknicon aknskins aknskinsrv fontutils
LIBS += -laknicon -laknskins -laknskinsrv -lfontutils
} else {
SOURCES += styles/qs60style_simulated.cpp
+ RESOURCES += styles/qstyle_s60_simulated.qrc
}
} else {
DEFINES += QT_NO_STYLE_S60
diff --git a/src/gui/text/qfontdatabase_s60.cpp b/src/gui/text/qfontdatabase_s60.cpp
index 058041b..fe90010 100644
--- a/src/gui/text/qfontdatabase_s60.cpp
+++ b/src/gui/text/qfontdatabase_s60.cpp
@@ -126,8 +126,13 @@ QFontDatabaseS60StoreImplementation::QFontDatabaseS60StoreImplementation()
}
QFontDatabaseS60StoreImplementation::~QFontDatabaseS60StoreImplementation()
{
- qDeleteAll(m_extensions);
- // TODO m_store cleanup removed because it was crashing
+ typedef QHash<QString, const QFontEngineS60Extensions *>::iterator iterator;
+ for (iterator p = m_extensions.begin(); p != m_extensions.end(); ++p) {
+ m_store->ReleaseFont((*p)->fontOwner());
+ delete *p;
+ }
+
+ delete m_store;
m_heap->Close();
}
@@ -140,7 +145,7 @@ const QFontEngineS60Extensions *QFontDatabaseS60StoreImplementation::extension(c
const TInt err = m_store->GetNearestFontToDesignHeightInPixels(font, spec);
Q_ASSERT(err == KErrNone && font);
CBitmapFont *bitmapFont = static_cast<CBitmapFont*>(font);
- m_extensions.insert(typeface, new QFontEngineS60Extensions(bitmapFont->OpenFont()));
+ m_extensions.insert(typeface, new QFontEngineS60Extensions(font, bitmapFont->OpenFont()));
}
return m_extensions.value(typeface);
}
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_s60.cpp b/src/gui/text/qfontengine_s60.cpp
index eba21e8..ed6b1c1 100644
--- a/src/gui/text/qfontengine_s60.cpp
+++ b/src/gui/text/qfontengine_s60.cpp
@@ -54,10 +54,11 @@
QT_BEGIN_NAMESPACE
-QFontEngineS60Extensions::QFontEngineS60Extensions(COpenFont *font)
+QFontEngineS60Extensions::QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font)
: m_font(font)
, m_cmap(0)
, m_symbolCMap(false)
+ , m_fontOwner(fontOwner)
{
TAny *shapingExtension = NULL;
m_font->ExtendedInterface(KUidOpenFontShapingExtension, shapingExtension);
@@ -109,6 +110,12 @@ QPainterPath QFontEngineS60Extensions::glyphOutline(glyph_t glyph) const
return result;
}
+CFont *QFontEngineS60Extensions::fontOwner() const
+{
+ return m_fontOwner;
+}
+
+
// duplicated from qfontengine_xyz.cpp
static inline unsigned int getChar(const QChar *str, int &i, const int len)
{
diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h
index 0c1be8c..bbbc3d6 100644
--- a/src/gui/text/qfontengine_s60_p.h
+++ b/src/gui/text/qfontengine_s60_p.h
@@ -69,11 +69,12 @@ QT_BEGIN_NAMESPACE
class QFontEngineS60Extensions
{
public:
- QFontEngineS60Extensions(COpenFont *font);
+ QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font);
QByteArray getSfntTable(uint tag) const;
const unsigned char *cmap() const;
QPainterPath glyphOutline(glyph_t glyph) const;
+ CFont *fontOwner() const;
private:
COpenFont *m_font;
@@ -82,6 +83,7 @@ private:
mutable const unsigned char *m_cmap;
mutable bool m_symbolCMap;
mutable QByteArray m_cmapTable;
+ CFont* m_fontOwner;
};
class QFontEngineS60 : public QFontEngine
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 465c1d8..ea7fbde 100644
--- a/src/gui/util/qsystemtrayicon_win.cpp
+++ b/src/gui/util/qsystemtrayicon_win.cpp
@@ -132,11 +132,12 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *object)
: hIcon(0), q(object), ignoreNextMouseRelease(false)
{
- notifyIconSize = sizeof(NOTIFYICONDATA);
-#ifdef Q_OS_WINCE
- 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 1b4d41b..d1adfee 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -1356,7 +1356,7 @@ void QAbstractScrollAreaPrivate::_q_gestureTriggered()
return;
QScrollBar *hBar = q->horizontalScrollBar();
QScrollBar *vBar = q->verticalScrollBar();
- QSize delta = g->lastOffset();
+ QSizeF delta = g->lastOffset();
if (!delta.isNull()) {
if (QApplication::isRightToLeft())
delta.rwidth() *= -1;
diff --git a/src/gui/widgets/qcocoatoolbardelegate_mac.mm b/src/gui/widgets/qcocoatoolbardelegate_mac.mm
index 3b58a4e..2ef0ead 100644
--- a/src/gui/widgets/qcocoatoolbardelegate_mac.mm
+++ b/src/gui/widgets/qcocoatoolbardelegate_mac.mm
@@ -100,7 +100,8 @@ QT_FORWARD_DECLARE_CLASS(QCFString);
{
Q_UNUSED(flag);
Q_UNUSED(nstoolbar);
- QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(qt_mac_NSStringToQString(itemIdentifier));
+ QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(
+ QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)(itemIdentifier));
NSToolbarItem *item = nil;
if (tb) {
item = [[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier];
@@ -112,7 +113,8 @@ QT_FORWARD_DECLARE_CLASS(QCFString);
- (void)toolbarWillAddItem:(NSNotification *)notification
{
NSToolbarItem *item = [[notification userInfo] valueForKey:@"item"];
- QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(qt_mac_NSStringToQString([item itemIdentifier]));
+ QToolBar *tb = mainWindowLayout->cocoaItemIDToToolbarHash.value(
+ QT_PREPEND_NAMESPACE(qt_mac_NSStringToQString)([item itemIdentifier]));
if (!tb)
return; // I can't really do anything about this.
[item retain];
diff --git a/src/gui/widgets/qlinecontrol_p.h b/src/gui/widgets/qlinecontrol_p.h
index adea742..0db6279 100644
--- a/src/gui/widgets/qlinecontrol_p.h
+++ b/src/gui/widgets/qlinecontrol_p.h
@@ -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 299ecfc..059aaf1 100644
--- a/src/gui/widgets/qlineedit.cpp
+++ b/src/gui/widgets/qlineedit.cpp
@@ -1395,7 +1395,7 @@ bool QLineEdit::event(QEvent * e)
if (e->type() == QEvent::EnterEditFocus) {
end(false);
d->setCursorVisible(true);
- d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()/2);
+ d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
} else if (e->type() == QEvent::LeaveEditFocus) {
d->setCursorVisible(false);
d->control->setCursorBlinkPeriod(0);
@@ -1690,7 +1690,7 @@ void QLineEdit::focusInEvent(QFocusEvent *e)
#ifdef QT_KEYPAD_NAVIGATION
if (!QApplication::keypadNavigationEnabled() || (hasEditFocus() && e->reason() == Qt::PopupFocusReason)){
#endif
- d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime()/2);
+ d->control->setCursorBlinkPeriod(QApplication::cursorFlashTime());
QStyleOptionFrameV2 opt;
initStyleOption(&opt);
if((!hasSelectedText() && d->control->preeditAreaText().isEmpty())
@@ -2002,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 3521dcb..260bc19 100644
--- a/src/gui/widgets/qlineedit_p.h
+++ b/src/gui/widgets/qlineedit_p.h
@@ -122,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/qmenu.cpp b/src/gui/widgets/qmenu.cpp
index f0f425f..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()
{
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index 47a8042..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);
}
}
}
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index e025876..6ac521b 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -379,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) {
@@ -2934,7 +2934,7 @@ void QPlainTextEditPrivate::_q_gestureTriggered()
QScrollBar *vBar = q->verticalScrollBar();
if (g->state() == Qt::GestureStarted)
originalOffsetY = vBar->value();
- QSize totalOffset = g->totalOffset();
+ QSizeF totalOffset = g->totalOffset();
if (!totalOffset.isNull()) {
if (QApplication::isRightToLeft())
totalOffset.rwidth() *= -1;
diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp
index 5166390..531c429 100644
--- a/src/gui/widgets/qtabbar.cpp
+++ b/src/gui/widgets/qtabbar.cpp
@@ -1293,6 +1293,7 @@ QSize QTabBarPrivate::minimumTabSizeHint(int index)
*/
QSize QTabBar::tabSizeHint(int index) const
{
+ //Note: this must match with the computations in QCommonStylePrivate::tabLayout
Q_D(const QTabBar);
if (const QTabBarPrivate::Tab *tab = d->at(index)) {
QStyleOptionTabV3 opt;
@@ -1309,18 +1310,18 @@ QSize QTabBar::tabSizeHint(int index) const
int widgetWidth = 0;
int widgetHeight = 0;
int padding = 0;
- if (opt.leftButtonSize.isValid()) {
- padding += 6 + 2;
+ if (!opt.leftButtonSize.isEmpty()) {
+ padding += 4;
widgetWidth += opt.leftButtonSize.width();
widgetHeight += opt.leftButtonSize.height();
}
- if (opt.rightButtonSize.isValid()) {
- padding += 6 + 2;
+ if (!opt.rightButtonSize.isEmpty()) {
+ padding += 4;
widgetWidth += opt.rightButtonSize.width();
widgetHeight += opt.rightButtonSize.height();
}
- if (opt.iconSize.isValid())
- padding += 2;
+ if (!opt.icon.isNull())
+ padding += 4;
QSize csz;
if (verticalTabs(d->shape)) {
@@ -1836,7 +1837,8 @@ void QTabBarPrivate::moveTabFinished(int index)
}
#endif //QT_NO_ANIMATION
if (allAnimationsFinished && cleanup) {
- movingTab->setVisible(false); // We might not get a mouse release
+ if(movingTab)
+ movingTab->setVisible(false); // We might not get a mouse release
for (int i = 0; i < tabList.count(); ++i) {
tabList[i].dragOffset = 0;
}
diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp
index bf44ea1..89e6d7a 100644
--- a/src/gui/widgets/qtoolbar.cpp
+++ b/src/gui/widgets/qtoolbar.cpp
@@ -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/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;