summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-06-16 12:16:23 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-06-16 12:16:23 (GMT)
commit714a62490fd30986dc86559e6f14194a34b3a5bc (patch)
treec5c189fb22eb2f20a6cf70c176f02dd348c83610 /src/gui
parentaa1120804708c44ac72e20e228d5ef383a1cd62a (diff)
parentc41591d57377cd7c520efc93d9c087ad34d2bb6f (diff)
downloadQt-714a62490fd30986dc86559e6f14194a34b3a5bc.zip
Qt-714a62490fd30986dc86559e6f14194a34b3a5bc.tar.gz
Qt-714a62490fd30986dc86559e6f14194a34b3a5bc.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: doc/src/qnamespace.qdoc doc/src/snippets/code/src_gui_qproxystyle.cpp src/3rdparty/webkit/VERSION src/3rdparty/webkit/WebKit/qt/ChangeLog src/gui/graphicsview/qgraphicsscene.cpp src/gui/kernel/qapplication.cpp src/gui/kernel/qapplication_x11.cpp src/gui/kernel/qt_x11_p.h src/gui/kernel/qwidget.cpp src/gui/styles/qproxystyle.cpp src/gui/styles/qstyle.cpp src/scripttools/debugging/qscriptdebugger.cpp src/scripttools/debugging/qscriptenginedebugger.cpp src/sql/drivers/odbc/qsql_odbc.cpp src/sql/kernel/qsqldatabase.cpp src/sql/kernel/qsqldriver.cpp
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp44
-rw-r--r--src/gui/kernel/qapplication.cpp2
-rw-r--r--src/gui/kernel/qapplication_x11.cpp17
-rw-r--r--src/gui/kernel/qt_x11_p.h2
-rw-r--r--src/gui/kernel/qwidget.cpp4
-rw-r--r--src/gui/math3d/qgenericmatrix.cpp2
-rw-r--r--src/gui/painting/qmatrix.cpp11
-rw-r--r--src/gui/painting/qmatrix.h11
-rw-r--r--src/gui/painting/qregion.cpp4
-rw-r--r--src/gui/painting/qtransform.cpp25
-rw-r--r--src/gui/painting/qtransform.h14
-rw-r--r--src/gui/styles/qproxystyle.cpp144
-rw-r--r--src/gui/styles/qstyle.cpp32
-rw-r--r--src/gui/widgets/qmenu_mac.mm59
-rw-r--r--src/gui/widgets/qmenu_p.h5
-rw-r--r--src/gui/widgets/qplaintextedit.cpp1
-rw-r--r--src/gui/widgets/qtextedit.cpp1
17 files changed, 266 insertions, 112 deletions
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 494eab2..e40796b 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -5197,6 +5197,9 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
opacity = parentOpacity;
}
+ // Item is invisible.
+ bool invisible = !item || ((item->d_ptr->flags & QGraphicsItem::ItemHasNoContents) || invisibleButChildIgnoresParentOpacity);
+
// Calculate the full transform for this item.
bool wasDirtyParentSceneTransform = false;
bool dontDrawItem = true;
@@ -5216,16 +5219,18 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
transform *= viewTransform;
}
- QRectF brect = item->boundingRect();
- // ### This does not take the clip into account.
- _q_adjustRect(&brect);
- QRect viewBoundingRect = transform.mapRect(brect).toRect();
- item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
- viewBoundingRect.adjust(-1, -1, 1, 1);
- if (exposedRegion)
- dontDrawItem = !exposedRegion->intersects(viewBoundingRect);
- else
- dontDrawItem = viewBoundingRect.isEmpty();
+ if (!invisible) {
+ QRectF brect = item->boundingRect();
+ // ### This does not take the clip into account.
+ _q_adjustRect(&brect);
+ QRect viewBoundingRect = transform.mapRect(brect).toRect();
+ item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
+ viewBoundingRect.adjust(-1, -1, 1, 1);
+ if (exposedRegion)
+ dontDrawItem = !exposedRegion->intersects(viewBoundingRect);
+ else
+ dontDrawItem = viewBoundingRect.isEmpty();
+ }
}
// Find and sort children.
@@ -5282,7 +5287,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
bool childClip = (item && (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape));
bool dontDrawChildren = item && dontDrawItem && childClip;
childClip &= !dontDrawChildren && !children->isEmpty();
- if (item && ((item->d_ptr->flags & QGraphicsItem::ItemHasNoContents) || invisibleButChildIgnoresParentOpacity))
+ if (item && invisible)
dontDrawItem = true;
// Clip children.
@@ -5291,7 +5296,7 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *
painter->setWorldTransform(transform);
painter->setClipPath(item->shape(), Qt::IntersectClip);
}
-
+
if (!dontDrawChildren) {
if (item && item->d_ptr->needSortChildren) {
item->d_ptr->needSortChildren = 0;
@@ -5401,11 +5406,14 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b
return;
}
- item->d_ptr->dirty = 1;
- if (fullItemUpdate)
- item->d_ptr->fullUpdatePending = 1;
- else if (!item->d_ptr->fullUpdatePending)
- item->d_ptr->needsRepaint |= rect;
+ bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents;
+ if (!hasNoContents) {
+ item->d_ptr->dirty = 1;
+ if (fullItemUpdate)
+ item->d_ptr->fullUpdatePending = 1;
+ else if (!item->d_ptr->fullUpdatePending)
+ item->d_ptr->needsRepaint |= rect;
+ }
if (invalidateChildren) {
item->d_ptr->allChildrenDirty = 1;
@@ -5971,7 +5979,7 @@ void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouch
{
QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
for (int i = 0; i < touchPoints.count(); ++i) {
- QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
+ QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect());
touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), touchEvent->widget()));
touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), touchEvent->widget()));
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 5269841..509f5fd 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -1400,7 +1400,7 @@ void QApplication::setStyle(QStyle *style)
#endif // QT_NO_STYLE_STYLESHEET
QApplicationPrivate::app_style = style;
QApplicationPrivate::app_style->setParent(qApp); // take ownership
-
+
// take care of possible palette requirements of certain gui
// styles. Do it before polishing the application since the style
// might call QApplication::setPalette() itself
diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp
index 9d8625c..27ee6d8 100644
--- a/src/gui/kernel/qapplication_x11.cpp
+++ b/src/gui/kernel/qapplication_x11.cpp
@@ -134,7 +134,7 @@ extern "C" {
# include <errno.h>
#endif
-#if defined(Q_OS_BSD4) || _POSIX_VERSION+0 < 200112L
+#if _POSIX_VERSION+0 < 200112L && !defined(Q_OS_BSD4)
# define QT_NO_UNSETENV
#endif
@@ -1767,7 +1767,7 @@ void qt_init(QApplicationPrivate *priv, int,
X11->pattern_fills[i].screen = -1;
#endif
- X11->startupId = X11->originalStartupId = X11->startupIdString = 0;
+ X11->startupId = 0;
int argc = priv->argc;
char **argv = priv->argv;
@@ -2565,15 +2565,13 @@ void qt_init(QApplicationPrivate *priv, int,
#endif // QT_NO_TABLET
X11->startupId = getenv("DESKTOP_STARTUP_ID");
- X11->originalStartupId = X11->startupId;
if (X11->startupId) {
#ifndef QT_NO_UNSETENV
unsetenv("DESKTOP_STARTUP_ID");
#else
// it's a small memory leak, however we won't crash if Qt is
// unloaded and someones tries to use the envoriment.
- X11->startupIdString = strdup("DESKTOP_STARTUP_ID=");
- putenv(X11->startupIdString);
+ putenv(strdup("DESKTOP_STARTUP_ID="));
#endif
}
} else {
@@ -2707,15 +2705,6 @@ void qt_cleanup()
#endif
}
-#ifdef QT_NO_UNSETENV
- // restore original value back.
- if (X11->originalStartupId && X11->startupIdString) {
- putenv(X11->originalStartupId);
- free(X11->startupIdString);
- X11->startupIdString = 0;
- }
-#endif
-
#ifndef QT_NO_XRENDER
for (int i = 0; i < X11->solid_fill_count; ++i) {
if (X11->solid_fills[i].picture)
diff --git a/src/gui/kernel/qt_x11_p.h b/src/gui/kernel/qt_x11_p.h
index b480f34..3493a8b 100644
--- a/src/gui/kernel/qt_x11_p.h
+++ b/src/gui/kernel/qt_x11_p.h
@@ -506,8 +506,6 @@ struct QX11Data
int fc_hint_style;
char *startupId;
- char *originalStartupId;
- char *startupIdString;
DesktopEnvironment desktopEnvironment;
diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp
index f95372b..6e12540 100644
--- a/src/gui/kernel/qwidget.cpp
+++ b/src/gui/kernel/qwidget.cpp
@@ -1,4 +1,4 @@
-/****************************************************************************
+****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
** Contact: Qt Software Information (qt-info@nokia.com)
@@ -5638,7 +5638,7 @@ bool QWidget::hasFocus() const
called from focusOutEvent() or focusInEvent(), you may get an
infinite recursion.
- \sa focus(), hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(),
+ \sa hasFocus(), clearFocus(), focusInEvent(), focusOutEvent(),
setFocusPolicy(), focusWidget(), QApplication::focusWidget(), grabKeyboard(),
grabMouse(), {Keyboard Focus}
*/
diff --git a/src/gui/math3d/qgenericmatrix.cpp b/src/gui/math3d/qgenericmatrix.cpp
index 19a0f6e..82be256 100644
--- a/src/gui/math3d/qgenericmatrix.cpp
+++ b/src/gui/math3d/qgenericmatrix.cpp
@@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE
But they can be different if the user wants to store elements
internally in a fixed-point format for the underlying hardware.
- \sa QMatrix4x4, QFixedPt
+ \sa QMatrix4x4
*/
/*!
diff --git a/src/gui/painting/qmatrix.cpp b/src/gui/painting/qmatrix.cpp
index 030415d..7e26a99 100644
--- a/src/gui/painting/qmatrix.cpp
+++ b/src/gui/painting/qmatrix.cpp
@@ -1194,4 +1194,15 @@ QDebug operator<<(QDebug dbg, const QMatrix &m)
Use the mapRect() function instead.
*/
+
+/*!
+ \fn bool qFuzzyCompare(const QMatrix& m1, const QMatrix& m2)
+
+ \relates QMatrix
+ \since 4.6
+
+ Returns true if \a m1 and \a m2 are equal, allowing for a small
+ fuzziness factor for floating-point comparisons; false otherwise.
+*/
+
QT_END_NAMESPACE
diff --git a/src/gui/painting/qmatrix.h b/src/gui/painting/qmatrix.h
index 1df2395..4a4e91f 100644
--- a/src/gui/painting/qmatrix.h
+++ b/src/gui/painting/qmatrix.h
@@ -165,6 +165,17 @@ inline bool QMatrix::isIdentity() const
&& qFuzzyIsNull(_m21) && qFuzzyIsNull(_dx) && qFuzzyIsNull(_dy);
}
+inline bool qFuzzyCompare(const QMatrix& m1, const QMatrix& m2)
+{
+ return qFuzzyCompare(m1.m11(), m2.m11())
+ && qFuzzyCompare(m1.m12(), m2.m12())
+ && qFuzzyCompare(m1.m21(), m2.m21())
+ && qFuzzyCompare(m1.m22(), m2.m22())
+ && qFuzzyCompare(m1.dx(), m2.dx())
+ && qFuzzyCompare(m1.dy(), m2.dy());
+}
+
+
/*****************************************************************************
QMatrix stream functions
*****************************************************************************/
diff --git a/src/gui/painting/qregion.cpp b/src/gui/painting/qregion.cpp
index c4cd77a..03e01c9 100644
--- a/src/gui/painting/qregion.cpp
+++ b/src/gui/painting/qregion.cpp
@@ -698,6 +698,8 @@ bool QRegion::intersects(const QRegion &region) const
if (!rect_intersects(boundingRect(), region.boundingRect()))
return false;
+ if (numRects() == 1 && region.numRects() == 1)
+ return true;
const QVector<QRect> myRects = rects();
const QVector<QRect> otherRects = region.rects();
@@ -723,6 +725,8 @@ bool QRegion::intersects(const QRect &rect) const
const QRect r = rect.normalized();
if (!rect_intersects(boundingRect(), r))
return false;
+ if (numRects() == 1)
+ return true;
const QVector<QRect> myRects = rects();
for (QVector<QRect>::const_iterator it = myRects.constBegin(); it < myRects.constEnd(); ++it)
diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp
index 4bc20f6..385fde1 100644
--- a/src/gui/painting/qtransform.cpp
+++ b/src/gui/painting/qtransform.cpp
@@ -708,11 +708,15 @@ QTransform & QTransform::rotateRadians(qreal a, Qt::Axis axis)
*/
bool QTransform::operator==(const QTransform &o) const
{
-#define qFZ qFuzzyCompare
- return qFZ(affine._m11, o.affine._m11) && qFZ(affine._m12, o.affine._m12) && qFZ(m_13, o.m_13)
- && qFZ(affine._m21, o.affine._m21) && qFZ(affine._m22, o.affine._m22) && qFZ(m_23, o.m_23)
- && qFZ(affine._dx, o.affine._dx) && qFZ(affine._dy, o.affine._dy) && qFZ(m_33, o.m_33);
-#undef qFZ
+ return affine._m11 == o.affine._m11 &&
+ affine._m12 == o.affine._m12 &&
+ affine._m21 == o.affine._m21 &&
+ affine._m22 == o.affine._m22 &&
+ affine._dx == o.affine._dx &&
+ affine._dy == o.affine._dy &&
+ m_13 == o.m_13 &&
+ m_23 == o.m_23 &&
+ m_33 == o.m_33;
}
/*!
@@ -2178,6 +2182,17 @@ QTransform::operator QVariant() const
\sa reset()
*/
+/*!
+ \fn bool qFuzzyCompare(const QTransform& t1, const QTransform& t2)
+
+ \relates QTransform
+ \since 4.6
+
+ Returns true if \a t1 and \a t2 are equal, allowing for a small
+ fuzziness factor for floating-point comparisons; false otherwise.
+*/
+
+
// returns true if the transform is uniformly scaling
// (same scale in x and y direction)
// scale is set to the max of x and y scaling factors
diff --git a/src/gui/painting/qtransform.h b/src/gui/painting/qtransform.h
index a5002ca..57ec826 100644
--- a/src/gui/painting/qtransform.h
+++ b/src/gui/painting/qtransform.h
@@ -331,6 +331,20 @@ inline QTransform &QTransform::operator-=(qreal num)
return *this;
}
+inline bool qFuzzyCompare(const QTransform& t1, const QTransform& t2)
+{
+ return qFuzzyCompare(t1.m11(), t2.m11())
+ && qFuzzyCompare(t1.m12(), t2.m12())
+ && qFuzzyCompare(t1.m13(), t2.m13())
+ && qFuzzyCompare(t1.m21(), t2.m21())
+ && qFuzzyCompare(t1.m22(), t2.m22())
+ && qFuzzyCompare(t1.m23(), t2.m23())
+ && qFuzzyCompare(t1.m31(), t2.m31())
+ && qFuzzyCompare(t1.m32(), t2.m32())
+ && qFuzzyCompare(t1.m33(), t2.m33());
+}
+
+
/****** stream functions *******************/
#ifndef QT_NO_DATASTREAM
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &, const QTransform &);
diff --git a/src/gui/styles/qproxystyle.cpp b/src/gui/styles/qproxystyle.cpp
index f36ad64..37f25be 100644
--- a/src/gui/styles/qproxystyle.cpp
+++ b/src/gui/styles/qproxystyle.cpp
@@ -53,27 +53,28 @@ QT_BEGIN_NAMESPACE
/*!
\class QProxyStyle
- \brief The QProxyStyle is a convenience class that simplifies
- the creation of proxy styles in Qt.
+ \brief The QProxyStyle class is a convenience class that simplifies
+ the overriding of QStyle elements.
\since 4.6
- A proxy style is a style that wraps a different,
- usually the default system style, to override the painting or
- behavior of only specific parts.
+ A QProxyStyle wraps a QStyle (usually the default system style) for the
+ purpose of overriding the painting or other specific behavior of the
+ wrapped style.
- Here's an example allowing you to override the shortcut underline
+ Below is an example that overrides the shortcut underline
behavior on all platforms:
- \snippet doc/src/snippets/code/src_gui_proxystyle.cpp 0
+ \snippet doc/src/snippets/code/src_gui_qproxystyle.cpp 1
- Warning: Note that even though Qt's internal styles should respect this.
- hint, there is no guarantee that it will work for all styles.
- The example above would for instance not work on Mac since menus are
- handled by the operating system.
+ Warning: Although Qt's internal styles should respect this hint,
+ there is no guarantee that it will work for all styles. It would
+ not work on a Mac, for example, because menus are handled by the
+ operating system on the Mac.
\sa QStyle
*/
+
void QProxyStylePrivate::ensureBaseStyle() const
{
Q_Q(const QProxyStyle);
@@ -92,7 +93,7 @@ void QProxyStylePrivate::ensureBaseStyle() const
baseStyle = 0;
}
}
- }
+ }
if (!baseStyle) // Use application desktop style
baseStyle = QStyleFactory::create(QApplicationPrivate::desktopStyleKey());
@@ -105,12 +106,12 @@ void QProxyStylePrivate::ensureBaseStyle() const
}
/*!
- Constructs a QProxyStyle object.
-
- If no base style is provided, the current application style
- will be used as the base style.
+ Constructs a QProxyStyle object for overriding behavior in \a style
+ or in the current application \l{QStyle}{style} if \a style is 0
+ (default). Normally \a style is 0, because you want to override
+ behavior in the system style.
- Ownership of \style is transferred to QProxyStyle.
+ Ownership of \a style is transferred to QProxyStyle.
*/
QProxyStyle::QProxyStyle(QStyle *style) :
QCommonStyle(*new QProxyStylePrivate())
@@ -147,7 +148,7 @@ QStyle *QProxyStyle::baseStyle() const
/*!
Sets the base style that should be proxied.
- Ownership of \style is transferred to QProxyStyle.
+ Ownership of \a style is transferred to QProxyStyle.
If style is zero, a desktop-dependant style will be
assigned automatically.
@@ -167,7 +168,8 @@ void QProxyStyle::setBaseStyle(QStyle *style)
}
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -175,7 +177,9 @@ void QProxyStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *op
d->baseStyle->drawPrimitive(element, option, painter, widget);
}
-/*! reimp */
+/*!
+ \reimp
+ */
void QProxyStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -183,7 +187,8 @@ void QProxyStyle::drawControl(ControlElement element, const QStyleOption *option
d->baseStyle->drawControl(element, option, painter, widget);
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::drawComplexControl(ComplexControl control, const QStyleOptionComplex *option, QPainter *painter, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -191,7 +196,8 @@ void QProxyStyle::drawComplexControl(ComplexControl control, const QStyleOptionC
d->baseStyle->drawComplexControl(control, option, painter, widget);
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled,
const QString &text, QPalette::ColorRole textRole) const
{
@@ -200,7 +206,8 @@ void QProxyStyle::drawItemText(QPainter *painter, const QRect &rect, int flags,
d->baseStyle->drawItemText(painter, rect, flags, pal, enabled, text, textRole);
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
{
Q_D (const QProxyStyle);
@@ -208,7 +215,8 @@ void QProxyStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int align
d->baseStyle->drawItemPixmap(painter, rect, alignment, pixmap);
}
-/*! reimp */
+/*! \reimp
+ */
QSize QProxyStyle::sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &size, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -216,7 +224,8 @@ QSize QProxyStyle::sizeFromContents(ContentsType type, const QStyleOption *optio
return d->baseStyle->sizeFromContents(type, option, size, widget);
}
-/*! reimp */
+/*! \reimp
+ */
QRect QProxyStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -224,7 +233,8 @@ QRect QProxyStyle::subElementRect(SubElement element, const QStyleOption *option
return d->baseStyle->subElementRect(element, option, widget);
}
-/*! reimp */
+/*! \reimp
+ */
QRect QProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *option, SubControl sc, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -232,7 +242,8 @@ QRect QProxyStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *
return d->baseStyle->subControlRect(cc, option, sc, widget);
}
-/*! reimp */
+/*! \reimp
+ */
QRect QProxyStyle::itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
{
Q_D (const QProxyStyle);
@@ -240,7 +251,8 @@ QRect QProxyStyle::itemTextRect(const QFontMetrics &fm, const QRect &r, int flag
return d->baseStyle->itemTextRect(fm, r, flags, enabled, text);
}
-/*! reimp */
+/*! \reimp
+ */
QRect QProxyStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
{
Q_D (const QProxyStyle);
@@ -248,7 +260,8 @@ QRect QProxyStyle::itemPixmapRect(const QRect &r, int flags, const QPixmap &pixm
return d->baseStyle->itemPixmapRect(r, flags, pixmap);
}
-/*! reimp */
+/*! \reimp
+ */
QStyle::SubControl QProxyStyle::hitTestComplexControl(ComplexControl control, const QStyleOptionComplex *option, const QPoint &pos, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -256,7 +269,8 @@ QStyle::SubControl QProxyStyle::hitTestComplexControl(ComplexControl control, co
return d->baseStyle->hitTestComplexControl(control, option, pos, widget);
}
-/*! reimp */
+/*! \reimp
+ */
int QProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWidget *widget, QStyleHintReturn *returnData) const
{
Q_D (const QProxyStyle);
@@ -264,7 +278,8 @@ int QProxyStyle::styleHint(StyleHint hint, const QStyleOption *option, const QWi
return d->baseStyle->styleHint(hint, option, widget, returnData);
}
-/*! reimp */
+/*! \reimp
+ */
int QProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -272,7 +287,8 @@ int QProxyStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, con
return d->baseStyle->pixelMetric(metric, option, widget);
}
-/*! reimp */
+/*! \reimp
+ */
QPixmap QProxyStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget) const
{
Q_D (const QProxyStyle);
@@ -280,7 +296,8 @@ QPixmap QProxyStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleO
return d->baseStyle->standardPixmap(standardPixmap, opt, widget);
}
-/*! reimp */
+/*! \reimp
+ */
QPixmap QProxyStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
{
Q_D (const QProxyStyle);
@@ -288,7 +305,8 @@ QPixmap QProxyStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pi
return d->baseStyle->generatedIconPixmap(iconMode, pixmap, opt);
}
-/*! reimp */
+/*! \reimp
+ */
QPalette QProxyStyle::standardPalette() const
{
Q_D (const QProxyStyle);
@@ -296,7 +314,8 @@ QPalette QProxyStyle::standardPalette() const
return d->baseStyle->standardPalette();
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::polish(QWidget *widget)
{
Q_D (QProxyStyle);
@@ -304,7 +323,8 @@ void QProxyStyle::polish(QWidget *widget)
d->baseStyle->polish(widget);
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::polish(QPalette &pal)
{
Q_D (QProxyStyle);
@@ -312,7 +332,8 @@ void QProxyStyle::polish(QPalette &pal)
d->baseStyle->polish(pal);
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::polish(QApplication *app)
{
Q_D (QProxyStyle);
@@ -320,7 +341,8 @@ void QProxyStyle::polish(QApplication *app)
d->baseStyle->polish(app);
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::unpolish(QWidget *widget)
{
Q_D (QProxyStyle);
@@ -328,7 +350,8 @@ void QProxyStyle::unpolish(QWidget *widget)
d->baseStyle->unpolish(widget);
}
-/*! reimp */
+/*! \reimp
+ */
void QProxyStyle::unpolish(QApplication *app)
{
Q_D (QProxyStyle);
@@ -336,7 +359,8 @@ void QProxyStyle::unpolish(QApplication *app)
d->baseStyle->unpolish(app);
}
-/*! reimp */
+/*! \reimp
+ */
bool QProxyStyle::event(QEvent *e)
{
Q_D (QProxyStyle);
@@ -344,17 +368,47 @@ bool QProxyStyle::event(QEvent *e)
return d->baseStyle->event(e);
}
-/*! reimp */
-QIcon QProxyStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option, const QWidget *widget) const
+/*!
+ Returns an icon for the given \a standardIcon.
+
+ Reimplement this slot to provide your own icons in a QStyle
+ subclass. The \a option argument can be used to pass extra
+ information required to find the appropriate icon. The \a widget
+ argument is optional and can also be used to help find the icon.
+
+ \note Because of binary compatibility constraints, standardIcon()
+ introduced in Qt 4.1 is not virtual. Therefore it must dynamically
+ detect and call \e this slot. This default implementation simply
+ calls standardIcon() with the given parameters.
+
+ \sa standardIcon()
+ */
+QIcon QProxyStyle::standardIconImplementation(StandardPixmap standardIcon,
+ const QStyleOption *option,
+ const QWidget *widget) const
{
Q_D (const QProxyStyle);
d->ensureBaseStyle();
return d->baseStyle->standardIcon(standardIcon, option, widget);
}
-/*! reimp */
-int QProxyStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2,
- Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const
+/*!
+ This slot is called by layoutSpacing() to determine the spacing that
+ should be used between \a control1 and \a control2 in a layout. \a
+ orientation specifies whether the controls are laid out side by side
+ or stacked vertically. The \a option parameter can be used to pass
+ extra information about the parent widget. The \a widget parameter
+ is optional and can also be used if \a option is 0.
+
+ The default implementation returns -1.
+
+ \sa layoutSpacing(), combinedLayoutSpacing()
+ */
+int QProxyStyle::layoutSpacingImplementation(QSizePolicy::ControlType control1,
+ QSizePolicy::ControlType control2,
+ Qt::Orientation orientation,
+ const QStyleOption *option,
+ const QWidget *widget) const
{
Q_D (const QProxyStyle);
d->ensureBaseStyle();
diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp
index c0fdc83..c848022 100644
--- a/src/gui/styles/qstyle.cpp
+++ b/src/gui/styles/qstyle.cpp
@@ -168,12 +168,21 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
\section1 Creating a Custom Style
- If you want to design a custom look and feel for your application,
- the first step is to pick one of the styles provided with Qt to
- build your custom style from. The choice will depend on which
- existing style resembles your style the most. The most general
- class that you can use as base is QCommonStyle (and not QStyle).
- This is because Qt requires its styles to be \l{QCommonStyle}s.
+ You can create a custom look and feel for your application by
+ creating a custom style. There are two approaches to creating a
+ custom style. In the static approach, you either choose an
+ existing QStyle class, subclass it, and reimplement virtual
+ functions to provide the custom behavior, or you create an entire
+ QStyle class from scratch. In the dynamic approach, you modify the
+ behavior of your system style at runtime. The static approach is
+ described below. The dynamic approach is described in QProxyStyle.
+
+ The first step in the static approach is to pick one of the styles
+ provided by Qt from which you will build your custom style. Your
+ choice of QStyle class will depend on which style resembles your
+ desired style the most. The most general class that you can use as
+ a base is QCommonStyle (not QStyle). This is because Qt requires
+ its styles to be \l{QCommonStyle}s.
Depending on which parts of the base style you want to change,
you must reimplement the functions that are used to draw those
@@ -222,7 +231,7 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
\section1 Using a Custom Style
There are several ways of using a custom style in a Qt
- application. The simplest way is call the
+ application. The simplest way is to pass the custom style to the
QApplication::setStyle() static function before creating the
QApplication object:
@@ -232,8 +241,8 @@ static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::C
it before the constructor, you ensure that the user's preference,
set using the \c -style command-line option, is respected.
- You may want to make your style available for use in other
- applications, some of which may not be yours and are not available for
+ You may want to make your custom style available for use in other
+ applications, which may not be yours and hence not available for
you to recompile. The Qt Plugin system makes it possible to create
styles as plugins. Styles created as plugins are loaded as shared
objects at runtime by Qt itself. Please refer to the \link
@@ -1182,6 +1191,7 @@ void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment,
\value SC_All Special value that matches all sub-controls.
\omitvalue SC_Q3ListViewBranch
+ \omitvalue SC_CustomBase
\sa ComplexControl
*/
@@ -2450,14 +2460,12 @@ QDebug operator<<(QDebug debug, QStyle::State state)
/*!
\since 4.6
- \fn const QStyle * proxy() const
+ \fn const QStyle *QStyle::proxy() const
This function returns the current proxy for this style.
By default most styles will return themselves. However
when a proxy style is in use, it will allow the style to
call back into its proxy.
-
- \sa setProxyStyle
*/
const QStyle * QStyle::proxy() const
{
diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm
index 67656b4..9b496ef 100644
--- a/src/gui/widgets/qmenu_mac.mm
+++ b/src/gui/widgets/qmenu_mac.mm
@@ -972,7 +972,7 @@ void Q_GUI_EXPORT qt_mac_set_menubar_merge(bool b) { qt_mac_no_menubar_merge = !
/*****************************************************************************
QMenu bindings
*****************************************************************************/
-QMenuPrivate::QMacMenuPrivate::QMacMenuPrivate() : menu(0)
+QMenuPrivate::QMacMenuPrivate::QMacMenuPrivate(QMenuPrivate *menu) : menu(0), qmenu(menu)
{
}
@@ -1300,22 +1300,61 @@ QMenuPrivate::QMacMenuPrivate::syncAction(QMacMenuAction *action)
#else
int itemIndex = [menu indexOfItem:item];
Q_ASSERT(itemIndex != -1);
- if (action->action->isSeparator()) {
+
+ // Separator handling: Menu items and separators can be added to a QMenu in
+ // any order (for example, add all the separators first and then "fill inn"
+ // the menu items). Create NSMenuItem seperatorItems for the Qt separators,
+ // and make sure that there are no double separators and no seprators
+ // at the top or bottom of the menu.
+ bool itemIsSeparator = action->action->isSeparator();
+ bool previousItemIsSeparator = false;
+ if (itemIndex > 0) {
+ if ([[menu itemAtIndex : itemIndex - 1] isSeparatorItem])
+ previousItemIsSeparator = true;
+ }
+ bool nexItemIsSeparator = false;
+ if (itemIndex > 0 && itemIndex < [menu numberOfItems] -1) {
+ if ([[menu itemAtIndex : itemIndex + 1] isSeparatorItem])
+ nexItemIsSeparator = true;
+ }
+ bool itemIsAtBottomOfMenu = (itemIndex == [menu numberOfItems] - 1);
+ bool itemIsAtTopOfMenu = (itemIndex == 0);
+
+
+ if (itemIsSeparator) {
+ // Create separators items for actions that are now separators
action->menuItem = [NSMenuItem separatorItem];
[action->menuItem retain];
+
+ // Hide duplicate/top/bottom separators.
+ if (qmenu->collapsibleSeparators && (previousItemIsSeparator || itemIsAtBottomOfMenu || itemIsAtTopOfMenu)) {
+ [action->menuItem setHidden : true];
+ }
+
[menu insertItem: action->menuItem atIndex:itemIndex];
[menu removeItem:item];
[item release];
item = action->menuItem;
return;
- } else if ([item isSeparatorItem]) {
- // I'm no longer a separator...
- action->menuItem = createNSMenuItem(action->action->text());
- [menu insertItem:action->menuItem atIndex:itemIndex];
- [menu removeItem:item];
- [item release];
- item = action->menuItem;
+ } else {
+ // Create standard menu items for actions that are no longer separators
+ if ([item isSeparatorItem]) {
+ action->menuItem = createNSMenuItem(action->action->text());
+ [menu insertItem:action->menuItem atIndex:itemIndex];
+ [menu removeItem:item];
+ [item release];
+ item = action->menuItem;
+ }
+
+ // Show separators that should now be visible since a non-separator
+ // item (the current item) was added.
+ if (previousItemIsSeparator) {
+ [[menu itemAtIndex : itemIndex - 1] setHidden : false];
+ } else if (itemIsAtTopOfMenu && nexItemIsSeparator) {
+ [[menu itemAtIndex : itemIndex + 1] setHidden : false];
+ }
}
+
#endif
//find text (and accel)
@@ -1499,7 +1538,7 @@ QMenuPrivate::macMenu(OSMenuRef merge)
if (mac_menu && mac_menu->menu)
return mac_menu->menu;
if (!mac_menu)
- mac_menu = new QMacMenuPrivate;
+ mac_menu = new QMacMenuPrivate(this);
mac_menu->menu = qt_mac_create_menu(q);
if (merge) {
#ifndef QT_MAC_USE_COCOA
diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h
index 1dfe701..20c63fe 100644
--- a/src/gui/widgets/qmenu_p.h
+++ b/src/gui/widgets/qmenu_p.h
@@ -263,8 +263,9 @@ public:
struct QMacMenuPrivate {
QList<QMacMenuAction*> actionItems;
OSMenuRef menu;
- QMacMenuPrivate();
- ~QMacMenuPrivate();
+ QMenuPrivate *qmenu;
+ QMacMenuPrivate(QMenuPrivate *menu);
+ ~QMacMenuPrivate();
bool merged(const QAction *action) const;
void addAction(QAction *, QMacMenuAction* =0, QMenuPrivate *qmenu = 0);
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index ca7dffd..827acac 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -2020,6 +2020,7 @@ void QPlainTextEdit::inputMethodEvent(QInputMethodEvent *e)
}
#endif
d->sendControlEvent(e);
+ ensureCursorVisible();
}
/*!\reimp
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp
index 1c4df93..61cd0ce 100644
--- a/src/gui/widgets/qtextedit.cpp
+++ b/src/gui/widgets/qtextedit.cpp
@@ -1659,6 +1659,7 @@ void QTextEdit::inputMethodEvent(QInputMethodEvent *e)
}
#endif
d->sendControlEvent(e);
+ ensureCursorVisible();
}
/*!\reimp