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>
This commit is contained in:
parent
8a3adfbed2
commit
ae5c4500c5
@ -61,10 +61,32 @@ static void dumpWidgetRecursion(QTextStream &str, const QWidget *w,
|
|||||||
if (const int states = w->windowState())
|
if (const int states = w->windowState())
|
||||||
str << "windowState=" << hex << showbase << states << dec << noshowbase << ' ';
|
str << "windowState=" << hex << showbase << states << dec << noshowbase << ' ';
|
||||||
formatRect(str, w->geometry());
|
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)) {
|
if (!(options & DontPrintWindowFlags)) {
|
||||||
str << ' ';
|
str << ' ';
|
||||||
formatWindowFlags(str, w->windowFlags());
|
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';
|
str << '\n';
|
||||||
#if QT_VERSION > 0x050000
|
#if QT_VERSION > 0x050000
|
||||||
if (const QWindow *win = w->windowHandle()) {
|
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;
|
QString d;
|
||||||
QTextStream str(&d);
|
QTextStream str(&d);
|
||||||
str << "### QWidgets:\n";
|
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);
|
dumpWidgetRecursion(str, tw, options);
|
||||||
#if QT_VERSION >= 0x050400
|
#if QT_VERSION >= 0x050400
|
||||||
qDebug().noquote() << d;
|
qDebug().noquote() << d;
|
||||||
|
@ -36,9 +36,11 @@
|
|||||||
|
|
||||||
#include "qwindowdump.h"
|
#include "qwindowdump.h"
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QWidget)
|
||||||
|
|
||||||
namespace QtDiag {
|
namespace QtDiag {
|
||||||
|
|
||||||
void dumpAllWidgets(FormatWindowOptions options = 0);
|
void dumpAllWidgets(FormatWindowOptions options = 0, const QWidget *root = 0);
|
||||||
|
|
||||||
} // namespace QtDiag
|
} // namespace QtDiag
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
# include <QtGui/QScreen>
|
# include <QtGui/QScreen>
|
||||||
# include <QtGui/QWindow>
|
# include <QtGui/QWindow>
|
||||||
# include <qpa/qplatformwindow.h>
|
# include <qpa/qplatformwindow.h>
|
||||||
|
# include <private/qwindow_p.h>
|
||||||
# if QT_VERSION >= 0x050600
|
# if QT_VERSION >= 0x050600
|
||||||
# include <private/qhighdpiscaling_p.h>
|
# include <private/qhighdpiscaling_p.h>
|
||||||
# endif
|
# endif
|
||||||
@ -151,6 +152,15 @@ void formatWindow(QTextStream &str, const QWindow *w, FormatWindowOptions option
|
|||||||
str << ' ';
|
str << ' ';
|
||||||
formatWindowFlags(str, w->flags());
|
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';
|
str << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,8 @@ QT_FORWARD_DECLARE_CLASS(QTextStream)
|
|||||||
namespace QtDiag {
|
namespace QtDiag {
|
||||||
|
|
||||||
enum FormatWindowOption {
|
enum FormatWindowOption {
|
||||||
DontPrintWindowFlags = 0x001
|
DontPrintWindowFlags = 0x001,
|
||||||
|
PrintSizeConstraints = 0x002
|
||||||
};
|
};
|
||||||
|
|
||||||
Q_DECLARE_FLAGS(FormatWindowOptions, FormatWindowOption)
|
Q_DECLARE_FLAGS(FormatWindowOptions, FormatWindowOption)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user