diff options
author | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-07-15 17:00:22 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@theqtcompany.com> | 2015-08-04 13:35:00 +0000 |
commit | 158b4dccbe7b24168eed05d1eb31065e45168e0e (patch) | |
tree | 9cc47b8feaf36a76e7610d2b1c7b8b7a9a294300 /src/qml/debugger | |
parent | 183eae3cbcb3c5c99d97fdc38f9dba7ea87cf05f (diff) |
Move inspector service and QtQuick2 inspector into a common plugin
The inspector service doesn't do anything useful without the QtQuick2
plugin and vice versa. This way we can also use the
QQmlDebugPluginManager.
Change-Id: I78f154dcc9103ec9ec3d2eda216bfb293231583e
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'src/qml/debugger')
-rw-r--r-- | src/qml/debugger/debugger.pri | 3 | ||||
-rw-r--r-- | src/qml/debugger/qqmldebugconnector.cpp | 4 | ||||
-rw-r--r-- | src/qml/debugger/qqmlinspectorinterface_p.h | 74 | ||||
-rw-r--r-- | src/qml/debugger/qqmlinspectorservice.cpp | 175 | ||||
-rw-r--r-- | src/qml/debugger/qqmlinspectorservice_p.h | 90 |
5 files changed, 2 insertions, 344 deletions
diff --git a/src/qml/debugger/debugger.pri b/src/qml/debugger/debugger.pri index 1488a4dfcf..b401216d77 100644 --- a/src/qml/debugger/debugger.pri +++ b/src/qml/debugger/debugger.pri @@ -6,7 +6,6 @@ SOURCES += \ $$PWD/qqmldebugservice.cpp \ $$PWD/qqmldebugserviceinterfaces.cpp \ $$PWD/qqmlprofilerservice.cpp \ - $$PWD/qqmlinspectorservice.cpp \ $$PWD/qqmlenginedebugservice.cpp \ $$PWD/qdebugmessageservice.cpp \ $$PWD/qv4debugservice.cpp \ @@ -24,8 +23,6 @@ HEADERS += \ $$PWD/qqmlprofilerservice_p.h \ $$PWD/qqmldebugserviceinterfaces_p.h \ $$PWD/qqmldebugstatesdelegate_p.h \ - $$PWD/qqmlinspectorservice_p.h \ - $$PWD/qqmlinspectorinterface_p.h \ $$PWD/qqmlenginedebugservice_p.h \ $$PWD/qqmldebug.h \ $$PWD/qdebugmessageservice_p.h \ diff --git a/src/qml/debugger/qqmldebugconnector.cpp b/src/qml/debugger/qqmldebugconnector.cpp index 72754ec15a..e1dabb439e 100644 --- a/src/qml/debugger/qqmldebugconnector.cpp +++ b/src/qml/debugger/qqmldebugconnector.cpp @@ -36,7 +36,6 @@ #include "qdebugmessageservice_p.h" #include "qqmlenginecontrolservice_p.h" #include "qqmlenginedebugservice_p.h" -#include "qqmlinspectorservice_p.h" #include "qqmlprofilerservice_p.h" #include "qv4debugservice_p.h" #include "qqmldebugservicefactory_p.h" @@ -56,6 +55,8 @@ Q_QML_DEBUG_PLUGIN_LOADER(QQmlDebugConnector) Q_QML_IMPORT_DEBUG_PLUGIN(QQmlDebugServerFactory) Q_QML_DEBUG_PLUGIN_LOADER(QQmlDebugService) +Q_QML_IMPORT_DEBUG_PLUGIN(QQmlInspectorServiceFactory) + struct QQmlDebugConnectorParams { QString pluginKey; QString arguments; @@ -123,7 +124,6 @@ QQmlDebugConnector *QQmlDebugConnector::instance() QQmlProfilerServiceImpl::instance(); QDebugMessageService::instance(); QQmlEngineControlService::instance(); - QQmlInspectorServiceImpl::instance(); foreach (const QJsonObject &object, metaDataForQQmlDebugService()) { foreach (const QJsonValue &key, object.value(QLatin1String("MetaData")).toObject() diff --git a/src/qml/debugger/qqmlinspectorinterface_p.h b/src/qml/debugger/qqmlinspectorinterface_p.h deleted file mode 100644 index 9b29d383c7..0000000000 --- a/src/qml/debugger/qqmlinspectorinterface_p.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLINSPECTORINTERFACE_H -#define QQMLINSPECTORINTERFACE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtQml/qtqmlglobal.h> -#include <private/qqmlglobal_p.h> - -QT_BEGIN_NAMESPACE - - -class Q_QML_PRIVATE_EXPORT QQmlInspectorInterface -{ -public: - QQmlInspectorInterface() {} - virtual ~QQmlInspectorInterface() {} - - virtual bool canHandleView(QObject *view) = 0; - - virtual void activate(QObject *view) = 0; - virtual void deactivate() = 0; - - virtual void clientMessage(const QByteArray &message) = 0; -}; - -#define QQmlInspectorInterface_iid "org.qt-project.Qt.QQmlInspectorInterface" - -Q_DECLARE_INTERFACE(QQmlInspectorInterface, QQmlInspectorInterface_iid) - -QT_END_NAMESPACE - -#endif // QQMLINSPECTORINTERFACE_H diff --git a/src/qml/debugger/qqmlinspectorservice.cpp b/src/qml/debugger/qqmlinspectorservice.cpp deleted file mode 100644 index f3ff13a8c0..0000000000 --- a/src/qml/debugger/qqmlinspectorservice.cpp +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmlinspectorservice_p.h" -#include "qqmlinspectorinterface_p.h" - -#include <private/qqmlglobal_p.h> - -#include <QtCore/QCoreApplication> -#include <QtCore/QDebug> -#include <QtCore/QDir> -#include <QtCore/QPluginLoader> - -#ifndef QT_NO_LIBRARY -// print detailed information about loading of plugins -DEFINE_BOOL_CONFIG_OPTION(qmlDebugVerbose, QML_DEBUGGER_VERBOSE) -#endif - -QT_BEGIN_NAMESPACE - -Q_GLOBAL_STATIC(QQmlInspectorServiceImpl, serviceInstance) - -QQmlInspectorServiceImpl::QQmlInspectorServiceImpl(): QQmlInspectorService(1), - m_currentInspectorPlugin(0) -{ -} - -QQmlInspectorServiceImpl *QQmlInspectorServiceImpl::instance() -{ - return serviceInstance(); -} - -void QQmlInspectorServiceImpl::addView(QObject *view) -{ - m_views.append(view); - updateState(); -} - -void QQmlInspectorServiceImpl::removeView(QObject *view) -{ - m_views.removeAll(view); - updateState(); -} - -void QQmlInspectorServiceImpl::stateChanged(State /*state*/) -{ - QMetaObject::invokeMethod(this, "updateState", Qt::QueuedConnection); -} - -void QQmlInspectorServiceImpl::updateState() -{ - if (m_views.isEmpty()) { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - return; - } - - if (state() == Enabled) { - if (m_inspectorPlugins.isEmpty()) - loadInspectorPlugins(); - - if (m_inspectorPlugins.isEmpty()) { - qWarning() << "QQmlInspector: No plugins found."; - return; - } - - m_currentInspectorPlugin = 0; - foreach (QQmlInspectorInterface *inspector, m_inspectorPlugins) { - if (inspector->canHandleView(m_views.first())) { - m_currentInspectorPlugin = inspector; - break; - } - } - - if (!m_currentInspectorPlugin) { - qWarning() << "QQmlInspector: No plugin available for view '" << m_views.first()->metaObject()->className() << "'."; - return; - } - m_currentInspectorPlugin->activate(m_views.first()); - } else { - if (m_currentInspectorPlugin) { - m_currentInspectorPlugin->deactivate(); - m_currentInspectorPlugin = 0; - } - } -} - -void QQmlInspectorServiceImpl::messageReceived(const QByteArray &message) -{ - QMetaObject::invokeMethod(this, "processMessage", Qt::QueuedConnection, Q_ARG(QByteArray, message)); -} - -void QQmlInspectorServiceImpl::processMessage(const QByteArray &message) -{ - if (m_currentInspectorPlugin) - m_currentInspectorPlugin->clientMessage(message); -} - -void QQmlInspectorServiceImpl::loadInspectorPlugins() -{ -#ifndef QT_NO_LIBRARY - QStringList pluginCandidates; - const QStringList paths = QCoreApplication::libraryPaths(); - foreach (const QString &libPath, paths) { - const QDir dir(libPath + QLatin1String("/qmltooling")); - if (dir.exists()) - foreach (const QString &pluginPath, dir.entryList(QDir::Files)) - pluginCandidates << dir.absoluteFilePath(pluginPath); - } - - foreach (const QString &pluginPath, pluginCandidates) { - if (qmlDebugVerbose()) - qDebug() << "QQmlInspector: Trying to load plugin " << pluginPath << "..."; - - QPluginLoader loader(pluginPath); - if (loader.metaData()[QLatin1String("IID")] != - QLatin1String("org.qt-project.Qt.QQmlInspectorInterface")) - continue; - - if (!loader.load()) { - if (qmlDebugVerbose()) - qDebug() << "QQmlInspector: Error while loading: " << loader.errorString(); - - continue; - } - - QQmlInspectorInterface *inspector = - qobject_cast<QQmlInspectorInterface*>(loader.instance()); - if (inspector) { - if (qmlDebugVerbose()) - qDebug() << "QQmlInspector: Plugin successfully loaded."; - m_inspectorPlugins << inspector; - } else { - if (qmlDebugVerbose()) - qDebug() << "QQmlInspector: Plugin does not implement interface QQmlInspectorInterface."; - - loader.unload(); - } - } -#endif -} - -QT_END_NAMESPACE diff --git a/src/qml/debugger/qqmlinspectorservice_p.h b/src/qml/debugger/qqmlinspectorservice_p.h deleted file mode 100644 index 61a350cf8d..0000000000 --- a/src/qml/debugger/qqmlinspectorservice_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQMLINSPECTORSERVICE_H -#define QQMLINSPECTORSERVICE_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "qqmldebugservice_p.h" -#include "qqmldebugserviceinterfaces_p.h" - -#include <QtQml/qtqmlglobal.h> -#include <QtCore/QList> - -QT_BEGIN_NAMESPACE - -namespace QmlJSDebugger { class AbstractViewInspector; } - -class QQmlInspectorInterface; - -class Q_QML_PRIVATE_EXPORT QQmlInspectorServiceImpl : public QQmlInspectorService -{ - Q_OBJECT - -public: - QQmlInspectorServiceImpl(); - static QQmlInspectorServiceImpl *instance(); - - void addView(QObject *); - void removeView(QObject *); - -protected: - virtual void stateChanged(State state); - virtual void messageReceived(const QByteArray &); - -private Q_SLOTS: - void processMessage(const QByteArray &message); - void updateState(); - -private: - friend class QmlJSDebugger::AbstractViewInspector; - void loadInspectorPlugins(); - - QList<QObject*> m_views; - QQmlInspectorInterface *m_currentInspectorPlugin; - QList<QQmlInspectorInterface*> m_inspectorPlugins; -}; - -QT_END_NAMESPACE - -#endif // QQMLINSPECTORSERVICE_H |