diff --git a/src/designer/src/designer/designer.pro b/src/designer/src/designer/designer.pro index a4d2510..056ad0e 100644 --- a/src/designer/src/designer/designer.pro +++ b/src/designer/src/designer/designer.pro @@ -6,7 +6,7 @@ INCLUDEPATH += \ ../lib/extension \ ../lib/shared \ extra - +CONFIG+=console RESOURCES += designer.qrc contains(QT_CONFIG, static) { diff --git a/src/designer/src/designer/main.cpp b/src/designer/src/designer/main.cpp index 1c398dc..577ccf0 100644 --- a/src/designer/src/designer/main.cpp +++ b/src/designer/src/designer/main.cpp @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(designer); QDesigner app(argc, argv); + app.setQuitOnLastWindowClosed(false); return app.exec(); diff --git a/src/designer/src/designer/qdesigner.cpp b/src/designer/src/designer/qdesigner.cpp index 9484bc2..2d1cb5c 100644 --- a/src/designer/src/designer/qdesigner.cpp +++ b/src/designer/src/designer/qdesigner.cpp @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -82,12 +83,111 @@ static void designerMessageHandler(QtMsgType type, const QMessageLogContext &con designerApp->showErrorMessage(qPrintable(msg)); } +static inline void formatObjectName(const QObject *w, QTextStream &str) +{ + str << w->metaObject()->className(); + if (!w->objectName().isEmpty()) + str << "/\"" << w->objectName() << '"'; +} + +static void dumpWindowRecursion(QTextStream &str, const QWindow *w, const QWindowList &allWins, int depth = 0) +{ + if (depth) + str << QString(depth * 2, QLatin1Char(' ')); + const QRect geom = w->geometry(); + const QPoint globalPos = w->isTopLevel() ? geom.topLeft() : w->mapToGlobal(geom.topLeft()); + formatObjectName(w, str); + str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] "); + if (w->isTopLevel()) + str << "[top] "; + if (w->surfaceType() == QSurface::OpenGLSurface) + str << "[gl] "; + const QSurfaceFormat format = w->requestedFormat(); + if (format.hasAlpha()) + str << "[alpha] "; + str << "f=0x" << hex << unsigned(w->flags()) << dec + << "\" " << geom.width() << 'x' << geom.height() + << forcesign << geom.x() << geom.y() + << " Global: " << globalPos.x() << globalPos.y() << noforcesign << '\n'; + foreach (const QWindow *cw, allWins) + if (cw->type() != Qt::Desktop && cw->parent() == w) + dumpWindowRecursion(str, cw, allWins, depth + 1); +} +static void dumpAllWindows() +{ + QString d; + QWindowList wins = QGuiApplication::allWindows(); + QTextStream str(&d); + foreach (const QWindow *w, wins) + if (w->type() != Qt::Desktop && w->isTopLevel()) + dumpWindowRecursion(str, w, wins, 0); + qDebug().nospace() << d; +} + + +static void dumpWidgetRecursion(QTextStream &str, const QWidget *w, int depth = 0) +{ + if (depth) + str << QString(depth * 2, QLatin1Char(' ')); + const QRect geom = w->geometry(); + const QPoint globalPos = w->isWindow() ? geom.topLeft() : w->mapToGlobal(geom.topLeft()); + formatObjectName(w, str); + str << ' ' << (w->isVisible() ? "[visible] " : "[hidden] ") + << "focuspol: " << w->focusPolicy() << ' '; +#if QT_VERSION >= 0x050000 + if (const QWindow *wh = w->windowHandle()) { + str << "[qwin: "; + formatObjectName(wh, str); + str << ']'; + } +#endif + if (const QWidget *fp = w->focusProxy()) { + str << "[focusproxy: "; + formatObjectName(fp, str); + str << ']'; + } + if (!w->isEnabled()) + str << "[disabled]"; + if (w->hasFocus()) + str << "[focus]"; + if (w->isWindow()) + str << "[top] "; + if (w->internalWinId()) + str << "[internalWinId] "; + if (w->testAttribute(Qt::WA_Mapped)) + str << "[mapped] "; + if (w->acceptDrops()) + str << "[drops] "; + str << "f=0x" << hex << unsigned(w->windowFlags()) << dec + << "\" " << geom.width() << 'x' << geom.height() + << forcesign << geom.x() << geom.y() + << " Global: " << globalPos.x() << globalPos.y() << noforcesign << '\n'; + foreach (const QObject *co, w->children()) + if (co->isWidgetType()) { + const QWidget *cw = static_cast(co); + dumpWidgetRecursion(str, cw, depth + 1); + } +} + +static void dumpWidgets(const QWidget *w) +{ + QString d; + QTextStream str(&d); + dumpWidgetRecursion(str, w); + qDebug().nospace() << d; +} + QDesigner::QDesigner(int &argc, char **argv) : QApplication(argc, argv), m_server(0), m_client(0), m_workbench(0), m_suppressNewFormShow(false) { + QStringList args = QCoreApplication::arguments(); + if (args.contains("-a")) { + qDebug() << "Qt::AA_NativeWindows"; + setAttribute(Qt::AA_NativeWindows); + } setOrganizationName(QStringLiteral("QtProject")); setApplicationName(QLatin1String(designerApplicationName)); QDesignerComponents::initializeResources(); @@ -232,6 +332,7 @@ void QDesigner::initialize() installTranslator(qtTranslator); m_workbench = new QDesignerWorkbench(); + dumpAllWindows(); emit initialized(); previousMessageHandler = qInstallMessageHandler(designerMessageHandler); // Warn when loading faulty forms @@ -296,6 +397,9 @@ bool QDesigner::event(QEvent *ev) void QDesigner::setMainWindow(MainWindowBase *tw) { m_mainWindow = tw; + if (tw) + dumpWidgets(tw); + } MainWindowBase *QDesigner::mainWindow() const