summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel')
-rw-r--r--src/gui/kernel/qaction.cpp128
-rw-r--r--src/gui/kernel/qaction.h66
-rw-r--r--src/gui/kernel/qaction_p.h42
-rw-r--r--src/gui/kernel/qactiongroup.cpp46
-rw-r--r--src/gui/kernel/qactiongroup.h40
-rw-r--r--src/gui/kernel/qactiongroup_p.h42
-rw-r--r--src/gui/kernel/qclipboard.cpp66
-rw-r--r--src/gui/kernel/qclipboard.h40
-rw-r--r--src/gui/kernel/qcursor.cpp77
-rw-r--r--src/gui/kernel/qcursor.h46
-rw-r--r--src/gui/kernel/qcursor_p.h40
-rw-r--r--src/gui/kernel/qdnd.cpp42
-rw-r--r--src/gui/kernel/qdnd_p.h42
-rw-r--r--src/gui/kernel/qdrag.cpp46
-rw-r--r--src/gui/kernel/qdrag.h40
-rw-r--r--src/gui/kernel/qevent.cpp765
-rw-r--r--src/gui/kernel/qevent.h293
-rw-r--r--src/gui/kernel/qevent_p.h45
-rw-r--r--src/gui/kernel/qeventpoint.cpp149
-rw-r--r--src/gui/kernel/qeventpoint.h44
-rw-r--r--src/gui/kernel/qeventpoint_p.h136
-rw-r--r--src/gui/kernel/qgenericplugin.cpp42
-rw-r--r--src/gui/kernel/qgenericplugin.h40
-rw-r--r--src/gui/kernel/qgenericpluginfactory.cpp51
-rw-r--r--src/gui/kernel/qgenericpluginfactory.h40
-rw-r--r--src/gui/kernel/qguiapplication.cpp886
-rw-r--r--src/gui/kernel/qguiapplication.h55
-rw-r--r--src/gui/kernel/qguiapplication_p.h129
-rw-r--r--src/gui/kernel/qguiapplication_platform.h68
-rw-r--r--src/gui/kernel/qguivariant.cpp54
-rw-r--r--src/gui/kernel/qhighdpiscaling.cpp102
-rw-r--r--src/gui/kernel/qhighdpiscaling_p.h56
-rw-r--r--src/gui/kernel/qinputdevice.cpp111
-rw-r--r--src/gui/kernel/qinputdevice.h45
-rw-r--r--src/gui/kernel/qinputdevice_p.h41
-rw-r--r--src/gui/kernel/qinputdevicemanager.cpp46
-rw-r--r--src/gui/kernel/qinputdevicemanager_p.h48
-rw-r--r--src/gui/kernel/qinputdevicemanager_p_p.h40
-rw-r--r--src/gui/kernel/qinputmethod.cpp62
-rw-r--r--src/gui/kernel/qinputmethod.h43
-rw-r--r--src/gui/kernel/qinputmethod_p.h40
-rw-r--r--src/gui/kernel/qinternalmimedata.cpp72
-rw-r--r--src/gui/kernel/qinternalmimedata_p.h40
-rw-r--r--src/gui/kernel/qkeymapper.cpp121
-rw-r--r--src/gui/kernel/qkeymapper_p.h68
-rw-r--r--src/gui/kernel/qkeysequence.cpp344
-rw-r--r--src/gui/kernel/qkeysequence.h52
-rw-r--r--src/gui/kernel/qkeysequence_p.h53
-rw-r--r--src/gui/kernel/qoffscreensurface.cpp59
-rw-r--r--src/gui/kernel/qoffscreensurface.h44
-rw-r--r--src/gui/kernel/qoffscreensurface_p.h40
-rw-r--r--src/gui/kernel/qoffscreensurface_platform.h51
-rw-r--r--src/gui/kernel/qopenglcontext.cpp130
-rw-r--r--src/gui/kernel/qopenglcontext.h48
-rw-r--r--src/gui/kernel/qopenglcontext_p.h52
-rw-r--r--src/gui/kernel/qopenglcontext_platform.h64
-rw-r--r--src/gui/kernel/qpaintdevicewindow.cpp50
-rw-r--r--src/gui/kernel/qpaintdevicewindow.h40
-rw-r--r--src/gui/kernel/qpaintdevicewindow_p.h47
-rw-r--r--src/gui/kernel/qpalette.cpp282
-rw-r--r--src/gui/kernel/qpalette.h51
-rw-r--r--src/gui/kernel/qpalette_p.h77
-rw-r--r--src/gui/kernel/qpixelformat.cpp42
-rw-r--r--src/gui/kernel/qpixelformat.h40
-rw-r--r--src/gui/kernel/qplatformclipboard.cpp40
-rw-r--r--src/gui/kernel/qplatformclipboard.h40
-rw-r--r--src/gui/kernel/qplatformcursor.cpp46
-rw-r--r--src/gui/kernel/qplatformcursor.h40
-rw-r--r--src/gui/kernel/qplatformdialoghelper.cpp152
-rw-r--r--src/gui/kernel/qplatformdialoghelper.h95
-rw-r--r--src/gui/kernel/qplatformdrag.cpp40
-rw-r--r--src/gui/kernel/qplatformdrag.h40
-rw-r--r--src/gui/kernel/qplatformgraphicsbuffer.cpp42
-rw-r--r--src/gui/kernel/qplatformgraphicsbuffer.h40
-rw-r--r--src/gui/kernel/qplatformgraphicsbufferhelper.cpp44
-rw-r--r--src/gui/kernel/qplatformgraphicsbufferhelper.h40
-rw-r--r--src/gui/kernel/qplatforminputcontext.cpp60
-rw-r--r--src/gui/kernel/qplatforminputcontext.h42
-rw-r--r--src/gui/kernel/qplatforminputcontext_p.h40
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory.cpp81
-rw-r--r--src/gui/kernel/qplatforminputcontextfactory_p.h43
-rw-r--r--src/gui/kernel/qplatforminputcontextplugin.cpp42
-rw-r--r--src/gui/kernel/qplatforminputcontextplugin_p.h40
-rw-r--r--src/gui/kernel/qplatformintegration.cpp103
-rw-r--r--src/gui/kernel/qplatformintegration.h61
-rw-r--r--src/gui/kernel/qplatformintegrationfactory.cpp83
-rw-r--r--src/gui/kernel/qplatformintegrationfactory_p.h40
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.cpp42
-rw-r--r--src/gui/kernel/qplatformintegrationplugin.h40
-rw-r--r--src/gui/kernel/qplatformkeymapper.cpp38
-rw-r--r--src/gui/kernel/qplatformkeymapper.h36
-rw-r--r--src/gui/kernel/qplatformmenu.cpp44
-rw-r--r--src/gui/kernel/qplatformmenu.h49
-rw-r--r--src/gui/kernel/qplatformmenu_p.h44
-rw-r--r--src/gui/kernel/qplatformnativeinterface.cpp44
-rw-r--r--src/gui/kernel/qplatformnativeinterface.h40
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.cpp40
-rw-r--r--src/gui/kernel/qplatformoffscreensurface.h40
-rw-r--r--src/gui/kernel/qplatformopenglcontext.cpp56
-rw-r--r--src/gui/kernel/qplatformopenglcontext.h43
-rw-r--r--src/gui/kernel/qplatformscreen.cpp58
-rw-r--r--src/gui/kernel/qplatformscreen.h46
-rw-r--r--src/gui/kernel/qplatformscreen_p.h47
-rw-r--r--src/gui/kernel/qplatformservices.cpp66
-rw-r--r--src/gui/kernel/qplatformservices.h60
-rw-r--r--src/gui/kernel/qplatformsessionmanager.cpp44
-rw-r--r--src/gui/kernel/qplatformsessionmanager.h44
-rw-r--r--src/gui/kernel/qplatformsharedgraphicscache.cpp42
-rw-r--r--src/gui/kernel/qplatformsharedgraphicscache.h40
-rw-r--r--src/gui/kernel/qplatformsurface.cpp51
-rw-r--r--src/gui/kernel/qplatformsurface.h42
-rw-r--r--src/gui/kernel/qplatformsystemtrayicon.cpp42
-rw-r--r--src/gui/kernel/qplatformsystemtrayicon.h45
-rw-r--r--src/gui/kernel/qplatformtheme.cpp213
-rw-r--r--src/gui/kernel/qplatformtheme.h77
-rw-r--r--src/gui/kernel/qplatformtheme_p.h42
-rw-r--r--src/gui/kernel/qplatformthemefactory.cpp91
-rw-r--r--src/gui/kernel/qplatformthemefactory_p.h40
-rw-r--r--src/gui/kernel/qplatformthemeplugin.cpp42
-rw-r--r--src/gui/kernel/qplatformthemeplugin.h40
-rw-r--r--src/gui/kernel/qplatformwindow.cpp84
-rw-r--r--src/gui/kernel/qplatformwindow.h41
-rw-r--r--src/gui/kernel/qplatformwindow_p.h92
-rw-r--r--src/gui/kernel/qpointingdevice.cpp139
-rw-r--r--src/gui/kernel/qpointingdevice.h48
-rw-r--r--src/gui/kernel/qpointingdevice_p.h45
-rw-r--r--src/gui/kernel/qrasterwindow.cpp58
-rw-r--r--src/gui/kernel/qrasterwindow.h41
-rw-r--r--src/gui/kernel/qscreen.cpp256
-rw-r--r--src/gui/kernel/qscreen.h56
-rw-r--r--src/gui/kernel/qscreen_p.h74
-rw-r--r--src/gui/kernel/qscreen_platform.h61
-rw-r--r--src/gui/kernel/qsessionmanager.cpp50
-rw-r--r--src/gui/kernel/qsessionmanager.h40
-rw-r--r--src/gui/kernel/qsessionmanager_p.h44
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow.cpp48
-rw-r--r--src/gui/kernel/qshapedpixmapdndwindow_p.h40
-rw-r--r--src/gui/kernel/qshortcut.cpp52
-rw-r--r--src/gui/kernel/qshortcut.h47
-rw-r--r--src/gui/kernel/qshortcut_p.h42
-rw-r--r--src/gui/kernel/qshortcutmap.cpp238
-rw-r--r--src/gui/kernel/qshortcutmap_p.h41
-rw-r--r--src/gui/kernel/qsimpledrag.cpp52
-rw-r--r--src/gui/kernel/qsimpledrag_p.h40
-rw-r--r--src/gui/kernel/qstylehints.cpp128
-rw-r--r--src/gui/kernel/qstylehints.h75
-rw-r--r--src/gui/kernel/qstylehints_p.h54
-rw-r--r--src/gui/kernel/qsurface.cpp53
-rw-r--r--src/gui/kernel/qsurface.h42
-rw-r--r--src/gui/kernel/qsurfaceformat.cpp47
-rw-r--r--src/gui/kernel/qsurfaceformat.h40
-rw-r--r--src/gui/kernel/qt_gui_pch.h41
-rw-r--r--src/gui/kernel/qtestsupport_gui.cpp122
-rw-r--r--src/gui/kernel/qtestsupport_gui.h49
-rw-r--r--src/gui/kernel/qtguiglobal.h55
-rw-r--r--src/gui/kernel/qtguiglobal_p.h40
-rw-r--r--src/gui/kernel/qwindow.cpp503
-rw-r--r--src/gui/kernel/qwindow.h61
-rw-r--r--src/gui/kernel/qwindow_p.h77
-rw-r--r--src/gui/kernel/qwindowdefs.h40
-rw-r--r--src/gui/kernel/qwindowdefs_win.h40
-rw-r--r--src/gui/kernel/qwindowsysteminterface.cpp563
-rw-r--r--src/gui/kernel/qwindowsysteminterface.h85
-rw-r--r--src/gui/kernel/qwindowsysteminterface_p.h76
164 files changed, 4522 insertions, 8521 deletions
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp
index 9c16123545..c67cfd53b1 100644
--- a/src/gui/kernel/qaction.cpp
+++ b/src/gui/kernel/qaction.cpp
@@ -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
#include "qaction.h"
#include "qactiongroup.h"
@@ -59,14 +23,16 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*
internal: guesses a descriptive text from a text suited for a menu entry
*/
static QString qt_strippedText(QString s)
{
- s.remove(QLatin1String("..."));
+ s.remove("..."_L1);
for (int i = 0; i < s.size(); ++i) {
- if (s.at(i) == QLatin1Char('&'))
+ if (s.at(i) == u'&')
s.remove(i, 1);
}
return s.trimmed();
@@ -115,26 +81,26 @@ void QActionPrivate::sendDataChanged()
void QActionPrivate::redoGrab(QShortcutMap &map)
{
Q_Q(QAction);
- for (int id : qAsConst(shortcutIds)) {
+ for (int id : std::as_const(shortcutIds)) {
if (id)
map.removeShortcut(id, q);
}
shortcutIds.clear();
- for (const QKeySequence &shortcut : qAsConst(shortcuts)) {
+ for (const QKeySequence &shortcut : std::as_const(shortcuts)) {
if (!shortcut.isEmpty())
shortcutIds.append(map.addShortcut(q, shortcut, shortcutContext, contextMatcher()));
else
shortcutIds.append(0);
}
if (!enabled) {
- for (int id : qAsConst(shortcutIds)) {
+ for (int id : std::as_const(shortcutIds)) {
if (id)
map.setShortcutEnabled(false, id, q);
}
}
if (!autorepeat) {
- for (int id : qAsConst(shortcutIds)) {
+ for (int id : std::as_const(shortcutIds)) {
if (id)
map.setShortcutAutoRepeat(false, id, q);
}
@@ -144,7 +110,7 @@ void QActionPrivate::redoGrab(QShortcutMap &map)
void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map)
{
Q_Q(QAction);
- for (int id : qAsConst(shortcutIds)) {
+ for (int id : std::as_const(shortcutIds)) {
if (id)
map.setShortcutEnabled(enable, id, q);
}
@@ -184,17 +150,18 @@ QObject *QActionPrivate::menu() const
user interface used, it is useful to represent each command as
an \e action.
- Actions can be added to menus and toolbars, and will
- automatically keep them in sync. For example, in a word processor,
- if the user presses a Bold toolbar button, the Bold menu item
+ Actions can be added to user interface elements such as menus and toolbars,
+ and will automatically keep the UI in sync. For example, in a word
+ processor, if the user presses a Bold toolbar button, the Bold menu item
will automatically be checked.
- A QAction may contain an icon, menu text, a shortcut, status text,
- "What's This?" text, and a tooltip. Most of these can be set in
- the constructor. They can also be set independently with
- setIcon(), setText(), setIconText(), setShortcut(),
- setStatusTip(), setWhatsThis(), and setToolTip(). For menu items,
- it is possible to set an individual font with setFont().
+ A QAction may contain an icon, descriptive text, icon text, a keyboard
+ shortcut, status text, "What's This?" text, and a tooltip. All properties
+ can be set independently with setIcon(), setText(), setIconText(),
+ setShortcut(), setStatusTip(), setWhatsThis(), and setToolTip(). Icon and
+ text, as the two most important properties, can also be set in the
+ constructor. It's possible to set an individual font with setFont(), which
+ e.g. menus respect when displaying the action as a menu item.
We recommend that actions are created as children of the window
they are used in. In most cases actions will be children of
@@ -204,9 +171,7 @@ QObject *QActionPrivate::menu() const
Once a QAction has been created, it should be added to the relevant
menu and toolbar, then connected to the slot which will perform
- the action. For example:
-
- \snippet ../widgets/mainwindows/application/mainwindow.cpp 19
+ the action.
Actions are added to widgets using QWidget::addAction() or
QGraphicsWidget::addAction(). Note that an action must be added to a
@@ -219,7 +184,7 @@ QObject *QActionPrivate::menu() const
use as menu items.
- \sa QMenu, QToolBar, {Qt Widgets - Application Example}
+ \sa QMenu, QToolBar
*/
/*!
@@ -272,13 +237,11 @@ QAction::QAction(QObject *parent)
parent is an action group the action will be automatically
inserted into the group.
- The action uses a stripped version of \a text (e.g. "\&Menu
- Option..." becomes "Menu Option") as descriptive text for
- tool buttons. You can override this by setting a specific
- description with setText(). The same text will be used for
- tooltips unless you specify a different text using
- setToolTip().
+ A stripped version of \a text (for example, "\&Menu Option..." becomes
+ "Menu Option") will be used for tooltips and icon text unless you specify a
+ different text using setToolTip() or setIconText(), respectively.
+ \sa text
*/
QAction::QAction(const QString &text, QObject *parent)
: QAction(parent)
@@ -292,12 +255,11 @@ QAction::QAction(const QString &text, QObject *parent)
parent. If \a parent is an action group the action will be
automatically inserted into the group.
- The action uses a stripped version of \a text (e.g. "\&Menu
- Option..." becomes "Menu Option") as descriptive text for
- tool buttons. You can override this by setting a specific
- description with setText(). The same text will be used for
- tooltips unless you specify a different text using
- setToolTip().
+ A stripped version of \a text (for example, "\&Menu Option..." becomes
+ "Menu Option") will be used for tooltips and icon text unless you specify a
+ different text using setToolTip() or setIconText(), respectively.
+
+ \sa text, icon
*/
QAction::QAction(const QIcon &icon, const QString &text, QObject *parent)
: QAction(text, parent)
@@ -492,7 +454,7 @@ QAction::~QAction()
d->group->removeAction(this);
#if QT_CONFIG(shortcut)
if (qApp) {
- for (int id : qAsConst(d->shortcutIds)) {
+ for (int id : std::as_const(d->shortcutIds)) {
if (id)
QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this);
}
@@ -548,14 +510,14 @@ QList<QObject*> QAction::associatedObjects() const
/*!
\fn QWidget *QAction::parentWidget() const
- \deprecated Use parent() with qobject_cast() instead.
+ \deprecated [6.0] Use parent() with qobject_cast() instead.
Returns the parent widget.
*/
/*!
\fn QList<QWidget*> QAction::associatedWidgets() const
- \deprecated Use associatedObjects() with qobject_cast() instead.
+ \deprecated [6.0] Use associatedObjects() with qobject_cast() instead.
Returns a list of widgets this action has been added to.
@@ -564,7 +526,7 @@ QList<QObject*> QAction::associatedObjects() const
/*!
\fn QList<QWidget*> QAction::associatedGraphicsWidgets() const
- \deprecated Use associatedObjects() with qobject_cast() instead.
+ \deprecated [6.0] Use associatedObjects() with qobject_cast() instead.
Returns a list of graphics widgets this action has been added to.
@@ -636,6 +598,14 @@ bool QAction::isSeparator() const
by using setText(), the action's description icon text will be
used as text. There is no default text.
+ Certain UI elements, such as menus or buttons, can use '&' in front of a
+ character to automatically create a mnemonic (a shortcut) for that
+ character. For example, "&File" for a menu will create the shortcut
+ \uicontrol Alt+F, which will open the File menu. "E&xit" will create the
+ shortcut \uicontrol Alt+X for a button, or in a menu allow navigating to
+ the menu item by pressing "x". (use '&&' to display an actual ampersand).
+ The widget might consume and perform an action on a given shortcut.
+
\sa iconText
*/
void QAction::setText(const QString &text)
@@ -654,7 +624,7 @@ QString QAction::text() const
QString s = d->text;
if (s.isEmpty()) {
s = d->iconText;
- s.replace(QLatin1Char('&'), QLatin1String("&&"));
+ s.replace(u'&', "&&"_L1);
}
return s;
}
@@ -1058,7 +1028,7 @@ bool QAction::event(QEvent *e)
{
Q_D(QAction);
if (e->type() == QEvent::ActionChanged) {
- for (auto object : qAsConst(d->associatedObjects))
+ for (auto object : std::as_const(d->associatedObjects))
QCoreApplication::sendEvent(object, e);
}
@@ -1225,14 +1195,13 @@ QAction::MenuRole QAction::menuRole() const
/*!
\fn QMenu *QAction::menu() const
- \deprecated
Returns the menu contained by this action.
In widget applications, actions that contain menus can be used to create menu
items with submenus, or inserted into toolbars to create buttons with popup menus.
- \sa QMenu::addAction()
+ \sa QMenu::addAction(), QMenu::menuInAction()
*/
QObject* QAction::menuObject() const
{
@@ -1242,7 +1211,6 @@ QObject* QAction::menuObject() const
/*!
\fn void QAction::setMenu(QMenu *menu)
- \deprecated
Sets the menu contained by this action to the specified \a menu.
*/
@@ -1262,7 +1230,7 @@ void QAction::setMenuObject(QObject *object)
The default is to follow whether the Qt::AA_DontShowIconsInMenus attribute
is set for the application. Explicitly settings this property overrides
- the presence (or abscence) of the attribute.
+ the presence (or absence) of the attribute.
For example:
\snippet code/src_gui_kernel_qaction.cpp 0
diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h
index 865e5c5eb0..d805599138 100644
--- a/src/gui/kernel/qaction.h
+++ b/src/gui/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 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_H
#define QACTION_H
@@ -47,6 +11,7 @@
#include <QtGui/qicon.h>
#include <QtCore/qstring.h>
#include <QtCore/qvariant.h>
+#include <QtCore/qobject.h>
QT_REQUIRE_CONFIG(action);
@@ -55,10 +20,10 @@ QT_BEGIN_NAMESPACE
class QActionEvent;
class QActionGroup;
class QActionPrivate;
+class QMenu;
#if QT_DEPRECATED_SINCE(6,0)
class QWidget;
class QGraphicsWidget;
-class QMenu;
#endif
class Q_GUI_EXPORT QAction : public QObject
@@ -68,7 +33,8 @@ class Q_GUI_EXPORT QAction : public QObject
Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable NOTIFY checkableChanged FINAL)
Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY toggled)
- Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged RESET resetEnabled FINAL)
+ Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged
+ RESET resetEnabled FINAL)
Q_PROPERTY(QIcon icon READ icon WRITE setIcon NOTIFY changed)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY changed)
Q_PROPERTY(QString iconText READ iconText WRITE setIconText NOTIFY changed)
@@ -78,14 +44,17 @@ class Q_GUI_EXPORT QAction : public QObject
Q_PROPERTY(QFont font READ font WRITE setFont NOTIFY changed)
#if QT_CONFIG(shortcut)
Q_PROPERTY(QKeySequence shortcut READ shortcut WRITE setShortcut NOTIFY changed)
- Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext NOTIFY changed)
+ Q_PROPERTY(Qt::ShortcutContext shortcutContext READ shortcutContext WRITE setShortcutContext
+ NOTIFY changed)
Q_PROPERTY(bool autoRepeat READ autoRepeat WRITE setAutoRepeat NOTIFY changed)
#endif // QT_CONFIG(shortcut)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL)
Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole NOTIFY changed)
- Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu NOTIFY changed)
- Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu WRITE setShortcutVisibleInContextMenu NOTIFY changed)
- Q_PROPERTY(Priority priority READ priority WRITE setPriority)
+ Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu
+ NOTIFY changed)
+ Q_PROPERTY(bool shortcutVisibleInContextMenu READ isShortcutVisibleInContextMenu
+ WRITE setShortcutVisibleInContextMenu NOTIFY changed)
+ Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY changed)
public:
// note this is copied into qplatformmenu.h, which must stay in sync
@@ -105,7 +74,7 @@ public:
QList<QObject *> associatedObjects() const;
#if QT_DEPRECATED_SINCE(6,0)
-#ifdef Q_CLANG_QDOC
+#ifdef Q_QDOC
QWidget *parentWidget() const;
QList<QWidget*> associatedWidgets() const;
QList<QGraphicsWidget*> associatedGraphicsWidgets() const;
@@ -115,6 +84,7 @@ public:
QWidget, QMenu, and QGraphicsWidget can be expected to be fully defined.
*/
template<typename T = QWidget*>
+ QT_DEPRECATED_VERSION_X_6_0("Use parent() with qobject_cast() instead")
T parentWidget() const
{
auto result = parent();
@@ -124,6 +94,7 @@ public:
}
template<typename T = QWidget*>
+ QT_DEPRECATED_VERSION_X_6_0("Use associatedObjects() with qobject_cast() instead")
QList<T> associatedWidgets() const
{
QList<T> result;
@@ -133,6 +104,7 @@ public:
return result;
}
template<typename T = QGraphicsWidget*>
+ QT_DEPRECATED_VERSION_X_6_0("Use associatedObjects() with qobject_cast() instead")
QList<T> associatedGraphicsWidgets() const
{
QList<T> result;
@@ -206,8 +178,7 @@ public:
void setMenuRole(MenuRole menuRole);
MenuRole menuRole() const;
-#if QT_DEPRECATED_SINCE(6,0)
-#ifdef Q_CLANG_QDOC
+#ifdef Q_QDOC
QMenu *menu() const;
void setMenu(QMenu *menu);
#else
@@ -222,7 +193,6 @@ public:
setMenuObject(m);
}
#endif
-#endif
void setIconVisibleInMenu(bool visible);
bool isIconVisibleInMenu() const;
diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h
index 77dc450a9f..e79cc26b4d 100644
--- a/src/gui/kernel/qaction_p.h
+++ b/src/gui/kernel/qaction_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 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_P_H
#define QACTION_P_H
@@ -57,6 +21,8 @@
#if QT_CONFIG(shortcut)
# include <QtGui/private/qshortcutmap_p.h>
#endif
+
+#include <QtCore/qpointer.h>
#include "private/qobject_p.h"
QT_REQUIRE_CONFIG(action);
diff --git a/src/gui/kernel/qactiongroup.cpp b/src/gui/kernel/qactiongroup.cpp
index 33f9b54ddc..7fb5b4ad46 100644
--- a/src/gui/kernel/qactiongroup.cpp
+++ b/src/gui/kernel/qactiongroup.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 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 "qactiongroup.h"
@@ -313,7 +277,7 @@ void QActionGroup::setEnabled(bool b)
{
Q_D(QActionGroup);
d->enabled = b;
- for (auto action : qAsConst(d->actions)) {
+ for (auto action : std::as_const(d->actions)) {
action->d_func()->setEnabled(b, true);
}
}
@@ -347,7 +311,7 @@ void QActionGroup::setVisible(bool b)
{
Q_D(QActionGroup);
d->visible = b;
- for (auto action : qAsConst(d->actions)) {
+ for (auto action : std::as_const(d->actions)) {
if (!action->d_func()->forceInvisible)
action->d_func()->setVisible(b);
}
@@ -360,3 +324,5 @@ bool QActionGroup::isVisible() const
}
QT_END_NAMESPACE
+
+#include "moc_qactiongroup.cpp"
diff --git a/src/gui/kernel/qactiongroup.h b/src/gui/kernel/qactiongroup.h
index 9ac8743629..d0830aeccb 100644
--- a/src/gui/kernel/qactiongroup.h
+++ b/src/gui/kernel/qactiongroup.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 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 QACTIONGROUP_H
#define QACTIONGROUP_H
diff --git a/src/gui/kernel/qactiongroup_p.h b/src/gui/kernel/qactiongroup_p.h
index 4b503783ed..ba939a2b10 100644
--- a/src/gui/kernel/qactiongroup_p.h
+++ b/src/gui/kernel/qactiongroup_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 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 QGUIACTIONGROUP_P_H
#define QGUIACTIONGROUP_P_H
@@ -57,6 +21,8 @@
#if QT_CONFIG(shortcut)
# include <QtGui/private/qshortcutmap_p.h>
#endif
+
+#include <QtCore/qpointer.h>
#include "private/qobject_p.h"
QT_REQUIRE_CONFIG(action);
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp
index 87fd222cb8..6a36862a04 100644
--- a/src/gui/kernel/qclipboard.cpp
+++ b/src/gui/kernel/qclipboard.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qclipboard.h"
@@ -54,6 +18,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QClipboard
\brief The QClipboard class provides access to the window system clipboard.
@@ -137,6 +103,10 @@ QT_BEGIN_NAMESPACE
\endlist
+ \section1 Notes for Android Users
+
+ On Android only these mime types are supported: text/plain, text/html, and text/uri-list.
+
\sa QGuiApplication
*/
@@ -270,22 +240,23 @@ QString QClipboard::text(QString &subtype, Mode mode) const
const QStringList formats = data->formats();
if (subtype.isEmpty()) {
- if (formats.contains(QLatin1String("text/plain")))
- subtype = QLatin1String("plain");
+ if (formats.contains("text/plain"_L1))
+ subtype = "plain"_L1;
else {
- for (int i = 0; i < formats.size(); ++i)
- if (formats.at(i).startsWith(QLatin1String("text/"))) {
- subtype = formats.at(i).mid(5);
+ for (const auto &format : formats) {
+ if (format.startsWith("text/"_L1)) {
+ subtype = format.sliced(5);
break;
}
+ }
if (subtype.isEmpty())
return QString();
}
- } else if (!formats.contains(QLatin1String("text/") + subtype)) {
+ } else if (!formats.contains("text/"_L1 + subtype)) {
return QString();
}
- const QByteArray rawData = data->data(QLatin1String("text/") + subtype);
+ const QByteArray rawData = data->data("text/"_L1 + subtype);
auto encoding = QStringConverter::encodingForData(rawData);
if (!encoding)
encoding = QStringConverter::Utf8;
@@ -582,12 +553,13 @@ void QClipboard::emitChanged(Mode mode)
case FindBuffer:
emit findBufferChanged();
break;
- default:
- break;
}
+
emit changed(mode);
}
QT_END_NAMESPACE
+#include "moc_qclipboard.cpp"
+
#endif // QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qclipboard.h b/src/gui/kernel/qclipboard.h
index e91444d3dc..42b8bad026 100644
--- a/src/gui/kernel/qclipboard.h
+++ b/src/gui/kernel/qclipboard.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QCLIPBOARD_H
#define QCLIPBOARD_H
diff --git a/src/gui/kernel/qcursor.cpp b/src/gui/kernel/qcursor.cpp
index 20511ef8e6..8e7747559a 100644
--- a/src/gui/kernel/qcursor.cpp
+++ b/src/gui/kernel/qcursor.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 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) 2021 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 "qcursor.h"
@@ -150,7 +114,7 @@ QT_BEGIN_NAMESPACE
\li Qt::DragLinkCursor \li \c dnd-link or \c link
\endtable
- \sa QWidget, {fowler}{GUI Design Handbook: Cursors}
+ \sa QWidget
*/
/*!
@@ -251,7 +215,8 @@ void QCursor::setPos(QScreen *screen, int x, int y)
{
if (screen) {
if (QPlatformCursor *cursor = screen->handle()->cursor()) {
- const QPoint devicePos = QHighDpi::toNativePixels(QPoint(x, y), screen);
+ const QPoint pos(x, y);
+ const QPoint devicePos = QHighDpi::toNativePixels(pos, screen->virtualSiblingAt(pos));
// Need to check, since some X servers generate null mouse move
// events, causing looping in applications which call setPos() on
// every mouse move event.
@@ -325,7 +290,7 @@ QDataStream &operator<<(QDataStream &s, const QCursor &c)
if (isPixmap)
s << c.pixmap();
else
- s << c.bitmap(Qt::ReturnByValue) << c.mask(Qt::ReturnByValue);
+ s << c.bitmap() << c.mask();
s << c.hotSpot();
}
return s;
@@ -474,8 +439,7 @@ QCursor::QCursor()
QCursor::QCursor(Qt::CursorShape shape)
: d(nullptr)
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
setShape(shape);
}
@@ -533,8 +497,7 @@ bool operator==(const QCursor &lhs, const QCursor &rhs) noexcept
*/
Qt::CursorShape QCursor::shape() const
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
return d->cshape;
}
@@ -547,8 +510,7 @@ Qt::CursorShape QCursor::shape() const
*/
void QCursor::setShape(Qt::CursorShape shape)
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
QCursorData *c = uint(shape) <= Qt::LastCursor ? qt_cursorTable[shape] : nullptr;
if (!c)
c = qt_cursorTable[0];
@@ -582,8 +544,7 @@ void QCursor::setShape(Qt::CursorShape shape)
*/
QBitmap QCursor::bitmap() const
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
if (d->bm)
return *(d->bm);
return QBitmap();
@@ -609,8 +570,7 @@ QBitmap QCursor::bitmap() const
*/
QBitmap QCursor::mask() const
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
if (d->bmm)
return *(d->bmm);
return QBitmap();
@@ -623,8 +583,7 @@ QBitmap QCursor::mask() const
QPixmap QCursor::pixmap() const
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
return d->pixmap;
}
@@ -635,8 +594,7 @@ QPixmap QCursor::pixmap() const
QPoint QCursor::hotSpot() const
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
return QPoint(d->hx, d->hy);
}
@@ -646,8 +604,7 @@ QPoint QCursor::hotSpot() const
QCursor::QCursor(const QCursor &c)
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
d = c.d;
d->ref.ref();
}
@@ -670,8 +627,7 @@ QCursor::~QCursor()
QCursor &QCursor::operator=(const QCursor &c)
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
if (c.d)
c.d->ref.ref();
if (d && !d->ref.deref())
@@ -742,8 +698,7 @@ void QCursorData::initialize()
QCursorData *QCursorData::setBitmap(const QBitmap &bitmap, const QBitmap &mask, int hotX, int hotY, qreal devicePixelRatio)
{
- if (!QCursorData::initialized)
- QCursorData::initialize();
+ QCursorData::initialize();
if (bitmap.depth() != 1 || mask.depth() != 1 || bitmap.size() != mask.size()) {
qWarning("QCursor: Cannot create bitmap cursor; invalid bitmap(s)");
QCursorData *c = qt_cursorTable[0];
diff --git a/src/gui/kernel/qcursor.h b/src/gui/kernel/qcursor.h
index c1d45cc41b..3aeef52094 100644
--- a/src/gui/kernel/qcursor.h
+++ b/src/gui/kernel/qcursor.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QCURSOR_H
#define QCURSOR_H
@@ -87,10 +51,10 @@ public:
QCursor(const QCursor &cursor);
~QCursor();
QCursor &operator=(const QCursor &cursor);
- QCursor(QCursor &&other) noexcept : d(qExchange(other.d, nullptr)) {}
+ QCursor(QCursor &&other) noexcept : d(std::exchange(other.d, nullptr)) {}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_MOVE_AND_SWAP(QCursor)
- void swap(QCursor &other) noexcept { qSwap(d, other.d); }
+ void swap(QCursor &other) noexcept { qt_ptr_swap(d, other.d); }
operator QVariant() const;
@@ -98,7 +62,9 @@ public:
void setShape(Qt::CursorShape newShape);
#if QT_DEPRECATED_SINCE(6, 0)
+ QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
QBitmap bitmap(Qt::ReturnByValueConstant) const { return bitmap(); }
+ QT_DEPRECATED_VERSION_X_6_0("Use the overload without argument instead.")
QBitmap mask(Qt::ReturnByValueConstant) const { return mask(); }
#endif // QT_DEPRECATED_SINCE(6, 0)
QBitmap bitmap() const;
diff --git a/src/gui/kernel/qcursor_p.h b/src/gui/kernel/qcursor_p.h
index 37245a793f..52ea15b59a 100644
--- a/src/gui/kernel/qcursor_p.h
+++ b/src/gui/kernel/qcursor_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 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) 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 QCURSOR_P_H
#define QCURSOR_P_H
diff --git a/src/gui/kernel/qdnd.cpp b/src/gui/kernel/qdnd.cpp
index fe766c900e..248a1e83ed 100644
--- a/src/gui/kernel/qdnd.cpp
+++ b/src/gui/kernel/qdnd.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qdnd_p.h"
@@ -123,3 +87,5 @@ Qt::DropAction QDragManager::drag(QDrag *o)
}
QT_END_NAMESPACE
+
+#include "moc_qdnd_p.cpp"
diff --git a/src/gui/kernel/qdnd_p.h b/src/gui/kernel/qdnd_p.h
index abb30986a5..b5a2e015f4 100644
--- a/src/gui/kernel/qdnd_p.h
+++ b/src/gui/kernel/qdnd_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 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) 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 QDND_P_H
#define QDND_P_H
@@ -63,6 +27,8 @@
#include "private/qobject_p.h"
#include "QtGui/qbackingstore.h"
+#include <QtCore/qpointer.h>
+
QT_REQUIRE_CONFIG(draganddrop);
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qdrag.cpp b/src/gui/kernel/qdrag.cpp
index 330be0ac8a..4e707e4915 100644
--- a/src/gui/kernel/qdrag.cpp
+++ b/src/gui/kernel/qdrag.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qdrag.h>
#include "private/qguiapplication_p.h"
@@ -45,6 +9,8 @@
#include <qpoint.h>
#include "qdnd_p.h"
+#include <QtCore/qpointer.h>
+
QT_BEGIN_NAMESPACE
/*!
@@ -100,7 +66,7 @@ QT_BEGIN_NAMESPACE
required.
\sa {Drag and Drop}, QClipboard, QMimeData, {Draggable Icons Example},
- {Draggable Text Example}, {Drop Site Example}, {Fridge Magnets Example}
+ {Draggable Text Example}, {Drop Site Example}
*/
/*!
@@ -392,3 +358,5 @@ void QDrag::cancel()
*/
QT_END_NAMESPACE
+
+#include "moc_qdrag.cpp"
diff --git a/src/gui/kernel/qdrag.h b/src/gui/kernel/qdrag.h
index eaa677b50d..65314fd20c 100644
--- a/src/gui/kernel/qdrag.h
+++ b/src/gui/kernel/qdrag.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QDRAG_H
#define QDRAG_H
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 4e6de35c94..d8c11d72a6 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -1,49 +1,16 @@
-/****************************************************************************
-**
-** 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
#include "qevent.h"
+
#include "qcursor.h"
#include "private/qguiapplication_p.h"
#include "private/qinputdevice_p.h"
#include "private/qpointingdevice_p.h"
#include "qpa/qplatformintegration.h"
#include "private/qevent_p.h"
+#include "private/qeventpoint_p.h"
+
#include "qfile.h"
#include "qhashfunctions.h"
#include "qmetaobject.h"
@@ -51,14 +18,35 @@
#include "qevent_p.h"
#include "qmath.h"
#include "qloggingcategory.h"
+#include "qpointer.h"
#if QT_CONFIG(draganddrop)
#include <qpa/qplatformdrag.h>
#include <private/qdnd_p.h>
#endif
+#if QT_CONFIG(shortcut)
+#include <private/qshortcut_p.h>
+#endif
+
#include <private/qdebug_p.h>
+#define Q_IMPL_POINTER_EVENT(Class) \
+ Class::Class(const Class &) = default; \
+ Class::~Class() = default; \
+ Class* Class::clone() const \
+ { \
+ auto c = new Class(*this); \
+ for (auto &point : c->m_points) \
+ QMutableEventPoint::detach(point); \
+ QEvent *e = c; \
+ /* check that covariant return is safe to add */ \
+ Q_ASSERT(reinterpret_cast<quintptr>(c) == reinterpret_cast<quintptr>(e)); \
+ return c; \
+ }
+
+
+
QT_BEGIN_NAMESPACE
static_assert(sizeof(QMutableTouchEvent) == sizeof(QTouchEvent));
@@ -90,55 +78,59 @@ QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const
{
}
-/*!
- \internal
-*/
-QEnterEvent::~QEnterEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QEnterEvent)
/*!
\fn QPoint QEnterEvent::globalPos() const
+ \deprecated [6.0] Use globalPosition() instead.
Returns the global position of the mouse cursor \e{at the time of the event}.
*/
/*!
\fn int QEnterEvent::globalX() const
+ \deprecated [6.0] Use globalPosition().x() instead.
Returns the global position on the X-axis of the mouse cursor \e{at the time of the event}.
*/
/*!
\fn int QEnterEvent::globalY() const
+ \deprecated [6.0] Use globalPosition().y() instead.
Returns the global position on the Y-axis of the mouse cursor \e{at the time of the event}.
*/
/*!
\fn QPointF QEnterEvent::localPos() const
+ \deprecated [6.0] Use position() instead.
Returns the mouse cursor's position relative to the receiving widget.
*/
/*!
\fn QPoint QEnterEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the mouse cursor relative to the receiving widget.
*/
/*!
\fn QPointF QEnterEvent::screenPos() const
+ \deprecated [6.0] Use globalPosition() instead.
Returns the position of the mouse cursor relative to the receiving screen.
*/
/*!
\fn QPointF QEnterEvent::windowPos() const
+ \deprecated [6.0] Use scenePosition() instead.
Returns the position of the mouse cursor relative to the receiving window.
*/
/*!
\fn int QEnterEvent::x() const
+ \deprecated [6.0] Use position().x() instead.
Returns the x position of the mouse cursor relative to the receiving widget.
*/
/*!
\fn int QEnterEvent::y() const
+ \deprecated [6.0] Use position().y() instead.
Returns the y position of the mouse cursor relative to the receiving widget.
*/
@@ -173,12 +165,7 @@ QInputEvent::QInputEvent(QEvent::Type type, QEvent::SinglePointEventTag, const Q
: QEvent(type, QEvent::SinglePointEventTag{}), m_dev(dev), m_modState(modifiers), m_reserved(0)
{}
-/*!
- \internal
-*/
-QInputEvent::~QInputEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QInputEvent)
/*!
\fn QInputDevice *QInputEvent::device() const
@@ -248,10 +235,12 @@ QInputEvent::~QInputEvent()
*/
/*!
- \fn QEventPoint &QPointerEvent::point(qsizetype i)
-
Returns a QEventPoint reference for the point at index \a i.
*/
+QEventPoint &QPointerEvent::point(qsizetype i)
+{
+ return m_points[i];
+}
/*!
\fn const QList<QEventPoint> &QPointerEvent::points() const
@@ -282,9 +271,7 @@ QPointerEvent::QPointerEvent(QEvent::Type type, QEvent::SinglePointEventTag, con
{
}
-QPointerEvent::~QPointerEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QPointerEvent);
/*!
Returns the point whose \l {QEventPoint::id()}{id} matches the given \a id,
@@ -300,12 +287,13 @@ QEventPoint *QPointerEvent::pointById(int id)
}
/*!
- Returns \c true if every point in points() has an exclusiveGrabber().
+ Returns \c true if every point in points() has either an exclusiveGrabber()
+ or one or more passiveGrabbers().
*/
bool QPointerEvent::allPointsGrabbed() const
{
for (const auto &p : points()) {
- if (exclusiveGrabber(p) && passiveGrabbers(p).isEmpty())
+ if (!exclusiveGrabber(p) && passiveGrabbers(p).isEmpty())
return false;
}
return true;
@@ -351,7 +339,7 @@ void QPointerEvent::setTimestamp(quint64 timestamp)
{
QInputEvent::setTimestamp(timestamp);
for (auto &p : m_points)
- QMutableEventPoint::from(p).setTimestamp(timestamp);
+ QMutableEventPoint::setTimestamp(p, timestamp);
}
/*!
@@ -389,7 +377,7 @@ void QPointerEvent::setExclusiveGrabber(const QEventPoint &point, QObject *exclu
Returns the list of objects that have been requested to receive all
future update events and the release event containing the given \a point.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
\sa QPointerEvent::addPassiveGrabber()
*/
@@ -409,7 +397,7 @@ QList<QPointer<QObject> > QPointerEvent::passiveGrabbers(const QEventPoint &poin
future update events and the release event containing the given \a point,
regardless where else those events may be delivered.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
Returns \c false if \a grabber was already added, \c true otherwise.
*/
@@ -424,7 +412,7 @@ bool QPointerEvent::addPassiveGrabber(const QEventPoint &point, QObject *grabber
Removes the passive \a grabber from the given \a point if it was previously added.
Returns \c true if it had been a passive grabber before, \c false if not.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
\sa QPointerEvent::addPassiveGrabber()
*/
@@ -438,7 +426,7 @@ bool QPointerEvent::removePassiveGrabber(const QEventPoint &point, QObject *grab
/*!
Removes all passive grabbers from the given \a point.
- It's mainly for use in Qt Quick at this time.
+ It's only for use by \l {Qt Quick Input Handlers}.
\sa QPointerEvent::addPassiveGrabber()
*/
@@ -474,7 +462,7 @@ void QPointerEvent::clearPassiveGrabbers(const QEventPoint &point)
Returns the button state when the event was generated.
The button state is a combination of Qt::LeftButton, Qt::RightButton,
- and Qt::MidButton using the OR operator.
+ and Qt::MiddleButton using the OR operator.
For mouse move or \l TabletMove events, this is all buttons that are
pressed down.
@@ -539,30 +527,30 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
bool isWheel = (type == QEvent::Type::Wheel);
auto devPriv = QPointingDevicePrivate::get(const_cast<QPointingDevice *>(pointingDevice()));
auto epd = devPriv->pointById(0);
- QMutableEventPoint &mut = QMutableEventPoint::from(epd->eventPoint);
- Q_ASSERT(mut.device() == dev);
- // mut is now a reference to a non-detached instance that lives in QPointingDevicePrivate::activePoints.
+ QEventPoint &p = epd->eventPoint;
+ Q_ASSERT(p.device() == dev);
+ // p is a reference to a non-detached instance that lives in QPointingDevicePrivate::activePoints.
// Update persistent info in that instance.
if (isPress || isWheel)
- mut.setGlobalLastPosition(globalPos);
+ QMutableEventPoint::setGlobalLastPosition(p, globalPos);
else
- mut.setGlobalLastPosition(mut.globalPosition());
- mut.setGlobalPosition(globalPos);
- if (isWheel && mut.state() != QEventPoint::State::Updated)
- mut.setGlobalPressPosition(globalPos);
+ QMutableEventPoint::setGlobalLastPosition(p, p.globalPosition());
+ QMutableEventPoint::setGlobalPosition(p, globalPos);
+ if (isWheel && p.state() != QEventPoint::State::Updated)
+ QMutableEventPoint::setGlobalPressPosition(p, globalPos);
if (type == MouseButtonDblClick)
- mut.setState(QEventPoint::State::Stationary);
+ QMutableEventPoint::setState(p, QEventPoint::State::Stationary);
else if (button == Qt::NoButton || isWheel)
- mut.setState(QEventPoint::State::Updated);
+ QMutableEventPoint::setState(p, QEventPoint::State::Updated);
else if (isPress)
- mut.setState(QEventPoint::State::Pressed);
+ QMutableEventPoint::setState(p, QEventPoint::State::Pressed);
else
- mut.setState(QEventPoint::State::Released);
- mut.setScenePosition(scenePos);
+ QMutableEventPoint::setState(p, QEventPoint::State::Released);
+ QMutableEventPoint::setScenePosition(p, scenePos);
// Now detach, and update the detached instance with ephemeral state.
- mut.detach();
- mut.setPosition(localPos);
- m_points.append(mut);
+ QMutableEventPoint::detach(p);
+ QMutableEventPoint::setPosition(p, localPos);
+ m_points.append(p);
}
/*! \internal
@@ -586,6 +574,8 @@ QSinglePointEvent::QSinglePointEvent(QEvent::Type type, const QPointingDevice *d
m_points << point;
}
+Q_IMPL_POINTER_EVENT(QSinglePointEvent)
+
/*!
Returns \c true if this event represents a \l {button()}{button} being pressed.
*/
@@ -630,7 +620,6 @@ bool QSinglePointEvent::isEndEvent() const
\endcode
*/
-
/*!
\class QMouseEvent
\ingroup events
@@ -680,7 +669,10 @@ bool QSinglePointEvent::isEndEvent() const
QCursor::pos()
*/
+#if QT_DEPRECATED_SINCE(6, 4)
/*!
+ \deprecated [6.4] Use another constructor instead (global position is required).
+
Constructs a mouse event object originating from \a device.
The \a type parameter must be one of QEvent::MouseButtonPress,
@@ -711,6 +703,7 @@ QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton but
button, buttons, modifiers)
{
}
+#endif
/*!
Constructs a mouse event object originating from \a device.
@@ -770,16 +763,12 @@ QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF &localPos, const QPoin
{
}
-/*!
- \internal
-*/
-QMouseEvent::~QMouseEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QMouseEvent)
/*!
+ \fn Qt::MouseEventSource QMouseEvent::source() const
\since 5.3
- \deprecated in 6.0: use pointingDevice()
+ \deprecated [6.0] Use pointingDevice() instead.
Returns information about the mouse event source.
@@ -795,7 +784,20 @@ QMouseEvent::~QMouseEvent()
\sa Qt::MouseEventSource
\sa QGraphicsSceneMouseEvent::source()
-*/
+
+ \note In Qt 5-based code, source() was often used to attempt to distinguish
+ mouse events from an actual mouse vs. those that were synthesized because
+ some legacy QQuickItem or QWidget subclass did not react to a QTouchEvent.
+ However, you could not tell whether it was synthesized from a QTouchEvent
+ or a QTabletEvent, and other information was lost. pointingDevice()
+ tells you the specific device that it came from, so you might check
+ \c {pointingDevice()->type()} or \c {pointingDevice()->capabilities()} to
+ decide how to react to this event. But it's even better to react to the
+ original event rather than handling only mouse events.
+*/
+// Note: the docs mention 6.0 as a deprecation version. That is correct and
+// intended, because we want our users to stop using it! Internally we will
+// deprecate it when we port our code away from using it.
Qt::MouseEventSource QMouseEvent::source() const
{
return Qt::MouseEventSource(m_source);
@@ -818,6 +820,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPointF QMouseEvent::localPos() const
+ \deprecated [6.0] Use position() instead.
\since 5.0
@@ -845,6 +848,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPointF QMouseEvent::windowPos() const
+ \deprecated [6.0] Use scenePosition() instead.
\since 5.0
@@ -860,6 +864,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPointF QMouseEvent::screenPos() const
+ \deprecated [6.0] Use globalPosition() instead.
\since 5.0
@@ -871,6 +876,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPoint QMouseEvent::pos() const
+ \deprecated [6.0] Use position() instead.
Returns the position of the mouse cursor, relative to the widget
that received the event.
@@ -884,6 +890,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPoint QMouseEvent::globalPos() const
+ \deprecated [6.0] Use globalPosition().toPoint() instead.
Returns the global position of the mouse cursor \e{at the time
of the event}. This is important on asynchronous window systems
@@ -897,6 +904,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::x() const
+ \deprecated [6.0] Use position().x() instead.
Returns the x position of the mouse cursor, relative to the
widget that received the event.
@@ -906,6 +914,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::y() const
+ \deprecated [6.0] Use position().y() instead.
Returns the y position of the mouse cursor, relative to the
widget that received the event.
@@ -915,6 +924,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::globalX() const
+ \deprecated [6.0] Use globalPosition().x() instead.
Returns the global x position of the mouse cursor at the time of
the event.
@@ -924,6 +934,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn int QMouseEvent::globalY() const
+ \deprecated [6.0] Use globalPosition().y() instead.
Returns the global y position of the mouse cursor at the time of
the event.
@@ -981,6 +992,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn QPoint QHoverEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the mouse cursor, relative to the widget
that received the event.
@@ -1006,6 +1018,7 @@ Qt::MouseEventFlags QMouseEvent::flags() const
/*!
\fn const QPointF &QHoverEvent::posF() const
+ \deprecated [6.0] Use position() instead.
Returns the position of the mouse cursor, relative to the widget
that received the event.
@@ -1035,23 +1048,40 @@ Qt::MouseEventFlags QMouseEvent::flags() const
The \a type parameter must be QEvent::HoverEnter,
QEvent::HoverLeave, or QEvent::HoverMove.
- The \a pos is the current mouse cursor's position relative to the
- receiving widget, while \a oldPos is its previous such position.
+ The \a scenePos is the current mouse cursor's position relative to the
+ receiving window or scene, \a oldPos is its previous such position, and
+ \a globalPos is the mouse position in absolute coordinates.
\a modifiers hold the state of all keyboard modifiers at the time
of the event.
*/
-QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
+QHoverEvent::QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos,
Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
- : QSinglePointEvent(type, device, pos, pos, pos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
+ : QSinglePointEvent(type, device, scenePos, scenePos, globalPos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
{
}
+#if QT_DEPRECATED_SINCE(6, 3)
/*!
- \internal
+ \deprecated [6.3] Use the other constructor instead (global position is required).
+
+ Constructs a hover event object originating from \a device.
+
+ The \a type parameter must be QEvent::HoverEnter,
+ QEvent::HoverLeave, or QEvent::HoverMove.
+
+ The \a pos is the current mouse cursor's position relative to the
+ receiving widget, while \a oldPos is its previous such position.
+ \a modifiers hold the state of all keyboard modifiers at the time
+ of the event.
*/
-QHoverEvent::~QHoverEvent()
+QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
+ Qt::KeyboardModifiers modifiers, const QPointingDevice *device)
+ : QSinglePointEvent(type, device, pos, pos, pos, Qt::NoButton, Qt::NoButton, modifiers), m_oldPos(oldPos)
{
}
+#endif
+
+Q_IMPL_POINTER_EVENT(QHoverEvent)
#if QT_CONFIG(wheelevent)
/*!
@@ -1097,7 +1127,7 @@ QHoverEvent::~QHoverEvent()
/*!
\fn Qt::MouseEventSource QWheelEvent::source() const
\since 5.5
- \deprecated in 6.0: use pointingDevice()
+ \deprecated [6.0] Use pointingDevice() instead.
Returns information about the wheel event source.
@@ -1176,12 +1206,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF &globalPos, QPoint pi
m_invertedScrolling = inverted;
}
-/*!
- \internal
-*/
-QWheelEvent::~QWheelEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QWheelEvent)
/*!
Returns \c true if this event's phase() is Qt::ScrollBegin.
@@ -1226,7 +1251,7 @@ bool QWheelEvent::isEndEvent() const
\li scrolling is about to begin, but the distance did not yet change (Qt::ScrollBegin),
\li or scrolling has ended and the distance did not change anymore (Qt::ScrollEnd).
\endlist
- \note On X11 this value is driver specific and unreliable, use angleDelta() instead
+ \note On X11 this value is driver-specific and unreliable, use angleDelta() instead.
*/
/*!
@@ -1361,22 +1386,17 @@ QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
}
-/*!
- \internal
-*/
-QKeyEvent::~QKeyEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QKeyEvent)
/*!
- \fn quint32 QKeyEvent::nativeScanCode() const
- \since 4.2
+ \fn quint32 QKeyEvent::nativeScanCode() const
+ \since 4.2
- Returns the native scan code of the key event. If the key event
- does not contain this data 0 is returned.
+ Returns the native scan code of the key event. If the key event
+ does not contain this data 0 is returned.
- Note: The native scan code may be 0, even if the key event contains
- extended information.
+ \note The native scan code may be 0, even if the key event contains
+ extended information.
*/
/*!
@@ -1386,7 +1406,7 @@ QKeyEvent::~QKeyEvent()
Returns the native virtual key, or key sym of the key event.
If the key event does not contain this data 0 is returned.
- Note: The native virtual key may be 0, even if the key event contains extended information.
+ \note The native virtual key may be 0, even if the key event contains extended information.
*/
/*!
@@ -1396,7 +1416,7 @@ QKeyEvent::~QKeyEvent()
Returns the native modifiers of a key event.
If the key event does not contain this data 0 is returned.
- Note: The native modifiers may be 0, even if the key event contains extended information.
+ \note The native modifiers may be 0, even if the key event contains extended information.
*/
/*!
@@ -1423,12 +1443,13 @@ QKeyEvent::~QKeyEvent()
Returns the Unicode text that this key generated.
- Return values when modifier keys such as
- Shift, Control, Alt, and Meta are pressed
- differ among platforms and could return an empty string.
+ The text is not limited to the printable range of Unicode
+ code points, and may include control characters or characters
+ from other Unicode categories, including QChar::Other_PrivateUse.
- \note \l key() will always return a valid value,
- independent of modifier keys.
+ The text may also be empty, for example when modifier keys such as
+ Shift, Control, Alt, and Meta are pressed (depending on the platform).
+ The key() function will always return a valid value.
\sa Qt::WA_KeyCompression
*/
@@ -1540,12 +1561,7 @@ QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
: QEvent(type), m_reason(reason)
{}
-/*!
- \internal
-*/
-QFocusEvent::~QFocusEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QFocusEvent)
/*!
Returns the reason for this focus event.
@@ -1618,12 +1634,7 @@ QPaintEvent::QPaintEvent(const QRect &paintRect)
{}
-/*!
- \internal
-*/
-QPaintEvent::~QPaintEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QPaintEvent)
/*!
\fn const QRect &QPaintEvent::rect() const
@@ -1665,12 +1676,7 @@ QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
: QEvent(Move), m_pos(pos), m_oldPos(oldPos)
{}
-/*!
- \internal
-*/
-QMoveEvent::~QMoveEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QMoveEvent)
/*!
\fn const QPoint &QMoveEvent::pos() const
@@ -1717,12 +1723,7 @@ QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
{
}
-/*!
- \internal
-*/
-QExposeEvent::~QExposeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QExposeEvent)
/*!
\class QPlatformSurfaceEvent
@@ -1766,15 +1767,11 @@ QPlatformSurfaceEvent::QPlatformSurfaceEvent(SurfaceEventType surfaceEventType)
{
}
-/*!
- \internal
-*/
-QPlatformSurfaceEvent::~QPlatformSurfaceEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QPlatformSurfaceEvent)
/*!
\fn const QRegion &QExposeEvent::region() const
+ \deprecated [6.0] Use QPaintEvent instead.
Returns the window area that has been exposed. The region is given in local coordinates.
*/
@@ -1801,12 +1798,7 @@ QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
: QEvent(Resize), m_size(size), m_oldSize(oldSize)
{}
-/*!
- \internal
-*/
-QResizeEvent::~QResizeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QResizeEvent)
/*!
\fn const QSize &QResizeEvent::size() const
@@ -1848,10 +1840,6 @@ QResizeEvent::~QResizeEvent()
special handling, you should reimplement the event handler and
ignore() the event.
- The \l{mainwindows/application#close event handler}{closeEvent() in the
- Application example} shows a close event handler that
- asks whether to save a document before closing.
-
If you want the widget to be deleted when it is closed, create it
with the Qt::WA_DeleteOnClose flag. This is very useful for
independent top-level windows in a multi-window application.
@@ -1881,11 +1869,7 @@ QCloseEvent::QCloseEvent()
: QEvent(Close)
{}
-/*! \internal
-*/
-QCloseEvent::~QCloseEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QCloseEvent)
/*!
\class QIconDragEvent
@@ -1914,10 +1898,7 @@ QIconDragEvent::QIconDragEvent()
: QEvent(IconDrag)
{ ignore(); }
-/*! \internal */
-QIconDragEvent::~QIconDragEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QIconDragEvent)
/*!
\class QContextMenuEvent
@@ -1953,12 +1934,12 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPo
: QInputEvent(ContextMenu, QPointingDevice::primaryPointingDevice(), modifiers), m_pos(pos), m_globalPos(globalPos), m_reason(reason)
{}
+Q_IMPL_EVENT_COMMON(QContextMenuEvent)
-/*! \internal */
-QContextMenuEvent::~QContextMenuEvent()
-{
-}
+#if QT_DEPRECATED_SINCE(6, 4)
/*!
+ \deprecated [6.4] Use the other constructor instead (global position is required).
+
Constructs a context menu event object with the accept parameter
flag set to false.
@@ -1979,6 +1960,7 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
m_globalPos = QCursor::pos();
#endif
}
+#endif
/*!
\fn const QPoint &QContextMenuEvent::pos() const
@@ -2113,7 +2095,7 @@ QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
has to be inserted to the widgets text directly before the preedit
string.
- If the commitString() should replace parts of the of the text in
+ If the commitString() should replace parts of the text in
the editor, replacementLength() will contain the number of
characters to be replaced. replacementStart() contains the position
at which characters are to be replaced relative from the start of
@@ -2269,9 +2251,7 @@ QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Att
{
}
-QInputMethodEvent::~QInputMethodEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QInputMethodEvent)
/*!
Sets the commit string to \a commitString.
@@ -2281,7 +2261,7 @@ QInputMethodEvent::~QInputMethodEvent()
result of the input operations and has to be inserted to the
widgets text directly before the preedit string.
- If the commit string should replace parts of the of the text in
+ If the commit string should replace parts of the text in
the editor, \a replaceLength specifies the number of
characters to be replaced. \a replaceFrom specifies the position
at which characters are to be replaced relative from the start of
@@ -2378,12 +2358,7 @@ QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQueries queries)
{
}
-/*!
- \internal
- */
-QInputMethodQueryEvent::~QInputMethodQueryEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QInputMethodQueryEvent)
/*!
Sets property \a query to \a value.
@@ -2530,17 +2505,12 @@ QTabletEvent::QTabletEvent(Type type, const QPointingDevice *dev, const QPointF
m_yTilt(yTilt),
m_z(z)
{
- QMutableEventPoint &mut = QMutableEventPoint::from(point(0));
- mut.setPressure(pressure);
- mut.setRotation(rotation);
+ QEventPoint &p = point(0);
+ QMutableEventPoint::setPressure(p, pressure);
+ QMutableEventPoint::setRotation(p, rotation);
}
-/*!
- \internal
-*/
-QTabletEvent::~QTabletEvent()
-{
-}
+Q_IMPL_POINTER_EVENT(QTabletEvent)
/*!
\fn qreal QTabletEvent::tangentialPressure() const
@@ -2606,6 +2576,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn QPoint QTabletEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the device, relative to the widget that
received the event.
@@ -2618,6 +2589,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::x() const
+ \deprecated [6.0] Use position().x() instead.
Returns the x position of the device, relative to the widget that
received the event.
@@ -2627,6 +2599,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::y() const
+ \deprecated [6.0] Use position().y() instead.
Returns the y position of the device, relative to the widget that
received the event.
@@ -2648,6 +2621,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn QPoint QTabletEvent::globalPos() const
+ \deprecated [6.0] Use globalPosition().toPoint() instead.
Returns the global position of the device \e{at the time of the
event}. This is important on asynchronous windows systems like X11;
@@ -2660,6 +2634,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::globalX() const
+ \deprecated [6.0] Use globalPosition().x() instead.
Returns the global x position of the mouse pointer at the time of
the event.
@@ -2669,6 +2644,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn int QTabletEvent::globalY() const
+ \deprecated [6.0] Use globalPosition().y() instead.
Returns the global y position of the tablet device at the time of
the event.
@@ -2678,6 +2654,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn qint64 QTabletEvent::uniqueId() const
+ \deprecated [6.0] Use pointingDevice().uniqueId() instead.
Returns a unique ID for the current device, making it possible
to differentiate between multiple devices being used at the same
@@ -2701,6 +2678,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn const QPointF &QTabletEvent::posF() const
+ \deprecated [6.0] Use position() instead.
Returns the position of the device, relative to the widget that
received the event.
@@ -2713,7 +2691,7 @@ QTabletEvent::~QTabletEvent()
/*!
\fn const QPointF &QTabletEvent::globalPosF() const
-
+ \deprecated [6.0] Use globalPosition() instead.
Returns the global position of the device \e{at the time of the
event}. This is important on asynchronous windows systems like X11;
whenever you move your widgets around in response to mouse events,
@@ -2734,8 +2712,10 @@ QTabletEvent::~QTabletEvent()
\ingroup events
Native gesture events are generated by the operating system, typically by
- interpreting touch events. Gesture events are high-level events such
- as zoom or rotate.
+ interpreting trackpad touch events. Gesture events are high-level events
+ such as zoom, rotate or pan. Several types hold incremental values: that is,
+ value() and delta() provide the difference from the previous event to the
+ current event.
\table
\header
@@ -2745,7 +2725,7 @@ QTabletEvent::~QTabletEvent()
\row
\li Qt::ZoomNativeGesture
\li Magnification delta in percent.
- \li \macos: Two-finger pinch.
+ \li \macos and Wayland: Two-finger pinch.
\row
\li Qt::SmartZoomNativeGesture
\li Boolean magnification state.
@@ -2753,10 +2733,17 @@ QTabletEvent::~QTabletEvent()
\row
\li Qt::RotateNativeGesture
\li Rotation delta in degrees.
- \li \macos: Two-finger rotate.
+ \li \macos and Wayland: Two-finger rotate.
+ \row
+ \li Qt::SwipeNativeGesture
+ \li Swipe angle in degrees.
+ \li \macos: Configurable in trackpad settings.
+ \row
+ \li Qt::PanNativeGesture
+ \li Displacement delta in pixels.
+ \li Wayland: Three or more fingers moving as a group, in any direction.
\endtable
-
In addition, BeginNativeGesture and EndNativeGesture are sent before and after
gesture event streams:
@@ -2766,12 +2753,25 @@ QTabletEvent::~QTabletEvent()
ZoomNativeGesture
EndNativeGesture
- \sa Qt::NativeGestureType, QGestureEvent
+ The event stream may include interleaved gestures of different types:
+ for example the two-finger pinch gesture generates a stream of Zoom and
+ Rotate events, and PanNativeGesture may sometimes be interleaved with
+ those, depending on the platform.
+
+ Other types are standalone events: SmartZoomNativeGesture and
+ SwipeNativeGesture occur only once each time the gesture is detected.
+
+ \note On a touchpad, moving two fingers as a group (the two-finger flick gesture)
+ is usually reserved for scrolling; in that case, Qt generates QWheelEvents.
+ This is the reason that three or more fingers are needed to generate a
+ PanNativeGesture.
+
+ \sa Qt::NativeGestureType, QGestureEvent, QWheelEvent
*/
+#if QT_DEPRECATED_SINCE(6, 2)
/*!
- \deprecated
- Use the other constructor, because \a intValue is no longer stored separately.
+ \deprecated [6.2] Use the other constructor, because \a intValue is no longer stored separately.
Constructs a native gesture event of type \a type originating from \a device.
@@ -2787,7 +2787,6 @@ QTabletEvent::~QTabletEvent()
it is stored in the same variable, such that value() returns the value
given as \a intValue.
*/
-#if QT_DEPRECATED_SINCE(6, 2)
QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device,
const QPointF &localPos, const QPointF &scenePos,
const QPointF &globalPos, qreal realValue, quint64 sequenceId,
@@ -2815,23 +2814,27 @@ QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPoin
indicating that the target item should have its scale adjusted like this:
item.scale = item.scale * (1 + event.value)
- For PanNativeGesture, \a deltas gives the distance in pixels that the
+ For PanNativeGesture, \a delta gives the distance in pixels that the
viewport, widget or item should be moved or panned.
+ \note The \a delta is stored in single precision (QVector2D), so \l delta()
+ may return slightly different values in some cases. This is subject to change
+ in future versions of Qt.
+
\since 6.2
*/
QNativeGestureEvent::QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *device, int fingerCount,
const QPointF &localPos, const QPointF &scenePos,
- const QPointF &globalPos, qreal value, QVector2D deltas,
+ const QPointF &globalPos, qreal value, const QPointF &delta,
quint64 sequenceId)
: QSinglePointEvent(QEvent::NativeGesture, device, localPos, scenePos, globalPos, Qt::NoButton,
Qt::NoButton, Qt::NoModifier),
- m_sequenceId(sequenceId), m_deltas(deltas), m_realValue(value), m_gestureType(type), m_fingerCount(fingerCount)
+ m_sequenceId(sequenceId), m_delta(delta), m_realValue(value), m_gestureType(type), m_fingerCount(fingerCount)
{
Q_ASSERT(fingerCount < 16); // we store it in 4 bits unsigned
}
-QNativeGestureEvent::~QNativeGestureEvent() = default;
+Q_IMPL_POINTER_EVENT(QNativeGestureEvent)
/*!
\fn QNativeGestureEvent::gestureType() const
@@ -2854,23 +2857,27 @@ QNativeGestureEvent::~QNativeGestureEvent() = default;
\since 5.2
Returns the gesture value. The value should be interpreted based on the
- gesture type. For example, a Zoom gesture provides a scale factor while a Rotate
+ gesture type. For example, a Zoom gesture provides a scale factor delta while a Rotate
gesture provides a rotation delta.
\sa QNativeGestureEvent, gestureType()
*/
/*!
- \fn QNativeGestureEvent::deltas() const
+ \fn QNativeGestureEvent::delta() const
\since 6.2
- Returns the distance moved. A Pan gesture provides the distance in pixels by which
- the target widget, item or viewport contents should be moved.
+ Returns the distance moved since the previous event, in pixels.
+ A Pan gesture provides the distance in pixels by which the target widget,
+ item or viewport contents should be moved.
+
+ \sa QPanGesture::delta()
*/
/*!
\fn QPoint QNativeGestureEvent::globalPos() const
\since 5.2
+ \deprecated [6.0] Use globalPosition().toPoint() instead.
Returns the position of the gesture as a QPointF in screen coordinates
*/
@@ -2878,6 +2885,7 @@ QNativeGestureEvent::~QNativeGestureEvent() = default;
/*!
\fn QPoint QNativeGestureEvent::pos() const
\since 5.2
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position of the mouse cursor, relative to the widget
or item that received the event.
@@ -2886,6 +2894,7 @@ QNativeGestureEvent::~QNativeGestureEvent() = default;
/*!
\fn QPointF QNativeGestureEvent::localPos() const
\since 5.2
+ \deprecated [6.0] Use position() instead.
Returns the position of the gesture as a QPointF, relative to the
widget or item that received the event.
@@ -2894,6 +2903,7 @@ QNativeGestureEvent::~QNativeGestureEvent() = default;
/*!
\fn QPointF QNativeGestureEvent::screenPos() const
\since 5.2
+ \deprecated [6.0] Use globalPosition() instead.
Returns the position of the gesture as a QPointF in screen coordinates.
*/
@@ -2901,6 +2911,7 @@ QNativeGestureEvent::~QNativeGestureEvent() = default;
/*!
\fn QPointF QNativeGestureEvent::windowPos() const
\since 5.2
+ \deprecated [6.0] Use scenePosition() instead.
Returns the position of the gesture as a QPointF, relative to the
window that received the event.
@@ -2926,12 +2937,7 @@ QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const
, m_rect(pos, QSize(1, 1))
{}
-/*!
- Destroys the event.
-*/
-QDragMoveEvent::~QDragMoveEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDragMoveEvent)
/*!
\fn void QDragMoveEvent::accept(const QRect &rectangle)
@@ -3044,10 +3050,7 @@ QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeD
ignore();
}
-/*! \internal */
-QDropEvent::~QDropEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDropEvent)
/*!
@@ -3078,24 +3081,49 @@ void QDropEvent::setDropAction(Qt::DropAction action)
/*!
\fn QPoint QDropEvent::pos() const
+ \deprecated [6.0] Use position().toPoint() instead.
Returns the position where the drop was made.
*/
/*!
\fn const QPointF& QDropEvent::posF() const
+ \deprecated [6.0] Use position() instead.
+
+ Returns the position where the drop was made.
+*/
+
+/*!
+ \fn QPointF QDropEvent::position() const
+ \since 6.0
Returns the position where the drop was made.
*/
/*!
\fn Qt::MouseButtons QDropEvent::mouseButtons() const
+ \deprecated [6.0] Use buttons() instead.
+
+ Returns the mouse buttons that are pressed.
+*/
- Returns the mouse buttons that are pressed..
+/*!
+ \fn Qt::MouseButtons QDropEvent::buttons() const
+ \since 6.0
+
+ Returns the mouse buttons that are pressed.
*/
/*!
\fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
+ \deprecated [6.0] Use modifiers() instead.
+
+ Returns the modifier keys that are pressed.
+*/
+
+/*!
+ \fn Qt::KeyboardModifiers QDropEvent::modifiers() const
+ \since 6.0
Returns the modifier keys that are pressed.
*/
@@ -3188,11 +3216,7 @@ QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, c
: QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
{}
-/*! \internal
-*/
-QDragEnterEvent::~QDragEnterEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDragEnterEvent)
/*!
\class QDragMoveEvent
@@ -3246,11 +3270,8 @@ QDragLeaveEvent::QDragLeaveEvent()
: QEvent(DragLeave)
{}
-/*! \internal
-*/
-QDragLeaveEvent::~QDragLeaveEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QDragLeaveEvent)
+
#endif // QT_CONFIG(draganddrop)
/*!
@@ -3332,11 +3353,7 @@ QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
\sa pos(), globalX(), globalY()
*/
-/*! \internal
-*/
-QHelpEvent::~QHelpEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QHelpEvent)
#ifndef QT_NO_STATUSTIP
@@ -3391,11 +3408,7 @@ QStatusTipEvent::QStatusTipEvent(const QString &tip)
: QEvent(StatusTip), m_tip(tip)
{}
-/*! \internal
-*/
-QStatusTipEvent::~QStatusTipEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QStatusTipEvent)
/*!
\fn QString QStatusTipEvent::tip() const
@@ -3431,11 +3444,7 @@ QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
: QEvent(WhatsThisClicked), m_href(href)
{}
-/*! \internal
-*/
-QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QWhatsThisClickedEvent)
/*!
\fn QString QWhatsThisClickedEvent::href() const
@@ -3477,11 +3486,7 @@ QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
: QEvent(static_cast<QEvent::Type>(type)), m_action(action), m_before(before)
{}
-/*! \internal
-*/
-QActionEvent::~QActionEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QActionEvent)
/*!
\fn QAction *QActionEvent::action() const
@@ -3531,11 +3536,7 @@ QHideEvent::QHideEvent()
: QEvent(Hide)
{}
-/*! \internal
-*/
-QHideEvent::~QHideEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QHideEvent)
/*!
\class QShowEvent
@@ -3561,11 +3562,7 @@ QShowEvent::QShowEvent()
: QEvent(Show)
{}
-/*! \internal
-*/
-QShowEvent::~QShowEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QShowEvent)
/*!
\class QFileOpenEvent
@@ -3596,10 +3593,15 @@ QShowEvent::~QShowEvent()
\snippet qfileopenevent/Info.plist Custom Info.plist
- The following implementation of a QApplication subclass prints the path to
- the file that was, for example, dropped on the Dock icon of the application.
+ The following implementation of a QApplication subclass shows how to handle
+ QFileOpenEvent to open the file that was, for example, dropped on the Dock
+ icon of the application.
\snippet qfileopenevent/main.cpp QApplication subclass
+
+ Note how \c{QFileOpenEvent::file()} is not guaranteed to be the name of a
+ local file that can be opened using QFile. The contents of the string depend
+ on the source application.
*/
/*!
@@ -3622,29 +3624,28 @@ QFileOpenEvent::QFileOpenEvent(const QUrl &url)
{
}
-
-/*! \internal
-*/
-QFileOpenEvent::~QFileOpenEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QFileOpenEvent)
/*!
\fn QString QFileOpenEvent::file() const
- Returns the file that is being opened.
+ Returns the name of the file that the application should open.
+
+ This is not guaranteed to be the path to a local file.
*/
/*!
\fn QUrl QFileOpenEvent::url() const
- Returns the url that is being opened.
+ Returns the url that the application should open.
\since 4.6
*/
+#if QT_DEPRECATED_SINCE(6, 6)
/*!
\fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
+ \deprecated [6.6] interpret the string returned by file()
Opens a QFile on the \a file referenced by this event in the mode specified
by \a flags. Returns \c true if successful; otherwise returns \c false.
@@ -3659,6 +3660,7 @@ bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
file.setFileName(m_file);
return file.open(flags);
}
+#endif
#ifndef QT_NO_TOOLBAR
/*!
@@ -3685,11 +3687,7 @@ QToolBarChangeEvent::QToolBarChangeEvent(bool t)
: QEvent(ToolBarChange), m_toggle(t)
{}
-/*! \internal
-*/
-QToolBarChangeEvent::~QToolBarChangeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QToolBarChangeEvent)
/*!
\fn bool QToolBarChangeEvent::toggle() const
@@ -3714,6 +3712,8 @@ QToolBarChangeEvent::~QToolBarChangeEvent()
Constructs a shortcut event for the given \a key press,
associated with the QShortcut ID \a id.
+ \deprecated use the other constructor
+
\a ambiguous specifies whether there is more than one QShortcut
for the same key sequence.
*/
@@ -3723,12 +3723,29 @@ QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
}
/*!
- Destroys the event object.
+ Constructs a shortcut event for the given \a key press,
+ associated with the QShortcut \a shortcut.
+ \since 6.5
+
+ \a ambiguous specifies whether there is more than one QShortcut
+ for the same key sequence.
*/
-QShortcutEvent::~QShortcutEvent()
+QShortcutEvent::QShortcutEvent(const QKeySequence &key, const QShortcut *shortcut, bool ambiguous)
+ : QEvent(Shortcut), m_sequence(key), m_shortcutId(0), m_ambiguous(ambiguous)
{
+ if (shortcut) {
+ auto priv = static_cast<const QShortcutPrivate *>(QShortcutPrivate::get(shortcut));
+ auto index = priv->sc_sequences.indexOf(key);
+ if (index < 0) {
+ qWarning() << "Given QShortcut does not contain key-sequence " << key;
+ return;
+ }
+ m_shortcutId = priv->sc_ids[index];
+ }
}
+Q_IMPL_EVENT_COMMON(QShortcutEvent)
+
#endif // QT_CONFIG(shortcut)
#ifndef QT_NO_DEBUG_STREAM
@@ -3754,6 +3771,13 @@ static void formatUnicodeString(QDebug d, const QString &s)
d << Qt::dec << '"';
}
+static QDebug operator<<(QDebug dbg, const QInputMethodEvent::Attribute &attr)
+{
+ dbg << "[type= " << attr.type << ", start=" << attr.start << ", length=" << attr.length
+ << ", value=" << attr.value << ']';
+ return dbg;
+}
+
static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
{
d << "QInputMethodEvent(";
@@ -3769,15 +3793,15 @@ static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
d << ", replacementStart=" << e->replacementStart() << ", replacementLength="
<< e->replacementLength();
}
- if (const int attributeCount = e->attributes().size()) {
+ const auto attributes = e->attributes();
+ auto it = attributes.cbegin();
+ const auto end = attributes.cend();
+ if (it != end) {
d << ", attributes= {";
- for (int a = 0; a < attributeCount; ++a) {
- const QInputMethodEvent::Attribute &at = e->attributes().at(a);
- if (a)
- d << ',';
- d << "[type= " << at.type << ", start=" << at.start << ", length=" << at.length
- << ", value=" << at.value << ']';
- }
+ d << *it;
+ ++it;
+ for (; it != end; ++it)
+ d << ',' << *it;
d << '}';
}
d << ')';
@@ -4026,12 +4050,10 @@ QDebug operator<<(QDebug dbg, const QEvent *e)
}
// More useful event output could be added here
const QEvent::Type type = e->type();
+ bool isMouse = false;
switch (type) {
case QEvent::Expose:
-QT_WARNING_PUSH
-QT_WARNING_DISABLE_DEPRECATED
- dbg << "QExposeEvent(" << static_cast<const QExposeEvent *>(e)->region() << ')';
-QT_WARNING_POP
+ dbg << "QExposeEvent()";
break;
case QEvent::Paint:
dbg << "QPaintEvent(" << static_cast<const QPaintEvent *>(e)->region() << ')';
@@ -4044,31 +4066,41 @@ QT_WARNING_POP
case QEvent::NonClientAreaMouseMove:
case QEvent::NonClientAreaMouseButtonRelease:
case QEvent::NonClientAreaMouseButtonDblClick:
+ isMouse = true;
+ Q_FALLTHROUGH();
+ case QEvent::HoverEnter:
+ case QEvent::HoverMove:
+ case QEvent::HoverLeave:
{
- const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
- const Qt::MouseButton button = me->button();
- const Qt::MouseButtons buttons = me->buttons();
- dbg << "QMouseEvent(";
+ const QSinglePointEvent *spe = static_cast<const QSinglePointEvent*>(e);
+ const Qt::MouseButton button = spe->button();
+ const Qt::MouseButtons buttons = spe->buttons();
+ dbg << eventClassName(type) << '(';
QtDebugUtils::formatQEnum(dbg, type);
- if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) {
- dbg << ' ';
- QtDebugUtils::formatQEnum(dbg, button);
- }
- if (buttons && button != buttons) {
- dbg << " btns=";
- QtDebugUtils::formatQFlags(dbg, buttons);
+ if (isMouse) {
+ if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove) {
+ dbg << ' ';
+ QtDebugUtils::formatQEnum(dbg, button);
+ }
+ if (buttons && button != buttons) {
+ dbg << " btns=";
+ QtDebugUtils::formatQFlags(dbg, buttons);
+ }
}
- QtDebugUtils::formatNonNullQFlags(dbg, ", ", me->modifiers());
+ QtDebugUtils::formatNonNullQFlags(dbg, ", ", spe->modifiers());
dbg << " pos=";
- QtDebugUtils::formatQPoint(dbg, me->position());
+ QtDebugUtils::formatQPoint(dbg, spe->position());
dbg << " scn=";
- QtDebugUtils::formatQPoint(dbg, me->scenePosition());
+ QtDebugUtils::formatQPoint(dbg, spe->scenePosition());
dbg << " gbl=";
- QtDebugUtils::formatQPoint(dbg, me->globalPosition());
- dbg << " dev=" << me->device() << ')';
- if (me->source() != Qt::MouseEventNotSynthesized) {
- dbg << " source=";
- QtDebugUtils::formatQEnum(dbg, me->source());
+ QtDebugUtils::formatQPoint(dbg, spe->globalPosition());
+ dbg << " dev=" << spe->device() << ')';
+ if (isMouse) {
+ auto src = static_cast<const QMouseEvent*>(e)->source();
+ if (src != Qt::MouseEventNotSynthesized) {
+ dbg << " source=";
+ QtDebugUtils::formatQEnum(dbg, src);
+ }
}
}
break;
@@ -4096,6 +4128,10 @@ QT_WARNING_POP
dbg << ", text=" << ke->text();
if (ke->isAutoRepeat())
dbg << ", autorepeat, count=" << ke->count();
+ if (dbg.verbosity() > QDebug::DefaultVerbosity) {
+ dbg << ", nativeScanCode=" << ke->nativeScanCode();
+ dbg << ", nativeVirtualKey=" << ke->nativeVirtualKey();
+ }
dbg << ')';
}
break;
@@ -4170,9 +4206,9 @@ QT_WARNING_POP
QtDebugUtils::formatQPoint(dbg, ne->position());
if (!qIsNull(ne->value()))
dbg << ", value=" << ne->value();
- if (!ne->deltas().isNull()) {
- dbg << ", deltas=";
- QtDebugUtils::formatQPoint(dbg, ne->deltas());
+ if (!ne->delta().isNull()) {
+ dbg << ", delta=";
+ QtDebugUtils::formatQPoint(dbg, ne->delta());
}
dbg << ')';
}
@@ -4262,6 +4298,8 @@ QT_WARNING_POP
/*!
\fn int QShortcutEvent::shortcutId() const
+ \deprecated
+
Returns the ID of the QShortcut object for which this event was
generated.
@@ -4305,11 +4343,7 @@ bool QWindowStateChangeEvent::isOverride() const
return m_override;
}
-/*! \internal
-*/
-QWindowStateChangeEvent::~QWindowStateChangeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QWindowStateChangeEvent)
/*!
@@ -4364,7 +4398,7 @@ QWindowStateChangeEvent::~QWindowStateChangeEvent()
describes the different states that a touch point may have.
\note The list of points() will never be partial: A touch event will always contain a touch
- point for each existing physical touch contacts targetting the window or widget to which the
+ point for each existing physical touch contacts targeting the window or widget to which the
event is sent. For instance, assuming that all touches target the same window or widget, an
event with a condition of points().count()==2 is guaranteed to imply that the number of
fingers touching the touchscreen or touchpad is exactly two.
@@ -4457,14 +4491,13 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType,
{
for (QEventPoint &point : m_points) {
m_touchPointStates |= point.state();
- QMutableEventPoint::from(point).setDevice(device);
+ QMutableEventPoint::setDevice(point, device);
}
}
+#if QT_DEPRECATED_SINCE(6, 0)
/*!
- \deprecated
- Try to use another constructor, because \a touchPointStates
- can be calculated from the given \a touchPoints.
+ \deprecated [6.0] Use another constructor.
Constructs a QTouchEvent with the given \a eventType, \a device, and
\a touchPoints. The \a touchPointStates and \a modifiers are the current
@@ -4480,14 +4513,11 @@ QTouchEvent::QTouchEvent(QEvent::Type eventType,
m_touchPointStates(touchPointStates)
{
for (QEventPoint &point : m_points)
- QMutableEventPoint::from(point).setDevice(device);
+ QMutableEventPoint::setDevice(point, device);
}
+#endif // QT_DEPRECATED_SINCE(6, 0)
-/*!
- Destroys the QTouchEvent.
-*/
-QTouchEvent::~QTouchEvent()
-{ }
+Q_IMPL_POINTER_EVENT(QTouchEvent)
/*!
Returns true if this event includes at least one newly-pressed touchpoint.
@@ -4527,8 +4557,7 @@ bool QTouchEvent::isEndEvent() const
*/
/*! \fn const QList<QEventPoint> &QTouchEvent::touchPoints() const
- \deprecated
- Deprecated since Qt 6.0. Use points() instead.
+ \deprecated [6.0] Use points() instead.
Returns a reference to the list of touch points contained in the touch event.
@@ -4562,12 +4591,7 @@ QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
{
}
-/*!
- Destroys QScrollEvent.
-*/
-QScrollPrepareEvent::~QScrollPrepareEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QScrollPrepareEvent)
/*!
\fn QPointF QScrollPrepareEvent::startPos() const
@@ -4665,12 +4689,7 @@ QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDi
{
}
-/*!
- Destroys QScrollEvent.
-*/
-QScrollEvent::~QScrollEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QScrollEvent)
/*!
\fn QPointF QScrollEvent::contentPos() const
@@ -4707,12 +4726,7 @@ QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt
{
}
-/*!
- Destroys QScreenOrientationChangeEvent.
-*/
-QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
-{
-}
+Q_IMPL_EVENT_COMMON(QScreenOrientationChangeEvent)
/*!
\fn QScreen *QScreenOrientationChangeEvent::screen() const
@@ -4735,12 +4749,57 @@ QApplicationStateChangeEvent::QApplicationStateChangeEvent(Qt::ApplicationState
{
}
+Q_IMPL_EVENT_COMMON(QApplicationStateChangeEvent)
+
/*!
\fn Qt::ApplicationState QApplicationStateChangeEvent::applicationState() const
Returns the state of the application.
*/
+/*!
+ \class QChildWindowEvent
+ \inmodule QtGui
+ \since 6.7
+ \brief The QChildWindowEvent class contains event parameters for
+ child window changes.
+
+ \ingroup events
+
+ Child window events are sent to windows when children are
+ added or removed.
+
+ In both cases you can only rely on the child being a QWindow
+ — not any subclass thereof. This is because in the
+ QEvent::ChildWindowAdded case the subclass is not yet fully
+ constructed, and in the QEvent::ChildWindowRemoved case it
+ might have already been destructed.
+*/
+
+/*!
+ Constructs a child window event object of a particular \a type
+ for the \a childWindow.
+
+ \a type can be QEvent::ChildWindowAdded or QEvent::ChildWindowRemoved.
+
+ \sa child()
+*/
+QChildWindowEvent::QChildWindowEvent(Type type, QWindow *childWindow)
+ : QEvent(type), c(childWindow)
+{
+}
+
+Q_IMPL_EVENT_COMMON(QChildWindowEvent)
+
+/*!
+ \fn QWindow *QChildWindowEvent::child() const
+
+ Returns the child window that was added or removed.
+*/
+
+QMutableTouchEvent::~QMutableTouchEvent()
+ = default;
+
/*! \internal
Add the given \a point.
*/
@@ -4749,10 +4808,14 @@ void QMutableTouchEvent::addPoint(const QEventPoint &point)
m_points.append(point);
auto &added = m_points.last();
if (!added.device())
- QMutableEventPoint::from(added).setDevice(pointingDevice());
+ QMutableEventPoint::setDevice(added, pointingDevice());
m_touchPointStates |= point.state();
}
+QMutableSinglePointEvent::~QMutableSinglePointEvent()
+ = default;
QT_END_NAMESPACE
+
+#include "moc_qevent.cpp"
diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h
index db886bdd98..a24f0c471c 100644
--- a/src/gui/kernel/qevent.h
+++ b/src/gui/kernel/qevent.h
@@ -1,52 +1,19 @@
-/****************************************************************************
-**
-** 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 QEVENT_H
#define QEVENT_H
+#if 0
+#pragma qt_class(QtEvents)
+#endif
+
#include <QtGui/qtguiglobal.h>
#include <QtCore/qcoreevent.h>
#include <QtCore/qiodevice.h>
#include <QtCore/qlist.h>
#include <QtCore/qnamespace.h>
-#include <QtCore/qpointer.h>
#include <QtCore/qstring.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
@@ -59,13 +26,19 @@
# include <QtGui/qkeysequence.h>
#endif
+class tst_QEvent;
+
QT_BEGIN_NAMESPACE
class QFile;
class QAction;
class QMouseEvent;
+template <typename T> class QPointer;
class QPointerEvent;
class QScreen;
+#if QT_CONFIG(shortcut)
+class QShortcut;
+#endif
class QTabletEvent;
class QTouchEvent;
#if QT_CONFIG(gestures)
@@ -74,11 +47,9 @@ class QGesture;
class Q_GUI_EXPORT QInputEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QInputEvent);
+ Q_DECL_EVENT_COMMON(QInputEvent)
public:
explicit QInputEvent(Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier);
- ~QInputEvent();
- QInputEvent *clone() const override { return new QInputEvent(*this); }
const QInputDevice *device() const { return m_dev; }
QInputDevice::DeviceType deviceType() const { return m_dev ? m_dev->type() : QInputDevice::DeviceType::Unknown; }
@@ -100,21 +71,19 @@ protected:
class Q_GUI_EXPORT QPointerEvent : public QInputEvent
{
- Q_EVENT_DISABLE_COPY(QPointerEvent);
+ Q_GADGET
+ Q_DECL_EVENT_COMMON(QPointerEvent)
public:
explicit QPointerEvent(Type type, const QPointingDevice *dev,
Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QList<QEventPoint> &points = {});
- ~QPointerEvent();
-
- QPointerEvent *clone() const override { return new QPointerEvent(*this); }
const QPointingDevice *pointingDevice() const;
QPointingDevice::PointerType pointerType() const {
return pointingDevice() ? pointingDevice()->pointerType() : QPointingDevice::PointerType::Unknown;
}
void setTimestamp(quint64 timestamp) override;
- qsizetype pointCount() const { return m_points.count(); }
- QEventPoint &point(qsizetype i) { return m_points[i]; }
+ qsizetype pointCount() const { return m_points.size(); }
+ QEventPoint &point(qsizetype i);
const QList<QEventPoint> &points() const { return m_points; }
QEventPoint *pointById(int id);
bool allPointsGrabbed() const;
@@ -139,9 +108,10 @@ protected:
class Q_GUI_EXPORT QSinglePointEvent : public QPointerEvent
{
Q_GADGET
- Q_PROPERTY(QObject *exclusivePointGrabber READ exclusivePointGrabber WRITE setExclusivePointGrabber)
+ Q_PROPERTY(QObject *exclusivePointGrabber READ exclusivePointGrabber
+ WRITE setExclusivePointGrabber)
- Q_EVENT_DISABLE_COPY(QSinglePointEvent);
+ Q_DECL_EVENT_COMMON(QSinglePointEvent)
public:
inline Qt::MouseButton button() const { return m_button; }
inline Qt::MouseButtons buttons() const { return m_mouseState; }
@@ -162,9 +132,8 @@ public:
void setExclusivePointGrabber(QObject *exclusiveGrabber)
{ QPointerEvent::setExclusiveGrabber(points().first(), exclusiveGrabber); }
- QSinglePointEvent *clone() const override { return new QSinglePointEvent(*this); }
-
protected:
+ friend class ::tst_QEvent;
QSinglePointEvent(Type type, const QPointingDevice *dev, const QEventPoint &point,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source);
@@ -194,13 +163,10 @@ protected:
class Q_GUI_EXPORT QEnterEvent : public QSinglePointEvent
{
- Q_EVENT_DISABLE_COPY(QEnterEvent);
+ Q_DECL_EVENT_COMMON(QEnterEvent)
public:
QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
- ~QEnterEvent();
-
- QEnterEvent *clone() const override { return new QEnterEvent(*this); }
#if QT_DEPRECATED_SINCE(6, 0)
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
@@ -228,11 +194,14 @@ public:
class Q_GUI_EXPORT QMouseEvent : public QSinglePointEvent
{
- Q_EVENT_DISABLE_COPY(QMouseEvent);
+ Q_DECL_EVENT_COMMON(QMouseEvent)
public:
+#if QT_DEPRECATED_SINCE(6, 4)
+ QT_DEPRECATED_VERSION_X_6_4("Use another constructor")
QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
+#endif
QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos,
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers,
@@ -245,9 +214,6 @@ public:
Qt::MouseButton button, Qt::MouseButtons buttons,
Qt::KeyboardModifiers modifiers, Qt::MouseEventSource source,
const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
- ~QMouseEvent();
-
- QMouseEvent *clone() const override { return new QMouseEvent(*this); }
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
inline QPoint pos() const { return position().toPoint(); }
@@ -271,21 +237,24 @@ public:
QPointF windowPos() const { return scenePosition(); }
QT_DEPRECATED_VERSION_X_6_0("Use globalPosition()")
QPointF screenPos() const { return globalPosition(); }
+#endif // QT_DEPRECATED_SINCE(6, 0)
Qt::MouseEventSource source() const;
Qt::MouseEventFlags flags() const;
-#endif // QT_DEPRECATED_SINCE(6, 0)
};
class Q_GUI_EXPORT QHoverEvent : public QSinglePointEvent
{
- Q_EVENT_DISABLE_COPY(QHoverEvent);
+ Q_DECL_EVENT_COMMON(QHoverEvent)
public:
+ QHoverEvent(Type type, const QPointF &scenePos, const QPointF &globalPos, const QPointF &oldPos,
+ Qt::KeyboardModifiers modifiers = Qt::NoModifier,
+ const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
+#if QT_DEPRECATED_SINCE(6, 3)
+ QT_DEPRECATED_VERSION_X_6_3("Use the other constructor")
QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos,
Qt::KeyboardModifiers modifiers = Qt::NoModifier,
const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
- ~QHoverEvent();
-
- QHoverEvent *clone() const override { return new QHoverEvent(*this); }
+#endif
#if QT_DEPRECATED_SINCE(6, 0)
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
@@ -317,7 +286,7 @@ class Q_GUI_EXPORT QWheelEvent : public QSinglePointEvent
Q_PROPERTY(Qt::ScrollPhase phase READ phase)
Q_PROPERTY(bool inverted READ inverted)
- Q_EVENT_DISABLE_COPY(QWheelEvent);
+ Q_DECL_EVENT_COMMON(QWheelEvent)
public:
enum { DefaultDeltasPerStep = 120 };
@@ -325,9 +294,6 @@ public:
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Qt::ScrollPhase phase,
bool inverted, Qt::MouseEventSource source = Qt::MouseEventNotSynthesized,
const QPointingDevice *device = QPointingDevice::primaryPointingDevice());
- ~QWheelEvent();
-
- QWheelEvent *clone() const override { return new QWheelEvent(*this); }
inline QPoint pixelDelta() const { return m_pixelDelta; }
inline QPoint angleDelta() const { return m_angleDelta; }
@@ -351,7 +317,7 @@ protected:
#if QT_CONFIG(tabletevent)
class Q_GUI_EXPORT QTabletEvent : public QSinglePointEvent
{
- Q_EVENT_DISABLE_COPY(QTabletEvent);
+ Q_DECL_EVENT_COMMON(QTabletEvent)
public:
QTabletEvent(Type t, const QPointingDevice *device,
const QPointF &pos, const QPointF &globalPos,
@@ -359,9 +325,6 @@ public:
float tangentialPressure, qreal rotation, float z,
Qt::KeyboardModifiers keyState,
Qt::MouseButton button, Qt::MouseButtons buttons);
- ~QTabletEvent();
-
- QTabletEvent *clone() const override { return new QTabletEvent(*this); }
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X_6_0("Use position()")
@@ -406,7 +369,7 @@ protected:
#if QT_CONFIG(gestures)
class Q_GUI_EXPORT QNativeGestureEvent : public QSinglePointEvent
{
- Q_EVENT_DISABLE_COPY(QNativeGestureEvent);
+ Q_DECL_EVENT_COMMON(QNativeGestureEvent)
public:
#if QT_DEPRECATED_SINCE(6, 2)
QT_DEPRECATED_VERSION_X_6_2("Use the other constructor")
@@ -415,15 +378,18 @@ public:
#endif
QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, int fingerCount,
const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos,
- qreal value, QVector2D deltas, quint64 sequenceId = UINT64_MAX);
- ~QNativeGestureEvent();
-
- QNativeGestureEvent *clone() const override { return new QNativeGestureEvent(*this); }
+ qreal value, const QPointF &delta, quint64 sequenceId = UINT64_MAX);
Qt::NativeGestureType gestureType() const { return m_gestureType; }
int fingerCount() const { return m_fingerCount; }
qreal value() const { return m_realValue; }
- QVector2D deltas() const { return m_deltas; }
+ QPointF delta() const {
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ return m_delta.toPointF();
+#else
+ return m_delta;
+#endif
+ }
#if QT_DEPRECATED_SINCE(6, 0)
#ifndef QT_NO_INTEGER_EVENT_COORDINATES
@@ -442,7 +408,11 @@ public:
protected:
quint64 m_sequenceId;
- QVector2D m_deltas;
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ QVector2D m_delta;
+#else
+ QPointF m_delta;
+#endif
qreal m_realValue;
Qt::NativeGestureType m_gestureType;
quint32 m_fingerCount : 4;
@@ -452,7 +422,7 @@ protected:
class Q_GUI_EXPORT QKeyEvent : public QInputEvent
{
- Q_EVENT_DISABLE_COPY(QKeyEvent);
+ Q_DECL_EVENT_COMMON(QKeyEvent)
public:
QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(),
bool autorep = false, quint16 count = 1);
@@ -460,9 +430,6 @@ public:
quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
const QString &text = QString(), bool autorep = false, quint16 count = 1,
const QInputDevice *device = QInputDevice::primaryKeyboard());
- ~QKeyEvent();
-
- QKeyEvent *clone() const override { return new QKeyEvent(*this); }
int key() const { return m_key; }
#if QT_CONFIG(shortcut)
@@ -501,12 +468,9 @@ protected:
class Q_GUI_EXPORT QFocusEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QFocusEvent);
+ Q_DECL_EVENT_COMMON(QFocusEvent)
public:
explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason);
- ~QFocusEvent();
-
- QFocusEvent *clone() const override { return new QFocusEvent(*this); }
inline bool gotFocus() const { return type() == FocusIn; }
inline bool lostFocus() const { return type() == FocusOut; }
@@ -520,13 +484,10 @@ private:
class Q_GUI_EXPORT QPaintEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QPaintEvent);
+ Q_DECL_EVENT_COMMON(QPaintEvent)
public:
explicit QPaintEvent(const QRegion& paintRegion);
explicit QPaintEvent(const QRect &paintRect);
- ~QPaintEvent();
-
- QPaintEvent *clone() const override { return new QPaintEvent(*this); }
inline const QRect &rect() const { return m_rect; }
inline const QRegion &region() const { return m_region; }
@@ -539,12 +500,9 @@ protected:
class Q_GUI_EXPORT QMoveEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QMoveEvent);
+ Q_DECL_EVENT_COMMON(QMoveEvent)
public:
QMoveEvent(const QPoint &pos, const QPoint &oldPos);
- ~QMoveEvent();
-
- QMoveEvent *clone() const override { return new QMoveEvent(*this); }
inline const QPoint &pos() const { return m_pos; }
inline const QPoint &oldPos() const { return m_oldPos;}
@@ -555,12 +513,9 @@ protected:
class Q_GUI_EXPORT QExposeEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QExposeEvent);
+ Q_DECL_EVENT_COMMON(QExposeEvent)
public:
explicit QExposeEvent(const QRegion &m_region);
- ~QExposeEvent();
-
- QExposeEvent *clone() const override { return new QExposeEvent(*this); }
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X_6_0("Handle QPaintEvent instead")
@@ -569,11 +524,12 @@ public:
protected:
QRegion m_region;
+ friend class QWidgetWindow;
};
class Q_GUI_EXPORT QPlatformSurfaceEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QPlatformSurfaceEvent);
+ Q_DECL_EVENT_COMMON(QPlatformSurfaceEvent)
public:
enum SurfaceEventType {
SurfaceCreated,
@@ -581,9 +537,6 @@ public:
};
explicit QPlatformSurfaceEvent(SurfaceEventType surfaceEventType);
- ~QPlatformSurfaceEvent();
-
- QPlatformSurfaceEvent *clone() const override { return new QPlatformSurfaceEvent(*this); }
inline SurfaceEventType surfaceEventType() const { return m_surfaceEventType; }
@@ -593,12 +546,9 @@ protected:
class Q_GUI_EXPORT QResizeEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QResizeEvent);
+ Q_DECL_EVENT_COMMON(QResizeEvent)
public:
QResizeEvent(const QSize &size, const QSize &oldSize);
- ~QResizeEvent();
-
- QResizeEvent *clone() const override { return new QResizeEvent(*this); }
inline const QSize &size() const { return m_size; }
inline const QSize &oldSize()const { return m_oldSize;}
@@ -610,52 +560,48 @@ protected:
class Q_GUI_EXPORT QCloseEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QCloseEvent);
+ Q_DECL_EVENT_COMMON(QCloseEvent)
public:
QCloseEvent();
- ~QCloseEvent();
};
class Q_GUI_EXPORT QIconDragEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QIconDragEvent);
+ Q_DECL_EVENT_COMMON(QIconDragEvent)
public:
QIconDragEvent();
- ~QIconDragEvent();
};
class Q_GUI_EXPORT QShowEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QShowEvent);
+ Q_DECL_EVENT_COMMON(QShowEvent)
public:
QShowEvent();
- ~QShowEvent();
};
class Q_GUI_EXPORT QHideEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QHideEvent);
+ Q_DECL_EVENT_COMMON(QHideEvent)
public:
QHideEvent();
- ~QHideEvent();
};
#ifndef QT_NO_CONTEXTMENU
class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent
{
- Q_EVENT_DISABLE_COPY(QContextMenuEvent);
+ Q_DECL_EVENT_COMMON(QContextMenuEvent)
public:
enum Reason { Mouse, Keyboard, Other };
QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+#if QT_DEPRECATED_SINCE(6, 4)
+ QT_DEPRECATED_VERSION_X_6_4("Use the other constructor")
QContextMenuEvent(Reason reason, const QPoint &pos);
- ~QContextMenuEvent();
-
- QContextMenuEvent *clone() const override { return new QContextMenuEvent(*this); }
+#endif
inline int x() const { return m_pos.x(); }
inline int y() const { return m_pos.y(); }
@@ -677,7 +623,7 @@ protected:
#ifndef QT_NO_INPUTMETHOD
class Q_GUI_EXPORT QInputMethodEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QInputMethodEvent);
+ Q_DECL_EVENT_COMMON(QInputMethodEvent)
public:
enum AttributeType {
TextFormat,
@@ -698,9 +644,6 @@ public:
};
QInputMethodEvent();
QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes);
- ~QInputMethodEvent();
-
- QInputMethodEvent *clone() const override { return new QInputMethodEvent(*this); }
void setCommitString(const QString &commitString, int replaceFrom = 0, int replaceLength = 0);
inline const QList<Attribute> &attributes() const { return m_attributes; }
@@ -734,12 +677,9 @@ Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_RELOCATABLE_TYPE);
class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QInputMethodQueryEvent);
+ Q_DECL_EVENT_COMMON(QInputMethodQueryEvent)
public:
explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries);
- ~QInputMethodQueryEvent();
-
- QInputMethodQueryEvent *clone() const override { return new QInputMethodQueryEvent(*this); }
Qt::InputMethodQueries queries() const { return m_queries; }
@@ -764,13 +704,10 @@ class QMimeData;
class Q_GUI_EXPORT QDropEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QDropEvent);
+ Q_DECL_EVENT_COMMON(QDropEvent)
public:
QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop);
- ~QDropEvent();
-
- QDropEvent *clone() const override { return new QDropEvent(*this); }
#if QT_DEPRECATED_SINCE(6, 0)
QT_DEPRECATED_VERSION_X_6_0("Use position().toPoint()")
@@ -811,13 +748,10 @@ protected:
class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent
{
- Q_EVENT_DISABLE_COPY(QDragMoveEvent);
+ Q_DECL_EVENT_COMMON(QDragMoveEvent)
public:
QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove);
- ~QDragMoveEvent();
-
- QDragMoveEvent *clone() const override { return new QDragMoveEvent(*this); }
inline QRect answerRect() const { return m_rect; }
@@ -834,32 +768,27 @@ protected:
class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent
{
- Q_EVENT_DISABLE_COPY(QDragEnterEvent);
+ Q_DECL_EVENT_COMMON(QDragEnterEvent)
public:
QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data,
Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers);
- ~QDragEnterEvent();
};
class Q_GUI_EXPORT QDragLeaveEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QDragLeaveEvent);
+ Q_DECL_EVENT_COMMON(QDragLeaveEvent)
public:
QDragLeaveEvent();
- ~QDragLeaveEvent();
};
#endif // QT_CONFIG(draganddrop)
class Q_GUI_EXPORT QHelpEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QHelpEvent);
+ Q_DECL_EVENT_COMMON(QHelpEvent)
public:
QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos);
- ~QHelpEvent();
-
- QHelpEvent *clone() const override { return new QHelpEvent(*this); }
inline int x() const { return m_pos.x(); }
inline int y() const { return m_pos.y(); }
@@ -877,12 +806,9 @@ private:
#ifndef QT_NO_STATUSTIP
class Q_GUI_EXPORT QStatusTipEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QStatusTipEvent);
+ Q_DECL_EVENT_COMMON(QStatusTipEvent)
public:
explicit QStatusTipEvent(const QString &tip);
- ~QStatusTipEvent();
-
- QStatusTipEvent *clone() const override { return new QStatusTipEvent(*this); }
inline QString tip() const { return m_tip; }
private:
@@ -893,12 +819,9 @@ private:
#if QT_CONFIG(whatsthis)
class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QWhatsThisClickedEvent);
+ Q_DECL_EVENT_COMMON(QWhatsThisClickedEvent)
public:
explicit QWhatsThisClickedEvent(const QString &href);
- ~QWhatsThisClickedEvent();
-
- QWhatsThisClickedEvent *clone() const override { return new QWhatsThisClickedEvent(*this); }
inline QString href() const { return m_href; }
private:
@@ -909,12 +832,9 @@ private:
#if QT_CONFIG(action)
class Q_GUI_EXPORT QActionEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QActionEvent);
+ Q_DECL_EVENT_COMMON(QActionEvent)
public:
QActionEvent(int type, QAction *action, QAction *before = nullptr);
- ~QActionEvent();
-
- QActionEvent *clone() const override { return new QActionEvent(*this); }
inline QAction *action() const { return m_action; }
inline QAction *before() const { return m_before; }
@@ -926,17 +846,17 @@ private:
class Q_GUI_EXPORT QFileOpenEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QFileOpenEvent);
+ Q_DECL_EVENT_COMMON(QFileOpenEvent)
public:
explicit QFileOpenEvent(const QString &file);
explicit QFileOpenEvent(const QUrl &url);
- ~QFileOpenEvent();
-
- QFileOpenEvent *clone() const override { return new QFileOpenEvent(*this); }
inline QString file() const { return m_file; }
QUrl url() const { return m_url; }
+#if QT_DEPRECATED_SINCE(6, 6)
+ QT_DEPRECATED_VERSION_X_6_6("Interpret the string returned by file()")
bool openFile(QFile &file, QIODevice::OpenMode flags) const;
+#endif
private:
QString m_file;
QUrl m_url;
@@ -945,12 +865,9 @@ private:
#ifndef QT_NO_TOOLBAR
class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QToolBarChangeEvent);
+ Q_DECL_EVENT_COMMON(QToolBarChangeEvent)
public:
explicit QToolBarChangeEvent(bool t);
- ~QToolBarChangeEvent();
-
- QToolBarChangeEvent *clone() const override { return new QToolBarChangeEvent(*this); }
inline bool toggle() const { return m_toggle; }
private:
@@ -961,14 +878,14 @@ private:
#if QT_CONFIG(shortcut)
class Q_GUI_EXPORT QShortcutEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QShortcutEvent);
+ Q_DECL_EVENT_COMMON(QShortcutEvent)
public:
+ // Note this is publicly deprecated, but should remain as internal constructor:
QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false);
- ~QShortcutEvent();
-
- QShortcutEvent *clone() const override { return new QShortcutEvent(*this); }
+ QShortcutEvent(const QKeySequence &key, const QShortcut *shortcut = nullptr, bool ambiguous = false);
inline const QKeySequence &key() const { return m_sequence; }
+ // Note this is publicly deprecated, but should remain as internal getter:
inline int shortcutId() const { return m_shortcutId; }
inline bool isAmbiguous() const { return m_ambiguous; }
protected:
@@ -980,12 +897,9 @@ protected:
class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent
{
- Q_EVENT_DISABLE_COPY(QWindowStateChangeEvent);
+ Q_DECL_EVENT_COMMON(QWindowStateChangeEvent)
public:
explicit QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride = false);
- ~QWindowStateChangeEvent();
-
- QWindowStateChangeEvent *clone() const override { return new QWindowStateChangeEvent(*this); }
inline Qt::WindowStates oldState() const { return m_oldStates; }
bool isOverride() const;
@@ -1001,7 +915,7 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *);
class Q_GUI_EXPORT QTouchEvent : public QPointerEvent
{
- Q_EVENT_DISABLE_COPY(QTouchEvent);
+ Q_DECL_EVENT_COMMON(QTouchEvent)
public:
using TouchPoint = QEventPoint; // source compat
@@ -1017,9 +931,6 @@ public:
QEventPoint::States touchPointStates,
const QList<QEventPoint> &touchPoints = {});
#endif
- ~QTouchEvent();
-
- QTouchEvent *clone() const override { return new QTouchEvent(*this); }
inline QObject *target() const { return m_target; }
inline QEventPoint::States touchPointStates() const { return m_touchPointStates; }
@@ -1039,12 +950,9 @@ protected:
class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QScrollPrepareEvent);
+ Q_DECL_EVENT_COMMON(QScrollPrepareEvent)
public:
explicit QScrollPrepareEvent(const QPointF &startPos);
- ~QScrollPrepareEvent();
-
- QScrollPrepareEvent *clone() const override { return new QScrollPrepareEvent(*this); }
QPointF startPos() const { return m_startPos; }
@@ -1066,7 +974,7 @@ private:
class Q_GUI_EXPORT QScrollEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QScrollEvent);
+ Q_DECL_EVENT_COMMON(QScrollEvent)
public:
enum ScrollState
{
@@ -1076,9 +984,6 @@ public:
};
QScrollEvent(const QPointF &contentPos, const QPointF &overshoot, ScrollState scrollState);
- ~QScrollEvent();
-
- QScrollEvent *clone() const override { return new QScrollEvent(*this); }
QPointF contentPos() const { return m_contentPos; }
QPointF overshootDistance() const { return m_overshoot; }
@@ -1092,12 +997,9 @@ private:
class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QScreenOrientationChangeEvent);
+ Q_DECL_EVENT_COMMON(QScreenOrientationChangeEvent)
public:
QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation);
- ~QScreenOrientationChangeEvent();
-
- QScreenOrientationChangeEvent *clone() const override { return new QScreenOrientationChangeEvent(*this); }
QScreen *screen() const { return m_screen; }
Qt::ScreenOrientation orientation() const { return m_orientation; }
@@ -1109,18 +1011,27 @@ private:
class Q_GUI_EXPORT QApplicationStateChangeEvent : public QEvent
{
- Q_EVENT_DISABLE_COPY(QApplicationStateChangeEvent);
+ Q_DECL_EVENT_COMMON(QApplicationStateChangeEvent)
public:
explicit QApplicationStateChangeEvent(Qt::ApplicationState state);
- QApplicationStateChangeEvent *clone() const override { return new QApplicationStateChangeEvent(*this); }
-
Qt::ApplicationState applicationState() const { return m_applicationState; }
private:
Qt::ApplicationState m_applicationState;
};
+class Q_GUI_EXPORT QChildWindowEvent : public QEvent
+{
+ Q_DECL_EVENT_COMMON(QChildWindowEvent)
+public:
+ explicit QChildWindowEvent(Type type, QWindow *childWindow);
+ QWindow *child() const { return c; }
+
+private:
+ QWindow *c;
+};
+
QT_END_NAMESPACE
#endif // QEVENT_H
diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h
index 227b1a4303..96ef8f123e 100644
--- a/src/gui/kernel/qevent_p.h
+++ b/src/gui/kernel/qevent_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 QEVENT_P_H
#define QEVENT_P_H
@@ -52,7 +16,6 @@
//
#include <QtGui/private/qtguiglobal_p.h>
-#include <QtGui/private/qeventpoint_p.h>
#include <QtCore/qurl.h>
#include <QtGui/qevent.h>
#include <QtGui/qwindow.h>
@@ -69,6 +32,7 @@ public:
Qt::KeyboardModifiers modifiers = Qt::NoModifier,
const QList<QEventPoint> &touchPoints = QList<QEventPoint>()) :
QTouchEvent(eventType, device, modifiers, touchPoints) { }
+ ~QMutableTouchEvent() override;
static QMutableTouchEvent *from(QTouchEvent *e) { return static_cast<QMutableTouchEvent *>(e); }
@@ -88,13 +52,12 @@ public:
Qt::KeyboardModifiers modifiers = Qt::NoModifier,
Qt::MouseEventSource source = Qt::MouseEventSynthesizedByQt) :
QSinglePointEvent(type, device, point, button, buttons, modifiers, source) { }
+ ~QMutableSinglePointEvent() override;
static QMutableSinglePointEvent *from(QSinglePointEvent *e) { return static_cast<QMutableSinglePointEvent *>(e); }
static QMutableSinglePointEvent &from(QSinglePointEvent &e) { return static_cast<QMutableSinglePointEvent &>(e); }
- QMutableEventPoint &mutablePoint() { return QMutableEventPoint::from(point(0)); }
-
void setSource(Qt::MouseEventSource s) { m_source = s; }
bool isDoubleClick() { return m_doubleClick; }
diff --git a/src/gui/kernel/qeventpoint.cpp b/src/gui/kernel/qeventpoint.cpp
index 0c8428286a..66d4f44ea0 100644
--- a/src/gui/kernel/qeventpoint.cpp
+++ b/src/gui/kernel/qeventpoint.cpp
@@ -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
#include "qeventpoint.h"
#include "private/qeventpoint_p.h"
@@ -142,8 +106,7 @@ bool QEventPoint::operator==(const QEventPoint &other) const noexcept
QEventPoint::~QEventPoint() = default;
/*! \fn QPointF QEventPoint::pos() const
- \deprecated
- Deprecated since Qt 6.0. Use position() instead.
+ \deprecated [6.0] Use position() instead.
Returns the position of this point, relative to the widget
or item that received the event.
@@ -376,7 +339,7 @@ ulong QEventPoint::pressTimestamp() const
/*!
\property QEventPoint::timeHeld
- \brief the duration, in milliseconds, since this point was pressed and not released.
+ \brief the duration, in seconds, since this point was pressed and not released.
\sa pressTimestamp, timestamp
*/
@@ -443,10 +406,8 @@ bool QEventPoint::isAccepted() const
/*!
- \deprecated
\fn QPointF QEventPoint::normalizedPos() const
-
- Deprecated since Qt 6.0. Use normalizedPosition() instead.
+ \deprecated [6.0] Use normalizedPosition() instead.
*/
/*!
@@ -469,9 +430,9 @@ QPointF QEventPoint::normalizedPosition() const
return (globalPosition() - geom.topLeft()) / geom.width();
}
+#if QT_DEPRECATED_SINCE(6, 0)
/*!
- \deprecated
- Deprecated since Qt 6.0. Use globalPressPosition() instead.
+ \deprecated [6.0] Use globalPressPosition() instead.
Returns the normalized press position of this point.
*/
@@ -487,8 +448,7 @@ QPointF QEventPoint::startNormalizedPos() const
}
/*!
- \deprecated
- Deprecated since Qt 6.0. Use globalLastPosition() instead.
+ \deprecated [6.0] Use globalLastPosition() instead.
Returns the normalized position of this point from the previous press or
move event.
@@ -496,7 +456,7 @@ QPointF QEventPoint::startNormalizedPos() const
The coordinates are normalized to QInputDevice::availableVirtualGeometry(),
i.e. \c (0, 0) is the top-left corner and \c (1, 1) is the bottom-right corner.
- \sa normalizedPos(), startNormalizedPos()
+ \sa normalizedPosition(), globalPressPosition()
*/
QPointF QEventPoint::lastNormalizedPos() const
{
@@ -508,7 +468,7 @@ QPointF QEventPoint::lastNormalizedPos() const
return QPointF();
return (globalLastPosition() - geom.topLeft()) / geom.width();
}
-
+#endif // QT_DEPRECATED_SINCE(6, 0)
/*! \internal
This class is explicitly shared, which means if you construct an event and
@@ -520,17 +480,17 @@ QPointF QEventPoint::lastNormalizedPos() const
modify an independent copy. (The independent copy can then be used in a
subsequent event.)
*/
-void QMutableEventPoint::detach()
+void QMutableEventPoint::detach(QEventPoint &p)
{
- if (d)
- d.detach();
+ if (p.d)
+ p.d.detach();
else
- d.reset(new QEventPointPrivate(-1, nullptr));
+ p.d.reset(new QEventPointPrivate(-1, nullptr));
}
/*! \internal
- Update current state from the given \a other point, assuming that this
- instance contains state from the previous event and \a other contains new
+ Update \a target state from the \a other point, assuming that \a target
+ contains state from the previous event and \a other contains new
values that came in from a device.
That is: global position and other valuators will be updated, but
@@ -542,40 +502,41 @@ void QMutableEventPoint::detach()
\li properties that should be persistent between events (such as grabbers)
\endlist
*/
-void QMutableEventPoint::updateFrom(const QEventPoint &other)
+void QMutableEventPoint::update(const QEventPoint &other, QEventPoint &target)
{
- detach();
- setPressure(other.pressure());
+ detach(target);
+ setPressure(target, other.pressure());
switch (other.state()) {
case QEventPoint::State::Pressed:
- setGlobalPressPosition(other.globalPosition());
- setGlobalLastPosition(other.globalPosition());
- if (pressure() < 0)
- setPressure(1);
+ setGlobalPressPosition(target, other.globalPosition());
+ setGlobalLastPosition(target, other.globalPosition());
+ if (target.pressure() < 0)
+ setPressure(target, 1);
break;
case QEventPoint::State::Released:
- if (globalPosition() != other.globalPosition())
- setGlobalLastPosition(globalPosition());
- setPressure(0);
+ if (target.globalPosition() != other.globalPosition())
+ setGlobalLastPosition(target, target.globalPosition());
+ setPressure(target, 0);
break;
default: // update or stationary
- if (globalPosition() != other.globalPosition())
- setGlobalLastPosition(globalPosition());
- if (pressure() < 0)
- setPressure(1);
+ if (target.globalPosition() != other.globalPosition())
+ setGlobalLastPosition(target, target.globalPosition());
+ if (target.pressure() < 0)
+ setPressure(target, 1);
break;
}
- setState(other.state());
- setPosition(other.position());
- setScenePosition(other.scenePosition());
- setGlobalPosition(other.globalPosition());
- setEllipseDiameters(other.ellipseDiameters());
- setRotation(other.rotation());
- setVelocity(other.velocity());
+ setState(target, other.state());
+ setPosition(target, other.position());
+ setScenePosition(target, other.scenePosition());
+ setGlobalPosition(target, other.globalPosition());
+ setEllipseDiameters(target, other.ellipseDiameters());
+ setRotation(target, other.rotation());
+ setVelocity(target, other.velocity());
+ setUniqueId(target, other.uniqueId()); // for TUIO
}
/*! \internal
@@ -596,33 +557,33 @@ void QMutableEventPoint::updateFrom(const QEventPoint &other)
The velocity calculation is skipped if the platform has promised to
provide velocities already by setting the QInputDevice::Velocity capability.
*/
-void QMutableEventPoint::setTimestamp(const ulong t)
+void QMutableEventPoint::setTimestamp(QEventPoint &p, ulong t)
{
// On mouse press, if the mouse has moved from its last-known location,
// QGuiApplicationPrivate::processMouseEvent() sends first a mouse move and
// then a press. Both events will get the same timestamp. So we need to set
// the press timestamp and position even when the timestamp isn't advancing,
// but skip setting lastTimestamp and velocity because those need a time delta.
- if (d) {
- if (state() == QEventPoint::State::Pressed) {
- d->pressTimestamp = t;
- d->globalPressPos = d->globalPos;
+ if (p.d) {
+ if (p.state() == QEventPoint::State::Pressed) {
+ p.d->pressTimestamp = t;
+ p.d->globalPressPos = p.d->globalPos;
}
- if (d->timestamp == t)
+ if (p.d->timestamp == t)
return;
}
- detach();
- if (device()) {
+ detach(p);
+ if (p.device()) {
// get the persistent instance out of QPointingDevicePrivate::activePoints
// (which sometimes might be the same as this instance)
QEventPointPrivate *pd = QPointingDevicePrivate::get(
- const_cast<QPointingDevice *>(d->device))->pointById(id())->eventPoint.d.get();
+ const_cast<QPointingDevice *>(p.d->device))->pointById(p.id())->eventPoint.d.get();
if (t > pd->timestamp) {
pd->lastTimestamp = pd->timestamp;
pd->timestamp = t;
- if (state() == QEventPoint::State::Pressed)
+ if (p.state() == QEventPoint::State::Pressed)
pd->pressTimestamp = t;
- if (pd->lastTimestamp > 0 && !device()->capabilities().testFlag(QInputDevice::Capability::Velocity)) {
+ if (pd->lastTimestamp > 0 && !p.device()->capabilities().testFlag(QInputDevice::Capability::Velocity)) {
// calculate instantaneous velocity according to time and distance moved since the previous point
QVector2D newVelocity = QVector2D(pd->globalPos - pd->globalLastPos) / (t - pd->lastTimestamp) * 1000;
// VERY simple kalman filter: does a weighted average
@@ -633,17 +594,17 @@ void QMutableEventPoint::setTimestamp(const ulong t)
"based on movement" << pd->globalLastPos << "->" << pd->globalPos <<
"over time" << pd->lastTimestamp << "->" << pd->timestamp;
}
- if (d != pd) {
- d->lastTimestamp = pd->lastTimestamp;
- d->velocity = pd->velocity;
+ if (p.d != pd) {
+ p.d->lastTimestamp = pd->lastTimestamp;
+ p.d->velocity = pd->velocity;
}
}
}
- d->timestamp = t;
+ p.d->timestamp = t;
}
/*!
- \fn void QMutableEventPoint::setPosition(const QPointF &pos)
+ \fn void QMutableEventPoint::setPosition(QPointF pos)
\internal
Sets the localized position.
@@ -654,3 +615,5 @@ void QMutableEventPoint::setTimestamp(const ulong t)
*/
QT_END_NAMESPACE
+
+#include "moc_qeventpoint.cpp"
diff --git a/src/gui/kernel/qeventpoint.h b/src/gui/kernel/qeventpoint.h
index 52b5c26039..518faecee2 100644
--- a/src/gui/kernel/qeventpoint.h
+++ b/src/gui/kernel/qeventpoint.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 QEVENTPOINT_H
#define QEVENTPOINT_H
@@ -50,12 +14,12 @@ QT_BEGIN_NAMESPACE
class QEventPointPrivate;
QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QEventPointPrivate, Q_GUI_EXPORT)
+class QMutableEventPoint;
class Q_GUI_EXPORT QEventPoint
{
Q_GADGET
Q_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
- QDOC_PROPERTY(QPointingDevice *device READ device CONSTANT) // qdoc doesn't know const
Q_PROPERTY(const QPointingDevice *device READ device CONSTANT)
Q_PROPERTY(int id READ id CONSTANT)
Q_PROPERTY(QPointingDeviceUniqueId uniqueId READ uniqueId CONSTANT)
@@ -101,7 +65,7 @@ public:
bool operator!=(const QEventPoint &other) const noexcept { return !operator==(other); }
~QEventPoint();
inline void swap(QEventPoint &other) noexcept
- { qSwap(d, other.d); }
+ { d.swap(other.d); }
QPointF position() const;
QPointF pressPosition() const;
diff --git a/src/gui/kernel/qeventpoint_p.h b/src/gui/kernel/qeventpoint_p.h
index f10739343f..c339c7e3e1 100644
--- a/src/gui/kernel/qeventpoint_p.h
+++ b/src/gui/kernel/qeventpoint_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 QEVENTPOINT_P_H
#define QEVENTPOINT_P_H
@@ -53,7 +17,9 @@
#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qevent.h>
+
#include <QtCore/qloggingcategory.h>
+#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
@@ -118,84 +84,58 @@ public:
// Private subclasses to allow accessing and modifying protected variables.
// These should NOT hold any extra state.
-class Q_GUI_EXPORT QMutableEventPoint : public QEventPoint
+class QMutableEventPoint
{
public:
- QMutableEventPoint(int pointId = -1, State state = QEventPoint::State::Stationary,
- const QPointF &scenePosition = QPointF(), const QPointF &globalPosition = QPointF()) :
- QEventPoint(pointId, state, scenePosition, globalPosition) {}
-
- QMutableEventPoint(ulong timestamp, int pointId, State state,
- const QPointF &position, const QPointF &scenePosition, const QPointF &globalPosition) :
- QEventPoint(pointId, state, scenePosition, globalPosition)
+ static QEventPoint withTimeStamp(ulong timestamp, int pointId, QEventPoint::State state,
+ QPointF position, QPointF scenePosition, QPointF globalPosition)
{
- d->timestamp = timestamp;
- d->pos = position;
+ QEventPoint p(pointId, state, scenePosition, globalPosition);
+ p.d->timestamp = timestamp;
+ p.d->pos = position;
+ return p;
}
- void updateFrom(const QEventPoint &other);
-
- static QMutableEventPoint *from(QEventPoint *me) { return static_cast<QMutableEventPoint *>(me); }
-
- static QMutableEventPoint &from(QEventPoint &me) { return static_cast<QMutableEventPoint &>(me); }
-
- static const QMutableEventPoint &constFrom(const QEventPoint &me) { return static_cast<const QMutableEventPoint &>(me); }
-
- void detach();
-
- void setId(int pointId) { d->pointId = pointId; }
-
- void setDevice(const QPointingDevice *device) { d->device = device; }
-
- void setTimestamp(const ulong t);
+ static Q_GUI_EXPORT void update(const QEventPoint &from, QEventPoint &to);
- void setPressTimestamp(const ulong t) { d->pressTimestamp = t; }
+ static Q_GUI_EXPORT void detach(QEventPoint &p);
- void setState(QEventPoint::State state) { d->state = state; }
+#define TRIVIAL_SETTER(type, field, Field) \
+ static void set##Field (QEventPoint &p, type arg) { p.d->field = std::move(arg); } \
+ /* end */
- void setUniqueId(const QPointingDeviceUniqueId &uid) { d->uniqueId = uid; }
+ TRIVIAL_SETTER(int, pointId, Id)
+ TRIVIAL_SETTER(const QPointingDevice *, device, Device)
- void setPosition(const QPointF &pos) { d->pos = pos; }
+ // not trivial:
+ static Q_GUI_EXPORT void setTimestamp(QEventPoint &p, ulong t);
- void setScenePosition(const QPointF &pos) { d->scenePos = pos; }
+ TRIVIAL_SETTER(ulong, pressTimestamp, PressTimestamp)
+ TRIVIAL_SETTER(QEventPoint::State, state, State)
+ TRIVIAL_SETTER(QPointingDeviceUniqueId, uniqueId, UniqueId)
+ TRIVIAL_SETTER(QPointF, pos, Position)
+ TRIVIAL_SETTER(QPointF, scenePos, ScenePosition)
+ TRIVIAL_SETTER(QPointF, globalPos, GlobalPosition)
- void setGlobalPosition(const QPointF &pos) { d->globalPos = pos; }
+ TRIVIAL_SETTER(QPointF, globalPressPos, GlobalPressPosition)
+ TRIVIAL_SETTER(QPointF, globalGrabPos, GlobalGrabPosition)
+ TRIVIAL_SETTER(QPointF, globalLastPos, GlobalLastPosition)
+ TRIVIAL_SETTER(QSizeF, ellipseDiameters, EllipseDiameters)
+ TRIVIAL_SETTER(qreal, pressure, Pressure)
+ TRIVIAL_SETTER(qreal, rotation, Rotation)
+ TRIVIAL_SETTER(QVector2D, velocity, Velocity)
-#if QT_DEPRECATED_SINCE(6, 0)
- // temporary replacements for QTouchEvent::TouchPoint setters, mainly to make porting easier
- QT_DEPRECATED_VERSION_X_6_0("Use setPosition()")
- void setPos(const QPointF &pos) { d->pos = pos; }
- QT_DEPRECATED_VERSION_X_6_0("Use setScenePosition()")
- void setScenePos(const QPointF &pos) { d->scenePos = pos; }
- QT_DEPRECATED_VERSION_X_6_0("Use setGlobalPosition()")
- void setScreenPos(const QPointF &pos) { d->globalPos = pos; }
-#endif
+ static QWindow *window(const QEventPoint &p) { return p.d->window.data(); }
- void setGlobalPressPosition(const QPointF &pos) { d->globalPressPos = pos; }
+ TRIVIAL_SETTER(QWindow *, window, Window)
- void setGlobalGrabPosition(const QPointF &pos) { d->globalGrabPos = pos; }
+ static QObject *target(const QEventPoint &p) { return p.d->target.data(); }
- void setGlobalLastPosition(const QPointF &pos) { d->globalLastPos = pos; }
+ TRIVIAL_SETTER(QObject *, target, Target)
- void setEllipseDiameters(const QSizeF &diams) { d->ellipseDiameters = diams; }
-
- void setPressure(qreal v) { d->pressure = v; }
-
- void setRotation(qreal v) { d->rotation = v; }
-
- void setVelocity(const QVector2D &v) { d->velocity = v; }
-
- QWindow *window() const { return d->window.data(); }
-
- void setWindow(const QPointer<QWindow> &w) { d->window = w; }
-
- QObject *target() const { return d->target.data(); }
-
- void setTarget(const QPointer<QObject> &t) { d->target = t; }
+#undef TRIVIAL_SETTER
};
-static_assert(sizeof(QMutableEventPoint) == sizeof(QEventPoint));
-
QT_END_NAMESPACE
#endif // QEVENTPOINT_P_H
diff --git a/src/gui/kernel/qgenericplugin.cpp b/src/gui/kernel/qgenericplugin.cpp
index a53b60b008..8411faeb1f 100644
--- a/src/gui/kernel/qgenericplugin.cpp
+++ b/src/gui/kernel/qgenericplugin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qgenericplugin.h"
@@ -94,3 +58,5 @@ QGenericPlugin::~QGenericPlugin()
*/
QT_END_NAMESPACE
+
+#include "moc_qgenericplugin.cpp"
diff --git a/src/gui/kernel/qgenericplugin.h b/src/gui/kernel/qgenericplugin.h
index 69b4f29854..f76228dc8a 100644
--- a/src/gui/kernel/qgenericplugin.h
+++ b/src/gui/kernel/qgenericplugin.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QGENERICPLUGIN_H
#define QGENERICPLUGIN_H
diff --git a/src/gui/kernel/qgenericpluginfactory.cpp b/src/gui/kernel/qgenericpluginfactory.cpp
index 9f41b948c0..5ce13ad5e1 100644
--- a/src/gui/kernel/qgenericpluginfactory.cpp
+++ b/src/gui/kernel/qgenericpluginfactory.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qgenericpluginfactory.h"
@@ -46,9 +10,10 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QGenericPluginFactoryInterface_iid,
- QLatin1String("/generic"), Qt::CaseInsensitive))
+using namespace Qt::StringLiterals;
+
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, gpLoader,
+ (QGenericPluginFactoryInterface_iid, "/generic"_L1, Qt::CaseInsensitive))
/*!
\class QGenericPluginFactory
@@ -69,7 +34,7 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
*/
QObject *QGenericPluginFactory::create(const QString& key, const QString &specification)
{
- return qLoadPlugin<QObject, QGenericPlugin>(loader(), key.toLower(), specification);
+ return qLoadPlugin<QObject, QGenericPlugin>(gpLoader(), key.toLower(), specification);
}
/*!
@@ -84,7 +49,7 @@ QStringList QGenericPluginFactory::keys()
typedef QMultiMap<int, QString> PluginKeyMap;
typedef PluginKeyMap::const_iterator PluginKeyMapConstIterator;
- const PluginKeyMap keyMap = loader()->keyMap();
+ const PluginKeyMap keyMap = gpLoader()->keyMap();
const PluginKeyMapConstIterator cend = keyMap.constEnd();
for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it)
if (!list.contains(it.value()))
diff --git a/src/gui/kernel/qgenericpluginfactory.h b/src/gui/kernel/qgenericpluginfactory.h
index 9cc77a0590..710c983310 100644
--- a/src/gui/kernel/qgenericpluginfactory.h
+++ b/src/gui/kernel/qgenericpluginfactory.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QGENERICPLUGINFACTORY_H
#define QGENERICPLUGINFACTORY_H
diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp
index 101b33f94a..444091afef 100644
--- a/src/gui/kernel/qguiapplication.cpp
+++ b/src/gui/kernel/qguiapplication.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 The Qt Company Ltd.
-** Copyright (C) 2016 Intel Corporation.
-** 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) 2021 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 "qguiapplication.h"
@@ -44,6 +8,8 @@
#include "private/qabstractfileiconprovider_p.h"
#include <qpa/qplatformintegrationfactory_p.h>
#include "private/qevent_p.h"
+#include "private/qeventpoint_p.h"
+#include "private/qiconloader_p.h"
#include "qfont.h"
#include "qpointingdevice.h"
#include <qpa/qplatformfontdatabase.h>
@@ -51,21 +17,24 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformtheme.h>
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformkeymapper.h>
#include <QtCore/QAbstractEventDispatcher>
+#include <QtCore/QFileInfo>
#include <QtCore/QStandardPaths>
#include <QtCore/QVariant>
#include <QtCore/private/qcoreapplication_p.h>
#include <QtCore/private/qabstracteventdispatcher_p.h>
+#include <QtCore/private/qminimalflatset_p.h>
#include <QtCore/qmutex.h>
#include <QtCore/private/qthread_p.h>
#include <QtCore/private/qlocking_p.h>
#include <QtCore/private/qflatmap_p.h>
#include <QtCore/qdir.h>
#include <QtCore/qlibraryinfo.h>
-#include <QtCore/qnumeric.h>
+#include <QtCore/private/qnumeric_p.h>
#include <QtDebug>
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
#include "qaccessible.h"
#endif
#include <qpalette.h>
@@ -76,6 +45,7 @@
#include <QtGui/qgenericpluginfactory.h>
#include <QtGui/qstylehints.h>
+#include <QtGui/private/qstylehints_p.h>
#include <QtGui/qinputmethod.h>
#include <QtGui/qpixmapcache.h>
#include <qpa/qplatforminputcontext.h>
@@ -84,8 +54,11 @@
#include <qpa/qwindowsysteminterface.h>
#include <qpa/qwindowsysteminterface_p.h>
#include "private/qwindow_p.h"
+#include "private/qicon_p.h"
#include "private/qcursor_p.h"
-#include "private/qopenglcontext_p.h"
+#if QT_CONFIG(opengl)
+# include "private/qopenglcontext_p.h"
+#endif
#include "private/qinputdevicemanager_p.h"
#include "private/qinputmethod_p.h"
#include "private/qpointingdevice_p.h"
@@ -122,12 +95,21 @@
#include <emscripten.h>
#endif
+#if QT_CONFIG(vulkan)
+#include <private/qvulkandefaultinstance_p.h>
+#endif
+
#include <qtgui_tracepoints_p.h>
-#include <ctype.h>
+#include <private/qtools_p.h>
+
+#include <limits>
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+using namespace QtMiscUtils;
+
// Helper macro for static functions to check on the existence of the application class.
#define CHECK_QAPP_INSTANCE(...) \
if (Q_LIKELY(QCoreApplication::instance())) { \
@@ -137,78 +119,81 @@ QT_BEGIN_NAMESPACE
}
Q_CORE_EXPORT void qt_call_post_routines();
-Q_GUI_EXPORT bool qt_is_gui_used = true;
+Q_CONSTINIT Q_GUI_EXPORT bool qt_is_tty_app = false;
-Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
-Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
+Q_CONSTINIT Qt::MouseButtons QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
+Q_CONSTINIT Qt::KeyboardModifiers QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
-QPointF QGuiApplicationPrivate::lastCursorPosition(qInf(), qInf());
+Q_CONSTINIT QGuiApplicationPrivate::QLastCursorPosition QGuiApplicationPrivate::lastCursorPosition;
-QWindow *QGuiApplicationPrivate::currentMouseWindow = nullptr;
+Q_CONSTINIT QWindow *QGuiApplicationPrivate::currentMouseWindow = nullptr;
-QString QGuiApplicationPrivate::styleOverride;
+Q_CONSTINIT QString QGuiApplicationPrivate::styleOverride;
-Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
+Q_CONSTINIT Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
-Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy =
+Q_CONSTINIT Qt::HighDpiScaleFactorRoundingPolicy QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy =
Qt::HighDpiScaleFactorRoundingPolicy::PassThrough;
-QPointer<QWindow> QGuiApplicationPrivate::currentDragWindow;
+Q_CONSTINIT QPointer<QWindow> QGuiApplicationPrivate::currentDragWindow;
-QList<QGuiApplicationPrivate::TabletPointData> QGuiApplicationPrivate::tabletDevicePoints; // TODO remove
+Q_CONSTINIT QList<QGuiApplicationPrivate::TabletPointData> QGuiApplicationPrivate::tabletDevicePoints; // TODO remove
-QPlatformIntegration *QGuiApplicationPrivate::platform_integration = nullptr;
-QPlatformTheme *QGuiApplicationPrivate::platform_theme = nullptr;
+Q_CONSTINIT QPlatformIntegration *QGuiApplicationPrivate::platform_integration = nullptr;
+Q_CONSTINIT QPlatformTheme *QGuiApplicationPrivate::platform_theme = nullptr;
-QList<QObject *> QGuiApplicationPrivate::generic_plugin_list;
+Q_CONSTINIT QList<QObject *> QGuiApplicationPrivate::generic_plugin_list;
enum ApplicationResourceFlags
{
ApplicationFontExplicitlySet = 0x2
};
-static unsigned applicationResourceFlags = 0;
+Q_CONSTINIT static unsigned applicationResourceFlags = 0;
-QIcon *QGuiApplicationPrivate::app_icon = nullptr;
+Q_CONSTINIT QIcon *QGuiApplicationPrivate::app_icon = nullptr;
-QString *QGuiApplicationPrivate::platform_name = nullptr;
-QString *QGuiApplicationPrivate::displayName = nullptr;
-QString *QGuiApplicationPrivate::desktopFileName = nullptr;
+Q_CONSTINIT QString *QGuiApplicationPrivate::platform_name = nullptr;
+Q_CONSTINIT QString *QGuiApplicationPrivate::displayName = nullptr;
+Q_CONSTINIT QString *QGuiApplicationPrivate::desktopFileName = nullptr;
-QPalette *QGuiApplicationPrivate::app_pal = nullptr; // default application palette
+Q_CONSTINIT QPalette *QGuiApplicationPrivate::app_pal = nullptr; // default application palette
-Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton;
+Q_CONSTINIT Qt::MouseButton QGuiApplicationPrivate::mousePressButton = Qt::NoButton;
-static int mouseDoubleClickDistance = -1;
-static int touchDoubleTapDistance = -1;
+Q_CONSTINIT static int mouseDoubleClickDistance = 0;
+Q_CONSTINIT static int touchDoubleTapDistance = 0;
-QWindow *QGuiApplicationPrivate::currentMousePressWindow = nullptr;
+Q_CONSTINIT QWindow *QGuiApplicationPrivate::currentMousePressWindow = nullptr;
-static Qt::LayoutDirection layout_direction = Qt::LayoutDirectionAuto;
-static bool force_reverse = false;
+Q_CONSTINIT static Qt::LayoutDirection layout_direction = Qt::LayoutDirectionAuto;
+Q_CONSTINIT static Qt::LayoutDirection effective_layout_direction = Qt::LeftToRight;
+Q_CONSTINIT static bool force_reverse = false;
-QGuiApplicationPrivate *QGuiApplicationPrivate::self = nullptr;
-int QGuiApplicationPrivate::m_fakeMouseSourcePointId = -1;
+Q_CONSTINIT QGuiApplicationPrivate *QGuiApplicationPrivate::self = nullptr;
+Q_CONSTINIT int QGuiApplicationPrivate::m_fakeMouseSourcePointId = -1;
#ifndef QT_NO_CLIPBOARD
-QClipboard *QGuiApplicationPrivate::qt_clipboard = nullptr;
+Q_CONSTINIT QClipboard *QGuiApplicationPrivate::qt_clipboard = nullptr;
#endif
-QList<QScreen *> QGuiApplicationPrivate::screen_list;
+Q_CONSTINIT QList<QScreen *> QGuiApplicationPrivate::screen_list;
+
+Q_CONSTINIT QWindowList QGuiApplicationPrivate::window_list;
+Q_CONSTINIT QWindow *QGuiApplicationPrivate::focus_window = nullptr;
-QWindowList QGuiApplicationPrivate::window_list;
-QWindow *QGuiApplicationPrivate::focus_window = nullptr;
+Q_CONSTINIT static QBasicMutex applicationFontMutex;
+Q_CONSTINIT QFont *QGuiApplicationPrivate::app_font = nullptr;
+Q_CONSTINIT QStyleHints *QGuiApplicationPrivate::styleHints = nullptr;
+Q_CONSTINIT bool QGuiApplicationPrivate::obey_desktop_settings = true;
-static QBasicMutex applicationFontMutex;
-QFont *QGuiApplicationPrivate::app_font = nullptr;
-QStyleHints *QGuiApplicationPrivate::styleHints = nullptr;
-bool QGuiApplicationPrivate::obey_desktop_settings = true;
+Q_CONSTINIT QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = nullptr;
-QInputDeviceManager *QGuiApplicationPrivate::m_inputDeviceManager = nullptr;
+Q_CONSTINIT qreal QGuiApplicationPrivate::m_maxDevicePixelRatio = 0.0;
-qreal QGuiApplicationPrivate::m_maxDevicePixelRatio = 0.0;
+Q_CONSTINIT static qreal fontSmoothingGamma = 1.7;
-static qreal fontSmoothingGamma = 1.7;
+Q_CONSTINIT bool QGuiApplicationPrivate::quitOnLastWindowClosed = true;
extern void qRegisterGuiVariant();
#if QT_CONFIG(animation)
@@ -221,7 +206,7 @@ static bool qt_detectRTLLanguage()
(QGuiApplication::tr("QT_LAYOUT_DIRECTION",
"Translate this string to the string 'LTR' in left-to-right"
" languages or to 'RTL' in right-to-left languages (such as Hebrew"
- " and Arabic) to get proper widget layout.") == QLatin1String("RTL"));
+ " and Arabic) to get proper widget layout.") == "RTL"_L1);
}
static void initFontUnlocked()
@@ -251,7 +236,7 @@ static void initThemeHints()
static bool checkNeedPortalSupport()
{
#if QT_CONFIG(dbus)
- return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty() || qEnvironmentVariableIsSet("SNAP");
+ return QFileInfo::exists("/.flatpak-info"_L1) || qEnvironmentVariableIsSet("SNAP");
#else
return false;
#endif // QT_CONFIG(dbus)
@@ -278,20 +263,20 @@ struct QWindowGeometrySpecification
static inline int nextGeometryToken(const QByteArray &a, int &pos, char *op)
{
*op = 0;
- const int size = a.size();
+ const qsizetype size = a.size();
if (pos >= size)
return -1;
*op = a.at(pos);
if (*op == '+' || *op == '-' || *op == 'x')
pos++;
- else if (isdigit(*op))
+ else if (isAsciiDigit(*op))
*op = 'x'; // If it starts with a digit, it is supposed to be a width specification.
else
return -1;
const int numberPos = pos;
- for ( ; pos < size && isdigit(a.at(pos)); ++pos) ;
+ for ( ; pos < size && isAsciiDigit(a.at(pos)); ++pos) ;
bool ok;
const int result = a.mid(numberPos, pos - numberPos).toInt(&ok);
@@ -579,10 +564,12 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME
\list
\li \c {altgr}, detect the key \c {AltGr} found on some keyboards as
Qt::GroupSwitchModifier (since Qt 5.12).
- \li \c {darkmode=[1|2]} controls how Qt responds to the activation
+ \li \c {darkmode=[0|1|2]} controls how Qt responds to the activation
of the \e{Dark Mode for applications} introduced in Windows 10
1903 (since Qt 5.15).
+ A value of 0 disables dark mode support.
+
A value of 1 causes Qt to switch the window borders to black
when \e{Dark Mode for applications} is activated and no High
Contrast Theme is in use. This is intended for applications
@@ -594,17 +581,17 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME
experimental pending the introduction of new style that
properly adapts to dark mode.
+ As of Qt 6.5, the default value is 2; to disable dark mode
+ support, set the value to 0 or 1.
+
\li \c {dialogs=[xp|none]}, \c xp uses XP-style native dialogs and
\c none disables them.
\li \c {fontengine=freetype}, uses the FreeType font engine.
- \li \c {fontengine=directwrite}, uses the experimental DirectWrite
- font database and defaults to using the DirectWrite font
+ \li \c {fontengine=gdi}, uses the legacy GDI-based
+ font database and defaults to using the GDI font
engine (which is otherwise only used for some font types
- or font properties.) This affects font selection and aims
- to provide font naming more consistent with other platforms,
- but does not support all font formats, such as Postscript
- Type-1 or Microsoft FNT fonts.
+ or font properties.) (Since Qt 6.8).
\li \c {menus=[native|none]}, controls the use of native menus.
Native menus are implemented using Win32 API and are simpler than
@@ -618,7 +605,8 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME
\li \c {nocolorfonts} Turn off DirectWrite Color fonts
(since Qt 5.8).
- \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8).
+ \li \c {nodirectwrite} Turn off DirectWrite fonts (since Qt 5.8). This implicitly
+ also selects the GDI font engine.
\li \c {nomousefromtouch} Ignores mouse events synthesized
from touch events by the operating system.
@@ -646,9 +634,9 @@ static QWindowGeometrySpecification windowGeometrySpecification = Q_WINDOW_GEOME
#ifdef Q_QDOC
QGuiApplication::QGuiApplication(int &argc, char **argv)
#else
-QGuiApplication::QGuiApplication(int &argc, char **argv, int flags)
+QGuiApplication::QGuiApplication(int &argc, char **argv, int)
#endif
- : QCoreApplication(*new QGuiApplicationPrivate(argc, argv, flags))
+ : QCoreApplication(*new QGuiApplicationPrivate(argc, argv))
{
d_func()->init();
@@ -704,15 +692,16 @@ QGuiApplication::~QGuiApplication()
QGuiApplicationPrivate::desktopFileName = nullptr;
QGuiApplicationPrivate::mouse_buttons = Qt::NoButton;
QGuiApplicationPrivate::modifier_buttons = Qt::NoModifier;
- QGuiApplicationPrivate::lastCursorPosition = {qreal(qInf()), qreal(qInf())};
+ QGuiApplicationPrivate::lastCursorPosition.reset();
QGuiApplicationPrivate::currentMousePressWindow = QGuiApplicationPrivate::currentMouseWindow = nullptr;
QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
+ QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = Qt::HighDpiScaleFactorRoundingPolicy::PassThrough;
QGuiApplicationPrivate::currentDragWindow = nullptr;
QGuiApplicationPrivate::tabletDevicePoints.clear();
}
-QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
- : QCoreApplicationPrivate(argc, argv, flags),
+QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv)
+ : QCoreApplicationPrivate(argc, argv),
inputMethod(nullptr),
lastTouchType(QEvent::TouchEnd),
ownGlobalShareContext(false)
@@ -761,13 +750,37 @@ QString QGuiApplication::applicationDisplayName()
}
/*!
+ Sets the application's badge to \a number.
+
+ Useful for providing feedback to the user about the number
+ of unread messages or similar.
+
+ The badge will be overlaid on the application's icon in the Dock
+ on \macos, the home screen icon on iOS, or the task bar on Windows
+ and Linux.
+
+ If the number is outside the range supported by the platform, the
+ number will be clamped to the supported range. If the number does
+ not fit within the badge, the number may be visually elided.
+
+ Setting the number to 0 will clear the badge.
+
+ \since 6.5
+ \sa applicationName
+*/
+void QGuiApplication::setBadgeNumber(qint64 number)
+{
+ QGuiApplicationPrivate::platformIntegration()->setApplicationBadge(number);
+}
+
+/*!
\property QGuiApplication::desktopFileName
\brief the base name of the desktop entry for this application
\since 5.7
- This is the file name, without the full path, of the desktop entry
- that represents this application according to the freedesktop desktop
- entry specification.
+ This is the file name, without the full path or the trailing ".desktop"
+ extension of the desktop entry that represents this application
+ according to the freedesktop desktop entry specification.
This property gives a precise indication of what desktop entry represents
the application and it is needed by the windowing system to retrieve
@@ -781,6 +794,15 @@ void QGuiApplication::setDesktopFileName(const QString &name)
if (!QGuiApplicationPrivate::desktopFileName)
QGuiApplicationPrivate::desktopFileName = new QString;
*QGuiApplicationPrivate::desktopFileName = name;
+ if (name.endsWith(QLatin1String(".desktop"))) { // ### Qt 7: remove
+ const QString filePath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, name);
+ if (!filePath.isEmpty()) {
+ qWarning("QGuiApplication::setDesktopFileName: the specified desktop file name "
+ "ends with .desktop. For compatibility reasons, the .desktop suffix will "
+ "be removed. Please specify a desktop file name without .desktop suffix");
+ (*QGuiApplicationPrivate::desktopFileName).chop(8);
+ }
+ }
}
QString QGuiApplication::desktopFileName()
@@ -807,7 +829,7 @@ QWindow *QGuiApplication::modalWindow()
CHECK_QAPP_INSTANCE(nullptr)
if (QGuiApplicationPrivate::self->modalWindowList.isEmpty())
return nullptr;
- return QGuiApplicationPrivate::self->modalWindowList.first();
+ return QGuiApplicationPrivate::self->modalWindowList.constFirst();
}
static void updateBlockedStatusRecursion(QWindow *window, bool shouldBeBlocked)
@@ -858,7 +880,7 @@ void QGuiApplicationPrivate::showModalWindow(QWindow *modal)
}
}
- for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) {
+ for (QWindow *window : std::as_const(QGuiApplicationPrivate::window_list)) {
if (needsWindowBlockedEvent(window) && !window->d_func()->blockedByModalWindow)
updateBlockedStatus(window);
}
@@ -870,12 +892,23 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window)
{
self->modalWindowList.removeAll(window);
- for (QWindow *window : qAsConst(QGuiApplicationPrivate::window_list)) {
+ for (QWindow *window : std::as_const(QGuiApplicationPrivate::window_list)) {
if (needsWindowBlockedEvent(window) && window->d_func()->blockedByModalWindow)
updateBlockedStatus(window);
}
}
+Qt::WindowModality QGuiApplicationPrivate::defaultModality() const
+{
+ return Qt::NonModal;
+}
+
+bool QGuiApplicationPrivate::windowNeverBlocked(QWindow *window) const
+{
+ Q_UNUSED(window);
+ return false;
+}
+
/*
Returns \c true if \a window is blocked by a modal window. If \a
blockingWindow is non-zero, *blockingWindow will be set to the blocking
@@ -883,55 +916,40 @@ void QGuiApplicationPrivate::hideModalWindow(QWindow *window)
*/
bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const
{
+ Q_ASSERT_X(window, Q_FUNC_INFO, "The window must not be null");
+
QWindow *unused = nullptr;
if (!blockingWindow)
blockingWindow = &unused;
+ *blockingWindow = nullptr;
- if (modalWindowList.isEmpty()) {
- *blockingWindow = nullptr;
+ if (modalWindowList.isEmpty() || windowNeverBlocked(window))
return false;
- }
- for (int i = 0; i < modalWindowList.count(); ++i) {
+ for (int i = 0; i < modalWindowList.size(); ++i) {
QWindow *modalWindow = modalWindowList.at(i);
// A window is not blocked by another modal window if the two are
// the same, or if the window is a child of the modal window.
- if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients)) {
- *blockingWindow = nullptr;
+ if (window == modalWindow || modalWindow->isAncestorOf(window, QWindow::IncludeTransients))
return false;
- }
- Qt::WindowModality windowModality = modalWindow->modality();
- switch (windowModality) {
+ switch (modalWindow->modality() == Qt::NonModal ? defaultModality()
+ : modalWindow->modality()) {
case Qt::ApplicationModal:
- {
- if (modalWindow != window) {
- *blockingWindow = modalWindow;
- return true;
- }
- break;
- }
- case Qt::WindowModal:
- {
- QWindow *w = window;
+ *blockingWindow = modalWindow;
+ return true;
+ case Qt::WindowModal: {
+ // Find the nearest ancestor of window which is also an ancestor of modal window to
+ // determine if the modal window blocks the window.
+ auto *current = window;
do {
- QWindow *m = modalWindow;
- do {
- if (m == w) {
- *blockingWindow = m;
- return true;
- }
- QWindow *p = m->parent();
- if (!p)
- p = m->transientParent();
- m = p;
- } while (m);
- QWindow *p = w->parent();
- if (!p)
- p = w->transientParent();
- w = p;
- } while (w);
+ if (current->isAncestorOf(modalWindow, QWindow::IncludeTransients)) {
+ *blockingWindow = modalWindow;
+ return true;
+ }
+ current = current->parent(QWindow::IncludeTransients);
+ } while (current);
break;
}
default:
@@ -939,13 +957,14 @@ bool QGuiApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blocking
break;
}
}
- *blockingWindow = nullptr;
return false;
}
/*!
Returns the QWindow that receives events tied to focus,
such as key events.
+
+ \sa QWindow::requestActivate()
*/
QWindow *QGuiApplication::focusWindow()
{
@@ -1123,7 +1142,7 @@ qreal QGuiApplication::devicePixelRatio() const
return QGuiApplicationPrivate::m_maxDevicePixelRatio;
QGuiApplicationPrivate::m_maxDevicePixelRatio = 1.0; // make sure we never return 0.
- for (QScreen *screen : qAsConst(QGuiApplicationPrivate::screen_list))
+ for (QScreen *screen : std::as_const(QGuiApplicationPrivate::screen_list))
QGuiApplicationPrivate::m_maxDevicePixelRatio = qMax(QGuiApplicationPrivate::m_maxDevicePixelRatio, screen->devicePixelRatio());
return QGuiApplicationPrivate::m_maxDevicePixelRatio;
@@ -1170,32 +1189,50 @@ QWindow *QGuiApplication::topLevelAt(const QPoint &pos)
\li \c offscreen
\li \c qnx
\li \c windows
- \li \c wayland is a platform plugin for modern Linux desktops and some
- embedded systems.
- \li \c xcb is the X11 plugin used on regular desktop Linux platforms.
+ \li \c wayland is a platform plugin for the Wayland display server protocol,
+ used on some Linux desktops and embedded systems.
+ \li \c xcb is a plugin for the X11 window system, used on some desktop Linux platforms.
\endlist
+ \note Calling this function without a QGuiApplication will return the default
+ platform name, if available. The default platform name is not affected by the
+ \c{-platform} command line option, or the \c QT_QPA_PLATFORM environment variable.
+
For more information about the platform plugins for embedded Linux devices,
see \l{Qt for Embedded Linux}.
*/
QString QGuiApplication::platformName()
{
- return QGuiApplicationPrivate::platform_name ?
- *QGuiApplicationPrivate::platform_name : QString();
+ if (!QGuiApplication::instance()) {
+#ifdef QT_QPA_DEFAULT_PLATFORM_NAME
+ return QStringLiteral(QT_QPA_DEFAULT_PLATFORM_NAME);
+#else
+ return QString();
+#endif
+ } else {
+ return QGuiApplicationPrivate::platform_name ?
+ *QGuiApplicationPrivate::platform_name : QString();
+ }
}
Q_LOGGING_CATEGORY(lcQpaPluginLoading, "qt.qpa.plugin");
+Q_LOGGING_CATEGORY(lcQpaTheme, "qt.qpa.theme");
Q_LOGGING_CATEGORY(lcPtrDispatch, "qt.pointer.dispatch");
static void init_platform(const QString &pluginNamesWithArguments, const QString &platformPluginPath, const QString &platformThemeName, int &argc, char **argv)
{
- QStringList plugins = pluginNamesWithArguments.split(QLatin1Char(';'), Qt::SkipEmptyParts);
+ qCDebug(lcQpaPluginLoading) << "init_platform called with"
+ << "pluginNamesWithArguments" << pluginNamesWithArguments
+ << "platformPluginPath" << platformPluginPath
+ << "platformThemeName" << platformThemeName;
+
+ QStringList plugins = pluginNamesWithArguments.split(u';', Qt::SkipEmptyParts);
QStringList platformArguments;
QStringList availablePlugins = QPlatformIntegrationFactory::keys(platformPluginPath);
for (const auto &pluginArgument : plugins) {
// Split into platform name and arguments
- QStringList arguments = pluginArgument.split(QLatin1Char(':'), Qt::SkipEmptyParts);
+ QStringList arguments = pluginArgument.split(u':', Qt::SkipEmptyParts);
if (arguments.isEmpty())
continue;
const QString name = arguments.takeFirst().toLower();
@@ -1205,10 +1242,16 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
argumentsKey[0] = argumentsKey.at(0).toUpper();
arguments.append(QLibraryInfo::platformPluginArguments(argumentsKey));
+ qCDebug(lcQpaPluginLoading) << "Attempting to load Qt platform plugin" << name << "with arguments" << arguments;
+
// Create the platform integration.
QGuiApplicationPrivate::platform_integration = QPlatformIntegrationFactory::create(name, arguments, argc, argv, platformPluginPath);
if (Q_UNLIKELY(!QGuiApplicationPrivate::platform_integration)) {
if (availablePlugins.contains(name)) {
+ if (name == QStringLiteral("xcb") && QVersionNumber::compare(QLibraryInfo::version(), QVersionNumber(6, 5, 0)) >= 0) {
+ qCWarning(lcQpaPluginLoading).nospace().noquote()
+ << "From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.";
+ }
qCInfo(lcQpaPluginLoading).nospace().noquote()
<< "Could not load the Qt platform plugin \"" << name << "\" in \""
<< QDir::toNativeSeparators(platformPluginPath) << "\" even though it was found.";
@@ -1218,6 +1261,7 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
<< QDir::toNativeSeparators(platformPluginPath) << "\"";
}
} else {
+ qCDebug(lcQpaPluginLoading) << "Successfully loaded Qt platform plugin" << name;
QGuiApplicationPrivate::platform_name = new QString(name);
platformArguments = arguments;
break;
@@ -1229,7 +1273,7 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
"Reinstalling the application may fix this problem.\n");
if (!availablePlugins.isEmpty())
- fatalMessage += QStringLiteral("\nAvailable platform plugins are: %1.\n").arg(availablePlugins.join(QLatin1String(", ")));
+ fatalMessage += "\nAvailable platform plugins are: %1.\n"_L1.arg(availablePlugins.join(", "_L1));
#if defined(Q_OS_WIN)
// Windows: Display message box unless it is a console application
@@ -1246,45 +1290,57 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
// 1) Fetch the platform name from the environment if present.
QStringList themeNames;
- if (!platformThemeName.isEmpty())
+ if (!platformThemeName.isEmpty()) {
+ qCDebug(lcQpaTheme) << "Adding" << platformThemeName << "from environment to list of theme names";
themeNames.append(platformThemeName);
+ }
// 2) Special case - check whether it's a flatpak or snap app to use xdg-desktop-portal platform theme for portals support
if (checkNeedPortalSupport()) {
+ qCDebug(lcQpaTheme) << "Adding xdgdesktopportal to list of theme names";
themeNames.append(QStringLiteral("xdgdesktopportal"));
}
// 3) Ask the platform integration for a list of theme names
- themeNames += QGuiApplicationPrivate::platform_integration->themeNames();
+ const auto platformIntegrationThemeNames = QGuiApplicationPrivate::platform_integration->themeNames();
+ qCDebug(lcQpaTheme) << "Adding platform integration's theme names to list of theme names:" << platformIntegrationThemeNames;
+ themeNames += platformIntegrationThemeNames;
// 4) Look for a theme plugin.
- for (const QString &themeName : qAsConst(themeNames)) {
+ for (const QString &themeName : std::as_const(themeNames)) {
+ qCDebug(lcQpaTheme) << "Attempting to create platform theme" << themeName << "via QPlatformThemeFactory::create";
QGuiApplicationPrivate::platform_theme = QPlatformThemeFactory::create(themeName, platformPluginPath);
- if (QGuiApplicationPrivate::platform_theme)
+ if (QGuiApplicationPrivate::platform_theme) {
+ qCDebug(lcQpaTheme) << "Successfully created platform theme" << themeName;
break;
+ }
}
// 5) If no theme plugin was found ask the platform integration to
// create a theme
if (!QGuiApplicationPrivate::platform_theme) {
- for (const QString &themeName : qAsConst(themeNames)) {
+ for (const QString &themeName : std::as_const(themeNames)) {
+ qCDebug(lcQpaTheme) << "Attempting to create platform theme" << themeName << "via createPlatformTheme";
QGuiApplicationPrivate::platform_theme = QGuiApplicationPrivate::platform_integration->createPlatformTheme(themeName);
- if (QGuiApplicationPrivate::platform_theme)
+ if (QGuiApplicationPrivate::platform_theme) {
+ qCDebug(lcQpaTheme) << "Successfully created platform theme" << themeName;
break;
+ }
}
// No error message; not having a theme plugin is allowed.
}
// 6) Fall back on the built-in "null" platform theme.
- if (!QGuiApplicationPrivate::platform_theme)
+ if (!QGuiApplicationPrivate::platform_theme) {
+ qCDebug(lcQpaTheme) << "Failed to create platform theme; using \"null\" platform theme";
QGuiApplicationPrivate::platform_theme = new QPlatformTheme;
+ }
-#ifndef QT_NO_PROPERTIES
// Set arguments as dynamic properties on the native interface as
// boolean 'foo' or strings: 'foo=bar'
if (!platformArguments.isEmpty()) {
if (QObject *nativeInterface = QGuiApplicationPrivate::platform_integration->nativeInterface()) {
- for (const QString &argument : qAsConst(platformArguments)) {
- const int equalsPos = argument.indexOf(QLatin1Char('='));
+ for (const QString &argument : std::as_const(platformArguments)) {
+ const qsizetype equalsPos = argument.indexOf(u'=');
const QByteArray name =
equalsPos != -1 ? argument.left(equalsPos).toUtf8() : argument.toUtf8();
const QVariant value =
@@ -1293,25 +1349,24 @@ static void init_platform(const QString &pluginNamesWithArguments, const QString
}
}
}
-#endif
const auto platformIntegration = QGuiApplicationPrivate::platformIntegration();
fontSmoothingGamma = platformIntegration->styleHint(QPlatformIntegration::FontSmoothingGamma).toReal();
QCoreApplication::setAttribute(Qt::AA_DontShowShortcutsInContextMenus,
- !platformIntegration->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus).toBool());
+ !QGuiApplication::styleHints()->showShortcutsInContextMenus());
}
static void init_plugins(const QList<QByteArray> &pluginList)
{
- for (int i = 0; i < pluginList.count(); ++i) {
+ for (int i = 0; i < pluginList.size(); ++i) {
QByteArray pluginSpec = pluginList.at(i);
- int colonPos = pluginSpec.indexOf(':');
+ qsizetype colonPos = pluginSpec.indexOf(':');
QObject *plugin;
if (colonPos < 0)
- plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec), QString());
+ plugin = QGenericPluginFactory::create(QLatin1StringView(pluginSpec), QString());
else
- plugin = QGenericPluginFactory::create(QLatin1String(pluginSpec.mid(0, colonPos)),
- QLatin1String(pluginSpec.mid(colonPos+1)));
+ plugin = QGenericPluginFactory::create(QLatin1StringView(pluginSpec.mid(0, colonPos)),
+ QLatin1StringView(pluginSpec.mid(colonPos+1)));
if (plugin)
QGuiApplicationPrivate::generic_plugin_list.append(plugin);
else
@@ -1364,11 +1419,11 @@ void QGuiApplicationPrivate::addQtOptions(QList<QCommandLineOption> *options)
QGuiApplication::tr("ID of the X11 Visual to use."), QStringLiteral("id")));
// Not using the "QStringList names" solution for those aliases, because it makes the first column too wide
options->append(QCommandLineOption(QStringLiteral("geometry"),
- QGuiApplication::tr("Alias for --windowgeometry."), QStringLiteral("geometry")));
+ QGuiApplication::tr("Alias for --qwindowgeometry."), QStringLiteral("geometry")));
options->append(QCommandLineOption(QStringLiteral("icon"),
- QGuiApplication::tr("Alias for --windowicon."), QStringLiteral("icon")));
+ QGuiApplication::tr("Alias for --qwindowicon."), QStringLiteral("icon")));
options->append(QCommandLineOption(QStringLiteral("title"),
- QGuiApplication::tr("Alias for --windowtitle."), QStringLiteral("title")));
+ QGuiApplication::tr("Alias for --qwindowtitle."), QStringLiteral("title")));
}
}
#endif // QT_CONFIG(commandlineparser)
@@ -1402,16 +1457,9 @@ void QGuiApplicationPrivate::createPlatformIntegration()
}
const bool defaultIsWayland = !defaultIsXcb && platformPluginBase.startsWith("wayland");
- bool isGnome = false;
const QByteArray waylandPlatformName = defaultIsWayland ? platformName : "wayland";
if (hasWaylandDisplay || isWaylandSessionType) {
- const QByteArray currentDesktop = qgetenv("XDG_CURRENT_DESKTOP").toLower();
- const QByteArray sessionDesktop = qgetenv("XDG_SESSION_DESKTOP").toLower();
- isGnome = currentDesktop.contains("gnome") || sessionDesktop.contains("gnome");
- if (isGnome)
- preferredPlatformOrder.append(waylandPlatformName);
- else
- preferredPlatformOrder.prepend(waylandPlatformName);
+ preferredPlatformOrder.prepend(waylandPlatformName);
if (defaultIsWayland)
platformName.clear();
@@ -1450,7 +1498,7 @@ void QGuiApplicationPrivate::createPlatformIntegration()
++arg;
if (strcmp(arg, "-platformpluginpath") == 0) {
if (++i < argc)
- platformPluginPath = QString::fromLocal8Bit(argv[i]);
+ platformPluginPath = QFile::decodeName(argv[i]);
} else if (strcmp(arg, "-platform") == 0) {
if (++i < argc) {
platformExplicitlySelected = true;
@@ -1467,7 +1515,7 @@ void QGuiApplicationPrivate::createPlatformIntegration()
firstWindowTitle = QString::fromLocal8Bit(argv[i]);
} else if (strcmp(arg, "-qwindowicon") == 0 || (xcbIsDefault && strcmp(arg, "-icon") == 0)) {
if (++i < argc) {
- icon = QString::fromLocal8Bit(argv[i]);
+ icon = QFile::decodeName(argv[i]);
}
} else {
argv[j++] = argv[i];
@@ -1479,16 +1527,11 @@ void QGuiApplicationPrivate::createPlatformIntegration()
argc = j;
}
-#if defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN)
- if ((hasWaylandDisplay || isWaylandSessionType) && isGnome && !platformExplicitlySelected) {
- qInfo() << "Warning: Ignoring WAYLAND_DISPLAY on Gnome."
- << "Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.";
- }
-#else
Q_UNUSED(platformExplicitlySelected);
-#endif
- init_platform(QLatin1String(platformName), platformPluginPath, platformThemeName, argc, argv);
+ init_platform(QLatin1StringView(platformName), platformPluginPath, platformThemeName, argc, argv);
+ if (const QPlatformTheme *theme = platformTheme())
+ QStyleHintsPrivate::get(QGuiApplication::styleHints())->updateColorScheme(theme->colorScheme());
if (!icon.isEmpty())
forcedWindowIcon = QDir::isAbsolutePath(icon) ? QIcon(icon) : QIcon::fromTheme(icon);
@@ -1507,7 +1550,11 @@ void QGuiApplicationPrivate::createEventDispatcher()
if (platform_integration == nullptr)
createPlatformIntegration();
- // The platform integration should not mess with the event dispatcher
+ // The platform integration should not result in creating an event dispatcher
+ Q_ASSERT_X(!threadData.loadRelaxed()->eventDispatcher, "QGuiApplication",
+ "Creating the platform integration resulted in creating an event dispatcher");
+
+ // Nor should it mess with the QCoreApplication's event dispatcher
Q_ASSERT(!eventDispatcher);
eventDispatcher = platform_integration->createEventDispatcher();
@@ -1521,7 +1568,7 @@ void QGuiApplicationPrivate::eventDispatcherReady()
platform_integration->initialize();
}
-void QGuiApplicationPrivate::init()
+void Q_TRACE_INSTRUMENT(qtgui) QGuiApplicationPrivate::init()
{
Q_TRACE_SCOPE(QGuiApplicationPrivate_init);
@@ -1571,12 +1618,12 @@ void QGuiApplicationPrivate::init()
} else if (strncmp(arg, "-psn_", 5) == 0) {
// eat "-psn_xxxx" on Mac, which is passed when starting an app from Finder.
// special hack to change working directory (for an app bundle) when running from finder
- if (QDir::currentPath() == QLatin1String("/")) {
+ if (QDir::currentPath() == "/"_L1) {
QCFType<CFURLRef> bundleURL(CFBundleCopyBundleURL(CFBundleGetMainBundle()));
QString qbundlePath = QCFString(CFURLCopyFileSystemPath(bundleURL,
kCFURLPOSIXPathStyle));
- if (qbundlePath.endsWith(QLatin1String(".app")))
- QDir::setCurrent(qbundlePath.section(QLatin1Char('/'), 0, -2));
+ if (qbundlePath.endsWith(".app"_L1))
+ QDir::setCurrent(qbundlePath.section(u'/', 0, -2));
}
#endif
#ifndef QT_NO_SESSIONMANAGER
@@ -1584,7 +1631,7 @@ void QGuiApplicationPrivate::init()
++i;
if (argv[i] && *argv[i]) {
session_id = QString::fromLatin1(argv[i]);
- int p = session_id.indexOf(QLatin1Char('_'));
+ qsizetype p = session_id.indexOf(u'_');
if (p >= 0) {
session_key = session_id.mid(p +1);
session_id = session_id.left(p);
@@ -1680,8 +1727,8 @@ void QGuiApplicationPrivate::init()
Q_UNUSED(loadTestability);
#endif // QT_CONFIG(library)
- if (layout_direction == Qt::LayoutDirectionAuto || force_reverse)
- QGuiApplication::setLayoutDirection(qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight);
+ // trigger changed signal and event delivery
+ QGuiApplication::setLayoutDirection(layout_direction);
if (!QGuiApplicationPrivate::displayName)
QObject::connect(q, &QGuiApplication::applicationNameChanged,
@@ -1695,7 +1742,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
is_app_closing = true;
is_app_running = false;
- for (int i = 0; i < generic_plugin_list.count(); ++i)
+ for (int i = 0; i < generic_plugin_list.size(); ++i)
delete generic_plugin_list.at(i);
generic_plugin_list.clear();
@@ -1707,7 +1754,7 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
QCursorData::cleanup();
#endif
- layout_direction = Qt::LeftToRight;
+ layout_direction = Qt::LayoutDirectionAuto;
cleanupThreadData();
@@ -1726,6 +1773,10 @@ QGuiApplicationPrivate::~QGuiApplicationPrivate()
}
#endif
+#if QT_CONFIG(vulkan)
+ QVulkanDefaultInstance::cleanup();
+#endif
+
platform_integration->destroy();
delete platform_theme;
@@ -1760,7 +1811,7 @@ static QClipboard *clipboard();
/*!
Returns the current state of the modifier keys on the keyboard. The current
- state is updated sychronously as the event queue is emptied of events that
+ state is updated synchronously as the event queue is emptied of events that
will spontaneously change the keyboard state (QEvent::KeyPress and
QEvent::KeyRelease events).
@@ -1796,7 +1847,7 @@ Qt::KeyboardModifiers QGuiApplication::queryKeyboardModifiers()
{
CHECK_QAPP_INSTANCE(Qt::KeyboardModifiers{})
QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration();
- return pi->queryKeyboardModifiers();
+ return pi->keyMapper()->queryKeyboardModifiers();
}
/*!
@@ -1854,9 +1905,10 @@ QFunctionPointer QGuiApplication::platformFunction(const QByteArray &function)
Generally, no user interaction can take place before calling exec().
- To make your application perform idle processing, e.g., executing a special
- function whenever there are no pending events, use a QTimer with 0 timeout.
- More advanced idle processing schemes can be achieved using processEvents().
+ To make your application perform idle processing, e.g., executing a
+ special function whenever there are no pending events, use a QChronoTimer
+ with 0ns timeout. More advanced idle processing schemes can be achieved
+ using processEvents().
We recommend that you connect clean-up code to the
\l{QCoreApplication::}{aboutToQuit()} signal, instead of putting it in your
@@ -1868,7 +1920,7 @@ QFunctionPointer QGuiApplication::platformFunction(const QByteArray &function)
*/
int QGuiApplication::exec()
{
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessible::setRootObject(qApp);
#endif
return QCoreApplication::exec();
@@ -1946,19 +1998,24 @@ bool QGuiApplication::notify(QObject *object, QEvent *event)
*/
bool QGuiApplication::event(QEvent *e)
{
- if (e->type() == QEvent::LanguageChange) {
- setLayoutDirection(qt_detectRTLLanguage()?Qt::RightToLeft:Qt::LeftToRight);
+ switch (e->type()) {
+ case QEvent::LanguageChange:
+ // if the layout direction was set explicitly, then don't override it here
+ if (layout_direction == Qt::LayoutDirectionAuto)
+ setLayoutDirection(layout_direction);
for (auto *topLevelWindow : QGuiApplication::topLevelWindows()) {
if (topLevelWindow->flags() != Qt::Desktop)
postEvent(topLevelWindow, new QEvent(QEvent::LanguageChange));
}
- } else if (e->type() == QEvent::ApplicationFontChange ||
- e->type() == QEvent::ApplicationPaletteChange) {
+ break;
+ case QEvent::ApplicationFontChange:
+ case QEvent::ApplicationPaletteChange:
for (auto *topLevelWindow : QGuiApplication::topLevelWindows()) {
if (topLevelWindow->flags() != Qt::Desktop)
postEvent(topLevelWindow, new QEvent(e->type()));
}
- } else if (e->type() == QEvent::Quit) {
+ break;
+ case QEvent::Quit:
// Close open windows. This is done in order to deliver de-expose
// events while the event loop is still running.
for (QWindow *topLevelWindow : QGuiApplication::topLevelWindows()) {
@@ -1970,8 +2027,10 @@ bool QGuiApplication::event(QEvent *e)
return true;
}
}
+ break;
+ default:
+ break;
}
-
return QCoreApplication::event(e);
}
@@ -2002,8 +2061,9 @@ bool QGuiApplicationPrivate::processNativeEvent(QWindow *window, const QByteArra
return window->nativeEvent(eventType, message, result);
}
-void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
+void Q_TRACE_INSTRUMENT(qtgui) QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePrivate::WindowSystemEvent *e)
{
+ Q_TRACE_PARAM_REPLACE(QWindowSystemInterfacePrivate::WindowSystemEvent *, int);
Q_TRACE_SCOPE(QGuiApplicationPrivate_processWindowSystemEvent, e->type);
switch(e->type) {
@@ -2028,8 +2088,8 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
case QWindowSystemInterfacePrivate::Leave:
QGuiApplicationPrivate::processLeaveEvent(static_cast<QWindowSystemInterfacePrivate::LeaveEvent *>(e));
break;
- case QWindowSystemInterfacePrivate::ActivatedWindow:
- QGuiApplicationPrivate::processActivatedEvent(static_cast<QWindowSystemInterfacePrivate::ActivatedWindowEvent *>(e));
+ case QWindowSystemInterfacePrivate::FocusWindow:
+ QGuiApplicationPrivate::processFocusWindowEvent(static_cast<QWindowSystemInterfacePrivate::FocusWindowEvent *>(e));
break;
case QWindowSystemInterfacePrivate::WindowStateChanged:
QGuiApplicationPrivate::processWindowStateChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowStateChangedEvent *>(e));
@@ -2037,6 +2097,9 @@ void QGuiApplicationPrivate::processWindowSystemEvent(QWindowSystemInterfacePriv
case QWindowSystemInterfacePrivate::WindowScreenChanged:
QGuiApplicationPrivate::processWindowScreenChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowScreenChangedEvent *>(e));
break;
+ case QWindowSystemInterfacePrivate::WindowDevicePixelRatioChanged:
+ QGuiApplicationPrivate::processWindowDevicePixelRatioChangedEvent(static_cast<QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *>(e));
+ break;
case QWindowSystemInterfacePrivate::SafeAreaMarginsChanged:
QGuiApplicationPrivate::processSafeAreaMarginsChangedEvent(static_cast<QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *>(e));
break;
@@ -2184,22 +2247,24 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
QPointF localPoint = e->localPos;
bool doubleClick = false;
auto persistentEPD = devPriv->pointById(0);
- const auto &persistentPoint = QMutableEventPoint::from(persistentEPD->eventPoint);
if (mouseMove) {
QGuiApplicationPrivate::lastCursorPosition = globalPoint;
const auto doubleClickDistance = (e->device && e->device->type() == QInputDevice::DeviceType::Mouse ?
mouseDoubleClickDistance : touchDoubleTapDistance);
- const auto pressPos = persistentPoint.globalPressPosition();
+ const auto pressPos = persistentEPD->eventPoint.globalPressPosition();
if (qAbs(globalPoint.x() - pressPos.x()) > doubleClickDistance ||
qAbs(globalPoint.y() - pressPos.y()) > doubleClickDistance)
mousePressButton = Qt::NoButton;
} else {
+ static unsigned long lastPressTimestamp = 0;
mouse_buttons = e->buttons;
if (mousePress) {
ulong doubleClickInterval = static_cast<ulong>(QGuiApplication::styleHints()->mouseDoubleClickInterval());
- doubleClick = e->timestamp - persistentPoint.pressTimestamp() < doubleClickInterval && button == mousePressButton;
+ doubleClick = e->timestamp - lastPressTimestamp
+ < doubleClickInterval && button == mousePressButton;
mousePressButton = button;
+ lastPressTimestamp = e ->timestamp;
}
}
@@ -2242,9 +2307,11 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
#endif
QMouseEvent ev(type, localPoint, localPoint, globalPoint, button, e->buttons, e->modifiers, e->source, device);
+ Q_ASSERT(devPriv->pointById(0) == persistentEPD); // we don't expect reallocation in QPlatformCursor::pointerEvenmt()
// restore globalLastPosition to avoid invalidating the velocity calculations,
// because the QPlatformCursor mouse event above was in native coordinates
- QMutableEventPoint::from(persistentEPD->eventPoint).setGlobalLastPosition(lastGlobalPosition);
+ QMutableEventPoint::setGlobalLastPosition(persistentEPD->eventPoint, lastGlobalPosition);
+ persistentEPD = nullptr; // incoming and synth events can cause reallocation during delivery, so don't use this again
// ev now contains a detached copy of the QEventPoint from QPointingDevicePrivate::activePoints
ev.setTimestamp(e->timestamp);
if (window->d_func()->blockedByModalWindow && !qApp->d_func()->popupActive()) {
@@ -2301,8 +2368,10 @@ void QGuiApplicationPrivate::processMouseEvent(QWindowSystemInterfacePrivate::Mo
}
}
if (type == QEvent::MouseButtonRelease && e->buttons == Qt::NoButton) {
- ev.setExclusiveGrabber(persistentPoint, nullptr);
- ev.clearPassiveGrabbers(persistentPoint);
+ if (auto *persistentEPD = devPriv->queryPointById(0)) {
+ ev.setExclusiveGrabber(persistentEPD->eventPoint, nullptr);
+ ev.clearPassiveGrabbers(persistentEPD->eventPoint);
+ }
}
}
@@ -2335,6 +2404,7 @@ void QGuiApplicationPrivate::processWheelEvent(QWindowSystemInterfacePrivate::Wh
mouse_buttons, e->modifiers, e->phase, e->inverted, e->source, device);
ev.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(window, &ev);
+ e->eventAccepted = ev.isAccepted();
#else
Q_UNUSED(e);
#endif // QT_CONFIG(wheelevent)
@@ -2345,7 +2415,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
QWindow *window = e->window.data();
modifier_buttons = e->modifiers;
if (e->nullWindow()
-#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
+#ifdef Q_OS_ANDROID
|| e->key == Qt::Key_Back || e->key == Qt::Key_Menu
#endif
) {
@@ -2381,7 +2451,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE
if (window && !window->d_func()->blockedByModalWindow)
QGuiApplication::sendSpontaneousEvent(window, &ev);
-#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_EMBEDDED)
+#ifdef Q_OS_ANDROID
else
ev.setAccepted(false);
@@ -2422,7 +2492,7 @@ void QGuiApplicationPrivate::processEnterEvent(QWindowSystemInterfacePrivate::En
const QPointingDevicePrivate *devPriv = QPointingDevicePrivate::get(event.pointingDevice());
auto epd = devPriv->queryPointById(event.points().first().id());
Q_ASSERT(epd);
- QMutableEventPoint::from(epd->eventPoint).setVelocity({});
+ QMutableEventPoint::setVelocity(epd->eventPoint, {});
QCoreApplication::sendSpontaneousEvent(e->enter.data(), &event);
}
@@ -2442,10 +2512,10 @@ void QGuiApplicationPrivate::processLeaveEvent(QWindowSystemInterfacePrivate::Le
QCoreApplication::sendSpontaneousEvent(e->leave.data(), &event);
}
-void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e)
+void QGuiApplicationPrivate::processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e)
{
QWindow *previous = QGuiApplicationPrivate::focus_window;
- QWindow *newFocus = e->activated.data();
+ QWindow *newFocus = e->focused.data();
if (previous == newFocus)
return;
@@ -2495,8 +2565,15 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
if (self) {
self->notifyActiveWindowChange(previous);
- if (previousFocusObject != qApp->focusObject())
+ if (previousFocusObject != qApp->focusObject() ||
+ // We are getting an activation change but there is no new focusObject, and we also
+ // don't have a previousFocusObject in the previously active window anymore. This can
+ // happen when window gets destroyed (see QWidgetWindow::focusObject returning nullptr
+ // when already in the QWidget destructor), so update the focusObject to avoid dangling
+ // pointers. See also QWidget::clearFocus(), which tries to cover for this as well.
+ (previous && previousFocusObject == nullptr && qApp->focusObject() == nullptr)) {
self->_q_updateFocusObject(qApp->focusObject());
+ }
}
emit qApp->focusWindowChanged(newFocus);
@@ -2508,32 +2585,46 @@ void QGuiApplicationPrivate::processActivatedEvent(QWindowSystemInterfacePrivate
void QGuiApplicationPrivate::processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *wse)
{
- if (QWindow *window = wse->window.data()) {
+ if (QWindow *window = wse->window.data()) {
+ QWindowPrivate *windowPrivate = qt_window_private(window);
+ const auto originalEffectiveState = QWindowPrivate::effectiveState(windowPrivate->windowState);
+
+ windowPrivate->windowState = wse->newState;
+ const auto newEffectiveState = QWindowPrivate::effectiveState(windowPrivate->windowState);
+ if (newEffectiveState != originalEffectiveState)
+ emit window->windowStateChanged(newEffectiveState);
+
+ windowPrivate->updateVisibility();
+
QWindowStateChangeEvent e(wse->oldState);
- window->d_func()->windowState = wse->newState;
QGuiApplication::sendSpontaneousEvent(window, &e);
}
}
void QGuiApplicationPrivate::processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *wse)
{
- if (QWindow *window = wse->window.data()) {
- if (window->screen() == wse->screen.data())
- return;
- if (QWindow *topLevelWindow = window->d_func()->topLevelWindow(QWindow::ExcludeTransients)) {
- if (QScreen *screen = wse->screen.data())
- topLevelWindow->d_func()->setTopLevelScreen(screen, false /* recreate */);
- else // Fall back to default behavior, and try to find some appropriate screen
- topLevelWindow->setScreen(nullptr);
- }
- // we may have changed scaling, so trigger resize event if needed
- if (window->handle()) {
- QWindowSystemInterfacePrivate::GeometryChangeEvent gce(window, QHighDpi::fromNativePixels(window->handle()->geometry(), window));
- processGeometryChangeEvent(&gce);
- }
+ QWindow *window = wse->window.data();
+ if (!window)
+ return;
+
+ if (window->screen() == wse->screen.data())
+ return;
+
+ if (QWindow *topLevelWindow = window->d_func()->topLevelWindow(QWindow::ExcludeTransients)) {
+ if (QScreen *screen = wse->screen.data())
+ topLevelWindow->d_func()->setTopLevelScreen(screen, false /* recreate */);
+ else // Fall back to default behavior, and try to find some appropriate screen
+ topLevelWindow->setScreen(nullptr);
}
}
+void QGuiApplicationPrivate::processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *wde)
+{
+ if (wde->window.isNull())
+ return;
+ QWindowPrivate::get(wde->window)->updateDevicePixelRatio();
+}
+
void QGuiApplicationPrivate::processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *wse)
{
if (wse->window.isNull())
@@ -2548,11 +2639,43 @@ void QGuiApplicationPrivate::processSafeAreaMarginsChangedEvent(QWindowSystemInt
void QGuiApplicationPrivate::processThemeChanged(QWindowSystemInterfacePrivate::ThemeChangeEvent *tce)
{
if (self)
- self->notifyThemeChanged();
- if (QWindow *window = tce->window.data()) {
- QEvent e(QEvent::ThemeChange);
- QGuiApplication::sendSpontaneousEvent(window, &e);
+ self->handleThemeChanged();
+
+ QIconPrivate::clearIconCache();
+
+ QStyleHintsPrivate::get(QGuiApplication::styleHints())->updateColorScheme(colorScheme());
+
+ QEvent themeChangeEvent(QEvent::ThemeChange);
+ const QWindowList windows = tce->window ? QWindowList{tce->window} : window_list;
+ for (auto *window : windows)
+ QGuiApplication::sendSpontaneousEvent(window, &themeChangeEvent);
+}
+
+/*!
+ \internal
+ \brief QGuiApplicationPrivate::colorScheme
+ \return the platform theme's color scheme
+ or Qt::ColorScheme::Unknown if a platform theme cannot be established
+ */
+Qt::ColorScheme QGuiApplicationPrivate::colorScheme()
+{
+ return platformTheme() ? platformTheme()->colorScheme()
+ : Qt::ColorScheme::Unknown;
+}
+
+void QGuiApplicationPrivate::handleThemeChanged()
+{
+ updatePalette();
+
+ QIconLoader::instance()->updateSystemTheme();
+ QAbstractFileIconProviderPrivate::clearIconTypeCache();
+
+ if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) {
+ const auto locker = qt_scoped_lock(applicationFontMutex);
+ clearFontUnlocked();
+ initFontUnlocked();
}
+ initThemeHints();
}
void QGuiApplicationPrivate::processGeometryChangeEvent(QWindowSystemInterfacePrivate::GeometryChangeEvent *e)
@@ -2611,8 +2734,10 @@ void QGuiApplicationPrivate::processCloseEvent(QWindowSystemInterfacePrivate::Cl
{
if (e->window.isNull())
return;
- if (e->window.data()->d_func()->blockedByModalWindow) {
- // a modal window is blocking this window, don't allow close events through
+ if (e->window.data()->d_func()->blockedByModalWindow && !e->window.data()->d_func()->inClose) {
+ // a modal window is blocking this window, don't allow close events through, unless they
+ // originate from a call to QWindow::close.
+ e->eventAccepted = false;
return;
}
@@ -2717,6 +2842,8 @@ void QGuiApplicationPrivate::processTabletEvent(QWindowSystemInterfacePrivate::T
QWindowSystemInterfacePrivate::MouseEvent mouseEvent(window, e->timestamp, e->local,
e->global, e->buttons, e->modifiers, button, mouseType, Qt::MouseEventNotSynthesized, false, device);
mouseEvent.flags |= QWindowSystemInterfacePrivate::WindowSystemEvent::Synthetic;
+ qCDebug(lcPtrDispatch) << "synthesizing mouse from tablet event" << mouseType
+ << e->local << button << e->buttons << e->modifiers;
processMouseEvent(&mouseEvent);
}
#else
@@ -2760,7 +2887,7 @@ void QGuiApplicationPrivate::processGestureEvent(QWindowSystemInterfacePrivate::
const QPointingDevice *device = static_cast<const QPointingDevice *>(e->device);
QNativeGestureEvent ev(e->type, device, e->fingerCount, e->pos, e->pos, e->globalPos, (e->intValue ? e->intValue : e->realValue),
- e->deltas, e->sequenceId);
+ e->delta, e->sequenceId);
ev.setTimestamp(e->timestamp);
QGuiApplication::sendSpontaneousEvent(e->window, &ev);
}
@@ -2795,6 +2922,9 @@ void QGuiApplicationPrivate::processContextMenuEvent(QWindowSystemInterfacePriva
void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::TouchEvent *e)
{
+ if (!QInputDevicePrivate::isRegistered(e->device))
+ return;
+
modifier_buttons = e->modifiers;
QPointingDevice *device = const_cast<QPointingDevice *>(static_cast<const QPointingDevice *>(e->device));
QPointingDevicePrivate *devPriv = QPointingDevicePrivate::get(device);
@@ -2804,19 +2934,17 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
// Send the TouchCancel to all windows with active touches and clean up.
QTouchEvent touchEvent(QEvent::TouchCancel, device, e->modifiers);
touchEvent.setTimestamp(e->timestamp);
- QSet<QWindow *> windowsNeedingCancel;
+ constexpr qsizetype Prealloc = decltype(devPriv->activePoints)::mapped_container_type::PreallocatedSize;
+ QMinimalVarLengthFlatSet<QWindow *, Prealloc> windowsNeedingCancel;
for (auto &epd : devPriv->activePoints.values()) {
- auto &mut = QMutableEventPoint::from(const_cast<QEventPoint &>(epd.eventPoint));
- QWindow *w = mut.window();
- if (w)
+ if (QWindow *w = QMutableEventPoint::window(epd.eventPoint))
windowsNeedingCancel.insert(w);
}
- for (QSet<QWindow *>::const_iterator winIt = windowsNeedingCancel.constBegin(),
- winItEnd = windowsNeedingCancel.constEnd(); winIt != winItEnd; ++winIt) {
- QGuiApplication::sendSpontaneousEvent(*winIt, &touchEvent);
- }
+ for (QWindow *w : windowsNeedingCancel)
+ QGuiApplication::sendSpontaneousEvent(w, &touchEvent);
+
if (!self->synthesizedMousePoints.isEmpty() && !e->synthetic()) {
for (QHash<QWindow *, SynthesizedMouseData>::const_iterator synthIt = self->synthesizedMousePoints.constBegin(),
synthItEnd = self->synthesizedMousePoints.constEnd(); synthIt != synthItEnd; ++synthIt) {
@@ -2858,7 +2986,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
for (auto &tempPt : e->points) {
// update state
auto epd = devPriv->pointById(tempPt.id());
- auto &mut = QMutableEventPoint::from(const_cast<QEventPoint &>(epd->eventPoint));
+ auto &ep = epd->eventPoint;
epd->eventPoint.setAccepted(false);
switch (tempPt.state()) {
case QEventPoint::State::Pressed:
@@ -2868,19 +2996,21 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
// If the QPA event didn't tell us which window, find the one under the touchpoint position.
if (!window)
window = QGuiApplication::topLevelAt(tempPt.globalPosition().toPoint());
- mut.setWindow(window);
+ QMutableEventPoint::setWindow(ep, window);
break;
case QEventPoint::State::Released:
- if (Q_UNLIKELY(!window.isNull() && window != mut.window()))
- qCWarning(lcPtrDispatch) << "delivering touch release to same window" << mut.window() << "not" << window.data();
- window = mut.window();
+ if (Q_UNLIKELY(!window.isNull() && window != QMutableEventPoint::window(ep)))
+ qCDebug(lcPtrDispatch) << "delivering touch release to same window"
+ << QMutableEventPoint::window(ep) << "not" << window.data();
+ window = QMutableEventPoint::window(ep);
break;
default: // update or stationary
- if (Q_UNLIKELY(!window.isNull() && window != mut.window()))
- qCWarning(lcPtrDispatch) << "delivering touch update to same window" << mut.window() << "not" << window.data();
- window = mut.window();
+ if (Q_UNLIKELY(!window.isNull() && window != QMutableEventPoint::window(ep)))
+ qCDebug(lcPtrDispatch) << "delivering touch update to same window"
+ << QMutableEventPoint::window(ep) << "not" << window.data();
+ window = QMutableEventPoint::window(ep);
break;
}
// If we somehow still don't have a window, we can't deliver this touchpoint. (should never happen)
@@ -2888,30 +3018,30 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
qCWarning(lcPtrDispatch) << "skipping" << &tempPt << ": no target window";
continue;
}
- mut.updateFrom(tempPt);
+ QMutableEventPoint::update(tempPt, ep);
Q_ASSERT(window.data() != nullptr);
// make the *scene* position the same as the *global* position
- mut.setScenePosition(tempPt.globalPosition());
+ QMutableEventPoint::setScenePosition(ep, tempPt.globalPosition());
// store the scene position as local position, for now
- mut.setPosition(window->mapFromGlobal(tempPt.globalPosition()));
+ QMutableEventPoint::setPosition(ep, window->mapFromGlobal(tempPt.globalPosition()));
// setTimeStamp has side effects, so we do it last
- mut.setTimestamp(e->timestamp);
+ QMutableEventPoint::setTimestamp(ep, e->timestamp);
// add the touchpoint to the event that will be delivered to the window
bool added = false;
for (QMutableTouchEvent &ev : touchEvents) {
if (ev.target() == window.data()) {
- ev.addPoint(mut);
+ ev.addPoint(ep);
added = true;
break;
}
}
if (!added) {
- QMutableTouchEvent mte(e->touchType, device, e->modifiers, {mut});
+ QMutableTouchEvent mte(e->touchType, device, e->modifiers, {ep});
mte.setTimestamp(e->timestamp);
mte.setTarget(window.data());
touchEvents.append(mte);
@@ -2963,7 +3093,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To
QEvent::Type mouseEventType = QEvent::MouseMove;
Qt::MouseButton button = Qt::NoButton;
Qt::MouseButtons buttons = Qt::LeftButton;
- if (eventType == QEvent::TouchBegin && m_fakeMouseSourcePointId < 0) {
+ if (eventType == QEvent::TouchBegin || m_fakeMouseSourcePointId < 0) {
m_fakeMouseSourcePointId = touchEvent.point(0).id();
qCDebug(lcPtrDispatch) << "synthesizing mouse events from touchpoint" << m_fakeMouseSourcePointId;
}
@@ -3047,26 +3177,16 @@ void QGuiApplicationPrivate::processScreenGeometryChange(QWindowSystemInterfaceP
if (!e->screen)
return;
- QScreen *s = e->screen.data();
+ {
+ QScreen *s = e->screen.data();
+ QScreenPrivate::UpdateEmitter updateEmitter(s);
- bool geometryChanged = e->geometry != s->d_func()->geometry;
- s->d_func()->geometry = e->geometry;
+ // Note: The incoming geometries have already been scaled by QHighDpi
+ // in the QWSI layer, so we don't need to call updateGeometry() here.
+ s->d_func()->geometry = e->geometry;
+ s->d_func()->availableGeometry = e->availableGeometry;
- bool availableGeometryChanged = e->availableGeometry != s->d_func()->availableGeometry;
- s->d_func()->availableGeometry = e->availableGeometry;
-
- const Qt::ScreenOrientation primaryOrientation = s->primaryOrientation();
- if (geometryChanged)
s->d_func()->updatePrimaryOrientation();
-
- s->d_func()->emitGeometryChangeSignals(geometryChanged, availableGeometryChanged);
-
- if (geometryChanged) {
- emit s->physicalSizeChanged(s->physicalSize());
- emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch());
-
- if (s->primaryOrientation() != primaryOrientation)
- emit s->primaryOrientationChanged(s->primaryOrientation());
}
resetCachedDevicePixelRatio();
@@ -3083,11 +3203,16 @@ void QGuiApplicationPrivate::processScreenLogicalDotsPerInchChange(QWindowSystem
if (!e->screen)
return;
- QScreen *s = e->screen.data();
- s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY);
+ {
+ QScreen *s = e->screen.data();
+ QScreenPrivate::UpdateEmitter updateEmitter(s);
+ s->d_func()->logicalDpi = QDpi(e->dpiX, e->dpiY);
+ s->d_func()->updateGeometry();
+ }
- emit s->logicalDotsPerInchChanged(s->logicalDotsPerInch());
- s->d_func()->updateGeometriesWithSignals();
+ for (QWindow *window : QGuiApplication::allWindows())
+ if (window->screen() == e->screen)
+ QWindowPrivate::get(window)->updateDevicePixelRatio();
resetCachedDevicePixelRatio();
}
@@ -3147,6 +3272,16 @@ void QGuiApplicationPrivate::processExposeEvent(QWindowSystemInterfacePrivate::E
const bool wasExposed = p->exposed;
p->exposed = e->isExposed && window->screen();
+ // We expect that the platform plugins send DevicePixelRatioChange events.
+ // As a fail-safe make a final check here to make sure the cached DPR value is
+ // always up to date before sending the expose event.
+ if (e->isExposed && !e->region.isEmpty()) {
+ const bool dprWasChanged = QWindowPrivate::get(window)->updateDevicePixelRatio();
+ if (dprWasChanged)
+ qWarning() << "The cached device pixel ratio value was stale on window expose. "
+ << "Please file a QTBUG which explains how to reproduce.";
+ }
+
// We treat expose events for an already exposed window as paint events
if (wasExposed && p->exposed && shouldSynthesizePaintEvents) {
QPaintEvent paintEvent(e->region);
@@ -3288,7 +3423,7 @@ QClipboard * QGuiApplication::clipboard()
/*!
\since 5.4
\fn void QGuiApplication::paletteChanged(const QPalette &palette)
- \deprecated
+ \deprecated [6.0] Handle QEvent::ApplicationPaletteChange instead.
This signal is emitted when the \a palette of the application changes. Use
QEvent::ApplicationPaletteChanged instead.
@@ -3372,11 +3507,13 @@ bool QGuiApplicationPrivate::setPalette(const QPalette &palette)
*/
QPalette QGuiApplicationPrivate::basePalette() const
{
- return platformTheme() ? *platformTheme()->palette() : Qt::gray;
+ const auto pf = platformTheme();
+ return pf && pf->palette() ? *pf->palette() : Qt::gray;
}
void QGuiApplicationPrivate::handlePaletteChanged(const char *className)
{
+#if QT_DEPRECATED_SINCE(6, 0)
if (!className) {
Q_ASSERT(app_pal);
QT_WARNING_PUSH
@@ -3384,6 +3521,9 @@ QT_WARNING_DISABLE_DEPRECATED
emit qGuiApp->paletteChanged(*QGuiApplicationPrivate::app_pal);
QT_WARNING_POP
}
+#else
+ Q_UNUSED(className);
+#endif // QT_DEPRECATED_SINCE(6, 0)
if (is_app_running && !is_app_closing) {
QEvent event(QEvent::ApplicationPaletteChange);
@@ -3399,7 +3539,7 @@ void QGuiApplicationPrivate::applyWindowGeometrySpecificationTo(QWindow *window)
/*!
\since 5.11
\fn void QGuiApplication::fontChanged(const QFont &font)
- \deprecated
+ \deprecated [6.0] Handle QEvent::ApplicationFontChange instead.
This signal is emitted when the \a font of the application changes. Use
QEvent::ApplicationFontChanged instead.
@@ -3442,10 +3582,14 @@ void QGuiApplication::setFont(const QFont &font)
if (emitChange && qGuiApp) {
auto font = *QGuiApplicationPrivate::app_font;
locker.unlock();
+#if QT_DEPRECATED_SINCE(6, 0)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
emit qGuiApp->fontChanged(font);
QT_WARNING_POP
+#else
+ Q_UNUSED(font);
+#endif // QT_DEPRECATED_SINCE(6, 0)
QEvent event(QEvent::ApplicationFontChange);
QGuiApplication::sendEvent(qGuiApp, &event);
}
@@ -3532,61 +3676,67 @@ void QGuiApplicationPrivate::notifyWindowIconChanged()
The default is \c true.
If this property is \c true, the applications quits when the last visible
- primary window (i.e. window with no parent) is closed.
+ \l{Primary and Secondary Windows}{primary window} (i.e. top level window
+ with no transient parent) is closed.
\sa quit(), QWindow::close()
*/
void QGuiApplication::setQuitOnLastWindowClosed(bool quit)
{
- QCoreApplication::setQuitLockEnabled(quit);
+ QGuiApplicationPrivate::quitOnLastWindowClosed = quit;
}
-
-
bool QGuiApplication::quitOnLastWindowClosed()
{
- return QCoreApplication::isQuitLockEnabled();
+ return QGuiApplicationPrivate::quitOnLastWindowClosed;
}
+void QGuiApplicationPrivate::maybeLastWindowClosed()
+{
+ if (!lastWindowClosed())
+ return;
+
+ if (in_exec)
+ emit q_func()->lastWindowClosed();
+
+ if (quitOnLastWindowClosed && canQuitAutomatically())
+ quitAutomatically();
+}
/*!
\fn void QGuiApplication::lastWindowClosed()
This signal is emitted from exec() when the last visible
- primary window (i.e. window with no parent) is closed.
+ \l{Primary and Secondary Windows}{primary window} (i.e.
+ top level window with no transient parent) is closed.
By default, QGuiApplication quits after this signal is emitted. This feature
can be turned off by setting \l quitOnLastWindowClosed to \c false.
- \sa QWindow::close(), QWindow::isTopLevel()
+ \sa QWindow::close(), QWindow::isTopLevel(), QWindow::transientParent()
*/
-void QGuiApplicationPrivate::emitLastWindowClosed()
+bool QGuiApplicationPrivate::lastWindowClosed() const
{
- if (qGuiApp && qGuiApp->d_func()->in_exec) {
- emit qGuiApp->lastWindowClosed();
- }
-}
+ for (auto *window : QGuiApplication::topLevelWindows()) {
+ auto *windowPrivate = qt_window_private(window);
+ if (!windowPrivate->participatesInLastWindowClosed())
+ continue;
-bool QGuiApplicationPrivate::shouldQuit()
-{
- const QWindowList processedWindows;
- return shouldQuitInternal(processedWindows);
+ if (windowPrivate->treatAsVisible())
+ return false;
+ }
+
+ return true;
}
-bool QGuiApplicationPrivate::shouldQuitInternal(const QWindowList &processedWindows)
+bool QGuiApplicationPrivate::canQuitAutomatically()
{
- /* if there is no visible top-level window left, we allow the quit */
- QWindowList list = QGuiApplication::topLevelWindows();
- for (int i = 0; i < list.size(); ++i) {
- QWindow *w = list.at(i);
- if (processedWindows.contains(w))
- continue;
- if (w->isVisible() && !w->transientParent())
- return false;
- }
- return true;
+ if (quitOnLastWindowClosed && !lastWindowClosed())
+ return false;
+
+ return QCoreApplicationPrivate::canQuitAutomatically();
}
void QGuiApplicationPrivate::quit()
@@ -3647,6 +3797,8 @@ Qt::ApplicationState QGuiApplication::applicationState()
*/
void QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy policy)
{
+ if (qApp)
+ qWarning("setHighDpiScaleFactorRoundingPolicy must be called before creating the QGuiApplication instance");
QGuiApplicationPrivate::highDpiScaleFactorRoundingPolicy = policy;
}
@@ -3867,7 +4019,8 @@ void QGuiApplication::sync()
\property QGuiApplication::layoutDirection
\brief the default layout direction for this application
- On system start-up, the default layout direction depends on the
+ On system start-up, or when the direction is explicitly set to
+ Qt::LayoutDirectionAuto, the default layout direction depends on the
application's language.
The notifier signal was introduced in Qt 5.4.
@@ -3877,11 +4030,15 @@ void QGuiApplication::sync()
void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction)
{
- if (layout_direction == direction || direction == Qt::LayoutDirectionAuto)
- return;
-
layout_direction = direction;
+ if (direction == Qt::LayoutDirectionAuto)
+ direction = qt_detectRTLLanguage() ? Qt::RightToLeft : Qt::LeftToRight;
+ // no change to the explicitly set or auto-detected layout direction
+ if (direction == effective_layout_direction)
+ return;
+
+ effective_layout_direction = direction;
if (qGuiApp) {
emit qGuiApp->layoutDirectionChanged(direction);
QGuiApplicationPrivate::self->notifyLayoutDirectionChange();
@@ -3890,10 +4047,15 @@ void QGuiApplication::setLayoutDirection(Qt::LayoutDirection direction)
Qt::LayoutDirection QGuiApplication::layoutDirection()
{
- // layout_direction is only ever Qt::LayoutDirectionAuto if setLayoutDirection
- // was never called, or called with Qt::LayoutDirectionAuto (which is a no-op).
- // In that case we return the default LeftToRight.
- return layout_direction == Qt::LayoutDirectionAuto ? Qt::LeftToRight : layout_direction;
+ /*
+ effective_layout_direction defaults to Qt::LeftToRight, and is updated with what is
+ auto-detected by a call to setLayoutDirection(Qt::LayoutDirectionAuto). This happens in
+ QGuiApplicationPrivate::init and when the language changes (or before if the application
+ calls the static function, but then no translators are installed so the auto-detection
+ always yields Qt::LeftToRight).
+ So we can be certain that it's always the right value.
+ */
+ return effective_layout_direction;
}
/*!
@@ -4000,7 +4162,7 @@ static inline void applyWindowCursor(const QList<QWindow *> &l)
Application cursors are stored on an internal stack. setOverrideCursor()
pushes the cursor onto the stack, and restoreOverrideCursor() pops the
- active cursor off the stack. changeOverrideCursor() changes the curently
+ active cursor off the stack. changeOverrideCursor() changes the currently
active application override cursor.
Every setOverrideCursor() must eventually be followed by a corresponding
@@ -4117,7 +4279,10 @@ QInputMethod *QGuiApplication::inputMethod()
/*!
\fn void QGuiApplication::fontDatabaseChanged()
- This signal is emitted when application fonts are loaded or removed.
+ This signal is emitted when the available fonts have changed.
+
+ This can happen when application fonts are added or removed, or when the
+ system fonts change.
\sa QFontDatabase::addApplicationFont(),
QFontDatabase::addApplicationFontFromData(),
@@ -4131,18 +4296,12 @@ QPixmap QGuiApplicationPrivate::getPixmapCursor(Qt::CursorShape cshape)
return QPixmap();
}
-void QGuiApplicationPrivate::notifyThemeChanged()
+QPoint QGuiApplicationPrivate::QLastCursorPosition::toPoint() const noexcept
{
- updatePalette();
-
- QAbstractFileIconProviderPrivate::clearIconTypeCache();
-
- if (!(applicationResourceFlags & ApplicationFontExplicitlySet)) {
- const auto locker = qt_scoped_lock(applicationFontMutex);
- clearFontUnlocked();
- initFontUnlocked();
- }
- initThemeHints();
+ // Guard against the default initialization of qInf() (avoid UB or SIGFPE in conversion).
+ if (Q_UNLIKELY(qIsInf(thePoint.x())))
+ return QPoint(std::numeric_limits<int>::max(), std::numeric_limits<int>::max());
+ return thePoint.toPoint();
}
#if QT_CONFIG(draganddrop)
@@ -4156,10 +4315,8 @@ void QGuiApplicationPrivate::notifyDragStarted(const QDrag *drag)
const QColorTrcLut *QGuiApplicationPrivate::colorProfileForA8Text()
{
#ifdef Q_OS_WIN
- if (!m_a8ColorProfile){
- QColorTrcLut *cs = QColorTrcLut::fromGamma(2.31); // This is a hard-coded thing for Windows text rendering
- m_a8ColorProfile.reset(cs);
- }
+ if (!m_a8ColorProfile)
+ m_a8ColorProfile = QColorTrcLut::fromGamma(2.31); // This is a hard-coded thing for Windows text rendering
return m_a8ColorProfile.get();
#else
return colorProfileForA32Text();
@@ -4168,10 +4325,8 @@ const QColorTrcLut *QGuiApplicationPrivate::colorProfileForA8Text()
const QColorTrcLut *QGuiApplicationPrivate::colorProfileForA32Text()
{
- if (!m_a32ColorProfile) {
- QColorTrcLut *cs = QColorTrcLut::fromGamma(fontSmoothingGamma);
- m_a32ColorProfile.reset(cs);
- }
+ if (!m_a32ColorProfile)
+ m_a32ColorProfile = QColorTrcLut::fromGamma(fontSmoothingGamma);
return m_a32ColorProfile.get();
}
@@ -4207,9 +4362,22 @@ QInputDeviceManager *QGuiApplicationPrivate::inputDeviceManager()
return m_inputDeviceManager;
}
-template <>
-Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QGuiApplication *that, const char *name, int revision)
+/*!
+ \fn template <typename QNativeInterface> QNativeInterface *QGuiApplication::nativeInterface() const
+
+ Returns a native interface of the given type for the application.
+
+ This function provides access to platform specific functionality
+ of QGuiApplication, as defined in the QNativeInterface namespace:
+
+ \annotatedlist native-interfaces-qguiapplication
+
+ If the requested interface is not available a \nullptr is returned.
+ */
+
+void *QGuiApplication::resolveInterface(const char *name, int revision) const
{
+ using namespace QNativeInterface;
using namespace QNativeInterface::Private;
auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
@@ -4218,10 +4386,16 @@ Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(cons
#if defined(Q_OS_WIN)
QT_NATIVE_INTERFACE_RETURN_IF(QWindowsApplication, platformIntegration);
#endif
+#if QT_CONFIG(xcb)
+ QT_NATIVE_INTERFACE_RETURN_IF(QX11Application, platformNativeInterface());
+#endif
+#if QT_CONFIG(wayland)
+ QT_NATIVE_INTERFACE_RETURN_IF(QWaylandApplication, platformNativeInterface());
+#endif
- return resolveInterface<QCoreApplication>(that, name, revision);
+ return QCoreApplication::resolveInterface(name, revision);
}
-#include "moc_qguiapplication.cpp"
-
QT_END_NAMESPACE
+
+#include "moc_qguiapplication.cpp"
diff --git a/src/gui/kernel/qguiapplication.h b/src/gui/kernel/qguiapplication.h
index 02d0376e77..14bce88c62 100644
--- a/src/gui/kernel/qguiapplication.h
+++ b/src/gui/kernel/qguiapplication.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QGUIAPPLICATION_H
#define QGUIAPPLICATION_H
@@ -73,11 +37,14 @@ class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
{
Q_OBJECT
Q_PROPERTY(QIcon windowIcon READ windowIcon WRITE setWindowIcon)
- Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName NOTIFY applicationDisplayNameChanged)
+ Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName
+ WRITE setApplicationDisplayName NOTIFY applicationDisplayNameChanged)
Q_PROPERTY(QString desktopFileName READ desktopFileName WRITE setDesktopFileName)
- Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged)
+ Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection
+ NOTIFY layoutDirectionChanged)
Q_PROPERTY(QString platformName READ platformName STORED false)
- Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
+ Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed
+ WRITE setQuitOnLastWindowClosed)
Q_PROPERTY(QScreen *primaryScreen READ primaryScreen NOTIFY primaryScreenChanged STORED false)
public:
@@ -91,6 +58,8 @@ public:
static void setApplicationDisplayName(const QString &name);
static QString applicationDisplayName();
+ Q_SLOT void setBadgeNumber(qint64 number);
+
static void setDesktopFileName(const QString &name);
static QString desktopFileName();
@@ -170,7 +139,7 @@ public:
bool isSavingSession() const;
#endif
- QT_DECLARE_NATIVE_INTERFACE_ACCESSOR
+ QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QGuiApplication)
static void sync();
Q_SIGNALS:
@@ -216,4 +185,6 @@ private:
QT_END_NAMESPACE
+#include <QtGui/qguiapplication_platform.h>
+
#endif // QGUIAPPLICATION_H
diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h
index 70571cf751..2bfcd87f3f 100644
--- a/src/gui/kernel/qguiapplication_p.h
+++ b/src/gui/kernel/qguiapplication_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 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) 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 QGUIAPPLICATION_P_H
#define QGUIAPPLICATION_P_H
@@ -55,11 +19,13 @@
#include <QtGui/qguiapplication.h>
#include <QtGui/qicon.h>
+#include <QtCore/QHash>
#include <QtCore/QPointF>
-#include <QtCore/QSharedPointer>
#include <QtCore/private/qcoreapplication_p.h>
#include <QtCore/qnativeinterface.h>
+#include <QtCore/private/qnativeinterface_p.h>
+#include <QtCore/private/qnumeric_p.h>
#include <QtCore/private/qthread_p.h>
#include <qpa/qwindowsysteminterface.h>
@@ -68,6 +34,10 @@
# include "private/qshortcutmap_p.h"
#endif
+#include <QtCore/qpointer.h>
+
+#include <memory>
+
QT_BEGIN_NAMESPACE
class QColorTrcLut;
@@ -89,7 +59,7 @@ class Q_GUI_EXPORT QGuiApplicationPrivate : public QCoreApplicationPrivate
{
Q_DECLARE_PUBLIC(QGuiApplication)
public:
- QGuiApplicationPrivate(int &argc, char **argv, int flags);
+ QGuiApplicationPrivate(int &argc, char **argv);
~QGuiApplicationPrivate();
void init();
@@ -104,10 +74,12 @@ public:
#if QT_CONFIG(commandlineparser)
void addQtOptions(QList<QCommandLineOption> *options) override;
#endif
- virtual bool shouldQuit() override;
+ bool canQuitAutomatically() override;
void quit() override;
- bool shouldQuitInternal(const QWindowList &processedWindows);
+ void maybeLastWindowClosed();
+ bool lastWindowClosed() const;
+ static bool quitOnLastWindowClosed;
static void captureGlobalModifierState(QEvent *e);
static Qt::KeyboardModifiers modifier_buttons;
@@ -143,9 +115,11 @@ public:
static void processEnterEvent(QWindowSystemInterfacePrivate::EnterEvent *e);
static void processLeaveEvent(QWindowSystemInterfacePrivate::LeaveEvent *e);
- static void processActivatedEvent(QWindowSystemInterfacePrivate::ActivatedWindowEvent *e);
+ static void processFocusWindowEvent(QWindowSystemInterfacePrivate::FocusWindowEvent *e);
+
static void processWindowStateChangedEvent(QWindowSystemInterfacePrivate::WindowStateChangedEvent *e);
static void processWindowScreenChangedEvent(QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e);
+ static void processWindowDevicePixelRatioChangedEvent(QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent *e);
static void processSafeAreaMarginsChangedEvent(QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e);
@@ -203,8 +177,6 @@ public:
return alignment;
}
- static void emitLastWindowClosed();
-
QPixmap getPixmapCursor(Qt::CursorShape cshape);
void _q_updateFocusObject(QObject *object);
@@ -220,11 +192,49 @@ public:
static void showModalWindow(QWindow *window);
static void hideModalWindow(QWindow *window);
static void updateBlockedStatus(QWindow *window);
- virtual bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const;
+
+ virtual Qt::WindowModality defaultModality() const;
+ virtual bool windowNeverBlocked(QWindow *window) const;
+ bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = nullptr) const;
virtual bool popupActive() { return false; }
+ virtual bool closeAllPopups() { return false; }
static Qt::MouseButton mousePressButton;
- static QPointF lastCursorPosition;
+ static struct QLastCursorPosition {
+ constexpr inline QLastCursorPosition() noexcept : thePoint(qt_inf(), qt_inf()) {}
+ constexpr inline Q_IMPLICIT QLastCursorPosition(QPointF p) noexcept : thePoint(p) {}
+ constexpr inline Q_IMPLICIT operator QPointF() const noexcept { return thePoint; }
+ constexpr inline qreal x() const noexcept{ return thePoint.x(); }
+ constexpr inline qreal y() const noexcept{ return thePoint.y(); }
+ Q_GUI_EXPORT QPoint toPoint() const noexcept;
+
+ constexpr void reset() noexcept { *this = QLastCursorPosition{}; }
+
+ // QGuiApplicationPrivate::lastCursorPosition is used for mouse-move detection
+ // but even QPointF's qFuzzCompare on doubles is too precise, and causes move-noise
+ // e.g. on macOS (see QTBUG-111170). So we specialize the equality operators here
+ // to use single-point precision.
+ friend constexpr bool operator==(const QLastCursorPosition &p1, const QPointF &p2) noexcept
+ {
+ return qFuzzyCompare(float(p1.x()), float(p2.x()))
+ && qFuzzyCompare(float(p1.y()), float(p2.y()));
+ }
+ friend constexpr bool operator!=(const QLastCursorPosition &p1, const QPointF &p2) noexcept
+ {
+ return !(p1 == p2);
+ }
+ friend constexpr bool operator==(const QPointF &p1, const QLastCursorPosition &p2) noexcept
+ {
+ return p2 == p1;
+ }
+ friend constexpr bool operator!=(const QPointF &p1, const QLastCursorPosition &p2) noexcept
+ {
+ return !(p2 == p1);
+ }
+
+ private:
+ QPointF thePoint;
+ } lastCursorPosition;
static QWindow *currentMouseWindow;
static QWindow *currentMousePressWindow;
static Qt::ApplicationState applicationState;
@@ -313,8 +323,10 @@ public:
static void updatePalette();
+ static Qt::ColorScheme colorScheme();
+
protected:
- virtual void notifyThemeChanged();
+ virtual void handleThemeChanged();
static bool setPalette(const QPalette &palette);
virtual QPalette basePalette() const;
@@ -331,8 +343,10 @@ private:
static QGuiApplicationPrivate *self;
static int m_fakeMouseSourcePointId;
- QSharedPointer<QColorTrcLut> m_a8ColorProfile;
- QSharedPointer<QColorTrcLut> m_a32ColorProfile;
+#ifdef Q_OS_WIN
+ std::shared_ptr<QColorTrcLut> m_a8ColorProfile;
+#endif
+ std::shared_ptr<QColorTrcLut> m_a32ColorProfile;
bool ownGlobalShareContext;
@@ -345,11 +359,12 @@ private:
// ----------------- QNativeInterface -----------------
+class QWindowsMimeConverter;
+
namespace QNativeInterface::Private {
-#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_WIN) || defined(Q_QDOC)
-class QWindowsMime;
struct Q_GUI_EXPORT QWindowsApplication
{
@@ -381,18 +396,18 @@ struct Q_GUI_EXPORT QWindowsApplication
virtual WindowActivationBehavior windowActivationBehavior() const = 0;
virtual void setWindowActivationBehavior(WindowActivationBehavior behavior) = 0;
+ virtual void setHasBorderInFullScreenDefault(bool border) = 0;
+
virtual bool isTabletMode() const = 0;
virtual bool isWinTabEnabled() const = 0;
virtual bool setWinTabEnabled(bool enabled) = 0;
- virtual bool isDarkMode() const = 0;
-
virtual DarkModeHandling darkModeHandling() const = 0;
virtual void setDarkModeHandling(DarkModeHandling handling) = 0;
- virtual void registerMime(QWindowsMime *mime) = 0;
- virtual void unregisterMime(QWindowsMime *mime) = 0;
+ virtual void registerMime(QWindowsMimeConverter *mime) = 0;
+ virtual void unregisterMime(QWindowsMimeConverter *mime) = 0;
virtual int registerMimeType(const QString &mime) = 0;
@@ -405,6 +420,8 @@ struct Q_GUI_EXPORT QWindowsApplication
virtual QVariant gpu() const = 0; // internal, used by qtdiag
virtual QVariant gpuList() const = 0;
+
+ virtual void populateLightSystemPalette(QPalette &pal) const = 0;
};
#endif // Q_OS_WIN
diff --git a/src/gui/kernel/qguiapplication_platform.h b/src/gui/kernel/qguiapplication_platform.h
new file mode 100644
index 0000000000..545bf75c84
--- /dev/null
+++ b/src/gui/kernel/qguiapplication_platform.h
@@ -0,0 +1,68 @@
+// Copyright (C) 2021 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 QGUIAPPLICATION_PLATFORM_H
+#define QGUIAPPLICATION_PLATFORM_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the native interface APIs. Usage of
+// this API may make your code source and binary incompatible
+// with future versions of Qt.
+//
+
+#include <QtGui/qtguiglobal.h>
+
+#include <QtCore/qnativeinterface.h>
+#include <QtGui/qguiapplication.h>
+
+#if QT_CONFIG(xcb)
+typedef struct _XDisplay Display;
+struct xcb_connection_t;
+#endif
+
+#if QT_CONFIG(wayland)
+struct wl_display;
+struct wl_compositor;
+struct wl_seat;
+struct wl_keyboard;
+struct wl_pointer;
+struct wl_touch;
+#endif
+
+QT_BEGIN_NAMESPACE
+
+namespace QNativeInterface
+{
+
+#if QT_CONFIG(xcb) || defined(Q_QDOC)
+struct Q_GUI_EXPORT QX11Application
+{
+ QT_DECLARE_NATIVE_INTERFACE(QX11Application, 1, QGuiApplication)
+ virtual Display *display() const = 0;
+ virtual xcb_connection_t *connection() const = 0;
+};
+#endif
+
+#if QT_CONFIG(wayland) || defined(Q_QDOC)
+struct Q_GUI_EXPORT QWaylandApplication
+{
+ QT_DECLARE_NATIVE_INTERFACE(QWaylandApplication, 1, QGuiApplication)
+ virtual wl_display *display() const = 0;
+ virtual wl_compositor *compositor() const = 0;
+ virtual wl_seat *seat() const = 0;
+ virtual wl_keyboard *keyboard() const = 0;
+ virtual wl_pointer *pointer() const = 0;
+ virtual wl_touch *touch() const = 0;
+ virtual uint lastInputSerial() const = 0;
+ virtual wl_seat *lastInputSeat() const = 0;
+};
+#endif
+
+} // QNativeInterface
+
+QT_END_NAMESPACE
+
+#endif // QGUIAPPLICATION_PLATFORM_H
diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp
index 1b455a57bf..fe72e7782f 100644
--- a/src/gui/kernel/qguivariant.cpp
+++ b/src/gui/kernel/qguivariant.cpp
@@ -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
// Gui types
#include "qbitmap.h"
@@ -86,20 +50,14 @@
#include <float.h>
-#include "private/qvariant_p.h"
#include <private/qmetatype_p.h>
QT_BEGIN_NAMESPACE
namespace {
-struct GuiTypesFilter {
- template<typename T>
- struct Acceptor {
- static const bool IsAccepted = QModulesPrivate::QTypeModuleInfo<T>::IsGui && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable;
- };
-};
-static const struct : QMetaTypeModuleHelper
+// NOLINTNEXTLINE(cppcoreguidelines-virtual-class-destructor): this is not a base class
+static constexpr struct : QMetaTypeModuleHelper
{
#define QT_IMPL_METATYPEINTERFACE_GUI_TYPES(MetaTypeName, MetaTypeId, RealName) \
QT_METATYPE_INTERFACE_INIT(RealName),
@@ -128,7 +86,7 @@ static const struct : QMetaTypeModuleHelper
return true;
);
QMETATYPE_CONVERTER(QColor, QByteArray,
- result.setNamedColor(QLatin1String(source));
+ result = QColor::fromString(QLatin1StringView(source));
return result.isValid();
);
QMETATYPE_CONVERTER(QString, QColor,
@@ -137,7 +95,7 @@ static const struct : QMetaTypeModuleHelper
return true;
);
QMETATYPE_CONVERTER(QColor, QString,
- result.setNamedColor(source);
+ result = QColor::fromString(source);
return result.isValid();
);
#if QT_CONFIG(shortcut)
diff --git a/src/gui/kernel/qhighdpiscaling.cpp b/src/gui/kernel/qhighdpiscaling.cpp
index 1ce5f84ed8..a0e1b48dcb 100644
--- a/src/gui/kernel/qhighdpiscaling.cpp
+++ b/src/gui/kernel/qhighdpiscaling.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qhighdpiscaling_p.h"
#include "qguiapplication.h"
@@ -183,7 +147,7 @@ static std::optional<qreal> qEnvironmentVariableOptionalReal(const char *name)
is always enabled. The Qt scale factor value is typically determined by the
QPlatformScreen implementation - see below.
- There is one environment variable based opt-out option: set QT_ENABLE_HIGH_DPI_SCALING=0.
+ There is one environment variable based opt-out option: set QT_ENABLE_HIGHDPI_SCALING=0.
Keep in mind that this does not affect the OS scale factor, which is controlled by
the operating system.
@@ -437,6 +401,8 @@ QDpi QHighDpiScaling::effectiveLogicalDpi(const QPlatformScreen *screen, qreal r
*/
void QHighDpiScaling::initHighDpiScaling()
{
+ qCDebug(lcHighDpi) << "Initializing high-DPI scaling";
+
// Read environment variables
static const char* envDebugStr = "environment variable set:";
std::optional<int> envEnableHighDpiScaling = qEnvironmentVariableOptionalInt(enableHighDpiScalingEnvVar);
@@ -496,7 +462,7 @@ void QHighDpiScaling::initHighDpiScaling()
// Resolve DpiAdjustmentPolicy to m_dpiAdjustmentPolicy
if (envDpiAdjustmentPolicy.has_value()) {
- QByteArray policyText = envScaleFactorRoundingPolicy.value();
+ QByteArray policyText = envDpiAdjustmentPolicy.value();
auto policyEnumValue = lookupDpiAdjustmentPolicy(policyText);
if (policyEnumValue != DpiAdjustmentPolicy::Unset) {
QHighDpiScaling::m_dpiAdjustmentPolicy = policyEnumValue;
@@ -510,6 +476,9 @@ void QHighDpiScaling::initHighDpiScaling()
// Set initial active state
m_active = m_globalScalingActive || m_usePlatformPluginDpi;
+
+ qCDebug(lcHighDpi) << "Initialization done, high-DPI scaling is"
+ << (m_active ? "active" : "inactive");
}
/*
@@ -518,14 +487,18 @@ void QHighDpiScaling::initHighDpiScaling()
*/
void QHighDpiScaling::updateHighDpiScaling()
{
+ qCDebug(lcHighDpi) << "Updating high-DPI scaling";
+
// Apply screen factors from environment
if (m_screenFactors.size() > 0) {
+ qCDebug(lcHighDpi) << "Applying screen factors" << m_screenFactors;
int i = -1;
const auto screens = QGuiApplication::screens();
- for (const auto &[name, factor] : m_screenFactors) {
+ for (const auto &[name, rawFactor]: m_screenFactors) {
+ const qreal factor = roundScaleFactor(rawFactor);
++i;
if (name.isNull()) {
- if (i < screens.count())
+ if (i < screens.size())
setScreenFactor(screens.at(i), factor);
} else {
for (QScreen *screen : screens) {
@@ -551,6 +524,9 @@ void QHighDpiScaling::updateHighDpiScaling()
}
m_active = m_globalScalingActive || m_screenFactorSet || m_platformPluginDpiScalingActive;
+
+ qCDebug(lcHighDpi) << "Update done, high-DPI scaling is"
+ << (m_active ? "active" : "inactive");
}
/*
@@ -558,17 +534,24 @@ void QHighDpiScaling::updateHighDpiScaling()
*/
void QHighDpiScaling::setGlobalFactor(qreal factor)
{
+ qCDebug(lcHighDpi) << "Setting global scale factor to" << factor;
+
if (qFuzzyCompare(factor, m_factor))
return;
if (!QGuiApplication::allWindows().isEmpty())
qWarning("QHighDpiScaling::setFactor: Should only be called when no windows exist.");
+ const auto screens = QGuiApplication::screens();
+
+ std::vector<QScreenPrivate::UpdateEmitter> updateEmitters;
+ for (QScreen *screen : screens)
+ updateEmitters.emplace_back(screen);
+
m_globalScalingActive = !qFuzzyCompare(factor, qreal(1));
m_factor = m_globalScalingActive ? factor : qreal(1);
m_active = m_globalScalingActive || m_screenFactorSet || m_platformPluginDpiScalingActive ;
- const auto screens = QGuiApplication::screens();
for (QScreen *screen : screens)
- screen->d_func()->updateHighDpi();
+ screen->d_func()->updateGeometry();
}
static const char scaleFactorProperty[] = "_q_scaleFactor";
@@ -578,11 +561,15 @@ static const char scaleFactorProperty[] = "_q_scaleFactor";
*/
void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
{
+ qCDebug(lcHighDpi) << "Setting screen scale factor for" << screen << "to" << factor;
+
if (!qFuzzyCompare(factor, qreal(1))) {
m_screenFactorSet = true;
m_active = true;
}
+ QScreenPrivate::UpdateEmitter updateEmitter(screen);
+
// Prefer associating the factor with screen name over the object
// since the screen object may be deleted on screen disconnects.
const QString name = screen->name();
@@ -591,9 +578,7 @@ void QHighDpiScaling::setScreenFactor(QScreen *screen, qreal factor)
else
QHighDpiScaling::m_namedScreenScaleFactors.insert(name, factor);
- // hack to force re-evaluation of screen geometry
- if (screen->handle())
- screen->d_func()->setPlatformScreen(screen->handle()); // updates geometries based on scale factor
+ screen->d_func()->updateGeometry();
}
QPoint QHighDpiScaling::mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen)
@@ -714,7 +699,7 @@ QVector<QHighDpiScaling::ScreenFactor> QHighDpiScaling::parseScreenScaleFactorsS
// - a semicolon-separated name=factor list: "foo=1.5;bar=2;baz=3"
const auto specs = screenScaleFactors.split(u';');
for (const auto &spec : specs) {
- const int equalsPos = spec.lastIndexOf(QLatin1Char('='));
+ const qsizetype equalsPos = spec.lastIndexOf(u'=');
if (equalsPos == -1) {
// screens in order
bool ok;
@@ -768,7 +753,20 @@ QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QWindow *w
return scaleAndOrigin(targetScreen, position);
}
-#else
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug debug, const QHighDpiScaling::ScreenFactor &factor)
+{
+ const QDebugStateSaver saver(debug);
+ debug.nospace();
+ if (!factor.name.isEmpty())
+ debug << factor.name << "=";
+ debug << factor.factor;
+ return debug;
+}
+#endif
+
+#else // QT_NO_HIGHDPISCALING
+
QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QPlatformScreen *, QPoint *)
{
return { qreal(1), QPoint() };
@@ -783,5 +781,9 @@ QHighDpiScaling::ScaleAndOrigin QHighDpiScaling::scaleAndOrigin(const QWindow *,
{
return { qreal(1), QPoint() };
}
-#endif //QT_NO_HIGHDPISCALING
+
+#endif // QT_NO_HIGHDPISCALING
+
QT_END_NAMESPACE
+
+#include "moc_qhighdpiscaling_p.cpp"
diff --git a/src/gui/kernel/qhighdpiscaling_p.h b/src/gui/kernel/qhighdpiscaling_p.h
index 8460b3ec2e..189f31fd0a 100644
--- a/src/gui/kernel/qhighdpiscaling_p.h
+++ b/src/gui/kernel/qhighdpiscaling_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 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) 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 QHIGHDPISCALING_P_H
#define QHIGHDPISCALING_P_H
@@ -124,6 +88,7 @@ public:
static QPoint mapPositionFromNative(const QPoint &pos, const QPlatformScreen *platformScreen);
static QPoint mapPositionToNative(const QPoint &pos, const QPlatformScreen *platformScreen);
static QDpi logicalDpi(const QScreen *screen);
+ static qreal roundScaleFactor(qreal rawFactor);
private:
struct ScreenFactor {
@@ -134,7 +99,6 @@ private:
};
static qreal rawScaleFactor(const QPlatformScreen *screen);
- static qreal roundScaleFactor(qreal rawFactor);
static QDpi effectiveLogicalDpi(const QPlatformScreen *screen, qreal rawFactor, qreal roundedFactor);
static qreal screenSubfactor(const QPlatformScreen *screen);
static QScreen *screenForPosition(Point position, QScreen *guess);
@@ -150,6 +114,10 @@ private:
static QVector<ScreenFactor> m_screenFactors;
static DpiAdjustmentPolicy m_dpiAdjustmentPolicy;
static QHash<QString, qreal> m_namedScreenScaleFactors;
+
+#ifndef QT_NO_DEBUG_STREAM
+ friend Q_GUI_EXPORT QDebug operator<<(QDebug, const ScreenFactor &);
+#endif
};
namespace QHighDpi {
@@ -219,10 +187,9 @@ inline QRegion scale(const QRegion &region, qreal scaleFactor, QPoint origin = Q
if (!QHighDpiScaling::isActive())
return region;
- QRegion scaled;
- for (const QRect &rect : region)
- scaled += scale(QRectF(rect), scaleFactor, origin).toRect();
- return scaled;
+ QRegion scaled = region.translated(-origin);
+ scaled = QTransform::fromScale(scaleFactor, scaleFactor).map(scaled);
+ return scaled.translated(origin);
}
template <typename T>
@@ -381,6 +348,9 @@ public:
namespace QHighDpi {
template <typename T> inline
+ T scale(const T &value, ...) { return value; }
+
+ template <typename T> inline
T toNative(const T &value, ...) { return value; }
template <typename T> inline
T fromNative(const T &value, ...) { return value; }
diff --git a/src/gui/kernel/qinputdevice.cpp b/src/gui/kernel/qinputdevice.cpp
index 9dcf288d00..f7b216dcf0 100644
--- a/src/gui/kernel/qinputdevice.cpp
+++ b/src/gui/kernel/qinputdevice.cpp
@@ -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
#include "qinputdevice.h"
#include "qinputdevice_p.h"
@@ -48,6 +12,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QInputDevice
\brief The QInputDevice class describes a device from which a QInputEvent originates.
@@ -101,6 +67,11 @@ QT_BEGIN_NAMESPACE
\value Scroll
Indicates that the device has a scroll capability.
+ \value [since 6.2] PixelScroll
+ Indicates that the device (usually a
+ \l {QInputDevice::DeviceType::TouchPad}{touchpad})
+ scrolls with \l {QWheelEvent::pixelDelta()}{pixel precision}.
+
\value Hover
Indicates that the device has a hover capability.
@@ -259,11 +230,18 @@ QString QInputDevice::seatName() const
using InputDevicesList = QList<const QInputDevice *>;
Q_GLOBAL_STATIC(InputDevicesList, deviceList)
-static QBasicMutex devicesMutex;
+Q_CONSTINIT static QBasicMutex devicesMutex;
/*!
Returns a list of all registered input devices (keyboards and pointing devices).
+ \note The list of devices is not always complete on all platforms. So far,
+ the most-complete information is available on the \l {Qt for Linux/X11}{X11}
+ platform, at startup and in response to hot-plugging. Most other platforms
+ are only able to provide generic devices of various types, only after receiving
+ events from them; and most platforms do not tell Qt when a device is plugged in,
+ or when it is unplugged at runtime.
+
\note The returned list cannot be used to add new devices. To add a simulated
touch screen for an autotest, QTest::createTouchDevice() can be used.
Platform plugins should call QWindowSystemInterface::registerInputDevice()
@@ -276,16 +254,37 @@ QList<const QInputDevice *> QInputDevice::devices()
}
/*!
+ \since 6.3
+
+ Returns a list of seat names for all registered input devices (keyboards and pointing devices).
+*/
+QStringList QInputDevice::seatNames()
+{
+ QMutexLocker locker(&devicesMutex);
+ const InputDevicesList devices = *deviceList();
+ locker.unlock();
+ QStringList result;
+ for (const QInputDevice *d : devices) {
+ if (!result.contains(d->seatName()))
+ result.append(d->seatName());
+ }
+
+ return result;
+}
+
+/*!
Returns the core or master keyboard on the given seat \a seatName.
*/
const QInputDevice *QInputDevice::primaryKeyboard(const QString& seatName)
{
QMutexLocker locker(&devicesMutex);
- InputDevicesList v = *deviceList();
+ const InputDevicesList devices = *deviceList();
locker.unlock();
const QInputDevice *ret = nullptr;
- for (const QInputDevice *d : v) {
- if (d->type() == DeviceType::Keyboard && d->seatName() == seatName) {
+ for (const QInputDevice *d : devices) {
+ if (d->type() != DeviceType::Keyboard)
+ continue;
+ if (seatName.isNull() || d->seatName() == seatName) {
// the master keyboard's parent is not another input device
if (!d->parent() || !qobject_cast<const QInputDevice *>(d->parent()))
return d;
@@ -297,7 +296,7 @@ const QInputDevice *QInputDevice::primaryKeyboard(const QString& seatName)
qCDebug(lcQpaInputDevices) << "no keyboards registered for seat" << seatName
<< "The platform plugin should have provided one via "
"QWindowSystemInterface::registerInputDevice(). Creating a default one for now.";
- ret = new QInputDevice(QLatin1String("core keyboard"), 0, DeviceType::Keyboard, seatName, QCoreApplication::instance());
+ ret = new QInputDevice("core keyboard"_L1, 0, DeviceType::Keyboard, seatName, QCoreApplication::instance());
QInputDevicePrivate::registerDevice(ret);
return ret;
}
@@ -305,6 +304,9 @@ const QInputDevice *QInputDevice::primaryKeyboard(const QString& seatName)
return ret;
}
+QInputDevicePrivate::~QInputDevicePrivate()
+ = default;
+
/*!
\internal
Checks whether a matching device is already registered
@@ -365,22 +367,29 @@ bool QInputDevice::operator==(const QInputDevice &other) const
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QInputDevice *device)
{
- const QInputDevicePrivate *d = QInputDevicePrivate::get(device);
- if (d->pointingDeviceType)
- return operator<<(debug, static_cast<const QPointingDevice *>(device));
QDebugStateSaver saver(debug);
debug.nospace();
debug.noquote();
+
debug << "QInputDevice(";
- if (device) {
- debug << '"' << device->name() << "\", type=" << device->type()
- << Qt::hex << ", ID=" << device->systemId() << ", seat='" << device->seatName() << "'";
- } else {
- debug << '0';
+ if (!device) {
+ debug << "0)";
+ return debug;
}
+
+ const QInputDevicePrivate *d = QInputDevicePrivate::get(device);
+
+ if (d->pointingDeviceType)
+ return operator<<(debug, static_cast<const QPointingDevice *>(device));
+
+ debug << "QInputDevice(";
+ debug << '"' << device->name() << "\", type=" << device->type()
+ << ", ID=" << device->systemId() << ", seat='" << device->seatName() << "'";
debug << ')';
return debug;
}
#endif // !QT_NO_DEBUG_STREAM
QT_END_NAMESPACE
+
+#include "moc_qinputdevice.cpp"
diff --git a/src/gui/kernel/qinputdevice.h b/src/gui/kernel/qinputdevice.h
index 0389c7856e..2b7ce32d86 100644
--- a/src/gui/kernel/qinputdevice.h
+++ b/src/gui/kernel/qinputdevice.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 QINPUTDEVICE_H
#define QINPUTDEVICE_H
@@ -58,7 +22,8 @@ class Q_GUI_EXPORT QInputDevice : public QObject
Q_PROPERTY(Capabilities capabilities READ capabilities CONSTANT)
Q_PROPERTY(qint64 systemId READ systemId CONSTANT)
Q_PROPERTY(QString seatName READ seatName CONSTANT)
- Q_PROPERTY(QRect availableVirtualGeometry READ availableVirtualGeometry NOTIFY availableVirtualGeometryChanged)
+ Q_PROPERTY(QRect availableVirtualGeometry READ availableVirtualGeometry
+ NOTIFY availableVirtualGeometryChanged)
public:
enum class DeviceType {
@@ -83,6 +48,7 @@ public:
Velocity = 0x0008,
NormalizedPosition = 0x0020,
MouseEmulation = 0x0040,
+ PixelScroll = 0x0080,
Scroll = 0x0100,
Hover = 0x0200,
Rotation = 0x0400,
@@ -108,6 +74,7 @@ public:
QString seatName() const;
QRect availableVirtualGeometry() const;
+ static QStringList seatNames();
static QList<const QInputDevice *> devices();
static const QInputDevice *primaryKeyboard(const QString& seatName = QString());
diff --git a/src/gui/kernel/qinputdevice_p.h b/src/gui/kernel/qinputdevice_p.h
index 41150d055d..7f6ee258be 100644
--- a/src/gui/kernel/qinputdevice_p.h
+++ b/src/gui/kernel/qinputdevice_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 QINPUTDEVICE_P_H
#define QINPUTDEVICE_P_H
@@ -73,6 +37,7 @@ public:
if (!systemId)
systemId = nextId++;
}
+ ~QInputDevicePrivate() override;
QString name;
QString seatName;
diff --git a/src/gui/kernel/qinputdevicemanager.cpp b/src/gui/kernel/qinputdevicemanager.cpp
index 11442407e1..72af92cf17 100644
--- a/src/gui/kernel/qinputdevicemanager.cpp
+++ b/src/gui/kernel/qinputdevicemanager.cpp
@@ -1,47 +1,13 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qinputdevicemanager_p.h"
#include "qinputdevicemanager_p_p.h"
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN_TAGGED(QInputDeviceManager::DeviceType, QInputDeviceManager__DeviceType)
+
/*!
\class QInputDeviceManager
\internal
@@ -67,6 +33,8 @@ QInputDeviceManager::QInputDeviceManager(QObject *parent)
qRegisterMetaType<DeviceType>();
}
+QInputDeviceManager::~QInputDeviceManager() = default;
+
int QInputDeviceManager::deviceCount(DeviceType type) const
{
Q_D(const QInputDeviceManager);
@@ -116,3 +84,5 @@ void QInputDeviceManager::setKeyboardModifiers(Qt::KeyboardModifiers mods)
}
QT_END_NAMESPACE
+
+#include "moc_qinputdevicemanager_p.cpp"
diff --git a/src/gui/kernel/qinputdevicemanager_p.h b/src/gui/kernel/qinputdevicemanager_p.h
index 1d20b102e3..9c34ece555 100644
--- a/src/gui/kernel/qinputdevicemanager_p.h
+++ b/src/gui/kernel/qinputdevicemanager_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 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) 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 QINPUTDEVICEMANAGER_P_H
#define QINPUTDEVICEMANAGER_P_H
@@ -74,7 +38,8 @@ public:
NumDeviceTypes
};
- QInputDeviceManager(QObject *parent = nullptr);
+ explicit QInputDeviceManager(QObject *parent = nullptr);
+ ~QInputDeviceManager() override;
int deviceCount(DeviceType type) const;
@@ -83,13 +48,14 @@ public:
Qt::KeyboardModifiers keyboardModifiers() const;
void setKeyboardModifiers(Qt::KeyboardModifiers mods);
-signals:
+Q_SIGNALS:
void deviceListChanged(QInputDeviceManager::DeviceType type);
void cursorPositionChangeRequested(const QPoint &pos);
};
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QInputDeviceManager::DeviceType)
+QT_DECL_METATYPE_EXTERN_TAGGED(QInputDeviceManager::DeviceType,
+ QInputDeviceManager__DeviceType, Q_GUI_EXPORT)
#endif // QINPUTDEVICEMANAGER_P_H
diff --git a/src/gui/kernel/qinputdevicemanager_p_p.h b/src/gui/kernel/qinputdevicemanager_p_p.h
index 82a86446a0..b43904aa67 100644
--- a/src/gui/kernel/qinputdevicemanager_p_p.h
+++ b/src/gui/kernel/qinputdevicemanager_p_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 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) 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 QINPUTDEVICEMANAGER_P_P_H
#define QINPUTDEVICEMANAGER_P_P_H
diff --git a/src/gui/kernel/qinputmethod.cpp b/src/gui/kernel/qinputmethod.cpp
index f5de06aea1..e37e85e246 100644
--- a/src/gui/kernel/qinputmethod.cpp
+++ b/src/gui/kernel/qinputmethod.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qinputmethod.h>
#include <private/qinputmethod_p.h>
@@ -426,13 +390,21 @@ QVariant QInputMethod::queryFocusObject(Qt::InputMethodQuery query, const QVaria
if (!focusObject)
return retval;
- bool newMethodWorks = QMetaObject::invokeMethod(focusObject, "inputMethodQuery",
- Qt::DirectConnection,
- Q_RETURN_ARG(QVariant, retval),
- Q_ARG(Qt::InputMethodQuery, query),
- Q_ARG(QVariant, argument));
- if (newMethodWorks)
- return retval;
+ static const char *signature = "inputMethodQuery(Qt::InputMethodQuery,QVariant)";
+ const bool newMethodSupported = focusObject->metaObject()->indexOfMethod(signature) != -1;
+ if (newMethodSupported) {
+ const bool ok = QMetaObject::invokeMethod(focusObject, "inputMethodQuery",
+ Qt::DirectConnection,
+ Q_RETURN_ARG(QVariant, retval),
+ Q_ARG(Qt::InputMethodQuery, query),
+ Q_ARG(QVariant, argument));
+ Q_ASSERT(ok);
+ if (retval.isValid())
+ return retval;
+
+ // If the new API didn't have an answer to the query, we fall
+ // back to use the old event-based API.
+ }
QInputMethodQueryEvent queryEvent(query);
QCoreApplication::sendEvent(focusObject, &queryEvent);
diff --git a/src/gui/kernel/qinputmethod.h b/src/gui/kernel/qinputmethod.h
index 8f5eca3886..dfddc9b7c7 100644
--- a/src/gui/kernel/qinputmethod.h
+++ b/src/gui/kernel/qinputmethod.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QINPUTMETHOD_H
#define QINPUTMETHOD_H
@@ -58,7 +22,8 @@ class Q_GUI_EXPORT QInputMethod : public QObject
Q_PROPERTY(QRectF cursorRectangle READ cursorRectangle NOTIFY cursorRectangleChanged)
Q_PROPERTY(QRectF anchorRectangle READ anchorRectangle NOTIFY anchorRectangleChanged)
Q_PROPERTY(QRectF keyboardRectangle READ keyboardRectangle NOTIFY keyboardRectangleChanged)
- Q_PROPERTY(QRectF inputItemClipRectangle READ inputItemClipRectangle NOTIFY inputItemClipRectangleChanged)
+ Q_PROPERTY(QRectF inputItemClipRectangle READ inputItemClipRectangle
+ NOTIFY inputItemClipRectangleChanged)
Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
Q_PROPERTY(bool animating READ isAnimating NOTIFY animatingChanged)
Q_PROPERTY(QLocale locale READ locale NOTIFY localeChanged)
diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h
index 5657edeb4e..9191813b44 100644
--- a/src/gui/kernel/qinputmethod_p.h
+++ b/src/gui/kernel/qinputmethod_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 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) 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 QINPUTMETHOD_P_H
#define QINPUTMETHOD_P_H
diff --git a/src/gui/kernel/qinternalmimedata.cpp b/src/gui/kernel/qinternalmimedata.cpp
index 5dc296cd01..d33402703e 100644
--- a/src/gui/kernel/qinternalmimedata.cpp
+++ b/src/gui/kernel/qinternalmimedata.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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) 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 "qinternalmimedata_p.h"
@@ -46,15 +10,17 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
static QStringList imageMimeFormats(const QList<QByteArray> &imageFormats)
{
QStringList formats;
formats.reserve(imageFormats.size());
for (const auto &format : imageFormats)
- formats.append(QLatin1String("image/") + QLatin1String(format.toLower()));
+ formats.append("image/"_L1 + QLatin1StringView(format.toLower()));
//put png at the front because it is best
- int pngIndex = formats.indexOf(QLatin1String("image/png"));
+ const qsizetype pngIndex = formats.indexOf("image/png"_L1);
if (pngIndex != -1 && pngIndex != 0)
formats.move(pngIndex, 0);
@@ -83,7 +49,7 @@ QInternalMimeData::~QInternalMimeData()
bool QInternalMimeData::hasFormat(const QString &mimeType) const
{
bool foundFormat = hasFormat_sys(mimeType);
- if (!foundFormat && mimeType == QLatin1String("application/x-qt-image")) {
+ if (!foundFormat && mimeType == "application/x-qt-image"_L1) {
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if ((foundFormat = hasFormat_sys(imageFormats.at(i))))
@@ -96,11 +62,11 @@ bool QInternalMimeData::hasFormat(const QString &mimeType) const
QStringList QInternalMimeData::formats() const
{
QStringList realFormats = formats_sys();
- if (!realFormats.contains(QLatin1String("application/x-qt-image"))) {
+ if (!realFormats.contains("application/x-qt-image"_L1)) {
QStringList imageFormats = imageReadMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if (realFormats.contains(imageFormats.at(i))) {
- realFormats += QLatin1String("application/x-qt-image");
+ realFormats += "application/x-qt-image"_L1;
break;
}
}
@@ -111,7 +77,7 @@ QStringList QInternalMimeData::formats() const
QVariant QInternalMimeData::retrieveData(const QString &mimeType, QMetaType type) const
{
QVariant data = retrieveData_sys(mimeType, type);
- if (mimeType == QLatin1String("application/x-qt-image")) {
+ if (mimeType == "application/x-qt-image"_L1) {
if (data.isNull() || (data.metaType().id() == QMetaType::QByteArray && data.toByteArray().isEmpty())) {
// try to find an image
QStringList imageFormats = imageReadMimeFormats();
@@ -128,7 +94,7 @@ QVariant QInternalMimeData::retrieveData(const QString &mimeType, QMetaType type
&& (typeId == QMetaType::QImage || typeId == QMetaType::QPixmap || typeId == QMetaType::QBitmap))
data = QImage::fromData(data.toByteArray());
- } else if (mimeType == QLatin1String("application/x-color") && data.metaType().id() == QMetaType::QByteArray) {
+ } else if (mimeType == "application/x-color"_L1 && data.metaType().id() == QMetaType::QByteArray) {
QColor c;
QByteArray ba = data.toByteArray();
if (ba.size() == 8) {
@@ -160,7 +126,7 @@ bool QInternalMimeData::canReadData(const QString &mimeType)
QStringList QInternalMimeData::formatsHelper(const QMimeData *data)
{
QStringList realFormats = data->formats();
- if (realFormats.contains(QLatin1String("application/x-qt-image"))) {
+ if (realFormats.contains("application/x-qt-image"_L1)) {
// add all supported image formats
QStringList imageFormats = imageWriteMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
@@ -176,14 +142,14 @@ bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData
bool foundFormat = data->hasFormat(mimeType);
if (!foundFormat) {
- if (mimeType == QLatin1String("application/x-qt-image")) {
+ if (mimeType == "application/x-qt-image"_L1) {
// check all supported image formats
QStringList imageFormats = imageWriteMimeFormats();
for (int i = 0; i < imageFormats.size(); ++i) {
if ((foundFormat = data->hasFormat(imageFormats.at(i))))
break;
}
- } else if (mimeType.startsWith(QLatin1String("image/"))) {
+ } else if (mimeType.startsWith("image/"_L1)) {
return data->hasImage() && imageWriteMimeFormats().contains(mimeType);
}
}
@@ -193,7 +159,7 @@ bool QInternalMimeData::hasFormatHelper(const QString &mimeType, const QMimeData
QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QMimeData *data)
{
QByteArray ba;
- if (mimeType == QLatin1String("application/x-color")) {
+ if (mimeType == "application/x-color"_L1) {
/* QMimeData can only provide colors as QColor or the name
of a color as a QByteArray or a QString. So we need to do
the conversion to application/x-color here.
@@ -215,17 +181,17 @@ QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QM
} else {
ba = data->data(mimeType);
if (ba.isEmpty()) {
- if (mimeType == QLatin1String("application/x-qt-image") && data->hasImage()) {
+ if (mimeType == "application/x-qt-image"_L1 && data->hasImage()) {
QImage image = qvariant_cast<QImage>(data->imageData());
QBuffer buf(&ba);
buf.open(QBuffer::WriteOnly);
// would there not be PNG ??
image.save(&buf, "PNG");
- } else if (mimeType.startsWith(QLatin1String("image/")) && data->hasImage()) {
+ } else if (mimeType.startsWith("image/"_L1) && data->hasImage()) {
QImage image = qvariant_cast<QImage>(data->imageData());
QBuffer buf(&ba);
buf.open(QBuffer::WriteOnly);
- image.save(&buf, mimeType.mid(mimeType.indexOf(QLatin1Char('/')) + 1).toLatin1().toUpper());
+ image.save(&buf, mimeType.mid(mimeType.indexOf(u'/') + 1).toLatin1().toUpper());
}
}
}
@@ -233,3 +199,5 @@ QByteArray QInternalMimeData::renderDataHelper(const QString &mimeType, const QM
}
QT_END_NAMESPACE
+
+#include "moc_qinternalmimedata_p.cpp"
diff --git a/src/gui/kernel/qinternalmimedata_p.h b/src/gui/kernel/qinternalmimedata_p.h
index 5c61370360..ce4cfaa72d 100644
--- a/src/gui/kernel/qinternalmimedata_p.h
+++ b/src/gui/kernel/qinternalmimedata_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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) 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 QINTERNALMIMEDATA_P_H
#define QINTERNALMIMEDATA_P_H
diff --git a/src/gui/kernel/qkeymapper.cpp b/src/gui/kernel/qkeymapper.cpp
index e3d39f80dc..4ceb508465 100644
--- a/src/gui/kernel/qkeymapper.cpp
+++ b/src/gui/kernel/qkeymapper.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qguiapplication.h"
@@ -45,6 +9,7 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
+#include <qpa/qplatformkeymapper.h>
QT_BEGIN_NAMESPACE
@@ -59,8 +24,7 @@ QT_BEGIN_NAMESPACE
/*!
Constructs a new key mapper.
*/
-QKeyMapper::QKeyMapper()
- : QObject(*new QKeyMapperPrivate, nullptr)
+QKeyMapper::QKeyMapper() : QObject()
{
}
@@ -71,34 +35,34 @@ QKeyMapper::~QKeyMapper()
{
}
-static QList<int> extractKeyFromEvent(QKeyEvent *e)
+QList<QKeyCombination> QKeyMapper::possibleKeys(const QKeyEvent *e)
{
- QList<int> result;
- if (e->key() && (e->key() != Qt::Key_unknown))
- result << e->keyCombination().toCombined();
- else if (!e->text().isEmpty())
- result << int(e->text().at(0).unicode() + (int)e->modifiers());
- return result;
-}
+ qCDebug(lcQpaKeyMapper).verbosity(3) << "Computing possible key combinations for" << e;
-QList<int> QKeyMapper::possibleKeys(QKeyEvent *e)
-{
- return instance()->d_func()->possibleKeys(e);
-}
+ const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ const auto *platformKeyMapper = platformIntegration->keyMapper();
+ QList<QKeyCombination> result = platformKeyMapper->possibleKeyCombinations(e);
-extern bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); // in qapplication_*.cpp
-void QKeyMapper::changeKeyboard()
-{
- // ## TODO: Support KeyboardLayoutChange on QPA
-#if 0
- // inform all toplevel widgets of the change
- QEvent e(QEvent::KeyboardLayoutChange);
- QWidgetList list = QApplication::topLevelWidgets();
- for (int i = 0; i < list.size(); ++i) {
- QWidget *w = list.at(i);
- qt_sendSpontaneousEvent(w, &e);
+ if (result.isEmpty()) {
+ if (e->key() && (e->key() != Qt::Key_unknown))
+ result << e->keyCombination();
+ else if (!e->text().isEmpty())
+ result << (Qt::Key(e->text().at(0).unicode()) | e->modifiers());
+ }
+
+#if QT_CONFIG(shortcut)
+ if (lcQpaKeyMapper().isDebugEnabled()) {
+ qCDebug(lcQpaKeyMapper) << "Resulting possible key combinations:";
+ for (auto keyCombination : result) {
+ auto keySequence = QKeySequence(keyCombination);
+ qCDebug(lcQpaKeyMapper).verbosity(0) << "\t-"
+ << keyCombination << "/" << keySequence << "/"
+ << qUtf8Printable(keySequence.toString(QKeySequence::NativeText));
+ }
}
#endif
+
+ return result;
}
Q_GLOBAL_STATIC(QKeyMapper, keymapper)
@@ -111,34 +75,9 @@ QKeyMapper *QKeyMapper::instance()
return keymapper();
}
-QKeyMapperPrivate *qt_keymapper_private()
-{
- return QKeyMapper::instance()->d_func();
-}
-
-QKeyMapperPrivate::QKeyMapperPrivate()
+void *QKeyMapper::resolveInterface(const char *name, int revision) const
{
- keyboardInputLocale = QLocale::system();
- keyboardInputDirection = keyboardInputLocale.textDirection();
-}
-
-QKeyMapperPrivate::~QKeyMapperPrivate()
-{
-}
-
-QList<int> QKeyMapperPrivate::possibleKeys(QKeyEvent *e)
-{
- QList<int> result = QGuiApplicationPrivate::platformIntegration()->possibleKeys(e);
- if (!result.isEmpty())
- return result;
-
- return extractKeyFromEvent(e);
-}
-
-template <>
-Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QKeyMapper *that, const char *name, int revision)
-{
- Q_UNUSED(that); Q_UNUSED(name); Q_UNUSED(revision);
+ Q_UNUSED(name); Q_UNUSED(revision);
using namespace QNativeInterface::Private;
#if QT_CONFIG(evdev)
@@ -149,3 +88,5 @@ Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(cons
}
QT_END_NAMESPACE
+
+#include "moc_qkeymapper_p.cpp"
diff --git a/src/gui/kernel/qkeymapper_p.h b/src/gui/kernel/qkeymapper_p.h
index 9f061a9eb7..1a6a9a608f 100644
--- a/src/gui/kernel/qkeymapper_p.h
+++ b/src/gui/kernel/qkeymapper_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 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) 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 QKEYMAPPER_P_H
#define QKEYMAPPER_P_H
@@ -61,7 +25,6 @@
QT_BEGIN_NAMESPACE
-class QKeyMapperPrivate;
class Q_GUI_EXPORT QKeyMapper : public QObject
{
Q_OBJECT
@@ -70,40 +33,19 @@ public:
~QKeyMapper();
static QKeyMapper *instance();
- static void changeKeyboard();
- static QList<int> possibleKeys(QKeyEvent *e);
+ static QList<QKeyCombination> possibleKeys(const QKeyEvent *e);
- QT_DECLARE_NATIVE_INTERFACE_ACCESSOR
+ QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QKeyMapper)
private:
- friend QKeyMapperPrivate *qt_keymapper_private();
- Q_DECLARE_PRIVATE(QKeyMapper)
Q_DISABLE_COPY_MOVE(QKeyMapper)
};
-struct KeyboardLayoutItem;
-class QKeyEvent;
-
-class QKeyMapperPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QKeyMapper)
-public:
- QKeyMapperPrivate();
- ~QKeyMapperPrivate();
-
- QList<int> possibleKeys(QKeyEvent *e);
-
- QLocale keyboardInputLocale;
- Qt::LayoutDirection keyboardInputDirection;
-};
-
-QKeyMapperPrivate *qt_keymapper_private(); // from qkeymapper.cpp
-
// ----------------- QNativeInterface -----------------
namespace QNativeInterface::Private {
-#if QT_CONFIG(evdev) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(evdev) || defined(Q_QDOC)
struct Q_GUI_EXPORT QEvdevKeyMapper
{
QT_DECLARE_NATIVE_INTERFACE(QEvdevKeyMapper, 1, QKeyMapper)
diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp
index c10ba93954..0529d940d2 100644
--- a/src/gui/kernel/qkeysequence.cpp
+++ b/src/gui/kernel/qkeysequence.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qkeysequence.h"
#include "qkeysequence_p.h"
@@ -49,30 +13,32 @@
#endif
#include "qvariant.h"
-#if defined(Q_OS_MACOS)
+#if defined(Q_OS_APPLE)
#include <QtCore/private/qcore_mac_p.h>
#endif
#include <algorithm>
+#include <q20algorithm.h>
QT_BEGIN_NAMESPACE
-#if defined(Q_OS_MACOS) || defined(Q_CLANG_QDOC)
-static bool qt_sequence_no_mnemonics = true;
-struct MacSpecialKey {
+using namespace Qt::StringLiterals;
+
+#if defined(Q_OS_APPLE) || defined(Q_QDOC)
+Q_CONSTINIT static bool qt_sequence_no_mnemonics = true;
+struct AppleSpecialKey {
int key;
- ushort macSymbol;
+ ushort appleSymbol;
};
// Unicode code points for the glyphs associated with these keys
// Defined by Carbon headers but not anywhere in Cocoa
-static const int kShiftUnicode = 0x21E7;
-static const int kControlUnicode = 0x2303;
-static const int kOptionUnicode = 0x2325;
-static const int kCommandUnicode = 0x2318;
+static constexpr int kShiftUnicode = 0x21E7;
+static constexpr int kControlUnicode = 0x2303;
+static constexpr int kOptionUnicode = 0x2325;
+static constexpr int kCommandUnicode = 0x2318;
-static const int NumEntries = 21;
-static const MacSpecialKey entries[NumEntries] = {
+static constexpr AppleSpecialKey entries[] = {
{ Qt::Key_Escape, 0x238B },
{ Qt::Key_Tab, 0x21E5 },
{ Qt::Key_Backtab, 0x21E4 },
@@ -80,6 +46,7 @@ static const MacSpecialKey entries[NumEntries] = {
{ Qt::Key_Return, 0x21B5 },
{ Qt::Key_Enter, 0x2324 },
{ Qt::Key_Delete, 0x2326 },
+ { Qt::Key_Clear, 0x2327 },
{ Qt::Key_Home, 0x2196 },
{ Qt::Key_End, 0x2198 },
{ Qt::Key_Left, 0x2190 },
@@ -93,43 +60,48 @@ static const MacSpecialKey entries[NumEntries] = {
{ Qt::Key_Meta, kControlUnicode },
{ Qt::Key_Alt, kOptionUnicode },
{ Qt::Key_CapsLock, 0x21EA },
+ { Qt::Key_Eject, 0x23CF },
};
-static bool operator<(const MacSpecialKey &entry, int key)
+static constexpr bool operator<(const AppleSpecialKey &lhs, const AppleSpecialKey &rhs)
{
- return entry.key < key;
+ return lhs.key < rhs.key;
}
-static bool operator<(int key, const MacSpecialKey &entry)
+static constexpr bool operator<(const AppleSpecialKey &lhs, int rhs)
{
- return key < entry.key;
+ return lhs.key < rhs;
}
-static const MacSpecialKey * const MacSpecialKeyEntriesEnd = entries + NumEntries;
+static constexpr bool operator<(int lhs, const AppleSpecialKey &rhs)
+{
+ return lhs < rhs.key;
+}
-QChar qt_macSymbolForQtKey(int key)
+static_assert(q20::is_sorted(std::begin(entries), std::end(entries)));
+
+static QChar appleSymbolForQtKey(int key)
{
- const MacSpecialKey *i = std::lower_bound(entries, MacSpecialKeyEntriesEnd, key);
- if ((i == MacSpecialKeyEntriesEnd) || (key < *i))
+ const auto i = std::lower_bound(std::begin(entries), std::end(entries), key);
+ if (i == std::end(entries) || key < *i)
return QChar();
- ushort macSymbol = i->macSymbol;
+ ushort appleSymbol = i->appleSymbol;
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
- && (macSymbol == kControlUnicode || macSymbol == kCommandUnicode)) {
- if (macSymbol == kControlUnicode)
- macSymbol = kCommandUnicode;
+ && (appleSymbol == kControlUnicode || appleSymbol == kCommandUnicode)) {
+ if (appleSymbol == kControlUnicode)
+ appleSymbol = kCommandUnicode;
else
- macSymbol = kControlUnicode;
+ appleSymbol = kControlUnicode;
}
- return QChar(macSymbol);
+ return QChar(appleSymbol);
}
-static int qtkeyForMacSymbol(const QChar ch)
+static int qtkeyForAppleSymbol(const QChar ch)
{
const ushort unicode = ch.unicode();
- for (int i = 0; i < NumEntries; ++i) {
- const MacSpecialKey &entry = entries[i];
- if (entry.macSymbol == unicode) {
+ for (const AppleSpecialKey &entry : entries) {
+ if (entry.appleSymbol == unicode) {
int key = entry.key;
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)
&& (unicode == kControlUnicode || unicode == kCommandUnicode)) {
@@ -145,7 +117,7 @@ static int qtkeyForMacSymbol(const QChar ch)
}
#else
-static bool qt_sequence_no_mnemonics = false;
+Q_CONSTINIT static bool qt_sequence_no_mnemonics = false;
#endif
/*!
@@ -192,9 +164,10 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
for users of different languages. Translations are made in the
"QShortcut" context.
\li For hard-coded shortcuts, integer key codes can be specified with
- a combination of values defined by the Qt::Key and Qt::Modifier enum
- values. Each key code consists of a single Qt::Key value and zero or
- more modifiers, such as Qt::SHIFT, Qt::CTRL, Qt::ALT and Qt::META.
+ a combination of values defined by the Qt::Key and Qt::KeyboardModifier
+ enum values. Each key code consists of a single Qt::Key value and zero
+ or more modifiers, such as Qt::ShiftModifier, Qt::ControlModifier,
+ Qt::AltModifier and Qt::MetaModifier.
\endlist
For example, \uicontrol{Ctrl P} might be a sequence used as a shortcut for
@@ -218,7 +191,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
QKeySequence objects can be cast to a QString to obtain a human-readable
translated version of the sequence. Similarly, the toString() function
- produces human-readable strings for use in menus. On \macos, the
+ produces human-readable strings for use in menus. On Apple platforms, the
appropriate symbols are used to describe keyboard shortcuts using special
keys on the Macintosh keyboard.
@@ -226,12 +199,12 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
code point of the character; for example, 'A' gives the same key sequence
as Qt::Key_A.
- \note On \macos, references to "Ctrl", Qt::CTRL, Qt::Key_Control
+ \note On Apple platforms, references to "Ctrl", Qt::CTRL, Qt::Key_Control
and Qt::ControlModifier correspond to the \uicontrol Command keys on the
Macintosh keyboard, and references to "Meta", Qt::META, Qt::Key_Meta and
- Qt::MetaModifier correspond to the \uicontrol Control keys. Developers on
- \macos can use the same shortcut descriptions across all platforms,
- and their applications will automatically work as expected on \macos.
+ Qt::MetaModifier correspond to the \uicontrol Control keys. In effect,
+ developers can use the same shortcut descriptions across all platforms,
+ and their applications will automatically work as expected on Apple platforms.
\section1 Standard Shortcuts
@@ -240,21 +213,21 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
setting up actions in a typical application. The table below shows
some common key sequences that are often used for these standard
shortcuts by applications on four widely-used platforms. Note
- that on \macos, the \uicontrol Ctrl value corresponds to the \uicontrol
+ that on Apple platforms, the \uicontrol Ctrl value corresponds to the \uicontrol
Command keys on the Macintosh keyboard, and the \uicontrol Meta value
corresponds to the \uicontrol Control keys.
\table
- \header \li StandardKey \li Windows \li \macos \li KDE Plasma \li GNOME
+ \header \li StandardKey \li Windows \li Apple platforms \li KDE Plasma \li GNOME
\row \li HelpContents \li F1 \li Ctrl+? \li F1 \li F1
\row \li WhatsThis \li Shift+F1 \li Shift+F1 \li Shift+F1 \li Shift+F1
\row \li Open \li Ctrl+O \li Ctrl+O \li Ctrl+O \li Ctrl+O
\row \li Close \li Ctrl+F4, Ctrl+W \li Ctrl+W, Ctrl+F4 \li Ctrl+W \li Ctrl+W
\row \li Save \li Ctrl+S \li Ctrl+S \li Ctrl+S \li Ctrl+S
\row \li Quit \li \li Ctrl+Q \li Ctrl+Q \li Ctrl+Q
- \row \li SaveAs \li \li Ctrl+Shift+S \li \li Ctrl+Shift+S
+ \row \li SaveAs \li Ctrl+Shift+S \li Ctrl+Shift+S \li Ctrl+Shift+S \li Ctrl+Shift+S
\row \li New \li Ctrl+N \li Ctrl+N \li Ctrl+N \li Ctrl+N
- \row \li Delete \li Del \li Del, Meta+D \li Del, Ctrl+D \li Del, Ctrl+D
+ \row \li Delete \li Del \li Forward Delete, Meta+D \li Del, Ctrl+D \li Del, Ctrl+D
\row \li Cut \li Ctrl+X, Shift+Del \li Ctrl+X, Meta+K \li Ctrl+X, F20, Shift+Del \li Ctrl+X, F20, Shift+Del
\row \li Copy \li Ctrl+C, Ctrl+Ins \li Ctrl+C \li Ctrl+C, F16, Ctrl+Ins \li Ctrl+C, F16, Ctrl+Ins
\row \li Paste \li Ctrl+V, Shift+Ins \li Ctrl+V, Meta+Y \li Ctrl+V, F18, Shift+Ins \li Ctrl+V, F18, Shift+Ins
@@ -314,7 +287,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\row \li DeleteCompleteLine \li (none) \li (none) \li Ctrl+U \li Ctrl+U
\row \li InsertParagraphSeparator \li Enter \li Enter \li Enter \li Enter
\row \li InsertLineSeparator \li Shift+Enter \li Meta+Enter, Meta+O \li Shift+Enter \li Shift+Enter
- \row \li Backspace \li (none) \li Meta+H \li (none) \li (none)
+ \row \li Backspace \li (none) \li Delete, Meta+H \li (none) \li (none)
\row \li Cancel \li Escape \li Escape, Ctrl+. \li Escape \li Escape
\endtable
@@ -401,7 +374,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
\enum QKeySequence::SequenceFormat
\value NativeText The key sequence as a platform specific string.
- This means that it will be shown translated and on the Mac it will
+ This means that it will be shown translated and on Apple platforms it will
resemble a key sequence from the menu bar. This enum is best used when you
want to display the string to the user.
@@ -410,7 +383,7 @@ void Q_GUI_EXPORT qt_set_sequence_auto_mnemonic(bool b) { qt_sequence_no_mnemoni
similar to the native text on Windows and X11.
*/
-static const struct {
+static constexpr struct {
int key;
const char name[25];
} keyname[] = {
@@ -699,6 +672,10 @@ static const struct {
{ Qt::Key_TouchpadToggle, QT_TRANSLATE_NOOP("QShortcut", "Touchpad Toggle") },
{ Qt::Key_TouchpadOn, QT_TRANSLATE_NOOP("QShortcut", "Touchpad On") },
{ Qt::Key_TouchpadOff, QT_TRANSLATE_NOOP("QShortcut", "Touchpad Off") },
+ { Qt::Key_Shift, QT_TRANSLATE_NOOP("QShortcut", "Shift") },
+ { Qt::Key_Control, QT_TRANSLATE_NOOP("QShortcut", "Control") },
+ { Qt::Key_Alt, QT_TRANSLATE_NOOP("QShortcut", "Alt") },
+ { Qt::Key_Meta, QT_TRANSLATE_NOOP("QShortcut", "Meta") },
};
static constexpr int numKeyNames = sizeof keyname / sizeof *keyname;
@@ -733,7 +710,7 @@ static constexpr int numKeyNames = sizeof keyname / sizeof *keyname;
\value InsertLineSeparator Insert a new line.
\value InsertParagraphSeparator Insert a new paragraph.
\value Italic Italic text.
- \value MoveToEndOfBlock Move cursor to end of block. This shortcut is only used on the \macos.
+ \value MoveToEndOfBlock Move cursor to end of block. This shortcut is only used on Apple platforms.
\value MoveToEndOfDocument Move cursor to end of document.
\value MoveToEndOfLine Move cursor to end of line.
\value MoveToNextChar Move cursor to next character.
@@ -744,7 +721,7 @@ static constexpr int numKeyNames = sizeof keyname / sizeof *keyname;
\value MoveToPreviousLine Move cursor to previous line.
\value MoveToPreviousPage Move cursor to previous page.
\value MoveToPreviousWord Move cursor to previous word.
- \value MoveToStartOfBlock Move cursor to start of a block. This shortcut is only used on \macos.
+ \value MoveToStartOfBlock Move cursor to start of a block. This shortcut is only used on Apple platforms.
\value MoveToStartOfDocument Move cursor to start of document.
\value MoveToStartOfLine Move cursor to start of line.
\value New Create new document.
@@ -762,7 +739,7 @@ static constexpr int numKeyNames = sizeof keyname / sizeof *keyname;
\value Save Save document.
\value SelectAll Select all text.
\value Deselect Deselect text. Since 5.1
- \value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on \macos.
+ \value SelectEndOfBlock Extend selection to the end of a text block. This shortcut is only used on Apple platforms.
\value SelectEndOfDocument Extend selection to end of document.
\value SelectEndOfLine Extend selection to end of line.
\value SelectNextChar Extend selection to next character.
@@ -773,7 +750,7 @@ static constexpr int numKeyNames = sizeof keyname / sizeof *keyname;
\value SelectPreviousLine Extend selection to previous line.
\value SelectPreviousPage Extend selection to previous page.
\value SelectPreviousWord Extend selection to previous word.
- \value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on \macos.
+ \value SelectStartOfBlock Extend selection to the start of a text block. This shortcut is only used on Apple platforms.
\value SelectStartOfDocument Extend selection to start of document.
\value SelectStartOfLine Extend selection to start of line.
\value Underline Underline text.
@@ -807,8 +784,8 @@ QKeySequence::QKeySequence(StandardKey key)
{
const QList <QKeySequence> bindings = keyBindings(key);
//pick only the first/primary shortcut from current bindings
- if (bindings.size() > 0) {
- d = bindings.first().d;
+ if (!bindings.isEmpty()) {
+ d = bindings.constFirst().d;
d->ref.ref();
}
else
@@ -821,7 +798,7 @@ QKeySequence::QKeySequence(StandardKey key)
*/
QKeySequence::QKeySequence()
{
- static QKeySequencePrivate shared_empty;
+ Q_CONSTINIT static QKeySequencePrivate shared_empty;
d = &shared_empty;
d->ref.ref();
}
@@ -857,8 +834,8 @@ static_assert(QKeySequencePrivate::MaxKeyCount == 4, "Change docs and ctor impl
\a k3 and \a k4.
The key codes are listed in Qt::Key and can be combined with
- modifiers (see Qt::Modifier) such as Qt::SHIFT, Qt::CTRL,
- Qt::ALT, or Qt::META.
+ modifiers (see Qt::KeyboardModifier) such as Qt::ShiftModifier,
+ Qt::ControlModifier, Qt::AltModifier, or Qt::MetaModifier.
*/
QKeySequence::QKeySequence(int k1, int k2, int k3, int k4)
{
@@ -954,11 +931,6 @@ bool QKeySequence::isEmpty() const
For example, mnemonic("E&xit") returns \c{Qt::ALT+Qt::Key_X},
mnemonic("&Quit") returns \c{ALT+Key_Q}, and mnemonic("Quit")
returns an empty QKeySequence.
-
- We provide a \l{accelerators.html}{list of common mnemonics}
- in English. At the time of writing, Microsoft and Open Group do
- not appear to have issued equivalent recommendations for other
- languages.
*/
QKeySequence QKeySequence::mnemonic(const QString &text)
{
@@ -968,12 +940,12 @@ QKeySequence QKeySequence::mnemonic(const QString &text)
return ret;
bool found = false;
- int p = 0;
+ qsizetype p = 0;
while (p >= 0) {
- p = text.indexOf(QLatin1Char('&'), p) + 1;
- if (p <= 0 || p >= (int)text.length())
+ p = text.indexOf(u'&', p) + 1;
+ if (p <= 0 || p >= (int)text.size())
break;
- if (text.at(p) != QLatin1Char('&')) {
+ if (text.at(p) != u'&') {
QChar c = text.at(p);
if (c.isPrint()) {
if (!found) {
@@ -1021,22 +993,22 @@ int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)
{
QString keyseq = ks;
int n = 0;
- int p = 0, diff = 0;
+ qsizetype p = 0, diff = 0;
// Run through the whole string, but stop
// if we have MaxKeyCount keys before the end.
- while (keyseq.length() && n < QKeySequencePrivate::MaxKeyCount) {
+ while (keyseq.size() && n < QKeySequencePrivate::MaxKeyCount) {
// We MUST use something to separate each sequence, and space
// does not cut it, since some of the key names have space
// in them.. (Let's hope no one translate with a comma in it:)
- p = keyseq.indexOf(QLatin1Char(','));
+ p = keyseq.indexOf(u',');
if (-1 != p) {
- if (p == keyseq.count() - 1) { // Last comma 'Ctrl+,'
+ if (p == keyseq.size() - 1) { // Last comma 'Ctrl+,'
p = -1;
} else {
- if (QLatin1Char(',') == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
+ if (u',' == keyseq.at(p+1)) // e.g. 'Ctrl+,, Shift+,,'
p++;
- if (QLatin1Char(' ') == keyseq.at(p+1)) { // Space after comma
+ if (u' ' == keyseq.at(p+1)) { // Space after comma
diff = 1;
p++;
} else {
@@ -1044,9 +1016,9 @@ int QKeySequence::assign(const QString &ks, QKeySequence::SequenceFormat format)
}
}
}
- QString part = keyseq.left(-1 == p ? keyseq.length() : p - diff);
- keyseq = keyseq.right(-1 == p ? 0 : keyseq.length() - (p + 1));
- d->key[n] = QKeySequencePrivate::decodeString(std::move(part), format);
+ QString part = keyseq.left(-1 == p ? keyseq.size() : p - diff);
+ keyseq = keyseq.right(-1 == p ? 0 : keyseq.size() - (p + 1));
+ d->key[n] = QKeySequencePrivate::decodeString(std::move(part), format).toCombined();
++n;
}
return n;
@@ -1064,15 +1036,7 @@ Q_DECLARE_TYPEINFO(QModifKeyName, Q_RELOCATABLE_TYPE);
Q_GLOBAL_STATIC(QList<QModifKeyName>, globalModifs)
Q_GLOBAL_STATIC(QList<QModifKeyName>, globalPortableModifs)
-/*!
- Constructs a single key from the string \a str.
-*/
-int QKeySequence::decodeString(const QString &str)
-{
- return QKeySequencePrivate::decodeString(str, NativeText);
-}
-
-int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceFormat format)
+QKeyCombination QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceFormat format)
{
Q_ASSERT(!accel.isEmpty());
@@ -1084,7 +1048,7 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
if (nativeText) {
gmodifs = globalModifs();
if (gmodifs->isEmpty()) {
-#if defined(Q_OS_MACOS)
+#if defined(Q_OS_APPLE)
const bool dontSwap = qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta);
if (dontSwap)
*gmodifs << QModifKeyName(Qt::META, QChar(kCommandUnicode));
@@ -1097,36 +1061,36 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
*gmodifs << QModifKeyName(Qt::META, QChar(kControlUnicode));
*gmodifs << QModifKeyName(Qt::SHIFT, QChar(kShiftUnicode));
#endif
- *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
- << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
- << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
- << QModifKeyName(Qt::META, QLatin1String("meta+"))
- << QModifKeyName(Qt::KeypadModifier, QLatin1String("num+"));
+ *gmodifs << QModifKeyName(Qt::CTRL, u"ctrl+"_s)
+ << QModifKeyName(Qt::SHIFT, u"shift+"_s)
+ << QModifKeyName(Qt::ALT, u"alt+"_s)
+ << QModifKeyName(Qt::META, u"meta+"_s)
+ << QModifKeyName(Qt::KeypadModifier, u"num+"_s);
}
} else {
gmodifs = globalPortableModifs();
if (gmodifs->isEmpty()) {
- *gmodifs << QModifKeyName(Qt::CTRL, QLatin1String("ctrl+"))
- << QModifKeyName(Qt::SHIFT, QLatin1String("shift+"))
- << QModifKeyName(Qt::ALT, QLatin1String("alt+"))
- << QModifKeyName(Qt::META, QLatin1String("meta+"))
- << QModifKeyName(Qt::KeypadModifier, QLatin1String("num+"));
+ *gmodifs << QModifKeyName(Qt::CTRL, u"ctrl+"_s)
+ << QModifKeyName(Qt::SHIFT, u"shift+"_s)
+ << QModifKeyName(Qt::ALT, u"alt+"_s)
+ << QModifKeyName(Qt::META, u"meta+"_s)
+ << QModifKeyName(Qt::KeypadModifier, u"num+"_s);
}
}
QList<QModifKeyName> modifs;
if (nativeText) {
- modifs << QModifKeyName(Qt::CTRL, QCoreApplication::translate("QShortcut", "Ctrl").toLower().append(QLatin1Char('+')))
- << QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(QLatin1Char('+')))
- << QModifKeyName(Qt::ALT, QCoreApplication::translate("QShortcut", "Alt").toLower().append(QLatin1Char('+')))
- << QModifKeyName(Qt::META, QCoreApplication::translate("QShortcut", "Meta").toLower().append(QLatin1Char('+')))
- << QModifKeyName(Qt::KeypadModifier, QCoreApplication::translate("QShortcut", "Num").toLower().append(QLatin1Char('+')));
+ modifs << QModifKeyName(Qt::CTRL, QCoreApplication::translate("QShortcut", "Ctrl").toLower().append(u'+'))
+ << QModifKeyName(Qt::SHIFT, QCoreApplication::translate("QShortcut", "Shift").toLower().append(u'+'))
+ << QModifKeyName(Qt::ALT, QCoreApplication::translate("QShortcut", "Alt").toLower().append(u'+'))
+ << QModifKeyName(Qt::META, QCoreApplication::translate("QShortcut", "Meta").toLower().append(u'+'))
+ << QModifKeyName(Qt::KeypadModifier, QCoreApplication::translate("QShortcut", "Num").toLower().append(u'+'));
}
modifs += *gmodifs; // Test non-translated ones last
QString sl = accel;
-#if defined(Q_OS_MACOS)
+#if defined(Q_OS_APPLE)
for (int i = 0; i < modifs.size(); ++i) {
const QModifKeyName &mkf = modifs.at(i);
if (sl.contains(mkf.name)) {
@@ -1139,9 +1103,9 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
return Qt::Key_unknown;
#endif
- int i = 0;
- int lastI = 0;
- while ((i = sl.indexOf(QLatin1Char('+'), i + 1)) != -1) {
+ qsizetype i = 0;
+ qsizetype lastI = 0;
+ while ((i = sl.indexOf(u'+', i + 1)) != -1) {
const QStringView sub = QStringView{sl}.mid(lastI, i - lastI + 1);
// If we get here the shortcuts contains at least one '+'. We break up
// along the following strategy:
@@ -1152,9 +1116,9 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
// except for a single '+' at the end of the string.
// Only '+' can have length 1.
- if (sub.length() == 1) {
+ if (sub.size() == 1) {
// Make sure we only encounter a single '+' at the end of the accel
- if (accel.lastIndexOf(QLatin1Char('+')) != accel.length()-1)
+ if (accel.lastIndexOf(u'+') != accel.size()-1)
return Qt::Key_unknown;
} else {
// Identify the modifier
@@ -1174,15 +1138,15 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
lastI = i + 1;
}
- int p = accel.lastIndexOf(QLatin1Char('+'), accel.length() - 2); // -2 so that Ctrl++ works
+ qsizetype p = accel.lastIndexOf(u'+', accel.size() - 2); // -2 so that Ctrl++ works
QStringView accelRef(accel);
if (p > 0)
accelRef = accelRef.mid(p + 1);
int fnum = 0;
- if (accelRef.length() == 1) {
-#if defined(Q_OS_MACOS)
- int qtKey = qtkeyForMacSymbol(accelRef.at(0));
+ if (accelRef.size() == 1) {
+#if defined(Q_OS_APPLE)
+ int qtKey = qtkeyForAppleSymbol(accelRef.at(0));
if (qtKey != -1) {
ret |= qtKey;
} else
@@ -1190,10 +1154,10 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
{
ret |= accelRef.at(0).toUpper().unicode();
}
- } else if (accelRef.at(0) == QLatin1Char('f') && (fnum = accelRef.mid(1).toInt()) >= 1 && fnum <= 35) {
+ } else if (accelRef.at(0) == u'f' && (fnum = accelRef.mid(1).toInt()) >= 1 && fnum <= 35) {
ret |= Qt::Key_F1 + fnum - 1;
} else {
- // For NativeText, check the traslation table first,
+ // For NativeText, check the translation table first,
// if we don't find anything then try it out with just the untranlated stuff.
// PortableText will only try the untranlated table.
bool found = false;
@@ -1217,17 +1181,7 @@ int QKeySequencePrivate::decodeString(QString accel, QKeySequence::SequenceForma
if (!found)
return Qt::Key_unknown;
}
- return ret;
-}
-
-/*!
- Creates a shortcut string for \a key. For example,
- Qt::CTRL+Qt::Key_O gives "Ctrl+O". The strings, "Ctrl", "Shift", etc. are
- translated (using QObject::tr()) in the "QShortcut" context.
- */
-QString QKeySequence::encodeString(int key)
-{
- return QKeySequencePrivate::encodeString(key, NativeText);
+ return QKeyCombination::fromCombined(ret);
}
static inline void addKey(QString &str, const QString &theKey, QKeySequence::SequenceFormat format)
@@ -1237,34 +1191,38 @@ static inline void addKey(QString &str, const QString &theKey, QKeySequence::Seq
//: Key separator in shortcut string
str += QCoreApplication::translate("QShortcut", "+");
} else {
- str += QLatin1Char('+');
+ str += u'+';
}
}
str += theKey;
}
-QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat format)
+QString QKeySequencePrivate::encodeString(QKeyCombination keyCombination, QKeySequence::SequenceFormat format)
{
bool nativeText = (format == QKeySequence::NativeText);
QString s;
+ const auto key = keyCombination.key();
+
// Handle -1 (Invalid Key) and Qt::Key_unknown gracefully
- if (key == -1 || key == Qt::Key_unknown)
+ if (keyCombination.toCombined() == -1 || key == Qt::Key_unknown)
return s;
-#if defined(Q_OS_MACOS)
+ const auto modifiers = keyCombination.keyboardModifiers();
+
+#if defined(Q_OS_APPLE)
if (nativeText) {
- // On OS X the order (by default) is Meta, Alt, Shift, Control.
+ // On Apple platforms the order (by default) is Meta, Alt, Shift, Control.
// If the AA_MacDontSwapCtrlAndMeta is enabled, then the order
- // is Ctrl, Alt, Shift, Meta. The macSymbolForQtKey does this swap
+ // is Ctrl, Alt, Shift, Meta. The appleSymbolForQtKey helper does this swap
// for us, which means that we have to adjust our order here.
// The upshot is a lot more infrastructure to keep the number of
// if tests down and the code relatively clean.
- static const int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };
- static const int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };
- static const int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };
- static const int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };
+ static constexpr int ModifierOrder[] = { Qt::META, Qt::ALT, Qt::SHIFT, Qt::CTRL, 0 };
+ static constexpr int QtKeyOrder[] = { Qt::Key_Meta, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Control, 0 };
+ static constexpr int DontSwapModifierOrder[] = { Qt::CTRL, Qt::ALT, Qt::SHIFT, Qt::META, 0 };
+ static constexpr int DontSwapQtKeyOrder[] = { Qt::Key_Control, Qt::Key_Alt, Qt::Key_Shift, Qt::Key_Meta, 0 };
const int *modifierOrder;
const int *qtkeyOrder;
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
@@ -1276,33 +1234,33 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
}
for (int i = 0; modifierOrder[i] != 0; ++i) {
- if (key & modifierOrder[i])
- s += qt_macSymbolForQtKey(qtkeyOrder[i]);
+ if (modifiers & modifierOrder[i])
+ s += appleSymbolForQtKey(qtkeyOrder[i]);
}
} else
#endif
{
// On other systems the order is Meta, Control, Alt, Shift
- if ((key & Qt::META) == Qt::META)
+ if (modifiers & Qt::MetaModifier)
s = nativeText ? QCoreApplication::translate("QShortcut", "Meta") : QString::fromLatin1("Meta");
- if ((key & Qt::CTRL) == Qt::CTRL)
+ if (modifiers & Qt::ControlModifier)
addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Ctrl") : QString::fromLatin1("Ctrl"), format);
- if ((key & Qt::ALT) == Qt::ALT)
+ if (modifiers & Qt::AltModifier)
addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Alt") : QString::fromLatin1("Alt"), format);
- if ((key & Qt::SHIFT) == Qt::SHIFT)
+ if (modifiers & Qt::ShiftModifier)
addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Shift") : QString::fromLatin1("Shift"), format);
}
- if ((key & Qt::KeypadModifier) == Qt::KeypadModifier)
+ if (modifiers & Qt::KeypadModifier)
addKey(s, nativeText ? QCoreApplication::translate("QShortcut", "Num") : QString::fromLatin1("Num"), format);
- QString p = keyName(key, format);
+ QString keyName = QKeySequencePrivate::keyName(key, format);
-#if defined(Q_OS_MACOS)
+#if defined(Q_OS_APPLE)
if (nativeText)
- s += p;
+ s += keyName;
else
#endif
- addKey(s, p, format);
+ addKey(s, keyName, format);
return s;
}
@@ -1314,10 +1272,9 @@ QString QKeySequencePrivate::encodeString(int key, QKeySequence::SequenceFormat
This static method is used by encodeString() and by the D-Bus menu exporter.
*/
-QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat format)
+QString QKeySequencePrivate::keyName(Qt::Key key, QKeySequence::SequenceFormat format)
{
bool nativeText = (format == QKeySequence::NativeText);
- key &= ~(Qt::ShiftModifier | Qt::ControlModifier | Qt::AltModifier | Qt::MetaModifier | Qt::KeypadModifier);
QString p;
if (key && key < Qt::Key_Escape && key != Qt::Key_Space) {
@@ -1332,9 +1289,9 @@ QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat forma
: QString::fromLatin1("F%1").arg(key - Qt::Key_F1 + 1);
} else if (key) {
int i=0;
-#if defined(Q_OS_MACOS)
+#if defined(Q_OS_APPLE)
if (nativeText) {
- QChar ch = qt_macSymbolForQtKey(key);
+ QChar ch = appleSymbolForQtKey(key);
if (!ch.isNull())
p = ch;
else
@@ -1342,7 +1299,7 @@ QString QKeySequencePrivate::keyName(int key, QKeySequence::SequenceFormat forma
} else
#endif
{
-#if defined(Q_OS_MACOS)
+#if defined(Q_OS_APPLE)
NonSymbol:
#endif
while (i < numKeyNames) {
@@ -1455,6 +1412,7 @@ bool QKeySequence::operator==(const QKeySequence &other) const
/*!
\since 5.6
+ \relates QKeySequence
Calculates the hash value of \a key, using
\a seed to seed the calculation.
@@ -1531,7 +1489,7 @@ bool QKeySequence::isDetached() const
If the key sequence has no keys, an empty string is returned.
- On \macos, the string returned resembles the sequence that is
+ On Apple platforms, the string returned resembles the sequence that is
shown in the menu bar if \a format is
QKeySequence::NativeText; otherwise, the string uses the
"portable" format, suitable for writing to a file.
@@ -1545,10 +1503,10 @@ QString QKeySequence::toString(SequenceFormat format) const
// look like our latin case on Windows and X11
int end = count();
for (int i = 0; i < end; ++i) {
- finalString += d->encodeString(d->key[i], format);
- finalString += QLatin1String(", ");
+ finalString += d->encodeString(QKeyCombination::fromCombined(d->key[i]), format);
+ finalString += ", "_L1;
}
- finalString.truncate(finalString.length() - 2);
+ finalString.truncate(finalString.size() - 2);
return finalString;
}
@@ -1576,8 +1534,8 @@ QList<QKeySequence> QKeySequence::listFromString(const QString &str, SequenceFor
{
QList<QKeySequence> result;
- const QStringList strings = str.split(QLatin1String("; "));
- result.reserve(strings.count());
+ const QStringList strings = str.split("; "_L1);
+ result.reserve(strings.size());
for (const QString &string : strings) {
result << fromString(string, format);
}
@@ -1599,9 +1557,9 @@ QString QKeySequence::listToString(const QList<QKeySequence> &list, SequenceForm
for (const QKeySequence &sequence : list) {
result += sequence.toString(format);
- result += QLatin1String("; ");
+ result += "; "_L1;
}
- result.truncate(result.length() - 2);
+ result.truncate(result.size() - 2);
return result;
}
@@ -1680,3 +1638,5 @@ QDebug operator<<(QDebug dbg, const QKeySequence &p)
*/
QT_END_NAMESPACE
+
+#include "moc_qkeysequence.cpp"
diff --git a/src/gui/kernel/qkeysequence.h b/src/gui/kernel/qkeysequence.h
index 61001dddbc..4dae26a755 100644
--- a/src/gui/kernel/qkeysequence.h
+++ b/src/gui/kernel/qkeysequence.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QKEYSEQUENCE_H
#define QKEYSEQUENCE_H
@@ -53,12 +17,12 @@ class QKeySequence;
/*****************************************************************************
QKeySequence stream functions
*****************************************************************************/
-#if !defined(QT_NO_DATASTREAM) || defined(Q_CLANG_QDOC)
+#if !defined(QT_NO_DATASTREAM) || defined(Q_QDOC)
Q_GUI_EXPORT QDataStream &operator<<(QDataStream &in, const QKeySequence &ks);
Q_GUI_EXPORT QDataStream &operator>>(QDataStream &out, QKeySequence &ks);
#endif
-#if defined(Q_CLANG_QDOC)
+#if defined(Q_QDOC)
void qt_set_sequence_auto_mnemonic(bool b);
#endif
@@ -151,6 +115,7 @@ public:
NativeText,
PortableText
};
+ Q_ENUM(SequenceFormat)
QKeySequence();
QKeySequence(const QString &key, SequenceFormat format = NativeText);
@@ -171,6 +136,7 @@ public:
PartialMatch,
ExactMatch
};
+ Q_ENUM(SequenceMatch);
QString toString(SequenceFormat format = PortableText) const;
static QKeySequence fromString(const QString &str, SequenceFormat format = PortableText);
@@ -186,7 +152,7 @@ public:
QKeyCombination operator[](uint i) const;
QKeySequence &operator=(const QKeySequence &other);
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QKeySequence)
- void swap(QKeySequence &other) noexcept { qSwap(d, other.d); }
+ void swap(QKeySequence &other) noexcept { qt_ptr_swap(d, other.d); }
bool operator==(const QKeySequence &other) const;
inline bool operator!= (const QKeySequence &other) const
@@ -201,8 +167,6 @@ public:
bool isDetached() const;
private:
- static int decodeString(const QString &ks);
- static QString encodeString(int key);
int assign(const QString &str);
int assign(const QString &str, SequenceFormat format);
void setKey(QKeyCombination key, int index);
@@ -222,7 +186,7 @@ public:
Q_DECLARE_SHARED(QKeySequence)
-#if !defined(QT_NO_DEBUG_STREAM) || defined(Q_CLANG_QDOC)
+#if !defined(QT_NO_DEBUG_STREAM) || defined(Q_QDOC)
Q_GUI_EXPORT QDebug operator<<(QDebug, const QKeySequence &);
#endif
diff --git a/src/gui/kernel/qkeysequence_p.h b/src/gui/kernel/qkeysequence_p.h
index 99d17e98d1..8b98e3778a 100644
--- a/src/gui/kernel/qkeysequence_p.h
+++ b/src/gui/kernel/qkeysequence_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 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) 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 QKEYSEQUENCE_P_H
#define QKEYSEQUENCE_P_H
@@ -71,11 +35,8 @@ struct QKeyBinding
class QKeySequencePrivate
{
public:
- enum { MaxKeyCount = 4 }; // also used in QKeySequenceEdit
- inline QKeySequencePrivate() : ref(1)
- {
- std::fill_n(key, uint(MaxKeyCount), 0);
- }
+ static constexpr int MaxKeyCount = 4 ; // also used in QKeySequenceEdit
+ constexpr QKeySequencePrivate() : ref(1), key{} {}
inline QKeySequencePrivate(const QKeySequencePrivate &copy) : ref(1)
{
std::copy(copy.key, copy.key + MaxKeyCount,
@@ -83,10 +44,10 @@ public:
}
QAtomicInt ref;
int key[MaxKeyCount];
- static QString encodeString(int key, QKeySequence::SequenceFormat format);
+ static QString encodeString(QKeyCombination keyCombination, QKeySequence::SequenceFormat format);
// used in dbusmenu
- Q_GUI_EXPORT static QString keyName(int key, QKeySequence::SequenceFormat format);
- static int decodeString(QString accel, QKeySequence::SequenceFormat format);
+ Q_GUI_EXPORT static QString keyName(Qt::Key key, QKeySequence::SequenceFormat format);
+ static QKeyCombination decodeString(QString accel, QKeySequence::SequenceFormat format);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qoffscreensurface.cpp b/src/gui/kernel/qoffscreensurface.cpp
index 7cb8050504..02e606658a 100644
--- a/src/gui/kernel/qoffscreensurface.cpp
+++ b/src/gui/kernel/qoffscreensurface.cpp
@@ -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
#include "qoffscreensurface.h"
@@ -50,6 +14,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
/*!
\class QOffscreenSurface
\inmodule QtGui
@@ -162,7 +128,7 @@ void QOffscreenSurface::create()
// violate the minimum title bar width on the platform.
d->offscreenWindow->setFlags(d->offscreenWindow->flags()
| Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
- d->offscreenWindow->setObjectName(QLatin1String("QOffscreenSurface"));
+ d->offscreenWindow->setObjectName("QOffscreenSurface"_L1);
// Remove this window from the global list since we do not want it to be destroyed when closing the app.
// The QOffscreenSurface has to be usable even after exiting the event loop.
QGuiApplicationPrivate::window_list.removeOne(d->offscreenWindow);
@@ -203,7 +169,7 @@ void QOffscreenSurface::destroy()
/*!
Returns \c true if this offscreen surface is valid; otherwise returns \c false.
- The offscreen surface is valid if the platform resources have been successfuly allocated.
+ The offscreen surface is valid if the platform resources have been successfully allocated.
\sa create()
*/
@@ -371,19 +337,20 @@ QPlatformSurface *QOffscreenSurface::surfaceHandle() const
using namespace QNativeInterface;
-template <>
-Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QOffscreenSurface *that, const char *name, int revision)
+void *QOffscreenSurface::resolveInterface(const char *name, int revision) const
{
- Q_UNUSED(that); Q_UNUSED(name); Q_UNUSED(revision);
+ Q_UNUSED(name); Q_UNUSED(revision);
- auto *surfacePrivate = QOffscreenSurfacePrivate::get(const_cast<QOffscreenSurface*>(that));
- Q_UNUSED(surfacePrivate);
+ Q_D(const QOffscreenSurface);
+ Q_UNUSED(d);
#if defined(Q_OS_ANDROID)
- QT_NATIVE_INTERFACE_RETURN_IF(QAndroidOffscreenSurface, surfacePrivate->platformOffscreenSurface);
+ QT_NATIVE_INTERFACE_RETURN_IF(QAndroidOffscreenSurface, d->platformOffscreenSurface);
#endif
return nullptr;
}
QT_END_NAMESPACE
+
+#include "moc_qoffscreensurface.cpp"
diff --git a/src/gui/kernel/qoffscreensurface.h b/src/gui/kernel/qoffscreensurface.h
index e63c85cb72..410b6d2b61 100644
--- a/src/gui/kernel/qoffscreensurface.h
+++ b/src/gui/kernel/qoffscreensurface.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 QOFFSCREENSURFACE_H
#define QOFFSCREENSURFACE_H
@@ -44,7 +8,7 @@
#include <QtCore/QObject>
#include <QtCore/qnativeinterface.h>
#include <QtGui/qsurface.h>
-Q_MOC_INCLUDE(<QScreen>)
+Q_MOC_INCLUDE(<QtGui/qscreen.h>)
QT_BEGIN_NAMESPACE
@@ -80,7 +44,7 @@ public:
QPlatformOffscreenSurface *handle() const;
- QT_DECLARE_NATIVE_INTERFACE_ACCESSOR
+ QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QOffscreenSurface)
Q_SIGNALS:
void screenChanged(QScreen *screen);
diff --git a/src/gui/kernel/qoffscreensurface_p.h b/src/gui/kernel/qoffscreensurface_p.h
index 5b41e71c29..3de4b5e17a 100644
--- a/src/gui/kernel/qoffscreensurface_p.h
+++ b/src/gui/kernel/qoffscreensurface_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 QOFFSCREENSURFACE_P_H
#define QOFFSCREENSURFACE_P_H
diff --git a/src/gui/kernel/qoffscreensurface_platform.h b/src/gui/kernel/qoffscreensurface_platform.h
index b6d77491d5..33e72c7e17 100644
--- a/src/gui/kernel/qoffscreensurface_platform.h
+++ b/src/gui/kernel/qoffscreensurface_platform.h
@@ -1,45 +1,18 @@
-/****************************************************************************
-**
-** 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 QOFFSCREENSURFACE_PLATFORM_H
#define QOFFSCREENSURFACE_PLATFORM_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the native interface APIs. Usage of
+// this API may make your code source and binary incompatible
+// with future versions of Qt.
+//
+
#include <QtGui/qtguiglobal.h>
#include <QtGui/qoffscreensurface.h>
#include <QtCore/qnativeinterface.h>
@@ -52,7 +25,7 @@ QT_BEGIN_NAMESPACE
namespace QNativeInterface {
-#if defined(Q_OS_ANDROID) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_ANDROID) || defined(Q_QDOC)
struct Q_GUI_EXPORT QAndroidOffscreenSurface
{
QT_DECLARE_NATIVE_INTERFACE(QAndroidOffscreenSurface, 1, QOffscreenSurface)
diff --git a/src/gui/kernel/qopenglcontext.cpp b/src/gui/kernel/qopenglcontext.cpp
index 8a9cd2b85f..dd41318f72 100644
--- a/src/gui/kernel/qopenglcontext.cpp
+++ b/src/gui/kernel/qopenglcontext.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qpa/qplatformopenglcontext.h>
#include <qpa/qplatformintegration.h>
@@ -78,7 +42,7 @@ static QOpenGLContext *global_share_context = nullptr;
#ifndef QT_NO_DEBUG
QHash<QOpenGLContext *, bool> QOpenGLContextPrivate::makeCurrentTracker;
-QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;
+Q_CONSTINIT QMutex QOpenGLContextPrivate::makeCurrentTrackerMutex;
#endif
/*!
@@ -105,6 +69,7 @@ QOpenGLContext *qt_gl_global_share_context()
/*!
\class QOpenGLContext
+ \ingroup painting-3D
\inmodule QtGui
\since 5.0
\brief The QOpenGLContext class represents a native OpenGL context, enabling
@@ -173,6 +138,22 @@ QOpenGLContext *qt_gl_global_share_context()
application is portable between different platforms. However, if you use
QOpenGLFunctions::glBindFramebuffer(), this is done automatically for you.
+ \warning WebAssembly
+
+ We recommend that only one QOpenGLContext is made current with a QSurface,
+ for the entire lifetime of the QSurface. Should more than once context be used,
+ it is important to understand that multiple QOpenGLContext instances may be
+ backed by the same native context underneath with the WebAssembly platform.
+ Therefore, calling makeCurrent() with the same QSurface on two QOpenGLContext
+ objects may not switch to a different native context in the second call. As
+ a result, any OpenGL state changes done after the second makeCurrent() may
+ alter the state of the first QOpenGLContext as well, as they are all backed
+ by the same native context.
+
+ \note This means that when targeting WebAssembly with existing OpenGL-based
+ Qt code, some porting may be required to cater to these limitations.
+
+
\sa QOpenGLFunctions, QOpenGLBuffer, QOpenGLShaderProgram, QOpenGLFramebufferObject
*/
@@ -189,6 +170,9 @@ QOpenGLContext *QOpenGLContextPrivate::setCurrentContext(QOpenGLContext *context
qWarning("No QTLS available. currentContext won't work");
return nullptr;
}
+ if (!context)
+ return nullptr;
+
threadContext = new QGuiGLThreadContext;
qwindow_context_storage()->setLocalData(threadContext);
}
@@ -396,6 +380,10 @@ bool QOpenGLContext::create()
return isValid();
}
+QOpenGLContextPrivate::~QOpenGLContextPrivate()
+{
+}
+
void QOpenGLContextPrivate::adopt(QPlatformOpenGLContext *context)
{
Q_Q(QOpenGLContext);
@@ -431,30 +419,47 @@ void QOpenGLContextPrivate::adopt(QPlatformOpenGLContext *context)
void QOpenGLContext::destroy()
{
Q_D(QOpenGLContext);
+
+ // Notify that the native context and the QPlatformOpenGLContext are going
+ // to go away.
if (d->platformGLContext)
emit aboutToBeDestroyed();
- if (QOpenGLContext::currentContext() == this)
- doneCurrent();
- if (d->shareGroup)
- d->shareGroup->d_func()->removeContext(this);
- d->shareGroup = nullptr;
- delete d->platformGLContext;
- d->platformGLContext = nullptr;
- delete d->functions;
- d->functions = nullptr;
+ // Invoke callbacks for helpers and invalidate.
if (d->textureFunctionsDestroyCallback) {
d->textureFunctionsDestroyCallback();
d->textureFunctionsDestroyCallback = nullptr;
}
d->textureFunctions = nullptr;
+ delete d->versionFunctions;
+ d->versionFunctions = nullptr;
+
if (d->vaoHelperDestroyCallback) {
Q_ASSERT(d->vaoHelper);
d->vaoHelperDestroyCallback(d->vaoHelper);
d->vaoHelperDestroyCallback = nullptr;
}
d->vaoHelper = nullptr;
+
+ // Tear down function wrappers.
+ delete d->versionFunctions;
+ d->versionFunctions = nullptr;
+
+ delete d->functions;
+ d->functions = nullptr;
+
+ // Clean up and destroy the native context machinery.
+ if (QOpenGLContext::currentContext() == this)
+ doneCurrent();
+
+ if (d->shareGroup)
+ d->shareGroup->d_func()->removeContext(this);
+
+ d->shareGroup = nullptr;
+
+ delete d->platformGLContext;
+ d->platformGLContext = nullptr;
}
/*!
@@ -466,6 +471,11 @@ void QOpenGLContext::destroy()
If you wish to make the context current in order to do clean-up, make sure
to only connect to the signal using a direct connection.
+
+ \note In Qt for Python, this signal will not be received when emitted
+ from the destructor of QOpenGLWidget or QOpenGLWindow due to the Python
+ instance already being destroyed. We recommend doing cleanups
+ in QWidget::hideEvent() instead.
*/
/*!
@@ -709,7 +719,8 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
|| qstrcmp(rendererString, "GC800 core") == 0
|| qstrcmp(rendererString, "GC1000 core") == 0
|| strstr(rendererString, "GC2000") != nullptr
- || qstrcmp(rendererString, "Immersion.16") == 0;
+ || qstrcmp(rendererString, "Immersion.16") == 0
+ || qstrncmp(rendererString, "Apple Mx", 7) == 0;
}
needsWorkaroundSet = true;
}
@@ -1030,6 +1041,9 @@ QOpenGLContextGroup *QOpenGLContextGroup::currentContextGroup()
return current ? current->shareGroup() : nullptr;
}
+QOpenGLContextGroupPrivate::~QOpenGLContextGroupPrivate()
+ = default;
+
void QOpenGLContextGroupPrivate::addContext(QOpenGLContext *ctx)
{
const auto locker = qt_scoped_lock(m_mutex);
@@ -1171,6 +1185,10 @@ void QOpenGLSharedResource::free()
\inmodule QtGui
*/
+
+QOpenGLSharedResourceGuard::~QOpenGLSharedResourceGuard()
+ = default;
+
void QOpenGLSharedResourceGuard::freeResource(QOpenGLContext *context)
{
if (m_id) {
@@ -1270,6 +1288,9 @@ void QOpenGLMultiGroupSharedResource::cleanup(QOpenGLContextGroup *group, QOpenG
m_groups.removeOne(group);
}
+QOpenGLContextVersionFunctionHelper::~QOpenGLContextVersionFunctionHelper()
+ = default;
+
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QOpenGLContext *ctx)
{
@@ -1311,12 +1332,11 @@ QDebug operator<<(QDebug debug, const QOpenGLContextGroup *cg)
using namespace QNativeInterface;
-template <>
-Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QOpenGLContext *that, const char *name, int revision)
+void *QOpenGLContext::resolveInterface(const char *name, int revision) const
{
- Q_UNUSED(that); Q_UNUSED(name); Q_UNUSED(revision);
+ Q_UNUSED(name); Q_UNUSED(revision);
- auto *platformContext = that->handle();
+ auto *platformContext = handle();
Q_UNUSED(platformContext);
#if defined(Q_OS_MACOS)
@@ -1335,6 +1355,6 @@ Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(cons
return nullptr;
}
-#include "moc_qopenglcontext.cpp"
-
QT_END_NAMESPACE
+
+#include "moc_qopenglcontext.cpp"
diff --git a/src/gui/kernel/qopenglcontext.h b/src/gui/kernel/qopenglcontext.h
index 4d8c568ed5..ca2d4a8903 100644
--- a/src/gui/kernel/qopenglcontext.h
+++ b/src/gui/kernel/qopenglcontext.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QOPENGLCONTEXT_H
#define QOPENGLCONTEXT_H
@@ -45,8 +9,9 @@
#ifndef QT_NO_OPENGL
#include <QtCore/qnamespace.h>
-#include <QtCore/QObject>
-#include <QtCore/QScopedPointer>
+#include <QtCore/qobject.h>
+#include <QtCore/qscopedpointer.h>
+#include <QtCore/qset.h>
#include <QtCore/qnativeinterface.h>
#include <QtGui/QSurfaceFormat>
@@ -61,7 +26,6 @@
#include <QtGui/qopengl.h>
#include <QtCore/qvariant.h>
-#include <QtCore/qnativeinterface.h>
QT_BEGIN_NAMESPACE
@@ -154,7 +118,7 @@ public:
static bool supportsThreadedOpenGL();
static QOpenGLContext *globalShareContext();
- QT_DECLARE_NATIVE_INTERFACE_ACCESSOR
+ QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QOpenGLContext)
Q_SIGNALS:
void aboutToBeDestroyed();
diff --git a/src/gui/kernel/qopenglcontext_p.h b/src/gui/kernel/qopenglcontext_p.h
index 7bba323120..a0e8eda679 100644
--- a/src/gui/kernel/qopenglcontext_p.h
+++ b/src/gui/kernel/qopenglcontext_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 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) 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 QOPENGLCONTEXT_P_H
#define QOPENGLCONTEXT_P_H
@@ -110,6 +74,7 @@ public:
, m_func(func)
{
}
+ ~QOpenGLSharedResourceGuard() override;
GLuint id() const { return m_id; }
@@ -135,6 +100,7 @@ public:
, m_refs(0)
{
}
+ ~QOpenGLContextGroupPrivate() override;
void addContext(QOpenGLContext *ctx);
void removeContext(QOpenGLContext *ctx);
@@ -196,7 +162,7 @@ class QOpenGLVertexArrayObjectHelper;
class Q_GUI_EXPORT QOpenGLContextVersionFunctionHelper
{
public:
- virtual ~QOpenGLContextVersionFunctionHelper() {}
+ virtual ~QOpenGLContextVersionFunctionHelper();
};
class Q_GUI_EXPORT QOpenGLContextPrivate : public QObjectPrivate
@@ -226,13 +192,7 @@ public:
requestedFormat = QSurfaceFormat::defaultFormat();
}
- ~QOpenGLContextPrivate()
- {
- //do not delete the QOpenGLContext handle here as it is deleted in
- //QWidgetPrivate::deleteTLSysExtra()
-
- delete versionFunctions;
- }
+ ~QOpenGLContextPrivate() override;
void adopt(QPlatformOpenGLContext *);
diff --git a/src/gui/kernel/qopenglcontext_platform.h b/src/gui/kernel/qopenglcontext_platform.h
index 7627e34c20..1f84cf6ce3 100644
--- a/src/gui/kernel/qopenglcontext_platform.h
+++ b/src/gui/kernel/qopenglcontext_platform.h
@@ -1,45 +1,18 @@
-/****************************************************************************
-**
-** 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 QOPENGLCONTEXT_PLATFORM_H
#define QOPENGLCONTEXT_PLATFORM_H
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the native interface APIs. Usage of
+// this API may make your code source and binary incompatible
+// with future versions of Qt.
+//
+
#ifndef QT_NO_OPENGL
#include <QtGui/qtguiglobal.h>
@@ -58,9 +31,10 @@ struct __GLXcontextRec; typedef struct __GLXcontextRec *GLXContext;
#if QT_CONFIG(egl)
typedef void *EGLContext;
typedef void *EGLDisplay;
+typedef void *EGLConfig;
#endif
-#if !defined(Q_OS_MACOS) && defined(Q_CLANG_QDOC)
+#if !defined(Q_OS_MACOS) && defined(Q_QDOC)
typedef void *NSOpenGLContext;
#endif
@@ -68,7 +42,7 @@ QT_BEGIN_NAMESPACE
namespace QNativeInterface {
-#if defined(Q_OS_MACOS) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_MACOS) || defined(Q_QDOC)
struct Q_GUI_EXPORT QCocoaGLContext
{
QT_DECLARE_NATIVE_INTERFACE(QCocoaGLContext, 1, QOpenGLContext)
@@ -77,7 +51,7 @@ struct Q_GUI_EXPORT QCocoaGLContext
};
#endif
-#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_WIN) || defined(Q_QDOC)
struct Q_GUI_EXPORT QWGLContext
{
QT_DECLARE_NATIVE_INTERFACE(QWGLContext, 1, QOpenGLContext)
@@ -87,7 +61,7 @@ struct Q_GUI_EXPORT QWGLContext
};
#endif
-#if QT_CONFIG(xcb_glx_plugin) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(xcb_glx_plugin) || defined(Q_QDOC)
struct Q_GUI_EXPORT QGLXContext
{
QT_DECLARE_NATIVE_INTERFACE(QGLXContext, 1, QOpenGLContext)
@@ -97,12 +71,16 @@ struct Q_GUI_EXPORT QGLXContext
};
#endif
-#if QT_CONFIG(egl) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(egl) || defined(Q_QDOC)
struct Q_GUI_EXPORT QEGLContext
{
QT_DECLARE_NATIVE_INTERFACE(QEGLContext, 1, QOpenGLContext)
static QOpenGLContext *fromNative(EGLContext context, EGLDisplay display, QOpenGLContext *shareContext = nullptr);
virtual EGLContext nativeContext() const = 0;
+ virtual EGLConfig config() const = 0;
+ virtual EGLDisplay display() const = 0;
+
+ virtual void invalidateContext() = 0;
};
#endif
diff --git a/src/gui/kernel/qpaintdevicewindow.cpp b/src/gui/kernel/qpaintdevicewindow.cpp
index ebacc727f9..9e8c6ae5a8 100644
--- a/src/gui/kernel/qpaintdevicewindow.cpp
+++ b/src/gui/kernel/qpaintdevicewindow.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qpaintdevicewindow_p.h"
@@ -44,6 +8,12 @@
QT_BEGIN_NAMESPACE
+QPaintDeviceWindowPrivate::QPaintDeviceWindowPrivate()
+ = default;
+
+QPaintDeviceWindowPrivate::~QPaintDeviceWindowPrivate()
+ = default;
+
/*!
\class QPaintDeviceWindow
\inmodule QtGui
@@ -201,6 +171,8 @@ bool QPaintDeviceWindow::event(QEvent *event)
auto region = QRect(QPoint(0, 0), size());
d->doFlush(region); // Will end up calling paintEvent
return true;
+ } else if (event->type() == QEvent::Resize) {
+ d->handleResizeEvent();
}
return QWindow::event(event);
@@ -223,3 +195,5 @@ QPaintEngine *QPaintDeviceWindow::paintEngine() const
}
QT_END_NAMESPACE
+
+#include "moc_qpaintdevicewindow.cpp"
diff --git a/src/gui/kernel/qpaintdevicewindow.h b/src/gui/kernel/qpaintdevicewindow.h
index 69e56ea842..d6b70298a6 100644
--- a/src/gui/kernel/qpaintdevicewindow.h
+++ b/src/gui/kernel/qpaintdevicewindow.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPAINTDEVICEWINDOW_H
#define QPAINTDEVICEWINDOW_H
diff --git a/src/gui/kernel/qpaintdevicewindow_p.h b/src/gui/kernel/qpaintdevicewindow_p.h
index a16b83689e..85c11cbf91 100644
--- a/src/gui/kernel/qpaintdevicewindow_p.h
+++ b/src/gui/kernel/qpaintdevicewindow_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 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) 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 QPAINTDEVICEWINDOW_P_H
#define QPAINTDEVICEWINDOW_P_H
@@ -64,6 +28,11 @@ class Q_GUI_EXPORT QPaintDeviceWindowPrivate : public QWindowPrivate
Q_DECLARE_PUBLIC(QPaintDeviceWindow)
public:
+ QPaintDeviceWindowPrivate();
+ ~QPaintDeviceWindowPrivate() override;
+
+ virtual void handleResizeEvent() {}
+
virtual void beginPaint(const QRegion &region)
{
Q_UNUSED(region);
@@ -115,7 +84,7 @@ public:
void markWindowAsDirty()
{
Q_Q(QPaintDeviceWindow);
- dirtyRegion += QRect(QPoint(0, 0), q->size());
+ dirtyRegion = QRect(QPoint(0, 0), q->size());
}
private:
diff --git a/src/gui/kernel/qpalette.cpp b/src/gui/kernel/qpalette.cpp
index b313d545a5..256ea52f01 100644
--- a/src/gui/kernel/qpalette.cpp
+++ b/src/gui/kernel/qpalette.cpp
@@ -1,44 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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$
-**
-****************************************************************************/
-
-#include "qpalette.h"
-#include "qguiapplication.h"
+// 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 "qpalette_p.h"
#include "qguiapplication_p.h"
#include "qdatastream.h"
#include "qvariant.h"
@@ -48,39 +11,61 @@
QT_BEGIN_NAMESPACE
-static int qt_palette_count = 1;
+static_assert(QPalettePrivate::bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1),
+ QPalette::ColorRole(QPalette::NColorRoles - 1))
+ < sizeof(QPalette::ResolveMask) * CHAR_BIT,
+ "The resolve mask type is not wide enough to fit the entire bit mask.");
-static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
+static QColor qt_mix_colors(QColor a, QColor b)
{
- return qToUnderlying(QPalette::NColorRoles) * qToUnderlying(colorGroup);
+ return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
+ (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
}
-static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup,
- QPalette::ColorRole colorRole)
-{
- return colorRole + colorRoleOffset(colorGroup);
-}
+/*!
+ \internal
-static_assert(bitPosition(QPalette::ColorGroup(QPalette::NColorGroups - 1),
- QPalette::ColorRole(QPalette::NColorRoles - 1))
- < sizeof(QPalette::ResolveMask) * CHAR_BIT,
- "The resolve mask type is not wide enough to fit the entire bit mask.");
+ Derive undefined \l PlaceholderText colors from \l Text colors.
+ Unless already set, PlaceholderText colors will be derived from their Text pendents.
+ Colors of existing PlaceHolderText brushes will not be replaced.
-class QPalettePrivate
+ \a alpha represents the dim factor as a percentage. By default, a PlaceHolderText color
+ becomes a 50% more transparent version of the corresponding Text color.
+*/
+static void qt_placeholder_from_text(QPalette &pal, int alpha = 50)
{
-public:
- QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { }
- QAtomicInt ref;
- QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
- QPalette::ResolveMask resolveMask = {0};
- int ser_no;
- int detach_no;
-};
+ if (alpha < 0 or alpha > 100)
+ return;
-static QColor qt_mix_colors(QColor a, QColor b)
+ for (int cg = 0; cg < int(QPalette::NColorGroups); ++cg) {
+ const QPalette::ColorGroup group = QPalette::ColorGroup(cg);
+
+ // skip if the brush has been set already
+ if (!pal.isBrushSet(group, QPalette::PlaceholderText)) {
+ QColor c = pal.color(group, QPalette::Text);
+ const int a = (c.alpha() * alpha) / 100;
+ c.setAlpha(a);
+ pal.setColor(group, QPalette::PlaceholderText, c);
+ }
+ }
+}
+
+static void qt_ensure_default_accent_color(QPalette &pal)
{
- return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
- (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
+ // have a lighter/darker factor handy, depending on dark/light heuristics
+ const int lighter = pal.base().color().lightness() > pal.text().color().lightness() ? 130 : 70;
+
+ // Act only for color groups where no accent color is set
+ for (int i = 0; i < QPalette::NColorGroups; ++i) {
+ const QPalette::ColorGroup group = static_cast<QPalette::ColorGroup>(i);
+ if (!pal.isBrushSet(group, QPalette::Accent)) {
+ // Default to highlight if available, otherwise use a shade of base
+ const QBrush accentBrush = pal.isBrushSet(group, QPalette::Highlight)
+ ? pal.brush(group, QPalette::Highlight)
+ : pal.brush(group, QPalette::Base).color().lighter(lighter);
+ pal.setBrush(group, QPalette::Accent, accentBrush);
+ }
+ }
}
static void qt_palette_from_color(QPalette &pal, const QColor &button)
@@ -105,6 +90,9 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button)
pal.setColorGroup(QPalette::Disabled, buttonBrushDark, buttonBrush, buttonBrushLight150,
buttonBrushDark, buttonBrushDark150, buttonBrushDark,
whiteBrush, buttonBrush, buttonBrush);
+
+ qt_placeholder_from_text(pal);
+ qt_ensure_default_accent_color(pal);
}
/*!
@@ -306,6 +294,15 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button)
*/
/*!
+ \fn const QBrush & QPalette::accent() const
+ \since 6.6
+
+ Returns the accent brush of the current color group.
+
+ \sa ColorRole, brush()
+*/
+
+/*!
\fn const QBrush & QPalette::link() const
Returns the unvisited link text brush of the current color group.
@@ -505,6 +502,13 @@ static void qt_palette_from_color(QPalette &pal, const QColor &button)
item. By default, the highlight color is
Qt::darkBlue.
+ \value [since 6.6] Accent
+ A color that typically contrasts or complements
+ Base, Window and Button colors. It usually represents
+ the users' choice of desktop personalisation.
+ Styling of interactive components is a typical use case.
+ Unless explicitly set, it defaults to Highlight.
+
\value HighlightedText A text color that contrasts with \c Highlight.
By default, the highlighted text color is Qt::white.
@@ -592,6 +596,9 @@ QPalette::QPalette(const QBrush &windowText, const QBrush &button,
init();
setColorGroup(All, windowText, button, light, dark, mid, text, bright_text,
base, window);
+
+ qt_placeholder_from_text(*this);
+ qt_ensure_default_accent_color(*this);
}
@@ -647,6 +654,9 @@ QPalette::QPalette(const QColor &button, const QColor &window)
setColorGroup(Disabled, disabledForeground, buttonBrush, buttonBrushLight150,
buttonBrushDark, buttonBrushDark150, disabledForeground,
whiteBrush, baseBrush, windowBrush);
+
+ qt_placeholder_from_text(*this);
+ qt_ensure_default_accent_color(*this);
}
/*!
@@ -746,7 +756,7 @@ const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const
gr = Active;
}
}
- return d->br[gr][cr];
+ return d->data->br[gr][cr];
}
/*!
@@ -784,12 +794,18 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
cg = Active;
}
- if (d->br[cg][cr] != b) {
+ const auto newResolveMask = d->resolveMask | ResolveMask(1) << QPalettePrivate::bitPosition(cg, cr);
+ const auto valueChanged = d->data->br[cg][cr] != b;
+
+ if (valueChanged) {
+ detach();
+ d->data.detach();
+ d->data->br[cg][cr] = b;
+ } else if (d->resolveMask != newResolveMask) {
detach();
- d->br[cg][cr] = b;
}
- d->resolveMask |= ResolveMask(1) << bitPosition(cg, cr);
+ d->resolveMask = newResolveMask;
}
/*!
@@ -808,6 +824,10 @@ void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b)
*/
bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
{
+ // NoRole has no resolve mask and should never be set anyway
+ if (cr == NoRole)
+ return false;
+
if (cg == Current)
cg = currentGroup;
@@ -821,7 +841,7 @@ bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
return false;
}
- return d->resolveMask & (ResolveMask(1) << bitPosition(cg, cr));
+ return d->resolveMask & (ResolveMask(1) << QPalettePrivate::bitPosition(cg, cr));
}
/*!
@@ -830,17 +850,14 @@ bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const
void QPalette::detach()
{
if (d->ref.loadRelaxed() != 1) {
- QPalettePrivate *x = new QPalettePrivate;
- for(int grp = 0; grp < (int)NColorGroups; grp++) {
- for(int role = 0; role < (int)NColorRoles; role++)
- x->br[grp][role] = d->br[grp][role];
- }
+ QPalettePrivate *x = new QPalettePrivate(d->data);
x->resolveMask = d->resolveMask;
if (!d->ref.deref())
delete d;
d = x;
+ } else {
+ d->detach_no = ++QPalettePrivate::qt_palette_private_count;
}
- ++d->detach_no;
}
/*!
@@ -859,18 +876,24 @@ void QPalette::detach()
Returns \c true (usually quickly) if this palette is equal to \a p;
otherwise returns \c false (slowly).
- \note The current ColorGroup is not taken into account when
- comparing palettes
+ \note The following is not taken into account when comparing palettes:
+ \list
+ \li the \c current ColorGroup
+ \li ColorRole NoRole \since 6.6
+ \endlist
\sa operator!=()
*/
bool QPalette::operator==(const QPalette &p) const
{
- if (isCopyOf(p))
+ if (isCopyOf(p) || d->data == p.d->data)
return true;
for(int grp = 0; grp < (int)NColorGroups; grp++) {
for(int role = 0; role < (int)NColorRoles; role++) {
- if (d->br[grp][role] != p.d->br[grp][role])
+ // Dont't verify NoRole, because it has no resolve bit
+ if (role == NoRole)
+ continue;
+ if (d->data->br[grp][role] != p.d->data->br[grp][role])
return false;
}
}
@@ -904,7 +927,7 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2)
if (group1 == group2)
return true;
for(int role = 0; role < (int)NColorRoles; role++) {
- if (d->br[group1][role] != d->br[group2][role])
+ if (d->data->br[group1][role] != d->data->br[group2][role])
return false;
}
return true;
@@ -919,7 +942,18 @@ bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2)
*/
qint64 QPalette::cacheKey() const
{
- return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no));
+ return (((qint64) d->data->ser_no) << 32) | ((qint64) (d->detach_no));
+}
+
+static constexpr QPalette::ResolveMask allResolveMask()
+{
+ QPalette::ResolveMask mask = {0};
+ for (int role = 0; role < int(QPalette::NColorRoles); ++role) {
+ for (int grp = 0; grp < int(QPalette::NColorGroups); ++grp) {
+ mask |= (QPalette::ResolveMask(1) << QPalettePrivate::bitPosition(QPalette::ColorGroup(grp), QPalette::ColorRole(role)));
+ }
+ }
+ return mask;
}
/*!
@@ -931,17 +965,25 @@ QPalette QPalette::resolve(const QPalette &other) const
if ((*this == other && d->resolveMask == other.d->resolveMask)
|| d->resolveMask == 0) {
QPalette o = other;
- o.d->resolveMask = d->resolveMask;
+ o.setResolveMask(d->resolveMask);
return o;
}
+ if (d->resolveMask == allResolveMask())
+ return *this;
+
QPalette palette(*this);
palette.detach();
for (int role = 0; role < int(NColorRoles); ++role) {
+ // Don't resolve NoRole, its bits are needed for Accent (see bitPosition)
+ if (role == NoRole)
+ continue;
+
for (int grp = 0; grp < int(NColorGroups); ++grp) {
- if (!(d->resolveMask & (ResolveMask(1) << bitPosition(ColorGroup(grp), ColorRole(role))))) {
- palette.d->br[grp][role] = other.d->br[grp][role];
+ if (!(d->resolveMask & (ResolveMask(1) << QPalettePrivate::bitPosition(ColorGroup(grp), ColorRole(role))))) {
+ palette.d->data.detach();
+ palette.d->data->br[grp][role] = other.d->data->br[grp][role];
}
}
}
@@ -1004,7 +1046,7 @@ QDataStream &operator<<(QDataStream &s, const QPalette &p)
if (s.version() == 1) {
// Qt 1.x
for (int i = 0; i < NumOldRoles; ++i)
- s << p.d->br[grp][oldRoles[i]].color();
+ s << p.d->data->br[grp][oldRoles[i]].color();
} else {
int max = (int)QPalette::NColorRoles;
if (s.version() <= QDataStream::Qt_2_1)
@@ -1013,8 +1055,11 @@ QDataStream &operator<<(QDataStream &s, const QPalette &p)
max = QPalette::AlternateBase + 1;
else if (s.version() <= QDataStream::Qt_5_11)
max = QPalette::ToolTipText + 1;
+ else if (s.version() <= QDataStream::Qt_6_5)
+ max = QPalette::PlaceholderText + 1;
+
for (int r = 0; r < max; r++)
- s << p.d->br[grp][r];
+ s << p.d->data->br[grp][r];
}
}
return s;
@@ -1056,15 +1101,25 @@ QDataStream &operator>>(QDataStream &s, QPalette &p)
} else if (s.version() <= QDataStream::Qt_5_11) {
p = QPalette();
max = QPalette::ToolTipText + 1;
+ } else if (s.version() <= QDataStream::Qt_6_5) {
+ p = QPalette();
+ max = QPalette::PlaceholderText + 1;
}
+
QBrush tmp;
for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) {
+ const QPalette::ColorGroup group = static_cast<QPalette::ColorGroup>(grp);
for(int role = 0; role < max; ++role) {
s >> tmp;
- p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp);
+ p.setBrush(group, (QPalette::ColorRole)role, tmp);
}
+
+ // Accent defaults to Highlight for stream versions that don't have it.
+ if (s.version() < QDataStream::Qt_6_6)
+ p.setBrush(group, QPalette::Accent, p.brush(group, QPalette::Highlight));
}
+
}
return s;
}
@@ -1111,10 +1166,10 @@ void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBru
for (int cr = Highlight; cr <= LinkVisited; ++cr) {
if (cg == All) {
for (int group = Active; group < NColorGroups; ++group) {
- d->resolveMask &= ~(ResolveMask(1) << bitPosition(ColorGroup(group), ColorRole(cr)));
+ d->resolveMask &= ~(ResolveMask(1) << QPalettePrivate::bitPosition(ColorGroup(group), ColorRole(cr)));
}
} else {
- d->resolveMask &= ~(ResolveMask(1) << bitPosition(ColorGroup(cg), ColorRole(cr)));
+ d->resolveMask &= ~(ResolveMask(1) << QPalettePrivate::bitPosition(ColorGroup(cg), ColorRole(cr)));
}
}
}
@@ -1169,47 +1224,6 @@ void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBru
setBrush(cg, ToolTipText, toolTipText);
}
-Q_GUI_EXPORT QPalette qt_fusionPalette()
-{
- QColor backGround(239, 239, 239);
- QColor light = backGround.lighter(150);
- QColor mid(backGround.darker(130));
- QColor midLight = mid.lighter(110);
- QColor base = Qt::white;
- QColor disabledBase(backGround);
- QColor dark = backGround.darker(150);
- QColor darkDisabled = QColor(209, 209, 209).darker(110);
- QColor text = Qt::black;
- QColor hightlightedText = Qt::white;
- QColor disabledText = QColor(190, 190, 190);
- QColor button = backGround;
- QColor shadow = dark.darker(135);
- QColor disabledShadow = shadow.lighter(150);
- QColor placeholder = text;
- placeholder.setAlpha(128);
-
- QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base);
- fusionPalette.setBrush(QPalette::Midlight, midLight);
- fusionPalette.setBrush(QPalette::Button, button);
- fusionPalette.setBrush(QPalette::Shadow, shadow);
- fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
-
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
- fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
- fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
-
- fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198));
- fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198));
- fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 145, 145));
-
- fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
-
- return fusionPalette;
-}
-
#ifndef QT_NO_DEBUG_STREAM
static QString groupsToString(const QPalette &p, QPalette::ColorRole cr)
{
@@ -1221,8 +1235,8 @@ static QString groupsToString(const QPalette &p, QPalette::ColorRole cr)
if (p.isBrushSet(cg, cr)) {
const auto &color = p.color(cg, cr);
- groupString += QString::fromUtf8(groupEnum.valueToKey(cg)) + QLatin1Char(':') +
- color.name(QColor::HexArgb) + QLatin1Char(',');
+ groupString += QString::fromUtf8(groupEnum.valueToKey(cg)) + u':' +
+ color.name(QColor::HexArgb) + u',';
}
}
groupString.chop(1);
@@ -1266,3 +1280,5 @@ QDebug operator<<(QDebug dbg, const QPalette &p)
#endif
QT_END_NAMESPACE
+
+#include "moc_qpalette.cpp"
diff --git a/src/gui/kernel/qpalette.h b/src/gui/kernel/qpalette.h
index 776d489d44..a6162e1090 100644
--- a/src/gui/kernel/qpalette.h
+++ b/src/gui/kernel/qpalette.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPALETTE_H
#define QPALETTE_H
@@ -68,19 +32,20 @@ public:
~QPalette();
QPalette &operator=(const QPalette &palette);
QPalette(QPalette &&other) noexcept
- : d(qExchange(other.d, nullptr)), currentGroup(other.currentGroup)
+ : d(std::exchange(other.d, nullptr)), currentGroup(other.currentGroup)
{}
QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QPalette)
void swap(QPalette &other) noexcept
{
- qSwap(currentGroup, other.currentGroup);
- qSwap(d, other.d);
+ std::swap(currentGroup, other.currentGroup);
+ qt_ptr_swap(d, other.d);
}
operator QVariant() const;
// Do not change the order, the serialization format depends on it
+ // Ensure these values are kept in sync with QQuickColorGroup's properties.
enum ColorGroup { Active, Disabled, Inactive, NColorGroups, Current, All, Normal = Active };
Q_ENUM(ColorGroup)
enum ColorRole { WindowText, Button, Light, Midlight, Dark, Mid,
@@ -91,7 +56,8 @@ public:
NoRole,
ToolTipBase, ToolTipText,
PlaceholderText,
- NColorRoles = PlaceholderText + 1,
+ Accent,
+ NColorRoles = Accent + 1,
};
Q_ENUM(ColorRole)
@@ -134,6 +100,7 @@ public:
inline const QBrush &link() const { return brush(Link); }
inline const QBrush &linkVisited() const { return brush(LinkVisited); }
inline const QBrush &placeholderText() const { return brush(PlaceholderText); }
+ inline const QBrush &accent() const { return brush(Accent); }
bool operator==(const QPalette &p) const;
inline bool operator!=(const QPalette &p) const { return !(operator==(p)); }
diff --git a/src/gui/kernel/qpalette_p.h b/src/gui/kernel/qpalette_p.h
new file mode 100644
index 0000000000..ce7c30d66d
--- /dev/null
+++ b/src/gui/kernel/qpalette_p.h
@@ -0,0 +1,77 @@
+// Copyright (C) 2023 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 QPALETTE_P_H
+#define QPALETTE_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qpalette.h"
+
+QT_BEGIN_NAMESPACE
+
+class Q_GUI_EXPORT QPalettePrivate
+{
+public:
+ class Data : public QSharedData {
+ public:
+ // Every instance of Data has to have a unique serial number, even
+ // if it gets created by copying another - we wouldn't create a copy
+ // in the first place if the serial number should be the same!
+ Data(const Data &other)
+ : QSharedData(other)
+ {
+ for (int grp = 0; grp < int(QPalette::NColorGroups); grp++) {
+ for (int role = 0; role < int(QPalette::NColorRoles); role++)
+ br[grp][role] = other.br[grp][role];
+ }
+ }
+ Data() = default;
+
+ QBrush br[QPalette::NColorGroups][QPalette::NColorRoles];
+ const int ser_no = qt_palette_count++;
+ };
+
+ QPalettePrivate(const QExplicitlySharedDataPointer<Data> &data)
+ : ref(1), data(data)
+ { }
+ QPalettePrivate()
+ : QPalettePrivate(QExplicitlySharedDataPointer<Data>(new Data))
+ { }
+
+ static constexpr QPalette::ResolveMask colorRoleOffset(QPalette::ColorGroup colorGroup)
+ {
+ // Exclude NoRole; that bit is used for Accent
+ return (qToUnderlying(QPalette::NColorRoles) - 1) * qToUnderlying(colorGroup);
+ }
+
+ static constexpr QPalette::ResolveMask bitPosition(QPalette::ColorGroup colorGroup,
+ QPalette::ColorRole colorRole)
+ {
+ // Map Accent into NoRole for resolving purposes
+ if (colorRole == QPalette::Accent)
+ colorRole = QPalette::NoRole;
+
+ return colorRole + colorRoleOffset(colorGroup);
+ }
+
+ QAtomicInt ref;
+ QPalette::ResolveMask resolveMask = {0};
+ static inline int qt_palette_count = 0;
+ static inline int qt_palette_private_count = 0;
+ int detach_no = ++qt_palette_private_count;
+ QExplicitlySharedDataPointer<Data> data;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPALETTE_P_H
diff --git a/src/gui/kernel/qpixelformat.cpp b/src/gui/kernel/qpixelformat.cpp
index 7a47dd472c..e05192f0b2 100644
--- a/src/gui/kernel/qpixelformat.cpp
+++ b/src/gui/kernel/qpixelformat.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qpixelformat.h"
@@ -186,7 +150,7 @@ QT_BEGIN_NAMESPACE
\enum QPixelFormat::YUVLayout
YUV is not represented by describing the size of the color channels. This is
- because YUV often use macro pixels, making the concept of sperate color channels
+ because YUV often use macro pixels, making the concept of separate color channels
invalid. Instead the different YUV layouts are described with this enum.
\value YUV444
diff --git a/src/gui/kernel/qpixelformat.h b/src/gui/kernel/qpixelformat.h
index 2fee7c1a9a..4954a6cd94 100644
--- a/src/gui/kernel/qpixelformat.h
+++ b/src/gui/kernel/qpixelformat.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPIXELFORMAT_H
#define QPIXELFORMAT_H
diff --git a/src/gui/kernel/qplatformclipboard.cpp b/src/gui/kernel/qplatformclipboard.cpp
index 34c94dca3b..7321b5065d 100644
--- a/src/gui/kernel/qplatformclipboard.cpp
+++ b/src/gui/kernel/qplatformclipboard.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformclipboard.h"
#ifndef QT_NO_CLIPBOARD
diff --git a/src/gui/kernel/qplatformclipboard.h b/src/gui/kernel/qplatformclipboard.h
index 3220201720..51b7c51abd 100644
--- a/src/gui/kernel/qplatformclipboard.h
+++ b/src/gui/kernel/qplatformclipboard.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMCLIPBOARD_H
#define QPLATFORMCLIPBOARD_H
diff --git a/src/gui/kernel/qplatformcursor.cpp b/src/gui/kernel/qplatformcursor.cpp
index 1330b5bf31..0e2fb9eba1 100644
--- a/src/gui/kernel/qplatformcursor.cpp
+++ b/src/gui/kernel/qplatformcursor.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformcursor.h"
#include <QPainter>
@@ -619,7 +583,7 @@ void QPlatformCursorImage::set(const uchar *data, const uchar *mask,
int p = 0;
int d, m;
- int x = -1, w = 0;
+ int x = -1;
uchar *cursor_data = cursorImage.bits();
qsizetype bpl = cursorImage.bytesPerLine();
@@ -641,15 +605,11 @@ void QPlatformCursorImage::set(const uchar *data, const uchar *mask,
x = j*8+b;
else if (x >= 0 && !m) {
x = -1;
- w = 0;
}
- if (m)
- w++;
}
}
if (x >= 0) {
x = -1;
- w = 0;
}
cursor_data += bpl;
}
diff --git a/src/gui/kernel/qplatformcursor.h b/src/gui/kernel/qplatformcursor.h
index f3871d8780..56216d475b 100644
--- a/src/gui/kernel/qplatformcursor.h
+++ b/src/gui/kernel/qplatformcursor.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMCURSOR_H
#define QPLATFORMCURSOR_H
diff --git a/src/gui/kernel/qplatformdialoghelper.cpp b/src/gui/kernel/qplatformdialoghelper.cpp
index 82b60b7749..93de7933d4 100644
--- a/src/gui/kernel/qplatformdialoghelper.cpp
+++ b/src/gui/kernel/qplatformdialoghelper.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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) 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 "qplatformdialoghelper.h"
@@ -51,11 +15,19 @@
#include <QtCore/QUrl>
#include <QtCore/QVariant>
#include <QtGui/QColor>
+#include <QtGui/QPixmap>
#include <algorithm>
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
+QT_IMPL_METATYPE_EXTERN_TAGGED(QPlatformDialogHelper::StandardButton,
+ QPlatformDialogHelper__StandardButton)
+QT_IMPL_METATYPE_EXTERN_TAGGED(QPlatformDialogHelper::ButtonRole,
+ QPlatformDialogHelper__ButtonRole)
+
/*!
\class QPlatformDialogHelper
\since 5.0
@@ -294,7 +266,7 @@ void QColorDialogStaticData::readSettings()
#if QT_CONFIG(settings)
const QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
for (int i = 0; i < int(CustomColorCount); ++i) {
- const QVariant v = settings.value(QLatin1String("Qt/customColors/") + QString::number(i));
+ const QVariant v = settings.value("Qt/customColors/"_L1 + QString::number(i));
if (v.isValid())
customRgb[i] = v.toUInt();
}
@@ -308,7 +280,7 @@ void QColorDialogStaticData::writeSettings() const
const_cast<QColorDialogStaticData*>(this)->customSet = false;
QSettings settings(QSettings::UserScope, QStringLiteral("QtProject"));
for (int i = 0; i < int(CustomColorCount); ++i)
- settings.setValue(QLatin1String("Qt/customColors/") + QString::number(i), customRgb[i]);
+ settings.setValue("Qt/customColors/"_L1 + QString::number(i), customRgb[i]);
}
#endif
}
@@ -643,7 +615,7 @@ QStringList QFileDialogOptions::mimeTypeFilters() const
void QFileDialogOptions::setDefaultSuffix(const QString &suffix)
{
d->defaultSuffix = suffix;
- if (d->defaultSuffix.size() > 1 && d->defaultSuffix.startsWith(QLatin1Char('.')))
+ if (d->defaultSuffix.size() > 1 && d->defaultSuffix.startsWith(u'.'))
d->defaultSuffix.remove(0, 1); // Silently change ".txt" -> "txt".
}
@@ -771,13 +743,13 @@ const char QPlatformFileDialogHelper::filterRegExp[] =
QStringList QPlatformFileDialogHelper::cleanFilterList(const QString &filter)
{
#if QT_CONFIG(regularexpression)
- QRegularExpression regexp(QString::fromLatin1(filterRegExp));
+ static const QRegularExpression regexp(QString::fromLatin1(filterRegExp));
Q_ASSERT(regexp.isValid());
QString f = filter;
QRegularExpressionMatch match = regexp.match(filter);
if (match.hasMatch())
f = match.captured(2);
- return f.split(QLatin1Char(' '), Qt::SkipEmptyParts);
+ return f.split(u' ', Qt::SkipEmptyParts);
#else
Q_UNUSED(filter);
return QStringList();
@@ -796,13 +768,19 @@ public:
{}
QString windowTitle;
- QMessageDialogOptions::Icon icon;
+ QMessageDialogOptions::StandardIcon icon;
QString text;
QString informativeText;
QString detailedText;
QPlatformDialogHelper::StandardButtons buttons;
QList<QMessageDialogOptions::CustomButton> customButtons;
int nextCustomButtonId;
+ QPixmap iconPixmap;
+ QString checkBoxLabel;
+ Qt::CheckState checkBoxState = Qt::Unchecked;
+ int defaultButtonId = 0;
+ int escapeButtonId = 0;
+ QMessageDialogOptions::Options options;
};
QMessageDialogOptions::QMessageDialogOptions(QMessageDialogOptionsPrivate *dd)
@@ -844,16 +822,26 @@ void QMessageDialogOptions::setWindowTitle(const QString &title)
d->windowTitle = title;
}
-QMessageDialogOptions::Icon QMessageDialogOptions::icon() const
+QMessageDialogOptions::StandardIcon QMessageDialogOptions::standardIcon() const
{
return d->icon;
}
-void QMessageDialogOptions::setIcon(Icon icon)
+void QMessageDialogOptions::setStandardIcon(StandardIcon icon)
{
d->icon = icon;
}
+void QMessageDialogOptions::setIconPixmap(const QPixmap &pixmap)
+{
+ d->iconPixmap = pixmap;
+}
+
+QPixmap QMessageDialogOptions::iconPixmap() const
+{
+ return d->iconPixmap;
+}
+
QString QMessageDialogOptions::text() const
{
return d->text;
@@ -895,9 +883,9 @@ QPlatformDialogHelper::StandardButtons QMessageDialogOptions::standardButtons()
}
int QMessageDialogOptions::addButton(const QString &label, QPlatformDialogHelper::ButtonRole role,
- void *buttonImpl)
+ void *buttonImpl, int buttonId)
{
- const CustomButton b(d->nextCustomButtonId++, label, role, buttonImpl);
+ const CustomButton b(buttonId ? buttonId : d->nextCustomButtonId++, label, role, buttonImpl);
d->customButtons.append(b);
return b.id;
}
@@ -917,12 +905,76 @@ const QList<QMessageDialogOptions::CustomButton> &QMessageDialogOptions::customB
return d->customButtons;
}
+void QMessageDialogOptions::clearCustomButtons()
+{
+ d->customButtons.clear();
+}
+
const QMessageDialogOptions::CustomButton *QMessageDialogOptions::customButton(int id)
{
- int i = d->customButtons.indexOf(CustomButton(id));
+ const int i = int(d->customButtons.indexOf(CustomButton(id)));
return (i < 0 ? nullptr : &d->customButtons.at(i));
}
+void QMessageDialogOptions::setCheckBox(const QString &label, Qt::CheckState state)
+{
+ d->checkBoxLabel = label;
+ d->checkBoxState = state;
+}
+
+QString QMessageDialogOptions::checkBoxLabel() const
+{
+ return d->checkBoxLabel;
+}
+
+Qt::CheckState QMessageDialogOptions::checkBoxState() const
+{
+ return d->checkBoxState;
+}
+
+void QMessageDialogOptions::setDefaultButton(int id)
+{
+ d->defaultButtonId = id;
+}
+
+int QMessageDialogOptions::defaultButton() const
+{
+ return d->defaultButtonId;
+}
+
+void QMessageDialogOptions::setEscapeButton(int id)
+{
+ d->escapeButtonId = id;
+}
+
+int QMessageDialogOptions::escapeButton() const
+{
+ return d->escapeButtonId;
+}
+
+void QMessageDialogOptions::setOption(QMessageDialogOptions::Option option, bool on)
+{
+ if (!(d->options & option) != !on)
+ setOptions(d->options ^ option);
+}
+
+bool QMessageDialogOptions::testOption(QMessageDialogOptions::Option option) const
+{
+ return d->options & option;
+}
+
+void QMessageDialogOptions::setOptions(QMessageDialogOptions::Options options)
+{
+ if (options != d->options)
+ d->options = options;
+}
+
+QMessageDialogOptions::Options QMessageDialogOptions::options() const
+{
+ return d->options;
+}
+
+
QPlatformDialogHelper::ButtonRole QPlatformDialogHelper::buttonRole(QPlatformDialogHelper::StandardButton button)
{
switch (button) {
@@ -1002,3 +1054,5 @@ void QPlatformMessageDialogHelper::setOptions(const QSharedPointer<QMessageDialo
}
QT_END_NAMESPACE
+
+#include "moc_qplatformdialoghelper.cpp"
diff --git a/src/gui/kernel/qplatformdialoghelper.h b/src/gui/kernel/qplatformdialoghelper.h
index 5d1d25a2dd..0569a7e2f9 100644
--- a/src/gui/kernel/qplatformdialoghelper.h
+++ b/src/gui/kernel/qplatformdialoghelper.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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) 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 QPLATFORMDIALOGHELPER_H
#define QPLATFORMDIALOGHELPER_H
@@ -176,8 +140,10 @@ Q_SIGNALS:
};
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QPlatformDialogHelper::StandardButton)
-Q_DECLARE_METATYPE(QPlatformDialogHelper::ButtonRole)
+QT_DECL_METATYPE_EXTERN_TAGGED(QPlatformDialogHelper::StandardButton,
+ QPlatformDialogHelper__StandardButton, Q_GUI_EXPORT)
+QT_DECL_METATYPE_EXTERN_TAGGED(QPlatformDialogHelper::ButtonRole,
+ QPlatformDialogHelper__ButtonRole, Q_GUI_EXPORT)
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QColorDialogOptions
@@ -191,7 +157,8 @@ public:
enum ColorDialogOption {
ShowAlphaChannel = 0x00000001,
NoButtons = 0x00000002,
- DontUseNativeDialog = 0x00000004
+ DontUseNativeDialog = 0x00000004,
+ NoEyeDropperButton = 0x00000008
};
Q_DECLARE_FLAGS(ColorDialogOptions, ColorDialogOption)
@@ -314,15 +281,16 @@ public:
enum DialogLabel { LookIn, FileName, FileType, Accept, Reject, DialogLabelCount };
Q_ENUM(DialogLabel)
+ // keep this in sync with QFileDialog::Options
enum FileDialogOption
{
ShowDirsOnly = 0x00000001,
DontResolveSymlinks = 0x00000002,
DontConfirmOverwrite = 0x00000004,
- DontUseNativeDialog = 0x00000010,
- ReadOnly = 0x00000020,
- HideNameFilterDetails = 0x00000040,
- DontUseCustomDirectoryIcons = 0x00000080
+ DontUseNativeDialog = 0x00000008,
+ ReadOnly = 0x00000010,
+ HideNameFilterDetails = 0x00000020,
+ DontUseCustomDirectoryIcons = 0x00000040
};
Q_DECLARE_FLAGS(FileDialogOptions, FileDialogOption)
Q_FLAG(FileDialogOptions)
@@ -436,9 +404,16 @@ protected:
~QMessageDialogOptions();
public:
+ // Keep in sync with QMessageBox Option
+ enum class Option {
+ DontUseNativeDialog = 0x00000001,
+ };
+ Q_DECLARE_FLAGS(Options, Option);
+ Q_FLAG(Options);
+
// Keep in sync with QMessageBox::Icon
- enum Icon { NoIcon, Information, Warning, Critical, Question };
- Q_ENUM(Icon)
+ enum StandardIcon { NoIcon, Information, Warning, Critical, Question };
+ Q_ENUM(StandardIcon)
static QSharedPointer<QMessageDialogOptions> create();
QSharedPointer<QMessageDialogOptions> clone() const;
@@ -446,8 +421,11 @@ public:
QString windowTitle() const;
void setWindowTitle(const QString &);
- void setIcon(Icon icon);
- Icon icon() const;
+ void setStandardIcon(StandardIcon icon);
+ StandardIcon standardIcon() const;
+
+ void setIconPixmap(const QPixmap &pixmap);
+ QPixmap iconPixmap() const;
void setText(const QString &text);
QString text() const;
@@ -458,6 +436,11 @@ public:
void setDetailedText(const QString &text);
QString detailedText() const;
+ void setOption(Option option, bool on = true);
+ bool testOption(Option option) const;
+ void setOptions(Options options);
+ Options options() const;
+
void setStandardButtons(QPlatformDialogHelper::StandardButtons buttons);
QPlatformDialogHelper::StandardButtons standardButtons() const;
@@ -476,10 +459,21 @@ public:
};
int addButton(const QString &label, QPlatformDialogHelper::ButtonRole role,
- void *buttonImpl = nullptr);
+ void *buttonImpl = nullptr, int buttonId = 0);
void removeButton(int id);
const QList<CustomButton> &customButtons();
const CustomButton *customButton(int id);
+ void clearCustomButtons();
+
+ void setCheckBox(const QString &label, Qt::CheckState state);
+ QString checkBoxLabel() const;
+ Qt::CheckState checkBoxState() const;
+
+ void setEscapeButton(int id);
+ int escapeButton() const;
+
+ void setDefaultButton(int id);
+ int defaultButton() const;
private:
QMessageDialogOptionsPrivate *d;
@@ -494,6 +488,7 @@ public:
Q_SIGNALS:
void clicked(QPlatformDialogHelper::StandardButton button, QPlatformDialogHelper::ButtonRole role);
+ void checkBoxStateChanged(Qt::CheckState state);
private:
QSharedPointer<QMessageDialogOptions> m_options;
diff --git a/src/gui/kernel/qplatformdrag.cpp b/src/gui/kernel/qplatformdrag.cpp
index b40ddcbfb8..cf50587996 100644
--- a/src/gui/kernel/qplatformdrag.cpp
+++ b/src/gui/kernel/qplatformdrag.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformdrag.h"
diff --git a/src/gui/kernel/qplatformdrag.h b/src/gui/kernel/qplatformdrag.h
index 0c99539357..d9e4a553b8 100644
--- a/src/gui/kernel/qplatformdrag.h
+++ b/src/gui/kernel/qplatformdrag.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMDRAG_H
#define QPLATFORMDRAG_H
diff --git a/src/gui/kernel/qplatformgraphicsbuffer.cpp b/src/gui/kernel/qplatformgraphicsbuffer.cpp
index b49aa47d41..52fc2770b4 100644
--- a/src/gui/kernel/qplatformgraphicsbuffer.cpp
+++ b/src/gui/kernel/qplatformgraphicsbuffer.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformgraphicsbuffer.h"
#include <QtGui/QOpenGLContext>
@@ -270,3 +234,5 @@ QPlatformGraphicsBuffer::Origin QPlatformGraphicsBuffer::origin() const
*/
QT_END_NAMESPACE
+
+#include "moc_qplatformgraphicsbuffer.cpp"
diff --git a/src/gui/kernel/qplatformgraphicsbuffer.h b/src/gui/kernel/qplatformgraphicsbuffer.h
index 9004116ea4..6723c63f0c 100644
--- a/src/gui/kernel/qplatformgraphicsbuffer.h
+++ b/src/gui/kernel/qplatformgraphicsbuffer.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMGRAPHICSBUFFER_H
#define QPLATFORMGRAPHICSBUFFER_H
diff --git a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp
index ff72171b85..0ec2308453 100644
--- a/src/gui/kernel/qplatformgraphicsbufferhelper.cpp
+++ b/src/gui/kernel/qplatformgraphicsbufferhelper.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <QtGui/qpa/qplatformgraphicsbuffer.h>
@@ -215,14 +179,14 @@ bool QPlatformGraphicsBufferHelper::bindSWToTexture(const QPlatformGraphicsBuffe
QRect rect = subRect;
if (rect.isNull() || rect == QRect(QPoint(0,0),size)) {
if (needsRowLength)
- funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, image.bytesPerLine() / 4);
+ funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, GLint(image.bytesPerLine() / 4));
funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, size.width(), size.height(), 0, GL_RGBA, pixelType, image.constBits());
if (needsRowLength)
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
} else {
if (!ctx->isOpenGLES() || ctx->format().majorVersion() >= 3) {
// OpenGL 2.1+ or OpenGL ES/3+
- funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, image.bytesPerLine() / 4);
+ funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, GLint(image.bytesPerLine() / 4));
funcs->glTexSubImage2D(GL_TEXTURE_2D, 0, rect.x(), rect.y(), rect.width(), rect.height(), GL_RGBA, pixelType,
image.constScanLine(rect.y()) + rect.x() * 4);
funcs->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
diff --git a/src/gui/kernel/qplatformgraphicsbufferhelper.h b/src/gui/kernel/qplatformgraphicsbufferhelper.h
index 36afd4877b..e408e4a674 100644
--- a/src/gui/kernel/qplatformgraphicsbufferhelper.h
+++ b/src/gui/kernel/qplatformgraphicsbufferhelper.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMGRAPHICSBUFFERHELPER_H
#define QPLATFORMGRAPHICSBUFFERHELPER_H
diff --git a/src/gui/kernel/qplatforminputcontext.cpp b/src/gui/kernel/qplatforminputcontext.cpp
index 0326744482..9d3ee4acb6 100644
--- a/src/gui/kernel/qplatforminputcontext.cpp
+++ b/src/gui/kernel/qplatforminputcontext.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatforminputcontext.h"
#include <qguiapplication.h>
@@ -83,6 +47,11 @@ QT_BEGIN_NAMESPACE
QPlatformInputContext::QPlatformInputContext()
: QObject(*(new QPlatformInputContextPrivate))
{
+ // Delay initialization of cached input direction
+ // until super class has finished constructing.
+ QMetaObject::invokeMethod(this, [this]{
+ m_inputDirection = inputDirection();
+ }, Qt::QueuedConnection);
}
/*!
@@ -131,7 +100,7 @@ void QPlatformInputContext::update(Qt::InputMethodQueries)
}
/*!
- Called when when the word currently being composed in input item is tapped by
+ Called when the word currently being composed in the input item is tapped by
the user. Input methods often use this information to offer more word
suggestions to the user.
*/
@@ -228,22 +197,29 @@ void QPlatformInputContext::emitInputPanelVisibleChanged()
QLocale QPlatformInputContext::locale() const
{
- return qt_keymapper_private()->keyboardInputLocale;
+ return QLocale::system();
}
void QPlatformInputContext::emitLocaleChanged()
{
emit QGuiApplication::inputMethod()->localeChanged();
+
+ // Changing the locale might have updated the input direction
+ emitInputDirectionChanged(inputDirection());
}
Qt::LayoutDirection QPlatformInputContext::inputDirection() const
{
- return qt_keymapper_private()->keyboardInputDirection;
+ return locale().textDirection();
}
void QPlatformInputContext::emitInputDirectionChanged(Qt::LayoutDirection newDirection)
{
+ if (newDirection == m_inputDirection)
+ return;
+
emit QGuiApplication::inputMethod()->inputDirectionChanged(newDirection);
+ m_inputDirection = newDirection;
}
/*!
@@ -377,3 +353,5 @@ QRectF QPlatformInputContext::keyboardRectangle()
}
QT_END_NAMESPACE
+
+#include "moc_qplatforminputcontext.cpp"
diff --git a/src/gui/kernel/qplatforminputcontext.h b/src/gui/kernel/qplatforminputcontext.h
index ea929f4a0d..481f97a065 100644
--- a/src/gui/kernel/qplatforminputcontext.h
+++ b/src/gui/kernel/qplatforminputcontext.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMINPUTCONTEXT_H
#define QPLATFORMINPUTCONTEXT_H
@@ -108,6 +72,8 @@ private:
friend class QGuiApplication;
friend class QGuiApplicationPrivate;
friend class QInputMethod;
+
+ Qt::LayoutDirection m_inputDirection;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatforminputcontext_p.h b/src/gui/kernel/qplatforminputcontext_p.h
index c4f4b97d03..d26bfe70af 100644
--- a/src/gui/kernel/qplatforminputcontext_p.h
+++ b/src/gui/kernel/qplatforminputcontext_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 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) 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 QPLATFORMINPUTCONTEXT_P_H
#define QPLATFORMINPUTCONTEXT_P_H
diff --git a/src/gui/kernel/qplatforminputcontextfactory.cpp b/src/gui/kernel/qplatforminputcontextfactory.cpp
index 749abaf27a..933d990f7c 100644
--- a/src/gui/kernel/qplatforminputcontextfactory.cpp
+++ b/src/gui/kernel/qplatforminputcontextfactory.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qpa/qplatforminputcontextfactory_p.h>
#include <qpa/qplatforminputcontextplugin_p.h>
@@ -48,35 +12,60 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
#if QT_CONFIG(settings)
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QPlatformInputContextFactoryInterface_iid, QLatin1String("/platforminputcontexts"), Qt::CaseInsensitive))
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, icLoader,
+ (QPlatformInputContextFactoryInterface_iid, "/platforminputcontexts"_L1, Qt::CaseInsensitive))
#endif
QStringList QPlatformInputContextFactory::keys()
{
#if QT_CONFIG(settings)
- return loader()->keyMap().values();
+ return icLoader()->keyMap().values();
#else
return QStringList();
#endif
}
-QString QPlatformInputContextFactory::requested()
+QStringList QPlatformInputContextFactory::requested()
{
- QByteArray env = qgetenv("QT_IM_MODULE");
- return env.isNull() ? QString() : QString::fromLocal8Bit(env);
+ QStringList imList;
+ QByteArray env = qgetenv("QT_IM_MODULES");
+
+ if (!env.isEmpty())
+ imList = QString::fromLocal8Bit(env).split(QChar::fromLatin1(';'), Qt::SkipEmptyParts);
+
+ if (!imList.isEmpty())
+ return imList;
+
+ env = qgetenv("QT_IM_MODULE");
+ if (!env.isEmpty())
+ imList = {QString::fromLocal8Bit(env)};
+
+ return imList;
+}
+
+QPlatformInputContext *QPlatformInputContextFactory::create(const QStringList& keys)
+{
+ for (const QString &key : keys) {
+ auto plugin = create(key);
+ if (plugin)
+ return plugin;
+ }
+
+ return nullptr;
}
QPlatformInputContext *QPlatformInputContextFactory::create(const QString& key)
{
#if QT_CONFIG(settings)
if (!key.isEmpty()) {
- QStringList paramList = key.split(QLatin1Char(':'));
+ QStringList paramList = key.split(u':');
const QString platform = paramList.takeFirst().toLower();
QPlatformInputContext *ic = qLoadPlugin<QPlatformInputContext, QPlatformInputContextPlugin>
- (loader(), platform, paramList);
+ (icLoader(), platform, paramList);
if (ic && ic->isValid())
return ic;
diff --git a/src/gui/kernel/qplatforminputcontextfactory_p.h b/src/gui/kernel/qplatforminputcontextfactory_p.h
index 881421ce49..5f5881c508 100644
--- a/src/gui/kernel/qplatforminputcontextfactory_p.h
+++ b/src/gui/kernel/qplatforminputcontextfactory_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 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) 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 QPLATFORMINPUTCONTEXTFACTORY_H
#define QPLATFORMINPUTCONTEXTFACTORY_H
@@ -63,7 +27,8 @@ class Q_GUI_EXPORT QPlatformInputContextFactory
{
public:
static QStringList keys();
- static QString requested();
+ static QStringList requested();
+ static QPlatformInputContext *create(const QStringList &keys);
static QPlatformInputContext *create(const QString &key);
static QPlatformInputContext *create();
};
diff --git a/src/gui/kernel/qplatforminputcontextplugin.cpp b/src/gui/kernel/qplatforminputcontextplugin.cpp
index 53d56dbb48..fdfc8483b5 100644
--- a/src/gui/kernel/qplatforminputcontextplugin.cpp
+++ b/src/gui/kernel/qplatforminputcontextplugin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatforminputcontextplugin_p.h"
@@ -51,3 +15,5 @@ QPlatformInputContextPlugin::~QPlatformInputContextPlugin()
}
QT_END_NAMESPACE
+
+#include "moc_qplatforminputcontextplugin_p.cpp"
diff --git a/src/gui/kernel/qplatforminputcontextplugin_p.h b/src/gui/kernel/qplatforminputcontextplugin_p.h
index 2228d5c8d6..819955bef4 100644
--- a/src/gui/kernel/qplatforminputcontextplugin_p.h
+++ b/src/gui/kernel/qplatforminputcontextplugin_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 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) 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 QPLATFORMINPUTCONTEXTPLUGIN_H
#define QPLATFORMINPUTCONTEXTPLUGIN_H
diff --git a/src/gui/kernel/qplatformintegration.cpp b/src/gui/kernel/qplatformintegration.cpp
index a53f0d09d7..130b479c64 100644
--- a/src/gui/kernel/qplatformintegration.cpp
+++ b/src/gui/kernel/qplatformintegration.cpp
@@ -1,47 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformintegration.h"
#include <qpa/qplatformfontdatabase.h>
#include <qpa/qplatformclipboard.h>
#include <qpa/qplatformaccessibility.h>
+#include <qpa/qplatformkeymapper.h>
#include <qpa/qplatformtheme.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qpixmap_raster_p.h>
@@ -187,7 +152,7 @@ QPlatformServices *QPlatformIntegration::services() const
/*!
\enum QPlatformIntegration::Capability
- Capabilities are used to determing specific features of a platform integration
+ Capabilities are used to determine specific features of a platform integration
\value ThreadedPixmaps The platform uses a pixmap implementation that is reentrant
and can be used from multiple threads, like the raster paint engine and QImage based
@@ -260,6 +225,15 @@ QPlatformServices *QPlatformIntegration::services() const
where there is an alternative, such as Qt Quick with its \c software backend, an
automatic fallback to that alternative may occur, if applicable. The default
implementation of hasCapability() returns \c true.
+
+ \value ScreenWindowGrabbing The platform supports grabbing window on screen.
+ On Wayland, this capability can be reported as \c false. The default implementation
+ of hasCapability() returns \c true.
+
+ \value BackingStoreStaticContents The platform backingstore supports static contents.
+ On resize of the backingstore the static contents region is provided, and the backing
+ store is expected to propagate the static content to the resized backing store, without
+ clients needing to repaint the static content region.
*/
/*!
@@ -284,7 +258,8 @@ QPlatformServices *QPlatformIntegration::services() const
bool QPlatformIntegration::hasCapability(Capability cap) const
{
return cap == NonFullScreenWindows || cap == NativeWidgets || cap == WindowManagement
- || cap == TopStackedNativeChildWindows || cap == WindowActivation || cap == RhiBasedRendering;
+ || cap == TopStackedNativeChildWindows || cap == WindowActivation
+ || cap == RhiBasedRendering || cap == ScreenWindowGrabbing;
}
QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const
@@ -373,7 +348,22 @@ QPlatformInputContext *QPlatformIntegration::inputContext() const
return nullptr;
}
-#ifndef QT_NO_ACCESSIBILITY
+/*!
+ Accessor for the platform integration's key mapper.
+
+ Default implementation returns a default QPlatformKeyMapper.
+
+ \sa QPlatformKeyMapper
+*/
+QPlatformKeyMapper *QPlatformIntegration::keyMapper() const
+{
+ static QPlatformKeyMapper *keyMapper = nullptr;
+ if (!keyMapper)
+ keyMapper = new QPlatformKeyMapper;
+ return keyMapper;
+}
+
+#if QT_CONFIG(accessibility)
/*!
Returns the platforms accessibility.
@@ -424,7 +414,7 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
case UseRtlExtensions:
return QVariant(false);
case SetFocusOnTouchRelease:
- return QVariant(false);
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::SetFocusOnTouchRelease);
case MousePressAndHoldInterval:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::MousePressAndHoldInterval);
case TabFocusBehavior:
@@ -439,6 +429,16 @@ QVariant QPlatformIntegration::styleHint(StyleHint hint) const
return QPlatformTheme::defaultThemeHint(QPlatformTheme::WheelScrollLines);
case MouseQuickSelectionThreshold:
return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseQuickSelectionThreshold);
+ case MouseDoubleClickDistance:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::MouseDoubleClickDistance);
+ case FlickStartDistance:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickStartDistance);
+ case FlickMaximumVelocity:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickMaximumVelocity);
+ case FlickDeceleration:
+ return QPlatformTheme::defaultThemeHint(QPlatformTheme::FlickDeceleration);
+ case UnderlineShortcut:
+ return true;
}
return 0;
@@ -450,6 +450,9 @@ Qt::WindowState QPlatformIntegration::defaultWindowState(Qt::WindowFlags flags)
if (flags & Qt::Popup & ~Qt::Window)
return Qt::WindowNoState;
+ if (flags & Qt::SubWindow)
+ return Qt::WindowNoState;
+
if (styleHint(QPlatformIntegration::ShowIsFullScreen).toBool())
return Qt::WindowFullScreen;
else if (styleHint(QPlatformIntegration::ShowIsMaximized).toBool())
@@ -589,7 +592,21 @@ void QPlatformIntegration::setApplicationIcon(const QIcon &icon) const
Q_UNUSED(icon);
}
-#if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC)
+/*!
+ \since 6.5
+
+ Should set the application's badge to \a number.
+
+ If the number is 0 the badge should be cleared.
+
+ \sa QGuiApplication::setBadge()
+*/
+void QPlatformIntegration::setApplicationBadge(qint64 number)
+{
+ Q_UNUSED(number);
+}
+
+#if QT_CONFIG(vulkan) || defined(Q_QDOC)
/*!
Factory function for QPlatformVulkanInstance. The \a instance parameter is a
diff --git a/src/gui/kernel/qplatformintegration.h b/src/gui/kernel/qplatformintegration.h
index 75b942f998..a18ae821c7 100644
--- a/src/gui/kernel/qplatformintegration.h
+++ b/src/gui/kernel/qplatformintegration.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMINTEGRATION_H
#define QPLATFORMINTEGRATION_H
@@ -69,6 +33,7 @@ class QPlatformOpenGLContext;
class QGuiGLFormat;
class QAbstractEventDispatcher;
class QPlatformInputContext;
+class QPlatformKeyMapper;
class QPlatformAccessibility;
class QPlatformTheme;
class QPlatformDialogHelper;
@@ -133,7 +98,9 @@ public:
OpenGLOnRasterSurface,
MaximizeUsingFullscreenGeometry,
PaintEvents,
- RhiBasedRendering
+ RhiBasedRendering,
+ ScreenWindowGrabbing, // whether QScreen::grabWindow() is supported
+ BackingStoreStaticContents
};
virtual ~QPlatformIntegration() { }
@@ -164,7 +131,7 @@ public:
virtual QPlatformDrag *drag() const;
#endif
virtual QPlatformInputContext *inputContext() const;
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
virtual QPlatformAccessibility *accessibility() const;
#endif
@@ -195,14 +162,23 @@ public:
UiEffects,
WheelScrollLines,
ShowShortcutsInContextMenus,
- MouseQuickSelectionThreshold
+ MouseQuickSelectionThreshold,
+ MouseDoubleClickDistance,
+ FlickStartDistance,
+ FlickMaximumVelocity,
+ FlickDeceleration,
+ UnderlineShortcut,
};
virtual QVariant styleHint(StyleHint hint) const;
virtual Qt::WindowState defaultWindowState(Qt::WindowFlags) const;
+protected:
virtual Qt::KeyboardModifiers queryKeyboardModifiers() const;
virtual QList<int> possibleKeys(const QKeyEvent *) const;
+ friend class QPlatformKeyMapper;
+public:
+ virtual QPlatformKeyMapper *keyMapper() const;
virtual QStringList themeNames() const;
virtual QPlatformTheme *createPlatformTheme(const QString &name) const;
@@ -219,11 +195,12 @@ public:
virtual QOpenGLContext::OpenGLModuleType openGLModuleType();
#endif
virtual void setApplicationIcon(const QIcon &icon) const;
+ virtual void setApplicationBadge(qint64 number);
virtual void beep() const;
virtual void quit() const;
-#if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(vulkan) || defined(Q_QDOC)
virtual QPlatformVulkanInstance *createPlatformVulkanInstance(QVulkanInstance *instance) const;
#endif
diff --git a/src/gui/kernel/qplatformintegrationfactory.cpp b/src/gui/kernel/qplatformintegrationfactory.cpp
index 3fcf9014a7..d0a5e8871f 100644
--- a/src/gui/kernel/qplatformintegrationfactory.cpp
+++ b/src/gui/kernel/qplatformintegrationfactory.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qpa/qplatformintegrationfactory_p.h>
#include <qpa/qplatformintegrationplugin.h>
@@ -48,27 +12,15 @@
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QPlatformIntegrationFactoryInterface_iid, QLatin1String("/platforms"), Qt::CaseInsensitive))
+using namespace Qt::StringLiterals;
-#if QT_CONFIG(library)
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
- (QPlatformIntegrationFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
-#endif // QT_CONFIG(library)
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, piLoader,
+ (QPlatformIntegrationFactoryInterface_iid, "/platforms"_L1, Qt::CaseInsensitive))
QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platform, const QStringList &paramList, int &argc, char **argv, const QString &platformPluginPath)
{
-#if QT_CONFIG(library)
- // Try loading the plugin from platformPluginPath first:
- if (!platformPluginPath.isEmpty()) {
- QCoreApplication::addLibraryPath(platformPluginPath);
- if (QPlatformIntegration *ret = qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin>(directLoader(), platform, paramList, argc, argv))
- return ret;
- }
-#else
- Q_UNUSED(platformPluginPath);
-#endif
- return qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin>(loader(), platform, paramList, argc, argv);
+ piLoader->setExtraSearchPath(platformPluginPath);
+ return qLoadPlugin<QPlatformIntegration, QPlatformIntegrationPlugin>(piLoader(), platform, paramList, argc, argv);
}
/*!
@@ -80,25 +32,8 @@ QPlatformIntegration *QPlatformIntegrationFactory::create(const QString &platfor
QStringList QPlatformIntegrationFactory::keys(const QString &platformPluginPath)
{
- QStringList list;
-#if QT_CONFIG(library)
- if (!platformPluginPath.isEmpty()) {
- QCoreApplication::addLibraryPath(platformPluginPath);
- list = directLoader()->keyMap().values();
- if (!list.isEmpty()) {
- const QString postFix = QLatin1String(" (from ")
- + QDir::toNativeSeparators(platformPluginPath)
- + QLatin1Char(')');
- const QStringList::iterator end = list.end();
- for (QStringList::iterator it = list.begin(); it != end; ++it)
- (*it).append(postFix);
- }
- }
-#else
- Q_UNUSED(platformPluginPath);
-#endif
- list.append(loader()->keyMap().values());
- return list;
+ piLoader->setExtraSearchPath(platformPluginPath);
+ return piLoader->keyMap().values();
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformintegrationfactory_p.h b/src/gui/kernel/qplatformintegrationfactory_p.h
index 22c77ce8bd..0010815956 100644
--- a/src/gui/kernel/qplatformintegrationfactory_p.h
+++ b/src/gui/kernel/qplatformintegrationfactory_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 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) 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 QPLATFORMINTEGRATIONFACTORY_H
#define QPLATFORMINTEGRATIONFACTORY_H
diff --git a/src/gui/kernel/qplatformintegrationplugin.cpp b/src/gui/kernel/qplatformintegrationplugin.cpp
index e024276797..faf32887c7 100644
--- a/src/gui/kernel/qplatformintegrationplugin.cpp
+++ b/src/gui/kernel/qplatformintegrationplugin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformintegrationplugin.h"
@@ -65,3 +29,5 @@ QPlatformIntegration *QPlatformIntegrationPlugin::create(const QString &key, con
}
QT_END_NAMESPACE
+
+#include "moc_qplatformintegrationplugin.cpp"
diff --git a/src/gui/kernel/qplatformintegrationplugin.h b/src/gui/kernel/qplatformintegrationplugin.h
index 6a0b9dc9a7..cf4915ad83 100644
--- a/src/gui/kernel/qplatformintegrationplugin.h
+++ b/src/gui/kernel/qplatformintegrationplugin.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMINTEGRATIONPLUGIN_H
#define QPLATFORMINTEGRATIONPLUGIN_H
diff --git a/src/gui/kernel/qplatformkeymapper.cpp b/src/gui/kernel/qplatformkeymapper.cpp
new file mode 100644
index 0000000000..f54e4ff379
--- /dev/null
+++ b/src/gui/kernel/qplatformkeymapper.cpp
@@ -0,0 +1,38 @@
+// Copyright (C) 2023 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 "qplatformkeymapper.h"
+
+#include <private/qguiapplication_p.h>
+#include <qpa/qplatformintegration.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_LOGGING_CATEGORY(lcQpaKeyMapper, "qt.qpa.keymapper")
+
+QPlatformKeyMapper::~QPlatformKeyMapper()
+{
+}
+
+/*
+ Should return a list of possible key combinations for the given key event.
+
+ For example, given a US English keyboard layout, the key event Shift+5
+ can represent both a "Shift+5" key combination, as well as just "%".
+*/
+QList<QKeyCombination> QPlatformKeyMapper::possibleKeyCombinations(const QKeyEvent *event) const
+{
+ auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ QList<int> possibleKeys = platformIntegration->possibleKeys(event);
+ QList<QKeyCombination> combinations;
+ for (int key : possibleKeys)
+ combinations << QKeyCombination::fromCombined(key);
+ return combinations;
+}
+
+Qt::KeyboardModifiers QPlatformKeyMapper::queryKeyboardModifiers() const
+{
+ return QGuiApplicationPrivate::platformIntegration()->queryKeyboardModifiers();
+}
+
+QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformkeymapper.h b/src/gui/kernel/qplatformkeymapper.h
new file mode 100644
index 0000000000..fb5b0cdb8b
--- /dev/null
+++ b/src/gui/kernel/qplatformkeymapper.h
@@ -0,0 +1,36 @@
+// Copyright (C) 2023 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 QPLATFORMKEYMAPPER_P
+#define QPLATFORMKEYMAPPER_P
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the QPA API and is not meant to be used
+// in applications. Usage of this API may make your code
+// source and binary incompatible with future versions of Qt.
+//
+
+#include <QtGui/qtguiglobal.h>
+#include <QtCore/qloggingcategory.h>
+
+QT_BEGIN_NAMESPACE
+
+Q_DECLARE_EXPORTED_LOGGING_CATEGORY(lcQpaKeyMapper, Q_GUI_EXPORT)
+
+class QKeyEvent;
+
+class Q_GUI_EXPORT QPlatformKeyMapper
+{
+public:
+ virtual ~QPlatformKeyMapper();
+
+ virtual QList<QKeyCombination> possibleKeyCombinations(const QKeyEvent *event) const;
+ virtual Qt::KeyboardModifiers queryKeyboardModifiers() const;
+};
+
+QT_END_NAMESPACE
+
+#endif // QPLATFORMKEYMAPPER_P
diff --git a/src/gui/kernel/qplatformmenu.cpp b/src/gui/kernel/qplatformmenu.cpp
index 0d76f2039d..d629c8b02d 100644
--- a/src/gui/kernel/qplatformmenu.cpp
+++ b/src/gui/kernel/qplatformmenu.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2014 Martin Graesslin <mgraesslin@kde.org>
-** 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) 2016 The Qt Company Ltd.
+// Copyright (C) 2014 Martin Graesslin <mgraesslin@kde.org>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformmenu.h"
@@ -92,3 +56,5 @@ QPlatformMenu *QPlatformMenuBar::createMenu() const
}
QT_END_NAMESPACE
+
+#include "moc_qplatformmenu.cpp"
diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h
index 8e470aefd3..fbb54f2af1 100644
--- a/src/gui/kernel/qplatformmenu.h
+++ b/src/gui/kernel/qplatformmenu.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author James Turner <james.turner@kdab.com>
-** 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) 2016 The Qt Company Ltd.
+// Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author James Turner <james.turner@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPLATFORMMENU_H
#define QPLATFORMMENU_H
@@ -49,13 +13,14 @@
// source and binary incompatible with future versions of Qt.
//
+#include <QtCore/qobject.h>
#include <QtGui/qtguiglobal.h>
#include <QtCore/qpointer.h>
-#include <QtGui/QFont>
+#include <QtGui/qfont.h>
#if QT_CONFIG(shortcut)
-# include <QtGui/QKeySequence>
+# include <QtGui/qkeysequence.h>
#endif
-#include <QtGui/QIcon>
+#include <QtGui/qicon.h>
QT_BEGIN_NAMESPACE
diff --git a/src/gui/kernel/qplatformmenu_p.h b/src/gui/kernel/qplatformmenu_p.h
index 38f49ef983..00e3fa56da 100644
--- a/src/gui/kernel/qplatformmenu_p.h
+++ b/src/gui/kernel/qplatformmenu_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 QPLATFORMMENU_P_H
#define QPLATFORMMENU_P_H
@@ -59,7 +23,7 @@ QT_BEGIN_NAMESPACE
// ----------------- QNativeInterface -----------------
-#if !defined(Q_OS_MACOS) && defined(Q_CLANG_QDOC)
+#if !defined(Q_OS_MACOS) && defined(Q_QDOC)
typedef void NSMenu;
#else
QT_END_NAMESPACE
@@ -69,7 +33,7 @@ QT_BEGIN_NAMESPACE
namespace QNativeInterface::Private {
-#if defined(Q_OS_MACOS) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_MACOS) || defined(Q_QDOC)
struct Q_GUI_EXPORT QCocoaMenu
{
QT_DECLARE_NATIVE_INTERFACE(QCocoaMenu)
diff --git a/src/gui/kernel/qplatformnativeinterface.cpp b/src/gui/kernel/qplatformnativeinterface.cpp
index 15b08e195a..d010f0b7c6 100644
--- a/src/gui/kernel/qplatformnativeinterface.cpp
+++ b/src/gui/kernel/qplatformnativeinterface.cpp
@@ -1,43 +1,9 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformnativeinterface.h"
+#include <QtCore/qvariant.h>
+#include <QtCore/qmap.h>
#include <QtGui/qcursor.h>
QT_BEGIN_NAMESPACE
@@ -175,3 +141,5 @@ void QPlatformNativeInterface::setWindowProperty(QPlatformWindow *window, const
}
QT_END_NAMESPACE
+
+#include "moc_qplatformnativeinterface.cpp"
diff --git a/src/gui/kernel/qplatformnativeinterface.h b/src/gui/kernel/qplatformnativeinterface.h
index 58c8f6b414..6e721ec71c 100644
--- a/src/gui/kernel/qplatformnativeinterface.h
+++ b/src/gui/kernel/qplatformnativeinterface.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMNATIVEINTERFACE_H
#define QPLATFORMNATIVEINTERFACE_H
diff --git a/src/gui/kernel/qplatformoffscreensurface.cpp b/src/gui/kernel/qplatformoffscreensurface.cpp
index c2952e166c..653b0c762a 100644
--- a/src/gui/kernel/qplatformoffscreensurface.cpp
+++ b/src/gui/kernel/qplatformoffscreensurface.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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) 2017 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 "qplatformoffscreensurface.h"
diff --git a/src/gui/kernel/qplatformoffscreensurface.h b/src/gui/kernel/qplatformoffscreensurface.h
index 259b213f5a..227c04794a 100644
--- a/src/gui/kernel/qplatformoffscreensurface.h
+++ b/src/gui/kernel/qplatformoffscreensurface.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 QPLATFORMOFFSCREENSURFACE_H
#define QPLATFORMOFFSCREENSURFACE_H
diff --git a/src/gui/kernel/qplatformopenglcontext.cpp b/src/gui/kernel/qplatformopenglcontext.cpp
index 839ec008aa..8391425caf 100644
--- a/src/gui/kernel/qplatformopenglcontext.cpp
+++ b/src/gui/kernel/qplatformopenglcontext.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformopenglcontext.h"
@@ -165,4 +129,20 @@ bool QPlatformOpenGLContext::parseOpenGLVersion(const QByteArray &versionString,
return (majorOk && minorOk);
}
+/*!
+ Called when the RHI begins rendering a new frame in the context. Will always be paired with a
+ call to \l endFrame().
+*/
+void QPlatformOpenGLContext::beginFrame()
+{
+}
+
+/*!
+ Called when the RHI ends rendering a in the context. Is always preceded by a call to
+ \l beginFrame().
+*/
+void QPlatformOpenGLContext::endFrame()
+{
+}
+
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformopenglcontext.h b/src/gui/kernel/qplatformopenglcontext.h
index 034462e5f3..ac13c42655 100644
--- a/src/gui/kernel/qplatformopenglcontext.h
+++ b/src/gui/kernel/qplatformopenglcontext.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMOPENGLCONTEXT_H
#define QPLATFORMOPENGLCONTEXT_H
@@ -84,6 +48,9 @@ public:
virtual bool makeCurrent(QPlatformSurface *surface) = 0;
virtual void doneCurrent() = 0;
+ virtual void beginFrame();
+ virtual void endFrame();
+
virtual bool isSharing() const { return false; }
virtual bool isValid() const { return true; }
diff --git a/src/gui/kernel/qplatformscreen.cpp b/src/gui/kernel/qplatformscreen.cpp
index 0649139455..0369a0b12a 100644
--- a/src/gui/kernel/qplatformscreen.cpp
+++ b/src/gui/kernel/qplatformscreen.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformscreen.h"
#include <QtCore/qdebug.h>
@@ -61,10 +25,8 @@ QPlatformScreen::QPlatformScreen()
QPlatformScreen::~QPlatformScreen()
{
Q_D(QPlatformScreen);
- if (d->screen) {
- qWarning("Manually deleting a QPlatformScreen. Call QWindowSystemInterface::handleScreenRemoved instead.");
- delete d->screen;
- }
+ Q_ASSERT_X(!d->screen, "QPlatformScreen",
+ "QPlatformScreens should be removed via QWindowSystemInterface::handleScreenRemoved()");
}
/*!
@@ -92,8 +54,9 @@ QPixmap QPlatformScreen::grabWindow(WId window, int x, int y, int width, int hei
QWindow *QPlatformScreen::topLevelAt(const QPoint & pos) const
{
const QWindowList list = QGuiApplication::topLevelWindows();
- for (int i = list.size()-1; i >= 0; --i) {
- QWindow *w = list[i];
+ const auto crend = list.crend();
+ for (auto it = list.crbegin(); it != crend; ++it) {
+ QWindow *w = *it;
if (w->isVisible() && QHighDpi::toNativePixels(w->geometry(), w).contains(pos))
return w;
}
@@ -471,13 +434,6 @@ QRect QPlatformScreen::mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation
return rect;
}
-QRect QPlatformScreen::deviceIndependentGeometry() const
-{
- qreal scaleFactor = QHighDpiScaling::factor(this);
- QRect nativeGeometry = geometry();
- return QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor));
-}
-
/*!
Returns a hint about this screen's subpixel layout structure.
diff --git a/src/gui/kernel/qplatformscreen.h b/src/gui/kernel/qplatformscreen.h
index 4e1ea4b3a9..a547a635e9 100644
--- a/src/gui/kernel/qplatformscreen.h
+++ b/src/gui/kernel/qplatformscreen.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMSCREEN_H
#define QPLATFORMSCREEN_H
@@ -78,6 +42,7 @@ typedef QPair<qreal, qreal> QDpi;
class Q_GUI_EXPORT QPlatformScreen
{
+ Q_GADGET
Q_DECLARE_PRIVATE(QPlatformScreen)
public:
@@ -160,9 +125,6 @@ public:
static QTransform transformBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &target);
static QRect mapBetween(Qt::ScreenOrientation a, Qt::ScreenOrientation b, const QRect &rect);
- // The platform screen's geometry in device independent coordinates
- QRect deviceIndependentGeometry() const;
-
static QDpi overrideDpi(const QDpi &in);
protected:
@@ -171,7 +133,7 @@ protected:
QScopedPointer<QPlatformScreenPrivate> d_ptr;
private:
- friend class QScreenPrivate;
+ friend class QScreen;
};
// Qt doesn't currently support running with no platform screen
diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h
index 35097b5d23..345a90845c 100644
--- a/src/gui/kernel/qplatformscreen_p.h
+++ b/src/gui/kernel/qplatformscreen_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 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) 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 QPLATFORMSCREEN_P_H
#define QPLATFORMSCREEN_P_H
@@ -70,7 +34,7 @@ public:
namespace QNativeInterface::Private {
-#if QT_CONFIG(xcb) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(xcb) || defined(Q_QDOC)
struct Q_GUI_EXPORT QXcbScreen
{
QT_DECLARE_NATIVE_INTERFACE(QXcbScreen, 1, QScreen)
@@ -78,7 +42,7 @@ struct Q_GUI_EXPORT QXcbScreen
};
#endif
-#if QT_CONFIG(vsp2) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(vsp2) || defined(Q_QDOC)
struct Q_GUI_EXPORT QVsp2Screen
{
QT_DECLARE_NATIVE_INTERFACE(QVsp2Screen, 1, QScreen)
@@ -91,7 +55,7 @@ struct Q_GUI_EXPORT QVsp2Screen
};
#endif
-#if defined(Q_OS_WEBOS) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_WEBOS) || defined(Q_QDOC)
struct Q_GUI_EXPORT QWebOSScreen
{
QT_DECLARE_NATIVE_INTERFACE(QWebOSScreen, 1, QScreen)
@@ -103,7 +67,6 @@ struct Q_GUI_EXPORT QWebOSScreen
virtual void addFlipListener(void (*callback)()) = 0;
};
#endif
-
} // QNativeInterface::Private
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformservices.cpp b/src/gui/kernel/qplatformservices.cpp
index fdc6a6c4aa..7ff2a6c2f8 100644
--- a/src/gui/kernel/qplatformservices.cpp
+++ b/src/gui/kernel/qplatformservices.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformservices.h"
@@ -55,6 +19,19 @@ QT_BEGIN_NAMESPACE
\brief The QPlatformServices provides the backend for desktop-related functionality.
*/
+/*!
+ \enum QPlatformServices::Capability
+
+ Capabilities are used to determine a specific platform service's availability.
+
+ \value ColorPickingFromScreen The platform natively supports color picking from screen.
+ This capability indicates that the platform supports "opaque" color picking, where the
+ platform implements a complete user experience for color picking and outputs a color.
+ This is in contrast to the application implementing the color picking user experience
+ (taking care of showing a cross hair, instructing the platform integration to obtain
+ the color at a given pixel, etc.). The related service function is pickColor().
+ */
+
QPlatformServices::QPlatformServices()
{ }
@@ -85,5 +62,18 @@ QByteArray QPlatformServices::desktopEnvironment() const
return QByteArray("UNKNOWN");
}
+QPlatformServiceColorPicker *QPlatformServices::colorPicker(QWindow *parent)
+{
+ Q_UNUSED(parent);
+ return nullptr;
+}
+
+bool QPlatformServices::hasCapability(Capability capability) const
+{
+ Q_UNUSED(capability)
+ return false;
+}
QT_END_NAMESPACE
+
+#include "moc_qplatformservices.cpp"
diff --git a/src/gui/kernel/qplatformservices.h b/src/gui/kernel/qplatformservices.h
index 5de96cfa7d..063247af08 100644
--- a/src/gui/kernel/qplatformservices.h
+++ b/src/gui/kernel/qplatformservices.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMSERVICES_H
#define QPLATFORMSERVICES_H
@@ -50,16 +14,32 @@
//
#include <QtGui/qtguiglobal.h>
+#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
class QUrl;
+class QWindow;
+
+class Q_GUI_EXPORT QPlatformServiceColorPicker : public QObject
+{
+ Q_OBJECT
+public:
+ using QObject::QObject;
+ virtual void pickColor() = 0;
+Q_SIGNALS:
+ void colorPicked(const QColor &color);
+};
class Q_GUI_EXPORT QPlatformServices
{
public:
Q_DISABLE_COPY_MOVE(QPlatformServices)
+ enum Capability {
+ ColorPicking,
+ };
+
QPlatformServices();
virtual ~QPlatformServices() { }
@@ -67,6 +47,10 @@ public:
virtual bool openDocument(const QUrl &url);
virtual QByteArray desktopEnvironment() const;
+
+ virtual bool hasCapability(Capability capability) const;
+
+ virtual QPlatformServiceColorPicker *colorPicker(QWindow *parent = nullptr);
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformsessionmanager.cpp b/src/gui/kernel/qplatformsessionmanager.cpp
index bc4ce22c0f..2a8e621294 100644
--- a/src/gui/kernel/qplatformsessionmanager.cpp
+++ b/src/gui/kernel/qplatformsessionmanager.cpp
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2013 Teo Mrnjavac <teo@kde.org>
-** Copyright (C) 2016 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) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
+// Copyright (C) 2013 Teo Mrnjavac <teo@kde.org>
+// 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 "qplatformsessionmanager.h"
diff --git a/src/gui/kernel/qplatformsessionmanager.h b/src/gui/kernel/qplatformsessionmanager.h
index c6c3984816..213d8dc07e 100644
--- a/src/gui/kernel/qplatformsessionmanager.h
+++ b/src/gui/kernel/qplatformsessionmanager.h
@@ -1,43 +1,7 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2013 Teo Mrnjavac <teo@kde.org>
-** Copyright (C) 2016 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) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
+// Copyright (C) 2013 Teo Mrnjavac <teo@kde.org>
+// 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 QPLATFORMSESSIONMANAGER_H
#define QPLATFORMSESSIONMANAGER_H
diff --git a/src/gui/kernel/qplatformsharedgraphicscache.cpp b/src/gui/kernel/qplatformsharedgraphicscache.cpp
index 971fb0f848..c482a94426 100644
--- a/src/gui/kernel/qplatformsharedgraphicscache.cpp
+++ b/src/gui/kernel/qplatformsharedgraphicscache.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformsharedgraphicscache.h"
@@ -292,3 +256,5 @@ QT_BEGIN_NAMESPACE
*/
QT_END_NAMESPACE
+
+#include "moc_qplatformsharedgraphicscache.cpp"
diff --git a/src/gui/kernel/qplatformsharedgraphicscache.h b/src/gui/kernel/qplatformsharedgraphicscache.h
index 56e51188cc..4935a52bd6 100644
--- a/src/gui/kernel/qplatformsharedgraphicscache.h
+++ b/src/gui/kernel/qplatformsharedgraphicscache.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMSHAREDGRAPHICSCACHE_H
#define QPLATFORMSHAREDGRAPHICSCACHE_H
diff --git a/src/gui/kernel/qplatformsurface.cpp b/src/gui/kernel/qplatformsurface.cpp
index fdb2cf567d..39a1869de6 100644
--- a/src/gui/kernel/qplatformsurface.cpp
+++ b/src/gui/kernel/qplatformsurface.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformsurface.h"
#ifndef QT_NO_DEBUG_STREAM
@@ -68,6 +32,17 @@ QPlatformSurface::QPlatformSurface(QSurface *surface) : m_surface(surface)
{
}
+bool QPlatformSurface::isRasterSurface(QSurface *surface)
+{
+ switch (surface->surfaceType()) {
+ case QSurface::RasterSurface:
+ case QSurface::RasterGLSurface:
+ return true;
+ default:
+ return false;
+ };
+}
+
#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QPlatformSurface *surface)
{
diff --git a/src/gui/kernel/qplatformsurface.h b/src/gui/kernel/qplatformsurface.h
index 475f3ef330..f867d3df1b 100644
--- a/src/gui/kernel/qplatformsurface.h
+++ b/src/gui/kernel/qplatformsurface.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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) 2017 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 QPLATFORMSURFACE_H
#define QPLATFORMSURFACE_H
@@ -73,6 +37,8 @@ public:
QSurface *surface() const;
virtual QPlatformScreen *screen() const = 0;
+ static bool isRasterSurface(QSurface *surface);
+
private:
explicit QPlatformSurface(QSurface *surface);
diff --git a/src/gui/kernel/qplatformsystemtrayicon.cpp b/src/gui/kernel/qplatformsystemtrayicon.cpp
index 296beda0f9..0b21fe39f7 100644
--- a/src/gui/kernel/qplatformsystemtrayicon.cpp
+++ b/src/gui/kernel/qplatformsystemtrayicon.cpp
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2012 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
-** 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) 2016 The Qt Company Ltd.
+// Copyright (C) 2012 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qplatformsystemtrayicon.h"
diff --git a/src/gui/kernel/qplatformsystemtrayicon.h b/src/gui/kernel/qplatformsystemtrayicon.h
index bd74a2cc0a..76a7ef03d9 100644
--- a/src/gui/kernel/qplatformsystemtrayicon.h
+++ b/src/gui/kernel/qplatformsystemtrayicon.h
@@ -1,47 +1,12 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Copyright (C) 2012 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
-** 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) 2016 The Qt Company Ltd.
+// Copyright (C) 2012 Klaralvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Christoph Schleifenbaum <christoph.schleifenbaum@kdab.com>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QPLATFORMSYSTEMTRAYICON_H
#define QPLATFORMSYSTEMTRAYICON_H
#include <QtGui/qtguiglobal.h>
+#include <qpa/qplatformscreen.h>
#include "QtCore/qobject.h"
#ifndef QT_NO_SYSTEMTRAYICON
@@ -49,7 +14,6 @@
QT_BEGIN_NAMESPACE
class QPlatformMenu;
-class QPlatformScreen;
class QIcon;
class QString;
class QRect;
@@ -57,7 +21,6 @@ class QRect;
class Q_GUI_EXPORT QPlatformSystemTrayIcon : public QObject
{
Q_OBJECT
- Q_MOC_INCLUDE(<qpa/qplatformscreen.h>)
public:
enum ActivationReason {
Unknown,
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 34f7307cd7..48978b849a 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformtheme.h"
@@ -64,6 +28,8 @@ QT_BEGIN_NAMESPACE
\ingroup qpa
\brief The QPlatformTheme class allows customizing the UI based on themes.
+ See the init_platform function in qguiapplication.cpp for the complete
+ platform initialization process.
*/
/*!
@@ -167,6 +133,26 @@ QT_BEGIN_NAMESPACE
as basis for the resize.
This enum value has been added in Qt 6.2.
+ \value ShowDirectoriesFirst (bool) Whether directories should be shown
+ first (before files) in file dialogs.
+ This enum value was added in Qt 6.3.
+
+ \value PreselectFirstFileInDirectory (bool) Whether the first file in a directory
+ should be automatically selected when a file dialog opens.
+ This enum value was added in Qt 6.3.
+
+ \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
+
+ \value SetFocusOnTouchRelease (bool) Whether focus objects (line edits etc) should receive
+ input focus after a touch/mouse release.
+ This enum value has been added in Qt 6.5.
+
+ \value MouseCursorTheme (QString) Name of the mouse cursor theme.
+ This enum value has been added in Qt 6.5.
+
+ \value MouseCursorSize (QSize) Size of the mouse cursor.
+ This enum value has been added in Qt 6.5.
+
\sa themeHint(), QStyle::pixelMetric()
*/
@@ -339,7 +325,7 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, KB_All},
{QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, KB_All},
{QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_O, KB_Mac},
- {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_Gnome | KB_Mac},
+ {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_All},
{QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac},
{QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_X11 | KB_Gnome | KB_KDE | KB_Mac},
{QKeySequence::FullScreen, 1, Qt::META | Qt::CTRL | Qt::Key_F, KB_Mac},
@@ -349,6 +335,7 @@ const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
{QKeySequence::FullScreen, 1, Qt::Key_F11, KB_Win | KB_KDE},
{QKeySequence::Deselect, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_A, KB_X11},
{QKeySequence::DeleteCompleteLine, 0, Qt::CTRL | Qt::Key_U, KB_X11},
+ {QKeySequence::Backspace, 1, Qt::Key_Backspace, KB_Mac},
{QKeySequence::Backspace, 0, Qt::META | Qt::Key_H, KB_Mac},
{QKeySequence::Cancel, 0, Qt::Key_Escape, KB_All},
{QKeySequence::Cancel, 0, Qt::CTRL | Qt::Key_Period, KB_Mac}
@@ -366,7 +353,61 @@ QPlatformThemePrivate::~QPlatformThemePrivate()
delete systemPalette;
}
-Q_GUI_EXPORT QPalette qt_fusionPalette();
+Q_GUI_EXPORT QPalette qt_fusionPalette()
+{
+ auto theme = QGuiApplicationPrivate::platformTheme();
+ const bool darkAppearance = theme
+ ? theme->colorScheme() == Qt::ColorScheme::Dark
+ : false;
+ const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
+ const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
+ const QColor light = backGround.lighter(150);
+ const QColor mid = (backGround.darker(130));
+ const QColor midLight = mid.lighter(110);
+ const QColor base = darkAppearance ? backGround.darker(140) : Qt::white;
+ const QColor disabledBase(backGround);
+ const QColor dark = backGround.darker(150);
+ const QColor darkDisabled = QColor(209, 209, 209).darker(110);
+ const QColor text = darkAppearance ? windowText : Qt::black;
+ const QColor highlight = QColor(48, 140, 198);
+ const QColor hightlightedText = darkAppearance ? windowText : Qt::white;
+ const QColor disabledText = darkAppearance ? QColor(130, 130, 130) : QColor(190, 190, 190);
+ const QColor button = backGround;
+ const QColor shadow = dark.darker(135);
+ const QColor disabledShadow = shadow.lighter(150);
+ const QColor disabledHighlight(145, 145, 145);
+ QColor placeholder = text;
+ placeholder.setAlpha(128);
+
+ QPalette fusionPalette(windowText, backGround, light, dark, mid, text, base);
+ fusionPalette.setBrush(QPalette::Midlight, midLight);
+ fusionPalette.setBrush(QPalette::Button, button);
+ fusionPalette.setBrush(QPalette::Shadow, shadow);
+ fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
+
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
+
+ fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
+ fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, disabledHighlight);
+
+ fusionPalette.setBrush(QPalette::Active, QPalette::Accent, highlight);
+ fusionPalette.setBrush(QPalette::Inactive, QPalette::Accent, highlight);
+ fusionPalette.setBrush(QPalette::Disabled, QPalette::Accent, disabledHighlight);
+
+ fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
+
+ // Use a more legible light blue on dark backgrounds than the default Qt::blue.
+ if (darkAppearance)
+ fusionPalette.setBrush(QPalette::Link, highlight);
+
+ return fusionPalette;
+}
void QPlatformThemePrivate::initializeSystemPalette()
{
@@ -401,6 +442,11 @@ QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType typ
return nullptr;
}
+Qt::ColorScheme QPlatformTheme::colorScheme() const
+{
+ return Qt::ColorScheme::Unknown;
+}
+
const QPalette *QPlatformTheme::palette(Palette type) const
{
Q_D(const QPlatformTheme);
@@ -477,6 +523,16 @@ QVariant QPlatformTheme::themeHint(ThemeHint hint) const
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects);
case QPlatformTheme::ShowShortcutsInContextMenus:
return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus);
+ case QPlatformTheme::SetFocusOnTouchRelease:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SetFocusOnTouchRelease);
+ case QPlatformTheme::FlickStartDistance:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickStartDistance);
+ case QPlatformTheme::FlickMaximumVelocity:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity);
+ case QPlatformTheme::FlickDeceleration:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration);
+ case QPlatformTheme::UnderlineShortcut:
+ return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UnderlineShortcut);
default:
return QPlatformTheme::defaultThemeHint(hint);
}
@@ -569,7 +625,30 @@ QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
return QVariant(10);
case InteractiveResizeAcrossScreens:
return true;
+ case ShowDirectoriesFirst:
+ return true;
+ case PreselectFirstFileInDirectory:
+ return false;
+ case ButtonPressKeys:
+ return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
+ case SetFocusOnTouchRelease:
+ return false;
+ case FlickStartDistance:
+ return QVariant(15);
+ case FlickMaximumVelocity:
+ return QVariant(2500);
+ case FlickDeceleration:
+ return QVariant(1500);
+ case MenuBarFocusOnAltPressRelease:
+ return false;
+ case MouseCursorTheme:
+ return QVariant(QString());
+ case MouseCursorSize:
+ return QVariant(QSize(16, 16));
+ case UnderlineShortcut:
+ return true;
}
+
return QVariant();
}
@@ -737,33 +816,38 @@ QString QPlatformTheme::defaultStandardButtonText(int button)
QString QPlatformTheme::removeMnemonics(const QString &original)
{
+ const auto mnemonicInParentheses = [](QStringView text) {
+ /* Format of mnemonics to remove is /\(&[^&]\)/ but accept full-width
+ forms of ( and ) as equivalent, for cross-platform compatibility with
+ MS (and consequent behavior of translators, see QTBUG-110829).
+ */
+ Q_ASSERT(text.size() == 4); // Caller's responsibility.
+ constexpr QChar wideOpen = u'\uff08', wideClose = u'\uff09';
+ if (!text.startsWith(u'(') && !text.startsWith(wideOpen))
+ return false;
+ if (text[1] != u'&' || text[2] == u'&')
+ return false;
+ return text.endsWith(u')') || text.endsWith(wideClose);
+ };
QString returnText(original.size(), u'\0');
int finalDest = 0;
- int currPos = 0;
- int l = original.length();
- while (l) {
- if (original.at(currPos) == QLatin1Char('&')) {
- ++currPos;
- --l;
- if (l == 0)
+ QStringView text(original);
+ while (!text.isEmpty()) {
+ if (text.startsWith(u'&')) {
+ text = text.sliced(1);
+ if (text.isEmpty())
break;
- } else if (original.at(currPos) == QLatin1Char('(') && l >= 4 &&
- original.at(currPos + 1) == QLatin1Char('&') &&
- original.at(currPos + 2) != QLatin1Char('&') &&
- original.at(currPos + 3) == QLatin1Char(')')) {
- /* remove mnemonics its format is "\s*(&X)" */
- int n = 0;
- while (finalDest > n && returnText.at(finalDest - n - 1).isSpace())
- ++n;
- finalDest -= n;
- currPos += 4;
- l -= 4;
+ } else if (text.size() >= 4 && mnemonicInParentheses(text.first(4))) {
+ // Advance over the matched mnemonic:
+ text = text.sliced(4);
+ // Also strip any leading space before it:
+ while (finalDest > 0 && returnText.at(finalDest - 1).isSpace())
+ --finalDest;
continue;
}
- returnText[finalDest] = original.at(currPos);
- ++currPos;
+ returnText[finalDest] = text.front();
+ text = text.sliced(1);
++finalDest;
- --l;
}
returnText.truncate(finalDest);
return returnText;
@@ -782,4 +866,11 @@ unsigned QPlatformThemePrivate::currentKeyPlatforms()
return result;
}
+QString QPlatformTheme::name() const
+{
+ return d_func()->name;
+}
+
QT_END_NAMESPACE
+
+#include "moc_qplatformtheme.cpp"
diff --git a/src/gui/kernel/qplatformtheme.h b/src/gui/kernel/qplatformtheme.h
index 0b6c0254f0..c0193947b9 100644
--- a/src/gui/kernel/qplatformtheme.h
+++ b/src/gui/kernel/qplatformtheme.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMTHEME_H
#define QPLATFORMTHEME_H
@@ -50,6 +14,7 @@
//
#include <QtGui/qtguiglobal.h>
+#include <QtCore/QObject>
#include <QtCore/QScopedPointer>
#if QT_CONFIG(shortcut)
# include <QtGui/QKeySequence>
@@ -76,7 +41,9 @@ class QFileInfo;
class Q_GUI_EXPORT QPlatformTheme
{
+ Q_GADGET
Q_DECLARE_PRIVATE(QPlatformTheme)
+
public:
Q_DISABLE_COPY_MOVE(QPlatformTheme)
@@ -119,7 +86,19 @@ public:
IconFallbackSearchPaths,
MouseQuickSelectionThreshold,
InteractiveResizeAcrossScreens,
+ ShowDirectoriesFirst,
+ PreselectFirstFileInDirectory,
+ ButtonPressKeys,
+ SetFocusOnTouchRelease,
+ FlickStartDistance,
+ FlickMaximumVelocity,
+ FlickDeceleration,
+ MenuBarFocusOnAltPressRelease,
+ MouseCursorTheme,
+ MouseCursorSize,
+ UnderlineShortcut,
};
+ Q_ENUM(ThemeHint)
enum DialogType {
FileDialog,
@@ -127,6 +106,7 @@ public:
FontDialog,
MessageDialog
};
+ Q_ENUM(DialogType);
enum Palette {
SystemPalette,
@@ -149,6 +129,7 @@ public:
TextLineEditPalette,
NPalettes
};
+ Q_ENUM(Palette)
enum Font {
SystemFont,
@@ -180,6 +161,7 @@ public:
EditorFont,
NFonts
};
+ Q_ENUM(Font)
enum StandardPixmap { // Keep in sync with QStyle::StandardPixmap
TitleBarMenuButton,
@@ -253,9 +235,20 @@ public:
MediaVolume,
MediaVolumeMuted,
LineEditClearButton,
+ DialogYesToAllButton,
+ DialogNoToAllButton,
+ DialogSaveAllButton,
+ DialogAbortButton,
+ DialogRetryButton,
+ DialogIgnoreButton,
+ RestoreDefaultsButton,
+ TabCloseButton,
+ NStandardPixmap, // assertion value for sync with QStyle::StandardPixmap
+
// do not add any values below/greater than this
CustomBase = 0xf0000000
};
+ Q_ENUM(StandardPixmap)
enum KeyboardSchemes
{
@@ -266,6 +259,7 @@ public:
GnomeKeyboardScheme,
CdeKeyboardScheme
};
+ Q_ENUM(KeyboardSchemes)
enum UiEffect
{
@@ -278,6 +272,7 @@ public:
AnimateToolBoxUiEffect = 0x40,
HoverEffect = 0x80
};
+ Q_ENUM(UiEffect)
enum IconOption {
DontUseCustomDirectoryIcons = 0x01
@@ -299,6 +294,8 @@ public:
virtual QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const;
#endif
+ virtual Qt::ColorScheme colorScheme() const;
+
virtual const QPalette *palette(Palette type = SystemPalette) const;
virtual const QFont *font(Font type = SystemFont) const;
@@ -322,10 +319,14 @@ public:
static QVariant defaultThemeHint(ThemeHint hint);
static QString defaultStandardButtonText(int button);
static QString removeMnemonics(const QString &original);
+ QString name() const;
protected:
explicit QPlatformTheme(QPlatformThemePrivate *priv);
QScopedPointer<QPlatformThemePrivate> d_ptr;
+
+private:
+ friend class QPlatformThemeFactory;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformtheme_p.h b/src/gui/kernel/qplatformtheme_p.h
index 2c16fec141..e847ead3be 100644
--- a/src/gui/kernel/qplatformtheme_p.h
+++ b/src/gui/kernel/qplatformtheme_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 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) 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 QPLATFORMTHEME_P_H
#define QPLATFORMTHEME_P_H
@@ -77,6 +41,8 @@ public:
static unsigned currentKeyPlatforms();
QPalette *systemPalette;
+
+ QString name;
};
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformthemefactory.cpp b/src/gui/kernel/qplatformthemefactory.cpp
index 447d385abe..beefa1c294 100644
--- a/src/gui/kernel/qplatformthemefactory.cpp
+++ b/src/gui/kernel/qplatformthemefactory.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qpa/qplatformthemefactory_p.h>
#include <qpa/qplatformthemeplugin.h>
@@ -44,33 +8,26 @@
#include "qmutex.h"
#include "qguiapplication.h"
+#include "qplatformtheme.h"
+#include "qplatformtheme_p.h"
#include "qdebug.h"
QT_BEGIN_NAMESPACE
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
- (QPlatformThemeFactoryInterface_iid, QLatin1String("/platformthemes"), Qt::CaseInsensitive))
+using namespace Qt::StringLiterals;
-#if QT_CONFIG(library)
-Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, directLoader,
- (QPlatformThemeFactoryInterface_iid, QLatin1String(""), Qt::CaseInsensitive))
-#endif
+Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, ptLoader,
+ (QPlatformThemeFactoryInterface_iid, "/platformthemes"_L1, Qt::CaseInsensitive))
QPlatformTheme *QPlatformThemeFactory::create(const QString& key, const QString &platformPluginPath)
{
- QStringList paramList = key.split(QLatin1Char(':'));
+ QStringList paramList = key.split(u':');
const QString platform = paramList.takeFirst().toLower();
-#if QT_CONFIG(library)
- // Try loading the plugin from platformPluginPath first:
- if (!platformPluginPath.isEmpty()) {
- QCoreApplication::addLibraryPath(platformPluginPath);
- if (QPlatformTheme *ret = qLoadPlugin<QPlatformTheme, QPlatformThemePlugin>(directLoader(), platform, paramList))
- return ret;
- }
-#else
- Q_UNUSED(platformPluginPath);
-#endif
- return qLoadPlugin<QPlatformTheme, QPlatformThemePlugin>(loader(), platform, paramList);
+ ptLoader->setExtraSearchPath(platformPluginPath);
+ QPlatformTheme *theme = qLoadPlugin<QPlatformTheme, QPlatformThemePlugin>(ptLoader(), platform, paramList);
+ if (theme)
+ theme->d_func()->name = key;
+ return theme;
}
/*!
@@ -81,26 +38,8 @@ QPlatformTheme *QPlatformThemeFactory::create(const QString& key, const QString
*/
QStringList QPlatformThemeFactory::keys(const QString &platformPluginPath)
{
- QStringList list;
-
-#if QT_CONFIG(library)
- if (!platformPluginPath.isEmpty()) {
- QCoreApplication::addLibraryPath(platformPluginPath);
- list += directLoader()->keyMap().values();
- if (!list.isEmpty()) {
- const QString postFix = QLatin1String(" (from ")
- + QDir::toNativeSeparators(platformPluginPath)
- + QLatin1Char(')');
- const QStringList::iterator end = list.end();
- for (QStringList::iterator it = list.begin(); it != end; ++it)
- (*it).append(postFix);
- }
- }
-#else
- Q_UNUSED(platformPluginPath);
-#endif
- list += loader()->keyMap().values();
- return list;
+ ptLoader->setExtraSearchPath(platformPluginPath);
+ return ptLoader->keyMap().values();
}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qplatformthemefactory_p.h b/src/gui/kernel/qplatformthemefactory_p.h
index c312eadf27..c466dcd461 100644
--- a/src/gui/kernel/qplatformthemefactory_p.h
+++ b/src/gui/kernel/qplatformthemefactory_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 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) 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 QPLATFORMTHEMEFACTORY_H
#define QPLATFORMTHEMEFACTORY_H
diff --git a/src/gui/kernel/qplatformthemeplugin.cpp b/src/gui/kernel/qplatformthemeplugin.cpp
index c09476bee5..8b22680c05 100644
--- a/src/gui/kernel/qplatformthemeplugin.cpp
+++ b/src/gui/kernel/qplatformthemeplugin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformthemeplugin.h"
@@ -60,3 +24,5 @@ QPlatformThemePlugin::~QPlatformThemePlugin()
}
QT_END_NAMESPACE
+
+#include "moc_qplatformthemeplugin.cpp"
diff --git a/src/gui/kernel/qplatformthemeplugin.h b/src/gui/kernel/qplatformthemeplugin.h
index 0f88806b0b..a983f4c5b7 100644
--- a/src/gui/kernel/qplatformthemeplugin.h
+++ b/src/gui/kernel/qplatformthemeplugin.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QPLATFORMTHEMEPLUGIN_H
#define QPLATFORMTHEMEPLUGIN_H
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp
index 0bee2968f7..5c0ae2ee2a 100644
--- a/src/gui/kernel/qplatformwindow.cpp
+++ b/src/gui/kernel/qplatformwindow.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qplatformwindow.h"
#include "qplatformwindow_p.h"
@@ -229,7 +193,7 @@ bool QPlatformWindow::isActive() const
*/
bool QPlatformWindow::isAncestorOf(const QPlatformWindow *child) const
{
- for (const QPlatformWindow *parent = child->parent(); parent; parent = child->parent()) {
+ for (const QPlatformWindow *parent = child->parent(); parent; parent = parent->parent()) {
if (parent == this)
return true;
}
@@ -406,18 +370,18 @@ void QPlatformWindow::setMask(const QRegion &region)
Reimplement to let Qt be able to request activation/focus for a window
Some window systems will probably not have callbacks for this functionality,
- and then calling QWindowSystemInterface::handleWindowActivated(QWindow *w)
+ and then calling QWindowSystemInterface::handleFocusWindowChanged(QWindow *w)
would be sufficient.
If the window system has some event handling/callbacks then call
- QWindowSystemInterface::handleWindowActivated(QWindow *w) when the window system
+ QWindowSystemInterface::handleFocusWindowChanged(QWindow *w) when the window system
gives the notification.
- Default implementation calls QWindowSystem::handleWindowActivated(QWindow *w)
+ Default implementation calls QWindowSystem::handleFocusWindowChanged(QWindow *w)
*/
void QPlatformWindow::requestActivateWindow()
{
- QWindowSystemInterface::handleWindowActivated(window());
+ QWindowSystemInterface::handleFocusWindowChanged(window());
}
/*!
@@ -763,20 +727,29 @@ QRect QPlatformWindow::initialGeometry(const QWindow *w, const QRect &initialGeo
should be delivered using QPlatformWindow::deliverUpdateRequest()
to not get out of sync with the internal state of QWindow.
- The default implementation posts an UpdateRequest event to the
- window after 5 ms. The additional time is there to give the event
- loop a bit of idle time to gather system events.
+ The default implementation posts an UpdateRequest event to the window after
+ an interval that is at most 5 ms. If the window's associated screen reports
+ a \l{QPlatformScreen::refreshRate()}{refresh rate} higher than 60 Hz, the
+ interval is scaled down to a valid smaller than 5. The additional time is
+ there to give the event loop a bit of idle time to gather system events.
*/
void QPlatformWindow::requestUpdate()
{
Q_D(QPlatformWindow);
- static int updateInterval = []() {
- bool ok = false;
- int customUpdateInterval = qEnvironmentVariableIntValue("QT_QPA_UPDATE_IDLE_TIME", &ok);
- return ok ? customUpdateInterval : 5;
- }();
+ static bool customUpdateIntervalValid = false;
+ static int customUpdateInterval = qEnvironmentVariableIntValue("QT_QPA_UPDATE_IDLE_TIME",
+ &customUpdateIntervalValid);
+ int updateInterval = customUpdateInterval;
+ if (!customUpdateIntervalValid) {
+ updateInterval = 5;
+ if (QPlatformScreen *currentScreen = screen()) {
+ const qreal refreshRate = currentScreen->refreshRate();
+ if (refreshRate > 60.0)
+ updateInterval /= refreshRate / 60.0;
+ }
+ }
Q_ASSERT(!d->updateTimer.isActive());
d->updateTimer.start(updateInterval, Qt::PreciseTimer, window());
@@ -805,6 +778,15 @@ void QPlatformWindow::deliverUpdateRequest()
QWindow *w = window();
QWindowPrivate *wp = qt_window_private(w);
+
+ // We expect that the platform plugins send DevicePixelRatioChange events.
+ // As a fail-safe make a final check here to make sure the cached DPR value is
+ // always up to date before delivering the update request.
+ if (wp->updateDevicePixelRatio()) {
+ qWarning() << "The cached device pixel ratio value was stale on window update. "
+ << "Please file a QTBUG which explains how to reproduce.";
+ }
+
wp->updateRequestPending = false;
QEvent request(QEvent::UpdateRequest);
QCoreApplication::sendEvent(w, &request);
diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h
index cd621b7636..b6e96a457e 100644
--- a/src/gui/kernel/qplatformwindow.h
+++ b/src/gui/kernel/qplatformwindow.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 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) 2017 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 QPLATFORMWINDOW_H
#define QPLATFORMWINDOW_H
@@ -60,6 +24,7 @@
QT_BEGIN_NAMESPACE
+#define QWINDOWSIZE_MAX ((1<<24)-1)
class QPlatformScreen;
class QPlatformWindowPrivate;
diff --git a/src/gui/kernel/qplatformwindow_p.h b/src/gui/kernel/qplatformwindow_p.h
index e35f527921..2bbdfd5bf9 100644
--- a/src/gui/kernel/qplatformwindow_p.h
+++ b/src/gui/kernel/qplatformwindow_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 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) 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 QPLATFORMWINDOW_P_H
#define QPLATFORMWINDOW_P_H
@@ -55,6 +19,14 @@
#include <QtCore/qbasictimer.h>
#include <QtCore/qrect.h>
#include <QtCore/qnativeinterface.h>
+#include <QtGui/qwindow.h>
+
+#if QT_CONFIG(wayland)
+#include <any>
+#include <QtCore/qobject.h>
+
+struct wl_surface;
+#endif
QT_BEGIN_NAMESPACE
@@ -71,7 +43,16 @@ public:
namespace QNativeInterface::Private {
-#if defined(Q_OS_MACOS) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_WASM) || defined(Q_QDOC)
+struct Q_GUI_EXPORT QWasmWindow
+{
+ QT_DECLARE_NATIVE_INTERFACE(QWasmWindow, 1, QWindow)
+ virtual emscripten::val document() const = 0;
+ virtual emscripten::val clientArea() const = 0;
+};
+#endif
+
+#if defined(Q_OS_MACOS) || defined(Q_QDOC)
struct Q_GUI_EXPORT QCocoaWindow
{
QT_DECLARE_NATIVE_INTERFACE(QCocoaWindow, 1, QWindow)
@@ -80,7 +61,7 @@ struct Q_GUI_EXPORT QCocoaWindow
};
#endif
-#if QT_CONFIG(xcb) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(xcb) || defined(Q_QDOC)
struct Q_GUI_EXPORT QXcbWindow
{
QT_DECLARE_NATIVE_INTERFACE(QXcbWindow, 1, QWindow)
@@ -112,7 +93,7 @@ struct Q_GUI_EXPORT QXcbWindow
};
#endif // xcb
-#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
+#if defined(Q_OS_WIN) || defined(Q_QDOC)
struct Q_GUI_EXPORT QWindowsWindow
{
QT_DECLARE_NATIVE_INTERFACE(QWindowsWindow, 1, QWindow)
@@ -125,6 +106,35 @@ struct Q_GUI_EXPORT QWindowsWindow
};
#endif // Q_OS_WIN
+#if QT_CONFIG(wayland)
+struct Q_GUI_EXPORT QWaylandWindow : public QObject
+{
+ Q_OBJECT
+public:
+ QT_DECLARE_NATIVE_INTERFACE(QWaylandWindow, 1, QWindow)
+
+ virtual wl_surface *surface() const = 0;
+ virtual void setCustomMargins(const QMargins &margins) = 0;
+ virtual void requestXdgActivationToken(uint serial) = 0;
+ template<typename T>
+ T *surfaceRole() const
+ {
+ std::any anyRole = _surfaceRole();
+ auto role = std::any_cast<T *>(&anyRole);
+ return role ? *role : nullptr;
+ }
+Q_SIGNALS:
+ void surfaceCreated();
+ void surfaceDestroyed();
+ void surfaceRoleCreated();
+ void surfaceRoleDestroyed();
+ void xdgActivationTokenCreated(const QString &token);
+
+protected:
+ virtual std::any _surfaceRole() const = 0;
+};
+#endif
+
} // QNativeInterface::Private
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qpointingdevice.cpp b/src/gui/kernel/qpointingdevice.cpp
index 2a09ee3ca9..c4c1e5fd5c 100644
--- a/src/gui/kernel/qpointingdevice.cpp
+++ b/src/gui/kernel/qpointingdevice.cpp
@@ -1,45 +1,11 @@
-/****************************************************************************
-**
-** 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
#include "qpointingdevice.h"
#include "qpointingdevice_p.h"
#include "qwindowsysteminterface_p.h"
+#include "qeventpoint_p.h"
+
#include <QList>
#include <QLoggingCategory>
#include <QMutex>
@@ -49,6 +15,8 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_LOGGING_CATEGORY(lcPointerGrab, "qt.pointer.grab");
/*!
@@ -143,11 +111,53 @@ Q_LOGGING_CATEGORY(lcPointerGrab, "qt.pointer.grab");
Any of the above (used as a default filter value).
*/
+/*! \enum QPointingDevice::GrabTransition
+
+ This enum represents a transition of exclusive or passive grab
+ from one object (possibly \c nullptr) to another (possibly \c nullptr).
+ It is emitted as an argument of the QPointingDevice::grabChanged() signal.
+
+ Valid values are:
+
+ \value GrabExclusive
+ Emitted after QPointerEvent::setExclusiveGrabber().
+ \value UngrabExclusive
+ Emitted after QPointerEvent::setExclusiveGrabber() when the grabber is
+ set to \c nullptr, to notify that the grab has terminated normally.
+ \value CancelGrabExclusive
+ Emitted after QPointerEvent::setExclusiveGrabber() when the grabber is set
+ to a different object, to notify that the old grabber's grab is "stolen".
+ \value GrabPassive
+ Emitted after QPointerEvent::addPassiveGrabber().
+ \value UngrabPassive
+ Emitted when a passive grab is terminated normally,
+ for example after QPointerEvent::removePassiveGrabber().
+ \value CancelGrabPassive
+ Emitted when a passive grab is terminated abnormally (a gesture is canceled).
+ \value OverrideGrabPassive
+ This value is not currently used.
+*/
+
+/*! \fn void QPointingDevice::grabChanged(QObject *grabber, QPointingDevice::GrabTransition transition, const QPointerEvent *event, const QEventPoint &point) const
+
+ This signal is emitted when the \a grabber object gains or loses an
+ exclusive or passive grab of \a point during delivery of \a event.
+ The \a transition tells what happened, from the perspective of the
+ \c grabber object.
+
+ \note A grab transition from one object to another results in two signals,
+ to notify that one object has lost its grab, and to notify that there is
+ another grabber. In other cases, when transitioning to or from a non-grabbing
+ state, only one signal is emitted: the \a grabber argument is never \c nullptr.
+
+ \sa QPointerEvent::setExclusiveGrabber(), QPointerEvent::addPassiveGrabber(), QPointerEvent::removePassiveGrabber()
+*/
+
/*!
Creates a new invalid pointing device instance as a child of \a parent.
*/
QPointingDevice::QPointingDevice(QObject *parent)
- : QInputDevice(*(new QPointingDevicePrivate(QLatin1String("unknown"), -1,
+ : QInputDevice(*(new QPointingDevicePrivate("unknown"_L1, -1,
DeviceType::Unknown, PointerType::Unknown,
Capability::None, 0, 0)), parent)
{
@@ -177,9 +187,10 @@ QPointingDevice::QPointingDevice(QPointingDevicePrivate &d, QObject *parent)
{
}
+#if QT_DEPRECATED_SINCE(6, 0)
/*!
\internal
- \deprecated Please use the constructor rather than setters.
+ \deprecated [6.0] Please use the constructor rather than setters.
Sets the device type \a devType and infers the pointer type.
*/
@@ -210,7 +221,7 @@ void QPointingDevice::setType(DeviceType devType)
/*!
\internal
- \deprecated Please use the constructor rather than setters.
+ \deprecated [6.0] Please use the constructor rather than setters.
*/
void QPointingDevice::setCapabilities(QInputDevice::Capabilities caps)
{
@@ -220,13 +231,14 @@ void QPointingDevice::setCapabilities(QInputDevice::Capabilities caps)
/*!
\internal
- \deprecated Please use the constructor rather than setters.
+ \deprecated [6.0] Please use the constructor rather than setters.
*/
void QPointingDevice::setMaximumTouchPoints(int c)
{
Q_D(QPointingDevice);
d->maximumTouchPoints = c;
}
+#endif // QT_DEPRECATED_SINCE(6, 0)
/*!
Returns the pointer type.
@@ -284,7 +296,7 @@ const QPointingDevice *QPointingDevice::primaryPointingDevice(const QString& sea
const QPointingDevice *mouse = nullptr;
const QPointingDevice *touchpad = nullptr;
for (const QInputDevice *dev : v) {
- if (dev->seatName() != seatName)
+ if (!seatName.isNull() && dev->seatName() != seatName)
continue;
if (dev->type() == QInputDevice::DeviceType::Mouse) {
if (!mouse)
@@ -301,19 +313,22 @@ const QPointingDevice *QPointingDevice::primaryPointingDevice(const QString& sea
qCDebug(lcQpaInputDevices) << "no mouse-like devices registered for seat" << seatName
<< "The platform plugin should have provided one via "
"QWindowSystemInterface::registerInputDevice(). Creating a default mouse for now.";
- mouse = new QPointingDevice(QLatin1String("core pointer"), 1, DeviceType::Mouse,
+ mouse = new QPointingDevice("core pointer"_L1, 1, DeviceType::Mouse,
PointerType::Generic, Capability::Position, 1, 3, seatName,
QPointingDeviceUniqueId(), QCoreApplication::instance());
QInputDevicePrivate::registerDevice(mouse);
return mouse;
}
- if (v.length() > 1)
+ if (v.size() > 1)
qCDebug(lcQpaInputDevices) << "core pointer ambiguous for seat" << seatName;
if (mouse)
return mouse;
return touchpad;
}
+QPointingDevicePrivate::~QPointingDevicePrivate()
+ = default;
+
/*!
\internal
Finds the device instance belonging to the drawing or eraser end of a particular stylus,
@@ -422,13 +437,12 @@ QPointingDevicePrivate::EventPointData *QPointingDevicePrivate::queryPointById(i
*/
QPointingDevicePrivate::EventPointData *QPointingDevicePrivate::pointById(int id) const
{
- auto it = activePoints.find(id);
- if (it == activePoints.end()) {
+ const auto [it, inserted] = activePoints.try_emplace(id);
+ if (inserted) {
Q_Q(const QPointingDevice);
- QPointingDevicePrivate::EventPointData epd;
- QMutableEventPoint::from(epd.eventPoint).setId(id);
- QMutableEventPoint::from(epd.eventPoint).setDevice(q);
- return &activePoints.insert(id, epd).first.value();
+ auto &epd = it.value();
+ QMutableEventPoint::setId(epd.eventPoint, id);
+ QMutableEventPoint::setDevice(epd.eventPoint, q);
}
return &it.value();
}
@@ -451,7 +465,7 @@ void QPointingDevicePrivate::removePointById(int id)
QObject *QPointingDevicePrivate::firstActiveTarget() const
{
for (auto &pt : activePoints.values()) {
- if (auto target = QMutableEventPoint::constFrom(pt.eventPoint).target())
+ if (auto target = QMutableEventPoint::target(pt.eventPoint))
return target;
}
return nullptr;
@@ -466,7 +480,7 @@ QObject *QPointingDevicePrivate::firstActiveTarget() const
QWindow *QPointingDevicePrivate::firstActiveWindow() const
{
for (auto &pt : activePoints.values()) {
- if (auto window = QMutableEventPoint::constFrom(pt.eventPoint).window())
+ if (auto window = QMutableEventPoint::window(pt.eventPoint))
return window;
}
return nullptr;
@@ -493,6 +507,7 @@ void QPointingDevicePrivate::setExclusiveGrabber(const QPointerEvent *event, con
qWarning() << "point is not in activePoints" << point;
return;
}
+ Q_ASSERT(persistentPoint->eventPoint.id() == point.id());
if (persistentPoint->exclusiveGrabber == exclusiveGrabber)
return;
auto oldGrabber = persistentPoint->exclusiveGrabber;
@@ -505,7 +520,7 @@ void QPointingDevicePrivate::setExclusiveGrabber(const QPointerEvent *event, con
<< "@" << point.scenePosition()
<< ": grab" << oldGrabber << "->" << exclusiveGrabber;
}
- QMutableEventPoint::from(persistentPoint->eventPoint).setGlobalGrabPosition(point.globalPosition());
+ QMutableEventPoint::setGlobalGrabPosition(persistentPoint->eventPoint, point.globalPosition());
if (exclusiveGrabber)
emit q->grabChanged(exclusiveGrabber, QPointingDevice::GrabExclusive, event, point);
else
@@ -549,7 +564,7 @@ bool QPointingDevicePrivate::addPassiveGrabber(const QPointerEvent *event, const
bool QPointingDevicePrivate::setPassiveGrabberContext(QPointingDevicePrivate::EventPointData *epd, QObject *grabber, QObject *context)
{
- int i = epd->passiveGrabbers.indexOf(grabber);
+ qsizetype i = epd->passiveGrabbers.indexOf(grabber);
if (i < 0)
return false;
if (epd->passiveGrabbersContext.size() <= i)
@@ -566,7 +581,7 @@ bool QPointingDevicePrivate::removePassiveGrabber(const QPointerEvent *event, co
qWarning() << "point is not in activePoints" << point;
return false;
}
- int i = persistentPoint->passiveGrabbers.indexOf(grabber);
+ qsizetype i = persistentPoint->passiveGrabbers.indexOf(grabber);
if (i >= 0) {
if (Q_UNLIKELY(lcPointerGrab().isDebugEnabled())) {
qCDebug(lcPointerGrab) << name << "point" << point.id() << point.state()
@@ -629,7 +644,7 @@ void QPointingDevicePrivate::removeGrabber(QObject *grabber, bool cancel)
cancel ? QPointingDevice::CancelGrabExclusive : QPointingDevice::UngrabExclusive,
nullptr, epd.eventPoint);
}
- int pi = epd.passiveGrabbers.indexOf(grabber);
+ qsizetype pi = epd.passiveGrabbers.indexOf(grabber);
if (pi >= 0) {
qCDebug(lcPointerGrab) << name << "point" << epd.eventPoint.id() << epd.eventPoint.state()
<< ": removing passive grabber" << grabber;
@@ -665,9 +680,9 @@ const QPointingDevice *QPointingDevicePrivate::tabletDevice(QInputDevice::Device
<< deviceType << pointerType << Qt::hex << uniqueId.numericId()
<< "The platform plugin should have provided one via "
"QWindowSystemInterface::registerInputDevice(). Creating a default one for now.";
- dev = new QPointingDevice(QLatin1String("fake tablet"), 2, deviceType, pointerType,
- QInputDevice::Capability::Position | QInputDevice::Capability::Pressure,
- 1, 1, QString(), uniqueId, QCoreApplication::instance());
+ dev = new QPointingDevice("fake tablet"_L1, 2, deviceType, pointerType,
+ QInputDevice::Capability::Position | QInputDevice::Capability::Pressure,
+ 1, 1, QString(), uniqueId, QCoreApplication::instance());
QInputDevicePrivate::registerDevice(dev);
}
return dev;
@@ -693,7 +708,7 @@ QDebug operator<<(QDebug debug, const QPointingDevice *device)
if (device) {
debug << '"' << device->name() << "\" ";
QtDebugUtils::formatQEnum(debug, device->type());
- debug << " id=" << Qt::hex << device->systemId() << Qt::dec;
+ debug << " id=" << device->systemId();
if (!device->seatName().isEmpty())
debug << " seat=" << device->seatName();
if (device->pointerType() != QPointingDevice::PointerType::Generic) {
@@ -804,3 +819,5 @@ size_t qHash(QPointingDeviceUniqueId key, size_t seed) noexcept
}
QT_END_NAMESPACE
+
+#include "moc_qpointingdevice.cpp"
diff --git a/src/gui/kernel/qpointingdevice.h b/src/gui/kernel/qpointingdevice.h
index 094780765a..b8e6460af7 100644
--- a/src/gui/kernel/qpointingdevice.h
+++ b/src/gui/kernel/qpointingdevice.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 QPOINTINGDEVICE_H
#define QPOINTINGDEVICE_H
@@ -143,7 +107,13 @@ public:
bool operator==(const QPointingDevice &other) const;
Q_SIGNALS:
- void grabChanged(QObject *grabber, GrabTransition transition, const QPointerEvent *event, const QEventPoint &point) const;
+#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
+ void grabChanged(QObject *grabber, GrabTransition transition,
+ const QPointerEvent *event, const QEventPoint &point) const;
+#else
+ void grabChanged(QObject *grabber, QPointingDevice::GrabTransition transition,
+ const QPointerEvent *event, const QEventPoint &point);
+#endif
protected:
QPointingDevice(QPointingDevicePrivate &d, QObject *parent);
diff --git a/src/gui/kernel/qpointingdevice_p.h b/src/gui/kernel/qpointingdevice_p.h
index 263bc91864..b2f0574e9b 100644
--- a/src/gui/kernel/qpointingdevice_p.h
+++ b/src/gui/kernel/qpointingdevice_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 QPOINTINGDEVICE_P_H
#define QPOINTINGDEVICE_P_H
@@ -56,6 +20,8 @@
#include <QtGui/qpointingdevice.h>
#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/private/qinputdevice_p.h>
+
+#include <QtCore/qpointer.h>
#include <QtCore/private/qflatmap_p.h>
QT_BEGIN_NAMESPACE
@@ -79,6 +45,7 @@ public:
pointingDeviceType = true;
activePoints.reserve(maxPoints);
}
+ ~QPointingDevicePrivate() override;
void sendTouchCancelEvent(QTouchEvent *cancelEvent);
@@ -107,7 +74,7 @@ public:
void clearPassiveGrabbers(const QPointerEvent *event, const QEventPoint &point);
void removeGrabber(QObject *grabber, bool cancel = false);
- using EventPointMap = QFlatMap<int, EventPointData>;
+ using EventPointMap = QVarLengthFlatMap<int, EventPointData, 20>;
mutable EventPointMap activePoints;
QPointingDeviceUniqueId uniqueId;
diff --git a/src/gui/kernel/qrasterwindow.cpp b/src/gui/kernel/qrasterwindow.cpp
index 70d87347c3..f292344ca1 100644
--- a/src/gui/kernel/qrasterwindow.cpp
+++ b/src/gui/kernel/qrasterwindow.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qrasterwindow.h"
@@ -70,14 +34,20 @@ class QRasterWindowPrivate : public QPaintDeviceWindowPrivate
{
Q_DECLARE_PUBLIC(QRasterWindow)
public:
+ void handleResizeEvent() override
+ {
+ Q_Q(QRasterWindow);
+ if (backingstore->size() != q->size())
+ markWindowAsDirty();
+ }
+
void beginPaint(const QRegion &region) override
{
Q_Q(QRasterWindow);
const QSize size = q->size();
- if (backingstore->size() != size) {
+ if (backingstore->size() != size)
backingstore->resize(size);
- markWindowAsDirty();
- }
+
backingstore->beginPaint(region);
}
@@ -138,4 +108,10 @@ QPaintDevice *QRasterWindow::redirected(QPoint *) const
return d->backingstore->paintDevice();
}
+void QRasterWindow::resizeEvent(QResizeEvent *)
+{
+}
+
QT_END_NAMESPACE
+
+#include "moc_qrasterwindow.cpp"
diff --git a/src/gui/kernel/qrasterwindow.h b/src/gui/kernel/qrasterwindow.h
index 9fe01c076b..986bf6b511 100644
--- a/src/gui/kernel/qrasterwindow.h
+++ b/src/gui/kernel/qrasterwindow.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QRASTERWINDOW_H
#define QRASTERWINDOW_H
@@ -59,6 +23,7 @@ public:
protected:
int metric(PaintDeviceMetric metric) const override;
QPaintDevice *redirected(QPoint *) const override;
+ void resizeEvent(QResizeEvent *event) override;
private:
Q_DISABLE_COPY(QRasterWindow)
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp
index 6f9f48d6c4..83641e7676 100644
--- a/src/gui/kernel/qscreen.cpp
+++ b/src/gui/kernel/qscreen.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qscreen.h"
#include "qscreen_p.h"
@@ -73,100 +37,42 @@ QT_BEGIN_NAMESPACE
\inmodule QtGui
*/
-QScreen::QScreen(QPlatformScreen *screen)
+QScreen::QScreen(QPlatformScreen *platformScreen)
: QObject(*new QScreenPrivate(), nullptr)
{
Q_D(QScreen);
- d->setPlatformScreen(screen);
-}
-void QScreenPrivate::updateGeometriesWithSignals()
-{
- const QRect oldGeometry = geometry;
- const QRect oldAvailableGeometry = availableGeometry;
- updateHighDpi();
- emitGeometryChangeSignals(oldGeometry != geometry, oldAvailableGeometry != availableGeometry);
-}
+ d->platformScreen = platformScreen;
+ platformScreen->d_func()->screen = this;
-void QScreenPrivate::emitGeometryChangeSignals(bool geometryChanged, bool availableGeometryChanged)
-{
- Q_Q(QScreen);
- if (geometryChanged)
- emit q->geometryChanged(geometry);
-
- if (availableGeometryChanged)
- emit q->availableGeometryChanged(availableGeometry);
-
- if (geometryChanged || availableGeometryChanged) {
- const auto siblings = q->virtualSiblings();
- for (QScreen* sibling : siblings)
- emit sibling->virtualGeometryChanged(sibling->virtualGeometry());
- }
+ d->orientation = platformScreen->orientation();
+ d->logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
+ d->refreshRate = platformScreen->refreshRate();
+ // safeguard ourselves against buggy platform behavior...
+ if (d->refreshRate < 1.0)
+ d->refreshRate = 60.0;
- if (geometryChanged)
- emit q->physicalDotsPerInchChanged(q->physicalDotsPerInch());
+ d->updateGeometry();
+ d->updatePrimaryOrientation(); // derived from the geometry
}
-void QScreenPrivate::setPlatformScreen(QPlatformScreen *screen)
+void QScreenPrivate::updateGeometry()
{
- Q_Q(QScreen);
- platformScreen = screen;
- platformScreen->d_func()->screen = q;
- orientation = platformScreen->orientation();
-
- logicalDpi = QPlatformScreen::overrideDpi(platformScreen->logicalDpi());
-
- refreshRate = platformScreen->refreshRate();
- // safeguard ourselves against buggy platform behavior...
- if (refreshRate < 1.0)
- refreshRate = 60.0;
-
- updateHighDpi();
- updatePrimaryOrientation(); // derived from the geometry
+ qreal scaleFactor = QHighDpiScaling::factor(platformScreen);
+ QRect nativeGeometry = platformScreen->geometry();
+ geometry = QRect(nativeGeometry.topLeft(), QHighDpi::fromNative(nativeGeometry.size(), scaleFactor));
+ availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), scaleFactor, geometry.topLeft());
}
-
/*!
Destroys the screen.
+
+ \internal
*/
QScreen::~QScreen()
{
- // Remove screen
- const bool wasPrimary = QGuiApplication::primaryScreen() == this;
- QGuiApplicationPrivate::screen_list.removeOne(this);
- QGuiApplicationPrivate::resetCachedDevicePixelRatio();
-
- if (!qGuiApp)
- return;
-
- QScreen *newPrimaryScreen = QGuiApplication::primaryScreen();
- if (wasPrimary && newPrimaryScreen)
- emit qGuiApp->primaryScreenChanged(newPrimaryScreen);
-
- // Allow clients to manage windows that are affected by the screen going
- // away, before we fall back to moving them to the primary screen.
- emit qApp->screenRemoved(this);
-
- if (QGuiApplication::closingDown())
- return;
-
- bool movingFromVirtualSibling = newPrimaryScreen
- && newPrimaryScreen->handle()->virtualSiblings().contains(handle());
-
- // Move any leftover windows to the primary screen
- const auto allWindows = QGuiApplication::allWindows();
- for (QWindow *window : allWindows) {
- if (!window->isTopLevel() || window->screen() != this)
- continue;
-
- const bool wasVisible = window->isVisible();
- window->setScreen(newPrimaryScreen);
-
- // Re-show window if moved from a virtual sibling screen. Otherwise
- // leave it up to the application developer to show the window.
- if (movingFromVirtualSibling)
- window->setVisible(wasVisible);
- }
+ Q_ASSERT_X(!QGuiApplicationPrivate::screen_list.contains(this), "QScreen",
+ "QScreens should be removed via QWindowSystemInterface::handleScreenRemoved()");
}
/*!
@@ -186,6 +92,10 @@ QPlatformScreen *QScreen::handle() const
For example, on X11 these correspond to the XRandr screen names,
typically "VGA1", "HDMI1", etc.
+
+ \note The user presentable string is not guaranteed to match the
+ result of any native APIs, and should not be used to uniquely identify
+ a screen.
*/
QString QScreen::name() const
{
@@ -449,9 +359,12 @@ QList<QScreen *> QScreen::virtualSiblings() const
Q_D(const QScreen);
const QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings();
QList<QScreen *> screens;
- screens.reserve(platformScreens.count());
- for (QPlatformScreen *platformScreen : platformScreens)
- screens << platformScreen->screen();
+ screens.reserve(platformScreens.size());
+ for (QPlatformScreen *platformScreen : platformScreens) {
+ // Only consider platform screens that have been added
+ if (auto *knownScreen = platformScreen->screen())
+ screens << knownScreen;
+ }
return screens;
}
@@ -547,6 +460,11 @@ Qt::ScreenOrientation QScreen::orientation() const
/*!
\property QScreen::refreshRate
\brief the approximate vertical refresh rate of the screen in Hz
+
+ \warning Avoid using the screen's refresh rate to drive animations via a
+ timer such as QChronoTimer. Instead use QWindow::requestUpdate().
+
+ \sa QWindow::requestUpdate()
*/
qreal QScreen::refreshRate() const
{
@@ -786,12 +704,25 @@ QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height)
return result;
}
-template <>
-Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QScreen *that, const char *name, int revision)
+/*!
+ \fn template <typename QNativeInterface> QNativeInterface *QScreen::nativeInterface() const
+
+ Returns a native interface of the given type for the screen.
+
+ This function provides access to platform specific functionality
+ of QScreen, as defined in the QNativeInterface namespace:
+
+ \annotatedlist native-interfaces-qscreen
+
+ If the requested interface is not available a \nullptr is returned.
+ */
+
+void *QScreen::resolveInterface(const char *name, int revision) const
{
+ using namespace QNativeInterface;
using namespace QNativeInterface::Private;
- auto *platformScreen = that->handle();
+ auto *platformScreen = handle();
Q_UNUSED(platformScreen);
Q_UNUSED(name);
Q_UNUSED(revision);
@@ -808,17 +739,22 @@ Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(cons
QT_NATIVE_INTERFACE_RETURN_IF(QWebOSScreen, platformScreen);
#endif
- return nullptr;
-}
+#if defined(Q_OS_WIN32)
+ QT_NATIVE_INTERFACE_RETURN_IF(QWindowsScreen, platformScreen);
+#endif
-#ifndef QT_NO_DEBUG_STREAM
+#if defined(Q_OS_ANDROID)
+ QT_NATIVE_INTERFACE_RETURN_IF(QAndroidScreen, platformScreen);
+#endif
-static inline void formatRect(QDebug &debug, const QRect r)
-{
- debug << r.width() << 'x' << r.height()
- << Qt::forcesign << r.x() << r.y() << Qt::noforcesign;
+#if QT_CONFIG(wayland)
+ QT_NATIVE_INTERFACE_RETURN_IF(QWaylandScreen, platformScreen);
+#endif
+
+ return nullptr;
}
+#ifndef QT_NO_DEBUG_STREAM
Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen)
{
const QDebugStateSaver saver(debug);
@@ -829,10 +765,8 @@ Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen)
if (debug.verbosity() > 2) {
if (screen == QGuiApplication::primaryScreen())
debug << ", primary";
- debug << ", geometry=";
- formatRect(debug, screen->geometry());
- debug << ", available=";
- formatRect(debug, screen->availableGeometry());
+ debug << ", geometry=" << screen->geometry();
+ debug << ", available=" << screen->availableGeometry();
debug << ", logical DPI=" << screen->logicalDotsPerInchX()
<< ',' << screen->logicalDotsPerInchY()
<< ", physical DPI=" << screen->physicalDotsPerInchX()
@@ -848,4 +782,60 @@ Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen)
}
#endif // !QT_NO_DEBUG_STREAM
+QScreenPrivate::UpdateEmitter::UpdateEmitter(QScreen *screen)
+{
+ initialState.platformScreen = screen->handle();
+
+ // Use public APIs to read out current state, rather
+ // than accessing the QScreenPrivate members, so that
+ // we detect any changes to the high-DPI scale factors
+ // that may be applied in the getters.
+
+ initialState.logicalDpi = QDpi{
+ screen->logicalDotsPerInchX(),
+ screen->logicalDotsPerInchY()
+ };
+ initialState.geometry = screen->geometry();
+ initialState.availableGeometry = screen->availableGeometry();
+ initialState.primaryOrientation = screen->primaryOrientation();
+}
+
+QScreenPrivate::UpdateEmitter::~UpdateEmitter()
+{
+ QScreen *screen = initialState.platformScreen->screen();
+
+ const auto logicalDotsPerInch = QDpi{
+ screen->logicalDotsPerInchX(),
+ screen->logicalDotsPerInchY()
+ };
+ if (logicalDotsPerInch != initialState.logicalDpi)
+ emit screen->logicalDotsPerInchChanged(screen->logicalDotsPerInch());
+
+ const auto geometry = screen->geometry();
+ const auto geometryChanged = geometry != initialState.geometry;
+ if (geometryChanged)
+ emit screen->geometryChanged(geometry);
+
+ const auto availableGeometry = screen->availableGeometry();
+ const auto availableGeometryChanged = availableGeometry != initialState.availableGeometry;
+ if (availableGeometryChanged)
+ emit screen->availableGeometryChanged(availableGeometry);
+
+ if (geometryChanged || availableGeometryChanged) {
+ const auto siblings = screen->virtualSiblings();
+ for (QScreen* sibling : siblings)
+ emit sibling->virtualGeometryChanged(sibling->virtualGeometry());
+ }
+
+ if (geometryChanged) {
+ emit screen->physicalDotsPerInchChanged(screen->physicalDotsPerInch());
+
+ const auto primaryOrientation = screen->primaryOrientation();
+ if (primaryOrientation != initialState.primaryOrientation)
+ emit screen->primaryOrientationChanged(primaryOrientation);
+ }
+}
+
QT_END_NAMESPACE
+
+#include "moc_qscreen.cpp"
diff --git a/src/gui/kernel/qscreen.h b/src/gui/kernel/qscreen.h
index 98271c0aa0..9442e7525b 100644
--- a/src/gui/kernel/qscreen.h
+++ b/src/gui/kernel/qscreen.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QSCREEN_H
#define QSCREEN_H
@@ -81,16 +45,20 @@ class Q_GUI_EXPORT QScreen : public QObject
Q_PROPERTY(QRect geometry READ geometry NOTIFY geometryChanged)
Q_PROPERTY(QRect availableGeometry READ availableGeometry NOTIFY availableGeometryChanged)
Q_PROPERTY(QRect virtualGeometry READ virtualGeometry NOTIFY virtualGeometryChanged)
- Q_PROPERTY(QRect availableVirtualGeometry READ availableVirtualGeometry NOTIFY virtualGeometryChanged)
+ Q_PROPERTY(QRect availableVirtualGeometry READ availableVirtualGeometry
+ NOTIFY virtualGeometryChanged)
Q_PROPERTY(QSizeF physicalSize READ physicalSize NOTIFY physicalSizeChanged)
- Q_PROPERTY(qreal physicalDotsPerInchX READ physicalDotsPerInchX NOTIFY physicalDotsPerInchChanged)
- Q_PROPERTY(qreal physicalDotsPerInchY READ physicalDotsPerInchY NOTIFY physicalDotsPerInchChanged)
+ Q_PROPERTY(qreal physicalDotsPerInchX READ physicalDotsPerInchX
+ NOTIFY physicalDotsPerInchChanged)
+ Q_PROPERTY(qreal physicalDotsPerInchY READ physicalDotsPerInchY
+ NOTIFY physicalDotsPerInchChanged)
Q_PROPERTY(qreal physicalDotsPerInch READ physicalDotsPerInch NOTIFY physicalDotsPerInchChanged)
Q_PROPERTY(qreal logicalDotsPerInchX READ logicalDotsPerInchX NOTIFY logicalDotsPerInchChanged)
Q_PROPERTY(qreal logicalDotsPerInchY READ logicalDotsPerInchY NOTIFY logicalDotsPerInchChanged)
Q_PROPERTY(qreal logicalDotsPerInch READ logicalDotsPerInch NOTIFY logicalDotsPerInchChanged)
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY physicalDotsPerInchChanged)
- Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation NOTIFY primaryOrientationChanged)
+ Q_PROPERTY(Qt::ScreenOrientation primaryOrientation READ primaryOrientation
+ NOTIFY primaryOrientationChanged)
Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged)
Q_PROPERTY(Qt::ScreenOrientation nativeOrientation READ nativeOrientation)
Q_PROPERTY(qreal refreshRate READ refreshRate NOTIFY refreshRateChanged)
@@ -149,7 +117,7 @@ public:
qreal refreshRate() const;
- QT_DECLARE_NATIVE_INTERFACE_ACCESSOR
+ QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QScreen)
Q_SIGNALS:
void geometryChanged(const QRect &geometry);
@@ -179,5 +147,7 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QScreen *);
QT_END_NAMESPACE
+#include <QtGui/qscreen_platform.h>
+
#endif // QSCREEN_H
diff --git a/src/gui/kernel/qscreen_p.h b/src/gui/kernel/qscreen_p.h
index 7543202c2f..964bc1cc58 100644
--- a/src/gui/kernel/qscreen_p.h
+++ b/src/gui/kernel/qscreen_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 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) 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 QSCREEN_P_H
#define QSCREEN_P_H
@@ -60,21 +24,8 @@
QT_BEGIN_NAMESPACE
-class QScreenPrivate : public QObjectPrivate
+struct QScreenData
{
- Q_DECLARE_PUBLIC(QScreen)
-public:
- void setPlatformScreen(QPlatformScreen *screen);
- void updateHighDpi()
- {
- geometry = platformScreen->deviceIndependentGeometry();
- availableGeometry = QHighDpi::fromNative(platformScreen->availableGeometry(), QHighDpiScaling::factor(platformScreen), geometry.topLeft());
- }
-
- void updatePrimaryOrientation();
- void updateGeometriesWithSignals();
- void emitGeometryChangeSignals(bool geometryChanged, bool availableGeometryChanged);
-
QPlatformScreen *platformScreen = nullptr;
Qt::ScreenOrientation orientation = Qt::PrimaryOrientation;
@@ -85,6 +36,25 @@ public:
qreal refreshRate = 60;
};
+class QScreenPrivate : public QObjectPrivate, public QScreenData
+{
+ Q_DECLARE_PUBLIC(QScreen)
+public:
+ void updateGeometry();
+ void updatePrimaryOrientation();
+
+ class UpdateEmitter
+ {
+ public:
+ explicit UpdateEmitter(QScreen *screen);
+ ~UpdateEmitter();
+ UpdateEmitter(UpdateEmitter&&) noexcept = default;
+ private:
+ Q_DISABLE_COPY(UpdateEmitter)
+ QScreenData initialState;
+ };
+};
+
QT_END_NAMESPACE
#endif // QSCREEN_P_H
diff --git a/src/gui/kernel/qscreen_platform.h b/src/gui/kernel/qscreen_platform.h
new file mode 100644
index 0000000000..6f40e9273f
--- /dev/null
+++ b/src/gui/kernel/qscreen_platform.h
@@ -0,0 +1,61 @@
+// Copyright (C) 2021 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 QSCREEN_PLATFORM_H
+#define QSCREEN_PLATFORM_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is part of the native interface APIs. Usage of
+// this API may make your code source and binary incompatible
+// with future versions of Qt.
+//
+
+#include <QtGui/qtguiglobal.h>
+
+#include <QtCore/qnativeinterface.h>
+#include <QtGui/qguiapplication.h>
+
+#if defined(Q_OS_WIN32)
+#include <QtGui/qwindowdefs_win.h>
+#endif
+
+#if QT_CONFIG(wayland)
+struct wl_output;
+#endif
+
+QT_BEGIN_NAMESPACE
+
+namespace QNativeInterface {
+
+#if defined(Q_OS_WIN32) || defined(Q_QDOC)
+struct Q_GUI_EXPORT QWindowsScreen
+{
+ QT_DECLARE_NATIVE_INTERFACE(QWindowsScreen, 1, QScreen)
+ virtual HMONITOR handle() const = 0;
+};
+#endif
+
+#if QT_CONFIG(wayland) || defined(Q_QDOC)
+struct Q_GUI_EXPORT QWaylandScreen
+{
+ QT_DECLARE_NATIVE_INTERFACE(QWaylandScreen, 1, QScreen)
+ virtual wl_output *output() const = 0;
+};
+#endif
+
+#if defined(Q_OS_ANDROID) || defined(Q_QDOC)
+struct Q_GUI_EXPORT QAndroidScreen
+{
+ QT_DECLARE_NATIVE_INTERFACE(QAndroidScreen, 1, QScreen)
+ virtual int displayId() const = 0;
+};
+#endif
+
+} // namespace QNativeInterface
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/gui/kernel/qsessionmanager.cpp b/src/gui/kernel/qsessionmanager.cpp
index 026e855874..0a1ff95656 100644
--- a/src/gui/kernel/qsessionmanager.cpp
+++ b/src/gui/kernel/qsessionmanager.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qsessionmanager.h>
#include <qguiapplication.h>
@@ -317,10 +281,6 @@ void QSessionManager::setRestartCommand(const QStringList &command)
/*!
Returns the currently set restart command.
- To iterate over the list, you can use the \l foreach pseudo-keyword:
-
- \snippet code/src_gui_kernel_qguiapplication.cpp 3
-
\sa setRestartCommand(), restartHint()
*/
QStringList QSessionManager::restartCommand() const
@@ -343,10 +303,6 @@ void QSessionManager::setDiscardCommand(const QStringList &command)
/*!
Returns the currently set discard command.
- To iterate over the list, you can use the \l foreach pseudo-keyword:
-
- \snippet code/src_gui_kernel_qguiapplication.cpp 4
-
\sa setDiscardCommand(), restartCommand(), setRestartCommand()
*/
QStringList QSessionManager::discardCommand() const
@@ -420,4 +376,6 @@ void QSessionManager::requestPhase2()
QT_END_NAMESPACE
+#include "moc_qsessionmanager.cpp"
+
#endif // QT_NO_SESSIONMANAGER
diff --git a/src/gui/kernel/qsessionmanager.h b/src/gui/kernel/qsessionmanager.h
index 21100b25d9..6015a0b378 100644
--- a/src/gui/kernel/qsessionmanager.h
+++ b/src/gui/kernel/qsessionmanager.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QSESSIONMANAGER_H
#define QSESSIONMANAGER_H
diff --git a/src/gui/kernel/qsessionmanager_p.h b/src/gui/kernel/qsessionmanager_p.h
index d07d9b5eb8..c98f7a5a1d 100644
--- a/src/gui/kernel/qsessionmanager_p.h
+++ b/src/gui/kernel/qsessionmanager_p.h
@@ -1,42 +1,6 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
-** Copyright (C) 2016 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) 2013 Samuel Gaist <samuel.gaist@edeltech.ch>
+// 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 QSESSIONMANAGER_P_H
#define QSESSIONMANAGER_P_H
@@ -63,7 +27,7 @@ QT_BEGIN_NAMESPACE
class QPlatformSessionManager;
-class QSessionManagerPrivate : public QObjectPrivate
+class Q_GUI_EXPORT QSessionManagerPrivate : public QObjectPrivate
{
public:
QSessionManagerPrivate(const QString &id,
diff --git a/src/gui/kernel/qshapedpixmapdndwindow.cpp b/src/gui/kernel/qshapedpixmapdndwindow.cpp
index e58d37693a..546a1a4937 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow.cpp
+++ b/src/gui/kernel/qshapedpixmapdndwindow.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qshapedpixmapdndwindow_p.h"
@@ -56,7 +20,7 @@ QShapedPixmapWindow::QShapedPixmapWindow(QScreen *screen)
QSurfaceFormat format;
format.setAlphaBufferSize(8);
setFormat(format);
- setFlags(Qt::ToolTip | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint
+ setFlags(Qt::FramelessWindowHint | Qt::BypassWindowManagerHint
| Qt::WindowTransparentForInput | Qt::WindowDoesNotAcceptFocus);
}
@@ -104,11 +68,11 @@ void QShapedPixmapWindow::updateGeometry(const QPoint &pos)
{
QSize size(1, 1);
if (!m_pixmap.isNull()) {
- size = qFuzzyCompare(m_pixmap.devicePixelRatio(), qreal(1.0))
- ? m_pixmap.size()
- : (QSizeF(m_pixmap.size()) / m_pixmap.devicePixelRatio()).toSize();
+ size = m_pixmap.deviceIndependentSize().toSize();
}
setGeometry(QRect(pos - m_hotSpot, size));
}
QT_END_NAMESPACE
+
+#include "moc_qshapedpixmapdndwindow_p.cpp"
diff --git a/src/gui/kernel/qshapedpixmapdndwindow_p.h b/src/gui/kernel/qshapedpixmapdndwindow_p.h
index 5089be7284..a2ce26a60e 100644
--- a/src/gui/kernel/qshapedpixmapdndwindow_p.h
+++ b/src/gui/kernel/qshapedpixmapdndwindow_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 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) 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 QSHAPEDPIXMAPDNDWINDOW_H
#define QSHAPEDPIXMAPDNDWINDOW_H
diff --git a/src/gui/kernel/qshortcut.cpp b/src/gui/kernel/qshortcut.cpp
index 524062ef30..3f6822cb03 100644
--- a/src/gui/kernel/qshortcut.cpp
+++ b/src/gui/kernel/qshortcut.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 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 "qshortcut_p.h"
@@ -132,7 +96,7 @@ QT_BEGIN_NAMESPACE
\sa activated()
*/
-static bool simpleContextMatcher(QObject *object, Qt::ShortcutContext context)
+bool QShortcutPrivate::simpleContextMatcher(QObject *object, Qt::ShortcutContext context)
{
auto guiShortcut = qobject_cast<QShortcut *>(object);
if (QGuiApplication::applicationState() != Qt::ApplicationActive || guiShortcut == nullptr)
@@ -163,14 +127,14 @@ void QShortcutPrivate::redoGrab(QShortcutMap &map)
return;
}
- for (int id : qAsConst(sc_ids))
+ for (int id : std::as_const(sc_ids))
map.removeShortcut(id, q);
sc_ids.clear();
if (sc_sequences.isEmpty())
return;
- sc_ids.reserve(sc_sequences.count());
- for (const auto &keySequence : qAsConst(sc_sequences)) {
+ sc_ids.reserve(sc_sequences.size());
+ for (const auto &keySequence : std::as_const(sc_sequences)) {
if (keySequence.isEmpty())
continue;
int id = map.addShortcut(q, keySequence, sc_context, contextMatcher());
@@ -373,7 +337,7 @@ QShortcut::~QShortcut()
{
Q_D(QShortcut);
if (qApp) {
- for (int id : qAsConst(d->sc_ids))
+ for (int id : std::as_const(d->sc_ids))
QGuiApplicationPrivate::instance()->shortcutMap.removeShortcut(id, this);
}
}
@@ -572,6 +536,8 @@ QString QShortcut::whatsThis() const
/*!
Returns the primary key binding's ID.
+ \deprecated
+
\sa QShortcutEvent::shortcutId()
*/
int QShortcut::id() const
diff --git a/src/gui/kernel/qshortcut.h b/src/gui/kernel/qshortcut.h
index d3db30fd4d..00b9168bea 100644
--- a/src/gui/kernel/qshortcut.h
+++ b/src/gui/kernel/qshortcut.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 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) 2019 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 QSHORTCUT_H
#define QSHORTCUT_H
@@ -68,7 +32,7 @@ public:
const char *member = nullptr, const char *ambiguousMember = nullptr,
Qt::ShortcutContext context = Qt::WindowShortcut);
-#ifdef Q_CLANG_QDOC
+#ifdef Q_QDOC
template<typename Functor>
QShortcut(const QKeySequence &key, QObject *parent,
Functor functor,
@@ -206,17 +170,18 @@ public:
bool autoRepeat() const;
#if QT_DEPRECATED_SINCE(6,0)
- Q_DECL_DEPRECATED int id() const;
+ QT_DEPRECATED_VERSION_6_0 int id() const;
#endif
void setWhatsThis(const QString &text);
QString whatsThis() const;
#if QT_DEPRECATED_SINCE(6,0)
-#ifdef Q_CLANG_QDOC
+#ifdef Q_QDOC
QWidget *parentWidget() const;
#else
template<typename T = QWidget*>
+ QT_DEPRECATED_VERSION_X_6_0("Use parent() and qobject_cast instead")
inline T parentWidget() const
{ return static_cast<T>(QObject::parent()); }
#endif
diff --git a/src/gui/kernel/qshortcut_p.h b/src/gui/kernel/qshortcut_p.h
index f62bab0297..8ff833d477 100644
--- a/src/gui/kernel/qshortcut_p.h
+++ b/src/gui/kernel/qshortcut_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 QSHORTCUT_P_H
#define QSHORTCUT_P_H
@@ -79,6 +43,8 @@ public:
virtual QShortcutMap::ContextMatcher contextMatcher() const;
virtual bool handleWhatsThis() { return false; }
+ static bool simpleContextMatcher(QObject *object, Qt::ShortcutContext context);
+
QList<QKeySequence> sc_sequences;
QString sc_whatsthis;
Qt::ShortcutContext sc_context = Qt::WindowShortcut;
diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp
index cf729d28c4..800e703ac2 100644
--- a/src/gui/kernel/qshortcutmap.cpp
+++ b/src/gui/kernel/qshortcutmap.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qshortcutmap_p.h"
#include "private/qobject_p.h"
@@ -65,23 +29,23 @@ Q_LOGGING_CATEGORY(lcShortcutMap, "qt.gui.shortcutmap")
struct QShortcutEntry
{
QShortcutEntry()
- : keyseq(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr)
+ : keySequence(0), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr)
{}
QShortcutEntry(const QKeySequence &k)
- : keyseq(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr)
+ : keySequence(k), context(Qt::WindowShortcut), enabled(false), autorepeat(1), id(0), owner(nullptr), contextMatcher(nullptr)
{}
QShortcutEntry(QObject *o, const QKeySequence &k, Qt::ShortcutContext c, int i, bool a, QShortcutMap::ContextMatcher m)
- : keyseq(k), context(c), enabled(true), autorepeat(a), id(i), owner(o), contextMatcher(m)
+ : keySequence(k), context(c), enabled(true), autorepeat(a), id(i), owner(o), contextMatcher(m)
{}
bool correctContext() const { return contextMatcher(owner, context); }
bool operator<(const QShortcutEntry &f) const
- { return keyseq < f.keyseq; }
+ { return keySequence < f.keySequence; }
- QKeySequence keyseq;
+ QKeySequence keySequence;
Qt::ShortcutContext context;
bool enabled : 1;
bool autorepeat : 1;
@@ -124,7 +88,7 @@ public:
}
QShortcutMap *q_ptr; // Private's parent
- QList<QShortcutEntry> sequences; // All sequences!
+ QList<QShortcutEntry> shortcuts; // All shortcuts!
int currentId; // Global shortcut ID number
int ambigCount; // Index of last enabled ambiguous dispatch
@@ -156,18 +120,18 @@ QShortcutMap::~QShortcutMap()
Adds a shortcut to the global map.
Returns the id of the newly added shortcut.
*/
-int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::ShortcutContext context, ContextMatcher matcher)
+int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &keySequence, Qt::ShortcutContext context, ContextMatcher matcher)
{
Q_ASSERT_X(owner, "QShortcutMap::addShortcut", "All shortcuts need an owner");
- Q_ASSERT_X(!key.isEmpty(), "QShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
+ Q_ASSERT_X(!keySequence.isEmpty(), "QShortcutMap::addShortcut", "Cannot add keyless shortcuts to map");
Q_D(QShortcutMap);
- QShortcutEntry newEntry(owner, key, context, --(d->currentId), true, matcher);
- const auto it = std::upper_bound(d->sequences.begin(), d->sequences.end(), newEntry);
- d->sequences.insert(it, newEntry); // Insert sorted
+ QShortcutEntry newEntry(owner, keySequence, context, --(d->currentId), true, matcher);
+ const auto it = std::upper_bound(d->shortcuts.begin(), d->shortcuts.end(), newEntry);
+ d->shortcuts.insert(it, newEntry); // Insert sorted
qCDebug(lcShortcutMap).nospace()
<< "QShortcutMap::addShortcut(" << owner << ", "
- << key << ", " << context << ") added shortcut with ID " << d->currentId;
+ << keySequence << ", " << context << ") added shortcut with ID " << d->currentId;
return d->currentId;
}
@@ -180,36 +144,36 @@ int QShortcutMap::addShortcut(QObject *owner, const QKeySequence &key, Qt::Short
Returns the number of sequences removed from the map.
*/
-int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key)
+int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &keySequence)
{
Q_D(QShortcutMap);
int itemsRemoved = 0;
bool allOwners = (owner == nullptr);
- bool allKeys = key.isEmpty();
+ bool allKeys = keySequence.isEmpty();
bool allIds = id == 0;
auto debug = qScopeGuard([&](){
qCDebug(lcShortcutMap).nospace()
<< "QShortcutMap::removeShortcut(" << id << ", " << owner << ", "
- << key << ") removed " << itemsRemoved << " shortcuts(s)";
+ << keySequence << ") removed " << itemsRemoved << " shortcuts(s)";
});
// Special case, remove everything
if (allOwners && allKeys && allIds) {
- itemsRemoved = d->sequences.size();
- d->sequences.clear();
+ itemsRemoved = d->shortcuts.size();
+ d->shortcuts.clear();
return itemsRemoved;
}
- int i = d->sequences.size()-1;
+ int i = d->shortcuts.size()-1;
while (i>=0)
{
- const QShortcutEntry &entry = d->sequences.at(i);
+ const QShortcutEntry &entry = d->shortcuts.at(i);
int entryId = entry.id;
if ((allOwners || entry.owner == owner)
&& (allIds || entry.id == id)
- && (allKeys || entry.keyseq == key)) {
- d->sequences.removeAt(i);
+ && (allKeys || entry.keySequence == keySequence)) {
+ d->shortcuts.removeAt(i);
++itemsRemoved;
}
if (id == entryId)
@@ -227,22 +191,22 @@ int QShortcutMap::removeShortcut(int id, QObject *owner, const QKeySequence &key
are changed.
Returns the number of sequences which are matched in the map.
*/
-int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &key)
+int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const QKeySequence &keySequence)
{
Q_D(QShortcutMap);
int itemsChanged = 0;
bool allOwners = (owner == nullptr);
- bool allKeys = key.isEmpty();
+ bool allKeys = keySequence.isEmpty();
bool allIds = id == 0;
- int i = d->sequences.size()-1;
+ int i = d->shortcuts.size()-1;
while (i>=0)
{
- QShortcutEntry entry = d->sequences.at(i);
+ QShortcutEntry entry = d->shortcuts.at(i);
if ((allOwners || entry.owner == owner)
&& (allIds || entry.id == id)
- && (allKeys || entry.keyseq == key)) {
- d->sequences[i].enabled = enable;
+ && (allKeys || entry.keySequence == keySequence)) {
+ d->shortcuts[i].enabled = enable;
++itemsChanged;
}
if (id == entry.id)
@@ -251,7 +215,7 @@ int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const
}
qCDebug(lcShortcutMap).nospace()
<< "QShortcutMap::setShortcutEnabled(" << enable << ", " << id << ", "
- << owner << ", " << key << ") = " << itemsChanged;
+ << owner << ", " << keySequence << ") = " << itemsChanged;
return itemsChanged;
}
@@ -263,22 +227,22 @@ int QShortcutMap::setShortcutEnabled(bool enable, int id, QObject *owner, const
are changed.
Returns the number of sequences which are matched in the map.
*/
-int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &key)
+int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const QKeySequence &keySequence)
{
Q_D(QShortcutMap);
int itemsChanged = 0;
bool allOwners = (owner == nullptr);
- bool allKeys = key.isEmpty();
+ bool allKeys = keySequence.isEmpty();
bool allIds = id == 0;
- int i = d->sequences.size()-1;
+ int i = d->shortcuts.size()-1;
while (i>=0)
{
- QShortcutEntry entry = d->sequences.at(i);
+ QShortcutEntry entry = d->shortcuts.at(i);
if ((allOwners || entry.owner == owner)
&& (allIds || entry.id == id)
- && (allKeys || entry.keyseq == key)) {
- d->sequences[i].autorepeat = on;
+ && (allKeys || entry.keySequence == keySequence)) {
+ d->shortcuts[i].autorepeat = on;
++itemsChanged;
}
if (id == entry.id)
@@ -287,7 +251,7 @@ int QShortcutMap::setShortcutAutoRepeat(bool on, int id, QObject *owner, const Q
}
qCDebug(lcShortcutMap).nospace()
<< "QShortcutMap::setShortcutAutoRepeat(" << on << ", " << id << ", "
- << owner << ", " << key << ") = " << itemsChanged;
+ << owner << ", " << keySequence << ") = " << itemsChanged;
return itemsChanged;
}
@@ -341,7 +305,7 @@ bool QShortcutMap::tryShortcut(QKeyEvent *e)
case QKeySequence::ExactMatch: {
// Save number of identical matches before dispatching
// to keep QShortcutMap and tryShortcut reentrant.
- const int identicalMatches = d->identicals.count();
+ const int identicalMatches = d->identicals.size();
resetState();
dispatchEvent(e);
// If there are no identicals we've only found disabled shortcuts, and
@@ -349,8 +313,7 @@ bool QShortcutMap::tryShortcut(QKeyEvent *e)
return identicalMatches > 0;
}
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
/*! \internal
@@ -396,17 +359,18 @@ QKeySequence::SequenceMatch QShortcutMap::nextState(QKeyEvent *e)
/*! \internal
- Determines if an enabled shortcut has a matcing key sequence.
+ Determines if an enabled shortcut has a matching key sequence.
*/
bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const
{
Q_D(const QShortcutMap);
QShortcutEntry entry(seq); // needed for searching
- const auto itEnd = d->sequences.cend();
- auto it = std::lower_bound(d->sequences.cbegin(), itEnd, entry);
+ const auto itEnd = d->shortcuts.cend();
+ auto it = std::lower_bound(d->shortcuts.cbegin(), itEnd, entry);
for (;it != itEnd; ++it) {
- if (matches(entry.keyseq, (*it).keyseq) == QKeySequence::ExactMatch && (*it).correctContext() && (*it).enabled) {
+ if (entry.keySequence.matches(it->keySequence) == QKeySequence::ExactMatch
+ && (*it).correctContext() && (*it).enabled) {
return true;
}
}
@@ -425,15 +389,15 @@ bool QShortcutMap::hasShortcutForKeySequence(const QKeySequence &seq) const
QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifiers)
{
Q_D(QShortcutMap);
- if (!d->sequences.count())
+ if (!d->shortcuts.size())
return QKeySequence::NoMatch;
createNewSequences(e, d->newEntries, ignoredModifiers);
- qCDebug(lcShortcutMap) << "Possible shortcut key sequences:" << d->newEntries;
+ qCDebug(lcShortcutMap) << "Possible input sequences:" << d->newEntries;
// Should never happen
if (d->newEntries == d->currentSequences) {
- Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().length(),
+ Q_ASSERT_X(e->key() != Qt::Key_unknown || e->text().size(),
"QShortcutMap::find", "New sequence to find identical to previous");
return QKeySequence::NoMatch;
}
@@ -444,26 +408,33 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier
bool partialFound = false;
bool identicalDisabledFound = false;
QList<QKeySequence> okEntries;
- int result = QKeySequence::NoMatch;
- for (int i = d->newEntries.count()-1; i >= 0 ; --i) {
+ QKeySequence::SequenceMatch result = QKeySequence::NoMatch;
+ for (int i = d->newEntries.size()-1; i >= 0 ; --i) {
QShortcutEntry entry(d->newEntries.at(i)); // needed for searching
- const auto itEnd = d->sequences.constEnd();
- auto it = std::lower_bound(d->sequences.constBegin(), itEnd, entry);
+ qCDebug(lcShortcutMap) << "Looking for shortcuts matching" << entry.keySequence;
+
+ QKeySequence::SequenceMatch bestMatchForEntry = QKeySequence::NoMatch;
- int oneKSResult = QKeySequence::NoMatch;
- int tempRes = QKeySequence::NoMatch;
- do {
- if (it == itEnd)
+ const auto itEnd = d->shortcuts.constEnd();
+ auto it = std::lower_bound(d->shortcuts.constBegin(), itEnd, entry);
+ for (; it != itEnd; ++it) {
+ QKeySequence::SequenceMatch match = entry.keySequence.matches(it->keySequence);
+ qCDebug(lcShortcutMap) << " -" << match << "for shortcut" << it->keySequence;
+
+ // If we got a valid match, there might still be more keys to check against,
+ // but if we get no match, we know that there are no more possible matches.
+ if (match == QKeySequence::NoMatch)
break;
- tempRes = matches(entry.keyseq, (*it).keyseq);
- oneKSResult = qMax(oneKSResult, tempRes);
- if (tempRes != QKeySequence::NoMatch && (*it).correctContext()) {
- if (tempRes == QKeySequence::ExactMatch) {
+
+ bestMatchForEntry = qMax(bestMatchForEntry, match);
+
+ if ((*it).correctContext()) {
+ if (match == QKeySequence::ExactMatch) {
if ((*it).enabled)
d->identicals.append(&*it);
else
identicalDisabledFound = true;
- } else if (tempRes == QKeySequence::PartialMatch) {
+ } else if (match == QKeySequence::PartialMatch) {
// We don't need partials, if we have identicals
if (d->identicals.size())
break;
@@ -471,20 +442,18 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier
// key events when all partials are disabled!
partialFound |= (*it).enabled;
}
+ } else {
+ qCDebug(lcShortcutMap) << " - But context was not correct";
}
- ++it;
- // If we got a valid match on this run, there might still be more keys to check against,
- // so we'll loop once more. If we get NoMatch, there's guaranteed no more possible
- // matches in the shortcutmap.
- } while (tempRes != QKeySequence::NoMatch);
+ }
// If the type of match improves (ergo, NoMatch->Partial, or Partial->Exact), clear the
// previous list. If this match is equal or better than the last match, append to the list
- if (oneKSResult > result) {
+ if (bestMatchForEntry > result) {
okEntries.clear();
qCDebug(lcShortcutMap) << "Found better match (" << d->newEntries << "), clearing key sequence list";
}
- if (oneKSResult && oneKSResult >= result) {
+ if (bestMatchForEntry && bestMatchForEntry >= result) {
okEntries << d->newEntries.at(i);
qCDebug(lcShortcutMap) << "Added ok key sequence" << d->newEntries;
}
@@ -503,7 +472,7 @@ QKeySequence::SequenceMatch QShortcutMap::find(QKeyEvent *e, int ignoredModifier
if (result != QKeySequence::NoMatch)
d->currentSequences = okEntries;
qCDebug(lcShortcutMap) << "Returning shortcut match == " << result;
- return QKeySequence::SequenceMatch(result);
+ return result;
}
/*! \internal
@@ -524,14 +493,14 @@ void QShortcutMap::clearSequence(QList<QKeySequence> &ksl)
void QShortcutMap::createNewSequences(QKeyEvent *e, QList<QKeySequence> &ksl, int ignoredModifiers)
{
Q_D(QShortcutMap);
- QList<int> possibleKeys = QKeyMapper::possibleKeys(e);
+ QList<QKeyCombination> possibleKeys = QKeyMapper::possibleKeys(e);
qCDebug(lcShortcutMap) << "Creating new sequences for" << e
<< "with ignoredModifiers=" << Qt::KeyboardModifiers(ignoredModifiers);
- int pkTotal = possibleKeys.count();
+ int pkTotal = possibleKeys.size();
if (!pkTotal)
return;
- int ssActual = d->currentSequences.count();
+ int ssActual = d->currentSequences.size();
int ssTotal = qMax(1, ssActual);
// Resize to possible permutations of the current sequence(s).
ksl.resize(pkTotal * ssTotal);
@@ -553,46 +522,13 @@ void QShortcutMap::createNewSequences(QKeyEvent *e, QList<QKeySequence> &ksl, in
curKsl.setKey(QKeyCombination::fromCombined(0), 2);
curKsl.setKey(QKeyCombination::fromCombined(0), 3);
}
- curKsl.setKey(QKeyCombination::fromCombined(possibleKeys.at(pkNum) & ~ignoredModifiers), index);
+ const int key = possibleKeys.at(pkNum).toCombined();
+ curKsl.setKey(QKeyCombination::fromCombined(key & ~ignoredModifiers), index);
}
}
}
/*! \internal
- Basically the same function as QKeySequence::matches(const QKeySequence &seq) const
- only that is specially handles Key_hyphen as Key_Minus, as people mix these up all the time and
- they conceptually the same.
-*/
-QKeySequence::SequenceMatch QShortcutMap::matches(const QKeySequence &seq1,
- const QKeySequence &seq2) const
-{
- uint userN = seq1.count(),
- seqN = seq2.count();
-
- if (userN > seqN)
- return QKeySequence::NoMatch;
-
- // If equal in length, we have a potential ExactMatch sequence,
- // else we already know it can only be partial.
- QKeySequence::SequenceMatch match = (userN == seqN
- ? QKeySequence::ExactMatch
- : QKeySequence::PartialMatch);
-
- for (uint i = 0; i < userN; ++i) {
- int userKey = seq1[i].toCombined(),
- sequenceKey = seq2[i].toCombined();
- if ((userKey & Qt::Key_unknown) == Qt::Key_hyphen)
- userKey = (userKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
- if ((sequenceKey & Qt::Key_unknown) == Qt::Key_hyphen)
- sequenceKey = (sequenceKey & Qt::KeyboardModifierMask) | Qt::Key_Minus;
- if (userKey != sequenceKey)
- return QKeySequence::NoMatch;
- }
- return match;
-}
-
-
-/*! \internal
Converts keyboard button states into modifier states
*/
int QShortcutMap::translateModifiers(Qt::KeyboardModifiers modifiers)
@@ -627,7 +563,7 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
if (!d->identicals.size())
return;
- const QKeySequence &curKey = d->identicals.at(0)->keyseq;
+ const QKeySequence &curKey = d->identicals.at(0)->keySequence;
if (d->prevSequence != curKey) {
d->ambigCount = 0;
d->prevSequence = curKey;
@@ -657,16 +593,16 @@ void QShortcutMap::dispatchEvent(QKeyEvent *e)
if (lcShortcutMap().isDebugEnabled()) {
if (ambiguousShortcuts.size() > 1) {
qCDebug(lcShortcutMap) << "The following shortcuts are about to be activated ambiguously:";
- for (const QShortcutEntry *entry : qAsConst(ambiguousShortcuts))
- qCDebug(lcShortcutMap).nospace() << "- " << entry->keyseq << " (belonging to " << entry->owner << ")";
+ for (const QShortcutEntry *entry : std::as_const(ambiguousShortcuts))
+ qCDebug(lcShortcutMap).nospace() << "- " << entry->keySequence << " (belonging to " << entry->owner << ")";
}
qCDebug(lcShortcutMap).nospace()
<< "QShortcutMap::dispatchEvent(): Sending QShortcutEvent(\""
- << next->keyseq.toString() << "\", " << next->id << ", "
+ << next->keySequence.toString() << "\", " << next->id << ", "
<< static_cast<bool>(enabledShortcuts>1) << ") to object(" << next->owner << ')';
}
- QShortcutEvent se(next->keyseq, next->id, enabledShortcuts>1);
+ QShortcutEvent se(next->keySequence, next->id, enabledShortcuts > 1);
QCoreApplication::sendEvent(const_cast<QObject *>(next->owner), &se);
}
@@ -674,7 +610,7 @@ QList<QKeySequence> QShortcutMap::keySequences(bool getAll) const
{
Q_D(const QShortcutMap);
QList<QKeySequence> keys;
- for (auto sequence : d->sequences) {
+ for (auto sequence : d->shortcuts) {
bool addSequence = false;
if (sequence.enabled) {
if (getAll || sequence.context == Qt::ApplicationShortcut ||
@@ -703,7 +639,7 @@ QList<QKeySequence> QShortcutMap::keySequences(bool getAll) const
}
}
if (addSequence)
- keys << sequence.keyseq;
+ keys << sequence.keySequence;
}
}
return keys;
@@ -718,8 +654,8 @@ QList<QKeySequence> QShortcutMap::keySequences(bool getAll) const
void QShortcutMap::dumpMap() const
{
Q_D(const QShortcutMap);
- for (int i = 0; i < d->sequences.size(); ++i)
- qDebug().nospace() << &(d->sequences.at(i));
+ for (int i = 0; i < d->shortcuts.size(); ++i)
+ qDebug().nospace() << &(d->shortcuts.at(i));
}
#endif
diff --git a/src/gui/kernel/qshortcutmap_p.h b/src/gui/kernel/qshortcutmap_p.h
index 287549ea3a..26d2b5301c 100644
--- a/src/gui/kernel/qshortcutmap_p.h
+++ b/src/gui/kernel/qshortcutmap_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 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) 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 QSHORTCUTMAP_P_H
#define QSHORTCUTMAP_P_H
@@ -98,7 +62,6 @@ private:
void dispatchEvent(QKeyEvent *e);
QKeySequence::SequenceMatch find(QKeyEvent *e, int ignoredModifiers = 0);
- QKeySequence::SequenceMatch matches(const QKeySequence &seq1, const QKeySequence &seq2) const;
QList<const QShortcutEntry *> matches() const;
void createNewSequences(QKeyEvent *e, QList<QKeySequence> &ksl, int ignoredModifiers);
void clearSequence(QList<QKeySequence> &ksl);
diff --git a/src/gui/kernel/qsimpledrag.cpp b/src/gui/kernel/qsimpledrag.cpp
index a02efd5a7a..a90e8dd33c 100644
--- a/src/gui/kernel/qsimpledrag.cpp
+++ b/src/gui/kernel/qsimpledrag.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qsimpledrag_p.h"
@@ -70,9 +34,10 @@ Q_LOGGING_CATEGORY(lcDnd, "qt.gui.dnd")
static QWindow* topLevelAt(const QPoint &pos)
{
- QWindowList list = QGuiApplication::topLevelWindows();
- for (int i = list.count()-1; i >= 0; --i) {
- QWindow *w = list.at(i);
+ const QWindowList list = QGuiApplication::topLevelWindows();
+ const auto crend = list.crend();
+ for (auto it = list.crbegin(); it != crend; ++it) {
+ QWindow *w = *it;
if (w->isVisible() && w->handle() && w->geometry().contains(pos) && !qobject_cast<QShapedPixmapWindow*>(w))
return w;
}
@@ -160,6 +125,7 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
}
case QEvent::MouseButtonRelease:
{
+ QPointer<QObject> objGuard(o);
disableEventFilter();
if (canDrop()) {
QPoint nativePosition = getNativeMousePos(e, m_drag_icon_window);
@@ -169,6 +135,8 @@ bool QBasicDrag::eventFilter(QObject *o, QEvent *e)
cancel();
}
exitDndEventLoop();
+ if (!objGuard)
+ return true;
// If a QShapedPixmapWindow (drag feedback) is being dragged along, the
// mouse event's localPos() will be relative to that, which is useless.
@@ -342,7 +310,7 @@ static inline QPoint fromNativeGlobalPixels(const QPoint &point)
#ifndef QT_NO_HIGHDPISCALING
QPoint res = point;
if (QHighDpiScaling::isActive()) {
- for (const QScreen *s : qAsConst(QGuiApplicationPrivate::screen_list)) {
+ for (const QScreen *s : std::as_const(QGuiApplicationPrivate::screen_list)) {
if (s->handle()->geometry().contains(point)) {
res = QHighDpi::fromNativePixels(point, s);
break;
diff --git a/src/gui/kernel/qsimpledrag_p.h b/src/gui/kernel/qsimpledrag_p.h
index 4409deb1da..32ba1cef6f 100644
--- a/src/gui/kernel/qsimpledrag_p.h
+++ b/src/gui/kernel/qsimpledrag_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 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) 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 QSIMPLEDRAG_P_H
#define QSIMPLEDRAG_P_H
diff --git a/src/gui/kernel/qstylehints.cpp b/src/gui/kernel/qstylehints.cpp
index 7b3c70c51b..5029701f24 100644
--- a/src/gui/kernel/qstylehints.cpp
+++ b/src/gui/kernel/qstylehints.cpp
@@ -1,43 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 <qstylehints.h>
+#include "qstylehints_p.h"
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformtheme.h>
#include <private/qguiapplication_p.h>
@@ -79,25 +44,6 @@ static inline QVariant themeableHint(QPlatformTheme::ThemeHint th)
return QPlatformTheme::defaultThemeHint(th);
}
-class QStyleHintsPrivate : public QObjectPrivate
-{
- Q_DECLARE_PUBLIC(QStyleHints)
-public:
- int m_mouseDoubleClickInterval = -1;
- int m_mousePressAndHoldInterval = -1;
- int m_startDragDistance = -1;
- int m_startDragTime = -1;
- int m_keyboardInputInterval = -1;
- int m_cursorFlashTime = -1;
- int m_tabFocusBehavior = -1;
- int m_uiEffects = -1;
- int m_showShortcutsInContextMenus = -1;
- int m_wheelScrollLines = -1;
- int m_mouseQuickSelectionThreshold = -1;
- int m_mouseDoubleClickDistance = -1;
- int m_touchDoubleTapDistance = -1;
-};
-
/*!
\class QStyleHints
\since 5.0
@@ -107,11 +53,10 @@ public:
An object of this class, obtained from QGuiApplication, provides access to certain global
user interface parameters of the current platform.
- Access is read only; typically the platform itself provides the user a way to tune these
- parameters.
-
- Access to these parameters are useful when implementing custom user interface components, in that
- they allow the components to exhibit the same behaviour and feel as other components.
+ Access to most settings is read only. The platform itself usually provides the user with
+ ways to tune these parameters. Authors of custom user interface components should read
+ relevant settings to allow the components to exhibit the same behavior and feel as other
+ components.
\sa QGuiApplication::styleHints()
*/
@@ -159,7 +104,7 @@ int QStyleHints::mouseDoubleClickDistance() const
Q_D(const QStyleHints);
return d->m_mouseDoubleClickDistance >= 0 ?
d->m_mouseDoubleClickDistance :
- themeableHint(QPlatformTheme::MouseDoubleClickDistance).toInt();
+ themeableHint(QPlatformTheme::MouseDoubleClickDistance, QPlatformIntegration::MouseDoubleClickDistance).toInt();
}
/*!
@@ -177,6 +122,18 @@ int QStyleHints::touchDoubleTapDistance() const
}
/*!
+ \property QStyleHints::colorScheme
+ \brief the color scheme of the platform theme.
+ \sa Qt::ColorScheme
+ \since 6.5
+*/
+Qt::ColorScheme QStyleHints::colorScheme() const
+{
+ Q_D(const QStyleHints);
+ return d->colorScheme();
+}
+
+/*!
Sets the \a mousePressAndHoldInterval.
\internal
\sa mousePressAndHoldInterval()
@@ -322,15 +279,29 @@ int QStyleHints::keyboardInputInterval() const
themeableHint(QPlatformTheme::KeyboardInputInterval, QPlatformIntegration::KeyboardInputInterval).toInt();
}
+#if QT_DEPRECATED_SINCE(6, 5)
/*!
\property QStyleHints::keyboardAutoRepeatRate
\brief the rate, in events per second, in which additional repeated key
presses will automatically be generated if a key is being held down.
+ \deprecated [6.5] Use keyboardAutoRepeatRateF() instead
*/
int QStyleHints::keyboardAutoRepeatRate() const
{
return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toInt();
}
+#endif
+
+/*!
+ \property QStyleHints::keyboardAutoRepeatRateF
+ \since 6.5
+ \brief the rate, in events per second, in which additional repeated key
+ presses will automatically be generated if a key is being held down.
+*/
+qreal QStyleHints::keyboardAutoRepeatRateF() const
+{
+ return themeableHint(QPlatformTheme::KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardAutoRepeatRate).toReal();
+}
/*!
Sets the \a cursorFlashTime.
@@ -406,6 +377,8 @@ bool QStyleHints::showIsMaximized() const
Since Qt 5.13, the setShowShortcutsInContextMenus() function can be used to
override the platform default.
+
+ \sa Qt::AA_DontShowShortcutsInContextMenus
*/
bool QStyleHints::showShortcutsInContextMenus() const
{
@@ -476,7 +449,7 @@ bool QStyleHints::useRtlExtensions() const
*/
bool QStyleHints::setFocusOnTouchRelease() const
{
- return hint(QPlatformIntegration::SetFocusOnTouchRelease).toBool();
+ return themeableHint(QPlatformTheme::SetFocusOnTouchRelease, QPlatformIntegration::SetFocusOnTouchRelease).toBool();
}
/*!
@@ -620,4 +593,31 @@ int QStyleHints::mouseQuickSelectionThreshold() const
return themeableHint(QPlatformTheme::MouseQuickSelectionThreshold, QPlatformIntegration::MouseQuickSelectionThreshold).toInt();
}
+/*!
+ \internal
+ QStyleHintsPrivate::updateColorScheme - set a new color scheme.
+
+ This function is called by the QPA plugin when the system theme changes. This in
+ turn might be the result of an explicit request of a color scheme via setColorScheme.
+
+ Set \a colorScheme as the new color scheme of the QStyleHints.
+ The colorSchemeChanged signal will be emitted if present and new color scheme differ.
+ */
+void QStyleHintsPrivate::updateColorScheme(Qt::ColorScheme colorScheme)
+{
+ if (m_colorScheme == colorScheme)
+ return;
+ m_colorScheme = colorScheme;
+ Q_Q(QStyleHints);
+ emit q->colorSchemeChanged(colorScheme);
+}
+
+QStyleHintsPrivate *QStyleHintsPrivate::get(QStyleHints *q)
+{
+ Q_ASSERT(q);
+ return q->d_func();
+}
+
QT_END_NAMESPACE
+
+#include "moc_qstylehints.cpp"
diff --git a/src/gui/kernel/qstylehints.h b/src/gui/kernel/qstylehints.h
index 30d8fdc64d..969bec4b35 100644
--- a/src/gui/kernel/qstylehints.h
+++ b/src/gui/kernel/qstylehints.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QSTYLEHINTS_H
#define QSTYLEHINTS_H
@@ -55,27 +19,40 @@ class Q_GUI_EXPORT QStyleHints : public QObject
Q_DECLARE_PRIVATE(QStyleHints)
Q_PROPERTY(int cursorFlashTime READ cursorFlashTime NOTIFY cursorFlashTimeChanged FINAL)
Q_PROPERTY(qreal fontSmoothingGamma READ fontSmoothingGamma STORED false CONSTANT FINAL)
+#if QT_DEPRECATED_SINCE(6, 5)
Q_PROPERTY(int keyboardAutoRepeatRate READ keyboardAutoRepeatRate STORED false CONSTANT FINAL)
- Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval NOTIFY keyboardInputIntervalChanged FINAL)
- Q_PROPERTY(int mouseDoubleClickInterval READ mouseDoubleClickInterval NOTIFY mouseDoubleClickIntervalChanged FINAL)
- Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval NOTIFY mousePressAndHoldIntervalChanged FINAL)
+#endif
+ Q_PROPERTY(qreal keyboardAutoRepeatRateF READ keyboardAutoRepeatRateF STORED false CONSTANT FINAL)
+ Q_PROPERTY(int keyboardInputInterval READ keyboardInputInterval
+ NOTIFY keyboardInputIntervalChanged FINAL)
+ Q_PROPERTY(int mouseDoubleClickInterval READ mouseDoubleClickInterval
+ NOTIFY mouseDoubleClickIntervalChanged FINAL)
+ Q_PROPERTY(int mousePressAndHoldInterval READ mousePressAndHoldInterval
+ NOTIFY mousePressAndHoldIntervalChanged FINAL)
Q_PROPERTY(QChar passwordMaskCharacter READ passwordMaskCharacter STORED false CONSTANT FINAL)
Q_PROPERTY(int passwordMaskDelay READ passwordMaskDelay STORED false CONSTANT FINAL)
Q_PROPERTY(bool setFocusOnTouchRelease READ setFocusOnTouchRelease STORED false CONSTANT FINAL)
Q_PROPERTY(bool showIsFullScreen READ showIsFullScreen STORED false CONSTANT FINAL)
Q_PROPERTY(bool showIsMaximized READ showIsMaximized STORED false CONSTANT FINAL)
- Q_PROPERTY(bool showShortcutsInContextMenus READ showShortcutsInContextMenus WRITE setShowShortcutsInContextMenus NOTIFY showShortcutsInContextMenusChanged FINAL)
+ Q_PROPERTY(bool showShortcutsInContextMenus READ showShortcutsInContextMenus
+ WRITE setShowShortcutsInContextMenus NOTIFY showShortcutsInContextMenusChanged FINAL)
Q_PROPERTY(int startDragDistance READ startDragDistance NOTIFY startDragDistanceChanged FINAL)
Q_PROPERTY(int startDragTime READ startDragTime NOTIFY startDragTimeChanged FINAL)
Q_PROPERTY(int startDragVelocity READ startDragVelocity STORED false CONSTANT FINAL)
Q_PROPERTY(bool useRtlExtensions READ useRtlExtensions STORED false CONSTANT FINAL)
- Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior NOTIFY tabFocusBehaviorChanged FINAL)
+ Q_PROPERTY(Qt::TabFocusBehavior tabFocusBehavior READ tabFocusBehavior
+ NOTIFY tabFocusBehaviorChanged FINAL)
Q_PROPERTY(bool singleClickActivation READ singleClickActivation STORED false CONSTANT FINAL)
- Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects NOTIFY useHoverEffectsChanged FINAL)
+ Q_PROPERTY(bool useHoverEffects READ useHoverEffects WRITE setUseHoverEffects
+ NOTIFY useHoverEffectsChanged FINAL)
Q_PROPERTY(int wheelScrollLines READ wheelScrollLines NOTIFY wheelScrollLinesChanged FINAL)
- Q_PROPERTY(int mouseQuickSelectionThreshold READ mouseQuickSelectionThreshold WRITE setMouseQuickSelectionThreshold NOTIFY mouseQuickSelectionThresholdChanged FINAL)
- Q_PROPERTY(int mouseDoubleClickDistance READ mouseDoubleClickDistance STORED false CONSTANT FINAL)
+ Q_PROPERTY(int mouseQuickSelectionThreshold READ mouseQuickSelectionThreshold
+ WRITE setMouseQuickSelectionThreshold NOTIFY mouseQuickSelectionThresholdChanged
+ FINAL)
+ Q_PROPERTY(int mouseDoubleClickDistance READ mouseDoubleClickDistance STORED false CONSTANT
+ FINAL)
Q_PROPERTY(int touchDoubleTapDistance READ touchDoubleTapDistance STORED false CONSTANT FINAL)
+ Q_PROPERTY(Qt::ColorScheme colorScheme READ colorScheme NOTIFY colorSchemeChanged FINAL)
public:
void setMouseDoubleClickInterval(int mouseDoubleClickInterval);
@@ -91,7 +68,11 @@ public:
int startDragVelocity() const;
void setKeyboardInputInterval(int keyboardInputInterval);
int keyboardInputInterval() const;
+#if QT_DEPRECATED_SINCE(6, 5)
+ QT_DEPRECATED_VERSION_X_6_5("Use keyboardAutoRepeatRateF() instead")
int keyboardAutoRepeatRate() const;
+#endif
+ qreal keyboardAutoRepeatRateF() const;
void setCursorFlashTime(int cursorFlashTime);
int cursorFlashTime() const;
bool showIsFullScreen() const;
@@ -112,6 +93,7 @@ public:
void setWheelScrollLines(int scrollLines);
void setMouseQuickSelectionThreshold(int threshold);
int mouseQuickSelectionThreshold() const;
+ Qt::ColorScheme colorScheme() const;
Q_SIGNALS:
void cursorFlashTimeChanged(int cursorFlashTime);
@@ -125,6 +107,7 @@ Q_SIGNALS:
void showShortcutsInContextMenusChanged(bool);
void wheelScrollLinesChanged(int scrollLines);
void mouseQuickSelectionThresholdChanged(int threshold);
+ void colorSchemeChanged(Qt::ColorScheme colorScheme);
private:
friend class QGuiApplication;
diff --git a/src/gui/kernel/qstylehints_p.h b/src/gui/kernel/qstylehints_p.h
new file mode 100644
index 0000000000..2b3979512a
--- /dev/null
+++ b/src/gui/kernel/qstylehints_p.h
@@ -0,0 +1,54 @@
+// Copyright (C) 2022 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 QSTYLEHINTS_P_H
+#define QSTYLEHINTS_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qpa/qplatformintegration.h>
+#include <QPalette>
+#include <private/qguiapplication_p.h>
+#include "qstylehints.h"
+
+QT_BEGIN_NAMESPACE
+
+class QStyleHintsPrivate : public QObjectPrivate
+{
+ Q_DECLARE_PUBLIC(QStyleHints)
+public:
+ int m_mouseDoubleClickInterval = -1;
+ int m_mousePressAndHoldInterval = -1;
+ int m_startDragDistance = -1;
+ int m_startDragTime = -1;
+ int m_keyboardInputInterval = -1;
+ int m_cursorFlashTime = -1;
+ int m_tabFocusBehavior = -1;
+ int m_uiEffects = -1;
+ int m_showShortcutsInContextMenus = -1;
+ int m_wheelScrollLines = -1;
+ int m_mouseQuickSelectionThreshold = -1;
+ int m_mouseDoubleClickDistance = -1;
+ int m_touchDoubleTapDistance = -1;
+
+ Qt::ColorScheme colorScheme() const { return m_colorScheme; }
+ void updateColorScheme(Qt::ColorScheme colorScheme);
+
+ static QStyleHintsPrivate *get(QStyleHints *q);
+
+private:
+ Qt::ColorScheme m_colorScheme = Qt::ColorScheme::Unknown;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/gui/kernel/qsurface.cpp b/src/gui/kernel/qsurface.cpp
index 5a293e4250..c00cf55a09 100644
--- a/src/gui/kernel/qsurface.cpp
+++ b/src/gui/kernel/qsurface.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qsurface.h"
#include "qopenglcontext.h"
@@ -44,6 +8,7 @@
QT_BEGIN_NAMESPACE
+QT_IMPL_METATYPE_EXTERN_TAGGED(QSurface*, QSurface_ptr)
/*!
\class QSurface
@@ -65,13 +30,12 @@ QT_BEGIN_NAMESPACE
\value Offscreen The surface is an instance of QOffscreenSurface.
*/
-
/*!
\enum QSurface::SurfaceType
The SurfaceType enum describes what type of surface this is.
- \value RasterSurface The surface is is composed of pixels and can be rendered to using
+ \value RasterSurface The surface is composed of pixels and can be rendered to using
a software rasterizer like Qt's raster paint engine.
\value OpenGLSurface The surface is an OpenGL compatible surface and can be used
in conjunction with QOpenGLContext.
@@ -83,14 +47,13 @@ QT_BEGIN_NAMESPACE
\value VulkanSurface The surface is a Vulkan compatible surface and can be used
in conjunction with the Vulkan graphics API.
\value MetalSurface The surface is a Metal compatible surface and can be used
- in conjunction with Apple's Metal graphics API. This surface type is supported
- on macOS only.
+ in conjunction with Apple's Metal graphics API. This surface type is only supported
+ on \macos and iOS.
\value Direct3DSurface The surface is a Direct 3D 11 and 12 compatible
surface and can be used in conjunction with the DXGI and Direct3D APIs. This
- surface type is supported on Windows only.
+ surface type is only supported on Windows.
*/
-
/*!
\fn QSurfaceFormat QSurface::format() const
@@ -162,3 +125,5 @@ QSurface::SurfaceClass QSurface::surfaceClass() const
QT_END_NAMESPACE
+#include "moc_qsurface.cpp"
+
diff --git a/src/gui/kernel/qsurface.h b/src/gui/kernel/qsurface.h
index 4ba1d4b589..ef70beab21 100644
--- a/src/gui/kernel/qsurface.h
+++ b/src/gui/kernel/qsurface.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QSURFACE_H
#define QSURFACE_H
@@ -96,6 +60,6 @@ protected:
QT_END_NAMESPACE
-Q_DECLARE_METATYPE(QSurface*)
+QT_DECL_METATYPE_EXTERN_TAGGED(QSurface*, QSurface_ptr, Q_GUI_EXPORT)
#endif //QSURFACE_H
diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp
index e62f87b167..74add6e973 100644
--- a/src/gui/kernel/qsurfaceformat.cpp
+++ b/src/gui/kernel/qsurfaceformat.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qsurfaceformat.h"
@@ -753,8 +717,10 @@ void QSurfaceFormat::setColorSpace(const QColorSpace &colorSpace)
}
}
+#if QT_DEPRECATED_SINCE(6, 0)
/*!
\overload
+ \deprecated [6.0] Use setColorSpace(QColorSpace) instead.
Sets the colorspace to one of the predefined values.
@@ -773,6 +739,7 @@ void QSurfaceFormat::setColorSpace(ColorSpace colorSpace)
break;
}
}
+#endif // QT_DEPRECATED_SINCE(6, 0)
/*!
\return the color space.
@@ -798,7 +765,7 @@ Q_GLOBAL_STATIC(QSurfaceFormat, qt_default_surface_format)
question's own setFormat() function. However, it is often more convenient to
set the format for all windows once at the start of the application. It also
guarantees proper behavior in cases where shared contexts are required,
- because settings the format via this function guarantees that all contexts
+ because setting the format via this function guarantees that all contexts
and surfaces, even the ones created internally by Qt, will use the same
format.
@@ -900,3 +867,5 @@ QDebug operator<<(QDebug dbg, const QSurfaceFormat &f)
#endif
QT_END_NAMESPACE
+
+#include "moc_qsurfaceformat.cpp"
diff --git a/src/gui/kernel/qsurfaceformat.h b/src/gui/kernel/qsurfaceformat.h
index dfe55a338d..07ee1cc07d 100644
--- a/src/gui/kernel/qsurfaceformat.h
+++ b/src/gui/kernel/qsurfaceformat.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QSURFACEFORMAT_H
#define QSURFACEFORMAT_H
diff --git a/src/gui/kernel/qt_gui_pch.h b/src/gui/kernel/qt_gui_pch.h
index 5e07fa45e7..fbde1cf9a2 100644
--- a/src/gui/kernel/qt_gui_pch.h
+++ b/src/gui/kernel/qt_gui_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 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) 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 /
@@ -48,6 +12,7 @@
#include "../../corelib/global/qt_pch.h"
#if defined __cplusplus
+#include <qtguiexports.h>
#include <qtguiglobal.h>
#include <qguiapplication.h>
#include <qbitmap.h>
diff --git a/src/gui/kernel/qtestsupport_gui.cpp b/src/gui/kernel/qtestsupport_gui.cpp
index ab48111fb5..869eddce49 100644
--- a/src/gui/kernel/qtestsupport_gui.cpp
+++ b/src/gui/kernel/qtestsupport_gui.cpp
@@ -1,43 +1,8 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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) 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 <private/qguiapplication_p.h>
+#include <private/qeventpoint_p.h>
#include <qpa/qplatformintegration.h>
@@ -53,11 +18,18 @@ QT_BEGIN_NAMESPACE
/*!
\since 5.0
- Waits for \a timeout milliseconds or until the \a window is active.
+ Returns \c true, if \a window is active within \a timeout milliseconds. Otherwise returns \c false.
- Returns \c true if \c window is active within \a timeout milliseconds, otherwise returns \c false.
+ The method is useful in tests that call QWindow::show() and rely on the window actually being
+ active (i.e. being visible and having focus) before proceeding.
- \sa qWaitForWindowExposed(), QWindow::isActive()
+ \note The method will time out and return \c false if another window prevents \a window from
+ becoming active.
+
+ \note Since focus is an exclusive property, \a window may loose its focus to another window at
+ any time - even after the method has returned \c true.
+
+ \sa qWaitForWindowExposed(), qWaitForWindowFocused(), QWindow::isActive()
*/
Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
{
@@ -73,17 +45,37 @@ Q_GUI_EXPORT bool QTest::qWaitForWindowActive(QWindow *window, int timeout)
}
/*!
+ \since 6.7
+
+ Returns \c true, if \a window is the focus window within \a timeout. Otherwise returns \c false.
+
+ The method is useful in tests that call QWindow::show() and rely on the window
+ having focus (for receiving keyboard events e.g.) before proceeding.
+
+ \note The method will time out and return \c false if another window prevents \a window from
+ becoming focused.
+
+ \note Since focus is an exclusive property, \a window may loose its focus to another window at
+ any time - even after the method has returned \c true.
+
+ \sa qWaitForWindowExposed(), qWaitForWindowActive(), QGuiApplication::focusWindow()
+*/
+Q_GUI_EXPORT bool QTest::qWaitForWindowFocused(QWindow *window, QDeadlineTimer timeout)
+{
+ return QTest::qWaitFor([&]() { return qGuiApp->focusWindow() == window; }, timeout);
+}
+
+/*!
\since 5.0
- Waits for \a timeout milliseconds or until the \a window is exposed.
- Returns \c true if \c window is exposed within \a timeout milliseconds, otherwise returns \c false.
+ Returns \c true, if \a window is exposed within \a timeout milliseconds. Otherwise returns \c false.
- This is mainly useful for asynchronous systems like X11, where a window will be mapped to screen some
- time after being asked to show itself on the screen.
+ The method is useful in tests that call QWindow::show() and rely on the window actually being
+ being visible before proceeding.
- Note that a window that is mapped to screen may still not be considered exposed if the window client
- area is completely covered by other windows, or if the window is otherwise not visible. This function
- will then time out when waiting for such a window.
+ \note A window mapped to screen may still not be considered exposed, if the window client area is
+ not visible, e.g. because it is completely covered by other windows.
+ In such cases, the method will time out and return \c false.
\sa qWaitForWindowActive(), QWindow::isExposed()
*/
@@ -97,47 +89,49 @@ namespace QTest {
QTouchEventSequence::~QTouchEventSequence()
{
if (commitWhenDestroyed)
- commit();
+ QTouchEventSequence::commit();
}
QTouchEventSequence& QTouchEventSequence::press(int touchId, const QPoint &pt, QWindow *window)
{
- auto &p = QMutableEventPoint::from(point(touchId));
- p.setGlobalPosition(mapToScreen(window, pt));
- p.setState(QEventPoint::State::Pressed);
+ auto &p = point(touchId);
+ QMutableEventPoint::setGlobalPosition(p, mapToScreen(window, pt));
+ QMutableEventPoint::setState(p, QEventPoint::State::Pressed);
return *this;
}
QTouchEventSequence& QTouchEventSequence::move(int touchId, const QPoint &pt, QWindow *window)
{
- auto &p = QMutableEventPoint::from(point(touchId));
- p.setGlobalPosition(mapToScreen(window, pt));
- p.setState(QEventPoint::State::Updated);
+ auto &p = point(touchId);
+ QMutableEventPoint::setGlobalPosition(p, mapToScreen(window, pt));
+ QMutableEventPoint::setState(p, QEventPoint::State::Updated);
return *this;
}
QTouchEventSequence& QTouchEventSequence::release(int touchId, const QPoint &pt, QWindow *window)
{
- auto &p = QMutableEventPoint::from(point(touchId));
- p.setGlobalPosition(mapToScreen(window, pt));
- p.setState(QEventPoint::State::Released);
+ auto &p = point(touchId);
+ QMutableEventPoint::setGlobalPosition(p, mapToScreen(window, pt));
+ QMutableEventPoint::setState(p, QEventPoint::State::Released);
return *this;
}
QTouchEventSequence& QTouchEventSequence::stationary(int touchId)
{
- auto &p = QMutableEventPoint::from(pointOrPreviousPoint(touchId));
- p.setState(QEventPoint::State::Stationary);
+ auto &p = pointOrPreviousPoint(touchId);
+ QMutableEventPoint::setState(p, QEventPoint::State::Stationary);
return *this;
}
-void QTouchEventSequence::commit(bool processEvents)
+bool QTouchEventSequence::commit(bool processEvents)
{
if (points.isEmpty())
- return;
- QThread::msleep(1);
+ return false;
+ QThread::sleep(std::chrono::milliseconds{1});
+ bool ret = false;
if (targetWindow)
- qt_handleTouchEvent(targetWindow, device, points.values());
+ ret = qt_handleTouchEventv2(targetWindow, device, points.values());
if (processEvents)
QCoreApplication::processEvents();
previousPoints = points;
points.clear();
+ return ret;
}
QTouchEventSequence::QTouchEventSequence(QWindow *window, QPointingDevice *aDevice, bool autoCommit)
diff --git a/src/gui/kernel/qtestsupport_gui.h b/src/gui/kernel/qtestsupport_gui.h
index ac4271db46..e5b2a88455 100644
--- a/src/gui/kernel/qtestsupport_gui.h
+++ b/src/gui/kernel/qtestsupport_gui.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2018 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) 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_GUI_H
#define QTESTSUPPORT_GUI_H
@@ -48,13 +12,18 @@ QT_BEGIN_NAMESPACE
class QWindow;
-Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, const QPointingDevice *device,
+Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *w, const QPointingDevice *device,
+ const QList<QEventPoint> &points,
+ Qt::KeyboardModifiers mods = Qt::NoModifier);
+
+Q_GUI_EXPORT bool qt_handleTouchEventv2(QWindow *w, const QPointingDevice *device,
const QList<QEventPoint> &points,
Qt::KeyboardModifiers mods = Qt::NoModifier);
namespace QTest {
[[nodiscard]] Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout = 5000);
+[[nodiscard]] Q_GUI_EXPORT bool qWaitForWindowFocused(QWindow *widget, QDeadlineTimer timeout = std::chrono::seconds{5});
[[nodiscard]] Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout = 5000);
Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType = QInputDevice::DeviceType::TouchScreen,
@@ -69,7 +38,7 @@ public:
QTouchEventSequence& release(int touchId, const QPoint &pt, QWindow *window = nullptr);
virtual QTouchEventSequence& stationary(int touchId);
- virtual void commit(bool processEvents = true);
+ virtual bool commit(bool processEvents = true);
protected:
QTouchEventSequence(QWindow *window, QPointingDevice *aDevice, bool autoCommit);
diff --git a/src/gui/kernel/qtguiglobal.h b/src/gui/kernel/qtguiglobal.h
index 8a7409e3d9..cea6448755 100644
--- a/src/gui/kernel/qtguiglobal.h
+++ b/src/gui/kernel/qtguiglobal.h
@@ -1,60 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QTGUIGLOBAL_H
#define QTGUIGLOBAL_H
#include <QtCore/qglobal.h>
#include <QtGui/qtgui-config.h>
-
-QT_BEGIN_NAMESPACE
-
-#ifndef QT_STATIC
-# if defined(QT_BUILD_GUI_LIB)
-# define Q_GUI_EXPORT Q_DECL_EXPORT
-# else
-# define Q_GUI_EXPORT Q_DECL_IMPORT
-# endif
-#else
-# define Q_GUI_EXPORT
-#endif
-
-QT_END_NAMESPACE
+#include <QtGui/qtguiexports.h>
#endif // QTGUIGLOBAL_H
diff --git a/src/gui/kernel/qtguiglobal_p.h b/src/gui/kernel/qtguiglobal_p.h
index d2c0b3c5d1..c9f341c172 100644
--- a/src/gui/kernel/qtguiglobal_p.h
+++ b/src/gui/kernel/qtguiglobal_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 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) 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 QTGUIGLOBAL_P_H
#define QTGUIGLOBAL_P_H
diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp
index 61c201559a..b40fd7e8e8 100644
--- a/src/gui/kernel/qwindow.cpp
+++ b/src/gui/kernel/qwindow.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 "qwindow.h"
@@ -54,7 +18,7 @@
#include "qwindow_p.h"
#include "qguiapplication_p.h"
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
# include "qaccessible.h"
#endif
#include "qhighdpiscaling_p.h"
@@ -164,7 +128,7 @@ QWindow::QWindow(QScreen *targetScreen)
, QSurface(QSurface::Window)
{
Q_D(QWindow);
- d->init(targetScreen);
+ d->init(nullptr, targetScreen);
}
static QWindow *nonDesktopParent(QWindow *parent)
@@ -205,11 +169,11 @@ QWindow::QWindow(QWindow *parent)
\sa setParent()
*/
QWindow::QWindow(QWindowPrivate &dd, QWindow *parent)
- : QObject(dd, nonDesktopParent(parent))
+ : QObject(dd, nullptr)
, QSurface(QSurface::Window)
{
Q_D(QWindow);
- d->init();
+ d->init(nonDesktopParent(parent));
}
/*!
@@ -219,35 +183,74 @@ QWindow::~QWindow()
{
Q_D(QWindow);
d->destroy();
+ // Decouple from parent before window goes under
+ setParent(nullptr);
QGuiApplicationPrivate::window_list.removeAll(this);
if (!QGuiApplicationPrivate::is_app_closing)
QGuiApplicationPrivate::instance()->modalWindowList.removeOne(this);
- // focus_window is normally cleared in destroy(), but the window may in
- // some cases end up becoming the focus window again. Clear it again
- // here as a workaround. See QTBUG-75326.
+ // thse are normally cleared in destroy(), but the window may in
+ // some cases end up becoming the focus window again, or receive an enter
+ // event. Clear it again here as a workaround. See QTBUG-75326.
if (QGuiApplicationPrivate::focus_window == this)
QGuiApplicationPrivate::focus_window = nullptr;
+ if (QGuiApplicationPrivate::currentMouseWindow == this)
+ QGuiApplicationPrivate::currentMouseWindow = nullptr;
+ if (QGuiApplicationPrivate::currentMousePressWindow == this)
+ QGuiApplicationPrivate::currentMousePressWindow = nullptr;
+
+ d->isWindow = false;
}
-void QWindowPrivate::init(QScreen *targetScreen)
+QWindowPrivate::QWindowPrivate()
+ = default;
+
+QWindowPrivate::~QWindowPrivate()
+ = default;
+
+void QWindowPrivate::init(QWindow *parent, QScreen *targetScreen)
{
Q_Q(QWindow);
+ q->QObject::setParent(parent);
+
+ isWindow = true;
parentWindow = static_cast<QWindow *>(q->QObject::parent());
+ QScreen *connectScreen = targetScreen ? targetScreen : QGuiApplication::primaryScreen();
+
if (!parentWindow)
- connectToScreen(targetScreen ? targetScreen : QGuiApplication::primaryScreen());
+ connectToScreen(connectScreen);
// If your application aborts here, you are probably creating a QWindow
// before the screen list is populated.
if (Q_UNLIKELY(!parentWindow && !topLevelScreen)) {
qFatal("Cannot create window: no screens available");
- exit(1);
}
QGuiApplicationPrivate::window_list.prepend(q);
requestedFormat = QSurfaceFormat::defaultFormat();
+ devicePixelRatio = connectScreen->devicePixelRatio();
+
+ QObject::connect(q, &QWindow::screenChanged, q, [q, this](QScreen *){
+ // We may have changed scaling; trigger resize event if needed,
+ // except on Windows, where we send resize events during WM_DPICHANGED
+ // event handling. FIXME: unify DPI change handling across all platforms.
+#ifndef Q_OS_WIN
+ if (q->handle()) {
+ QWindowSystemInterfacePrivate::GeometryChangeEvent gce(q, QHighDpi::fromNativePixels(q->handle()->geometry(), q));
+ QGuiApplicationPrivate::processGeometryChangeEvent(&gce);
+ }
+#else
+ Q_UNUSED(q);
+#endif
+ updateDevicePixelRatio();
+ });
+
+ if (parentWindow) {
+ QChildWindowEvent childAddedEvent(QEvent::ChildWindowAdded, q);
+ QCoreApplication::sendEvent(parentWindow, &childAddedEvent);
+ }
}
/*!
@@ -328,7 +331,6 @@ void QWindow::setVisibility(Visibility v)
break;
default:
Q_ASSERT(false);
- break;
}
}
@@ -453,14 +455,14 @@ void QWindowPrivate::updateSiblingPosition(SiblingPosition position)
QObjectList &siblings = q->parent()->d_ptr->children;
- const int siblingCount = siblings.size() - 1;
+ const qsizetype siblingCount = siblings.size() - 1;
if (siblingCount == 0)
return;
- const int currentPosition = siblings.indexOf(q);
+ const qsizetype currentPosition = siblings.indexOf(q);
Q_ASSERT(currentPosition >= 0);
- const int targetPosition = position == PositionTop ? siblingCount : 0;
+ const qsizetype targetPosition = position == PositionTop ? siblingCount : 0;
if (currentPosition == targetPosition)
return;
@@ -468,7 +470,7 @@ void QWindowPrivate::updateSiblingPosition(SiblingPosition position)
siblings.move(currentPosition, targetPosition);
}
-inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const
+bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const
{
Q_Q(const QWindow);
const QScreen *oldScreen = q->screen();
@@ -476,7 +478,7 @@ inline bool QWindowPrivate::windowRecreationRequired(QScreen *newScreen) const
&& !(oldScreen && oldScreen->virtualSiblings().contains(newScreen));
}
-inline void QWindowPrivate::disconnectFromScreen()
+void QWindowPrivate::disconnectFromScreen()
{
if (topLevelScreen)
topLevelScreen = nullptr;
@@ -519,7 +521,9 @@ void QWindowPrivate::setTopLevelScreen(QScreen *newScreen, bool recreate)
}
}
-void QWindowPrivate::create(bool recursive, WId nativeHandle)
+static constexpr auto kForeignWindowId = "_q_foreignWinId";
+
+void QWindowPrivate::create(bool recursive)
{
Q_Q(QWindow);
if (platformWindow)
@@ -533,6 +537,13 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle)
if (q->parent())
q->parent()->create();
+ if (platformWindow) {
+ // Creating the parent window will end up creating any child window
+ // that was already visible, via setVisible. If this applies to us,
+ // we will already have a platform window at this point.
+ return;
+ }
+
// QPlatformWindow will poll geometry() during construction below. Set the
// screen here so that high-dpi scaling will use the correct scale factor.
if (q->isTopLevel()) {
@@ -540,6 +551,8 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle)
setTopLevelScreen(screen, false);
}
+ const WId nativeHandle = q->property(kForeignWindowId).value<WId>();
+
QPlatformIntegration *platformIntegration = QGuiApplicationPrivate::platformIntegration();
platformWindow = nativeHandle ? platformIntegration->createForeignWindow(q, nativeHandle)
: platformIntegration->createPlatformWindow(q);
@@ -575,6 +588,8 @@ void QWindowPrivate::create(bool recursive, WId nativeHandle)
QPlatformSurfaceEvent e(QPlatformSurfaceEvent::SurfaceCreated);
QGuiApplication::sendEvent(q, &e);
+ updateDevicePixelRatio();
+
if (needsUpdate)
q->requestUpdate();
}
@@ -592,6 +607,37 @@ QRectF QWindowPrivate::closestAcceptableGeometry(const QRectF &rect) const
return QRectF();
}
+void QWindowPrivate::setMinOrMaxSize(QSize *oldSizeMember, const QSize &size,
+ qxp::function_ref<void()> funcWidthChanged,
+ qxp::function_ref<void()> funcHeightChanged)
+{
+ Q_Q(QWindow);
+ Q_ASSERT(oldSizeMember);
+ const QSize adjustedSize =
+ size.expandedTo(QSize(0, 0)).boundedTo(QSize(QWINDOWSIZE_MAX, QWINDOWSIZE_MAX));
+ if (*oldSizeMember == adjustedSize)
+ return;
+ const bool widthChanged = adjustedSize.width() != oldSizeMember->width();
+ const bool heightChanged = adjustedSize.height() != oldSizeMember->height();
+ *oldSizeMember = adjustedSize;
+
+ if (platformWindow && q->isTopLevel())
+ platformWindow->propagateSizeHints();
+
+ if (widthChanged)
+ funcWidthChanged();
+ if (heightChanged)
+ funcHeightChanged();
+
+ // resize window if current size is outside of min and max limits
+ if (minimumSize.width() <= maximumSize.width()
+ || minimumSize.height() <= maximumSize.height()) {
+ const QSize currentSize = q->size();
+ const QSize boundedSize = currentSize.expandedTo(minimumSize).boundedTo(maximumSize);
+ q->resize(boundedSize);
+ }
+}
+
/*!
Sets the \a surfaceType of the window.
@@ -631,6 +677,13 @@ QWindow::SurfaceType QWindow::surfaceType() const
By default, the window is not visible, you must call setVisible(true), or
show() or similar to make it visible.
+ \note Hiding a window does not remove the window from the windowing system,
+ it only hides it. On windowing systems that give full screen applications a
+ dedicated desktop (such as macOS), hiding a full screen window will not remove
+ that desktop, but leave it blank. Another window from the same application
+ might be shown full screen, and will fill that desktop. Use QWindow::close to
+ completely remove a window from the windowing system.
+
\sa show()
*/
void QWindow::setVisible(bool visible)
@@ -654,7 +707,7 @@ bool QWindow::isVisible() const
into an actual native surface. However, the window remains hidden until setVisible() is called.
Note that it is not usually necessary to call this function directly, as it will be implicitly
- called by show(), setVisible(), and other functions that require access to the platform
+ called by show(), setVisible(), winId(), and other functions that require access to the platform
resources.
Call destroy() to free the platform resources if necessary.
@@ -670,6 +723,9 @@ void QWindow::create()
/*!
Returns the window's platform id.
+ \note This function will cause the platform window to be created if it is not already.
+ Returns 0, if the platform window creation failed.
+
For platforms where this id might be useful, the value returned
will uniquely represent the window inside the corresponding screen.
@@ -682,6 +738,9 @@ WId QWindow::winId() const
if (!d->platformWindow)
const_cast<QWindow *>(this)->create();
+ if (!d->platformWindow)
+ return 0;
+
return d->platformWindow->winId();
}
@@ -725,6 +784,10 @@ void QWindow::setParent(QWindow *parent)
return;
}
+ QEvent parentAboutToChangeEvent(QEvent::ParentWindowAboutToChange);
+ QCoreApplication::sendEvent(this, &parentAboutToChangeEvent);
+
+ const auto previousParent = d->parentWindow;
QObject::setParent(parent);
d->parentWindow = parent;
@@ -747,6 +810,19 @@ void QWindow::setParent(QWindow *parent)
}
QGuiApplicationPrivate::updateBlockedStatus(this);
+
+ if (previousParent) {
+ QChildWindowEvent childRemovedEvent(QEvent::ChildWindowRemoved, this);
+ QCoreApplication::sendEvent(previousParent, &childRemovedEvent);
+ }
+
+ if (parent) {
+ QChildWindowEvent childAddedEvent(QEvent::ChildWindowAdded, this);
+ QCoreApplication::sendEvent(parent, &childAddedEvent);
+ }
+
+ QEvent parentChangedEvent(QEvent::ParentWindowChange);
+ QCoreApplication::sendEvent(this, &parentChangedEvent);
}
/*!
@@ -1230,12 +1306,16 @@ bool QWindow::isExposed() const
*/
/*!
- Returns \c true if the window should appear active from a style perspective.
+ Returns \c true if the window is active.
This is the case for the window that has input focus as well as windows
that are in the same parent / transient parent chain as the focus window.
+ Typically active windows should appear active from a style perspective.
+
To get the window that currently has focus, use QGuiApplication::focusWindow().
+
+ \sa requestActivate()
*/
bool QWindow::isActive() const
{
@@ -1309,14 +1389,31 @@ Qt::ScreenOrientation QWindow::contentOrientation() const
qreal QWindow::devicePixelRatio() const
{
Q_D(const QWindow);
+ return d->devicePixelRatio;
+}
+
+/*
+ Updates the cached devicePixelRatio value by polling for a new value.
+ Sends QEvent::DevicePixelRatioChange to the window if the DPR has changed.
+ Returns true if the DPR was changed.
+*/
+bool QWindowPrivate::updateDevicePixelRatio()
+{
+ Q_Q(QWindow);
// If there is no platform window use the associated screen's devicePixelRatio,
// which typically is the primary screen and will be correct for single-display
// systems (a very common case).
- if (!d->platformWindow)
- return screen()->devicePixelRatio();
+ const qreal newDevicePixelRatio = platformWindow ?
+ platformWindow->devicePixelRatio() * QHighDpiScaling::factor(q) : q->screen()->devicePixelRatio();
- return d->platformWindow->devicePixelRatio() * QHighDpiScaling::factor(this);
+ if (newDevicePixelRatio == devicePixelRatio)
+ return false;
+
+ devicePixelRatio = newDevicePixelRatio;
+ QEvent dprChangeEvent(QEvent::DevicePixelRatioChange);
+ QGuiApplication::sendEvent(q, &dprChangeEvent);
+ return true;
}
Qt::WindowState QWindowPrivate::effectiveState(Qt::WindowStates state)
@@ -1371,8 +1468,13 @@ void QWindow::setWindowStates(Qt::WindowStates state)
if (d->platformWindow)
d->platformWindow->setWindowState(state);
+
+ auto originalEffectiveState = QWindowPrivate::effectiveState(d->windowState);
d->windowState = state;
- emit windowStateChanged(QWindowPrivate::effectiveState(d->windowState));
+ auto newEffectiveState = QWindowPrivate::effectiveState(d->windowState);
+ if (newEffectiveState != originalEffectiveState)
+ emit windowStateChanged(newEffectiveState);
+
d->updateVisibility();
}
@@ -1547,17 +1649,9 @@ QSize QWindow::sizeIncrement() const
void QWindow::setMinimumSize(const QSize &size)
{
Q_D(QWindow);
- QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX));
- if (d->minimumSize == adjustedSize)
- return;
- QSize oldSize = d->minimumSize;
- d->minimumSize = adjustedSize;
- if (d->platformWindow && isTopLevel())
- d->platformWindow->propagateSizeHints();
- if (d->minimumSize.width() != oldSize.width())
- emit minimumWidthChanged(d->minimumSize.width());
- if (d->minimumSize.height() != oldSize.height())
- emit minimumHeightChanged(d->minimumSize.height());
+ d->setMinOrMaxSize(
+ &d->minimumSize, size, [this, d]() { emit minimumWidthChanged(d->minimumSize.width()); },
+ [this, d]() { emit minimumHeightChanged(d->minimumSize.height()); });
}
/*!
@@ -1590,20 +1684,18 @@ void QWindow::setY(int arg)
\property QWindow::width
\brief the width of the window's geometry
*/
-void QWindow::setWidth(int arg)
+void QWindow::setWidth(int w)
{
- if (width() != arg)
- resize(arg, height());
+ resize(w, height());
}
/*!
\property QWindow::height
\brief the height of the window's geometry
*/
-void QWindow::setHeight(int arg)
+void QWindow::setHeight(int h)
{
- if (height() != arg)
- resize(width(), arg);
+ resize(width(), h);
}
/*!
@@ -1634,17 +1726,9 @@ void QWindow::setMinimumHeight(int h)
void QWindow::setMaximumSize(const QSize &size)
{
Q_D(QWindow);
- QSize adjustedSize = QSize(qBound(0, size.width(), QWINDOWSIZE_MAX), qBound(0, size.height(), QWINDOWSIZE_MAX));
- if (d->maximumSize == adjustedSize)
- return;
- QSize oldSize = d->maximumSize;
- d->maximumSize = adjustedSize;
- if (d->platformWindow && isTopLevel())
- d->platformWindow->propagateSizeHints();
- if (d->maximumSize.width() != oldSize.width())
- emit maximumWidthChanged(d->maximumSize.width());
- if (d->maximumSize.height() != oldSize.height())
- emit maximumHeightChanged(d->maximumSize.height());
+ d->setMinOrMaxSize(
+ &d->maximumSize, size, [this, d]() { emit maximumWidthChanged(d->maximumSize.width()); },
+ [this, d]() { emit maximumHeightChanged(d->maximumSize.height()); });
}
/*!
@@ -1740,13 +1824,7 @@ void QWindow::setGeometry(const QRect &rect)
QScreen *newScreen = d->screenForGeometry(rect);
if (newScreen && isTopLevel())
d->setTopLevelScreen(newScreen, true);
-
- QRect nativeRect;
- if (newScreen && isTopLevel())
- nativeRect = QHighDpi::toNativePixels(rect, newScreen);
- else
- nativeRect = QHighDpi::toNativeLocalPosition(rect, newScreen);
- d->platformWindow->setGeometry(nativeRect);
+ d->platformWindow->setGeometry(QHighDpi::toNativeWindowGeometry(rect, this));
} else {
d->geometry = rect;
@@ -1877,6 +1955,10 @@ void QWindow::setFramePosition(const QPoint &point)
For interactively moving windows, see startSystemMove(). For interactively
resizing windows, see startSystemResize().
+ \note Not all windowing systems support setting or querying top level window positions.
+ On such a system, programmatically moving windows may not have any effect, and artificial
+ values may be returned for the current positions, such as \c QPoint(0, 0).
+
\sa position(), startSystemMove()
*/
void QWindow::setPosition(const QPoint &pt)
@@ -1900,6 +1982,10 @@ void QWindow::setPosition(int posx, int posy)
\fn QPoint QWindow::position() const
\brief Returns the position of the window on the desktop excluding any window frame
+ \note Not all windowing systems support setting or querying top level window positions.
+ On such a system, programmatically moving windows may not have any effect, and artificial
+ values may be returned for the current positions, such as \c QPoint(0, 0).
+
\sa setPosition()
*/
@@ -1931,11 +2017,16 @@ void QWindow::resize(int w, int h)
void QWindow::resize(const QSize &newSize)
{
Q_D(QWindow);
+
+ const QSize oldSize = size();
+ if (newSize == oldSize)
+ return;
+
d->positionPolicy = QWindowPrivate::WindowFrameExclusive;
if (d->platformWindow) {
- d->platformWindow->setGeometry(QHighDpi::toNativePixels(QRect(position(), newSize), this));
+ d->platformWindow->setGeometry(
+ QHighDpi::toNativeWindowGeometry(QRect(position(), newSize), this));
} else {
- const QSize oldSize = d->geometry.size();
d->geometry.setSize(newSize);
if (newSize.width() != oldSize.width())
emit widthChanged(newSize.width());
@@ -1972,6 +2063,16 @@ void QWindowPrivate::destroy()
QObject *object = childrenWindows.at(i);
if (object->isWindowType()) {
QWindow *w = static_cast<QWindow*>(object);
+ auto *childPlatformWindow = w->handle();
+ if (!childPlatformWindow)
+ continue;
+
+ // Decouple the foreign window from this window,
+ // so that destroying our native handle doesn't
+ // bring down the foreign window as well.
+ if (childPlatformWindow->isForeignWindow())
+ childPlatformWindow->setParent(nullptr);
+
qt_window_private(w)->destroy();
}
}
@@ -1984,7 +2085,7 @@ void QWindowPrivate::destroy()
// Let subclasses act, typically by doing graphics resource cleaup, when
// the window, to which graphics resource may be tied, is going away.
//
- // NB! This is disfunctional when destroy() is invoked from the dtor since
+ // NB! This is dysfunctional when destroy() is invoked from the dtor since
// a reimplemented event() will not get called in the subclasses at that
// stage. However, the typical QWindow cleanup involves either close() or
// going through QWindowContainer, both of which will do an explicit, early
@@ -1996,9 +2097,7 @@ void QWindowPrivate::destroy()
// Unset platformWindow before deleting, so that the destructor of the
// platform window does not recurse back into the platform window via
// this window during destruction (e.g. as a result of platform events).
- QPlatformWindow *pw = platformWindow;
- platformWindow = nullptr;
- delete pw;
+ delete std::exchange(platformWindow, nullptr);
if (QGuiApplicationPrivate::focus_window == q)
QGuiApplicationPrivate::focus_window = q->parent();
@@ -2146,20 +2245,26 @@ QObject *QWindow::focusObject() const
/*!
Shows the window.
- This is equivalent to calling showFullScreen(), showMaximized(), or showNormal(),
+ For child windows, this is equivalent to calling showNormal().
+ Otherwise, it is equivalent to calling showFullScreen(), showMaximized(), or showNormal(),
depending on the platform's default behavior for the window type and flags.
\sa showFullScreen(), showMaximized(), showNormal(), hide(), QStyleHints::showIsFullScreen(), flags()
*/
void QWindow::show()
{
- Qt::WindowState defaultState = QGuiApplicationPrivate::platformIntegration()->defaultWindowState(d_func()->windowFlags);
- if (defaultState == Qt::WindowFullScreen)
- showFullScreen();
- else if (defaultState == Qt::WindowMaximized)
- showMaximized();
- else
+ if (parent()) {
showNormal();
+ } else {
+ const auto *platformIntegration = QGuiApplicationPrivate::platformIntegration();
+ Qt::WindowState defaultState = platformIntegration->defaultWindowState(d_func()->windowFlags);
+ if (defaultState == Qt::WindowFullScreen)
+ showFullScreen();
+ else if (defaultState == Qt::WindowMaximized)
+ showMaximized();
+ else
+ showNormal();
+ }
}
/*!
@@ -2208,6 +2313,9 @@ void QWindow::showMaximized()
Equivalent to calling setWindowStates(Qt::WindowFullScreen) and then
setVisible(true).
+ See the \l{QWidget::showFullScreen()} documentation for platform-specific
+ considerations and limitations.
+
\sa setWindowStates(), setVisible()
*/
void QWindow::showFullScreen()
@@ -2246,15 +2354,52 @@ void QWindow::showNormal()
bool QWindow::close()
{
Q_D(QWindow);
+ if (d->inClose)
+ return true;
// Do not close non top level windows
- if (parent())
+ if (!isTopLevel())
return false;
if (!d->platformWindow)
return true;
- return d->platformWindow->close();
+ // The window might be deleted during close,
+ // as a result of delivering the close event.
+ QPointer guard(this);
+ d->inClose = true;
+ bool success = d->platformWindow->close();
+ if (guard)
+ d->inClose = false;
+
+ return success;
+}
+
+bool QWindowPrivate::participatesInLastWindowClosed() const
+{
+ Q_Q(const QWindow);
+
+ if (!q->isTopLevel())
+ return false;
+
+ // Tool-tip widgets do not normally have Qt::WA_QuitOnClose,
+ // but since we do not have a similar flag for non-widget
+ // windows we need an explicit exclusion here as well.
+ if (q->type() == Qt::ToolTip)
+ return false;
+
+ // A window with a transient parent is not a primary window,
+ // it's a secondary window.
+ if (q->transientParent())
+ return false;
+
+ return true;
+}
+
+bool QWindowPrivate::treatAsVisible() const
+{
+ Q_Q(const QWindow);
+ return q->isVisible();
}
/*!
@@ -2407,7 +2552,7 @@ bool QWindow::event(QEvent *ev)
case QEvent::FocusIn: {
focusInEvent(static_cast<QFocusEvent *>(ev));
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessible::State state;
state.active = true;
QAccessibleStateChangeEvent event(this, state);
@@ -2417,7 +2562,7 @@ bool QWindow::event(QEvent *ev)
case QEvent::FocusOut: {
focusOutEvent(static_cast<QFocusEvent *>(ev));
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessible::State state;
state.active = true;
QAccessibleStateChangeEvent event(this, state);
@@ -2431,20 +2576,25 @@ bool QWindow::event(QEvent *ev)
break;
#endif
- case QEvent::Close:
+ case QEvent::Close: {
+
+ Q_D(QWindow);
+ const bool wasVisible = d->treatAsVisible();
+ const bool participatesInLastWindowClosed = d->participatesInLastWindowClosed();
+
+ // The window might be deleted in the close event handler
+ QPointer<QWindow> deletionGuard(this);
closeEvent(static_cast<QCloseEvent*>(ev));
+
if (ev->isAccepted()) {
- Q_D(QWindow);
- bool wasVisible = isVisible();
- destroy();
- if (wasVisible) {
- // FIXME: This check for visibility is a workaround for both QWidgetWindow
- // and QWindow having logic to emit lastWindowClosed, and possibly quit the
- // application. We should find a better way to handle this.
- d->maybeQuitOnLastWindowClosed();
- }
+ if (deletionGuard)
+ destroy();
+ if (wasVisible && participatesInLastWindowClosed)
+ QGuiApplicationPrivate::instance()->maybeLastWindowClosed();
}
+
break;
+ }
case QEvent::Expose:
exposeEvent(static_cast<QExposeEvent *>(ev));
@@ -2466,13 +2616,6 @@ bool QWindow::event(QEvent *ev)
setIcon(icon());
break;
- case QEvent::WindowStateChange: {
- Q_D(QWindow);
- emit windowStateChanged(QWindowPrivate::effectiveState(d->windowState));
- d->updateVisibility();
- break;
- }
-
#if QT_CONFIG(tabletevent)
case QEvent::TabletPress:
case QEvent::TabletMove:
@@ -2514,11 +2657,15 @@ bool QWindow::event(QEvent *ev)
static const QEvent::Type contextMenuTrigger =
QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::ContextMenuOnMouseRelease).toBool() ?
QEvent::MouseButtonRelease : QEvent::MouseButtonPress;
- if (QMouseEvent *me = static_cast<QMouseEvent *>(ev);
+ auto asMouseEvent = [](QEvent *ev) {
+ const auto t = ev->type();
+ return t == QEvent::MouseButtonPress || t == QEvent::MouseButtonRelease
+ ? static_cast<QMouseEvent *>(ev) : nullptr ;
+ };
+ if (QMouseEvent *me = asMouseEvent(ev); me &&
ev->type() == contextMenuTrigger && me->button() == Qt::RightButton) {
- QSinglePointEvent *pev = static_cast<QSinglePointEvent*>(ev);
QContextMenuEvent e(QContextMenuEvent::Mouse, me->position().toPoint(),
- pev->globalPosition().toPoint(), pev->modifiers());
+ me->globalPosition().toPoint(), me->modifiers());
QGuiApplication::sendEvent(this, &e);
}
#endif
@@ -2528,11 +2675,13 @@ bool QWindow::event(QEvent *ev)
/*!
Schedules a QEvent::UpdateRequest event to be delivered to this window.
- The event is delivered in sync with the display vsync on platforms
- where this is possible. Otherwise, the event is delivered after a
- delay of 5 ms. The additional time is there to give the event loop
- a bit of idle time to gather system events, and can be overridden
- using the QT_QPA_UPDATE_IDLE_TIME environment variable.
+ The event is delivered in sync with the display vsync on platforms where
+ this is possible. Otherwise, the event is delivered after a delay of at
+ most 5 ms. If the window's associated screen reports a
+ \l{QScreen::refreshRate()}{refresh rate} higher than 60 Hz, the interval is
+ scaled down to a value smaller than 5. The additional time is there to give
+ the event loop a bit of idle time to gather system events, and can be
+ overridden using the QT_QPA_UPDATE_IDLE_TIME environment variable.
When driving animations, this function should be called once after drawing
has completed. Calling this function multiple times will result in a single
@@ -2708,7 +2857,7 @@ QPointF QWindow::mapToGlobal(const QPointF &pos) const
// QTBUG-43252, prefer platform implementation for foreign windows.
if (d->platformWindow
&& (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) {
- return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapToGlobalF(QHighDpi::toNativeLocalPosition(pos, this)), this);
+ return QHighDpi::fromNativeGlobalPosition(d->platformWindow->mapToGlobalF(QHighDpi::toNativeLocalPosition(pos, this)), this);
}
if (!QHighDpiScaling::isActive())
@@ -2721,7 +2870,12 @@ QPointF QWindow::mapToGlobal(const QPointF &pos) const
// Map the position (and the window's global position) to native coordinates, perform
// the addition, and then map back to device independent coordinates.
QPointF nativeLocalPos = QHighDpi::toNativeLocalPosition(pos, this);
- QPointF nativeWindowGlobalPos = QHighDpi::toNativeGlobalPosition(QPointF(d->globalPosition()), this);
+ // Get the native window position directly from the platform window
+ // if available (it can be null if the window hasn't been shown yet),
+ // or fall back to scaling the QWindow position.
+ QPointF nativeWindowGlobalPos = d->platformWindow
+ ? d->platformWindow->mapToGlobal(QPoint(0,0)).toPointF()
+ : QHighDpi::toNativeGlobalPosition(QPointF(d->globalPosition()), this);
QPointF nativeGlobalPos = nativeLocalPos + nativeWindowGlobalPos;
QPointF deviceIndependentGlobalPos = QHighDpi::fromNativeGlobalPosition(nativeGlobalPos, this);
return deviceIndependentGlobalPos;
@@ -2750,16 +2904,21 @@ QPointF QWindow::mapFromGlobal(const QPointF &pos) const
// QTBUG-43252, prefer platform implementation for foreign windows.
if (d->platformWindow
&& (d->platformWindow->isForeignWindow() || d->platformWindow->isEmbedded())) {
- return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobalF(QHighDpi::toNativeLocalPosition(pos, this)), this);
+ return QHighDpi::fromNativeLocalPosition(d->platformWindow->mapFromGlobalF(QHighDpi::toNativeGlobalPosition(pos, this)), this);
}
if (!QHighDpiScaling::isActive())
return pos - d->globalPosition();
// Calculate local position in the native coordinate system. (See comment for the
- // correspinding mapToGlobal() code above).
+ // corresponding mapToGlobal() code above).
QPointF nativeGlobalPos = QHighDpi::toNativeGlobalPosition(pos, this);
- QPointF nativeWindowGlobalPos = QHighDpi::toNativeGlobalPosition(QPointF(d->globalPosition()), this);
+ // Get the native window position directly from the platform window
+ // if available (it can be null if the window hasn't been shown yet),
+ // or fall back to scaling the QWindow position.
+ QPointF nativeWindowGlobalPos = d->platformWindow
+ ? d->platformWindow->mapToGlobal(QPoint(0,0)).toPointF()
+ : QHighDpi::toNativeGlobalPosition(QPointF(d->globalPosition()), this);
QPointF nativeLocalPos = nativeGlobalPos - nativeWindowGlobalPos;
QPointF deviceIndependentLocalPos = QHighDpi::fromNativeLocalPosition(nativeLocalPos, this);
return deviceIndependentLocalPos;
@@ -2795,34 +2954,6 @@ Q_GUI_EXPORT QWindowPrivate *qt_window_private(QWindow *window)
return window->d_func();
}
-void QWindowPrivate::maybeQuitOnLastWindowClosed()
-{
- if (!QCoreApplication::instance())
- return;
-
- Q_Q(QWindow);
- if (!q->isTopLevel())
- return;
-
- QWindowList list = QGuiApplication::topLevelWindows();
- bool lastWindowClosed = true;
- for (int i = 0; i < list.size(); ++i) {
- QWindow *w = list.at(i);
- if (!w->isVisible() || w->transientParent() || w->type() == Qt::ToolTip)
- continue;
- lastWindowClosed = false;
- break;
- }
- if (lastWindowClosed) {
- QGuiApplicationPrivate::emitLastWindowClosed();
-
- if (QGuiApplication::quitOnLastWindowClosed()) {
- QCoreApplicationPrivate *applicationPrivate = static_cast<QCoreApplicationPrivate*>(QObjectPrivate::get(QCoreApplication::instance()));
- applicationPrivate->maybeQuit();
- }
- }
-}
-
QWindow *QWindowPrivate::topLevelWindow(QWindow::AncestorMode mode) const
{
Q_Q(const QWindow);
@@ -2840,13 +2971,6 @@ QWindow *QWindowPrivate::topLevelWindow(QWindow::AncestorMode mode) const
return window;
}
-#if QT_CONFIG(opengl)
-QOpenGLContext *QWindowPrivate::shareContext() const
-{
- return qt_gl_global_share_context();
-};
-#endif
-
/*!
Creates a local representation of a window created by another process or by
using native libraries below Qt.
@@ -2876,7 +3000,11 @@ QWindow *QWindow::fromWinId(WId id)
}
QWindow *window = new QWindow;
- qt_window_private(window)->create(false, id);
+
+ // Persist the winId in a private property so that we
+ // can recreate the window after being destroyed.
+ window->setProperty(kForeignWindowId, id);
+ window->create();
if (!window->handle()) {
delete window;
@@ -2887,7 +3015,7 @@ QWindow *QWindow::fromWinId(WId id)
}
/*!
- Causes an alert to be shown for \a msec miliseconds. If \a msec is \c 0 (the
+ Causes an alert to be shown for \a msec milliseconds. If \a msec is \c 0 (the
default), then the alert is shown indefinitely until the window becomes
active again. This function has no effect on an active window.
@@ -3004,12 +3132,11 @@ bool QWindowPrivate::applyCursor()
}
#endif // QT_NO_CURSOR
-template <>
-Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(const QWindow *that, const char *name, int revision)
+void *QWindow::resolveInterface(const char *name, int revision) const
{
using namespace QNativeInterface::Private;
- auto *platformWindow = that->handle();
+ auto *platformWindow = handle();
Q_UNUSED(platformWindow);
Q_UNUSED(name);
Q_UNUSED(revision);
@@ -3026,6 +3153,14 @@ Q_NATIVE_INTERFACE_EXPORT void *QNativeInterface::Private::resolveInterface(cons
QT_NATIVE_INTERFACE_RETURN_IF(QCocoaWindow, platformWindow);
#endif
+#if QT_CONFIG(wayland)
+ QT_NATIVE_INTERFACE_RETURN_IF(QWaylandWindow, platformWindow);
+#endif
+
+#if defined(Q_OS_WASM)
+ QT_NATIVE_INTERFACE_RETURN_IF(QWasmWindow, platformWindow);
+#endif
+
return nullptr;
}
@@ -3068,7 +3203,7 @@ QDebug operator<<(QDebug debug, const QWindow *window)
}
#endif // !QT_NO_DEBUG_STREAM
-#if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(vulkan) || defined(Q_QDOC)
/*!
Associates this window with the specified Vulkan \a instance.
diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h
index 6200727789..a5ec47708a 100644
--- a/src/gui/kernel/qwindow.h
+++ b/src/gui/kernel/qwindow.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QWINDOW_H
#define QWINDOW_H
@@ -91,7 +55,7 @@ class QWindowContainer;
#ifndef QT_NO_DEBUG_STREAM
class QDebug;
#endif
-#if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(vulkan) || defined(Q_QDOC)
class QVulkanInstance;
#endif
@@ -118,18 +82,23 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface
Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged)
Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged)
Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged)
- Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged)
+ Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight
+ NOTIFY minimumHeightChanged)
Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged)
- Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged)
+ Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight
+ NOTIFY maximumHeightChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged)
Q_PROPERTY(bool active READ isActive NOTIFY activeChanged REVISION(2, 1))
- Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged REVISION(2, 1))
- Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
+ Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged
+ REVISION(2, 1))
+ Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation
+ WRITE reportContentOrientationChange NOTIFY contentOrientationChanged)
Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged REVISION(2, 1))
#ifdef Q_QDOC
Q_PROPERTY(QWindow* transientParent READ transientParent WRITE setTransientParent NOTIFY transientParentChanged)
#else
- Q_PRIVATE_PROPERTY(QWindow::d_func(), QWindow* transientParent MEMBER transientParent WRITE setTransientParent NOTIFY transientParentChanged REVISION(2, 13))
+ Q_PRIVATE_PROPERTY(QWindow::d_func(), QWindow* transientParent MEMBER transientParent
+ WRITE setTransientParent NOTIFY transientParentChanged REVISION(2, 13))
#endif
public:
@@ -279,12 +248,12 @@ public:
static QWindow *fromWinId(WId id);
-#if QT_CONFIG(vulkan) || defined(Q_CLANG_QDOC)
+#if QT_CONFIG(vulkan) || defined(Q_QDOC)
void setVulkanInstance(QVulkanInstance *instance);
QVulkanInstance *vulkanInstance() const;
#endif
- QT_DECLARE_NATIVE_INTERFACE_ACCESSOR
+ QT_DECLARE_NATIVE_INTERFACE_ACCESSOR(QWindow)
public Q_SLOTS:
Q_REVISION(2, 1) void requestActivate();
diff --git a/src/gui/kernel/qwindow_p.h b/src/gui/kernel/qwindow_p.h
index 5d9de82295..a9716847a1 100644
--- a/src/gui/kernel/qwindow_p.h
+++ b/src/gui/kernel/qwindow_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 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) 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 QWINDOW_P_H
#define QWINDOW_P_H
@@ -58,11 +22,13 @@
#include <QtCore/private/qobject_p.h>
#include <QtCore/qelapsedtimer.h>
-#include <QtGui/QIcon>
+#include <QtCore/qxpfunctional.h>
+#include <QtGui/qicon.h>
+#include <QtGui/qpalette.h>
-QT_BEGIN_NAMESPACE
+#include <QtCore/qpointer.h>
-#define QWINDOWSIZE_MAX ((1<<24)-1)
+QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate
{
@@ -75,15 +41,11 @@ public:
WindowFrameExclusive
};
- QWindowPrivate()
- : QObjectPrivate()
- {
- isWindow = true;
- }
+ QWindowPrivate();
+ ~QWindowPrivate() override;
- void init(QScreen *targetScreen = nullptr);
+ void init(QWindow *parent, QScreen *targetScreen = nullptr);
- void maybeQuitOnLastWindowClosed();
#ifndef QT_NO_CURSOR
void setCursor(const QCursor *c = nullptr);
bool applyCursor();
@@ -93,11 +55,8 @@ public:
QWindow *topLevelWindow(QWindow::AncestorMode mode = QWindow::IncludeTransients) const;
-#if QT_CONFIG(opengl)
- virtual QOpenGLContext *shareContext() const;
-#endif
-
virtual QWindow *eventReceiver() { Q_Q(QWindow); return q; }
+ virtual QPalette windowPalette() const { return QPalette(); }
virtual void setVisible(bool visible);
void updateVisibility();
@@ -107,7 +66,7 @@ public:
void updateSiblingPosition(SiblingPosition);
bool windowRecreationRequired(QScreen *newScreen) const;
- void create(bool recursive, WId nativeHandle = 0);
+ void create(bool recursive);
void destroy();
void setTopLevelScreen(QScreen *newScreen, bool recreate);
void connectToScreen(QScreen *topLevelScreen);
@@ -119,12 +78,21 @@ public:
virtual void clearFocusObject();
virtual QRectF closestAcceptableGeometry(const QRectF &rect) const;
+ void setMinOrMaxSize(QSize *oldSizeMember, const QSize &size,
+ qxp::function_ref<void()> funcWidthChanged,
+ qxp::function_ref<void()> funcHeightChanged);
+
virtual void processSafeAreaMarginsChanged() {}
+ virtual bool participatesInLastWindowClosed() const;
+ virtual bool treatAsVisible() const;
+
bool isPopup() const { return (windowFlags & Qt::WindowType_Mask) == Qt::Popup; }
void setAutomaticPositionAndResizeEnabled(bool a)
{ positionAutomatic = resizeAutomatic = a; }
+ bool updateDevicePixelRatio();
+
static QWindowPrivate *get(QWindow *window) { return window->d_func(); }
static Qt::WindowState effectiveState(Qt::WindowStates);
@@ -136,11 +104,13 @@ public:
bool visible= false;
bool visibilityOnDestroy = false;
bool exposed = false;
+ bool inClose = false;
QSurfaceFormat requestedFormat;
QString windowTitle;
QString windowFilePath;
QIcon windowIcon;
QRect geometry;
+ qreal devicePixelRatio = 1.0;
Qt::WindowStates windowState = Qt::WindowNoState;
QWindow::Visibility visibility = QWindow::Hidden;
bool resizeEventPending = true;
@@ -175,7 +145,6 @@ public:
bool hasCursor = false;
#endif
- bool compositing = false;
QElapsedTimer lastComposeTime;
#if QT_CONFIG(vulkan)
diff --git a/src/gui/kernel/qwindowdefs.h b/src/gui/kernel/qwindowdefs.h
index 1ac245900e..27d02d4d58 100644
--- a/src/gui/kernel/qwindowdefs.h
+++ b/src/gui/kernel/qwindowdefs.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QWINDOWDEFS_H
#define QWINDOWDEFS_H
diff --git a/src/gui/kernel/qwindowdefs_win.h b/src/gui/kernel/qwindowdefs_win.h
index 40074d6cce..c2b968fe1f 100644
--- a/src/gui/kernel/qwindowdefs_win.h
+++ b/src/gui/kernel/qwindowdefs_win.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 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) 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 QWINDOWDEFS_WIN_H
#define QWINDOWDEFS_WIN_H
diff --git a/src/gui/kernel/qwindowsysteminterface.cpp b/src/gui/kernel/qwindowsysteminterface.cpp
index 31097dfac6..1875594300 100644
--- a/src/gui/kernel/qwindowsysteminterface.cpp
+++ b/src/gui/kernel/qwindowsysteminterface.cpp
@@ -1,47 +1,13 @@
-/****************************************************************************
-**
-** 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
#include "qwindowsysteminterface.h"
#include <qpa/qplatformwindow.h>
#include "qwindowsysteminterface_p.h"
#include "private/qguiapplication_p.h"
#include "private/qevent_p.h"
+#include "private/qeventpoint_p.h"
#include "private/qpointingdevice_p.h"
+#include "private/qscreen_p.h"
#include <QAbstractEventDispatcher>
#include <qpa/qplatformintegration.h>
#include <qdebug.h>
@@ -56,14 +22,16 @@
QT_BEGIN_NAMESPACE
+using namespace Qt::StringLiterals;
+
Q_LOGGING_CATEGORY(lcQpaInputDevices, "qt.qpa.input.devices")
-QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
+Q_CONSTINIT QElapsedTimer QWindowSystemInterfacePrivate::eventTime;
bool QWindowSystemInterfacePrivate::synchronousWindowSystemEvents = false;
bool QWindowSystemInterfacePrivate::TabletEvent::platformSynthesizesMouse = true;
QWaitCondition QWindowSystemInterfacePrivate::eventsFlushed;
-QMutex QWindowSystemInterfacePrivate::flushEventMutex;
-QAtomicInt QWindowSystemInterfacePrivate::eventAccepted;
+Q_CONSTINIT QMutex QWindowSystemInterfacePrivate::flushEventMutex;
+Q_CONSTINIT QAtomicInt QWindowSystemInterfacePrivate::eventAccepted;
QWindowSystemEventHandler *QWindowSystemInterfacePrivate::eventHandler;
QWindowSystemInterfacePrivate::WindowSystemEventList QWindowSystemInterfacePrivate::windowSystemEventQueue;
@@ -72,20 +40,45 @@ extern QPointer<QWindow> qt_last_mouse_receiver;
// ------------------- QWindowSystemInterfacePrivate -------------------
+/*!
+ \internal
+
+ The QWindowSystemHelper creates synchronously delivered events on the stack, unless
+ the calling thread is not the Gui thread.
+
+ Asynchronously delivered events, and events created outside the Gui thread are
+ allocated on the heap.
+*/
+
+template<typename Delivery>
+struct QWindowSystemHelper
+{
+ template<typename EventType, typename ...Args>
+ static bool handleEvent(Args ...);
+};
+
/*
- Handles a window system event asynchronously by posting the event to Qt Gui.
+ Handles a window system event.
- This function posts the event on the window system event queue and wakes the
- Gui event dispatcher. Qt Gui will then handle the event asynchonously at a
- later point.
+ By default this function posts the event on the window system event queue and
+ wakes the Gui event dispatcher. Qt Gui will then handle the event asynchronously
+ at a later point. The return value is not used in asynchronous mode and will
+ always be true.
+
+ In synchronous mode Qt Gui will process the event immediately. The return value
+ indicates if Qt accepted the event. If the event is delivered from another thread
+ than the Qt main thread the window system event queue is flushed, which may deliver
+ other events as well.
+
+ \sa flushWindowSystemEvents(), setSynchronousWindowSystemEvents()
*/
template<>
-bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(WindowSystemEvent *ev)
+template<typename EventType, typename ...Args>
+bool QWindowSystemHelper<QWindowSystemInterface::DefaultDelivery>::handleEvent(Args ...args)
{
- windowSystemEventQueue.append(ev);
- if (QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher())
- dispatcher->wakeUp();
- return true;
+ return QWindowSystemInterfacePrivate::synchronousWindowSystemEvents
+ ? QWindowSystemHelper<QWindowSystemInterface::SynchronousDelivery>::handleEvent<EventType>(args...)
+ : QWindowSystemHelper<QWindowSystemInterface::AsynchronousDelivery>::handleEvent<EventType>(args...);
}
/*
@@ -99,50 +92,53 @@ bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterfa
well.
*/
template<>
-bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::SynchronousDelivery>(WindowSystemEvent *ev)
+template<typename EventType, typename ...Args>
+bool QWindowSystemHelper<QWindowSystemInterface::SynchronousDelivery>::handleEvent(Args ...args)
{
- bool accepted = true;
if (QThread::currentThread() == QGuiApplication::instance()->thread()) {
- // Process the event immediately on the current thread and return the accepted state.
- QGuiApplicationPrivate::processWindowSystemEvent(ev);
- accepted = ev->eventAccepted;
- delete ev;
+ EventType event(args...);
+ // Process the event immediately on the Gui thread and return the accepted state
+ if (QWindowSystemInterfacePrivate::eventHandler) {
+ if (!QWindowSystemInterfacePrivate::eventHandler->sendEvent(&event))
+ return false;
+ } else {
+ QGuiApplicationPrivate::processWindowSystemEvent(&event);
+ }
+ return event.eventAccepted;
} else {
// Post the event on the Qt main thread queue and flush the queue.
// This will wake up the Gui thread which will process the event.
// Return the accepted state for the last event on the queue,
// which is the event posted by this function.
- handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(ev);
- accepted = QWindowSystemInterface::flushWindowSystemEvents();
+ QWindowSystemHelper<QWindowSystemInterface::AsynchronousDelivery>::handleEvent<EventType>(args...);
+ return QWindowSystemInterface::flushWindowSystemEvents();
}
- return accepted;
}
/*
- Handles a window system event.
-
- By default this function posts the event on the window system event queue and
- wakes the Gui event dispatcher. Qt Gui will then handle the event asynchonously
- at a later point. The return value is not used in asynchronous mode and will
- always be true.
-
- In synchronous mode Qt Gui will process the event immediately. The return value
- indicates if Qt accepted the event. If the event is delivered from another thread
- than the Qt main thread the window system event queue is flushed, which may deliver
- other events as well.
+ Handles a window system event asynchronously by posting the event to Qt Gui.
- \sa flushWindowSystemEvents(), setSynchronousWindowSystemEvents()
+ This function posts the event on the window system event queue and wakes the
+ Gui event dispatcher. Qt Gui will then handle the event asynchronously at a
+ later point.
*/
template<>
-bool QWindowSystemInterfacePrivate::handleWindowSystemEvent<QWindowSystemInterface::DefaultDelivery>(QWindowSystemInterfacePrivate::WindowSystemEvent *ev)
+template<typename EventType, typename ...Args>
+bool QWindowSystemHelper<QWindowSystemInterface::AsynchronousDelivery>::handleEvent(Args ...args)
{
- if (synchronousWindowSystemEvents)
- return handleWindowSystemEvent<QWindowSystemInterface::SynchronousDelivery>(ev);
- else
- return handleWindowSystemEvent<QWindowSystemInterface::AsynchronousDelivery>(ev);
+ QWindowSystemInterfacePrivate::windowSystemEventQueue.append(new EventType(args...));
+ if (QAbstractEventDispatcher *dispatcher = QGuiApplicationPrivate::qt_qpa_core_dispatcher())
+ dispatcher->wakeUp();
+ return true;
+}
+
+template <typename EventType, typename Delivery = QWindowSystemInterface::DefaultDelivery, typename ...Args>
+static bool handleWindowSystemEvent(Args ...args)
+{
+ return QWindowSystemHelper<Delivery>::template handleEvent<EventType>(args...);
}
-int QWindowSystemInterfacePrivate::windowSystemEventsQueued()
+qsizetype QWindowSystemInterfacePrivate::windowSystemEventsQueued()
{
return windowSystemEventQueue.count();
}
@@ -221,16 +217,14 @@ bool QWindowSystemEventHandler::sendEvent(QWindowSystemInterfacePrivate::WindowS
QT_DEFINE_QPA_EVENT_HANDLER(void, handleEnterEvent, QWindow *window, const QPointF &local, const QPointF &global)
{
if (window) {
- QWindowSystemInterfacePrivate::EnterEvent *e
- = new QWindowSystemInterfacePrivate::EnterEvent(window, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window));
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::EnterEvent, Delivery>(window,
+ QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window));
}
}
QT_DEFINE_QPA_EVENT_HANDLER(void, handleLeaveEvent, QWindow *window)
{
- QWindowSystemInterfacePrivate::LeaveEvent *e = new QWindowSystemInterfacePrivate::LeaveEvent(window);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::LeaveEvent, Delivery>(window);
}
/*!
@@ -246,11 +240,9 @@ void QWindowSystemInterface::handleEnterLeaveEvent(QWindow *enter, QWindow *leav
handleEnterEvent(enter, local, global);
}
-QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowActivated, QWindow *window, Qt::FocusReason r)
+QT_DEFINE_QPA_EVENT_HANDLER(void, handleFocusWindowChanged, QWindow *window, Qt::FocusReason r)
{
- QWindowSystemInterfacePrivate::ActivatedWindowEvent *e =
- new QWindowSystemInterfacePrivate::ActivatedWindowEvent(window, r);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::FocusWindowEvent, Delivery>(window, r);
}
QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt::WindowStates newState, int oldState)
@@ -259,38 +251,35 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowStateChanged, QWindow *window, Qt:
if (oldState < Qt::WindowNoState)
oldState = window->windowStates();
- QWindowSystemInterfacePrivate::WindowStateChangedEvent *e =
- new QWindowSystemInterfacePrivate::WindowStateChangedEvent(window, newState, Qt::WindowStates(oldState));
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowStateChangedEvent, Delivery>(window, newState, Qt::WindowStates(oldState));
}
QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowScreenChanged, QWindow *window, QScreen *screen)
{
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowScreenChangedEvent, Delivery>(window, screen);
+}
- QWindowSystemInterfacePrivate::WindowScreenChangedEvent *e =
- new QWindowSystemInterfacePrivate::WindowScreenChangedEvent(window, screen);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+QT_DEFINE_QPA_EVENT_HANDLER(void, handleWindowDevicePixelRatioChanged, QWindow *window)
+{
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowDevicePixelRatioChangedEvent, Delivery>(window);
}
+
QT_DEFINE_QPA_EVENT_HANDLER(void, handleSafeAreaMarginsChanged, QWindow *window)
{
- QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent *e =
- new QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent(window);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::SafeAreaMarginsChangedEvent, Delivery>(window);
}
QT_DEFINE_QPA_EVENT_HANDLER(void, handleApplicationStateChanged, Qt::ApplicationState newState, bool forcePropagate)
{
Q_ASSERT(QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::ApplicationState));
- QWindowSystemInterfacePrivate::ApplicationStateChangedEvent *e =
- new QWindowSystemInterfacePrivate::ApplicationStateChangedEvent(newState, forcePropagate);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::ApplicationStateChangedEvent, Delivery>(newState, forcePropagate);
}
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleApplicationTermination)
{
- auto *e = new QWindowSystemInterfacePrivate::WindowSystemEvent(QWindowSystemInterfacePrivate::ApplicationTermination);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowSystemEvent, Delivery>(
+ QWindowSystemInterfacePrivate::ApplicationTermination);
}
QWindowSystemInterfacePrivate::GeometryChangeEvent::GeometryChangeEvent(QWindow *window, const QRect &newGeometry)
@@ -308,7 +297,6 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleGeometryChange, QWindow *window, const Q
{
Q_ASSERT(window);
const auto newRectDi = QHighDpi::fromNativeWindowGeometry(newRect, window);
- auto e = new QWindowSystemInterfacePrivate::GeometryChangeEvent(window, newRectDi);
if (window->handle()) {
// Persist the new geometry so that QWindow::geometry() can be queried in the resize event
window->handle()->QPlatformWindow::setGeometry(newRect);
@@ -316,7 +304,7 @@ QT_DEFINE_QPA_EVENT_HANDLER(void, handleGeometryChange, QWindow *window, const Q
// have its handle set up yet. Platforms that deliver events during window creation need
// to handle the persistence manually, e.g. by overriding geometry().
}
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::GeometryChangeEvent, Delivery>(window, newRectDi);
}
QWindowSystemInterfacePrivate::ExposeEvent::ExposeEvent(QWindow *window, const QRegion &region)
@@ -346,24 +334,21 @@ QWindowSystemInterfacePrivate::ExposeEvent::ExposeEvent(QWindow *window, const Q
*/
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleExposeEvent, QWindow *window, const QRegion &region)
{
- QWindowSystemInterfacePrivate::ExposeEvent *e =
- new QWindowSystemInterfacePrivate::ExposeEvent(window, QHighDpi::fromNativeLocalExposedRegion(region, window));
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::ExposeEvent, Delivery>(window,
+ QHighDpi::fromNativeLocalExposedRegion(region, window));
}
QT_DEFINE_QPA_EVENT_HANDLER(bool, handlePaintEvent, QWindow *window, const QRegion &region)
{
- QWindowSystemInterfacePrivate::PaintEvent *e =
- new QWindowSystemInterfacePrivate::PaintEvent(window, QHighDpi::fromNativeLocalExposedRegion(region, window));
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::PaintEvent, Delivery>(window,
+ QHighDpi::fromNativeLocalExposedRegion(region, window));
}
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleCloseEvent, QWindow *window)
{
Q_ASSERT(window);
- auto *event = new QWindowSystemInterfacePrivate::CloseEvent(window);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(event);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::CloseEvent, Delivery>(window);
}
/*!
@@ -404,65 +389,34 @@ QT_DEFINE_QPA_EVENT_HANDLER(bool, handleMouseEvent, QWindow *window, ulong times
Qt::MouseButton button, QEvent::Type type, Qt::KeyboardModifiers mods,
Qt::MouseEventSource source)
{
- Q_ASSERT_X(type != QEvent::MouseButtonDblClick && type != QEvent::NonClientAreaMouseButtonDblClick,
- "QWindowSystemInterface::handleMouseEvent",
- "QTBUG-71263: Native double clicks are not implemented.");
- auto localPos = QHighDpi::fromNativeLocalPosition(local, window);
- auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window);
-
- QWindowSystemInterfacePrivate::MouseEvent *e =
- new QWindowSystemInterfacePrivate::MouseEvent(window, timestamp, localPos, globalPos,
- state, mods, button, type, source, false, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
-}
-
-bool QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window,
- const QPointF &local, const QPointF &global,
- Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods,
- Qt::MouseEventSource source)
-{
- const unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- return handleFrameStrutMouseEvent(window, time, local, global, state, button, type, mods, source);
-}
-bool QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window, const QPointingDevice *device,
- const QPointF &local, const QPointF &global,
- Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods,
- Qt::MouseEventSource source)
-{
- const unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
- return handleFrameStrutMouseEvent(window, time, device, local, global, state, button, type, mods, source);
-}
+ bool isNonClientArea = {};
-bool QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window, ulong timestamp,
- const QPointF &local, const QPointF &global,
- Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods,
- Qt::MouseEventSource source)
-{
- return handleFrameStrutMouseEvent(window, timestamp, QPointingDevice::primaryPointingDevice(),
- local, global, state, button, type, mods, source);
-}
+ switch (type) {
+ case QEvent::MouseButtonDblClick:
+ case QEvent::NonClientAreaMouseButtonDblClick:
+ Q_ASSERT_X(false, "QWindowSystemInterface::handleMouseEvent",
+ "QTBUG-71263: Native double clicks are not implemented.");
+ return false;
+ case QEvent::MouseMove:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ isNonClientArea = false;
+ break;
+ case QEvent::NonClientAreaMouseMove:
+ case QEvent::NonClientAreaMouseButtonPress:
+ case QEvent::NonClientAreaMouseButtonRelease:
+ isNonClientArea = true;
+ break;
+ default:
+ Q_UNREACHABLE();
+ }
-bool QWindowSystemInterface::handleFrameStrutMouseEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
- const QPointF &local, const QPointF &global,
- Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods,
- Qt::MouseEventSource source)
-{
auto localPos = QHighDpi::fromNativeLocalPosition(local, window);
auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window);
- QWindowSystemInterfacePrivate::MouseEvent *e =
- new QWindowSystemInterfacePrivate::MouseEvent(window, timestamp, localPos, globalPos,
- state, mods, button, type, source, true, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::MouseEvent, Delivery>(window,
+ timestamp, localPos, globalPos, state, mods, button, type, source, isNonClientArea, device);
}
bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestamp, int keyCode, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode,
@@ -479,13 +433,11 @@ bool QWindowSystemInterface::handleShortcutEvent(QWindow *window, ulong timestam
// key event, so that the target that accepted the shortcut override event can handle it. Note that we only
// do this if the shortcut map hasn't found a partial shortcut match yet. If it has, the shortcut can not be
// overridden.
- QWindowSystemInterfacePrivate::KeyEvent *shortcutOverrideEvent = new QWindowSystemInterfacePrivate::KeyEvent(window, timestamp,
- QEvent::ShortcutOverride, keyCode, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorepeat, count);
-
- {
- if (QWindowSystemInterfacePrivate::handleWindowSystemEvent<SynchronousDelivery>(shortcutOverrideEvent))
- return false;
- }
+ bool overridden = handleWindowSystemEvent<QWindowSystemInterfacePrivate::KeyEvent, SynchronousDelivery>
+ (window,timestamp, QEvent::ShortcutOverride, keyCode, modifiers, nativeScanCode,
+ nativeVirtualKey, nativeModifiers, text, autorepeat, count);
+ if (overridden)
+ return false;
}
// The shortcut event is dispatched as a QShortcutEvent, not a QKeyEvent, but we use
@@ -517,25 +469,19 @@ QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *window, QEvent::Type
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleKeyEvent, QWindow *window, ulong timestamp, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text, bool autorep, ushort count)
{
-#if defined(Q_OS_MACOS)
- if (t == QEvent::KeyPress && QWindowSystemInterface::handleShortcutEvent(window, timestamp, k, mods, 0, 0, 0, text, autorep, count))
- return true;
-#endif
-
- QWindowSystemInterfacePrivate::KeyEvent * e =
- new QWindowSystemInterfacePrivate::KeyEvent(window, timestamp, t, k, mods, text, autorep, count);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::KeyEvent, Delivery>(window,
+ timestamp, t, k, mods, text, autorep, count);
}
bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *window, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text, bool autorep,
- ushort count, bool tryShortcutOverride)
+ ushort count)
{
unsigned long time = QWindowSystemInterfacePrivate::eventTime.elapsed();
return handleExtendedKeyEvent(window, time, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers,
- text, autorep, count, tryShortcutOverride);
+ text, autorep, count);
}
bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *window, ulong timestamp, QEvent::Type type, int key,
@@ -543,21 +489,10 @@ bool QWindowSystemInterface::handleExtendedKeyEvent(QWindow *window, ulong times
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text, bool autorep,
- ushort count, bool tryShortcutOverride)
+ ushort count)
{
-#if defined(Q_OS_MACOS)
- if (tryShortcutOverride && type == QEvent::KeyPress && QWindowSystemInterface::handleShortcutEvent(window,
- timestamp, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count)) {
- return true;
- }
-#else
- Q_UNUSED(tryShortcutOverride);
-#endif
-
- QWindowSystemInterfacePrivate::KeyEvent * e =
- new QWindowSystemInterfacePrivate::KeyEvent(window, timestamp, type, key, modifiers,
- nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::KeyEvent>(window,
+ timestamp, type, key, modifiers, nativeScanCode, nativeVirtualKey, nativeModifiers, text, autorep, count);
}
bool QWindowSystemInterface::handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global, QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods, Qt::ScrollPhase phase, Qt::MouseEventSource source)
@@ -585,7 +520,6 @@ bool QWindowSystemInterface::handleWheelEvent(QWindow *window, ulong timestamp,
// In addition high-resolution pixel-based deltas are also supported.
// Platforms that does not support these may pass a null point here.
// Angle deltas must always be sent in addition to pixel deltas.
- QWindowSystemInterfacePrivate::WheelEvent *e;
// Pass Qt::ScrollBegin and Qt::ScrollEnd through
// even if the wheel delta is null.
@@ -594,16 +528,16 @@ bool QWindowSystemInterface::handleWheelEvent(QWindow *window, ulong timestamp,
// Simple case: vertical deltas only:
if (angleDelta.y() != 0 && angleDelta.x() == 0) {
- e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
- pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
+ timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
+ pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling, device);
}
// Simple case: horizontal deltas only:
if (angleDelta.y() == 0 && angleDelta.x() != 0) {
- e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
- pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
+ timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
+ pixelDelta, angleDelta, angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling, device);
}
bool acceptVert;
@@ -611,15 +545,16 @@ bool QWindowSystemInterface::handleWheelEvent(QWindow *window, ulong timestamp,
// Both horizontal and vertical deltas: Send two wheel events.
// The first event contains the Qt 5 pixel and angle delta as points,
// and in addition the Qt 4 compatibility vertical angle delta.
- e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
- pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling, device);
- acceptVert = QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ acceptVert = handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
+ timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
+ pixelDelta, angleDelta, angleDelta.y(), Qt::Vertical, mods, phase, source, invertedScrolling, device);
// The second event contains null pixel and angle points and the
// Qt 4 compatibility horizontal angle delta.
- e = new QWindowSystemInterfacePrivate::WheelEvent(window, timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
- QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling, device);
- acceptHorz = QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ acceptHorz = handleWindowSystemEvent<QWindowSystemInterfacePrivate::WheelEvent>(window,
+ timestamp, QHighDpi::fromNativeLocalPosition(local, window), QHighDpi::fromNativeGlobalPosition(global, window),
+ QPoint(), QPoint(), angleDelta.x(), Qt::Horizontal, mods, phase, source, invertedScrolling, device);
+
return acceptVert || acceptHorz;
}
@@ -679,19 +614,19 @@ QList<QEventPoint>
QList<QEventPoint> touchPoints;
QEventPoint::States states;
- touchPoints.reserve(points.count());
+ touchPoints.reserve(points.size());
QList<QWindowSystemInterface::TouchPoint>::const_iterator point = points.constBegin();
QList<QWindowSystemInterface::TouchPoint>::const_iterator end = points.constEnd();
while (point != end) {
QPointF globalPos = QHighDpi::fromNativePixels(point->area.center(), window);
- QMutableEventPoint p(point->id, point->state, globalPos, globalPos);
+ QEventPoint p(point->id, point->state, globalPos, globalPos);
states |= point->state;
if (point->uniqueId >= 0)
- p.setUniqueId(QPointingDeviceUniqueId::fromNumericId(point->uniqueId));
- p.setPressure(point->pressure);
- p.setRotation(point->rotation);
- p.setEllipseDiameters(QHighDpi::fromNativePixels(point->area.size(), window));
- p.setVelocity(QHighDpi::fromNativePixels(point->velocity, window));
+ QMutableEventPoint::setUniqueId(p, QPointingDeviceUniqueId::fromNumericId(point->uniqueId));
+ QMutableEventPoint::setPressure(p, point->pressure);
+ QMutableEventPoint::setRotation(p, point->rotation);
+ QMutableEventPoint::setEllipseDiameters(p, QHighDpi::fromNativePixels(point->area.size(), window));
+ QMutableEventPoint::setVelocity(p, QHighDpi::fromNativePixels(point->velocity, window));
// The local pos is not set: it will be calculated
// when the event gets processed by QGuiApplication.
@@ -746,9 +681,9 @@ QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchEvent, QWindow *window, ulong times
QEvent::Type type;
QList<QEventPoint> touchPoints =
QWindowSystemInterfacePrivate::fromNativeTouchPoints(points, window, &type);
- QWindowSystemInterfacePrivate::TouchEvent *e =
- new QWindowSystemInterfacePrivate::TouchEvent(window, timestamp, type, device, touchPoints, mods);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TouchEvent, Delivery>(window,
+ timestamp, type, device, touchPoints, mods);
}
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, const QPointingDevice *device,
@@ -761,10 +696,8 @@ QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, const
QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, ulong timestamp, const QPointingDevice *device,
Qt::KeyboardModifiers mods)
{
- QWindowSystemInterfacePrivate::TouchEvent *e =
- new QWindowSystemInterfacePrivate::TouchEvent(window, timestamp, QEvent::TouchCancel, device,
- QList<QEventPoint>(), mods);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TouchEvent, Delivery>(window,
+ timestamp, QEvent::TouchCancel, device, QList<QEventPoint>(), mods);
}
/*!
@@ -778,9 +711,9 @@ QT_DEFINE_QPA_EVENT_HANDLER(bool, handleTouchCancelEvent, QWindow *window, ulong
The screen should be deleted by calling QWindowSystemInterface::handleScreenRemoved().
*/
-void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrimary)
+void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *platformScreen, bool isPrimary)
{
- QScreen *screen = new QScreen(ps);
+ QScreen *screen = new QScreen(platformScreen);
if (isPrimary)
QGuiApplicationPrivate::screen_list.prepend(screen);
@@ -789,6 +722,7 @@ void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrima
QGuiApplicationPrivate::resetCachedDevicePixelRatio();
QHighDpiScaling::updateHighDpiScaling();
+ screen->d_func()->updateGeometry();
emit qGuiApp->screenAdded(screen);
@@ -806,9 +740,45 @@ void QWindowSystemInterface::handleScreenAdded(QPlatformScreen *ps, bool isPrima
*/
void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen)
{
- // Important to keep this order since the QSceen doesn't own the platform screen.
- // The QScreen destructor will take care changing the primary screen, so no need here.
- delete platformScreen->screen();
+ QScreen *screen = platformScreen->screen();
+
+ // Remove screen
+ const bool wasPrimary = QGuiApplication::primaryScreen() == screen;
+ QGuiApplicationPrivate::screen_list.removeOne(screen);
+ QGuiApplicationPrivate::resetCachedDevicePixelRatio();
+
+ if (qGuiApp) {
+ QScreen *newPrimaryScreen = QGuiApplication::primaryScreen();
+ if (wasPrimary && newPrimaryScreen)
+ emit qGuiApp->primaryScreenChanged(newPrimaryScreen);
+
+ // Allow clients to manage windows that are affected by the screen going
+ // away, before we fall back to moving them to the primary screen.
+ emit qApp->screenRemoved(screen);
+
+ if (!QGuiApplication::closingDown()) {
+ bool movingFromVirtualSibling = newPrimaryScreen
+ && newPrimaryScreen->handle()->virtualSiblings().contains(platformScreen);
+
+ // Move any leftover windows to the primary screen
+ const auto allWindows = QGuiApplication::allWindows();
+ for (QWindow *window : allWindows) {
+ if (!window->isTopLevel() || window->screen() != screen)
+ continue;
+
+ const bool wasVisible = window->isVisible();
+ window->setScreen(newPrimaryScreen);
+
+ // Re-show window if moved from a virtual sibling screen. Otherwise
+ // leave it up to the application developer to show the window.
+ if (movingFromVirtualSibling)
+ window->setVisible(wasVisible);
+ }
+ }
+ }
+
+ // Important to keep this order since the QSceen doesn't own the platform screen
+ delete screen;
delete platformScreen;
}
@@ -821,7 +791,7 @@ void QWindowSystemInterface::handleScreenRemoved(QPlatformScreen *platformScreen
void QWindowSystemInterface::handlePrimaryScreenChanged(QPlatformScreen *newPrimary)
{
QScreen *newPrimaryScreen = newPrimary->screen();
- int indexOfScreen = QGuiApplicationPrivate::screen_list.indexOf(newPrimaryScreen);
+ qsizetype indexOfScreen = QGuiApplicationPrivate::screen_list.indexOf(newPrimaryScreen);
Q_ASSERT(indexOfScreen >= 0);
if (indexOfScreen == 0)
return;
@@ -832,36 +802,36 @@ void QWindowSystemInterface::handlePrimaryScreenChanged(QPlatformScreen *newPrim
void QWindowSystemInterface::handleScreenOrientationChange(QScreen *screen, Qt::ScreenOrientation orientation)
{
- QWindowSystemInterfacePrivate::ScreenOrientationEvent *e =
- new QWindowSystemInterfacePrivate::ScreenOrientationEvent(screen, orientation);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenOrientationEvent>(screen, orientation);
}
void QWindowSystemInterface::handleScreenGeometryChange(QScreen *screen, const QRect &geometry, const QRect &availableGeometry)
{
- QWindowSystemInterfacePrivate::ScreenGeometryEvent *e =
- new QWindowSystemInterfacePrivate::ScreenGeometryEvent(screen, QHighDpi::fromNativeScreenGeometry(geometry, screen), QHighDpi::fromNative(availableGeometry, screen, geometry.topLeft()));
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenGeometryEvent>(screen,
+ QHighDpi::fromNativeScreenGeometry(geometry, screen), QHighDpi::fromNative(availableGeometry,
+ screen, geometry.topLeft()));
}
void QWindowSystemInterface::handleScreenLogicalDotsPerInchChange(QScreen *screen, qreal dpiX, qreal dpiY)
{
+ // Keep QHighDpiScaling::m_active in sync with platform screen state, in
+ // order to make scaling calls made during DPI change use the new state.
+ // FIXME: Remove when QHighDpiScaling::m_active has been removed.
+ QHighDpiScaling::updateHighDpiScaling();
+
const QDpi effectiveDpi = QPlatformScreen::overrideDpi(QDpi{dpiX, dpiY});
- auto e = new QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent(screen, effectiveDpi.first, effectiveDpi.second);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenLogicalDotsPerInchEvent>(screen,
+ effectiveDpi.first, effectiveDpi.second);
}
void QWindowSystemInterface::handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate)
{
- QWindowSystemInterfacePrivate::ScreenRefreshRateEvent *e =
- new QWindowSystemInterfacePrivate::ScreenRefreshRateEvent(screen, newRefreshRate);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::ScreenRefreshRateEvent>(screen, newRefreshRate);
}
QT_DEFINE_QPA_EVENT_HANDLER(void, handleThemeChange, QWindow *window)
{
- QWindowSystemInterfacePrivate::ThemeChangeEvent *e = new QWindowSystemInterfacePrivate::ThemeChangeEvent(window);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<Delivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::ThemeChangeEvent, Delivery>(window);
}
#if QT_CONFIG(draganddrop)
@@ -924,13 +894,12 @@ bool QWindowSystemInterface::handleTabletEvent(QWindow *window, ulong timestamp,
qreal tangentialPressure, qreal rotation, int z,
Qt::KeyboardModifiers modifiers)
{
- QWindowSystemInterfacePrivate::TabletEvent *e =
- new QWindowSystemInterfacePrivate::TabletEvent(window, timestamp,
- QHighDpi::fromNativeLocalPosition(local, window),
- QHighDpi::fromNativeGlobalPosition(global, window),
- device, buttons, pressure,
- xTilt, yTilt, tangentialPressure, rotation, z, modifiers);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletEvent>(window,
+ timestamp,
+ QHighDpi::fromNativeLocalPosition(local, window),
+ QHighDpi::fromNativeGlobalPosition(global, window),
+ device, buttons, pressure,
+ xTilt, yTilt, tangentialPressure, rotation, z, modifiers);
}
bool QWindowSystemInterface::handleTabletEvent(QWindow *window, const QPointingDevice *device,
@@ -982,15 +951,9 @@ bool QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(QWindow *windo
Q_UNUSED(rotation);
Q_UNUSED(z);
Q_UNUSED(modifiers);
- if (inProximity) {
- QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e =
- new QWindowSystemInterfacePrivate::TabletEnterProximityEvent(timestamp, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
- } else {
- QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e =
- new QWindowSystemInterfacePrivate::TabletLeaveProximityEvent(timestamp, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
- }
+ return inProximity
+ ? handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletEnterProximityEvent>(timestamp, device)
+ : handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent>(timestamp, device);
}
bool QWindowSystemInterface::handleTabletEnterLeaveProximityEvent(QWindow *window, const QPointingDevice *device,
@@ -1011,9 +974,7 @@ bool QWindowSystemInterface::handleTabletEnterProximityEvent(ulong timestamp, in
const QPointingDevice *device = QPointingDevicePrivate::tabletDevice(QInputDevice::DeviceType(deviceType),
QPointingDevice::PointerType(pointerType),
QPointingDeviceUniqueId::fromNumericId(uid));
- QWindowSystemInterfacePrivate::TabletEnterProximityEvent *e =
- new QWindowSystemInterfacePrivate::TabletEnterProximityEvent(timestamp, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletEnterProximityEvent>(timestamp, device);
}
void QWindowSystemInterface::handleTabletEnterProximityEvent(int deviceType, int pointerType, qint64 uid)
@@ -1027,9 +988,7 @@ bool QWindowSystemInterface::handleTabletLeaveProximityEvent(ulong timestamp, in
const QPointingDevice *device = QPointingDevicePrivate::tabletDevice(QInputDevice::DeviceType(deviceType),
QPointingDevice::PointerType(pointerType),
QPointingDeviceUniqueId::fromNumericId(uid));
- QWindowSystemInterfacePrivate::TabletLeaveProximityEvent *e =
- new QWindowSystemInterfacePrivate::TabletLeaveProximityEvent(timestamp, device);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::TabletLeaveProximityEvent>(timestamp, device);
}
void QWindowSystemInterface::handleTabletLeaveProximityEvent(int deviceType, int pointerType, qint64 uid)
@@ -1042,37 +1001,30 @@ void QWindowSystemInterface::handleTabletLeaveProximityEvent(int deviceType, int
bool QWindowSystemInterface::handleGestureEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
Qt::NativeGestureType type, const QPointF &local, const QPointF &global, int fingerCount)
{
- QWindowSystemInterfacePrivate::GestureEvent *e =
- new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, fingerCount, local, global);
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleGestureEventWithValueAndDelta(window, timestamp, device, type, {}, {}, local, global, fingerCount);
}
bool QWindowSystemInterface::handleGestureEventWithRealValue(QWindow *window, ulong timestamp, const QPointingDevice *device,
Qt::NativeGestureType type, qreal value, const QPointF &local, const QPointF &global, int fingerCount)
{
- QWindowSystemInterfacePrivate::GestureEvent *e =
- new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, fingerCount, local, global);
- e->realValue = value;
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ return handleGestureEventWithValueAndDelta(window, timestamp, device, type, value, {}, local, global, fingerCount);
}
-bool QWindowSystemInterface::handleGestureEventWithValueAndDeltas(QWindow *window, ulong timestamp, const QPointingDevice *device,
- Qt::NativeGestureType type, qreal value, QVector2D deltas,
- const QPointF &local, const QPointF &global, int fingerCount)
+bool QWindowSystemInterface::handleGestureEventWithValueAndDelta(QWindow *window, ulong timestamp, const QPointingDevice *device,
+ Qt::NativeGestureType type, qreal value, const QPointF &delta,
+ const QPointF &local, const QPointF &global, int fingerCount)
{
- QWindowSystemInterfacePrivate::GestureEvent *e =
- new QWindowSystemInterfacePrivate::GestureEvent(window, timestamp, type, device, fingerCount, local, global);
- e->realValue = value;
- e->deltas = deltas;
- return QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ auto localPos = QHighDpi::fromNativeLocalPosition(local, window);
+ auto globalPos = QHighDpi::fromNativeGlobalPosition(global, window);
+
+ return handleWindowSystemEvent<QWindowSystemInterfacePrivate::GestureEvent>(window,
+ timestamp, type, device, fingerCount, localPos, globalPos, value, delta);
}
#endif // QT_NO_GESTURES
void QWindowSystemInterface::handlePlatformPanelEvent(QWindow *w)
{
- QWindowSystemInterfacePrivate::PlatformPanelEvent *e =
- new QWindowSystemInterfacePrivate::PlatformPanelEvent(w);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::PlatformPanelEvent>(w);
}
#ifndef QT_NO_CONTEXTMENU
@@ -1080,19 +1032,16 @@ void QWindowSystemInterface::handleContextMenuEvent(QWindow *window, bool mouseT
const QPoint &pos, const QPoint &globalPos,
Qt::KeyboardModifiers modifiers)
{
- QWindowSystemInterfacePrivate::ContextMenuEvent *e =
- new QWindowSystemInterfacePrivate::ContextMenuEvent(window, mouseTriggered, pos,
- globalPos, modifiers);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::ContextMenuEvent>(window,
+ mouseTriggered, pos, globalPos, modifiers);
}
#endif
#if QT_CONFIG(whatsthis)
void QWindowSystemInterface::handleEnterWhatsThisEvent()
{
- QWindowSystemInterfacePrivate::WindowSystemEvent *e =
- new QWindowSystemInterfacePrivate::WindowSystemEvent(QWindowSystemInterfacePrivate::EnterWhatsThisMode);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::WindowSystemEvent>(
+ QWindowSystemInterfacePrivate::EnterWhatsThisMode);
}
#endif
@@ -1114,7 +1063,7 @@ Q_GUI_EXPORT QDebug operator<<(QDebug dbg, const QWindowSystemInterface::TouchPo
*/
bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFlags flags)
{
- const int count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
+ const qsizetype count = QWindowSystemInterfacePrivate::windowSystemEventQueue.count();
if (!count)
return false;
if (!QGuiApplication::instance()) {
@@ -1128,8 +1077,7 @@ bool QWindowSystemInterface::flushWindowSystemEvents(QEventLoop::ProcessEventsFl
// Post a FlushEvents event which will trigger a call back to
// deferredFlushWindowSystemEvents from the Gui thread.
QMutexLocker locker(&QWindowSystemInterfacePrivate::flushEventMutex);
- QWindowSystemInterfacePrivate::FlushEventsEvent *e = new QWindowSystemInterfacePrivate::FlushEventsEvent(flags);
- QWindowSystemInterfacePrivate::handleWindowSystemEvent<AsynchronousDelivery>(e);
+ handleWindowSystemEvent<QWindowSystemInterfacePrivate::FlushEventsEvent, AsynchronousDelivery>(flags);
QWindowSystemInterfacePrivate::eventsFlushed.wait(&QWindowSystemInterfacePrivate::flushEventMutex);
} else {
sendWindowSystemEvents(flags);
@@ -1210,8 +1158,18 @@ Q_GUI_EXPORT void qt_handleMouseEvent(QWindow *window, const QPointF &local, con
timestamp, nativeLocal, nativeGlobal, state, button, type, mods);
}
+/*
+ Used by QTest::simulateEvent() to synthesize key events during testing
+*/
Q_GUI_EXPORT void qt_handleKeyEvent(QWindow *window, QEvent::Type t, int k, Qt::KeyboardModifiers mods, const QString & text = QString(), bool autorep = false, ushort count = 1)
{
+#if defined(Q_OS_MACOS)
+ // FIXME: Move into QTest::simulateEvent() and align with QGuiApplicationPrivate::processKeyEvent()
+ auto timestamp = QWindowSystemInterfacePrivate::eventTime.elapsed();
+ if (t == QEvent::KeyPress && QWindowSystemInterface::handleShortcutEvent(window, timestamp, k, mods, 0, 0, 0, text, autorep, count))
+ return;
+#endif
+
QWindowSystemInterface::handleKeyEvent<QWindowSystemInterface::SynchronousDelivery>(window, t, k, mods, text, autorep, count);
}
@@ -1252,13 +1210,20 @@ Q_GUI_EXPORT bool qt_sendShortcutOverrideEvent(QObject *o, ulong timestamp, int
#endif
}
+Q_GUI_EXPORT void qt_handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global,
+ QPoint pixelDelta, QPoint angleDelta, Qt::KeyboardModifiers mods,
+ Qt::ScrollPhase phase)
+{
+ QWindowSystemInterface::handleWheelEvent(window, local, global, pixelDelta, angleDelta, mods, phase);
+}
+
namespace QTest
{
- Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType = QInputDevice::DeviceType::TouchScreen,
- QInputDevice::Capabilities caps = QInputDevice::Capability::Position)
+ Q_GUI_EXPORT QPointingDevice * createTouchDevice(QInputDevice::DeviceType devType,
+ QInputDevice::Capabilities caps)
{
static qint64 nextId = 0x100000000;
- QPointingDevice *ret = new QPointingDevice(QLatin1String("test touch device"), nextId++,
+ QPointingDevice *ret = new QPointingDevice("test touch device"_L1, nextId++,
devType, QPointingDevice::PointerType::Finger,
caps, 8, 0);
QWindowSystemInterface::registerInputDevice(ret);
@@ -1266,13 +1231,19 @@ namespace QTest
}
}
-Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *window, const QPointingDevice *device,
+Q_GUI_EXPORT bool qt_handleTouchEventv2(QWindow *window, const QPointingDevice *device,
const QList<QEventPoint> &points,
- Qt::KeyboardModifiers mods = Qt::NoModifier)
+ Qt::KeyboardModifiers mods)
{
- QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(window, device,
+ return QWindowSystemInterface::handleTouchEvent<QWindowSystemInterface::SynchronousDelivery>(window, device,
QWindowSystemInterfacePrivate::toNativeTouchPoints(points, window), mods);
}
+Q_GUI_EXPORT void qt_handleTouchEvent(QWindow *window, const QPointingDevice *device,
+ const QList<QEventPoint> &points,
+ Qt::KeyboardModifiers mods)
+{
+ qt_handleTouchEventv2(window, device, points, mods);
+}
QT_END_NAMESPACE
diff --git a/src/gui/kernel/qwindowsysteminterface.h b/src/gui/kernel/qwindowsysteminterface.h
index 742d8201dd..4fc61a475d 100644
--- a/src/gui/kernel/qwindowsysteminterface.h
+++ b/src/gui/kernel/qwindowsysteminterface.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 QWINDOWSYSTEMINTERFACE_H
#define QWINDOWSYSTEMINTERFACE_H
@@ -100,31 +64,6 @@ public:
Qt::KeyboardModifiers mods = Qt::NoModifier,
Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
- static bool handleFrameStrutMouseEvent(QWindow *window, const QPointF &local,
- const QPointF &global, Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods = Qt::NoModifier,
- Qt::MouseEventSource source =
- Qt::MouseEventNotSynthesized);
- static bool handleFrameStrutMouseEvent(QWindow *window, const QPointingDevice *device,
- const QPointF &local, const QPointF &global,
- Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods = Qt::NoModifier,
- Qt::MouseEventSource source =
- Qt::MouseEventNotSynthesized);
- static bool handleFrameStrutMouseEvent(QWindow *window, ulong timestamp, const QPointF &local,
- const QPointF &global, Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods = Qt::NoModifier,
- Qt::MouseEventSource source =
- Qt::MouseEventNotSynthesized);
- static bool handleFrameStrutMouseEvent(QWindow *window, ulong timestamp, const QPointingDevice *device,
- const QPointF &local, const QPointF &global, Qt::MouseButtons state,
- Qt::MouseButton button, QEvent::Type type,
- Qt::KeyboardModifiers mods = Qt::NoModifier,
- Qt::MouseEventSource source = Qt::MouseEventNotSynthesized);
-
static bool handleShortcutEvent(QWindow *window, ulong timestamp, int k, Qt::KeyboardModifiers mods, quint32 nativeScanCode,
quint32 nativeVirtualKey, quint32 nativeModifiers, const QString & text = QString(), bool autorep = false, ushort count = 1);
@@ -137,18 +76,18 @@ public:
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
- ushort count = 1, bool tryShortcutOverride = true);
+ ushort count = 1);
static bool handleExtendedKeyEvent(QWindow *window, ulong timestamp, QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
- ushort count = 1, bool tryShortcutOverride = true);
+ ushort count = 1);
static bool handleExtendedKeyEvent(QWindow *window, ulong timestamp, const QInputDevice *device,
QEvent::Type type, int key, Qt::KeyboardModifiers modifiers,
quint32 nativeScanCode, quint32 nativeVirtualKey,
quint32 nativeModifiers,
const QString& text = QString(), bool autorep = false,
- ushort count = 1, bool tryShortcutOverride = true);
+ ushort count = 1);
static bool handleWheelEvent(QWindow *window, const QPointF &local, const QPointF &global,
QPoint pixelDelta, QPoint angleDelta,
Qt::KeyboardModifiers mods = Qt::NoModifier,
@@ -218,8 +157,9 @@ public:
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static void handleLeaveEvent(QWindow *window);
static void handleEnterLeaveEvent(QWindow *enter, QWindow *leave, const QPointF &local = QPointF(), const QPointF& global = QPointF());
+
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
- static void handleWindowActivated(QWindow *window, Qt::FocusReason r = Qt::OtherFocusReason);
+ static void handleFocusWindowChanged(QWindow *window, Qt::FocusReason r = Qt::OtherFocusReason);
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static void handleWindowStateChanged(QWindow *window, Qt::WindowStates newState, int oldState = -1);
@@ -227,6 +167,9 @@ public:
static void handleWindowScreenChanged(QWindow *window, QScreen *newScreen);
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
+ static void handleWindowDevicePixelRatioChanged(QWindow *window);
+
+ template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
static void handleSafeAreaMarginsChanged(QWindow *window);
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
@@ -257,7 +200,7 @@ public:
static void handleScreenRefreshRateChange(QScreen *screen, qreal newRefreshRate);
template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
- static void handleThemeChange(QWindow *window);
+ static void handleThemeChange(QWindow *window = nullptr);
static void handleFileOpenEvent(const QString& fileName);
static void handleFileOpenEvent(const QUrl &url);
@@ -288,6 +231,8 @@ public:
Qt::MouseButtons buttons = {}, int xTilt = 0, int yTilt = 0,
qreal tangentialPressure = 0, qreal rotation = 0, int z = 0,
Qt::KeyboardModifiers modifiers = Qt::NoModifier);
+
+ // The following 4 functions are deprecated (QTBUG-114560)
static bool handleTabletEnterProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);
static void handleTabletEnterProximityEvent(int deviceType, int pointerType, qint64 uid);
static bool handleTabletLeaveProximityEvent(ulong timestamp, int deviceType, int pointerType, qint64 uid);
@@ -298,8 +243,8 @@ public:
const QPointF &local, const QPointF &global, int fingerCount = 0);
static bool handleGestureEventWithRealValue(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type,
qreal value, const QPointF &local, const QPointF &global, int fingerCount = 2);
- static bool handleGestureEventWithValueAndDeltas(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value,
- QVector2D deltas, const QPointF &local, const QPointF &global, int fingerCount = 2);
+ static bool handleGestureEventWithValueAndDelta(QWindow *window, ulong timestamp, const QPointingDevice *device, Qt::NativeGestureType type, qreal value,
+ const QPointF &delta, const QPointF &local, const QPointF &global, int fingerCount = 2);
#endif // QT_NO_GESTURES
static void handlePlatformPanelEvent(QWindow *window);
diff --git a/src/gui/kernel/qwindowsysteminterface_p.h b/src/gui/kernel/qwindowsysteminterface_p.h
index 742e22f7e8..51ab58fc99 100644
--- a/src/gui/kernel/qwindowsysteminterface_p.h
+++ b/src/gui/kernel/qwindowsysteminterface_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 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) 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 QWINDOWSYSTEMINTERFACE_P_H
#define QWINDOWSYSTEMINTERFACE_P_H
@@ -76,7 +40,7 @@ public:
GeometryChange = 0x02,
Enter = UserInputEvent | 0x03,
Leave = UserInputEvent | 0x04,
- ActivatedWindow = 0x05,
+ FocusWindow = 0x05,
WindowStateChanged = 0x06,
Mouse = UserInputEvent | 0x07,
Wheel = UserInputEvent | 0x09,
@@ -104,7 +68,8 @@ public:
WindowScreenChanged = 0x21,
SafeAreaMarginsChanged = 0x22,
ApplicationTermination = 0x23,
- Paint = 0x24
+ Paint = 0x24,
+ WindowDevicePixelRatioChanged = 0x25,
};
class WindowSystemEvent {
@@ -160,12 +125,12 @@ public:
QPointer<QWindow> leave;
};
- class ActivatedWindowEvent : public WindowSystemEvent {
+ class FocusWindowEvent : public WindowSystemEvent {
public:
- explicit ActivatedWindowEvent(QWindow *activatedWindow, Qt::FocusReason r)
- : WindowSystemEvent(ActivatedWindow), activated(activatedWindow), reason(r)
+ explicit FocusWindowEvent(QWindow *focusedWindow, Qt::FocusReason r)
+ : WindowSystemEvent(FocusWindow), focused(focusedWindow), reason(r)
{ }
- QPointer<QWindow> activated;
+ QPointer<QWindow> focused;
Qt::FocusReason reason;
};
@@ -190,6 +155,15 @@ public:
QPointer<QScreen> screen;
};
+ class WindowDevicePixelRatioChangedEvent : public WindowSystemEvent {
+ public:
+ WindowDevicePixelRatioChangedEvent(QWindow *w)
+ : WindowSystemEvent(WindowDevicePixelRatioChanged), window(w)
+ { }
+
+ QPointer<QWindow> window;
+ };
+
class SafeAreaMarginsChangedEvent : public WindowSystemEvent {
public:
SafeAreaMarginsChangedEvent(QWindow *w)
@@ -452,13 +426,13 @@ public:
class GestureEvent : public PointerEvent {
public:
GestureEvent(QWindow *window, ulong time, Qt::NativeGestureType type, const QPointingDevice *dev,
- int fingerCount, QPointF pos, QPointF globalPos)
+ int fingerCount, QPointF pos, QPointF globalPos, qreal realValue, QPointF delta)
: PointerEvent(window, time, Gesture, Qt::NoModifier, dev), type(type), pos(pos), globalPos(globalPos),
- fingerCount(fingerCount), realValue(0), sequenceId(0), intValue(0) { }
+ delta(delta), fingerCount(fingerCount), realValue(realValue), sequenceId(0), intValue(0) { }
Qt::NativeGestureType type;
QPointF pos;
QPointF globalPos;
- QVector2D deltas;
+ QPointF delta;
int fingerCount;
// Mac
qreal realValue;
@@ -499,8 +473,8 @@ public:
}
void append(WindowSystemEvent *e)
{ const QMutexLocker locker(&mutex); impl.append(e); }
- int count() const
- { const QMutexLocker locker(&mutex); return impl.count(); }
+ qsizetype count() const
+ { const QMutexLocker locker(&mutex); return impl.size(); }
WindowSystemEvent *peekAtFirstOfType(EventType t) const
{
const QMutexLocker locker(&mutex);
@@ -526,14 +500,12 @@ public:
static WindowSystemEventList windowSystemEventQueue;
- static int windowSystemEventsQueued();
+ static qsizetype windowSystemEventsQueued();
static bool nonUserInputEventsQueued();
static WindowSystemEvent *getWindowSystemEvent();
static WindowSystemEvent *getNonUserInputWindowSystemEvent();
static WindowSystemEvent *peekWindowSystemEvent(EventType t);
static void removeWindowSystemEvent(WindowSystemEvent *event);
- template<typename Delivery = QWindowSystemInterface::DefaultDelivery>
- static bool handleWindowSystemEvent(WindowSystemEvent *ev);
public:
static QElapsedTimer eventTime;