diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-02-01 21:00:55 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-02-01 21:00:55 +0100 |
commit | dcd5cb973622d059818dba1a2c7b9a7b7601a14c (patch) | |
tree | fbda1c8c6d36cae42b084f7298cf5b1904e21e9f /src/widgets/kernel | |
parent | f299b565b5904e39a47b6133643448e46810f0ed (diff) | |
parent | ff68e5d667cc62141f177d01f747a62c95f08d3e (diff) |
Merge remote-tracking branch 'gerrit/dev' into HEAD
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 26 | ||||
-rw-r--r-- | src/widgets/kernel/qshortcut.cpp | 8 | ||||
-rw-r--r-- | src/widgets/kernel/qsizepolicy.cpp | 12 | ||||
-rw-r--r-- | src/widgets/kernel/qsizepolicy.h | 88 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 8 |
5 files changed, 94 insertions, 48 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 6258605a65..008b2a0d77 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -408,7 +408,6 @@ QWidget *QApplicationPrivate::focus_widget = 0; // has keyboard input foc QWidget *QApplicationPrivate::hidden_focus_widget = 0; // will get keyboard input focus after show() QWidget *QApplicationPrivate::active_window = 0; // toplevel with keyboard focus #ifndef QT_NO_WHEELEVENT -int QApplicationPrivate::wheel_scroll_lines; // number of lines to scroll QPointer<QWidget> QApplicationPrivate::wheel_widget; #endif bool qt_in_tab_key_event = false; @@ -642,19 +641,12 @@ void QApplicationPrivate::initialize() if (qEnvironmentVariableIntValue("QT_USE_NATIVE_WINDOWS") > 0) QCoreApplication::setAttribute(Qt::AA_NativeWindows); -#ifndef QT_NO_WHEELEVENT - QApplicationPrivate::wheel_scroll_lines = 3; -#endif - if (qt_is_gui_used) initializeMultitouch(); if (QApplication::desktopSettingsAware()) if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme()) { QApplicationPrivate::enabledAnimations = theme->themeHint(QPlatformTheme::UiEffects).toInt(); -#ifndef QT_NO_WHEELEVENT - QApplicationPrivate::wheel_scroll_lines = theme->themeHint(QPlatformTheme::WheelScrollLines).toInt(); -#endif } is_app_running = true; // no longer starting up @@ -3290,7 +3282,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) QWheelEvent we(relpos, wheel->globalPos(), wheel->pixelDelta(), wheel->angleDelta(), wheel->delta(), wheel->orientation(), wheel->buttons(), wheel->modifiers(), phase, wheel->source(), wheel->inverted()); bool eventAccepted; - while (w) { + do { we.spont = spontaneous && w == receiver; we.ignore(); res = d->notify_helper(w, &we); @@ -3308,7 +3300,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) we.p += w->pos(); w = w->parentWidget(); - } + } while (w); wheel->setAccepted(eventAccepted); } else if (!spontaneous) { // wheel_widget may forward the wheel event to a delegate widget, @@ -4049,16 +4041,18 @@ int QApplication::keyboardInputInterval() or \l{QAbstractItemView::ScrollPerPixel}{scroll one pixel}. By default, this property has a value of 3. + + \sa QStyleHints::wheelScrollLines() */ #ifndef QT_NO_WHEELEVENT int QApplication::wheelScrollLines() { - return QApplicationPrivate::wheel_scroll_lines; + return styleHints()->wheelScrollLines(); } void QApplication::setWheelScrollLines(int lines) { - QApplicationPrivate::wheel_scroll_lines = lines; + styleHints()->setWheelScrollLines(lines); } #endif @@ -4482,9 +4476,13 @@ void QApplicationPrivate::notifyThemeChanged() #ifndef QT_NO_DRAGANDDROP void QApplicationPrivate::notifyDragStarted(const QDrag *drag) { - // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation. QGuiApplicationPrivate::notifyDragStarted(drag); - qt_button_down = 0; + // QTBUG-26145 + // Prevent pickMouseReceiver() from using the widget where the drag was started after a drag operation... + // QTBUG-56713 + // ...only if qt_button_down is not a QQuickWidget + if (qt_button_down && !qt_button_down->inherits("QQuickWidget")) + qt_button_down = nullptr; } #endif // QT_NO_DRAGANDDROP diff --git a/src/widgets/kernel/qshortcut.cpp b/src/widgets/kernel/qshortcut.cpp index 6eec5ff7e8..be5788274e 100644 --- a/src/widgets/kernel/qshortcut.cpp +++ b/src/widgets/kernel/qshortcut.cpp @@ -141,9 +141,11 @@ bool qWidgetShortcutContextMatcher(QObject *object, Qt::ShortcutContext context) static bool correctWidgetContext(Qt::ShortcutContext context, QWidget *w, QWidget *active_window) { bool visible = w->isVisible(); -#if defined(Q_OS_DARWIN) && !defined(QT_NO_MENUBAR) - if (!qApp->testAttribute(Qt::AA_DontUseNativeMenuBar) && qobject_cast<QMenuBar *>(w)) - visible = true; +#ifndef QT_NO_MENUBAR + if (QMenuBar *menuBar = qobject_cast<QMenuBar *>(w)) { + if (menuBar->isNativeMenuBar()) + visible = true; + } #endif if (!visible || !w->isEnabled()) diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp index e902bb522c..34ad64217b 100644 --- a/src/widgets/kernel/qsizepolicy.cpp +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -395,6 +395,18 @@ void QSizePolicy::setControlType(ControlType type) \fn void QSizePolicy::transpose() Swaps the horizontal and vertical policies and stretches. + + \sa transposed() +*/ + +/*! + \fn QSizePolicy QSizePolicy::transposed() + \since 5.9 + + Returns a size policy object with the horizontal and vertical + policies and stretches swapped. + + \sa transpose() */ /*! diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 3934c0f1d0..3ab672a8e8 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -45,6 +45,29 @@ QT_BEGIN_NAMESPACE +// gcc < 4.8.0 has problems with init'ing variant members in constexpr ctors +// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54922 +#if !defined(Q_CC_GNU) || defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || Q_CC_GNU >= 408 +# define QT_SIZEPOLICY_CONSTEXPR Q_DECL_CONSTEXPR +# if defined(Q_COMPILER_UNIFORM_INIT) +# define QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT Q_DECL_CONSTEXPR +# if defined(Q_COMPILER_CONSTEXPR) +# define QT_SIZEPOLICY_RETURN_BITS(E1, E2, E3, E4, E5, E6, E7, E8) \ + return Bits{ E1, E2, E3, E4, E5, E6, E7, E8 } +# endif // constexpr && uniform-init +# endif // uniform-init +#endif + +#ifndef QT_SIZEPOLICY_CONSTEXPR +# define QT_SIZEPOLICY_CONSTEXPR +#endif +#ifndef QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +# define QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +#endif +#ifndef QT_SIZEPOLICY_RETURN_BITS +# define QT_SIZEPOLICY_RETURN_BITS(E1, E2, E3, E4, E5, E6, E7, E8) \ + const Bits result = { E1, E2, E3, E4, E5, E6, E7, E8 }; return result +#endif class QVariant; class QSizePolicy; @@ -94,7 +117,7 @@ public: Q_DECLARE_FLAGS(ControlTypes, ControlType) Q_FLAG(ControlTypes) - QSizePolicy() : data(0) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy() : data(0) { } QSizePolicy(Policy horizontal, Policy vertical, ControlType type = DefaultType) : data(0) { @@ -102,48 +125,56 @@ public: bits.verPolicy = vertical; setControlType(type); } - Policy horizontalPolicy() const { return static_cast<Policy>(bits.horPolicy); } - Policy verticalPolicy() const { return static_cast<Policy>(bits.verPolicy); } + QT_SIZEPOLICY_CONSTEXPR Policy horizontalPolicy() const { return static_cast<Policy>(bits.horPolicy); } + QT_SIZEPOLICY_CONSTEXPR Policy verticalPolicy() const { return static_cast<Policy>(bits.verPolicy); } ControlType controlType() const; void setHorizontalPolicy(Policy d) { bits.horPolicy = d; } void setVerticalPolicy(Policy d) { bits.verPolicy = d; } void setControlType(ControlType type); - Qt::Orientations expandingDirections() const { + QT_SIZEPOLICY_CONSTEXPR Qt::Orientations expandingDirections() const { return ( (verticalPolicy() & ExpandFlag) ? Qt::Vertical : Qt::Orientations() ) | ( (horizontalPolicy() & ExpandFlag) ? Qt::Horizontal : Qt::Orientations() ) ; } - void setHeightForWidth(bool b) { bits.hfw = b; } - bool hasHeightForWidth() const { return bits.hfw; } + void setHeightForWidth(bool b) { bits.hfw = b; } + QT_SIZEPOLICY_CONSTEXPR bool hasHeightForWidth() const { return bits.hfw; } void setWidthForHeight(bool b) { bits.wfh = b; } - bool hasWidthForHeight() const { return bits.wfh; } + QT_SIZEPOLICY_CONSTEXPR bool hasWidthForHeight() const { return bits.wfh; } - bool operator==(const QSizePolicy& s) const { return data == s.data; } - bool operator!=(const QSizePolicy& s) const { return data != s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator==(const QSizePolicy& s) const { return data == s.data; } + QT_SIZEPOLICY_CONSTEXPR bool operator!=(const QSizePolicy& s) const { return data != s.data; } friend Q_DECL_CONST_FUNCTION uint qHash(QSizePolicy key, uint seed) Q_DECL_NOTHROW { return qHash(key.data, seed); } operator QVariant() const; - int horizontalStretch() const { return static_cast<int>(bits.horStretch); } - int verticalStretch() const { return static_cast<int>(bits.verStretch); } + QT_SIZEPOLICY_CONSTEXPR int horizontalStretch() const { return static_cast<int>(bits.horStretch); } + QT_SIZEPOLICY_CONSTEXPR int verticalStretch() const { return static_cast<int>(bits.verStretch); } void setHorizontalStretch(int stretchFactor) { bits.horStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); } void setVerticalStretch(int stretchFactor) { bits.verStretch = static_cast<quint32>(qBound(0, stretchFactor, 255)); } - bool retainSizeWhenHidden() const { return bits.retainSizeWhenHidden; } + QT_SIZEPOLICY_CONSTEXPR bool retainSizeWhenHidden() const { return bits.retainSizeWhenHidden; } void setRetainSizeWhenHidden(bool retainSize) { bits.retainSizeWhenHidden = retainSize; } - void transpose(); - + void transpose() { *this = transposed(); } +#ifndef Q_QDOC + QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +#endif + QSizePolicy transposed() const Q_DECL_NOTHROW Q_REQUIRED_RESULT + { + return QSizePolicy(bits.transposed()); + } private: #ifndef QT_NO_DATASTREAM friend Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); friend Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); #endif - QSizePolicy(int i) : data(i) { } + QT_SIZEPOLICY_CONSTEXPR QSizePolicy(int i) : data(i) { } + struct Bits; + QT_SIZEPOLICY_CONSTEXPR explicit QSizePolicy(Bits b) Q_DECL_NOTHROW : bits(b) { } struct Bits { quint32 horStretch : 8; @@ -154,6 +185,19 @@ private: quint32 hfw : 1; quint32 wfh : 1; quint32 retainSizeWhenHidden : 1; + + QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT + Bits transposed() const Q_DECL_NOTHROW + { + QT_SIZEPOLICY_RETURN_BITS(verStretch, // \ swap + horStretch, // / + verPolicy, // \ swap + horPolicy, // / + ctype, + hfw, // \ don't swap (historic behavior) + wfh, // / + retainSizeWhenHidden); + } }; union { Bits bits; @@ -176,16 +220,10 @@ Q_WIDGETS_EXPORT QDataStream &operator>>(QDataStream &, QSizePolicy &); Q_WIDGETS_EXPORT QDebug operator<<(QDebug dbg, const QSizePolicy &); #endif -inline void QSizePolicy::transpose() { - Policy hData = horizontalPolicy(); - Policy vData = verticalPolicy(); - int hStretch = horizontalStretch(); - int vStretch = verticalStretch(); - setHorizontalPolicy(vData); - setVerticalPolicy(hData); - setHorizontalStretch(vStretch); - setVerticalStretch(hStretch); -} + +#undef QT_SIZEPOLICY_CONSTEXPR +#undef QT_SIZEPOLICY_CONSTEXPR_AND_UNIFORM_INIT +#undef QT_SIZEPOLICY_RETURN_BITS QT_END_NAMESPACE diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 61956b3fa4..759821a057 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2526,10 +2526,6 @@ QWidget *QWidget::find(WId id) If a widget is non-native (alien) and winId() is invoked on it, that widget will be provided a native handle. - On \macos, the type returned depends on which framework Qt was linked - against. If Qt is using Carbon, the {WId} is actually an HIViewRef. If Qt - is using Cocoa, {WId} is a pointer to an NSView. - This value may change at run-time. An event with type QEvent::WinIdChange will be sent to the widget following a change in window system identifier. @@ -9988,8 +9984,8 @@ bool QWidget::nativeEvent(const QByteArray &eventType, void *message, long *resu } /*! - Ensures that the widget has been polished by QStyle (i.e., has a - proper font and palette). + Ensures that the widget and its children have been polished by + QStyle (i.e., have a proper font and palette). QWidget calls this function after it has been fully constructed but before it is shown the very first time. You can call this |