QScroller: Fix deprecation warning about QDdesktopWidget:::primaryScreen()
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ø <tor.arne.vestbo@qt.io>
This commit is contained in:
parent
54519d7327
commit
309169afd9
@ -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
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user