diff options
author | Jesper Thomschutz <jesper.thomschutz@nokia.com> | 2010-09-15 07:45:55 (GMT) |
---|---|---|
committer | A-Team <ateam@pad.test.qt.nokia.com> | 2010-09-15 07:46:55 (GMT) |
commit | f78119906b0ffc7fd3dd36d6d827d456478a7fd5 (patch) | |
tree | e161fe397dedd702f86d186ef32eabcf7cae00d8 /src/gui | |
parent | 66420856664c7a412b3c9efe4be6ff7a6061e5f2 (diff) | |
parent | 05ab8ad1577fc038aa2b3bd96cedda54e6a64979 (diff) | |
download | Qt-f78119906b0ffc7fd3dd36d6d827d456478a7fd5.zip Qt-f78119906b0ffc7fd3dd36d6d827d456478a7fd5.tar.gz Qt-f78119906b0ffc7fd3dd36d6d827d456478a7fd5.tar.bz2 |
git Merge branch '4.7-upstream' into 4.7-doc
Conflicts:
src/gui/kernel/qgesturemanager.cpp
Diffstat (limited to 'src/gui')
24 files changed, 263 insertions, 140 deletions
diff --git a/src/gui/accessible/qaccessible_win.cpp b/src/gui/accessible/qaccessible_win.cpp index 132d01f..31e7245 100644 --- a/src/gui/accessible/qaccessible_win.cpp +++ b/src/gui/accessible/qaccessible_win.cpp @@ -76,71 +76,71 @@ QT_END_INCLUDE_NAMESPACE static const char *roleString(QAccessible::Role role) { static const char *roles[] = { - "NoRole" /*= 0x00000000*/, - "TitleBar" /*= 0x00000001*/, - "MenuBar" /*= 0x00000002*/, - "ScrollBar" /*= 0x00000003*/, - "Grip" /*= 0x00000004*/, - "Sound" /*= 0x00000005*/, - "Cursor" /*= 0x00000006*/, - "Caret" /*= 0x00000007*/, - "AlertMessage" /*= 0x00000008*/, - "Window" /*= 0x00000009*/, - "Client" /*= 0x0000000A*/, - "PopupMenu" /*= 0x0000000B*/, - "MenuItem" /*= 0x0000000C*/, - "ToolTip" /*= 0x0000000D*/, - "Application" /*= 0x0000000E*/, - "Document" /*= 0x0000000F*/, - "Pane" /*= 0x00000010*/, - "Chart" /*= 0x00000011*/, - "Dialog" /*= 0x00000012*/, - "Border" /*= 0x00000013*/, - "Grouping" /*= 0x00000014*/, - "Separator" /*= 0x00000015*/, - "ToolBar" /*= 0x00000016*/, - "StatusBar" /*= 0x00000017*/, - "Table" /*= 0x00000018*/, - "ColumnHeader" /*= 0x00000019*/, - "RowHeader" /*= 0x0000001A*/, - "Column" /*= 0x0000001B*/, - "Row" /*= 0x0000001C*/, - "Cell" /*= 0x0000001D*/, - "Link" /*= 0x0000001E*/, - "HelpBalloon" /*= 0x0000001F*/, - "Assistant" /*= 0x00000020*/, - "List" /*= 0x00000021*/, - "ListItem" /*= 0x00000022*/, - "Tree" /*= 0x00000023*/, - "TreeItem" /*= 0x00000024*/, - "PageTab" /*= 0x00000025*/, - "PropertyPage" /*= 0x00000026*/, - "Indicator" /*= 0x00000027*/, - "Graphic" /*= 0x00000028*/, - "StaticText" /*= 0x00000029*/, - "EditableText" /*= 0x0000002A*/, // Editable, selectable, etc. - "PushButton" /*= 0x0000002B*/, - "CheckBox" /*= 0x0000002C*/, - "RadioButton" /*= 0x0000002D*/, - "ComboBox" /*= 0x0000002E*/, - "DropList" /*= 0x0000002F*/, // commented out - "ProgressBar" /*= 0x00000030*/, - "Dial" /*= 0x00000031*/, - "HotkeyField" /*= 0x00000032*/, - "Slider" /*= 0x00000033*/, - "SpinBox" /*= 0x00000034*/, - "Canvas" /*= 0x00000035*/, - "Animation" /*= 0x00000036*/, - "Equation" /*= 0x00000037*/, - "ButtonDropDown" /*= 0x00000038*/, - "ButtonMenu" /*= 0x00000039*/, - "ButtonDropGrid" /*= 0x0000003A*/, - "Whitespace" /*= 0x0000003B*/, - "PageTabList" /*= 0x0000003C*/, - "Clock" /*= 0x0000003D*/, - "Splitter" /*= 0x0000003E*/, - "LayeredPane" /*= 0x0000003F*/, - "UserRole" /*= 0x0000ffff*/ + "NoRole" /* = 0x00000000 */, + "TitleBar" /* = 0x00000001 */, + "MenuBar" /* = 0x00000002 */, + "ScrollBar" /* = 0x00000003 */, + "Grip" /* = 0x00000004 */, + "Sound" /* = 0x00000005 */, + "Cursor" /* = 0x00000006 */, + "Caret" /* = 0x00000007 */, + "AlertMessage" /* = 0x00000008 */, + "Window" /* = 0x00000009 */, + "Client" /* = 0x0000000A */, + "PopupMenu" /* = 0x0000000B */, + "MenuItem" /* = 0x0000000C */, + "ToolTip" /* = 0x0000000D */, + "Application" /* = 0x0000000E */, + "Document" /* = 0x0000000F */, + "Pane" /* = 0x00000010 */, + "Chart" /* = 0x00000011 */, + "Dialog" /* = 0x00000012 */, + "Border" /* = 0x00000013 */, + "Grouping" /* = 0x00000014 */, + "Separator" /* = 0x00000015 */, + "ToolBar" /* = 0x00000016 */, + "StatusBar" /* = 0x00000017 */, + "Table" /* = 0x00000018 */, + "ColumnHeader" /* = 0x00000019 */, + "RowHeader" /* = 0x0000001A */, + "Column" /* = 0x0000001B */, + "Row" /* = 0x0000001C */, + "Cell" /* = 0x0000001D */, + "Link" /* = 0x0000001E */, + "HelpBalloon" /* = 0x0000001F */, + "Assistant" /* = 0x00000020 */, + "List" /* = 0x00000021 */, + "ListItem" /* = 0x00000022 */, + "Tree" /* = 0x00000023 */, + "TreeItem" /* = 0x00000024 */, + "PageTab" /* = 0x00000025 */, + "PropertyPage" /* = 0x00000026 */, + "Indicator" /* = 0x00000027 */, + "Graphic" /* = 0x00000028 */, + "StaticText" /* = 0x00000029 */, + "EditableText" /* = 0x0000002A */, // Editable, selectable, etc. + "PushButton" /* = 0x0000002B */, + "CheckBox" /* = 0x0000002C */, + "RadioButton" /* = 0x0000002D */, + "ComboBox" /* = 0x0000002E */, + "DropList" /* = 0x0000002F */, // commented out + "ProgressBar" /* = 0x00000030 */, + "Dial" /* = 0x00000031 */, + "HotkeyField" /* = 0x00000032 */, + "Slider" /* = 0x00000033 */, + "SpinBox" /* = 0x00000034 */, + "Canvas" /* = 0x00000035 */, + "Animation" /* = 0x00000036 */, + "Equation" /* = 0x00000037 */, + "ButtonDropDown" /* = 0x00000038 */, + "ButtonMenu" /* = 0x00000039 */, + "ButtonDropGrid" /* = 0x0000003A */, + "Whitespace" /* = 0x0000003B */, + "PageTabList" /* = 0x0000003C */, + "Clock" /* = 0x0000003D */, + "Splitter" /* = 0x0000003E */, + "LayeredPane" /* = 0x0000003F */, + "UserRole" /* = 0x0000ffff*/ }; if (role >=0x40) diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp index 3958cf0..c77c35c 100644 --- a/src/gui/embedded/qsoundqss_qws.cpp +++ b/src/gui/embedded/qsoundqss_qws.cpp @@ -286,7 +286,7 @@ public: rightVolume = maxVolume>>1; isPriority = false; samples_due = 0; - max1 = max2 = out = 0;//= sound_buffer_size; + max1 = max2 = out = 0;// = sound_buffer_size; data = data1; max = &max1; sampleRunin = 0; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 81ec414..c166c30 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4984,14 +4984,15 @@ void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, b return; } - bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents - && !item->d_ptr->graphicsEffect; + 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; + } else if (item->d_ptr->graphicsEffect) { + invalidateChildren = true; } if (invalidateChildren) { diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index a6d2594..f7e0751 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -82,8 +82,9 @@ static QString qt_strippedText(QString s) QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), forceEnabledInSoftkeys(false), menuActionSoftkeys(false), + iconVisibleInMenu(-1), menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), - priority(QAction::NormalPriority), iconVisibleInMenu(-1) + priority(QAction::NormalPriority) { #ifdef QT3_SUPPORT static int qt_static_action_id = -1; diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index caeeeb9..2fd2f46 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4367,11 +4367,13 @@ bool QApplication::notify(QObject *receiver, QEvent *e) eventAccepted = ge.isAccepted(); for (int i = 0; i < gestures.size(); ++i) { QGesture *g = gestures.at(i); - if ((res && eventAccepted) || (!eventAccepted && ge.isAccepted(g))) { + // Ignore res [event return value] because handling of multiple gestures + // packed into a single QEvent depends on not consuming the event + if (eventAccepted || ge.isAccepted(g)) { // if the gesture was accepted, mark the target widget for it gestureEvent->d_func()->targetWidgets[g->gestureType()] = w; gestureEvent->setAccepted(g, true); - } else if (!eventAccepted && !ge.isAccepted(g)) { + } else { // if the gesture was explicitly ignored by the application, // put it back so a parent can get it allGestures.append(g); diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index 7495f6d..e7b7ed8 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -400,11 +400,39 @@ QTabletDeviceDataList *qt_tablet_devices() extern bool qt_tabletChokeMouse; #endif +typedef bool(*QX11FilterFunction)(XEvent *event); + +Q_GLOBAL_STATIC(QList<QX11FilterFunction>, x11Filters) + +Q_GUI_EXPORT void qt_installX11EventFilter(QX11FilterFunction func) +{ + Q_ASSERT(func); + + if (QList<QX11FilterFunction> *list = x11Filters()) + list->append(func); +} + +Q_GUI_EXPORT void qt_removeX11EventFilter(QX11FilterFunction func) +{ + Q_ASSERT(func); + + if (QList<QX11FilterFunction> *list = x11Filters()) + list->removeOne(func); +} + + static bool qt_x11EventFilter(XEvent* ev) { long unused; if (qApp->filterEvent(ev, &unused)) return true; + if (const QList<QX11FilterFunction> *list = x11Filters()) { + for (QList<QX11FilterFunction>::const_iterator it = list->constBegin(); it != list->constEnd(); ++it) { + if ((*it)(ev)) + return true; + } + } + return qApp->x11EventFilter(ev); } diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index 13274c4..5725a22 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -775,4 +775,6 @@ int QTapAndHoldGesturePrivate::Timeout = 700; // in ms QT_END_NAMESPACE +#include <moc_qgesture.cpp> + #endif // QT_NO_GESTURES diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index dcb0264..8416708 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -54,6 +54,7 @@ QT_BEGIN_HEADER Q_DECLARE_METATYPE(Qt::GestureState) +Q_DECLARE_METATYPE(Qt::GestureType) QT_BEGIN_NAMESPACE @@ -112,6 +113,8 @@ class Q_GUI_EXPORT QPanGesture : public QGesture Q_PROPERTY(QPointF offset READ offset WRITE setOffset) Q_PROPERTY(QPointF delta READ delta STORED false) Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration) + Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal horizontalVelocity READ horizontalVelocity WRITE setHorizontalVelocity) + Q_PRIVATE_PROPERTY(QPanGesture::d_func(), qreal verticalVelocity READ verticalVelocity WRITE setVerticalVelocity) public: QPanGesture(QObject *parent = 0); @@ -210,6 +213,7 @@ class Q_GUI_EXPORT QSwipeGesture : public QGesture Q_PROPERTY(SwipeDirection horizontalDirection READ horizontalDirection STORED false) Q_PROPERTY(SwipeDirection verticalDirection READ verticalDirection STORED false) Q_PROPERTY(qreal swipeAngle READ swipeAngle WRITE setSwipeAngle) + Q_PRIVATE_PROPERTY(QSwipeGesture::d_func(), qreal velocity READ velocity WRITE setVelocity) public: enum SwipeDirection { NoDirection, Left, Right, Up, Down }; diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 29b923e..6a856ac 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -88,14 +88,21 @@ class QPanGesturePrivate : public QGesturePrivate public: QPanGesturePrivate() - : acceleration(0) + : acceleration(0), xVelocity(0), yVelocity(0) { } + qreal horizontalVelocity() const { return xVelocity; } + void setHorizontalVelocity(qreal value) { xVelocity = value; } + qreal verticalVelocity() const { return yVelocity; } + void setVerticalVelocity(qreal value) { yVelocity = value; } + QPointF lastOffset; QPointF offset; QPoint startPosition; qreal acceleration; + qreal xVelocity; + qreal yVelocity; }; class QPinchGesturePrivate : public QGesturePrivate @@ -105,7 +112,7 @@ class QPinchGesturePrivate : public QGesturePrivate public: QPinchGesturePrivate() : totalChangeFlags(0), changeFlags(0), - totalScaleFactor(0), lastScaleFactor(0), scaleFactor(0), + totalScaleFactor(1), lastScaleFactor(1), scaleFactor(1), totalRotationAngle(0), lastRotationAngle(0), rotationAngle(0), isNewSequence(true) { @@ -139,17 +146,20 @@ public: : horizontalDirection(QSwipeGesture::NoDirection), verticalDirection(QSwipeGesture::NoDirection), swipeAngle(0), - started(false), speed(0) + started(false), velocityValue(0) { } + qreal velocity() const { return velocityValue; } + void setVelocity(qreal value) { velocityValue = value; } + QSwipeGesture::SwipeDirection horizontalDirection; QSwipeGesture::SwipeDirection verticalDirection; qreal swipeAngle; QPoint lastPositions[3]; bool started; - qreal speed; + qreal velocityValue; QElapsedTimer time; }; diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index f50dbbd..6dd8127 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -184,8 +184,8 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ // get or create a QGesture object that will represent the state for a given object, used by the recognizer QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recognizer, Qt::GestureType type) { - // if the widget is being deleted we should be carefull and not to - // create a new state, as it will create QWeakPointer which doesn't work + // if the widget is being deleted we should be careful not to + // create a new state, as it will create QWeakPointer which doesnt work // from the destructor. if (object->isWidgetType()) { if (static_cast<QWidget *>(object)->d_func()->data.in_destructor) diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index 127e150..893ba2b 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -199,6 +199,7 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, d->startPosition[1] = p2.screenPos(); } QLineF line(p1.screenPos(), p2.screenPos()); + QLineF lastLine(p1.lastScreenPos(), p2.lastScreenPos()); QLineF tmp(line); tmp.setLength(line.length() / 2.); QPointF centerPoint = tmp.p2(); @@ -207,16 +208,15 @@ QGestureRecognizer::Result QPinchGestureRecognizer::recognize(QGesture *state, d->centerPoint = centerPoint; d->changeFlags |= QPinchGesture::CenterPointChanged; - const qreal scaleFactor = - QLineF(p1.screenPos(), p2.screenPos()).length() - / QLineF(d->startPosition[0], d->startPosition[1]).length(); + const qreal scaleFactor = line.length() / lastLine.length(); + if (d->isNewSequence) { d->lastScaleFactor = scaleFactor; } else { d->lastScaleFactor = d->scaleFactor; } d->scaleFactor = scaleFactor; - d->totalScaleFactor += d->scaleFactor - d->lastScaleFactor; + d->totalScaleFactor = d->totalScaleFactor * scaleFactor; d->changeFlags |= QPinchGesture::ScaleFactorChanged; qreal angle = QLineF(p1.screenPos(), p2.screenPos()).angle(); @@ -266,7 +266,7 @@ void QPinchGestureRecognizer::reset(QGesture *state) d->totalChangeFlags = d->changeFlags = 0; d->startCenterPoint = d->lastCenterPoint = d->centerPoint = QPointF(); - d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 0; + d->totalScaleFactor = d->lastScaleFactor = d->scaleFactor = 1; d->totalRotationAngle = d->lastRotationAngle = d->rotationAngle = 0; d->isNewSequence = true; @@ -304,7 +304,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state, switch (event->type()) { case QEvent::TouchBegin: { - d->speed = 1; + d->velocityValue = 1; d->time.start(); d->started = true; result = QGestureRecognizer::MayBeGesture; @@ -345,7 +345,7 @@ QGestureRecognizer::Result QSwipeGestureRecognizer::recognize(QGesture *state, int elapsedTime = d->time.restart(); if (!elapsedTime) elapsedTime = 1; - d->speed = 0.9 * d->speed + distance / elapsedTime; + d->velocityValue = 0.9 * d->velocityValue + distance / elapsedTime; d->swipeAngle = QLineF(p1.startScreenPos(), p1.screenPos()).angle(); static const int MoveThreshold = 50; @@ -407,7 +407,7 @@ void QSwipeGestureRecognizer::reset(QGesture *state) d->lastPositions[0] = d->lastPositions[1] = d->lastPositions[2] = QPoint(); d->started = false; - d->speed = 0; + d->velocityValue = 0; d->time.invalidate(); QGestureRecognizer::reset(state); diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 1979c84..159c45d 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2375,7 +2375,8 @@ void QWidgetPrivate::recreateMacWindow() HIViewRemoveFromSuperview(myView); determineWindowClass(); createWindow_sys(); - if (QMainWindowLayout *mwl = qobject_cast<QMainWindowLayout *>(q->layout())) { + + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) { mwl->updateHIToolBarStatus(); } @@ -2912,7 +2913,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) // We do this down below for wasCreated, so avoid doing this twice // (only for performance, it gets called a lot anyway). if (!wasCreated) { - if (QMainWindowLayout *mwl = qobject_cast<QMainWindowLayout *>(q->layout())) { + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) { mwl->updateHIToolBarStatus(); } } @@ -2937,7 +2938,7 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) // If we were a unified window, We just transfered our toolbars out of the unified toolbar. // So redo the status one more time. It apparently is not an issue with Cocoa. if (q->isWindow()) { - if (QMainWindowLayout *mwl = qobject_cast<QMainWindowLayout *>(q->layout())) { + if (QMainWindowLayout *mwl = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q))) { mwl->updateHIToolBarStatus(); } } @@ -5138,7 +5139,7 @@ void QWidgetPrivate::macUpdateMetalAttribute() return; recreateMacWindow(); #else - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(q->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q)); if (q->testAttribute(Qt::WA_MacBrushedMetal)) { if (layout) layout->updateHIToolBarStatus(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index c98c05a..4109ed8 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -518,7 +518,7 @@ void QWidgetPrivate::show_sys() if (q->windowState() & Qt::WindowMaximized) { TRect r = static_cast<CEikAppUi*>(S60->appUi())->ClientRect(); id->SetExtent(r.iTl, r.Size()); - } else if (!q->testAttribute(Qt::WA_Moved)) { + } else if (!q->testAttribute(Qt::WA_Moved) && q->windowType() != Qt::Dialog) { id->SetPosition(static_cast<CEikAppUi*>(S60->appUi())->ClientRect().iTl); } } diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index ac73958..f97d865 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -300,11 +300,14 @@ void QT_FASTCALL comp_func_solid_SourceOver_sse2(uint *destPixels, int length, u const __m128i half = _mm_set1_epi16(0x80); const __m128i minusAlphaOfColorVector = _mm_set1_epi16(minusAlphaOfColor); + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) + destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor); + for (; x < length-3; x += 4) { - __m128i dstVector = _mm_loadu_si128((__m128i *)&dst[x]); + __m128i dstVector = _mm_load_si128((__m128i *)&dst[x]); BYTE_MUL_SSE2(dstVector, dstVector, minusAlphaOfColorVector, colorMask, half); dstVector = _mm_add_epi8(colorVector, dstVector); - _mm_storeu_si128((__m128i *)&dst[x], dstVector); + _mm_store_si128((__m128i *)&dst[x], dstVector); } for (;x < length; ++x) destPixels[x] = color + BYTE_MUL(destPixels[x], minusAlphaOfColor); diff --git a/src/gui/painting/qpaintengineex.cpp b/src/gui/painting/qpaintengineex.cpp index 881bd6e..1e857e4 100644 --- a/src/gui/painting/qpaintengineex.cpp +++ b/src/gui/painting/qpaintengineex.cpp @@ -768,7 +768,7 @@ void QPaintEngineEx::drawRoundedRect(const QRectF &rect, qreal xRadius, qreal yR x1, y2 - (1 - KAPPA) * yRadius, x1, y2 - yRadius, x1, y1 + yRadius, // LineTo - x1, y1 + KAPPA * yRadius, // CurveTo + x1, y1 + (1 - KAPPA) * yRadius, // CurveTo x1 + (1 - KAPPA) * xRadius, y1, x1 + xRadius, y1 }; diff --git a/src/gui/painting/qstroker.cpp b/src/gui/painting/qstroker.cpp index eabbd8a..9cff339 100644 --- a/src/gui/painting/qstroker.cpp +++ b/src/gui/painting/qstroker.cpp @@ -609,7 +609,7 @@ void QStroker::joinPoints(qfixed focal_x, qfixed focal_y, const QLineF &nextLine } QLineF miterLine(QPointF(qt_fixed_to_real(focal_x), qt_fixed_to_real(focal_y)), isect); - if (miterLine.length() > qt_fixed_to_real(m_strokeWidth * m_miterLimit) / 2) { + if (type == QLineF::NoIntersection || miterLine.length() > qt_fixed_to_real(m_strokeWidth * m_miterLimit) / 2) { emitLineTo(qt_real_to_fixed(nextLine.x1()), qt_real_to_fixed(nextLine.y1())); } else { diff --git a/src/gui/widgets/qdockarealayout.cpp b/src/gui/widgets/qdockarealayout.cpp index 171000b..b540e76 100644 --- a/src/gui/widgets/qdockarealayout.cpp +++ b/src/gui/widgets/qdockarealayout.cpp @@ -60,6 +60,9 @@ QT_BEGIN_NAMESPACE +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + enum { StateFlagVisible = 1, StateFlagFloating = 2 }; /****************************************************************************** @@ -1480,7 +1483,7 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const QMainWindowLayout *QDockAreaLayoutInfo::mainWindowLayout() const { - QMainWindowLayout *result = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); + QMainWindowLayout *result = qt_mainwindow_layout(mainWindow); Q_ASSERT(result != 0); return result; } @@ -3070,8 +3073,7 @@ void QDockAreaLayout::splitDockWidget(QDockWidget *after, void QDockAreaLayout::apply(bool animate) { - QWidgetAnimator &widgetAnimator - = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->widgetAnimator; + QWidgetAnimator &widgetAnimator = qt_mainwindow_layout(mainWindow)->widgetAnimator; for (int i = 0; i < QInternal::DockCount; ++i) docks[i].apply(animate); @@ -3176,7 +3178,7 @@ void QDockAreaLayout::updateSeparatorWidgets() const if (j < separatorWidgets.size()) { sepWidget = separatorWidgets.at(j); } else { - sepWidget = qobject_cast<QMainWindowLayout*>(mainWindow->layout())->getSeparatorWidget(); + sepWidget = qt_mainwindow_layout(mainWindow)->getSeparatorWidget(); separatorWidgets.append(sepWidget); } j++; diff --git a/src/gui/widgets/qdockwidget.cpp b/src/gui/widgets/qdockwidget.cpp index 11f0a94..df9b171 100644 --- a/src/gui/widgets/qdockwidget.cpp +++ b/src/gui/widgets/qdockwidget.cpp @@ -68,6 +68,9 @@ QT_BEGIN_NAMESPACE extern QString qt_setWindowTitle_helperHelper(const QString&, const QWidget*); // qwidget.cpp +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + static inline bool hasFeature(const QDockWidgetPrivate *priv, QDockWidget::DockWidgetFeature feature) { return (priv->features & feature) == feature; } @@ -690,7 +693,7 @@ void QDockWidgetPrivate::initDrag(const QPoint &pos, bool nca) QMainWindow *win = qobject_cast<QMainWindow*>(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (layout->pluggingWidget != 0) // the main window is animating a docking operation return; @@ -711,8 +714,7 @@ void QDockWidgetPrivate::startDrag() if (state == 0 || state->dragging) return; - QMainWindowLayout *layout - = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(layout != 0); state->widgetItem = layout->unplug(q); @@ -739,8 +741,7 @@ void QDockWidgetPrivate::endDrag(bool abort) q->releaseMouse(); if (state->dragging) { - QMainWindowLayout *mwLayout = - qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(mwLayout != 0); if (abort || !mwLayout->plug(state->widgetItem)) { @@ -780,8 +781,7 @@ bool QDockWidgetPrivate::isAnimating() const if (mainWin == 0) return false; - QMainWindowLayout *mainWinLayout - = qobject_cast<QMainWindowLayout*>(mainWin->layout()); + QMainWindowLayout *mainWinLayout = qt_mainwindow_layout(mainWin); if (mainWinLayout == 0) return false; @@ -847,9 +847,8 @@ bool QDockWidgetPrivate::mouseMoveEvent(QMouseEvent *event) return ret; QDockWidgetLayout *dwlayout - = qobject_cast<QDockWidgetLayout*>(layout); - QMainWindowLayout *mwlayout - = qobject_cast<QMainWindowLayout*>(q->parentWidget()->layout()); + = qobject_cast<QDockWidgetLayout *>(layout); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (!dwlayout->nativeWindowDeco()) { if (!state->dragging && mwlayout->pluggingWidget == 0 @@ -943,8 +942,7 @@ void QDockWidgetPrivate::nonClientAreaMouseEvent(QMouseEvent *event) } #ifdef Q_OS_MAC else { // workaround for lack of mouse-grab on Mac - QMainWindowLayout *layout - = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(layout != 0); q->move(event->globalPos() - state->pressPos); @@ -980,8 +978,7 @@ void QDockWidgetPrivate::moveEvent(QMoveEvent *event) if (state->ctrlDrag) return; - QMainWindowLayout *layout - = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(layout != 0); QPoint globalMousePos = event->pos() + state->pressPos; @@ -1009,7 +1006,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect Q_Q(QDockWidget); if (!floating && parent) { - QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout && mwlayout->dockWidgetArea(q) == Qt::NoDockWidgetArea) return; // this dockwidget can't be redocked } @@ -1055,7 +1052,7 @@ void QDockWidgetPrivate::setWindowState(bool floating, bool unplug, const QRect if (floating != wasFloating) { emit q->topLevelChanged(floating); if (!floating && parent) { - QMainWindowLayout *mwlayout = qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *mwlayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); if (mwlayout) emit q->dockLocationChanged(mwlayout->dockWidgetArea(q)); } @@ -1326,10 +1323,10 @@ void QDockWidget::changeEvent(QEvent *event) #ifndef QT_NO_TABBAR { QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); - if (QMainWindowLayout *winLayout = - (win ? qobject_cast<QMainWindowLayout*>(win->layout()) : 0)) + if (QMainWindowLayout *winLayout = qt_mainwindow_layout(win)) { if (QDockAreaLayoutInfo *info = winLayout->layoutState.dockAreaLayout.info(this)) info->updateTabBar(); + } } #endif // QT_NO_TABBAR break; @@ -1382,9 +1379,7 @@ bool QDockWidget::event(QEvent *event) Q_D(QDockWidget); QMainWindow *win = qobject_cast<QMainWindow*>(parentWidget()); - QMainWindowLayout *layout = 0; - if (win != 0) - layout = qobject_cast<QMainWindowLayout*>(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); switch (event->type()) { #ifndef QT_NO_ACTION diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 44483ea..1183be6 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +//#define QT_EXPERIMENTAL_CLIENT_DECORATIONS + #include "qmainwindow.h" #include "qmainwindowlayout_p.h" @@ -99,12 +101,70 @@ public: uint hasOldCursor : 1; uint cursorAdjusted : 1; #endif + + static inline QMainWindowLayout *mainWindowLayout(const QMainWindow *mainWindow) + { + return mainWindow ? mainWindow->d_func()->layout : static_cast<QMainWindowLayout *>(0); + } }; +QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow) +{ + return QMainWindowPrivate::mainWindowLayout(mainWindow); +} + +#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS +Q_GUI_EXPORT void qt_setMainWindowTitleWidget(QMainWindow *mainWindow, Qt::DockWidgetArea area, QWidget *widget) +{ + QGridLayout *topLayout = qobject_cast<QGridLayout *>(mainWindow->layout()); + Q_ASSERT(topLayout); + + int row = 0; + int column = 0; + + switch (area) { + case Qt::LeftDockWidgetArea: + row = 1; + column = 0; + break; + case Qt::TopDockWidgetArea: + row = 0; + column = 1; + break; + case Qt::BottomDockWidgetArea: + row = 2; + column = 1; + break; + case Qt::RightDockWidgetArea: + row = 1; + column = 2; + break; + default: + Q_ASSERT_X(false, "qt_setMainWindowTitleWidget", "Unknown area"); + return; + } + + if (QLayoutItem *oldItem = topLayout->itemAtPosition(row, column)) + delete oldItem->widget(); + topLayout->addWidget(widget, row, column); +} +#endif + void QMainWindowPrivate::init() { Q_Q(QMainWindow); - layout = new QMainWindowLayout(q); + +#ifdef QT_EXPERIMENTAL_CLIENT_DECORATIONS + QGridLayout *topLayout = new QGridLayout(q); + topLayout->setContentsMargins(0, 0, 0, 0); + + layout = new QMainWindowLayout(q, topLayout); + + topLayout->addItem(layout, 1, 1); +#else + layout = new QMainWindowLayout(q, 0); +#endif + const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); iconSize = QSize(metric, metric); q->setAttribute(Qt::WA_Hover); @@ -461,10 +521,11 @@ QMenuBar *QMainWindow::menuBar() const */ void QMainWindow::setMenuBar(QMenuBar *menuBar) { - Q_D(QMainWindow); - if (d->layout->menuBar() && d->layout->menuBar() != menuBar) { + QLayout *topLayout = layout(); + + if (topLayout->menuBar() && topLayout->menuBar() != menuBar) { // Reparent corner widgets before we delete the old menu bar. - QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(d->layout->menuBar()); + QMenuBar *oldMenuBar = qobject_cast<QMenuBar *>(topLayout->menuBar()); if (menuBar) { // TopLeftCorner widget. QWidget *cornerWidget = oldMenuBar->cornerWidget(Qt::TopLeftCorner); @@ -478,7 +539,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->hide(); oldMenuBar->deleteLater(); } - d->layout->setMenuBar(menuBar); + topLayout->setMenuBar(menuBar); } /*! diff --git a/src/gui/widgets/qmainwindowlayout.cpp b/src/gui/widgets/qmainwindowlayout.cpp index 62ee398..4dd5208 100644 --- a/src/gui/widgets/qmainwindowlayout.cpp +++ b/src/gui/widgets/qmainwindowlayout.cpp @@ -160,7 +160,7 @@ static void dumpLayout(QTextStream &qout, const QDockAreaLayout &layout, QString void qt_dumpLayout(QTextStream &qout, QMainWindow *window) { - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(window->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(window); dumpLayout(qout, layout->layoutState.dockAreaLayout, QString()); } @@ -235,7 +235,7 @@ void QMainWindowLayoutState::apply(bool animated) dockAreaLayout.apply(animated); #else if (centralWidgetItem != 0) { - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); Q_ASSERT(layout != 0); layout->widgetAnimator.animate(centralWidgetItem->widget(), centralWidgetRect, animated); } @@ -1674,8 +1674,8 @@ void QMainWindowLayout::restore(bool keepSavedState) updateGapIndicator(); } -QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow) - : QLayout(mainwindow) +QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout) + : QLayout(parentLayout ? static_cast<QWidget *>(0) : mainwindow) , layoutState(mainwindow) , savedState(mainwindow) , dockOptions(QMainWindow::AnimatedDocks | QMainWindow::AllowTabbedDocks) @@ -1698,6 +1698,9 @@ QMainWindowLayout::QMainWindowLayout(QMainWindow *mainwindow) , blockVisiblityCheck(false) #endif { + if (parentLayout) + setParent(parentLayout); + #ifndef QT_NO_DOCKWIDGET #ifndef QT_NO_TABBAR sep = mainwindow->style()->pixelMetric(QStyle::PM_DockWidgetSeparatorExtent, 0, mainwindow); diff --git a/src/gui/widgets/qmainwindowlayout_p.h b/src/gui/widgets/qmainwindowlayout_p.h index 955693d..e1b981c 100644 --- a/src/gui/widgets/qmainwindowlayout_p.h +++ b/src/gui/widgets/qmainwindowlayout_p.h @@ -159,7 +159,7 @@ class Q_AUTOTEST_EXPORT QMainWindowLayout : public QLayout public: QMainWindowLayoutState layoutState, savedState; - explicit QMainWindowLayout(QMainWindow *mainwindow); + QMainWindowLayout(QMainWindow *mainwindow, QLayout *parentLayout); ~QMainWindowLayout(); QMainWindow::DockOptions dockOptions; diff --git a/src/gui/widgets/qtoolbar.cpp b/src/gui/widgets/qtoolbar.cpp index 7ed27ea..316bb44 100644 --- a/src/gui/widgets/qtoolbar.cpp +++ b/src/gui/widgets/qtoolbar.cpp @@ -82,6 +82,9 @@ static void qt_mac_updateToolBarButtonHint(QWidget *parentWidget) } #endif +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + /****************************************************************************** ** QToolBarPrivate */ @@ -197,7 +200,7 @@ void QToolBarPrivate::initDrag(const QPoint &pos) QMainWindow *win = qobject_cast<QMainWindow*>(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (layout->pluggingWidget != 0) // the main window is animating a docking operation return; @@ -223,7 +226,7 @@ void QToolBarPrivate::startDrag(bool moving) QMainWindow *win = qobject_cast<QMainWindow*>(parent); Q_ASSERT(win != 0); - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (!moving) { @@ -247,8 +250,7 @@ void QToolBarPrivate::endDrag() q->releaseMouse(); if (state->dragging) { - QMainWindowLayout *layout = - qobject_cast<QMainWindowLayout *>(q->parentWidget()->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(q->parentWidget())); Q_ASSERT(layout != 0); if (!layout->plug(state->widgetItem)) { @@ -340,7 +342,7 @@ bool QToolBarPrivate::mouseMoveEvent(QMouseEvent *event) if (win == 0) return true; - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); Q_ASSERT(layout != 0); if (layout->pluggingWidget == 0 @@ -588,7 +590,7 @@ QToolBar::~QToolBar() QMainWindow *mainwindow = qobject_cast<QMainWindow *>(parentWidget()); if (mainwindow) { #ifdef Q_WS_MAC - QMainWindowLayout *mainwin_layout = qobject_cast<QMainWindowLayout *>(mainwindow->layout()); + QMainWindowLayout *mainwin_layout = qt_mainwindow_layout(mainwindow); if (mainwin_layout && mainwin_layout->layoutState.toolBarAreaLayout.isEmpty() && mainwindow->testAttribute(Qt::WA_WState_Created)) macWindowToolbarShow(mainwindow, false); @@ -1135,7 +1137,7 @@ bool QToolBar::event(QEvent *event) if (toolbarInUnifiedToolBar(this)) { // I can static_cast because I did the qobject_cast in the if above, therefore // we must have a QMainWindowLayout here. - QMainWindowLayout *mwLayout = static_cast<QMainWindowLayout *>(parentWidget()->layout()); + QMainWindowLayout *mwLayout = qt_mainwindow_layout(qobject_cast<QMainWindow *>(parentWidget())); mwLayout->fixSizeInUnifiedToolbar(this); mwLayout->syncUnifiedToolbarVisibility(); } @@ -1289,6 +1291,8 @@ QWidget *QToolBar::widgetForAction(QAction *action) const return d->layout->itemAt(index)->widget(); } +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + /*! \internal */ @@ -1315,7 +1319,7 @@ void QToolBar::initStyleOption(QStyleOptionToolBar *option) const if (!mainWindow) return; - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout *>(mainWindow->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); Q_ASSERT_X(layout != 0, "QToolBar::initStyleOption()", "QMainWindow->layout() != QMainWindowLayout"); diff --git a/src/gui/widgets/qtoolbararealayout.cpp b/src/gui/widgets/qtoolbararealayout.cpp index 8327af5..b312751 100644 --- a/src/gui/widgets/qtoolbararealayout.cpp +++ b/src/gui/widgets/qtoolbararealayout.cpp @@ -59,6 +59,9 @@ QT_BEGIN_NAMESPACE +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *mainWindow); + QSize QToolBarAreaLayoutItem::minimumSize() const { if (skip()) @@ -872,7 +875,7 @@ void QToolBarAreaLayout::insertItem(QToolBar *before, QLayoutItem *item) void QToolBarAreaLayout::apply(bool animate) { - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(mainWindow->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(mainWindow); Q_ASSERT(layout != 0); Qt::LayoutDirection dir = mainWindow->layoutDirection(); diff --git a/src/gui/widgets/qtoolbarlayout.cpp b/src/gui/widgets/qtoolbarlayout.cpp index f87510f..59b027e 100644 --- a/src/gui/widgets/qtoolbarlayout.cpp +++ b/src/gui/widgets/qtoolbarlayout.cpp @@ -57,6 +57,9 @@ QT_BEGIN_NAMESPACE +// qmainwindow.cpp +extern QMainWindowLayout *qt_mainwindow_layout(const QMainWindow *window); + /****************************************************************************** ** QToolBarItem */ @@ -404,7 +407,7 @@ void QToolBarLayout::setGeometry(const QRect &rect) if (QMainWindow *win = qobject_cast<QMainWindow*>(tb->parentWidget())) { Qt::ToolBarArea area = win->toolBarArea(tb); if (win->unifiedTitleAndToolBarOnMac() && area == Qt::TopToolBarArea) { - static_cast<QMainWindowLayout *>(win->layout())->fixSizeInUnifiedToolbar(tb); + qt_mainwindow_layout(win)->fixSizeInUnifiedToolbar(tb); } } # endif @@ -659,7 +662,7 @@ void QToolBarLayout::setExpanded(bool exp) #else animating = !tb->isWindow() && win->isAnimated(); #endif - QMainWindowLayout *layout = qobject_cast<QMainWindowLayout*>(win->layout()); + QMainWindowLayout *layout = qt_mainwindow_layout(win); if (expanded) { tb->raise(); } else { |