summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2010-02-03 13:10:50 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-02-03 13:10:50 (GMT)
commita084456fe8c634f16cf772dce2dd2498e59bed30 (patch)
tree41b0fcc16d313e08969e4c21dc997034fde69eec
parent7e46016d55a80e9d49797efe34779893d80b71e3 (diff)
parent09fe8e377fea67b4279521e3cb08bb937ef65474 (diff)
downloadQt-a084456fe8c634f16cf772dce2dd2498e59bed30.zip
Qt-a084456fe8c634f16cf772dce2dd2498e59bed30.tar.gz
Qt-a084456fe8c634f16cf772dce2dd2498e59bed30.tar.bz2
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.6
-rw-r--r--dist/changes-4.6.27
-rw-r--r--src/gui/graphicsview/qgraphicsscene.cpp18
-rw-r--r--src/gui/painting/qpathclipper.cpp6
-rw-r--r--src/gui/painting/qpathclipper_p.h2
-rw-r--r--src/gui/styles/qstylesheetstyle.cpp2
-rw-r--r--src/gui/widgets/qabstractscrollarea.cpp11
-rw-r--r--src/gui/widgets/qabstractslider.cpp2
-rw-r--r--tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp97
-rw-r--r--tests/auto/uiloader/baseline/css_qtbug7737_borderimageradius.ui44
9 files changed, 80 insertions, 109 deletions
diff --git a/dist/changes-4.6.2 b/dist/changes-4.6.2
index 58dcf0e..4127e13 100644
--- a/dist/changes-4.6.2
+++ b/dist/changes-4.6.2
@@ -46,9 +46,16 @@ QtCore
QtGui
-----
+ - QAbstractScrollArea
+ * [QTBUG-1760] Reverted horizontal scrolling with mouse wheel when vertical scrollbar is hidden
+
- QBmpHandler
* [QTBUG-7530] Fixed an infinite loop that could occur when reading invalid BMP images.
+ - QGraphicsEffect
+ * [QTBUG-6901] Fixed performance problem when translating items with
+ graphics effects.
+
- QImage
* [QTBUG-7231] Avoid an unnecessary copy in QImage::scaled().
diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp
index 842d368..4bfe9ad 100644
--- a/src/gui/graphicsview/qgraphicsscene.cpp
+++ b/src/gui/graphicsview/qgraphicsscene.cpp
@@ -251,6 +251,7 @@
#endif
#include <private/qgraphicseffect_p.h>
#include <private/qgesturemanager_p.h>
+#include <private/qpathclipper_p.h>
// #define GESTURE_DEBUG
#ifndef GESTURE_DEBUG
@@ -4765,7 +4766,12 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q
painter->setWorldTransform(*transformPtr * *effectTransform);
else
painter->setWorldTransform(*transformPtr);
- painter->setClipPath(item->shape(), Qt::IntersectClip);
+ QRectF clipRect;
+ const QPainterPath clipPath(item->shape());
+ if (QPathClipper::pathToRect(clipPath, &clipRect))
+ painter->setClipRect(clipRect, Qt::IntersectClip);
+ else
+ painter->setClipPath(clipPath, Qt::IntersectClip);
}
// Draw children behind
@@ -4801,8 +4807,14 @@ void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const Q
painter->setWorldTransform(*transformPtr);
}
- if (itemClipsToShape)
- painter->setClipPath(item->shape(), Qt::IntersectClip);
+ if (itemClipsToShape) {
+ QRectF clipRect;
+ const QPainterPath clipPath(item->shape());
+ if (QPathClipper::pathToRect(clipPath, &clipRect))
+ painter->setClipRect(clipRect, Qt::IntersectClip);
+ else
+ painter->setClipPath(clipPath, Qt::IntersectClip);
+ }
painter->setOpacity(opacity);
if (!item->d_ptr->cacheMode && !item->d_ptr->isWidget)
diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp
index 7997e77..bc81514 100644
--- a/src/gui/painting/qpathclipper.cpp
+++ b/src/gui/painting/qpathclipper.cpp
@@ -90,8 +90,6 @@ static QPointF normalize(const QPointF &p)
return p / qSqrt(p.x() * p.x() + p.y() * p.y());
}
-static bool pathToRect(const QPainterPath &path, QRectF *rect = 0);
-
struct QIntersection
{
qreal alphaA;
@@ -1660,7 +1658,7 @@ static bool fuzzyCompare(qreal a, qreal b)
return qFuzzyCompare(a, b);
}
-static bool pathToRect(const QPainterPath &path, QRectF *rect)
+bool QPathClipper::pathToRect(const QPainterPath &path, QRectF *rect)
{
if (path.elementCount() != 5)
return false;
@@ -1693,7 +1691,7 @@ static bool pathToRect(const QPainterPath &path, QRectF *rect)
return false;
if (rect)
- *rect = QRectF(QPointF(x1, y1), QPointF(x2, y2));
+ rect->setCoords(x1, y1, x2, y2);
return true;
}
diff --git a/src/gui/painting/qpathclipper_p.h b/src/gui/painting/qpathclipper_p.h
index 0d2c049..b900862 100644
--- a/src/gui/painting/qpathclipper_p.h
+++ b/src/gui/painting/qpathclipper_p.h
@@ -86,6 +86,8 @@ public:
bool intersect();
bool contains();
+ static bool pathToRect(const QPainterPath &path, QRectF *rect = 0);
+
private:
Q_DISABLE_COPY(QPathClipper)
diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp
index 498313b..b36294a 100644
--- a/src/gui/styles/qstylesheetstyle.cpp
+++ b/src/gui/styles/qstylesheetstyle.cpp
@@ -1125,6 +1125,7 @@ void QRenderRule::fixupBorder(int nativeWidth)
void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect)
{
+ setClip(p, rect);
static const Qt::TileRule tileMode2TileRule[] = {
Qt::StretchTile, Qt::RoundTile, Qt::StretchTile, Qt::RepeatTile, Qt::StretchTile };
@@ -1142,6 +1143,7 @@ void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect)
QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins,
QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch]));
p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform);
+ unsetClip(p);
}
QRect QRenderRule::originRect(const QRect &rect, Origin origin) const
diff --git a/src/gui/widgets/qabstractscrollarea.cpp b/src/gui/widgets/qabstractscrollarea.cpp
index 87f6c83..1d496d5 100644
--- a/src/gui/widgets/qabstractscrollarea.cpp
+++ b/src/gui/widgets/qabstractscrollarea.cpp
@@ -1134,13 +1134,10 @@ void QAbstractScrollArea::mouseMoveEvent(QMouseEvent *e)
void QAbstractScrollArea::wheelEvent(QWheelEvent *e)
{
Q_D(QAbstractScrollArea);
- QScrollBar *const bars[2] = { d->hbar, d->vbar };
- int idx = (e->orientation() == Qt::Vertical) ? 1 : 0;
- int other = (idx + 1) % 2;
- if (!bars[idx]->isVisible() && bars[other]->isVisible())
- idx = other; // If the scrollbar of the event orientation is hidden, fallback to the other.
-
- QApplication::sendEvent(bars[idx], e);
+ if (static_cast<QWheelEvent*>(e)->orientation() == Qt::Horizontal)
+ QApplication::sendEvent(d->hbar, e);
+ else
+ QApplication::sendEvent(d->vbar, e);
}
#endif
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index 2874647..77c5a01 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -697,6 +697,8 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
{
Q_D(QAbstractSlider);
e->ignore();
+ if (e->orientation() != d->orientation && !rect().contains(e->pos()))
+ return;
int stepsToScroll = 0;
qreal offset = qreal(e->delta()) / 120;
diff --git a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
index 3e062b8..da83826 100644
--- a/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
+++ b/tests/auto/qabstractscrollarea/tst_qabstractscrollarea.cpp
@@ -71,8 +71,6 @@ private slots:
void viewportCrash();
void task214488_layoutDirection_data();
void task214488_layoutDirection();
- void wheelEvent_data();
- void wheelEvent();
};
tst_QAbstractScrollArea::tst_QAbstractScrollArea()
@@ -298,10 +296,10 @@ public:
setAttribute(Qt::WA_DropSiteRegistered, true);
- startTimer(200);
+ startTimer(2000);
}
- void timerEvent(QTimerEvent *)
+ void timerEvent(QTimerEvent *event)
{
// should not crash.
(void)new QScrollArea(this);
@@ -387,96 +385,5 @@ void tst_QAbstractScrollArea::patternBackground()
QCOMPARE(image.pixel(QPoint(20,20)) , QColor(Qt::red).rgb());
}
-Q_DECLARE_METATYPE(QWheelEvent *);
-
-void tst_QAbstractScrollArea::wheelEvent_data()
-{
- QTest::addColumn<QSize>("widgetSize");
- QTest::addColumn<QPoint>("initialOffset");
- QTest::addColumn<QWheelEvent *>("event");
- QTest::addColumn<int>("movedX"); // -1 , 0 , or 1
- QTest::addColumn<int>("movedY");
-
- QPoint pos(100,100);
- int delta =-120;
-
- QTest::newRow("1") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0;
-
- QTest::newRow("2") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1;
-
- QTest::newRow("3") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0;
-
- QTest::newRow("4") << QSize(600,600) << QPoint(50,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1;
-
- QTest::newRow("5") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 0 << 1;
-
- QTest::newRow("6") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 0 << 1;
-
- QTest::newRow("7") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << 0 << -1;
-
- QTest::newRow("8") << QSize(20,600) << QPoint(0,50)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << 0 << -1;
-
- QTest::newRow("9") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Horizontal) << 1 << 0;
-
- QTest::newRow("a") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, delta, 0, 0, Qt::Vertical) << 1 << 0;
-
- QTest::newRow("b") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Horizontal) << -1 << 0;
-
- QTest::newRow("c") << QSize(600,20) << QPoint(50,0)
- << new QWheelEvent(pos, -delta, 0, 0, Qt::Vertical) << -1 << 0;
-}
-
-
-
-
-void tst_QAbstractScrollArea::wheelEvent()
-{
- QFETCH(QSize, widgetSize);
- QFETCH(QPoint, initialOffset);
- QFETCH(QWheelEvent *, event);
- QFETCH(int, movedX);
- QFETCH(int, movedY);
-
- QScrollArea scrollArea;
- scrollArea.resize(200, 200);
- QLabel widget("H e l l o");
- widget.resize(widgetSize);
- scrollArea.setWidget(&widget);
- scrollArea.show();
- QTest::qWait(20);
-
- scrollArea.verticalScrollBar()->setValue(initialOffset.y());
- scrollArea.horizontalScrollBar()->setValue(initialOffset.x());
-
- QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y());
- QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x());
-
- QApplication::sendEvent(scrollArea.viewport(), event);
-
- if(movedX == 0)
- QCOMPARE(scrollArea.horizontalScrollBar()->value(), initialOffset.x());
- else
- QVERIFY(movedX * scrollArea.horizontalScrollBar()->value() > movedX * initialOffset.x());
-
- if(movedY == 0)
- QCOMPARE(scrollArea.verticalScrollBar()->value(), initialOffset.y());
- else
- QVERIFY(movedY * scrollArea.verticalScrollBar()->value() > movedY * initialOffset.y());
-
- delete event;
-}
-
-
QTEST_MAIN(tst_QAbstractScrollArea)
#include "tst_qabstractscrollarea.moc"
diff --git a/tests/auto/uiloader/baseline/css_qtbug7737_borderimageradius.ui b/tests/auto/uiloader/baseline/css_qtbug7737_borderimageradius.ui
new file mode 100644
index 0000000..089cb76
--- /dev/null
+++ b/tests/auto/uiloader/baseline/css_qtbug7737_borderimageradius.ui
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>207</width>
+ <height>69</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">QPushButton { border-image: url(&quot;images/pushbutton.png&quot;) 5 5 5 5; border-radius:8px; }</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string>Border image and radius</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>