summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-21 17:12:46 +0100
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2016-01-26 13:33:09 +0000
commitae5c4500c5d717a79214c22a4f11e65381f4ccc8 (patch)
tree95418f9ea80187e30e898dcac081321173b7bdc4
parent8a3adfbed20b95bfc7d8dd8d31c224c79788def8 (diff)
Diaglib: Improve output of widgets.
- Make it possible to pass an optional root widget to dumpAllWidgets(). - Add option to output size constraints of widgets/windows. - Output normal geometry of top levels. Change-Id: Ib48809d070c5721fe4688a2ad39cb99f286618de Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--tests/manual/diaglib/qwidgetdump.cpp31
-rw-r--r--tests/manual/diaglib/qwidgetdump.h4
-rw-r--r--tests/manual/diaglib/qwindowdump.cpp10
-rw-r--r--tests/manual/diaglib/qwindowdump.h3
4 files changed, 44 insertions, 4 deletions
diff --git a/tests/manual/diaglib/qwidgetdump.cpp b/tests/manual/diaglib/qwidgetdump.cpp
index f057a58ff0..e5fdfaeb71 100644
--- a/tests/manual/diaglib/qwidgetdump.cpp
+++ b/tests/manual/diaglib/qwidgetdump.cpp
@@ -61,10 +61,32 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w,
if (const int states = w->windowState())
str << "windowState=" << hex << showbase << states << dec << noshowbase << ' ';
formatRect(str, w->geometry());
+ if (w->isWindow()) {
+ const QRect normalGeometry = w->normalGeometry();
+ if (normalGeometry.isValid() && !normalGeometry.isEmpty() && normalGeometry != w->geometry()) {
+ str << " normal=";
+ formatRect(str, w->normalGeometry());
+ }
+ }
if (!(options & DontPrintWindowFlags)) {
str << ' ';
formatWindowFlags(str, w->windowFlags());
}
+ if (options & PrintSizeConstraints) {
+ str << ' ';
+ const QSize minimumSize = w->minimumSize();
+ if (minimumSize.width() > 0 || minimumSize.height() > 0)
+ str << "minimumSize=" << minimumSize.width() << 'x' << minimumSize.height() << ' ';
+ const QSize sizeHint = w->sizeHint();
+ const QSize minimumSizeHint = w->minimumSizeHint();
+ if (minimumSizeHint.isValid() && !(sizeHint.isValid() && minimumSizeHint == sizeHint))
+ str << "minimumSizeHint=" << minimumSizeHint.width() << 'x' << minimumSizeHint.height() << ' ';
+ if (sizeHint.isValid())
+ str << "sizeHint=" << sizeHint.width() << 'x' << sizeHint.height() << ' ';
+ const QSize maximumSize = w->maximumSize();
+ if (maximumSize.width() < QWIDGETSIZE_MAX || maximumSize.height() < QWIDGETSIZE_MAX)
+ str << "maximumSize=" << maximumSize.width() << 'x' << maximumSize.height() << ' ';
+ }
str << '\n';
#if QT_VERSION > 0x050000
if (const QWindow *win = w->windowHandle()) {
@@ -79,12 +101,17 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w,
}
}
-void dumpAllWidgets(FormatWindowOptions options)
+void dumpAllWidgets(FormatWindowOptions options, const QWidget *root)
{
QString d;
QTextStream str(&d);
str << "### QWidgets:\n";
- foreach (QWidget *tw, QApplication::topLevelWidgets())
+ QWidgetList topLevels;
+ if (root)
+ topLevels.append(const_cast<QWidget *>(root));
+ else
+ topLevels = QApplication::topLevelWidgets();
+ foreach (QWidget *tw, topLevels)
dumpWidgetRecursion(str, tw, options);
#if QT_VERSION >= 0x050400
qDebug().noquote() << d;
diff --git a/tests/manual/diaglib/qwidgetdump.h b/tests/manual/diaglib/qwidgetdump.h
index 0519a0307c..6f8d9548b3 100644
--- a/tests/manual/diaglib/qwidgetdump.h
+++ b/tests/manual/diaglib/qwidgetdump.h
@@ -36,9 +36,11 @@
#include "qwindowdump.h"
+QT_FORWARD_DECLARE_CLASS(QWidget)
+
namespace QtDiag {
-void dumpAllWidgets(FormatWindowOptions options = 0);
+void dumpAllWidgets(FormatWindowOptions options = 0, const QWidget *root = 0);
} // namespace QtDiag
diff --git a/tests/manual/diaglib/qwindowdump.cpp b/tests/manual/diaglib/qwindowdump.cpp
index c0faefb918..04576dbcf4 100644
--- a/tests/manual/diaglib/qwindowdump.cpp
+++ b/tests/manual/diaglib/qwindowdump.cpp
@@ -38,6 +38,7 @@
# include <QtGui/QScreen>
# include <QtGui/QWindow>
# include <qpa/qplatformwindow.h>
+# include <private/qwindow_p.h>
# if QT_VERSION >= 0x050600
# include <private/qhighdpiscaling_p.h>
# endif
@@ -151,6 +152,15 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option
str << ' ';
formatWindowFlags(str, w->flags());
}
+ if (options & PrintSizeConstraints) {
+ str << ' ';
+ const QSize minimumSize = w->minimumSize();
+ if (minimumSize.width() > 0 || minimumSize.height() > 0)
+ str << "minimumSize=" << minimumSize.width() << 'x' << minimumSize.height() << ' ';
+ const QSize maximumSize = w->maximumSize();
+ if (maximumSize.width() < QWINDOWSIZE_MAX || maximumSize.height() < QWINDOWSIZE_MAX)
+ str << "maximumSize=" << maximumSize.width() << 'x' << maximumSize.height() << ' ';
+ }
str << '\n';
}
diff --git a/tests/manual/diaglib/qwindowdump.h b/tests/manual/diaglib/qwindowdump.h
index 9ab00790b6..2a7d69c915 100644
--- a/tests/manual/diaglib/qwindowdump.h
+++ b/tests/manual/diaglib/qwindowdump.h
@@ -44,7 +44,8 @@ QT_FORWARD_DECLARE_CLASS(QTextStream)
namespace QtDiag {
enum FormatWindowOption {
- DontPrintWindowFlags = 0x001
+ DontPrintWindowFlags = 0x001,
+ PrintSizeConstraints = 0x002
};
Q_DECLARE_FLAGS(FormatWindowOptions, FormatWindowOption)