aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2015-11-19 17:14:23 +0100
committerSimon Hausmann <simon.hausmann@theqtcompany.com>2016-01-12 18:00:47 +0000
commit258638f3726f63b308b6275090b1dad596f4fb56 (patch)
treecbbcfe5772a90b8e2dd0cfe493be465f9bc2003f /src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
parent11bd376d1399faff71ff17af9ee10f61b959901b (diff)
Rewrite inspector service
The inspector service had bitrotted to a point where there was little code to be rescued. Apparently it was never really finished and quite some code didn't make any sense. This change removes some features that were unused or didn't work correctly: 1. Panning and Zooming with mouse wheel and touch interaction. This might be useful in some contexts, but the implementation was so broken that it wasn't worth trying to fix it. The whole idea of doing this on the layer of QQuickItems is not so great because there is no distinction between spontaneous changes triggered by the application and debugging interaction triggered from outside. It might be better to implement such functionality on a lower level, e.g. in the renderer. 2. Reloading the scene with debug changes. Use one of the other debug services to change properties. Clearing the component cache is a rather drastic measure and not necessary here. In turn, we get support for inspecting multiple windows, and all subclasses of QQuickWindow are supported now. Also, show-on-top works now. Task-number: QTBUG-33376 Change-Id: I65497f49c6b46128a600b0e3a31483eeef40313c Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp')
-rw-r--r--src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp91
1 files changed, 50 insertions, 41 deletions
diff --git a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
index 6b786024f8..37faff9c8c 100644
--- a/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
+++ b/src/plugins/qmltooling/qmldbg_inspector/qqmlinspectorservice.cpp
@@ -32,89 +32,98 @@
****************************************************************************/
#include "qqmlinspectorservicefactory.h"
-#include "qquickviewinspector.h"
+#include "globalinspector.h"
+#include "qquickwindowinspector.h"
-#include <private/qqmlglobal_p.h>
-
-#include <QtCore/QCoreApplication>
-#include <QtCore/QDebug>
-#include <QtCore/QDir>
-#include <QtCore/QPluginLoader>
+#include <QtGui/QWindow>
QT_BEGIN_NAMESPACE
class QQmlInspectorServiceImpl : public QQmlInspectorService
{
Q_OBJECT
-
public:
QQmlInspectorServiceImpl(QObject *parent = 0);
- void addView(QObject *) Q_DECL_OVERRIDE;
- void removeView(QObject *) Q_DECL_OVERRIDE;
+ void addWindow(QQuickWindow *window) Q_DECL_OVERRIDE;
+ void setParentWindow(QQuickWindow *window, QWindow *parent) Q_DECL_OVERRIDE;
+ void removeWindow(QQuickWindow *window) Q_DECL_OVERRIDE;
protected:
- virtual void stateChanged(State state) Q_DECL_OVERRIDE;
virtual void messageReceived(const QByteArray &) Q_DECL_OVERRIDE;
-private Q_SLOTS:
- void processMessage(const QByteArray &message);
- void updateState();
+private slots:
+ void messageFromClient(const QByteArray &message);
private:
friend class QQmlInspectorServiceFactory;
- QList<QObject*> m_views;
- QmlJSDebugger::AbstractViewInspector *m_currentInspector;
+ QmlJSDebugger::GlobalInspector *checkInspector();
+ QmlJSDebugger::GlobalInspector *m_globalInspector;
+ QHash<QQuickWindow *, QWindow *> m_waitingWindows;
};
QQmlInspectorServiceImpl::QQmlInspectorServiceImpl(QObject *parent):
- QQmlInspectorService(1, parent), m_currentInspector(0)
+ QQmlInspectorService(1, parent), m_globalInspector(0)
{
}
-void QQmlInspectorServiceImpl::addView(QObject *view)
+QmlJSDebugger::GlobalInspector *QQmlInspectorServiceImpl::checkInspector()
{
- m_views.append(view);
- updateState();
+ if (state() == Enabled) {
+ if (!m_globalInspector) {
+ m_globalInspector = new QmlJSDebugger::GlobalInspector(this);
+ connect(m_globalInspector, &QmlJSDebugger::GlobalInspector::messageToClient,
+ this, &QQmlDebugService::messageToClient);
+ for (QHash<QQuickWindow *, QWindow *>::ConstIterator i = m_waitingWindows.constBegin();
+ i != m_waitingWindows.constEnd(); ++i) {
+ m_globalInspector->addWindow(i.key());
+ if (i.value() != 0)
+ m_globalInspector->setParentWindow(i.key(), i.value());
+ }
+ m_waitingWindows.clear();
+ }
+ } else if (m_globalInspector) {
+ delete m_globalInspector;
+ m_globalInspector = 0;
+ }
+ return m_globalInspector;
}
-void QQmlInspectorServiceImpl::removeView(QObject *view)
+void QQmlInspectorServiceImpl::addWindow(QQuickWindow *window)
{
- m_views.removeAll(view);
- updateState();
+ if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
+ inspector->addWindow(window);
+ else
+ m_waitingWindows.insert(window, 0);
}
-void QQmlInspectorServiceImpl::stateChanged(State /*state*/)
+void QQmlInspectorServiceImpl::removeWindow(QQuickWindow *window)
{
- QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection);
+ if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
+ inspector->removeWindow(window);
+ else
+ m_waitingWindows.remove(window);
}
-void QQmlInspectorServiceImpl::updateState()
+void QQmlInspectorServiceImpl::setParentWindow(QQuickWindow *window, QWindow *parent)
{
- delete m_currentInspector;
- m_currentInspector = 0;
-
- if (m_views.isEmpty() || state() != Enabled)
- return;
-
- QQuickView *qtQuickView = qobject_cast<QQuickView*>(m_views.first());
- if (qtQuickView)
- m_currentInspector = new QmlJSDebugger::QQuickViewInspector(this, qtQuickView, this);
+ if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
+ inspector->setParentWindow(window, parent);
else
- qWarning() << "QQmlInspector: No inspector available for view '"
- << m_views.first()->metaObject()->className() << "'.";
+ m_waitingWindows[window] = parent;
}
void QQmlInspectorServiceImpl::messageReceived(const QByteArray &message)
{
- QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message));
+ QMetaObject::invokeMethod(this, "messageFromClient", Qt::QueuedConnection,
+ Q_ARG(QByteArray, message));
}
-void QQmlInspectorServiceImpl::processMessage(const QByteArray &message)
+void QQmlInspectorServiceImpl::messageFromClient(const QByteArray &message)
{
- if (m_currentInspector)
- m_currentInspector->handleMessage(message);
+ if (QmlJSDebugger::GlobalInspector *inspector = checkInspector())
+ inspector->processMessage(message);
}
QQmlDebugService *QQmlInspectorServiceFactory::create(const QString &key)