diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-05-23 21:27:07 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-05-23 21:27:07 +0200 |
commit | d3a8bc803cd7c4ce106038bfc4b37cdd6bb8e177 (patch) | |
tree | 3b6db0d4869f334d0eb4559c5ae457995cbe913e /src/widgets/kernel | |
parent | d934ddc297f6db94dbc548fe01da64350f13577d (diff) | |
parent | 47a7628023610904c6ac52e23fa289f75f349b4e (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/corelib/io/qdatastream.cpp
src/corelib/io/qdatastream.h
src/corelib/json/qjsonwriter.cpp
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/xcb/qxcbkeyboard.cpp
Change-Id: I46fef1455f5a9f2ce1ec394a3c65881093c51b62
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qformlayout.cpp | 4 | ||||
-rw-r--r-- | src/widgets/kernel/qformlayout.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qlayout.cpp | 10 | ||||
-rw-r--r-- | src/widgets/kernel/qshortcut.cpp | 10 | ||||
-rw-r--r-- | src/widgets/kernel/qstandardgestures.cpp | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 16 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_qpa.cpp | 14 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 10 |
9 files changed, 48 insertions, 23 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b8d3117a41..edd7cafd83 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3821,7 +3821,8 @@ bool QApplicationPrivate::translateTouchToMouse(QWidget *widget, QTouchEvent *ev const QPoint pos = widget->mapFromGlobal(p.screenPos().toPoint()); QMouseEvent mouseEvent(eventType, pos, p.screenPos().toPoint(), - Qt::LeftButton, Qt::LeftButton, + Qt::LeftButton, + (eventType == QEvent::MouseButtonRelease) ? Qt::NoButton : Qt::LeftButton, event->modifiers()); mouseEvent.setAccepted(true); mouseEvent.setTimestamp(event->timestamp()); diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 669faac4f6..fd6482d5af 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1022,7 +1022,7 @@ QStyle* QFormLayoutPrivate::getStyle() const \li \b{Adherence to the different platform's look and feel guidelines.} For example, the - \l{https://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html}{Mac OS X Aqua} and KDE guidelines specify that the + \l{http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html}{Mac OS X Aqua} and KDE guidelines specify that the labels should be right-aligned, whereas Windows and GNOME applications normally use left-alignment. @@ -1065,7 +1065,7 @@ QStyle* QFormLayoutPrivate::getStyle() const corresponds to what we would get using a two-column QGridLayout.) \li Style based on the - \l{https://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html}{Mac OS X Aqua} guidelines. Labels are right-aligned, + \l{http://developer.apple.com/library/mac/#documentation/UserExperience/Conceptual/AppleHIGuidelines/Intro/Intro.html}{Mac OS X Aqua} guidelines. Labels are right-aligned, the fields don't grow beyond their size hint, and the form is horizontally centered. \li Recommended style for diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h index d59f71eb32..a1356c734f 100644 --- a/src/widgets/kernel/qformlayout.h +++ b/src/widgets/kernel/qformlayout.h @@ -52,7 +52,7 @@ class QFormLayoutPrivate; class Q_WIDGETS_EXPORT QFormLayout : public QLayout { Q_OBJECT - Q_ENUMS(FormStyle FieldGrowthPolicy RowWrapPolicy ItemRole) + Q_ENUMS(FieldGrowthPolicy RowWrapPolicy ItemRole) Q_DECLARE_PRIVATE(QFormLayout) Q_PROPERTY(FieldGrowthPolicy fieldGrowthPolicy READ fieldGrowthPolicy WRITE setFieldGrowthPolicy RESET resetFieldGrowthPolicy) Q_PROPERTY(RowWrapPolicy rowWrapPolicy READ rowWrapPolicy WRITE setRowWrapPolicy RESET resetRowWrapPolicy) diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 0402f9939a..a65c34adf5 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -59,12 +59,10 @@ static int menuBarHeightForWidth(QWidget *menubar, int w) { if (menubar && !menubar->isHidden() && !menubar->isWindow()) { int result = menubar->heightForWidth(qMax(w, menubar->minimumWidth())); - if (result != -1) - return result; - result = menubar->sizeHint() - .expandedTo(menubar->minimumSize()) - .expandedTo(menubar->minimumSizeHint()) - .boundedTo(menubar->maximumSize()).height(); + if (result == -1) + result = menubar->sizeHint().height(); + const int min = qSmartMinSize(menubar).height(); + result = qBound(min, result, menubar->maximumSize().height()); if (result != -1) return result; } diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index f323c682d1..c5cdce3d60 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -246,9 +246,19 @@ static bool correctActionContext(Qt::ShortcutContext context, QAction *a, QWidge QWidget *w = widgets.at(i); #ifndef QT_NO_MENU if (QMenu *menu = qobject_cast<QMenu *>(w)) { +#ifdef Q_OS_MAC + // On Mac, menu item shortcuts are processed before reaching any window. + // That means that if a menu action shortcut has not been already processed + // (and reaches this point), then the menu item itself has been disabled. + // This occurs at the QPA level on Mac, were we disable all the Cocoa menus + // when showing a modal window. + Q_UNUSED(menu); + continue; +#else QAction *a = menu->menuAction(); if (correctActionContext(context, a, active_window)) return true; +#endif } else #endif if (correctWidgetContext(context, w, active_window)) diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index f4307e9737..e3fd6404db 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -59,7 +59,7 @@ QPanGestureRecognizer::QPanGestureRecognizer() QGesture *QPanGestureRecognizer::create(QObject *target) { if (target && target->isWidgetType()) { -#if ((defined(Q_OS_MAC) && !defined(Q_OS_IOS)) || defined(Q_OS_WIN)) && !defined(QT_NO_NATIVE_GESTURES) +#if (defined(Q_OS_MACX) || defined(Q_OS_WIN)) && !defined(QT_NO_NATIVE_GESTURES) // for scroll areas on Windows and Mac OS X we want to use native gestures instead if (!qobject_cast<QAbstractScrollArea *>(target->parent())) static_cast<QWidget *>(target)->setAttribute(Qt::WA_AcceptTouchEvents); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index cb7761add7..cfccce7c41 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -3040,7 +3040,8 @@ QList<QAction*> QWidget::actions() const Disabling a widget implicitly disables all its children. Enabling respectively enables all child widgets unless they have been - explicitly disabled. + explicitly disabled. It it not possible to explicitly enable a child + widget which is not a window while its parent widget remains disabled. By default, this property is true. @@ -9909,11 +9910,16 @@ void QWidget::update(const QRect &rect) */ void QWidget::update(const QRegion &rgn) { - if (!isVisible() || !updatesEnabled() || rgn.isEmpty()) + if (!isVisible() || !updatesEnabled()) + return; + + QRegion r = rgn & QWidget::rect(); + + if (r.isEmpty()) return; if (testAttribute(Qt::WA_WState_InPaintEvent)) { - QApplication::postEvent(this, new QUpdateLaterEvent(rgn)); + QApplication::postEvent(this, new QUpdateLaterEvent(r)); return; } @@ -9926,9 +9932,9 @@ void QWidget::update(const QRegion &rgn) #endif // Q_WS_MAC QTLWExtra *tlwExtra = window()->d_func()->maybeTopData(); if (tlwExtra && !tlwExtra->inTopLevelResize && tlwExtra->backingStore) - tlwExtra->backingStoreTracker->markDirty(rgn, this); + tlwExtra->backingStoreTracker->markDirty(r, this); } else { - d_func()->repaint_sys(rgn); + d_func()->repaint_sys(r); } } diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index a4da98815b..3b6c9ca448 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -137,6 +137,9 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ? QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive; win->create(); + // Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing. + if ((flags & Qt::Desktop) == Qt::Window) + win->handle()->setFrameStrutEventsEnabled(true); data.window_flags = win->flags(); @@ -260,10 +263,8 @@ void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) bool explicitlyHidden = q->testAttribute(Qt::WA_WState_Hidden) && q->testAttribute(Qt::WA_WState_ExplicitShowHide); // Reparenting toplevel to child - if (!(f&Qt::Window) && (oldFlags&Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) { - //qDebug() << "setParent_sys() change from toplevel"; + if (wasCreated && !(f & Qt::Window) && (oldFlags & Qt::Window) && !q->testAttribute(Qt::WA_NativeWindow)) q->destroy(); - } adjustFlags(f, q); data.window_flags = f; @@ -543,6 +544,13 @@ void QWidgetPrivate::show_sys() #endif invalidateBuffer(q->rect()); window->setVisible(true); + // Was the window moved by the Window system or QPlatformWindow::initialGeometry() ? + if (window->isTopLevel()) { + const QPoint crectTopLeft = q->data->crect.topLeft(); + const QPoint windowTopLeft = window->geometry().topLeft(); + if (crectTopLeft == QPoint(0, 0) && windowTopLeft != crectTopLeft) + q->data->crect.moveTopLeft(windowTopLeft); + } } } diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index bedcfe78bf..c19b617091 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -476,6 +476,10 @@ void QWidgetWindow::handleTouchEvent(QTouchEvent *event) if (event->type() == QEvent::TouchCancel) { QApplicationPrivate::translateTouchCancel(event->device(), event->timestamp()); event->accept(); + } else if (qApp->d_func()->inPopupMode()) { + // Ignore touch events for popups. This will cause QGuiApplication to synthesise mouse + // events instead, which QWidgetWindow::handleMouseEvent will forward correctly: + event->ignore(); } else { event->setAccepted(QApplicationPrivate::translateRawTouchEvent(m_widget, event->device(), event->touchPoints(), event->timestamp())); } @@ -486,15 +490,13 @@ void QWidgetWindow::handleKeyEvent(QKeyEvent *event) if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type())) return; - QObject *receiver = 0; - if (QApplicationPrivate::inPopupMode()) { + QObject *receiver = QWidget::keyboardGrabber(); + if (!receiver && QApplicationPrivate::inPopupMode()) { QWidget *popup = QApplication::activePopupWidget(); QWidget *popupFocusWidget = popup->focusWidget(); receiver = popupFocusWidget ? popupFocusWidget : popup; } if (!receiver) - receiver = QWidget::keyboardGrabber(); - if (!receiver) receiver = focusObject(); QGuiApplication::sendSpontaneousEvent(receiver, event); } |