diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-01-29 14:59:50 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@digia.com> | 2015-03-16 13:11:01 +0000 |
commit | 3d8c86881c7c57f646819e825c7c48f2b27bbfcc (patch) | |
tree | 691c5cc40fff9b8d382d45eb3fec4280f87b8d24 /src/gui/kernel/qscreen.cpp | |
parent | 77c0c1ca6505eb66bd75b3766f9a498574822bd1 (diff) |
Implement QDebug streaming operators for QWindow, QScreen and QWidget.
The operators can be switched to verbose using QDebug::setVerbosity()
and then provide more useful information than the standard
operator for QObject.
[ChangeLog][QtCore][QDebug] When streaming QWindow, QScreen,
QWidget instances to a debug stream that has increased verbosity
set, detailed information about geometries, states etc. will
be printed.
Change-Id: Ice26e00f6c713cd6244e1c1df54195e0b0de3c20
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Diffstat (limited to 'src/gui/kernel/qscreen.cpp')
-rw-r--r-- | src/gui/kernel/qscreen.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gui/kernel/qscreen.cpp b/src/gui/kernel/qscreen.cpp index 038be09dc7..5785722918 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 @@ -654,4 +655,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 |