From 44fb925f50471ebc23dcccfaa4e9d9873b05d205 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Sat, 16 May 2020 20:43:34 +0200 Subject: Phase 2 of removing QDesktopWidget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove QDestopWidget public header, simplify the implementation that maintains a Qt::Desktop type QWidget for each QScreen, and turn QWidget's initial target screen into a QScreen pointer. QApplication::desktop() now takes an optional QScreen pointer, and returns a QWidget pointer, so that applications and widgets can get access to the root widget for a specific screen without having to resort to private APIs. QDesktopWidgetPrivate implementations to look up a screen for an index, widget, or point are now all inline functions that thinly wrap QGuiApplication::screens/screenAt calls. We should consider adding those as convenience APIs to QScreen instead. Note that QWidget::screen is assumed to return a valid pointer; there is code that handles the case that it returns nullptr (but also code that trusts that it never is nullptr), so this needs to be defined, verified with tests, and asserted. We can then simplify the code further. Change-Id: Ifc89be65a0dce265b6729feaf54121c35137cb94 Reviewed-by: Shawn Rutledge Reviewed-by: Tor Arne Vestbø Reviewed-by: Qt CI Bot --- src/widgets/util/qcompleter.cpp | 3 +-- src/widgets/util/qscroller.cpp | 1 - src/widgets/util/qsystemtrayicon.cpp | 5 ++--- 3 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/widgets/util') diff --git a/src/widgets/util/qcompleter.cpp b/src/widgets/util/qcompleter.cpp index 926eee26f3..72084ebd8f 100644 --- a/src/widgets/util/qcompleter.cpp +++ b/src/widgets/util/qcompleter.cpp @@ -157,7 +157,6 @@ #endif #include "QtWidgets/qapplication.h" #include "QtGui/qevent.h" -#include "QtWidgets/qdesktopwidget.h" #include #include #if QT_CONFIG(lineedit) @@ -921,7 +920,7 @@ void QCompleterPrivate::_q_autoResizePopup() void QCompleterPrivate::showPopup(const QRect& rect) { - const QRect screen = QDesktopWidgetPrivate::availableGeometry(widget); + const QRect screen = QWidgetPrivate::availableScreenGeometry(widget); Qt::LayoutDirection dir = widget->layoutDirection(); QPoint pos; int rh, w; diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index fec373d45c..003f27de56 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -57,7 +57,6 @@ #include #include #endif -#include #include #include #include diff --git a/src/widgets/util/qsystemtrayicon.cpp b/src/widgets/util/qsystemtrayicon.cpp index e4ee5770f1..170eba7514 100644 --- a/src/widgets/util/qsystemtrayicon.cpp +++ b/src/widgets/util/qsystemtrayicon.cpp @@ -60,7 +60,6 @@ #include "qstyle.h" #include "qgridlayout.h" #include "qapplication.h" -#include "qdesktopwidget.h" #include #include "qbitmap.h" @@ -132,7 +131,7 @@ static QIcon messageIcon2qIcon(QSystemTrayIcon::MessageIcon icon) of type QEvent::ToolTip. Additionally, the QSystemTrayIcon receives wheel events of type QEvent::Wheel. These are not supported on any other platform. - \sa QDesktopServices, QDesktopWidget, {Desktop Integration}, {System Tray Icon Example} + \sa QDesktopServices, {Desktop Integration}, {System Tray Icon Example} */ /*! @@ -533,7 +532,7 @@ QBalloonTip::QBalloonTip(const QIcon &icon, const QString &title, msgLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft); // smart size for the message label - int limit = QDesktopWidgetPrivate::availableGeometry(msgLabel).size().width() / 3; + int limit = QWidgetPrivate::availableScreenGeometry(msgLabel).width() / 3; if (msgLabel->sizeHint().width() > limit) { msgLabel->setWordWrap(true); if (msgLabel->sizeHint().width() > limit) { -- cgit v1.2.3