Purge QDesktopWidget

It's no longer used; the only calls to QApplicationPrivate::desktop
pass the default nullptr for QScreen, so all we need is a Qt::Desktop
type toplevel widget.

Include changes documentation about both the class and QApplication::desktop
being gone in Qt 6.

Change-Id: I22d6e93cabc6aaaefffe5e96942886a2ef4e0609
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Volker Hilsheimer 2020-10-14 23:40:34 +02:00
parent ef1905aebc
commit 215594d664
10 changed files with 23 additions and 242 deletions

View File

@ -2150,8 +2150,7 @@
\value SplashScreen Indicates that the window is a splash screen.
This is the default type for QSplashScreen.
\omitvalue Desktop Indicates that this widget is the desktop. This
is the type for QDesktopWidget.
\omitvalue Desktop Indicates that this widget is the desktop.
\value SubWindow Indicates that this widget is a sub-window, such
as a QMdiSubWindow widget.

View File

@ -12,7 +12,6 @@ qt_internal_add_module(Widgets
itemviews/qfileiconprovider.cpp itemviews/qfileiconprovider.h itemviews/qfileiconprovider_p.h
kernel/qapplication.cpp kernel/qapplication.h kernel/qapplication_p.h
kernel/qboxlayout.cpp kernel/qboxlayout.h
kernel/qdesktopwidget.cpp kernel/qdesktopwidget_p.h
kernel/qgesture.cpp kernel/qgesture.h kernel/qgesture_p.h
kernel/qgesturemanager.cpp kernel/qgesturemanager_p.h
kernel/qgesturerecognizer.cpp kernel/qgesturerecognizer.h

View File

@ -12,7 +12,6 @@ qt_internal_add_module(Widgets
itemviews/qfileiconprovider.cpp itemviews/qfileiconprovider.h itemviews/qfileiconprovider_p.h
kernel/qapplication.cpp kernel/qapplication.h kernel/qapplication_p.h
kernel/qboxlayout.cpp kernel/qboxlayout.h
kernel/qdesktopwidget.cpp kernel/qdesktopwidget_p.h
kernel/qgesture.cpp kernel/qgesture.h kernel/qgesture_p.h
kernel/qgesturemanager.cpp kernel/qgesturemanager_p.h
kernel/qgesturerecognizer.cpp kernel/qgesturerecognizer.h

View File

@ -41,6 +41,18 @@
In this topic we summarize those changes in Qt Widgets, and provide
guidance to handle them.
\section1 ADD STUFF HERE
\section1 Kernel classes
\section2 QDesktopWidget and QApplication::desktop()
QDesktopWidget was already deprecated in Qt 5, and has been removed in
Qt 6, together with QApplication::desktop().
QScreen provides equivalent functionality to query for information about
available screens, screen that form a virtual desktop, and screen
geometries.
Use QWidget::setScreen() to create a QWidget on a specific display;
note that this does not move a widget to a screen in a virtual desktop
setup.
*/

View File

@ -25,7 +25,6 @@ HEADERS += \
kernel/qstandardgestures_p.h \
kernel/qgesturerecognizer.h \
kernel/qgesturemanager_p.h \
kernel/qdesktopwidget_p.h \
kernel/qwidgetwindow_p.h \
kernel/qwindowcontainer_p.h \
kernel/qtestsupport_widgets.h
@ -45,7 +44,6 @@ SOURCES += \
kernel/qstandardgestures.cpp \
kernel/qgesturerecognizer.cpp \
kernel/qgesturemanager.cpp \
kernel/qdesktopwidget.cpp \
kernel/qwidgetsvariant.cpp \
kernel/qwidgetwindow.cpp \
kernel/qwindowcontainer.cpp \

View File

@ -42,7 +42,6 @@
#include "qapplication.h"
#include "qclipboard.h"
#include "qcursor.h"
#include "qdesktopwidget_p.h"
#include "qdir.h"
#include "qevent.h"
#include "qfile.h"
@ -378,7 +377,7 @@ FontHash *qt_app_fonts_hash() { return app_fonts(); }
QWidgetList *QApplicationPrivate::popupWidgets = nullptr; // has keyboard input focus
QDesktopWidget *qt_desktopWidget = nullptr; // root window widgets
QWidget *qt_desktopWidget = nullptr; // root window widgets
/*!
\internal
@ -2510,31 +2509,21 @@ void QApplicationPrivate::sendSyntheticEnterLeave(QWidget *widget)
}
/*!
\obsolete
\internal
Returns the desktop widget (also called the root window) for \a screen.
Returns the desktop widget (also called the root window).
If \a screen is nullptr, then the widget that represents the entire virtual
desktop is returned, and its geometry will be the union of all screens.
Use the desktop widget for a specific screen as the parent of a new toplevel
widget to position the widget on a specific screen.
The desktop may be composed of multiple screens, so it would be incorrect,
for example, to attempt to \e center some widget in the desktop's geometry.
Use QScreen::geometry() and QScreen::availableGeometry() to get the dimensions
of a specific screen instead.
The widget represents the entire virtual desktop, and its geometry will
be the union of all screens.
*/
QWidget *QApplicationPrivate::desktop(QScreen *screen)
QWidget *QApplicationPrivate::desktop()
{
CHECK_QAPP_INSTANCE(nullptr)
if (!qt_desktopWidget || // not created yet
!(qt_desktopWidget->windowType() == Qt::Desktop)) { // reparented away
qt_desktopWidget = new QDesktopWidget();
qt_desktopWidget = new QWidget(nullptr, Qt::Desktop);
}
if (!screen)
return qt_desktopWidget;
return qt_desktopWidget->widgetForScreen(screen);
return qt_desktopWidget;
}
/*

View File

@ -113,7 +113,7 @@ public:
void createEventDispatcher() override;
static void dispatchEnterLeave(QWidget *enter, QWidget *leave, const QPointF &globalPosF);
static QWidget *desktop(QScreen *screen = nullptr);
static QWidget *desktop();
void notifyWindowIconChanged() override;
#ifndef QT_NO_ACTION

View File

@ -1,123 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qglobal.h"
#include "qdesktopwidget_p.h"
#include "qscreen.h"
#include "qwidget_p.h"
#include "qwindow.h"
#include <private/qhighdpiscaling_p.h>
#include <qpa/qplatformscreen.h>
QT_BEGIN_NAMESPACE
QDesktopWidgetPrivate::~QDesktopWidgetPrivate()
{
qDeleteAll(screenWidgets.values());
}
void QDesktopWidgetPrivate::updateScreens()
{
Q_Q(QDesktopWidget);
const QList<QScreen *> screenList = QGuiApplication::screens();
// Re-build our screens list. This is the easiest way to later compute which signals to emit.
// Create new screen widgets as necessary.
// Furthermore, we note which screens have changed, and compute the overall virtual geometry.
QFlatMap<QScreen*, QWidget*> newScreenWidgets;
QRegion virtualGeometry;
for (QScreen *screen : screenList) {
const QRect screenGeometry = screen->geometry();
QWidget *screenWidget = screenWidgets.value(screen);
if (!screenWidget) {
// a new screen, create a widget and connect the signals.
screenWidget = new QWidget(nullptr, Qt::Desktop);
screenWidget->setVisible(false);
screenWidget->setScreen(screen);
screenWidget->setGeometry(screenGeometry);
screenWidget->setObjectName(QLatin1String("qt_desktop_widget_%1").arg(screen->name()));
QObjectPrivate::connect(screen, &QScreen::geometryChanged,
this, &QDesktopWidgetPrivate::updateScreens, Qt::QueuedConnection);
QObjectPrivate::connect(screen, &QObject::destroyed,
this, &QDesktopWidgetPrivate::updateScreens, Qt::QueuedConnection);
}
// record all the screens and the overall geometry.
newScreenWidgets.insert(screen, screenWidget);
virtualGeometry += screenGeometry;
}
// Now we apply the accumulated updates.
qSwap(screenWidgets, newScreenWidgets); // now [newScreenWidgets] is the old screen list
Q_ASSERT(screenWidgets.size() == screenList.length());
q->setGeometry(virtualGeometry.boundingRect());
// Delete the screen widgets that are not used any more.
for (auto it : qAsConst(newScreenWidgets)) {
if (!screenWidgets.contains(it.first))
delete it.second;
}
}
QDesktopWidget::QDesktopWidget()
: QWidget(*new QDesktopWidgetPrivate, nullptr, Qt::Desktop)
{
Q_D(QDesktopWidget);
setObjectName(QLatin1String("desktop"));
d->updateScreens();
QObjectPrivate::connect(qApp, &QApplication::screenAdded, d, &QDesktopWidgetPrivate::updateScreens);
}
QDesktopWidget::~QDesktopWidget() = default;
/*!
\internal
Returns the Qt::Desktop type widget for \a qScreen.
*/
QWidget *QDesktopWidget::widgetForScreen(QScreen *qScreen) const
{
Q_D(const QDesktopWidget);
return d->screenWidgets.value(qScreen);
}
QT_END_NAMESPACE
#include "moc_qdesktopwidget_p.cpp"

View File

@ -1,91 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtWidgets module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of other Qt classes. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//
#ifndef QDESKTOPWIDGET_P_H
#define QDESKTOPWIDGET_P_H
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qwidget_p.h"
#include <QtGui/qscreen.h>
#include <QtCore/private/qflatmap_p.h>
QT_BEGIN_NAMESPACE
class QDesktopWidgetPrivate;
class Q_WIDGETS_EXPORT QDesktopWidget : public QWidget
{
Q_OBJECT
public:
QDesktopWidget();
~QDesktopWidget();
QWidget *widgetForScreen(QScreen *qScreen) const;
private:
Q_DISABLE_COPY(QDesktopWidget)
Q_DECLARE_PRIVATE(QDesktopWidget)
};
class QDesktopWidgetPrivate : public QWidgetPrivate
{
Q_DECLARE_PUBLIC(QDesktopWidget)
public:
~QDesktopWidgetPrivate();
void updateScreens();
QFlatMap<QScreen*, QWidget*> screenWidgets;
};
QT_END_NAMESPACE
#endif // QDESKTOPWIDGET_QPA_P_H

View File

@ -14,7 +14,6 @@ network_remote_stresstest \
network_stresstest \
qcursor \
qdesktopservices \
qdesktopwidget \
qgraphicsitem \
qgraphicsitemgroup \
qgraphicslayout/flicker \