From e32f2d7ffdbcedc949e00af196d080b7dd070ae2 Mon Sep 17 00:00:00 2001 From: Aurindam Jana Date: Mon, 2 Apr 2012 10:30:29 +0200 Subject: [PATCH] QmlJSInspector: Disable Zoom Tool for QmlDebugger Zoom Tool and Select Tool are combined for QmlDebugger. The Zoom Tool is enabled only for backwards compatibility. Change-Id: Id66eb94ce0535ccac169fa5a80f937370a0f9f6f Reviewed-by: Kai Koehne --- src/libs/qmljsdebugclient/qmldebuggerclient.cpp | 3 ++- src/libs/qmljsdebugclient/qmlenginedebugclient.cpp | 5 ++--- src/libs/qmljsdebugclient/qmljsdebugclientconstants.h | 3 +++ src/plugins/qmljsinspector/qmljsclientproxy.cpp | 5 +++++ src/plugins/qmljsinspector/qmljsclientproxy.h | 2 ++ src/plugins/qmljsinspector/qmljsinspector.cpp | 8 +++++++- src/plugins/qmljsinspector/qmljsinspectortoolbar.cpp | 11 +++++++++-- src/plugins/qmljsinspector/qmljsinspectortoolbar.h | 2 ++ 8 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/libs/qmljsdebugclient/qmldebuggerclient.cpp b/src/libs/qmljsdebugclient/qmldebuggerclient.cpp index f995e710d17..3ab14966ee9 100644 --- a/src/libs/qmljsdebugclient/qmldebuggerclient.cpp +++ b/src/libs/qmljsdebugclient/qmldebuggerclient.cpp @@ -30,12 +30,13 @@ **************************************************************************/ #include "qmldebuggerclient.h" +#include "qmljsdebugclientconstants.h" namespace QmlJsDebugClient { QmlDebuggerClient::QmlDebuggerClient( QDeclarativeDebugConnection *connection) - : QmlEngineDebugClient(QLatin1String("QmlDebugger"), connection) + : QmlEngineDebugClient(QLatin1String(Constants::QML_DEBUGGER), connection) { } diff --git a/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp b/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp index 2593e4b63eb..0ed99fa3d51 100644 --- a/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp +++ b/src/libs/qmljsdebugclient/qmlenginedebugclient.cpp @@ -30,8 +30,7 @@ **************************************************************************/ #include "qmlenginedebugclient.h" - -const float CURRENT_SUPPORTED_VERSION = 2.0; +#include "qmljsdebugclientconstants.h" namespace QmlJsDebugClient { @@ -80,7 +79,7 @@ void QmlEngineDebugClient::decode(QDataStream &ds, ds >> data; int parentId = -1; if (objectName() == QLatin1String("QmlDebugger") && - serviceVersion() >= CURRENT_SUPPORTED_VERSION ) + serviceVersion() >= Constants::CURRENT_SUPPORTED_VERSION ) ds >> parentId; o.m_debugId = data.objectId; o.m_className = data.objectType; diff --git a/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h b/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h index be8d5714ce3..02c5e4a0d47 100644 --- a/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h +++ b/src/libs/qmljsdebugclient/qmljsdebugclientconstants.h @@ -44,6 +44,9 @@ const char STR_IGNORING_DEBUGGER[] = "Ignoring \"-qmljsdebugger="; const char STR_IGNORING_DEBUGGER2[] = "Ignoring\"-qmljsdebugger="; // There is (was?) a bug in one of the error strings - safest to handle both const char STR_CONNECTION_ESTABLISHED[] = "Connection established"; +const char QML_DEBUGGER[] = "QmlDebugger"; +const float CURRENT_SUPPORTED_VERSION = 2.0; + } // namespace Constants } // namespace QmlJsDebugClient diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.cpp b/src/plugins/qmljsinspector/qmljsclientproxy.cpp index 3ce7c69f747..50d8c53b356 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.cpp +++ b/src/plugins/qmljsinspector/qmljsclientproxy.cpp @@ -127,6 +127,11 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status) updateConnected(); } +QDeclarativeDebugClient *ClientProxy::qmlDebugger() const +{ + return m_engineClient; +} + void ClientProxy::engineClientStatusChanged(QDeclarativeDebugClient::Status status) { if (status == QDeclarativeDebugClient::Enabled) { diff --git a/src/plugins/qmljsinspector/qmljsclientproxy.h b/src/plugins/qmljsinspector/qmljsclientproxy.h index 57d86c8edc5..38e26e52de8 100644 --- a/src/plugins/qmljsinspector/qmljsclientproxy.h +++ b/src/plugins/qmljsinspector/qmljsclientproxy.h @@ -99,6 +99,8 @@ public: void fetchContextObjectRecursive(const QmlDebugContextReference &context, bool clear); void insertObjectInTreeIfNeeded(const QmlDebugObjectReference &object); + QDeclarativeDebugClient *qmlDebugger() const; + signals: void objectTreeUpdated(); void connectionStatusMessage(const QString &text); diff --git a/src/plugins/qmljsinspector/qmljsinspector.cpp b/src/plugins/qmljsinspector/qmljsinspector.cpp index 9e18a43919c..9b56917e4bb 100644 --- a/src/plugins/qmljsinspector/qmljsinspector.cpp +++ b/src/plugins/qmljsinspector/qmljsinspector.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -315,7 +316,12 @@ void InspectorUi::connected(ClientProxy *clientProxy) if (m_clientProxy) connect(m_clientProxy, SIGNAL(result(quint32,QVariant)), SLOT(onResult(quint32,QVariant))); - + using namespace QmlJsDebugClient::Constants; + if (m_clientProxy->qmlDebugger()->objectName() == QML_DEBUGGER && + m_clientProxy->qmlDebugger()->serviceVersion() >= CURRENT_SUPPORTED_VERSION) + m_toolBar->setZoomToolEnabled(false); + else + m_toolBar->setZoomToolEnabled(true); QmlJS::Snapshot snapshot = modelManager()->snapshot(); for (QHash::const_iterator it = m_textPreviews.constBegin(); it != m_textPreviews.constEnd(); ++it) { diff --git a/src/plugins/qmljsinspector/qmljsinspectortoolbar.cpp b/src/plugins/qmljsinspector/qmljsinspectortoolbar.cpp index 0c055ba7d3f..0ca99cc8bc0 100644 --- a/src/plugins/qmljsinspector/qmljsinspectortoolbar.cpp +++ b/src/plugins/qmljsinspector/qmljsinspectortoolbar.cpp @@ -79,7 +79,8 @@ QmlJsInspectorToolBar::QmlJsInspectorToolBar(QObject *parent) : m_animationSpeed(1.0f), m_designModeActive(false), m_activeTool(NoTool), - m_barWidget(0) + m_barWidget(0), + m_zoomActionEnable(true) { } @@ -89,7 +90,7 @@ void QmlJsInspectorToolBar::setEnabled(bool value) m_showAppOnTopAction->setEnabled(value); m_playAction->setEnabled(value); m_selectAction->setEnabled(value); - m_zoomAction->setEnabled(value); + m_zoomAction->setEnabled(value && m_zoomActionEnable); } void QmlJsInspectorToolBar::enable() @@ -162,6 +163,12 @@ void QmlJsInspectorToolBar::setShowAppOnTop(bool showAppOnTop) m_emitSignals = true; } +void QmlJsInspectorToolBar::setZoomToolEnabled(bool enable) +{ + m_zoomActionEnable = enable; + m_zoomAction->setEnabled(m_zoomActionEnable); +} + void QmlJsInspectorToolBar::createActions() { Core::Context context(Debugger::Constants::C_QMLDEBUGGER); diff --git a/src/plugins/qmljsinspector/qmljsinspectortoolbar.h b/src/plugins/qmljsinspector/qmljsinspectortoolbar.h index 99c4fd9a39f..c9bf5061f4b 100644 --- a/src/plugins/qmljsinspector/qmljsinspectortoolbar.h +++ b/src/plugins/qmljsinspector/qmljsinspectortoolbar.h @@ -71,6 +71,7 @@ public: void createActions(); QWidget *widget() const; void readSettings(); + void setZoomToolEnabled(bool enable); public slots: void writeSettings() const; @@ -137,6 +138,7 @@ private: DesignTool m_activeTool; QWidget *m_barWidget; + bool m_zoomActionEnable; }; } // namespace Internal