diff options
Diffstat (limited to 'src/widgets/kernel')
59 files changed, 781 insertions, 2656 deletions
diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index 7c9496f638..4311d503d7 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtGui/QAction> diff --git a/src/widgets/kernel/qaction_widgets.cpp b/src/widgets/kernel/qaction_widgets.cpp index dcecb32b06..53b6e13b2d 100644 --- a/src/widgets/kernel/qaction_widgets.cpp +++ b/src/widgets/kernel/qaction_widgets.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qaction.h" diff --git a/src/widgets/kernel/qaction_widgets_p.h b/src/widgets/kernel/qaction_widgets_p.h index c301aeb926..bc24ce3df1 100644 --- a/src/widgets/kernel/qaction_widgets_p.h +++ b/src/widgets/kernel/qaction_widgets_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QACTION_WIDGETS_P_H #define QACTION_WIDGETS_P_H diff --git a/src/widgets/kernel/qactiongroup.h b/src/widgets/kernel/qactiongroup.h index 74c6c44a00..2592eb17b4 100644 --- a/src/widgets/kernel/qactiongroup.h +++ b/src/widgets/kernel/qactiongroup.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtGui/QActionGroup> diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index f3deab05a1..0812faf99a 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qplatformdefs.h" #include "qabstracteventdispatcher.h" @@ -84,6 +48,9 @@ #if QT_CONFIG(whatsthis) #include <QtWidgets/QWhatsThis> #endif +#if QT_CONFIG(accessibility) +#include <QtGui/qaccessible_base.h> +#endif #include "private/qkeymapper_p.h" #include "private/qaccessiblewidgetfactory_p.h" @@ -116,8 +83,6 @@ #include <algorithm> #include <iterator> -//#define ALIEN_DEBUG - static void initResources() { Q_INIT_RESOURCE(qstyle); @@ -129,6 +94,8 @@ static void initResources() QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + // Helper macro for static functions to check on the existence of the application class. #define CHECK_QAPP_INSTANCE(...) \ if (Q_LIKELY(QCoreApplication::instance())) { \ @@ -144,8 +111,8 @@ QApplicationPrivate *QApplicationPrivate::self = nullptr; bool QApplicationPrivate::autoSipEnabled = true; -QApplicationPrivate::QApplicationPrivate(int &argc, char **argv, int flags) - : QApplicationPrivateBase(argc, argv, flags) +QApplicationPrivate::QApplicationPrivate(int &argc, char **argv) + : QGuiApplicationPrivate(argc, argv) { application_type = QApplicationPrivate::Gui; @@ -388,7 +355,7 @@ void QApplicationPrivate::process_cmdline() styleOverride = QString::fromLocal8Bit(qgetenv("QT_STYLE_OVERRIDE")); // process platform-indep command line - if (!qt_is_gui_used || !argc) + if (qt_is_tty_app || !argc) return; int i, j; @@ -408,10 +375,10 @@ void QApplicationPrivate::process_cmdline() // obsolete argument #ifndef QT_NO_STYLE_STYLESHEET } else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) { - styleSheet = QLatin1String("file:///"); + styleSheet = "file:///"_L1; styleSheet.append(QString::fromLocal8Bit(argv[++i])); } else if (strncmp(arg, "-stylesheet=", 12) == 0) { - styleSheet = QLatin1String("file:///"); + styleSheet = "file:///"_L1; styleSheet.append(QString::fromLocal8Bit(arg + 12)); #endif } else if (qstrcmp(arg, "-widgetcount") == 0) { @@ -475,9 +442,9 @@ void QApplicationPrivate::process_cmdline() #ifdef Q_QDOC QApplication::QApplication(int &argc, char **argv) #else -QApplication::QApplication(int &argc, char **argv, int _internal) +QApplication::QApplication(int &argc, char **argv, int) #endif - : QGuiApplication(*new QApplicationPrivate(argc, argv, _internal)) + : QGuiApplication(*new QApplicationPrivate(argc, argv)) { Q_D(QApplication); d->init(); @@ -496,7 +463,7 @@ void QApplicationPrivate::init() initResources(); - qt_is_gui_used = (application_type != QApplicationPrivate::Tty); + qt_is_tty_app = (application_type == QApplicationPrivate::Tty); process_cmdline(); // Must be called before initialize() @@ -508,7 +475,7 @@ void QApplicationPrivate::init() initialize(); eventDispatcher->startingUp(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) // factory for accessible interfaces for widgets shipped with Qt QAccessible::installFactory(&qAccessibleFactory); #endif @@ -548,7 +515,7 @@ void QApplicationPrivate::initialize() } else { qWarning("QApplication: invalid style override '%s' passed, ignoring it.\n" "\tAvailable styles: %s", qPrintable(styleOverride), - qPrintable(QStyleFactory::keys().join(QLatin1String(", ")))); + qPrintable(QStyleFactory::keys().join(", "_L1))); } } @@ -559,7 +526,7 @@ void QApplicationPrivate::initialize() if (qEnvironmentVariableIntValue("QT_USE_NATIVE_WINDOWS") > 0) QCoreApplication::setAttribute(Qt::AA_NativeWindows); - if (qt_is_gui_used) + if (!qt_is_tty_app) initializeMultitouch(); if (QGuiApplication::desktopSettingsAware()) @@ -719,7 +686,7 @@ QApplication::~QApplication() QApplicationPrivate::app_style = nullptr; #if QT_CONFIG(draganddrop) - if (qt_is_gui_used) + if (!qt_is_tty_app) delete QDragManager::self(); #endif @@ -1909,7 +1876,6 @@ QWidget *qt_tlw_for_window(QWindow *wnd) void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) { - Q_UNUSED(previous); #ifndef Q_OS_MACOS // Some delayed focus event to ignore, unless we are on cocoa where // popups can be opened via right-click on inactive applications @@ -1926,6 +1892,20 @@ void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) if (widget->inherits("QAxHostWidget")) widget->setFocus(Qt::ActiveWindowFocusReason); } + + // QApplication::setActiveWindow() will deliver window activation events for + // QWidgetWindows. But for other subclasses of QWindow (like QQuickWindow), we + // need to send them explicitly, like we do from the base class implementation. + if (previous && !qobject_cast<QWidgetWindow *>(previous)) { + QEvent de(QEvent::WindowDeactivate); + QCoreApplication::sendEvent(previous, &de); + } + + if (focusWindow && !qobject_cast<QWidgetWindow *>(focusWindow)) { + QEvent ae(QEvent::WindowActivate); + QCoreApplication::sendEvent(focusWindow, &ae); + } + // don't call base class to avoid double delivery of WindowActivate/Deactivate events } @@ -2015,9 +1995,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con if ((!enter && !leave) || (enter == leave)) return; -#ifdef ALIEN_DEBUG - qDebug() << "QApplicationPrivate::dispatchEnterLeave, ENTER:" << enter << "LEAVE:" << leave; -#endif + QWidgetList leaveList; QWidgetList enterList; @@ -2073,7 +2051,7 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { Q_ASSERT(instance()); - QHoverEvent he(QEvent::HoverLeave, QPoint(-1, -1), w->mapFromGlobal(QApplicationPrivate::instance()->hoverGlobalPos), + QHoverEvent he(QEvent::HoverLeave, QPointF(-1, -1), globalPosF, w->mapFromGlobal(globalPosF), QGuiApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } @@ -2081,19 +2059,19 @@ void QApplicationPrivate::dispatchEnterLeave(QWidget* enter, QWidget* leave, con } if (!enterList.isEmpty()) { // Guard against QGuiApplicationPrivate::lastCursorPosition initialized to qInf(), qInf(). - const QPoint globalPos = qIsInf(globalPosF.x()) - ? QPoint(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) - : globalPosF.toPoint(); - const QPoint windowPos = qAsConst(enterList).back()->window()->mapFromGlobal(globalPos); + const QPointF globalPos = qIsInf(globalPosF.x()) + ? QPointF(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX) + : globalPosF; + const QPointF windowPos = qAsConst(enterList).back()->window()->mapFromGlobal(globalPos); for (auto it = enterList.crbegin(), end = enterList.crend(); it != end; ++it) { auto *w = *it; if (!QApplication::activeModalWidget() || QApplicationPrivate::tryModalHelper(w, nullptr)) { const QPointF localPos = w->mapFromGlobal(globalPos); - QEnterEvent enterEvent(localPos, windowPos, globalPosF); + QEnterEvent enterEvent(localPos, windowPos, globalPos); QCoreApplication::sendEvent(w, &enterEvent); if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { - QHoverEvent he(QEvent::HoverEnter, localPos, QPoint(-1, -1), + QHoverEvent he(QEvent::HoverEnter, localPos, QPointF(-1, -1), globalPos, QGuiApplication::keyboardModifiers()); qApp->d_func()->notify_helper(w, &he); } @@ -2324,9 +2302,6 @@ QWidget *QApplicationPrivate::pickMouseReceiver(QWidget *candidate, const QPoint if (mouseGrabber && mouseGrabber != candidate) { receiver = mouseGrabber; *pos = receiver->mapFromGlobal(candidate->mapToGlobal(windowPos)); -#ifdef ALIEN_DEBUG - qDebug() << " ** receiver adjusted to:" << receiver << "pos:" << pos; -#endif } return receiver; @@ -2390,13 +2365,6 @@ bool QApplicationPrivate::sendMouseEvent(QWidget *receiver, QMouseEvent *event, } } -#ifdef ALIEN_DEBUG - qDebug() << "QApplicationPrivate::sendMouseEvent: receiver:" << receiver - << "pos:" << event->position() << "alien" << alienWidget << "button down" - << *buttonDown << "last" << lastMouseReceiver << "leave after release" - << leaveAfterRelease; -#endif - // We need this quard in case someone opens a modal dialog / popup. If that's the case // leaveAfterRelease is set to null, but we shall not update lastMouseReceiver. const bool wasLeaveAfterRelease = leaveAfterRelease != nullptr; @@ -2843,11 +2811,11 @@ bool QApplication::notify(QObject *receiver, QEvent *e) w = static_cast<QWidget *>(receiver); relpos = mouse->position().toPoint(); - QPoint diff = relpos - w->mapFromGlobal(d->hoverGlobalPos); + QPoint diff = relpos - w->mapFromGlobal(mouse->globalPosition().toPoint()); while (w) { if (w->testAttribute(Qt::WA_Hover) && (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == w->window())) { - QHoverEvent he(QEvent::HoverMove, relpos, relpos - diff, mouse->modifiers()); + QHoverEvent he(QEvent::HoverMove, relpos, mouse->globalPosition(), relpos - diff, mouse->modifiers()); d->notify_helper(w, &he); } if (w->isWindow() || w->testAttribute(Qt::WA_NoMousePropagation)) @@ -4029,9 +3997,9 @@ void QApplicationPrivate::translateTouchCancel(const QPointingDevice *device, ul } } -void QApplicationPrivate::notifyThemeChanged() +void QApplicationPrivate::handleThemeChanged() { - QGuiApplicationPrivate::notifyThemeChanged(); + QGuiApplicationPrivate::handleThemeChanged(); qt_init_tooltip_palette(); } diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 97e07bd17a..3f2ffe40dd 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QAPPLICATION_H #define QAPPLICATION_H diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 155081fd79..197e16afc6 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QAPPLICATION_P_H #define QAPPLICATION_P_H @@ -86,7 +50,7 @@ class QPointingDevice; class QGestureManager; #endif -extern Q_GUI_EXPORT bool qt_is_gui_used; +extern Q_GUI_EXPORT bool qt_is_tty_app; #ifndef QT_NO_CLIPBOARD extern QClipboard *qt_clipboard; #endif @@ -94,13 +58,11 @@ extern QClipboard *qt_clipboard; typedef QHash<QByteArray, QFont> FontHash; Q_WIDGETS_EXPORT FontHash *qt_app_fonts_hash(); -#define QApplicationPrivateBase QGuiApplicationPrivate - -class Q_WIDGETS_EXPORT QApplicationPrivate : public QApplicationPrivateBase +class Q_WIDGETS_EXPORT QApplicationPrivate : public QGuiApplicationPrivate { Q_DECLARE_PUBLIC(QApplication) public: - QApplicationPrivate(int &argc, char **argv, int flags); + QApplicationPrivate(int &argc, char **argv); ~QApplicationPrivate(); virtual void notifyLayoutDirectionChange() override; @@ -165,7 +127,7 @@ public: static QStyle *app_style; protected: - void notifyThemeChanged() override; + void handleThemeChanged() override; QPalette basePalette() const override; void handlePaletteChanged(const char *className = nullptr) override; diff --git a/src/widgets/kernel/qboxlayout.cpp b/src/widgets/kernel/qboxlayout.cpp index 28e7302b83..d16d903f53 100644 --- a/src/widgets/kernel/qboxlayout.cpp +++ b/src/widgets/kernel/qboxlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qapplication.h" #include "qboxlayout.h" @@ -124,6 +88,7 @@ public: void effectiveMargins(int *left, int *top, int *right, int *bottom) const; QLayoutItem* replaceAt(int index, QLayoutItem*) override; + int validateIndex(int index) const; }; QBoxLayoutPrivate::~QBoxLayoutPrivate() @@ -443,6 +408,14 @@ QLayoutItem* QBoxLayoutPrivate::replaceAt(int index, QLayoutItem *item) return r; } +int QBoxLayoutPrivate::validateIndex(int index) const +{ + if (index < 0) + return list.count(); // append + + Q_ASSERT_X(index >= 0 && index <= list.count(), "QBoxLayout::insert", "index out of range"); + return index; +} /*! \class QBoxLayout @@ -847,9 +820,7 @@ void QBoxLayout::addItem(QLayoutItem *item) void QBoxLayout::insertItem(int index, QLayoutItem *item) { Q_D(QBoxLayout); - if (index < 0) // append - index = d->list.count(); - + index = d->validateIndex(index); QBoxLayoutItem *it = new QBoxLayoutItem(item); d->list.insert(index, it); invalidate(); @@ -867,9 +838,7 @@ void QBoxLayout::insertItem(int index, QLayoutItem *item) void QBoxLayout::insertSpacing(int index, int size) { Q_D(QBoxLayout); - if (index < 0) // append - index = d->list.count(); - + index = d->validateIndex(index); QLayoutItem *b; if (horz(d->dir)) b = QLayoutPrivate::createSpacerItem(this, size, 0, QSizePolicy::Fixed, QSizePolicy::Minimum); @@ -892,9 +861,7 @@ void QBoxLayout::insertSpacing(int index, int size) void QBoxLayout::insertStretch(int index, int stretch) { Q_D(QBoxLayout); - if (index < 0) // append - index = d->list.count(); - + index = d->validateIndex(index); QLayoutItem *b; if (horz(d->dir)) b = QLayoutPrivate::createSpacerItem(this, 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum); @@ -919,9 +886,7 @@ void QBoxLayout::insertStretch(int index, int stretch) void QBoxLayout::insertSpacerItem(int index, QSpacerItem *spacerItem) { Q_D(QBoxLayout); - if (index < 0) // append - index = d->list.count(); - + index = d->validateIndex(index); QBoxLayoutItem *it = new QBoxLayoutItem(spacerItem); it->magic = true; d->list.insert(index, it); @@ -943,8 +908,7 @@ void QBoxLayout::insertLayout(int index, QLayout *layout, int stretch) return; if (!adoptLayout(layout)) return; - if (index < 0) // append - index = d->list.count(); + index = d->validateIndex(index); QBoxLayoutItem *it = new QBoxLayoutItem(layout, stretch); d->list.insert(index, it); invalidate(); @@ -977,8 +941,7 @@ void QBoxLayout::insertWidget(int index, QWidget *widget, int stretch, if (!d->checkWidget(widget)) return; addChildWidget(widget); - if (index < 0) // append - index = d->list.count(); + index = d->validateIndex(index); QWidgetItem *b = QLayoutPrivate::createWidgetItem(this, widget); b->setAlignment(alignment); diff --git a/src/widgets/kernel/qboxlayout.h b/src/widgets/kernel/qboxlayout.h index ab0b2267f0..a1adb2809b 100644 --- a/src/widgets/kernel/qboxlayout.h +++ b/src/widgets/kernel/qboxlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QBOXLAYOUT_H #define QBOXLAYOUT_H diff --git a/src/widgets/kernel/qformlayout.cpp b/src/widgets/kernel/qformlayout.cpp index 8c3d3448ca..fdce766c93 100644 --- a/src/widgets/kernel/qformlayout.cpp +++ b/src/widgets/kernel/qformlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qapplication.h" #include "qdebug.h" @@ -110,7 +74,7 @@ enum { ColumnCount = 2 }; // This owns the QLayoutItem struct QFormLayoutItem { - QFormLayoutItem(QLayoutItem* i) : item(i), fullRow(false), isHfw(false) { } + QFormLayoutItem(QLayoutItem* i) : item(i) { } ~QFormLayoutItem() { delete item; } // Wrappers @@ -127,31 +91,62 @@ struct QFormLayoutItem void setGeometry(const QRect& r) { item->setGeometry(r); } QRect geometry() const { return item->geometry(); } + void setVisible(bool on); + bool isHidden() const { return !isVisible || (widget() && widget()->isHidden()); } + // For use with FixedColumnMatrix bool operator==(const QFormLayoutItem& other) { return item == other.item; } - QLayoutItem *item; - bool fullRow; + QLayoutItem *item = nullptr; + bool fullRow = false; + bool isVisible = true; // set by updateSizes - bool isHfw; + bool isHfw = false; QSize minSize; QSize sizeHint; QSize maxSize; // also set by updateSizes - int sbsHSpace; // only used for side by side, for the field item only (not label) - int vSpace; // This is the spacing to the item in the row above + int sbsHSpace = -1; // only used for side by side, for the field item only (not label) + int vSpace = -1; // This is the spacing to the item in the row above // set by setupVerticalLayoutData - bool sideBySide; - int vLayoutIndex; + bool sideBySide = false; + int vLayoutIndex = -1; // set by setupHorizontalLayoutData - int layoutPos; - int layoutWidth; + int layoutPos = -1; + int layoutWidth = -1; }; +static void hideOrShowWidgetsInLayout(QLayout *layout, bool on) +{ + for (int i = 0; i < layout->count(); ++i) { + QLayoutItem *item = layout->itemAt(i); + if (QWidget *widget = item->widget()) + widget->setVisible(on); + else if (item->layout()) + hideOrShowWidgetsInLayout(item->layout(), on); + } +} + +void QFormLayoutItem::setVisible(bool on) +{ + isVisible = on; + // Explicitly hide the widget so that it loses focus and + // doesn't automatically get shown again when this layout + // hides and shows. + if (widget()) { + widget()->setVisible(on); + return; + } + // Layouts can't be hidden, so we have to traverse the widgets + // inside and hide all of them so that they also lose focus. + if (layout()) + hideOrShowWidgetsInLayout(layout(), on); +} + class QFormLayoutPrivate : public QLayoutPrivate { Q_DECLARE_PUBLIC(QFormLayout) @@ -378,23 +373,25 @@ void QFormLayoutPrivate::updateSizes() QSizePolicy::ControlTypes(fldtop ? fldtop->controlTypes() : QSizePolicy::DefaultType); // To be compatible to QGridLayout, we have to compare solitary labels & fields with both predecessors - if (label) { + if (label && !label->isHidden()) { if (!field) { int lblspacing = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); int fldspacing = style->combinedLayoutSpacing(fldtoptypes, lbltypes, Qt::Vertical, nullptr, parent); label->vSpace = qMax(lblspacing, fldspacing); - } else + } else { label->vSpace = style->combinedLayoutSpacing(lbltoptypes, lbltypes, Qt::Vertical, nullptr, parent); + } } - if (field) { + if (field && !field->isHidden()) { // check spacing against both the previous label and field if (!label) { int lblspacing = style->combinedLayoutSpacing(lbltoptypes, fldtypes, Qt::Vertical, nullptr, parent); int fldspacing = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); field->vSpace = qMax(lblspacing, fldspacing); - } else + } else { field->vSpace = style->combinedLayoutSpacing(fldtoptypes, fldtypes, Qt::Vertical, nullptr, parent); + } } } } @@ -507,7 +504,7 @@ void QFormLayoutPrivate::setupHfwLayoutData() QFormLayoutItem *label = m_matrix(i, 0); QFormLayoutItem *field = m_matrix(i, 1); - if (label) { + if (label && label->vLayoutIndex > -1) { if (label->isHfw) { // We don't check sideBySide here, since a label is only // ever side by side with its field @@ -522,7 +519,7 @@ void QFormLayoutPrivate::setupHfwLayoutData() } } - if (field) { + if (field && field->vLayoutIndex > -1) { int hfw = field->isHfw ? field->heightForWidth(field->layoutWidth) : 0; int h = field->isHfw ? hfw : field->sizeHint.height(); int mh = field->isHfw ? hfw : field->minSize.height(); @@ -681,11 +678,11 @@ void QFormLayoutPrivate::setupVerticalLayoutData(int width) bool prevRowSplit = false; for (int i = 0; i < rr; ++i) { - QFormLayoutItem *label = m_matrix(i, 0); + QFormLayoutItem *label = m_matrix(i, 0); QFormLayoutItem *field = m_matrix(i, 1); - // Totally ignore empty rows... - if (!label && !field) + // Totally ignore empty rows or rows with only hidden items + if (!q->isRowVisible(i)) continue; QSize min1; @@ -2193,7 +2190,7 @@ void QFormLayoutPrivate::arrangeWidgets(const QList<QLayoutStruct> &layouts, QRe QFormLayoutItem *label = m_matrix(i, 0); QFormLayoutItem *field = m_matrix(i, 1); - if (label) { + if (label && label->vLayoutIndex > -1) { int height = layouts.at(label->vLayoutIndex).size; if ((label->expandingDirections() & Qt::Vertical) == 0) { /* @@ -2220,7 +2217,7 @@ void QFormLayoutPrivate::arrangeWidgets(const QList<QLayoutStruct> &layouts, QRe label->setGeometry(QStyle::visualRect(layoutDirection, rect, QRect(p, sz))); } - if (field) { + if (field && field->vLayoutIndex > -1) { QSize sz(field->layoutWidth, layouts.at(field->vLayoutIndex).size); QPoint p(field->layoutPos + leftOffset + rect.x(), layouts.at(field->vLayoutIndex).pos); /* @@ -2300,6 +2297,158 @@ void QFormLayout::setItem(int row, ItemRole role, QLayoutItem *item) } /*! + \since 6.4 + + Shows the row \a row if \a on is true, otherwise hides the row. + + \a row must be non-negative and less than rowCount(). + + \sa removeRow(), takeRow() +*/ +void QFormLayout::setRowVisible(int row, bool on) +{ + Q_D(QFormLayout); + QFormLayoutItem *label = d->m_matrix(row, 0); + QFormLayoutItem *field = d->m_matrix(row, 1); + bool change = false; + if (label) { + change = label->isVisible != on; + label->setVisible(on); + } + if (field) { + change |= field->isVisible != on; + field->setVisible(on); + } + if (change) + invalidate(); +} + +/*! + \since 6.4 + + \overload + + Shows the row corresponding to \a widget if \a on is true, + otherwise hides the row. + + \sa removeRow(), takeRow() +*/ +void QFormLayout::setRowVisible(QWidget *widget, bool on) +{ + Q_D(QFormLayout); + if (Q_UNLIKELY(!d->checkWidget(widget))) + return; + + int row; + ItemRole role; + getWidgetPosition(widget, &row, &role); + + if (Q_UNLIKELY(row < 0)) { + qWarning("QFormLayout::setRowVisible: Invalid widget"); + return; + } + + setRowVisible(row, on); +} + +/*! + \since 6.4 + + \overload + + Shows the row corresponding to \a layout if \a on is true, + otherwise hides the row. + + \sa removeRow(), takeRow() +*/ +void QFormLayout::setRowVisible(QLayout *layout, bool on) +{ + Q_D(QFormLayout); + if (Q_UNLIKELY(!d->checkLayout(layout))) + return; + + int row; + ItemRole role; + getLayoutPosition(layout, &row, &role); + + if (Q_UNLIKELY(row < 0)) { + qWarning("QFormLayout::setRowVisible: Invalid layout"); + return; + } + + setRowVisible(row, on); +} + +/*! + \since 6.4 + + Returns true if some items in the row \a row are visible, + otherwise returns false. +*/ +bool QFormLayout::isRowVisible(int row) const +{ + Q_D(const QFormLayout); + QFormLayoutItem *label = d->m_matrix(row, 0); + QFormLayoutItem *field = d->m_matrix(row, 1); + + int visibleItemCount = 2; + if (!label || label->isHidden() || (label->widget() && label->widget()->isHidden())) + --visibleItemCount; + if (!field || field->isHidden() || (field->widget() && field->widget()->isHidden())) + --visibleItemCount; + + return visibleItemCount > 0; +} + +/*! + \since 6.4 + \overload + + Returns true if some items in the row corresponding to \a widget + are visible, otherwise returns false. +*/ +bool QFormLayout::isRowVisible(QWidget *widget) const +{ + Q_D(const QFormLayout); + if (Q_UNLIKELY(!d->checkWidget(widget))) + return false; + int row; + ItemRole role; + getWidgetPosition(widget, &row, &role); + + if (Q_UNLIKELY(row < 0)) { + qWarning("QFormLayout::takeRow: Invalid widget"); + return false; + } + + return isRowVisible(row); +} + +/*! + \since 6.4 + \overload + + Returns true if some items in the row corresponding to \a layout + are visible, otherwise returns false. +*/ +bool QFormLayout::isRowVisible(QLayout *layout) const +{ + Q_D(const QFormLayout); + if (Q_UNLIKELY(!d->checkLayout(layout))) + return false; + int row; + ItemRole role; + getLayoutPosition(layout, &row, &role); + + if (Q_UNLIKELY(row < 0)) { + qWarning("QFormLayout::takeRow: Invalid layout"); + return false; + } + + return isRowVisible(row); +} + +/*! \internal */ diff --git a/src/widgets/kernel/qformlayout.h b/src/widgets/kernel/qformlayout.h index c716a963e5..b24fe131a0 100644 --- a/src/widgets/kernel/qformlayout.h +++ b/src/widgets/kernel/qformlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QFORMLAYOUT_H #define QFORMLAYOUT_H @@ -138,6 +102,14 @@ public: void setWidget(int row, ItemRole role, QWidget *widget); void setLayout(int row, ItemRole role, QLayout *layout); + void setRowVisible(int row, bool on); + void setRowVisible(QWidget *widget, bool on); + void setRowVisible(QLayout *layout, bool on); + + bool isRowVisible(int row) const; + bool isRowVisible(QWidget *widget) const; + bool isRowVisible(QLayout *layout) const; + QLayoutItem *itemAt(int row, ItemRole role) const; void getItemPosition(int index, int *rowPtr, ItemRole *rolePtr) const; void getWidgetPosition(QWidget *widget, int *rowPtr, ItemRole *rolePtr) const; diff --git a/src/widgets/kernel/qgesture.cpp b/src/widgets/kernel/qgesture.cpp index bde5484771..82b4d9ced8 100644 --- a/src/widgets/kernel/qgesture.cpp +++ b/src/widgets/kernel/qgesture.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qgesture.h" #include "private/qgesture_p.h" @@ -49,6 +13,13 @@ QT_BEGIN_NAMESPACE +QT_IMPL_METATYPE_EXTERN_TAGGED(Qt::GestureState, Qt__GestureState) +QT_IMPL_METATYPE_EXTERN_TAGGED(Qt::GestureType, Qt__GestureType) +QT_IMPL_METATYPE_EXTERN_TAGGED(QPinchGesture::ChangeFlags, + QPinchGesture__ChangeFlags) +QT_IMPL_METATYPE_EXTERN_TAGGED(QGesture::GestureCancelPolicy, + QGesture__GestureCancelPolicy) + /*! \class QGesture \since 4.6 diff --git a/src/widgets/kernel/qgesture.h b/src/widgets/kernel/qgesture.h index 312962f9bf..7e7041ef76 100644 --- a/src/widgets/kernel/qgesture.h +++ b/src/widgets/kernel/qgesture.h @@ -1,47 +1,12 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGESTURE_H #define QGESTURE_H #include <QtWidgets/qtwidgetsglobal.h> #include <QtCore/qobject.h> +#include <QtCore/qmap.h> #include <QtCore/qlist.h> #include <QtCore/qdatetime.h> #include <QtCore/qpoint.h> @@ -51,8 +16,10 @@ #ifndef QT_NO_GESTURES -Q_DECLARE_METATYPE(Qt::GestureState) -Q_DECLARE_METATYPE(Qt::GestureType) +// ### move to qnamespace.h +QT_DECL_METATYPE_EXTERN_TAGGED(Qt::GestureState, Qt__GestureState, Q_WIDGETS_EXPORT) +// ### move to qnamespace.h +QT_DECL_METATYPE_EXTERN_TAGGED(Qt::GestureType, Qt__GestureType, Q_WIDGETS_EXPORT) QT_BEGIN_NAMESPACE @@ -143,7 +110,7 @@ public: RotationAngleChanged = 0x2, CenterPointChanged = 0x4 }; - Q_FLAG(ChangeFlag) + Q_ENUM(ChangeFlag) Q_DECLARE_FLAGS(ChangeFlags, ChangeFlag) Q_FLAG(ChangeFlags) @@ -200,7 +167,8 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QPinchGesture::ChangeFlags) QT_END_NAMESPACE -Q_DECLARE_METATYPE(QPinchGesture::ChangeFlags) +QT_DECL_METATYPE_EXTERN_TAGGED(QPinchGesture::ChangeFlags, + QPinchGesture__ChangeFlags, Q_WIDGETS_EXPORT) QT_BEGIN_NAMESPACE @@ -323,7 +291,9 @@ Q_WIDGETS_EXPORT QDebug operator<<(QDebug, const QGestureEvent *); QT_END_NAMESPACE -Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy) +QT_DECL_METATYPE_EXTERN_TAGGED(QGesture::GestureCancelPolicy, + QGesture__GestureCancelPolicy, Q_WIDGETS_EXPORT) + #endif // QT_NO_GESTURES #endif // QGESTURE_H diff --git a/src/widgets/kernel/qgesture_p.h b/src/widgets/kernel/qgesture_p.h index 057302bda1..1e4292abf9 100644 --- a/src/widgets/kernel/qgesture_p.h +++ b/src/widgets/kernel/qgesture_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGESTURE_P_H #define QGESTURE_P_H diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index b725485948..0108e01e5f 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "private/qgesturemanager_p.h" #include "private/qstandardgestures_p.h" @@ -57,6 +21,7 @@ #include "qdebug.h" #include <QtCore/QLoggingCategory> +#include <QtCore/QVarLengthArray> #ifndef QT_NO_GESTURES diff --git a/src/widgets/kernel/qgesturemanager_p.h b/src/widgets/kernel/qgesturemanager_p.h index 3a5c9822eb..1bf1358b13 100644 --- a/src/widgets/kernel/qgesturemanager_p.h +++ b/src/widgets/kernel/qgesturemanager_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGESTUREMANAGER_P_H #define QGESTUREMANAGER_P_H diff --git a/src/widgets/kernel/qgesturerecognizer.cpp b/src/widgets/kernel/qgesturerecognizer.cpp index 75d091ce4e..50c394e9b0 100644 --- a/src/widgets/kernel/qgesturerecognizer.cpp +++ b/src/widgets/kernel/qgesturerecognizer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qgesturerecognizer.h" diff --git a/src/widgets/kernel/qgesturerecognizer.h b/src/widgets/kernel/qgesturerecognizer.h index 04e85c46cc..de48fec399 100644 --- a/src/widgets/kernel/qgesturerecognizer.h +++ b/src/widgets/kernel/qgesturerecognizer.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGESTURERECOGNIZER_H #define QGESTURERECOGNIZER_H diff --git a/src/widgets/kernel/qgridlayout.cpp b/src/widgets/kernel/qgridlayout.cpp index 336a68cd80..c3fb7d6993 100644 --- a/src/widgets/kernel/qgridlayout.cpp +++ b/src/widgets/kernel/qgridlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qapplication.h" #include "qgridlayout.h" diff --git a/src/widgets/kernel/qgridlayout.h b/src/widgets/kernel/qgridlayout.h index 1107d850eb..bb4887e2fd 100644 --- a/src/widgets/kernel/qgridlayout.h +++ b/src/widgets/kernel/qgridlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QGRIDLAYOUT_H #define QGRIDLAYOUT_H diff --git a/src/widgets/kernel/qlayout.cpp b/src/widgets/kernel/qlayout.cpp index 2867bd9fb1..7639803c8b 100644 --- a/src/widgets/kernel/qlayout.cpp +++ b/src/widgets/kernel/qlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qlayout.h" @@ -745,24 +709,24 @@ QLayout::~QLayout() /*! This function is called from \c addLayout() or \c insertLayout() functions in - subclasses to add layout \a l as a sub-layout. + subclasses to add layout \a childLayout as a sub-layout. The only scenario in which you need to call it directly is if you implement a custom layout that supports nested layouts. \sa QBoxLayout::addLayout(), QBoxLayout::insertLayout(), QGridLayout::addLayout() */ -void QLayout::addChildLayout(QLayout *l) +void QLayout::addChildLayout(QLayout *childLayout) { - if (Q_UNLIKELY(l->parent())) { - qWarning("QLayout::addChildLayout: layout \"%ls\" already has a parent", - qUtf16Printable(l->objectName())); + if (Q_UNLIKELY(childLayout->parent())) { + qWarning("QLayout::addChildLayout: layout %s \"%ls\" already has a parent", + childLayout->metaObject()->className(), qUtf16Printable(childLayout->objectName())); return; } - l->setParent(this); + childLayout->setParent(this); if (QWidget *mw = parentWidget()) { - l->d_func()->reparentChildWidgets(mw); + childLayout->d_func()->reparentChildWidgets(mw); } } @@ -865,9 +829,10 @@ bool QLayoutPrivate::checkLayout(QLayout *otherLayout) const This function is called from \c addWidget() functions in subclasses to add \a w as a managed widget of a layout. - If \a w is already managed by a layout, this function will give a warning - and remove \a w from that layout. This function must therefore be - called before adding \a w to the layout's data structure. + If \a w is already managed by a layout, this function will produce + a warning, and remove \a w from that layout. This function must + therefore be called before adding \a w to the layout's data + structure. */ void QLayout::addChildWidget(QWidget *w) { diff --git a/src/widgets/kernel/qlayout.h b/src/widgets/kernel/qlayout.h index d37caeef25..ee7b5e047c 100644 --- a/src/widgets/kernel/qlayout.h +++ b/src/widgets/kernel/qlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLAYOUT_H #define QLAYOUT_H diff --git a/src/widgets/kernel/qlayout_p.h b/src/widgets/kernel/qlayout_p.h index 437ab84fc3..cd40a98fb7 100644 --- a/src/widgets/kernel/qlayout_p.h +++ b/src/widgets/kernel/qlayout_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLAYOUT_P_H #define QLAYOUT_P_H diff --git a/src/widgets/kernel/qlayoutengine.cpp b/src/widgets/kernel/qlayoutengine.cpp index e318300f98..576678ad0a 100644 --- a/src/widgets/kernel/qlayoutengine.cpp +++ b/src/widgets/kernel/qlayoutengine.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qlayout.h" #include "private/qlayoutengine_p.h" diff --git a/src/widgets/kernel/qlayoutengine_p.h b/src/widgets/kernel/qlayoutengine_p.h index 4eefb36c68..ff7b4107e1 100644 --- a/src/widgets/kernel/qlayoutengine_p.h +++ b/src/widgets/kernel/qlayoutengine_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLAYOUTENGINE_P_H #define QLAYOUTENGINE_P_H diff --git a/src/widgets/kernel/qlayoutitem.cpp b/src/widgets/kernel/qlayoutitem.cpp index b241821c82..eb53a3a120 100644 --- a/src/widgets/kernel/qlayoutitem.cpp +++ b/src/widgets/kernel/qlayoutitem.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qlayout.h" diff --git a/src/widgets/kernel/qlayoutitem.h b/src/widgets/kernel/qlayoutitem.h index ba11976f06..531498ea4b 100644 --- a/src/widgets/kernel/qlayoutitem.h +++ b/src/widgets/kernel/qlayoutitem.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QLAYOUTITEM_H #define QLAYOUTITEM_H diff --git a/src/widgets/kernel/qmacgesturerecognizer.cpp b/src/widgets/kernel/qmacgesturerecognizer.cpp index 8e18132df8..8149bea30d 100644 --- a/src/widgets/kernel/qmacgesturerecognizer.cpp +++ b/src/widgets/kernel/qmacgesturerecognizer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qmacgesturerecognizer_p.h" #include "qgesture.h" diff --git a/src/widgets/kernel/qmacgesturerecognizer_p.h b/src/widgets/kernel/qmacgesturerecognizer_p.h index 739fc201b7..5c559c6cb9 100644 --- a/src/widgets/kernel/qmacgesturerecognizer_p.h +++ b/src/widgets/kernel/qmacgesturerecognizer_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QMACSWIPEGESTURERECOGNIZER_MAC_P_H #define QMACSWIPEGESTURERECOGNIZER_MAC_P_H diff --git a/src/widgets/kernel/qshortcut.h b/src/widgets/kernel/qshortcut.h index c09cf23ca4..6cec8d45ea 100644 --- a/src/widgets/kernel/qshortcut.h +++ b/src/widgets/kernel/qshortcut.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtGui/QShortcut> diff --git a/src/widgets/kernel/qshortcut_widgets.cpp b/src/widgets/kernel/qshortcut_widgets.cpp index 8beb4ce5d6..968cc898d7 100644 --- a/src/widgets/kernel/qshortcut_widgets.cpp +++ b/src/widgets/kernel/qshortcut_widgets.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qshortcut.h" #include "private/qshortcut_p.h" diff --git a/src/widgets/kernel/qsizepolicy.cpp b/src/widgets/kernel/qsizepolicy.cpp index fe34ef5982..b883c1ed6f 100644 --- a/src/widgets/kernel/qsizepolicy.cpp +++ b/src/widgets/kernel/qsizepolicy.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qsizepolicy.h" diff --git a/src/widgets/kernel/qsizepolicy.h b/src/widgets/kernel/qsizepolicy.h index 53c7afc906..af964bf6af 100644 --- a/src/widgets/kernel/qsizepolicy.h +++ b/src/widgets/kernel/qsizepolicy.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSIZEPOLICY_H #define QSIZEPOLICY_H @@ -198,6 +162,7 @@ private: Q_DECLARE_TYPEINFO(QSizePolicy, Q_PRIMITIVE_TYPE); Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes) +Q_DECLARE_MIXED_ENUM_OPERATORS(int, QSizePolicy::Policy, QSizePolicy::PolicyFlag) #ifndef QT_NO_DATASTREAM Q_WIDGETS_EXPORT QDataStream &operator<<(QDataStream &, const QSizePolicy &); diff --git a/src/widgets/kernel/qstackedlayout.cpp b/src/widgets/kernel/qstackedlayout.cpp index 2f3d6f39cb..78177aa0cd 100644 --- a/src/widgets/kernel/qstackedlayout.cpp +++ b/src/widgets/kernel/qstackedlayout.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qstackedlayout.h" #include "qlayout_p.h" diff --git a/src/widgets/kernel/qstackedlayout.h b/src/widgets/kernel/qstackedlayout.h index 966ee2aae4..91d7d1e9f5 100644 --- a/src/widgets/kernel/qstackedlayout.h +++ b/src/widgets/kernel/qstackedlayout.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSTACKEDLAYOUT_H #define QSTACKEDLAYOUT_H diff --git a/src/widgets/kernel/qstandardgestures.cpp b/src/widgets/kernel/qstandardgestures.cpp index 32faa7d1d4..4effc1a2d1 100644 --- a/src/widgets/kernel/qstandardgestures.cpp +++ b/src/widgets/kernel/qstandardgestures.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qstandardgestures_p.h" #include "qgesture.h" diff --git a/src/widgets/kernel/qstandardgestures_p.h b/src/widgets/kernel/qstandardgestures_p.h index 6de09361fe..ef1c1cb97c 100644 --- a/src/widgets/kernel/qstandardgestures_p.h +++ b/src/widgets/kernel/qstandardgestures_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSTANDARDGESTURES_P_H #define QSTANDARDGESTURES_P_H diff --git a/src/widgets/kernel/qt_widgets_pch.h b/src/widgets/kernel/qt_widgets_pch.h index 954e50f7a3..213e2c23e0 100644 --- a/src/widgets/kernel/qt_widgets_pch.h +++ b/src/widgets/kernel/qt_widgets_pch.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only /* * This is a precompiled header file for use in Xcode / Mac GCC / diff --git a/src/widgets/kernel/qtestsupport_widgets.cpp b/src/widgets/kernel/qtestsupport_widgets.cpp index acc69d098c..490a40d431 100644 --- a/src/widgets/kernel/qtestsupport_widgets.cpp +++ b/src/widgets/kernel/qtestsupport_widgets.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qtestsupport_widgets.h" @@ -47,9 +11,24 @@ #include <QtGui/qtestsupport_gui.h> #include <QtGui/private/qevent_p.h> #include <QtGui/private/qeventpoint_p.h> +#include <private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> QT_BEGIN_NAMESPACE +template <typename FunctorWindowGetter, typename FunctorPredicate> +static bool qWaitForWidgetWindow(FunctorWindowGetter windowGetter, FunctorPredicate predicate, int timeout) +{ + if (!windowGetter()) + return false; + + return QTest::qWaitFor([&]() { + if (QWindow *window = windowGetter()) + return predicate(window); + return false; + }, timeout); +} + /*! \since 5.0 @@ -61,9 +40,17 @@ QT_BEGIN_NAMESPACE */ Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout) { - if (QWindow *window = widget->window()->windowHandle()) - return QTest::qWaitForWindowActive(window, timeout); - return false; + if (Q_UNLIKELY(!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))) { + qWarning() << "qWaitForWindowActive was called on a platform that doesn't support window" + << "activation. This means there is an error in the test and it should either" + << "check for the WindowActivation platform capability before calling" + << "qWaitForWindowActivate, use qWaitForWindowExposed instead, or skip the test." + << "Falling back to qWaitForWindowExposed."; + return qWaitForWindowExposed(widget, timeout); + } + return qWaitForWidgetWindow([&]() { return widget->window()->windowHandle(); }, + [&](QWindow *window) { return window->isActive(); }, + timeout); } /*! @@ -86,9 +73,9 @@ Q_WIDGETS_EXPORT bool QTest::qWaitForWindowActive(QWidget *widget, int timeout) */ Q_WIDGETS_EXPORT bool QTest::qWaitForWindowExposed(QWidget *widget, int timeout) { - if (QWindow *window = widget->window()->windowHandle()) - return QTest::qWaitForWindowExposed(window, timeout); - return false; + return qWaitForWidgetWindow([&]() { return widget->window()->windowHandle(); }, + [&](QWindow *window) { return window->isExposed(); }, + timeout); } namespace QTest { diff --git a/src/widgets/kernel/qtestsupport_widgets.h b/src/widgets/kernel/qtestsupport_widgets.h index b375b7264b..54784b25e1 100644 --- a/src/widgets/kernel/qtestsupport_widgets.h +++ b/src/widgets/kernel/qtestsupport_widgets.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtTest module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTESTSUPPORT_WIDGETS_H #define QTESTSUPPORT_WIDGETS_H diff --git a/src/widgets/kernel/qtooltip.cpp b/src/widgets/kernel/qtooltip.cpp index 49de9e0c6a..b831c5265a 100644 --- a/src/widgets/kernel/qtooltip.cpp +++ b/src/widgets/kernel/qtooltip.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include <QtWidgets/private/qtwidgetsglobal_p.h> @@ -62,6 +26,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + /*! \class QToolTip @@ -147,7 +113,7 @@ protected: #ifndef QT_NO_STYLE_STYLESHEET public slots: /** \internal - Cleanup the _q_stylesheet_parent propery. + Cleanup the _q_stylesheet_parent property. */ void styleSheetParentDestroyed() { setProperty("_q_stylesheet_parent", QVariant()); @@ -372,7 +338,7 @@ void QTipLabel::placeTip(const QPoint &pos, QWidget *w) //the stylesheet need to know the real parent QTipLabel::instance->setProperty("_q_stylesheet_parent", QVariant::fromValue(w)); //we force the style to be the QStyleSheetStyle, and force to clear the cache as well. - QTipLabel::instance->setStyleSheet(QLatin1String("/* */")); + QTipLabel::instance->setStyleSheet("/* */"_L1); // Set up for cleaning up this later... QTipLabel::instance->styleSheetParent = w; @@ -492,7 +458,7 @@ void QToolTip::showText(const QPoint &pos, const QString &text, QWidget *w, cons QWidgetPrivate::get(QTipLabel::instance)->setScreen(QTipLabel::getTipScreen(pos, w)); QTipLabel::instance->setTipRect(w, rect); QTipLabel::instance->placeTip(pos, w); - QTipLabel::instance->setObjectName(QLatin1String("qtooltip_label")); + QTipLabel::instance->setObjectName("qtooltip_label"_L1); #if QT_CONFIG(effects) if (QApplication::isEffectEnabled(Qt::UI_FadeTooltip)) diff --git a/src/widgets/kernel/qtooltip.h b/src/widgets/kernel/qtooltip.h index c78e4c3251..863162e15b 100644 --- a/src/widgets/kernel/qtooltip.h +++ b/src/widgets/kernel/qtooltip.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTOOLTIP_H #define QTOOLTIP_H diff --git a/src/widgets/kernel/qtwidgetsglobal.h b/src/widgets/kernel/qtwidgetsglobal.h index 4b990c6e2a..bfa7272f19 100644 --- a/src/widgets/kernel/qtwidgetsglobal.h +++ b/src/widgets/kernel/qtwidgetsglobal.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTWIDGETSGLOBAL_H #define QTWIDGETSGLOBAL_H diff --git a/src/widgets/kernel/qtwidgetsglobal_p.h b/src/widgets/kernel/qtwidgetsglobal_p.h index 22ba876022..535071891e 100644 --- a/src/widgets/kernel/qtwidgetsglobal_p.h +++ b/src/widgets/kernel/qtwidgetsglobal_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QTWIDGETSGLOBAL_P_H #define QTWIDGETSGLOBAL_P_H diff --git a/src/widgets/kernel/qwhatsthis.cpp b/src/widgets/kernel/qwhatsthis.cpp index d264dfc4b2..9f8656b3fb 100644 --- a/src/widgets/kernel/qwhatsthis.cpp +++ b/src/widgets/kernel/qwhatsthis.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwhatsthis.h" #include "qpointer.h" @@ -56,7 +20,7 @@ #include <qpa/qplatformtheme.h> #include "private/qtextdocumentlayout_p.h" #include "qdebug.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include "qaccessible.h" #endif @@ -402,7 +366,7 @@ QWhatsThisPrivate::QWhatsThisPrivate() QGuiApplication::setOverrideCursor(Qt::WhatsThisCursor); #endif } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleEvent event(this, QAccessible::ContextHelpStart); QAccessible::updateAccessibility(&event); #endif @@ -417,7 +381,7 @@ QWhatsThisPrivate::~QWhatsThisPrivate() #ifndef QT_NO_CURSOR QGuiApplication::restoreOverrideCursor(); #endif -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleEvent event(this, QAccessible::ContextHelpEnd); QAccessible::updateAccessibility(&event); #endif diff --git a/src/widgets/kernel/qwhatsthis.h b/src/widgets/kernel/qwhatsthis.h index fa5b97d98a..0ab32d8bd6 100644 --- a/src/widgets/kernel/qwhatsthis.h +++ b/src/widgets/kernel/qwhatsthis.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWHATSTHIS_H #define QWHATSTHIS_H diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 80dcadb81f..1160471194 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Intel Corporation. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2016 Intel Corporation. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qapplication.h" #include "qapplication_p.h" @@ -57,7 +21,7 @@ #include "qwidget.h" #include "qstyleoption.h" #include "qstylehints.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) # include "qaccessible.h" #endif #include <qpa/qplatformwindow.h> @@ -77,9 +41,6 @@ #include "qscopeguard.h" #include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/qinputmethod.h> -#include <QtGui/qopenglcontext.h> -#include <QtGui/private/qopenglcontext_p.h> -#include <QtGui/qoffscreensurface.h> #if QT_CONFIG(graphicseffect) #include <private/qgraphicseffect_p.h> @@ -113,13 +74,12 @@ #include "qwindowcontainer_p.h" -// widget/widget data creation count -//#define QWIDGET_EXTRA_DEBUG -//#define ALIEN_DEBUG +#include <sstream> QT_BEGIN_NAMESPACE using namespace QNativeInterface::Private; +using namespace Qt::StringLiterals; Q_LOGGING_CATEGORY(lcWidgetPainting, "qt.widgets.painting", QtWarningMsg); @@ -178,10 +138,8 @@ QWidgetPrivate::QWidgetPrivate(int version) #ifndef QT_NO_IM , inheritsInputMethodHints(0) #endif -#ifndef QT_NO_OPENGL , renderToTextureReallyDirty(1) - , renderToTextureComposeActive(0) -#endif + , usesRhiFlush(0) , childrenHiddenByWState(0) , childrenShownByExpose(0) #if defined(Q_OS_WIN) @@ -1114,6 +1072,47 @@ QScreen *QWidgetPrivate::associatedScreen() const return nullptr; } +// finds the first rhiconfig in the hierarchy that has enable==true +static bool q_evaluateRhiConfigRecursive(const QWidget *w, QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType) +{ + QPlatformBackingStoreRhiConfig config = QWidgetPrivate::get(w)->rhiConfig(); + if (config.isEnabled()) { + if (outConfig) + *outConfig = config; + if (outType) + *outType = QBackingStoreRhiSupport::surfaceTypeForConfig(config); + return true; + } + QObjectList children = w->children(); + for (int i = 0; i < children.size(); i++) { + if (children.at(i)->isWidgetType()) { + const QWidget *childWidget = qobject_cast<const QWidget *>(children.at(i)); + if (childWidget) { + if (q_evaluateRhiConfigRecursive(childWidget, outConfig, outType)) + return true; + } + } + } + return false; +} + +// First tries q_evaluateRhiConfigRecursive, then if that did not indicate that rhi is wanted, +// then checks env.vars or something else to see if we need to force using rhi-based composition. +bool q_evaluateRhiConfig(const QWidget *w, QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType) +{ + if (q_evaluateRhiConfigRecursive(w, outConfig, outType)) { + qCDebug(lcWidgetPainting) << "Tree with root" << w << "evaluates to flushing with QRhi"; + return true; + } + + if (QBackingStoreRhiSupport::checkForceRhi(outConfig, outType)) { + qCDebug(lcWidgetPainting) << "Tree with root" << w << "evaluated to forced flushing with QRhi"; + return true; + } + + return false; +} + // ### fixme: Qt 6: Remove parameter window from QWidget::create() /*! @@ -1174,11 +1173,6 @@ void QWidget::create(WId window, bool initializeWindow, bool destroyOldWindow) if (QApplicationPrivate::testAttribute(Qt::AA_NativeWindows)) setAttribute(Qt::WA_NativeWindow); -#ifdef ALIEN_DEBUG - qDebug() << "QWidget::create:" << this << "parent:" << parentWidget() - << "Alien?" << !testAttribute(Qt::WA_NativeWindow); -#endif - d->updateIsOpaque(); setAttribute(Qt::WA_WState_Created); // set created flag @@ -1336,14 +1330,21 @@ void QWidgetPrivate::create() #endif QBackingStore *store = q->backingStore(); + usesRhiFlush = false; if (!store) { if (q->windowType() != Qt::Desktop) { - if (q->isWindow()) + if (q->isWindow()) { q->setBackingStore(new QBackingStore(win)); + QPlatformBackingStoreRhiConfig rhiConfig; + usesRhiFlush = q_evaluateRhiConfig(q, &rhiConfig, nullptr); + topData()->backingStore->handle()->setRhiConfig(rhiConfig); + } } else { q->setAttribute(Qt::WA_PaintOnScreen, true); } + } else if (win->handle()) { + usesRhiFlush = q_evaluateRhiConfig(q, nullptr, nullptr); } setWindowModified_helper(); @@ -1685,10 +1686,7 @@ void QWidgetPrivate::deleteTLSysExtra() extra->topextra->repaintManager.reset(nullptr); deleteBackingStore(this); -#ifndef QT_NO_OPENGL extra->topextra->widgetTextures.clear(); - extra->topextra->shareContext.reset(); -#endif //the toplevel might have a context with a "qglcontext associated with it. We need to //delete the qglcontext before we delete the qplatformopenglcontext. @@ -2366,9 +2364,6 @@ WId QWidget::winId() const if (!data->in_destructor && (!testAttribute(Qt::WA_WState_Created) || !internalWinId())) { -#ifdef ALIEN_DEBUG - qDebug() << "QWidget::winId: creating native window for" << this; -#endif QWidget *that = const_cast<QWidget*>(this); that->setAttribute(Qt::WA_NativeWindow); that->d_func()->createWinId(); @@ -2381,9 +2376,6 @@ void QWidgetPrivate::createWinId() { Q_Q(QWidget); -#ifdef ALIEN_DEBUG - qDebug() << "QWidgetPrivate::createWinId for" << q; -#endif const bool forceNativeWindow = q->testAttribute(Qt::WA_NativeWindow); if (!q->testAttribute(Qt::WA_WState_Created) || (forceNativeWindow && !q->internalWinId())) { if (!q->isWindow()) { @@ -2454,10 +2446,6 @@ Ensures that the widget has a window system identifier, i.e. that it is known to void QWidget::createWinId() { Q_D(QWidget); -#ifdef ALIEN_DEBUG - qDebug() << "QWidget::createWinId" << this; -#endif -// qWarning("QWidget::createWinId is obsolete, please fix your code."); d->createWinId(); } @@ -5473,7 +5461,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP QWidgetEffectSourcePrivate *sourced = static_cast<QWidgetEffectSourcePrivate *> (source->d_func()); if (!sourced->context) { - const QRegion effectRgn(rgn.boundingRect()); + const QRegion effectRgn((flags & UseEffectRegionBounds) ? rgn.boundingRect() : rgn); QWidgetPaintContext context(pdev, effectRgn, offset, flags, sharedPainter, repaintManager); sourced->context = &context; if (!sharedPainter) { @@ -5505,6 +5493,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP } } #endif // QT_CONFIG(graphicseffect) + flags = flags & ~UseEffectRegionBounds; const bool alsoOnScreen = flags & DrawPaintOnScreen; const bool recursive = flags & DrawRecursive; @@ -5538,30 +5527,22 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP //paint the background if ((asRoot || q->autoFillBackground() || onScreen || q->testAttribute(Qt::WA_StyledBackground)) && !q->testAttribute(Qt::WA_OpaquePaintEvent) && !q->testAttribute(Qt::WA_NoSystemBackground)) { -#ifndef QT_NO_OPENGL beginBackingStorePainting(); -#endif QPainter p(q); paintBackground(&p, toBePainted, (asRoot || onScreen) ? (flags | DrawAsRoot) : DrawWidgetFlags()); -#ifndef QT_NO_OPENGL endBackingStorePainting(); -#endif } if (!sharedPainter) setSystemClip(pdev->paintEngine(), pdev->devicePixelRatio(), toBePainted.translated(offset)); if (!onScreen && !asRoot && !isOpaque && q->testAttribute(Qt::WA_TintedBackground)) { -#ifndef QT_NO_OPENGL beginBackingStorePainting(); -#endif QPainter p(q); QColor tint = q->palette().window().color(); tint.setAlphaF(.6f); p.fillRect(toBePainted.boundingRect(), tint); -#ifndef QT_NO_OPENGL endBackingStorePainting(); -#endif } } @@ -5572,7 +5553,6 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP #endif bool skipPaintEvent = false; -#ifndef QT_NO_OPENGL if (renderToTexture) { // This widget renders into a texture which is composed later. We just need to // punch a hole in the backingstore, so the texture will be visible. @@ -5598,7 +5578,6 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP else skipPaintEvent = true; } -#endif // QT_NO_OPENGL if (!skipPaintEvent) { //actually send the paint event @@ -5654,10 +5633,8 @@ void QWidgetPrivate::sendPaintEvent(const QRegion &toBePainted) QPaintEvent e(toBePainted); QCoreApplication::sendSpontaneousEvent(q, &e); -#ifndef QT_NO_OPENGL if (renderToTexture) resolveSamples(); -#endif // QT_NO_OPENGL } void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, @@ -5991,7 +5968,7 @@ QString QWidget::windowTitle() const if (!d->extra->topextra->caption.isEmpty()) return d->extra->topextra->caption; if (!d->extra->topextra->filePath.isEmpty()) - return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]"); + return QFileInfo(d->extra->topextra->filePath).fileName() + "[*]"_L1; } return QString(); } @@ -6015,7 +5992,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg if (cap.isEmpty()) return cap; - QLatin1String placeHolder("[*]"); + const auto placeHolder = "[*]"_L1; int index = cap.indexOf(placeHolder); // here the magic begins @@ -6039,7 +6016,7 @@ QString qt_setWindowTitle_helperHelper(const QString &title, const QWidget *widg index = cap.indexOf(placeHolder, index); } - cap.replace(QLatin1String("[*][*]"), placeHolder); + cap.replace("[*][*]"_L1, placeHolder); return cap; } @@ -6535,12 +6512,16 @@ void QWidget::setFocus(Qt::FocusReason reason) f->d_func()->updateFocusChild(); QApplicationPrivate::setFocusWidget(f, reason); -#ifndef QT_NO_ACCESSIBILITY - // menus update the focus manually and this would create bogus events - if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem"))) - { - QAccessibleEvent event(f, QAccessible::Focus); - QAccessible::updateAccessibility(&event); +#if QT_CONFIG(accessibility) + // If the widget gets focus because its window becomes active, then the accessibility + // subsystem is already informed about the window opening, and also knows which child + // within the window has focus. Don't interrupt it by emitting another focus event. + if (reason != Qt::ActiveWindowFocusReason) { + // menus update the focus manually and this would create bogus events + if (!(f->inherits("QMenuBar") || f->inherits("QMenu") || f->inherits("QMenuItem"))) { + QAccessibleEvent event(f, QAccessible::Focus); + QAccessible::updateAccessibility(&event); + } } #endif #if QT_CONFIG(graphicsview) @@ -6677,7 +6658,14 @@ void QWidget::clearFocus() } QTLWExtra *extra = window()->d_func()->maybeTopData(); - QObject *originalFocusObject = (extra && extra->window) ? extra->window->focusObject() : nullptr; + QObject *originalFocusObject = nullptr; + if (extra && extra->window) { + originalFocusObject = extra->window->focusObject(); + // the window's focus object might already be nullptr if we are in the destructor, but we still + // need to update QGuiApplication and input context if we have a focus widget. + if (!originalFocusObject) + originalFocusObject = focusWidget(); + } QWidget *w = this; while (w) { @@ -6703,7 +6691,7 @@ void QWidget::clearFocus() if (hasFocus()) { // Update proxy state QApplicationPrivate::setFocusWidget(nullptr, Qt::OtherFocusReason); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleEvent event(this, QAccessible::Focus); QAccessible::updateAccessibility(&event); #endif @@ -7978,7 +7966,7 @@ void QWidgetPrivate::show_helper() if (!isEmbedded && q->windowType() == Qt::Popup) qApp->d_func()->openPopup(q); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) if (q->windowType() != Qt::ToolTip) { // Tooltips are read aloud twice in MS narrator. QAccessibleEvent event(q, QAccessible::ObjectShow); QAccessible::updateAccessibility(&event); @@ -8124,7 +8112,7 @@ void QWidgetPrivate::hide_helper() if (QWidgetRepaintManager *repaintManager = maybeRepaintManager()) repaintManager->removeDirtyWidget(q); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) if (wasVisible) { QAccessibleEvent event(q, QAccessible::ObjectHide); QAccessible::updateAccessibility(&event); @@ -8372,7 +8360,7 @@ void QWidgetPrivate::hideChildren(bool spontaneous) } } qApp->d_func()->sendSyntheticEnterLeave(widget); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) if (!spontaneous) { QAccessibleEvent event(widget, QAccessible::ObjectHide); QAccessible::updateAccessibility(&event); @@ -8908,8 +8896,18 @@ bool QWidget::event(QEvent *event) Qt::InputMethodQuery q = (Qt::InputMethodQuery)(int)(queries & (1<<i)); if (q) { QVariant v = inputMethodQuery(q); - if (q == Qt::ImEnabled && !v.isValid() && isEnabled()) - v = QVariant(true); // special case for Qt4 compatibility + if (q == Qt::ImEnabled && !v.isValid() && isEnabled()) { + // Qt:ImEnabled was added in Qt 5.3. So not all widgets support it, even + // if they implement IM otherwise (and override inputMethodQuery()). + // So for legacy reasons, we need to check by other means if IM is supported when + // Qt::ImEnabled is not implemented (the query returns an invalid QVariant). + // Since QWidget implements inputMethodQuery(), and return valid values for + // some of the IM properties, we cannot just query for Qt::ImQueryAll. + // Instead we assume that if a widget supports IM, it will implement + // Qt::ImSurroundingText (which is not implemented by QWidget). + const bool imEnabledFallback = inputMethodQuery(Qt::ImSurroundingText).isValid(); + v = QVariant(imEnabledFallback); + } query->setValue(q, v); } } @@ -9232,11 +9230,8 @@ bool QWidget::event(QEvent *event) } if (d->data.fnt.d->dpi != logicalDpiY()) d->updateFont(d->data.fnt); -#ifndef QT_NO_OPENGL d->renderToTextureReallyDirty = 1; -#endif break; -#ifndef QT_NO_PROPERTIES case QEvent::DynamicPropertyChange: { const QByteArray &propName = static_cast<QDynamicPropertyChangeEvent *>(event)->propertyName(); if (propName.length() == 13 && !qstrncmp(propName, "_q_customDpi", 12)) { @@ -9254,7 +9249,6 @@ bool QWidget::event(QEvent *event) windowHandle()->setProperty(propName, property(propName)); Q_FALLTHROUGH(); } -#endif default: return QObject::event(event); } @@ -9282,7 +9276,7 @@ void QWidget::changeEvent(QEvent * event) switch(event->type()) { case QEvent::EnabledChange: { update(); -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessible::State s; s.disabled = true; QAccessibleStateChangeEvent event(this, s); @@ -10513,22 +10507,20 @@ void QWidget::setParent(QWidget *parent) setParent((QWidget*)parent, windowFlags() & ~Qt::WindowType_Mask); } -#ifndef QT_NO_OPENGL -static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget) +static void sendWindowChangeToTextureChildrenRecursively(QWidget *widget, QEvent::Type eventType) { QWidgetPrivate *d = QWidgetPrivate::get(widget); if (d->renderToTexture) { - QEvent e(QEvent::WindowChangeInternal); + QEvent e(eventType); QCoreApplication::sendEvent(widget, &e); } for (int i = 0; i < d->children.size(); ++i) { QWidget *w = qobject_cast<QWidget *>(d->children.at(i)); if (w && !w->isWindow() && QWidgetPrivate::get(w)->textureChildSeen) - sendWindowChangeToTextureChildrenRecursively(w); + sendWindowChangeToTextureChildrenRecursively(w, eventType); } } -#endif /*! \overload @@ -10584,6 +10576,12 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) QCoreApplication::sendEvent(this, &e); } } + + // texture-based widgets need a pre-notification when their associated top-level window changes + // This is not under the wasCreated/newParent conditions above in order to also play nice with QDockWidget. + if (d->textureChildSeen && ((!parent && parentWidget()) || (parent && parent->window() != oldtlw))) + sendWindowChangeToTextureChildrenRecursively(this, QEvent::WindowAboutToChangeInternal); + // If we get parented into another window, children will be folded // into the new parent's focus chain, so clear focus now. if (newParent && isAncestorOf(focusWidget()) && !(f & Qt::Window)) @@ -10594,12 +10592,10 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) if (desktopWidget) parent = nullptr; -#ifndef QT_NO_OPENGL if (d->textureChildSeen && parent) { // set the textureChildSeen flag up the whole parent chain QWidgetPrivate::get(parent)->setTextureChildSeen(); } -#endif if (QWidgetRepaintManager *oldPaintManager = oldtlw->d_func()->maybeRepaintManager()) { if (newParent) @@ -10661,12 +10657,11 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) QEvent e(QEvent::ParentChange); QCoreApplication::sendEvent(this, &e); } -#ifndef QT_NO_OPENGL - //renderToTexture widgets also need to know when their top-level window changes - if (d->textureChildSeen && oldtlw != window()) { - sendWindowChangeToTextureChildrenRecursively(this); - } -#endif + + // texture-based widgets need another event when their top-level window + // changes (more precisely, has already changed at this point) + if (d->textureChildSeen && oldtlw != window()) + sendWindowChangeToTextureChildrenRecursively(this, QEvent::WindowChangeInternal); if (!wasCreated) { if (isWindow() || parentWidget()->isVisible()) @@ -10692,6 +10687,20 @@ void QWidget::setParent(QWidget *parent, Qt::WindowFlags f) if (d->extra && d->extra->hasWindowContainer) QWindowContainer::parentWasChanged(this); + + QWidget *newtlw = window(); + if (oldtlw != newtlw) { + QSurface::SurfaceType surfaceType = QSurface::RasterSurface; + if (q_evaluateRhiConfig(this, nullptr, &surfaceType)) { + newtlw->d_func()->usesRhiFlush = true; + if (QWindow *w = newtlw->windowHandle()) { + if (w->surfaceType() != surfaceType) { + newtlw->destroy(); + newtlw->create(); + } + } + } + } } void QWidgetPrivate::setParent_sys(QWidget *newparent, Qt::WindowFlags f) @@ -10949,7 +10958,7 @@ void QWidgetPrivate::repaint(T r) return; QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData(); - if (tlwExtra && tlwExtra->backingStore) + if (tlwExtra && tlwExtra->backingStore && tlwExtra->repaintManager) tlwExtra->repaintManager->markDirty(r, q, QWidgetRepaintManager::UpdateNow); } @@ -11010,6 +11019,11 @@ void QWidgetPrivate::update(T r) { Q_Q(QWidget); + if (renderToTexture && !q->isVisible()) { + renderToTextureReallyDirty = 1; + return; + } + if (!q->isVisible() || !q->updatesEnabled()) return; @@ -11024,7 +11038,7 @@ void QWidgetPrivate::update(T r) } QTLWExtra *tlwExtra = q->window()->d_func()->maybeTopData(); - if (tlwExtra && tlwExtra->backingStore) + if (tlwExtra && tlwExtra->backingStore && tlwExtra->repaintManager) tlwExtra->repaintManager->markDirty(clipped, q); } @@ -11403,7 +11417,7 @@ void QWidgetPrivate::setWindowModified_helper() return; bool on = q->testAttribute(Qt::WA_WindowModified); if (!platformWindow->setWindowModified(on)) { - if (Q_UNLIKELY(on && !q->windowTitle().contains(QLatin1String("[*]")))) + if (Q_UNLIKELY(on && !q->windowTitle().contains("[*]"_L1))) qWarning("QWidget::setWindowModified: The window title does not contain a '[*]' placeholder"); setWindowTitle_helper(q->windowTitle()); setWindowIconText_helper(q->windowIconText()); @@ -11515,7 +11529,7 @@ QString QWidget::whatsThis() const } #endif // QT_CONFIG(whatsthis) -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) /*! \property QWidget::accessibleName @@ -11580,7 +11594,7 @@ QString QWidget::accessibleDescription() const Q_D(const QWidget); return d->accessibleDescription; } -#endif // QT_NO_ACCESSIBILITY +#endif // QT_CONFIG(accessibility) #ifndef QT_NO_SHORTCUT /*! @@ -12160,27 +12174,6 @@ void QWidgetPrivate::adjustQuitOnCloseAttribute() } } -QOpenGLContext *QWidgetPrivate::shareContext() const -{ -#ifdef QT_NO_OPENGL - return nullptr; -#else - if (!extra || !extra->topextra || !extra->topextra->window) - return nullptr; - - if (!extra->topextra->shareContext) { - auto ctx = std::make_unique<QOpenGLContext>(); - ctx->setShareContext(qt_gl_global_share_context()); - ctx->setFormat(extra->topextra->window->format()); - ctx->setScreen(extra->topextra->window->screen()); - ctx->create(); - extra->topextra->shareContext = std::move(ctx); - } - return extra->topextra->shareContext.get(); -#endif // QT_NO_OPENGL -} - -#ifndef QT_NO_OPENGL void QWidgetPrivate::sendComposeStatus(QWidget *w, bool end) { QWidgetPrivate *wd = QWidgetPrivate::get(w); @@ -12196,7 +12189,6 @@ void QWidgetPrivate::sendComposeStatus(QWidget *w, bool end) sendComposeStatus(w, end); } } -#endif // QT_NO_OPENGL Q_WIDGETS_EXPORT QWidgetData *qt_qwidget_data(QWidget *widget) { @@ -12712,57 +12704,60 @@ void QWidget::activateWindow() */ int QWidget::metric(PaintDeviceMetric m) const { - QWindow *topLevelWindow = nullptr; - QScreen *screen = nullptr; - if (QWidget *topLevel = window()) { - topLevelWindow = topLevel->windowHandle(); - if (topLevelWindow) - screen = topLevelWindow->screen(); - } - if (!screen && QGuiApplication::primaryScreen()) - screen = QGuiApplication::primaryScreen(); + QScreen *screen = this->screen(); if (!screen) { if (m == PdmDpiX || m == PdmDpiY) return 72; return QPaintDevice::metric(m); } - int val; - if (m == PdmWidth) { - val = data->crect.width(); - } else if (m == PdmWidthMM) { - val = data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); - } else if (m == PdmHeight) { - val = data->crect.height(); - } else if (m == PdmHeightMM) { - val = data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); - } else if (m == PdmDepth) { + + auto resolveDevicePixelRatio = [this, screen]() -> qreal { + + // Note: keep in sync with QBackingStorePrivate::backingStoreDevicePixelRatio()! + static bool downscale = qEnvironmentVariableIntValue("QT_WIDGETS_HIGHDPI_DOWNSCALE") > 0; + QWindow *window = this->window()->windowHandle(); + if (downscale && window) + return std::ceil(window->devicePixelRatio()); + + return screen->devicePixelRatio(); + }; + + switch (m) { + case PdmWidth: + return data->crect.width(); + case PdmWidthMM: + return data->crect.width() * screen->physicalSize().width() / screen->geometry().width(); + case PdmHeight: + return data->crect.height(); + case PdmHeightMM: + return data->crect.height() * screen->physicalSize().height() / screen->geometry().height(); + case PdmDepth: return screen->depth(); - } else if (m == PdmDpiX) { + case PdmDpiX: for (const QWidget *p = this; p; p = p->parentWidget()) { if (p->d_func()->extra && p->d_func()->extra->customDpiX) return p->d_func()->extra->customDpiX; } return qRound(screen->logicalDotsPerInchX()); - } else if (m == PdmDpiY) { + case PdmDpiY: for (const QWidget *p = this; p; p = p->parentWidget()) { if (p->d_func()->extra && p->d_func()->extra->customDpiY) return p->d_func()->extra->customDpiY; } return qRound(screen->logicalDotsPerInchY()); - } else if (m == PdmPhysicalDpiX) { + case PdmPhysicalDpiX: return qRound(screen->physicalDotsPerInchX()); - } else if (m == PdmPhysicalDpiY) { + case PdmPhysicalDpiY: return qRound(screen->physicalDotsPerInchY()); - } else if (m == PdmDevicePixelRatio) { - return topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio(); - } else if (m == PdmDevicePixelRatioScaled) { - return (QPaintDevice::devicePixelRatioFScale() * - (topLevelWindow ? topLevelWindow->devicePixelRatio() : qApp->devicePixelRatio())); - } else { - val = QPaintDevice::metric(m);// XXX + case PdmDevicePixelRatio: + return resolveDevicePixelRatio(); + case PdmDevicePixelRatioScaled: + return QPaintDevice::devicePixelRatioFScale() * resolveDevicePixelRatio(); + default: + break; } - return val; + return QPaintDevice::metric(m); } /*! @@ -12937,6 +12932,25 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new widget->setParent(static_cast<QWidget*>(newParent)); } +std::string QWidgetPrivate::flagsForDumping() const +{ + Q_Q(const QWidget); + std::string flags = QObjectPrivate::flagsForDumping(); + if (QApplication::focusWidget() == q) + flags += 'F'; + if (q->isVisible()) { + std::stringstream s; + s << '<' + << q->width() << 'x' << q->height() + << std::showpos << q->x() << q->y() + << '>'; + flags += s.str(); + } else { + flags += 'I'; + } + return flags; +} + void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing) { #if QT_CONFIG(xcb) @@ -13045,4 +13059,4 @@ QDebug operator<<(QDebug debug, const QWidget *widget) QT_END_NAMESPACE #include "moc_qwidget.cpp" - +#include "moc_qwidget_p.cpp" diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index 6c30e018df..06ac265ede 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIDGET_H #define QWIDGET_H @@ -197,7 +161,7 @@ class Q_WIDGETS_EXPORT QWidget : public QObject, public QPaintDevice #if QT_CONFIG(whatsthis) Q_PROPERTY(QString whatsThis READ whatsThis WRITE setWhatsThis) #endif -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) Q_PROPERTY(QString accessibleName READ accessibleName WRITE setAccessibleName) Q_PROPERTY(QString accessibleDescription READ accessibleDescription WRITE setAccessibleDescription) #endif @@ -432,7 +396,7 @@ public: void setWhatsThis(const QString &); QString whatsThis() const; #endif -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QString accessibleName() const; void setAccessibleName(const QString &name); QString accessibleDescription() const; @@ -832,17 +796,17 @@ inline QWidget *QWidget::childAt(int ax, int ay) const { return childAt(QPoint(ax, ay)); } inline Qt::WindowType QWidget::windowType() const -{ return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); } +{ return static_cast<Qt::WindowType>((data->window_flags & Qt::WindowType_Mask).toInt()); } inline Qt::WindowFlags QWidget::windowFlags() const { return data->window_flags; } #if QT_DEPRECATED_SINCE(6, 1) inline bool QWidget::isTopLevel() const -{ return (windowType() & Qt::Window); } +{ return bool(windowType() & Qt::Window); } #endif inline bool QWidget::isWindow() const -{ return (windowType() & Qt::Window); } +{ return bool(windowType() & Qt::Window); } inline bool QWidget::isEnabled() const { return !testAttribute(Qt::WA_Disabled); } diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 41f343dfec..65e368d945 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIDGET_P_H #define QWIDGET_P_H @@ -61,7 +25,6 @@ #include "QtCore/qset.h" #include "QtGui/qregion.h" #include "QtGui/qinputmethod.h" -#include "QtGui/qopengl.h" #include "QtGui/qsurfaceformat.h" #include "QtGui/qscreen.h" #include "QtWidgets/qsizepolicy.h" @@ -77,6 +40,7 @@ #endif #include <private/qgesture_p.h> #include <qpa/qplatformbackingstore.h> +#include <QtGui/private/qbackingstorerhisupport_p.h> #include <vector> #include <memory> @@ -94,7 +58,6 @@ class QPixmap; class QWidgetRepaintManager; class QGraphicsProxyWidget; class QWidgetItemV2; -class QOpenGLContext; class QStyle; @@ -130,9 +93,6 @@ struct QTLWExtra { QBackingStore *backingStore; QPainter *sharedPainter; QWidgetWindow *window; -#ifndef QT_NO_OPENGL - mutable std::unique_ptr<QOpenGLContext> shareContext; -#endif // Implicit pointers (shared_null). QString caption; // widget caption @@ -149,9 +109,7 @@ struct QTLWExtra { Qt::WindowFlags savedFlags; // Save widget flags while showing fullscreen QScreen *initialScreen; // Screen when passing a QDesktop[Screen]Widget as parent. -#ifndef QT_NO_OPENGL std::vector<std::unique_ptr<QPlatformTextureList>> widgetTextures; -#endif // *************************** Cross-platform bit fields **************************** uint opacity : 8; @@ -231,7 +189,8 @@ public: DontSubtractOpaqueChildren = 0x10, DontDrawOpaqueChildren = 0x20, DontDrawNativeChildren = 0x40, - DontSetCompositionMode = 0x80 + DontSetCompositionMode = 0x80, + UseEffectRegionBounds = 0x100 }; Q_DECLARE_FLAGS(DrawWidgetFlags, DrawWidgetFlag) Q_FLAG(DrawWidgetFlags) @@ -479,27 +438,22 @@ public: // These helper functions return the (available) geometry for the screen // the widget is on, and takes care if this one is embedded in a QGraphicsView. - static QRect graphicsViewParentRect(const QWidget *widget) + static QWidget *parentGraphicsView(const QWidget *widget) { - QRect rect; #if QT_CONFIG(graphicsview) QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget); //It's embedded if it has an ancestor if (ancestorProxy) { if (!bypassGraphicsProxyWidget(widget) && ancestorProxy->scene() != nullptr) { - // One view, let be smart and return the viewport rect then the popup is aligned - if (ancestorProxy->scene()->views().size() == 1) { - QGraphicsView *view = ancestorProxy->scene()->views().at(0); - rect = view->mapToScene(view->viewport()->rect()).boundingRect().toRect(); - } else { - rect = ancestorProxy->scene()->sceneRect().toRect(); + if (!ancestorProxy->scene()->views().empty()) { + return ancestorProxy->scene()->views().at(0); } } } #else Q_UNUSED(widget); #endif - return rect; + return nullptr; } static QRect screenGeometry(const QWidget *widget) @@ -512,11 +466,10 @@ public: return availableScreenGeometry(widget, QPoint(), false); } - static QRect screenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true) + static QScreen *screen(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true) { - QRect rect = graphicsViewParentRect(widget); - if (!rect.isNull()) - return rect; + while (QWidget *view = parentGraphicsView(widget)) + widget = view; QScreen *screen = nullptr; if (hasPosition) @@ -524,22 +477,17 @@ public: if (!screen) screen = widget->screen(); - return screen->geometry(); + return screen; } - static QRect availableScreenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true) + static QRect screenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true) { - QRect rect = graphicsViewParentRect(widget); - if (!rect.isNull()) - return rect; - - QScreen *screen = nullptr; - if (hasPosition) - screen = widget->screen()->virtualSiblingAt(globalPosition); - if (!screen) - screen = widget->screen(); + return screen(widget, globalPosition, hasPosition)->geometry(); + } - return screen->availableGeometry(); + static QRect availableScreenGeometry(const QWidget *widget, const QPoint &globalPosition, bool hasPosition = true) + { + return screen(widget, globalPosition, hasPosition)->availableGeometry(); } inline void setRedirected(QPaintDevice *replacement, const QPoint &offset) @@ -627,12 +575,11 @@ public: inline QRect mapFromWS(const QRect &r) const { return r.translated(data.wrect.topLeft()); } - QOpenGLContext *shareContext() const; - virtual QObject *focusObject() { return nullptr; } -#ifndef QT_NO_OPENGL - virtual GLuint textureId() const { return 0; } + virtual QPlatformBackingStoreRhiConfig rhiConfig() const { return {}; } + + virtual QRhiTexture *texture() const { return nullptr; } virtual QPlatformTextureList::Flags textureListFlags() { Q_Q(QWidget); return q->testAttribute(Qt::WA_AlwaysStackOnTop) @@ -667,10 +614,11 @@ public: virtual void resizeViewportFramebuffer() { } // Called after each paint event. virtual void resolveSamples() { } -#endif static void setWidgetParentHelper(QObject *widgetAsObject, QObject *newParent); + std::string flagsForDumping() const override; + // Variables. // Regular pointers (keep them together to avoid gaps on 64 bit architectures). std::unique_ptr<QWExtra> extra; @@ -709,7 +657,7 @@ public: #if QT_CONFIG(whatsthis) QString whatsThis; #endif -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QString accessibleName; QString accessibleDescription; #endif @@ -758,10 +706,8 @@ public: #ifndef QT_NO_IM uint inheritsInputMethodHints : 1; #endif -#ifndef QT_NO_OPENGL uint renderToTextureReallyDirty : 1; - uint renderToTextureComposeActive : 1; -#endif + uint usesRhiFlush : 1; uint childrenHiddenByWState : 1; uint childrenShownByExpose : 1; diff --git a/src/widgets/kernel/qwidgetaction.cpp b/src/widgets/kernel/qwidgetaction.cpp index f9cd82f788..1f2fa5dea3 100644 --- a/src/widgets/kernel/qwidgetaction.cpp +++ b/src/widgets/kernel/qwidgetaction.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwidgetaction.h" #include "qwidget.h" diff --git a/src/widgets/kernel/qwidgetaction.h b/src/widgets/kernel/qwidgetaction.h index e3bfc62ca7..b8539f275b 100644 --- a/src/widgets/kernel/qwidgetaction.h +++ b/src/widgets/kernel/qwidgetaction.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIDGETACTION_H #define QWIDGETACTION_H diff --git a/src/widgets/kernel/qwidgetaction_p.h b/src/widgets/kernel/qwidgetaction_p.h index 4b118c45c5..bd156241c6 100644 --- a/src/widgets/kernel/qwidgetaction_p.h +++ b/src/widgets/kernel/qwidgetaction_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIDGETACTION_P_H #define QWIDGETACTION_P_H diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index 16ff8ea721..69ab7de1af 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qplatformdefs.h" @@ -65,12 +29,11 @@ QT_BEGIN_NAMESPACE -#ifndef QT_NO_OPENGL Q_GLOBAL_STATIC(QPlatformTextureList, qt_dummy_platformTextureList) // Watches one or more QPlatformTextureLists for changes in the lock state and // triggers a backingstore sync when all the registered lists turn into -// unlocked state. This is essential when a custom composeAndFlush() +// unlocked state. This is essential when a custom rhiFlush() // implementation in a platform plugin is not synchronous and keeps // holding on to the textures for some time even after returning from there. class QPlatformTextureListWatcher : public QObject @@ -105,7 +68,6 @@ private: QHash<QPlatformTextureList *, bool> m_locked; QWidgetRepaintManager *m_repaintManager; }; -#endif // --------------------------------------------------------------------------- @@ -374,7 +336,6 @@ void QWidgetRepaintManager::sendUpdateRequest(QWidget *widget, UpdateTime update qCInfo(lcWidgetPainting) << "Sending update request to" << widget << "with" << updateTime; -#ifndef QT_NO_OPENGL // Having every repaint() leading to a sync/flush is bad as it causes // compositing and waiting for vsync each and every time. Change to // UpdateLater, except for approx. once per frame to prevent starvation in @@ -392,7 +353,6 @@ void QWidgetRepaintManager::sendUpdateRequest(QWidget *widget, UpdateTime update updateTime = UpdateLater; } } -#endif switch (updateTime) { case UpdateLater: @@ -571,7 +531,6 @@ bool QWidgetRepaintManager::bltRect(const QRect &rect, int dx, int dy, QWidget * // --------------------------------------------------------------------------- -#ifndef QT_NO_OPENGL static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, QPlatformTextureList *widgetTextures, QList<QWidget *> *nativeChildren) @@ -580,7 +539,7 @@ static void findTextureWidgetsRecursively(QWidget *tlw, QWidget *widget, if (wd->renderToTexture) { QPlatformTextureList::Flags flags = wd->textureListFlags(); const QRect rect(widget->mapTo(tlw, QPoint()), widget->size()); - widgetTextures->appendTexture(widget, wd->textureId(), rect, wd->clipRect(), flags); + widgetTextures->appendTexture(widget, wd->texture(), rect, wd->clipRect(), flags); } for (int i = 0; i < wd->children.size(); ++i) { @@ -624,33 +583,12 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget) } } - if (QWidgetPrivate::get(widget)->textureChildSeen) { - // No render-to-texture widgets in the (sub-)tree due to hidden or native - // children. Returning null results in using the normal backingstore flush path - // without OpenGL-based compositing. This is very desirable normally. However, - // some platforms cannot handle switching between the non-GL and GL paths for - // their windows so it has to be opt-in. - static bool switchableWidgetComposition = - QGuiApplicationPrivate::instance()->platformIntegration() - ->hasCapability(QPlatformIntegration::SwitchableWidgetComposition); - if (!switchableWidgetComposition) - return qt_dummy_platformTextureList(); - } + if (QWidgetPrivate::get(widget)->textureChildSeen) + return qt_dummy_platformTextureList(); return nullptr; } -#else - -static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget) -{ - Q_UNUSED(tlw); - Q_UNUSED(widget); - return nullptr; -} - -#endif // QT_NO_OPENGL - // --------------------------------------------------------------------------- /*! @@ -725,7 +663,6 @@ bool QWidgetPrivate::shouldDiscardSyncRequest() const bool QWidgetRepaintManager::syncAllowed() { -#ifndef QT_NO_OPENGL QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData(); if (textureListWatcher && !textureListWatcher->isLocked()) { textureListWatcher->deleteLater(); @@ -744,7 +681,6 @@ bool QWidgetRepaintManager::syncAllowed() if (skipSync) // cannot compose due to widget textures being in use return false; } -#endif return true; } @@ -857,7 +793,6 @@ void QWidgetRepaintManager::paintAndFlush() } dirtyWidgets.clear(); -#ifndef QT_NO_OPENGL // Find all render-to-texture child widgets (including self). // The search is cut at native widget boundaries, meaning that each native child widget // has its own list for the subtree below it. @@ -865,13 +800,12 @@ void QWidgetRepaintManager::paintAndFlush() tlwExtra->widgetTextures.clear(); findAllTextureWidgetsRecursively(tlw, tlw); qt_window_private(tlw->windowHandle())->compositing = false; // will get updated in flush() -#endif if (toClean.isEmpty()) { // Nothing to repaint. However renderToTexture widgets are handled // specially, they are not in the regular dirty list, in order to // prevent triggering unnecessary backingstore painting when only the - // OpenGL content changes. Check if we have such widgets in the special + // texture content changes. Check if we have such widgets in the special // dirty list. QVarLengthArray<QWidget *, 16> paintPending; const int numPaintPending = dirtyRenderToTextureWidgets.count(); @@ -903,7 +837,6 @@ void QWidgetRepaintManager::paintAndFlush() return; } -#ifndef QT_NO_OPENGL for (const auto &tl : tlwExtra->widgetTextures) { for (int i = 0; i < tl->count(); ++i) { QWidget *w = static_cast<QWidget *>(tl->source(i)); @@ -920,7 +853,6 @@ void QWidgetRepaintManager::paintAndFlush() for (int i = 0; i < dirtyRenderToTextureWidgets.count(); ++i) resetWidget(dirtyRenderToTextureWidgets.at(i)); dirtyRenderToTextureWidgets.clear(); -#endif #if QT_CONFIG(graphicsview) if (tlw->d_func()->extra->proxyWidget) { @@ -965,7 +897,8 @@ void QWidgetRepaintManager::paintAndFlush() // Paint the rest with composition. if (repaintAllWidgets || !dirtyCopy.isEmpty()) { - QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive; + QWidgetPrivate::DrawWidgetFlags flags = QWidgetPrivate::DrawAsRoot | QWidgetPrivate::DrawRecursive + | QWidgetPrivate::UseEffectRegionBounds; tlw->d_func()->drawWidget(store->paintDevice(), dirtyCopy, QPoint(), flags, nullptr, this); } @@ -1046,12 +979,10 @@ void QWidgetRepaintManager::flush() // Render-to-texture widgets are not in topLevelNeedsFlush so flush if we have not done it above. if (!flushed && !hasNeedsFlushWidgets) { -#ifndef QT_NO_OPENGL if (!tlw->d_func()->topData()->widgetTextures.empty()) { if (QPlatformTextureList *widgetTextures = widgetTexturesFor(tlw, tlw)) flush(tlw, QRegion(), widgetTextures); } -#endif } if (!hasNeedsFlushWidgets) @@ -1073,12 +1004,7 @@ void QWidgetRepaintManager::flush() */ void QWidgetRepaintManager::flush(QWidget *widget, const QRegion ®ion, QPlatformTextureList *widgetTextures) { -#ifdef QT_NO_OPENGL - Q_UNUSED(widgetTextures); - Q_ASSERT(!region.isEmpty()); -#else Q_ASSERT(!region.isEmpty() || widgetTextures); -#endif Q_ASSERT(widget); Q_ASSERT(tlw); @@ -1091,8 +1017,6 @@ void QWidgetRepaintManager::flush(QWidget *widget, const QRegion ®ion, QPlatf return; } - qCInfo(lcWidgetPainting) << "Flushing" << region << "of" << widget; - static bool fpsDebug = qEnvironmentVariableIntValue("QT_DEBUG_FPS"); if (fpsDebug) { if (!perfFrames++) @@ -1108,40 +1032,38 @@ void QWidgetRepaintManager::flush(QWidget *widget, const QRegion ®ion, QPlatf if (widget != tlw) offset += widget->mapTo(tlw, QPoint()); - QRegion effectiveRegion = region; -#ifndef QT_NO_OPENGL - const bool compositionWasActive = widget->d_func()->renderToTextureComposeActive; - if (!widgetTextures) { - widget->d_func()->renderToTextureComposeActive = false; - // Detect the case of falling back to the normal flush path when no - // render-to-texture widgets are visible anymore. We will force one - // last flush to go through the OpenGL-based composition to prevent - // artifacts. The next flush after this one will use the normal path. - if (compositionWasActive) + if (widget->d_func()->usesRhiFlush) { + QRhi *rhi = store->handle()->rhi(); + qCDebug(lcWidgetPainting) << "Flushing" << region << "of" << widget + << "with QRhi" << rhi + << "to window" << widget->windowHandle(); + if (!widgetTextures) widgetTextures = qt_dummy_platformTextureList; - } else { - widget->d_func()->renderToTextureComposeActive = true; - } - // When changing the composition status, make sure the dirty region covers - // the entire widget. Just having e.g. the shown/hidden render-to-texture - // widget's area marked as dirty is incorrect when changing flush paths. - if (compositionWasActive != widget->d_func()->renderToTextureComposeActive) - effectiveRegion = widget->rect(); - - // re-test since we may have been forced to this path via the dummy texture list above - if (widgetTextures) { + qt_window_private(tlw->windowHandle())->compositing = true; - widget->window()->d_func()->sendComposeStatus(widget->window(), false); + QWidgetPrivate *widgetWindowPrivate = widget->window()->d_func(); + widgetWindowPrivate->sendComposeStatus(widget->window(), false); // A window may have alpha even when the app did not request // WA_TranslucentBackground. Therefore the compositor needs to know whether the app intends // to rely on translucency, in order to decide if it should clear to transparent or opaque. const bool translucentBackground = widget->testAttribute(Qt::WA_TranslucentBackground); - store->handle()->composeAndFlush(widget->windowHandle(), effectiveRegion, offset, - widgetTextures, translucentBackground); - widget->window()->d_func()->sendComposeStatus(widget->window(), true); - } else -#endif - store->flush(effectiveRegion, widget->windowHandle(), offset); + + QPlatformBackingStore::FlushResult flushResult; + flushResult = store->handle()->rhiFlush(widget->windowHandle(), + widget->devicePixelRatio(), + region, + offset, + widgetTextures, + translucentBackground); + widgetWindowPrivate->sendComposeStatus(widget->window(), true); + if (flushResult == QPlatformBackingStore::FlushFailedDueToLostDevice) { + store->handle()->graphicsDeviceReportedLost(); + widget->update(); + } + } else { + qCInfo(lcWidgetPainting) << "Flushing" << region << "of" << widget; + store->flush(region, widget->windowHandle(), offset); + } } // --------------------------------------------------------------------------- @@ -1353,6 +1275,12 @@ void QWidgetPrivate::invalidateBackingStore_resizeHelper(const QPoint &oldPos, c } } +QRhi *QWidgetRepaintManager::rhi() const +{ + return store->handle()->rhi(); +} + QT_END_NAMESPACE #include "qwidgetrepaintmanager.moc" +#include "moc_qwidgetrepaintmanager_p.cpp" diff --git a/src/widgets/kernel/qwidgetrepaintmanager_p.h b/src/widgets/kernel/qwidgetrepaintmanager_p.h index 89f65e05bc..4378974610 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager_p.h +++ b/src/widgets/kernel/qwidgetrepaintmanager_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIDGETREPAINTMANAGER_P_H #define QWIDGETREPAINTMANAGER_P_H @@ -62,8 +26,10 @@ QT_BEGIN_NAMESPACE class QPlatformTextureList; class QPlatformTextureListWatcher; class QWidgetRepaintManager; +class QRhi; +class QRhiSwapChain; -class Q_AUTOTEST_EXPORT QWidgetRepaintManager +class Q_WIDGETS_EXPORT QWidgetRepaintManager { Q_GADGET public: @@ -106,6 +72,8 @@ public: bool bltRect(const QRect &rect, int dx, int dy, QWidget *widget); + QRhi *rhi() const; + private: void updateLists(QWidget *widget); diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index e27c26cd05..5e5c932a89 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qvariant.h" diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp index 14a2655e35..c1fcdbb2dd 100644 --- a/src/widgets/kernel/qwidgetwindow.cpp +++ b/src/widgets/kernel/qwidgetwindow.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "private/qwindow_p.h" #include "qwidgetwindow_p.h" @@ -43,7 +7,7 @@ #include "private/qwidget_p.h" #include "private/qapplication_p.h" -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) #include <QtGui/qaccessible.h> #endif #include <private/qwidgetrepaintmanager_p.h> @@ -55,6 +19,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + Q_WIDGETS_EXPORT extern bool qt_tab_all_widgets(); Q_WIDGETS_EXPORT QWidget *qt_button_down = nullptr; // widget got last button-down @@ -108,9 +74,6 @@ public: } QRectF closestAcceptableGeometry(const QRectF &rect) const override; -#if QT_CONFIG(opengl) - QOpenGLContext *shareContext() const override; -#endif void processSafeAreaMarginsChanged() override { @@ -152,26 +115,19 @@ QRectF QWidgetWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const return result; } -#if QT_CONFIG(opengl) -QOpenGLContext *QWidgetWindowPrivate::shareContext() const -{ - Q_Q(const QWidgetWindow); - const QWidgetPrivate *widgetPrivate = QWidgetPrivate::get(q->widget()); - return widgetPrivate->shareContext(); -} -#endif // opengl +bool q_evaluateRhiConfig(const QWidget *w, QPlatformBackingStoreRhiConfig *outConfig, QSurface::SurfaceType *outType); QWidgetWindow::QWidgetWindow(QWidget *widget) : QWindow(*new QWidgetWindowPrivate(), nullptr) , m_widget(widget) { updateObjectName(); - // Enable QOpenGLWidget/QQuickWidget children if the platform plugin supports it, - // and the application developer has not explicitly disabled it. - if (QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface) - && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) { - setSurfaceType(QSurface::RasterGLSurface); + if (!QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) { + QSurface::SurfaceType type = QSurface::RasterSurface; + q_evaluateRhiConfig(m_widget, nullptr, &type); + setSurfaceType(type); } + connect(widget, &QObject::objectNameChanged, this, &QWidgetWindow::updateObjectName); connect(this, SIGNAL(screenChanged(QScreen*)), this, SLOT(handleScreenChange())); } @@ -180,7 +136,7 @@ QWidgetWindow::~QWidgetWindow() { } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleInterface *QWidgetWindow::accessibleRoot() const { if (m_widget) @@ -255,7 +211,7 @@ bool QWidgetWindow::event(QEvent *event) handleFocusInEvent(static_cast<QFocusEvent *>(event)); Q_FALLTHROUGH(); case QEvent::FocusOut: { -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessible::State state; state.active = true; QAccessibleStateChangeEvent ev(m_widget, state); @@ -402,7 +358,7 @@ void QWidgetWindow::handleEnterLeaveEvent(QEvent *event) QWindowSystemInterfacePrivate::EnterEvent *systemEvent = static_cast<QWindowSystemInterfacePrivate::EnterEvent *> (QWindowSystemInterfacePrivate::peekWindowSystemEvent(QWindowSystemInterfacePrivate::Enter)); - const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QGuiApplicationPrivate::lastCursorPosition; + const QPointF globalPosF = systemEvent ? systemEvent->globalPos : QPointF(QGuiApplicationPrivate::lastCursorPosition); if (systemEvent) { if (QWidgetWindow *enterWindow = qobject_cast<QWidgetWindow *>(systemEvent->enter)) { @@ -941,8 +897,9 @@ void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event) event->ignore(); if (m_dragTarget) { // Send DragLeave to previous QDragLeaveEvent leaveEvent; - QGuiApplication::forwardEvent(m_dragTarget, &leaveEvent, event); + QWidget *dragTarget = m_dragTarget; m_dragTarget = nullptr; + QGuiApplication::forwardEvent(dragTarget, &leaveEvent, event); } } else { const QPoint mapped = widget->mapFromGlobal(m_widget->mapToGlobal(event->position().toPoint())); @@ -956,8 +913,9 @@ void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event) } else { if (m_dragTarget) { // Send DragLeave to previous QDragLeaveEvent leaveEvent; - QGuiApplication::forwardEvent(m_dragTarget, &leaveEvent, event); + QWidget *dragTarget = m_dragTarget; m_dragTarget = nullptr; + QGuiApplication::forwardEvent(dragTarget, &leaveEvent, event); } // widget might have been deleted when handling the leaveEvent if (widget) { @@ -979,9 +937,11 @@ void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event) void QWidgetWindow::handleDragLeaveEvent(QDragLeaveEvent *event) { - if (m_dragTarget) - QGuiApplication::forwardEvent(m_dragTarget, event); - m_dragTarget = nullptr; + if (m_dragTarget) { + QWidget *dragTarget = m_dragTarget; + m_dragTarget = nullptr; + QGuiApplication::forwardEvent(dragTarget, event); + } } void QWidgetWindow::handleDropEvent(QDropEvent *event) @@ -993,10 +953,11 @@ void QWidgetWindow::handleDropEvent(QDropEvent *event) } const QPoint mapped = m_dragTarget->mapFromGlobal(m_widget->mapToGlobal(event->position().toPoint())); QDropEvent translated(mapped, event->possibleActions(), event->mimeData(), event->buttons(), event->modifiers()); - QGuiApplication::forwardEvent(m_dragTarget, &translated, event); + QWidget *dragTarget = m_dragTarget; + m_dragTarget = nullptr; + QGuiApplication::forwardEvent(dragTarget, &translated, event); event->setAccepted(translated.isAccepted()); event->setDropAction(translated.dropAction()); - m_dragTarget = nullptr; } #endif // QT_CONFIG(draganddrop) @@ -1169,8 +1130,8 @@ void QWidgetWindow::updateObjectName() { QString name = m_widget->objectName(); if (name.isEmpty()) - name = QString::fromUtf8(m_widget->metaObject()->className()) + QLatin1String("Class"); - name += QLatin1String("Window"); + name = QString::fromUtf8(m_widget->metaObject()->className()) + "Class"_L1; + name += "Window"_L1; setObjectName(name); } diff --git a/src/widgets/kernel/qwidgetwindow_p.h b/src/widgets/kernel/qwidgetwindow_p.h index 0ad3ec5062..92f1a8b6d4 100644 --- a/src/widgets/kernel/qwidgetwindow_p.h +++ b/src/widgets/kernel/qwidgetwindow_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWIDGETWINDOW_P_H #define QWIDGETWINDOW_P_H @@ -74,7 +38,7 @@ public: ~QWidgetWindow(); QWidget *widget() const { return m_widget; } -#ifndef QT_NO_ACCESSIBILITY +#if QT_CONFIG(accessibility) QAccessibleInterface *accessibleRoot() const override; #endif diff --git a/src/widgets/kernel/qwindowcontainer.cpp b/src/widgets/kernel/qwindowcontainer.cpp index 5484544444..072a0bc5fa 100644 --- a/src/widgets/kernel/qwindowcontainer.cpp +++ b/src/widgets/kernel/qwindowcontainer.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwindowcontainer_p.h" #include "qwidget_p.h" @@ -52,6 +16,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + class QWindowContainerPrivate : public QWidgetPrivate { public: @@ -204,8 +170,6 @@ QWidget *QWidget::createWindowContainer(QWindow *window, QWidget *parent, Qt::Wi return new QWindowContainer(window, parent, flags); } - - /*! \internal */ @@ -219,21 +183,15 @@ QWindowContainer::QWindowContainer(QWindow *embeddedWindow, QWidget *parent, Qt: return; } - // The embedded QWindow must use the same logic as QWidget when it comes to the surface type. - // Otherwise we may end up with BadMatch failures on X11. - if (embeddedWindow->surfaceType() == QSurface::RasterSurface - && QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RasterGLSurface) - && !QCoreApplication::testAttribute(Qt::AA_ForceRasterWidgets)) - embeddedWindow->setSurfaceType(QSurface::RasterGLSurface); - d->window = embeddedWindow; QString windowName = d->window->objectName(); if (windowName.isEmpty()) windowName = QString::fromUtf8(d->window->metaObject()->className()); - d->fakeParent.setObjectName(windowName + QLatin1String("ContainerFakeParent")); + d->fakeParent.setObjectName(windowName + "ContainerFakeParent"_L1); d->window->setParent(&d->fakeParent); + d->window->parent()->installEventFilter(this); d->window->setFlag(Qt::SubWindow); setAcceptDrops(true); @@ -286,6 +244,26 @@ void QWindowContainer::focusWindowChanged(QWindow *focusWindow) \internal */ +bool QWindowContainer::eventFilter(QObject *o, QEvent *e) +{ + Q_D(QWindowContainer); + if (!d->window) + return false; + + if (e->type() == QEvent::ChildRemoved) { + QChildEvent *ce = static_cast<QChildEvent *>(e); + if (ce->child() == d->window) { + o->removeEventFilter(this); + d->window = nullptr; + } + } + return false; +} + +/*! + \internal + */ + bool QWindowContainer::event(QEvent *e) { Q_D(QWindowContainer); @@ -294,12 +272,6 @@ bool QWindowContainer::event(QEvent *e) QEvent::Type type = e->type(); switch (type) { - case QEvent::ChildRemoved: { - QChildEvent *ce = static_cast<QChildEvent *>(e); - if (ce->child() == d->window) - d->window = nullptr; - break; - } // The only thing we are interested in is making sure our sizes stay // in sync, so do a catch-all case. case QEvent::Resize: @@ -314,10 +286,13 @@ bool QWindowContainer::event(QEvent *e) case QEvent::Show: d->updateUsesNativeWidgets(); if (d->isStillAnOrphan()) { + d->window->parent()->removeEventFilter(this); d->window->setParent(d->usesNativeWidgets ? windowHandle() : window()->windowHandle()); d->fakeParent.destroy(); + if (d->window->parent()) + d->window->parent()->installEventFilter(this); } if (d->window->parent()) { d->markParentChain(); @@ -388,7 +363,10 @@ static void qwindowcontainer_traverse(QWidget *parent, qwindowcontainer_traverse void QWindowContainer::toplevelAboutToBeDestroyed(QWidget *parent) { if (QWindowContainerPrivate *d = QWindowContainerPrivate::get(parent)) { + if (d->window->parent()) + d->window->parent()->removeEventFilter(parent); d->window->setParent(&d->fakeParent); + d->window->parent()->installEventFilter(parent); } qwindowcontainer_traverse(parent, toplevelAboutToBeDestroyed); } @@ -406,7 +384,9 @@ void QWindowContainer::parentWasChanged(QWidget *parent) tld->createTLSysExtra(); Q_ASSERT(toplevel->windowHandle()); } + d->window->parent()->removeEventFilter(parent); d->window->setParent(toplevel->windowHandle()); + toplevel->windowHandle()->installEventFilter(parent); d->fakeParent.destroy(); d->updateGeometry(); } diff --git a/src/widgets/kernel/qwindowcontainer_p.h b/src/widgets/kernel/qwindowcontainer_p.h index 72474077aa..8dc5c64af4 100644 --- a/src/widgets/kernel/qwindowcontainer_p.h +++ b/src/widgets/kernel/qwindowcontainer_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWINDOWCONTAINER_H #define QWINDOWCONTAINER_H @@ -76,6 +40,7 @@ public: protected: bool event(QEvent *ev) override; + bool eventFilter(QObject *, QEvent *ev) override; private slots: void focusWindowChanged(QWindow *focusWindow); |