diff options
Diffstat (limited to 'src/gui/kernel/qscreen.cpp')
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 038be09dc7..1e0d4f766a 100644 --- a/src/gui/kernel/qscreen.cpp +++ b/src/gui/kernel/qscreen.cpp @@ -37,6 +37,7 @@ #include "qguiapplication_p.h" #include <qpa/qplatformscreen.h> +#include <QtCore/QDebug> #include <QtCore/private/qobject_p.h> QT_BEGIN_NAMESPACE @@ -328,6 +329,7 @@ QList<QScreen *> QScreen::virtualSiblings() const Q_D(const QScreen); QList<QPlatformScreen *> platformScreens = d->platformScreen->virtualSiblings(); QList<QScreen *> screens; + screens.reserve(platformScreens.count()); foreach (QPlatformScreen *platformScreen, platformScreens) screens << platformScreen->screen(); return screens; @@ -654,4 +656,41 @@ QPixmap QScreen::grabWindow(WId window, int x, int y, int width, int height) return platformScreen->grabWindow(window, x, y, width, height); } +#ifndef QT_NO_DEBUG_STREAM + +static inline void formatRect(QDebug &debug, const QRect r) +{ + debug << r.width() << 'x' << r.height() + << forcesign << r.x() << r.y() << noforcesign; +} + +Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QScreen *screen) +{ + const QDebugStateSaver saver(debug); + debug.nospace(); + debug << "QScreen(" << (void *)screen; + if (screen) { + debug << ", name=" << screen->name(); + if (debug.verbosity() > 2) { + if (screen == QGuiApplication::primaryScreen()) + debug << ", primary"; + debug << ", geometry="; + formatRect(debug, screen->geometry()); + debug << ", available="; + formatRect(debug, screen->availableGeometry()); + debug << ", logical DPI=" << screen->logicalDotsPerInchX() + << ',' << screen->logicalDotsPerInchY() + << ", physical DPI=" << screen->physicalDotsPerInchX() + << ',' << screen->physicalDotsPerInchY() + << ", devicePixelRatio=" << screen->devicePixelRatio() + << ", orientation=" << screen->orientation() + << ", physical size=" << screen->physicalSize().width() + << 'x' << screen->physicalSize().height() << "mm"; + } + } + debug << ')'; + return debug; +} +#endif // !QT_NO_DEBUG_STREAM + QT_END_NAMESPACE |