From 309169afd9a500fb8c4e95dab3a7e0fb53e5d86b Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 21 Dec 2017 09:49:12 +0100 Subject: [PATCH] QScroller: Fix deprecation warning about QDdesktopWidget:::primaryScreen() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In file included from ..\..\include\QtWidgets/qdesktopwidget.h:1:0, from kernel\qt_widgets_pch.h:71: ..\..\include\QtWidgets/../../src/widgets/kernel/qdesktopwidget.h:71:65: note: declared here QT_DEPRECATED_X("Use QGuiApplication::primaryScreen()") int primaryScreen() const; Use QScreen directly and remove the then unused function realDpi(). Change-Id: I526adb09ba35ed0699338d6a8d044c2ff9a03a1e Reviewed-by: Tor Arne Vestbø --- src/widgets/util/qscroller.cpp | 38 ++-------------------------------- src/widgets/util/qscroller_p.h | 1 - 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index 50351ea568b..4f5cf55a645 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -1013,40 +1013,6 @@ bool QScroller::handleInput(Input input, const QPointF &position, qint64 timesta return false; } -#if 1 // Used to be excluded in Qt4 for Q_WS_MAC -// the Mac version is implemented in qscroller_mac.mm - -QPointF QScrollerPrivate::realDpi(int screenNumber) const -{ -# if 0 /* Used to be included in Qt4 for Q_WS_X11 */ && !defined(QT_NO_XRANDR) - if (X11 && X11->use_xrandr && X11->ptrXRRSizes && X11->ptrXRRRootToScreen) { - int nsizes = 0; - // QDesktopWidget is based on Xinerama screens, which do not always - // correspond to RandR screens: NVidia's TwinView e.g. will show up - // as 2 screens in QDesktopWidget, but libXRandR will only see 1 screen. - // (although with the combined size of the Xinerama screens). - // Additionally, libXrandr will simply crash when calling XRRSizes - // for (the non-existent) screen 1 in this scenario. - Window root = RootWindow(X11->display, screen == -1 ? X11->defaultScreen : screen); - int randrscreen = (root != XNone) ? X11->ptrXRRRootToScreen(X11->display, root) : -1; - - XRRScreenSize *sizes = X11->ptrXRRSizes(X11->display, randrscreen == -1 ? 0 : randrscreen, &nsizes); - if (nsizes > 0 && sizes && sizes->width && sizes->height && sizes->mwidth && sizes->mheight) { - qScrollerDebug() << "XRandR DPI:" << QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth), - qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight)); - return QPointF(qreal(25.4) * qreal(sizes->width) / qreal(sizes->mwidth), - qreal(25.4) * qreal(sizes->height) / qreal(sizes->mheight)); - } - } -# endif - - const QScreen *screen = QDesktopWidgetPrivate::screen(screenNumber); - return QPointF(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY()); -} - -#endif - - /*! \internal Returns the resolution of the used screen. */ @@ -1071,8 +1037,8 @@ void QScrollerPrivate::setDpi(const QPointF &dpi) */ void QScrollerPrivate::setDpiFromWidget(QWidget *widget) { - QDesktopWidget *dw = QApplication::desktop(); - setDpi(realDpi(widget ? dw->screenNumber(widget) : dw->primaryScreen())); + const QScreen *screen = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(widget)); + setDpi(QPointF(screen->physicalDotsPerInchX(), screen->physicalDotsPerInchY())); } /*! \internal diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h index 4557e7cc339..5e0c3595147 100644 --- a/src/widgets/util/qscroller_p.h +++ b/src/widgets/util/qscroller_p.h @@ -119,7 +119,6 @@ public: bool prepareScrolling(const QPointF &position); void handleDrag(const QPointF &position, qint64 timestamp); - QPointF realDpi(int screen) const; QPointF dpi() const; void setDpi(const QPointF &dpi); void setDpiFromWidget(QWidget *widget);