From 215594d664f6fc7057468a05a59344f08a78a976 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Wed, 14 Oct 2020 23:40:34 +0200 Subject: Purge QDesktopWidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø --- src/widgets/.prev_CMakeLists.txt | 1 - src/widgets/CMakeLists.txt | 1 - src/widgets/doc/src/qt6-changes.qdoc | 14 +++- src/widgets/kernel/kernel.pri | 2 - src/widgets/kernel/qapplication.cpp | 27 +++----- src/widgets/kernel/qapplication_p.h | 2 +- src/widgets/kernel/qdesktopwidget.cpp | 123 ---------------------------------- src/widgets/kernel/qdesktopwidget_p.h | 91 ------------------------- 8 files changed, 22 insertions(+), 239 deletions(-) delete mode 100644 src/widgets/kernel/qdesktopwidget.cpp delete mode 100644 src/widgets/kernel/qdesktopwidget_p.h (limited to 'src/widgets') diff --git a/src/widgets/.prev_CMakeLists.txt b/src/widgets/.prev_CMakeLists.txt index f2d3448e0d..99792726ee 100644 --- a/src/widgets/.prev_CMakeLists.txt +++ b/src/widgets/.prev_CMakeLists.txt @@ -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 diff --git a/src/widgets/CMakeLists.txt b/src/widgets/CMakeLists.txt index 1e18191014..e1e7dd968a 100644 --- a/src/widgets/CMakeLists.txt +++ b/src/widgets/CMakeLists.txt @@ -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 diff --git a/src/widgets/doc/src/qt6-changes.qdoc b/src/widgets/doc/src/qt6-changes.qdoc index 4f0379a2f6..47e02dc6c9 100644 --- a/src/widgets/doc/src/qt6-changes.qdoc +++ b/src/widgets/doc/src/qt6-changes.qdoc @@ -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. */ diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index b00e220078..85a388009e 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -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 \ diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 41b3dd9aca..ed6414b16f 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -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 - - Returns the desktop widget (also called the root window) for \a screen. - - 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. + \internal - Use the desktop widget for a specific screen as the parent of a new toplevel - widget to position the widget on a specific screen. + Returns the desktop widget (also called the root window). - 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; } /* diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index c5c3f2f393..af89244d57 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -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 diff --git a/src/widgets/kernel/qdesktopwidget.cpp b/src/widgets/kernel/qdesktopwidget.cpp deleted file mode 100644 index 5c781222e1..0000000000 --- a/src/widgets/kernel/qdesktopwidget.cpp +++ /dev/null @@ -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 -#include - -QT_BEGIN_NAMESPACE - -QDesktopWidgetPrivate::~QDesktopWidgetPrivate() -{ - qDeleteAll(screenWidgets.values()); -} - -void QDesktopWidgetPrivate::updateScreens() -{ - Q_Q(QDesktopWidget); - const QList 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 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" diff --git a/src/widgets/kernel/qdesktopwidget_p.h b/src/widgets/kernel/qdesktopwidget_p.h deleted file mode 100644 index 5e8c256040..0000000000 --- a/src/widgets/kernel/qdesktopwidget_p.h +++ /dev/null @@ -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 -#include "private/qwidget_p.h" - -#include -#include - -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 screenWidgets; -}; - -QT_END_NAMESPACE - -#endif // QDESKTOPWIDGET_QPA_P_H -- cgit v1.2.3