diff options
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/qaction.h | 6 | ||||
-rw-r--r-- | src/widgets/kernel/qapplication.cpp | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qdesktopwidget.qdoc | 10 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget.cpp | 30 | ||||
-rw-r--r-- | src/widgets/kernel/qwidget_p.h | 2 | ||||
-rw-r--r-- | src/widgets/kernel/qwidgetwindow.cpp | 24 |
6 files changed, 42 insertions, 33 deletions
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index abfa2cdd42..bd491c89ca 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -90,9 +90,9 @@ public: NormalPriority = 128, HighPriority = 256}; Q_ENUM(Priority) - explicit QAction(QObject* parent); - QAction(const QString &text, QObject* parent); - QAction(const QIcon &icon, const QString &text, QObject* parent); + explicit QAction(QObject *parent = nullptr); + explicit QAction(const QString &text, QObject *parent = nullptr); + explicit QAction(const QIcon &icon, const QString &text, QObject *parent = nullptr); ~QAction(); diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 2e68c7888f..141f15637c 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -436,8 +436,6 @@ Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypa QWidget *QApplicationPrivate::oldEditFocus = 0; #endif -bool qt_tabletChokeMouse = false; - inline bool QApplicationPrivate::isAlien(QWidget *widget) { return widget && !widget->isWindow(); @@ -3459,7 +3457,6 @@ bool QApplication::notify(QObject *receiver, QEvent *e) w = w->parentWidget(); } tablet->setAccepted(eventAccepted); - qt_tabletChokeMouse = tablet->isAccepted(); } break; #endif // QT_NO_TABLETEVENT diff --git a/src/widgets/kernel/qdesktopwidget.qdoc b/src/widgets/kernel/qdesktopwidget.qdoc index abdbd35f5b..c23e942eec 100644 --- a/src/widgets/kernel/qdesktopwidget.qdoc +++ b/src/widgets/kernel/qdesktopwidget.qdoc @@ -1,7 +1,7 @@ /**************************************************************************** ** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ ** ** This file is part of the documentation of the Qt Toolkit. ** @@ -11,8 +11,8 @@ ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. ** ** GNU Free Documentation License Usage ** Alternatively, this file may be used under the terms of the GNU Free @@ -20,7 +20,7 @@ ** Foundation and appearing in the file included in the packaging of ** this file. Please review the following information to ensure ** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. ** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 598991bd98..986f1d0218 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1250,11 +1250,14 @@ void QWidgetPrivate::createRecursively() } - +// ### fixme: Qt 6: Remove parameter window from QWidget::create() /*! - Creates a new widget window if \a window is 0, otherwise sets the - widget's window to \a window. + Creates a new widget window. + + The parameter \a window is ignored in Qt 5. Please use + QWindow::fromWinId() to create a QWindow wrapping a foreign + window and pass it to QWidget::createWindowContainer() instead. Initializes the window (sets the geometry etc.) if \a initializeWindow is true. If \a initializeWindow is false, no @@ -1267,11 +1270,15 @@ void QWidgetPrivate::createRecursively() The QWidget constructor calls create(0,true,true) to create a window for this widget. + + \sa createWindowContainer(), QWindow::fromWinId() */ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) { Q_D(QWidget); + if (Q_UNLIKELY(window)) + qWarning("QWidget::create(): Parameter 'window' does not have any effect."); if (testAttribute(Qt::WA_WState_Created) && window == 0 && internalWinId()) return; @@ -1295,7 +1302,7 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) // We're about to create a native child widget that doesn't have a native parent; // enforce a native handle for the parent unless the Qt::WA_DontCreateNativeAncestors // attribute is set. - d->createWinId(window); + d->createWinId(); // Nothing more to do. Q_ASSERT(testAttribute(Qt::WA_WState_Created)); Q_ASSERT(internalWinId()); @@ -2534,13 +2541,12 @@ WId QWidget::winId() const return data->winid; } - -void QWidgetPrivate::createWinId(WId winid) +void QWidgetPrivate::createWinId() { Q_Q(QWidget); #ifdef ALIEN_DEBUG - qDebug() << "QWidgetPrivate::createWinId for" << q << winid; + qDebug() << "QWidgetPrivate::createWinId for" << q; #endif const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { @@ -2557,15 +2563,7 @@ void QWidgetPrivate::createWinId(WId winid) QWidget *w = qobject_cast<QWidget *>(pd->children.at(i)); if (w && !w->isWindow() && (!w->testAttribute(Qt::WA_WState_Created) || (!w->internalWinId() && w->testAttribute(Qt::WA_NativeWindow)))) { - if (w!=q) { - w->create(); - } else { - w->create(winid); - // if the window has already been created, we - // need to raise it to its proper stacking position - if (winid) - w->raise(); - } + w->create(); } } } else { diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 91af7a4cb0..838236536a 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -339,7 +339,7 @@ public: void init(QWidget *desktopWidget, Qt::WindowFlags f); void create_sys(WId window, bool initializeWindow, bool destroyOldWindow); void createRecursively(); - void createWinId(WId id = 0); + void createWinId(); void createTLExtra(); void createExtra(); diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index c22841dd56..3ba04e4a2a 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -162,11 +162,29 @@ QObject *QWidgetWindow::focusObject() const return widget; } +static inline bool shouldBePropagatedToWidget(QEvent *event) +{ + switch (event->type()) { + // Handing show events to widgets would cause them to be triggered twice + case QEvent::Show: + case QEvent::Hide: + case QEvent::Timer: + case QEvent::DynamicPropertyChange: + case QEvent::ChildAdded: + case QEvent::ChildRemoved: + return false; + default: + return true; + } +} + bool QWidgetWindow::event(QEvent *event) { if (m_widget->testAttribute(Qt::WA_DontShowOnScreen)) { // \a event is uninteresting for QWidgetWindow, the event was probably // generated before WA_DontShowOnScreen was set + if (!shouldBePropagatedToWidget(event)) + return true; return QCoreApplication::sendEvent(m_widget, event); } @@ -291,10 +309,6 @@ bool QWidgetWindow::event(QEvent *event) return true; #endif // QT_NO_CONTEXTMENU - // Handing show events to widgets (see below) here would cause them to be triggered twice - case QEvent::Show: - case QEvent::Hide: - return QWindow::event(event); case QEvent::WindowBlocked: qt_button_down = 0; break; @@ -309,7 +323,7 @@ bool QWidgetWindow::event(QEvent *event) break; } - if (QCoreApplication::sendEvent(m_widget, event) && event->type() != QEvent::Timer) + if (shouldBePropagatedToWidget(event) && QCoreApplication::sendEvent(m_widget, event)) return true; return QWindow::event(event); |