summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp23
-rw-r--r--src/gui/image/qpixmap.cpp3
-rw-r--r--src/gui/kernel/qapplication.cpp4
-rw-r--r--src/gui/kernel/qapplication_mac.mm37
-rw-r--r--src/gui/kernel/qcocoaview_mac.mm24
-rw-r--r--src/gui/kernel/qgesture.cpp6
-rw-r--r--src/gui/kernel/qstandardgestures.cpp1
-rw-r--r--src/gui/kernel/qwidget_mac.mm11
-rw-r--r--src/gui/widgets/qabstractslider.cpp44
9 files changed, 71 insertions, 82 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index 97357a7..378a4b5 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -1228,7 +1228,8 @@ void QGraphicsItemCache::purge()
}
/*!
- Constructs a QGraphicsItem, passing \a item to QGraphicsItem's constructor. It does not modify \fn QObject::parent().
+ Constructs a QGraphicsItem, passing \a item to QGraphicsItem's constructor.
+ It does not modify the parent object returned by QObject::parent().
If \a parent is 0, you can add the item to a scene by calling
QGraphicsScene::addItem(). The item will then become a top-level item.
@@ -7283,6 +7284,21 @@ static void qt_graphicsItem_highlightSelected(
The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms.
It maps many of QGraphicsItem's basic setters and getters to properties and adds notification
signals for many of them.
+
+ \section1 Parents and Children
+
+ Each graphics object can be constructed with a parent item. This ensures that the
+ item will be destroyed when its parent item is destroyed. Although QGraphicsObject
+ inherits from both QObject and QGraphicsItem, you should use the functions provided
+ by QGraphicsItem, \e not QObject, to manage the relationships between parent and
+ child items.
+
+ The relationships between items can be explored using the parentItem() and childItems()
+ functions. In the hierarchy of items in a scene, the parentObject() and parentWidget()
+ functions are the equivalent of the QWidget::parent() and QWidget::parentWidget()
+ functions for QWidget subclasses.
+
+ \sa QGraphicsWidget
*/
/*!
@@ -7318,7 +7334,10 @@ void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureContext co
/*!
\property QGraphicsObject::parent
- \brief the parent of the item. It is independent from \fn QObject::parent.
+ \brief the parent of the item
+
+ \note The item's parent is set independently of the parent object returned
+ by QObject::parent().
\sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject()
*/
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index a3b7516..45ff5f4 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -860,6 +860,9 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers
bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags)
{
+ if (len == 0 || buf == 0)
+ return false;
+
return data->fromData(buf, len, format, flags);
}
diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp
index 7c38d4b..85b055e 100644
--- a/src/gui/kernel/qapplication.cpp
+++ b/src/gui/kernel/qapplication.cpp
@@ -940,12 +940,8 @@ void QApplicationPrivate::initialize()
graphics_system = QGraphicsSystemFactory::create(graphics_system_name);
#endif
#ifndef QT_NO_WHEELEVENT
-#ifdef Q_OS_MAC
- QApplicationPrivate::wheel_scroll_lines = 1;
-#else
QApplicationPrivate::wheel_scroll_lines = 3;
#endif
-#endif
initializeMultitouch();
}
diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm
index 771cddc..84e0d50 100644
--- a/src/gui/kernel/qapplication_mac.mm
+++ b/src/gui/kernel/qapplication_mac.mm
@@ -1697,15 +1697,14 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
// (actually two events; one for horizontal and one for vertical).
// As a results of this, and to make sure we dont't receive duplicate events,
// we try to detect when this happend by checking the 'compatibilityEvent'.
- const int scrollFactor = 4 * 8;
SInt32 mdelt = 0;
GetEventParameter(event, kEventParamMouseWheelSmoothHorizontalDelta, typeSInt32, 0,
sizeof(mdelt), 0, &mdelt);
- wheel_deltaX = mdelt * scrollFactor;
+ wheel_deltaX = mdelt;
mdelt = 0;
GetEventParameter(event, kEventParamMouseWheelSmoothVerticalDelta, typeSInt32, 0,
sizeof(mdelt), 0, &mdelt);
- wheel_deltaY = mdelt * scrollFactor;
+ wheel_deltaY = mdelt;
GetEventParameter(event, kEventParamEventRef, typeEventRef, 0,
sizeof(compatibilityEvent), 0, &compatibilityEvent);
} else if (ekind == kEventMouseWheelMoved) {
@@ -1718,31 +1717,11 @@ QApplicationPrivate::globalEventProcessor(EventHandlerCallRef er, EventRef event
GetEventParameter(event, kEventParamMouseWheelAxis, typeMouseWheelAxis, 0,
sizeof(axis), 0, &axis);
- // The 'new' event has acceleration applied by the OS, while the old (on
- // Carbon only), has not. So we introduce acceleration here to be consistent.
- // The acceleration is trying to respect both pixel based and line scrolling,
- // which turns out to be rather difficult.
- int linesToScroll = mdelt > 0 ? 1 : -1;
- static QTime t;
- int elapsed = t.elapsed();
- t.restart();
- if (elapsed < 20)
- linesToScroll *= 120;
- else if (elapsed < 30)
- linesToScroll *= 60;
- else if (elapsed < 50)
- linesToScroll *= 30;
- else if (elapsed < 100)
- linesToScroll *= 6;
- else if (elapsed < 200)
- linesToScroll *= 3;
- else if (elapsed < 300)
- linesToScroll *= 2;
-
+ // Remove acceleration, and use either -120 or 120 as delta:
if (axis == kEventMouseWheelAxisX)
- wheel_deltaX = linesToScroll * 120;
+ wheel_deltaX = qBound(-120, int(mdelt * 10000), 120);
else
- wheel_deltaY = linesToScroll * 120;
+ wheel_deltaY = qBound(-120, int(mdelt * 10000), 120);
}
}
@@ -2695,11 +2674,7 @@ int QApplication::keyboardInputInterval()
void QApplication::setWheelScrollLines(int n)
{
- Q_UNUSED(n);
- // On Mac, acceleration is handled by the OS. Multiplying wheel scroll
- // deltas with n will not be as cross platform as one might think! So
- // we choose to go native in this case (and let wheel_scroll_lines == 1).
- // QApplicationPrivate::wheel_scroll_lines = n;
+ QApplicationPrivate::wheel_scroll_lines = n;
}
int QApplication::wheelScrollLines()
diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm
index d49c150..ecc6bc9 100644
--- a/src/gui/kernel/qcocoaview_mac.mm
+++ b/src/gui/kernel/qcocoaview_mac.mm
@@ -795,23 +795,23 @@ extern "C" {
const EventRef carbonEvent = (EventRef)[theEvent eventRef];
const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
- if (carbonEventKind == kEventMouseScroll) {
+ const bool scrollEvent = carbonEventKind == kEventMouseScroll;
+
+ if (scrollEvent) {
// The mouse device containts pixel scroll wheel support (Mighty Mouse, Trackpad).
// Since deviceDelta is delivered as pixels rather than degrees, we need to
// convert from pixels to degrees in a sensible manner.
// It looks like four degrees per pixel behaves most native.
// Qt expects the unit for delta to be 1/8 of a degree:
- const int scrollFactor = 4 * 8;
- deltaX = (int)[theEvent deviceDeltaX] * scrollFactor;
- deltaY = (int)[theEvent deviceDeltaY] * scrollFactor;
- deltaZ = (int)[theEvent deviceDeltaZ] * scrollFactor;
- } else { // carbonEventKind == kEventMouseWheelMoved
- // Mouse wheel deltas seem to tick in at increments of 0.1.
- // Qt widgets expect the delta to be a multiple of 120.
- const int scrollFactor = 10 * 120;
- deltaX = [theEvent deltaX] * scrollFactor;
- deltaY = [theEvent deltaY] * scrollFactor;
- deltaZ = [theEvent deltaZ] * scrollFactor;
+ deltaX = [theEvent deviceDeltaX];
+ deltaY = [theEvent deviceDeltaY];
+ deltaZ = [theEvent deviceDeltaZ];
+ } else {
+ // carbonEventKind == kEventMouseWheelMoved
+ // Remove acceleration, and use either -120 or 120 as delta:
+ deltaX = qBound(-120, int([theEvent deltaX] * 10000), 120);
+ deltaY = qBound(-120, int([theEvent deltaY] * 10000), 120);
+ deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120);
}
if (deltaX != 0) {
diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp
index ecdd661..a161876 100644
--- a/src/gui/kernel/qgesture.cpp
+++ b/src/gui/kernel/qgesture.cpp
@@ -142,12 +142,6 @@ QGesture::~QGesture()
\brief whether the gesture has a hot-spot
*/
-/*!
- \property QGesture::targetObject
- \brief the target object which will receive the gesture event if the hotSpot is
- not set
-*/
-
Qt::GestureType QGesture::gestureType() const
{
return d_func()->gestureType;
diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp
index a136379..dec2311 100644
--- a/src/gui/kernel/qstandardgestures.cpp
+++ b/src/gui/kernel/qstandardgestures.cpp
@@ -140,7 +140,6 @@ void QPanGestureRecognizer::reset(QGesture *state)
QGestureRecognizer::reset(state);
}
-/*! \internal */
/*
bool QPanGestureRecognizer::event(QEvent *event)
{
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index d08f8a9..95c0bed 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -3390,12 +3390,19 @@ void QWidgetPrivate::hide_sys()
w = q->parentWidget()->window();
if(!w || (!w->isVisible() && !w->isMinimized())) {
#ifndef QT_MAC_USE_COCOA
- for(WindowPtr wp = GetFrontWindowOfClass(kDocumentWindowClass, true);
- wp; wp = GetNextWindowOfClass(wp, kDocumentWindowClass, true)) {
+ for (WindowPtr wp = GetFrontWindowOfClass(kMovableModalWindowClass, true);
+ wp; wp = GetNextWindowOfClass(wp, kMovableModalWindowClass, true)) {
if((w = qt_mac_find_window(wp)))
break;
}
if (!w){
+ for (WindowPtr wp = GetFrontWindowOfClass(kDocumentWindowClass, true);
+ wp; wp = GetNextWindowOfClass(wp, kDocumentWindowClass, true)) {
+ if((w = qt_mac_find_window(wp)))
+ break;
+ }
+ }
+ if (!w){
for(WindowPtr wp = GetFrontWindowOfClass(kSimpleWindowClass, true);
wp; wp = GetNextWindowOfClass(wp, kSimpleWindowClass, true)) {
if((w = qt_mac_find_window(wp)))
diff --git a/src/gui/widgets/qabstractslider.cpp b/src/gui/widgets/qabstractslider.cpp
index 588a48e..fec9fab 100644
--- a/src/gui/widgets/qabstractslider.cpp
+++ b/src/gui/widgets/qabstractslider.cpp
@@ -693,29 +693,27 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
if (e->orientation() != d->orientation && !rect().contains(e->pos()))
return;
- qreal currentOffset = qreal(e->delta()) / 120;
- d->offset_accumulated += currentOffset;
- if (int(d->offset_accumulated) == 0) {
- // QAbstractSlider works on integer values. So if the accumulated
- // offset is less than +/- 1, we need to wait until we get more
- // wheel events (this means that the wheel resolution is higher than
- // 15 degrees, e.g. when using mac mighty mouse/trackpad):
- return;
- }
+ int stepsToScroll = 0;
+ qreal offset = qreal(e->delta()) / 120;
- int stepsToScroll;
if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier)) {
- stepsToScroll = currentOffset > 0 ? d->pageStep : -d->pageStep;
+ // Scroll one page regardless of delta:
+ stepsToScroll = qBound(-d->pageStep, int(offset * d->pageStep), d->pageStep);
+ d->offset_accumulated = 0;
} else {
- // Calculate the number of steps to scroll (per 15 degrees of rotate):
-#ifdef Q_OS_MAC
- // On mac, since mouse wheel scrolling is accelerated and
- // fine tuned by the OS, we skip applying acceleration:
- stepsToScroll = int(d->offset_accumulated);
-#else
- stepsToScroll = int(d->offset_accumulated) * QApplication::wheelScrollLines() * d->singleStep;
-#endif
- stepsToScroll = qBound(-d->pageStep, stepsToScroll, d->pageStep);
+ // Calculate how many lines to scroll. Depending on what delta is (and
+ // offset), we might end up with a fraction (e.g. scroll 1.3 lines). We can
+ // only scroll whole lines, so we keep the reminder until next event.
+ qreal stepsToScrollF = offset * QApplication::wheelScrollLines() * d->singleStep;
+ // Check if wheel changed direction since last event:
+ if (d->offset_accumulated != 0 && (offset / d->offset_accumulated) < 0)
+ d->offset_accumulated = 0;
+
+ d->offset_accumulated += stepsToScrollF;
+ stepsToScroll = qBound(-d->pageStep, int(d->offset_accumulated), d->pageStep);
+ d->offset_accumulated -= int(d->offset_accumulated);
+ if (stepsToScroll == 0)
+ return;
}
if (d->invertedControls)
@@ -725,12 +723,10 @@ void QAbstractSlider::wheelEvent(QWheelEvent * e)
d->position = d->overflowSafeAdd(stepsToScroll); // value will be updated by triggerAction()
triggerAction(SliderMove);
- if (prevValue == d->value) {
+ if (prevValue == d->value)
d->offset_accumulated = 0;
- } else {
- d->offset_accumulated -= int(d->offset_accumulated);
+ else
e->accept();
- }
}
#endif
#ifdef QT_KEYPAD_NAVIGATION