forked from qt-creator/qt-creator
Inspector: Enable/disable tools on engine state
On a debug break, inspector tools cannot be used as the gui thread is blocked. Task-number: QTCREATORBUG-5466 Change-Id: I808d751b1ade7e4a5c98e87fec7bb4cb02715ad8 Reviewed-by: Christiaan Janssen <christiaan.janssen@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
committed by
Kai Koehne
parent
3271af9292
commit
1b916719d0
@@ -559,18 +559,12 @@ DebuggerSettings::DebuggerSettings(QSettings *settings)
|
||||
const QString qmlInspectorGroup = QLatin1String("QML.Inspector");
|
||||
item = new SavedAction(this);
|
||||
item->setSettingsKey(qmlInspectorGroup, QLatin1String("QmlInspector.ShowAppOnTop"));
|
||||
item->setText(tr("Show Application On Top"));
|
||||
item->setCheckable(true);
|
||||
item->setDefaultValue(false);
|
||||
item->setIcon(QIcon(QLatin1String(":/debugger/images/qml/app-on-top.png")));
|
||||
insertItem(ShowAppOnTop, item);
|
||||
|
||||
item = new SavedAction(this);
|
||||
item->setSettingsKey(qmlInspectorGroup, QLatin1String("QmlInspector.FromQml"));
|
||||
item->setText(tr("Apply Changes on Save"));
|
||||
item->setCheckable(true);
|
||||
item->setDefaultValue(false);
|
||||
item->setIcon(QIcon(QLatin1String(":/debugger/images/qml/apply-on-save.png")));
|
||||
insertItem(QmlUpdateOnSave, item);
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ const char STEPOUT[] = "Debugger.StepOut";
|
||||
const char NEXT[] = "Debugger.NextLine";
|
||||
const char REVERSE[] = "Debugger.ReverseDirection";
|
||||
const char OPERATE_BY_INSTRUCTION[] = "Debugger.OperateByInstruction";
|
||||
const char QML_SHOW_APP_ON_TOP[] = "Debugger.QmlShowAppOnTop";
|
||||
const char QML_UPDATE_ON_SAVE[] = "Debugger.QmlUpdateOnSave";
|
||||
const char QML_SELECTTOOL[] = "Debugger.QmlSelectTool";
|
||||
const char QML_ZOOMTOOL[] = "Debugger.QmlZoomTool";
|
||||
|
||||
|
||||
@@ -2848,6 +2848,20 @@ void DebuggerPluginPrivate::extensionsInitialized()
|
||||
connect(action(OperateByInstruction), SIGNAL(triggered(bool)),
|
||||
SLOT(handleOperateByInstructionTriggered(bool)));
|
||||
|
||||
QAction *qmlShowAppOnTopDummyAction = new QAction(tr("Show Application On Top"), this);
|
||||
qmlShowAppOnTopDummyAction->setCheckable(true);
|
||||
qmlShowAppOnTopDummyAction->setIcon(QIcon(_(":/debugger/images/qml/app-on-top.png")));
|
||||
qmlShowAppOnTopDummyAction->setEnabled(false);
|
||||
ActionManager::registerAction(qmlShowAppOnTopDummyAction, Constants::QML_SHOW_APP_ON_TOP,
|
||||
globalcontext);
|
||||
|
||||
QAction *qmlUpdateOnSaveDummyAction = new QAction(tr("Apply Changes on Save"), this);
|
||||
qmlUpdateOnSaveDummyAction->setCheckable(true);
|
||||
qmlUpdateOnSaveDummyAction->setIcon(QIcon(_(":/debugger/images/qml/apply-on-save.png")));
|
||||
qmlUpdateOnSaveDummyAction->setEnabled(false);
|
||||
ActionManager::registerAction(qmlUpdateOnSaveDummyAction, Constants::QML_UPDATE_ON_SAVE,
|
||||
globalcontext);
|
||||
|
||||
QAction *qmlSelectDummyAction = new QAction(tr("Select"), this);
|
||||
qmlSelectDummyAction->setCheckable(true);
|
||||
qmlSelectDummyAction->setIcon(QIcon(_(":/debugger/images/qml/select.png")));
|
||||
@@ -3256,8 +3270,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
|
||||
hbox = new QHBoxLayout(qmlToolbar);
|
||||
hbox->setMargin(0);
|
||||
hbox->setSpacing(0);
|
||||
hbox->addWidget(toolButton(action(QmlUpdateOnSave)));
|
||||
hbox->addWidget(toolButton(action(ShowAppOnTop)));
|
||||
hbox->addWidget(toolButton(Constants::QML_UPDATE_ON_SAVE));
|
||||
hbox->addWidget(toolButton(Constants::QML_SHOW_APP_ON_TOP));
|
||||
hbox->addWidget(new StyledSeparator);
|
||||
hbox->addWidget(toolButton(Constants::QML_SELECTTOOL));
|
||||
hbox->addWidget(toolButton(Constants::QML_ZOOMTOOL));
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "debuggercore.h"
|
||||
#include "debuggerstringutils.h"
|
||||
#include "qmladapter.h"
|
||||
#include "qmlengine.h"
|
||||
#include "debuggerengine.h"
|
||||
#include "qmlinspectoragent.h"
|
||||
#include "qmllivetextpreview.h"
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace Internal {
|
||||
* integration with the text editor.
|
||||
*/
|
||||
QmlInspectorAdapter::QmlInspectorAdapter(QmlAdapter *debugAdapter,
|
||||
QmlEngine *engine,
|
||||
DebuggerEngine *engine,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
, m_debugAdapter(debugAdapter)
|
||||
@@ -75,8 +75,14 @@ QmlInspectorAdapter::QmlInspectorAdapter(QmlAdapter *debugAdapter,
|
||||
, m_inspectorToolsContext("Debugger.QmlInspector")
|
||||
, m_selectAction(new QAction(this))
|
||||
, m_zoomAction(new QAction(this))
|
||||
, m_showAppOnTopAction(debuggerCore()->action(ShowAppOnTop))
|
||||
, m_updateOnSaveAction(debuggerCore()->action(QmlUpdateOnSave))
|
||||
, m_engineClientConnected(false)
|
||||
{
|
||||
if (!m_engine->isMasterEngine())
|
||||
m_engine = m_engine->masterEngine();
|
||||
connect(m_engine, SIGNAL(stateChanged(Debugger::DebuggerState)),
|
||||
SLOT(onEngineStateChanged(Debugger::DebuggerState)));
|
||||
connect(m_agent, SIGNAL(objectFetched(QmlDebug::ObjectReference)),
|
||||
SLOT(onObjectFetched(QmlDebug::ObjectReference)));
|
||||
connect(m_agent, SIGNAL(jumpToObjectDefinition(QmlDebug::FileReference,int)),
|
||||
@@ -131,11 +137,21 @@ QmlInspectorAdapter::QmlInspectorAdapter(QmlAdapter *debugAdapter,
|
||||
m_zoomAction->setObjectName(QLatin1String("QML Zoom Action"));
|
||||
m_selectAction->setCheckable(true);
|
||||
m_zoomAction->setCheckable(true);
|
||||
m_showAppOnTopAction->setCheckable(true);
|
||||
m_updateOnSaveAction->setCheckable(true);
|
||||
m_selectAction->setEnabled(false);
|
||||
m_zoomAction->setEnabled(false);
|
||||
m_showAppOnTopAction->setEnabled(false);
|
||||
m_updateOnSaveAction->setEnabled(false);
|
||||
|
||||
connect(m_selectAction, SIGNAL(triggered(bool)),
|
||||
SLOT(onSelectActionTriggered(bool)));
|
||||
connect(m_zoomAction, SIGNAL(triggered(bool)),
|
||||
SLOT(onZoomActionTriggered(bool)));
|
||||
connect(m_showAppOnTopAction, SIGNAL(triggered(bool)),
|
||||
SLOT(onShowAppOnTopChanged(bool)));
|
||||
connect(m_updateOnSaveAction, SIGNAL(triggered(bool)),
|
||||
SLOT(onUpdateOnSaveChanged(bool)));
|
||||
}
|
||||
|
||||
QmlInspectorAdapter::~QmlInspectorAdapter()
|
||||
@@ -193,56 +209,49 @@ void QmlInspectorAdapter::toolsClientStatusChanged(QmlDebug::ClientStatus status
|
||||
connect(client, SIGNAL(reloaded()), SLOT(onReloaded()));
|
||||
connect(client, SIGNAL(destroyedObject(int)), SLOT(onDestroyedObject(int)));
|
||||
|
||||
// only enable zoom action for Qt 4.x/old client
|
||||
// (zooming is integrated into selection tool in Qt 5).
|
||||
m_zoomAction->setEnabled(
|
||||
qobject_cast<DeclarativeToolsClient*>(client) != 0);
|
||||
|
||||
// register actions here
|
||||
// because there can be multiple QmlEngines
|
||||
// at the same time (but hopefully one one is connected)
|
||||
Core::ActionManager::registerAction(m_selectAction,
|
||||
Core::Id(Constants::QML_SELECTTOOL),
|
||||
m_inspectorToolsContext);
|
||||
Core::Id(Constants::QML_SELECTTOOL),
|
||||
m_inspectorToolsContext);
|
||||
Core::ActionManager::registerAction(m_zoomAction, Core::Id(Constants::QML_ZOOMTOOL),
|
||||
m_inspectorToolsContext);
|
||||
m_inspectorToolsContext);
|
||||
Core::ActionManager::registerAction(m_showAppOnTopAction,
|
||||
Core::Id(Constants::QML_SHOW_APP_ON_TOP),
|
||||
m_inspectorToolsContext);
|
||||
Core::ActionManager::registerAction(m_updateOnSaveAction,
|
||||
Core::Id(Constants::QML_UPDATE_ON_SAVE),
|
||||
m_inspectorToolsContext);
|
||||
|
||||
Core::ICore::updateAdditionalContexts(Core::Context(),
|
||||
m_inspectorToolsContext);
|
||||
|
||||
Utils::SavedAction *action = debuggerCore()->action(QmlUpdateOnSave);
|
||||
connect(action, SIGNAL(valueChanged(QVariant)),
|
||||
SLOT(onUpdateOnSaveChanged(QVariant)));
|
||||
|
||||
action = debuggerCore()->action(ShowAppOnTop);
|
||||
connect(action, SIGNAL(valueChanged(QVariant)),
|
||||
SLOT(onShowAppOnTopChanged(QVariant)));
|
||||
if (action->isChecked())
|
||||
m_toolsClient->showAppOnTop(true);
|
||||
Core::ICore::updateAdditionalContexts(Core::Context(), m_inspectorToolsContext);
|
||||
|
||||
m_toolsClientConnected = true;
|
||||
onEngineStateChanged(m_engine->state());
|
||||
if (m_showAppOnTopAction->isChecked())
|
||||
m_toolsClient->showAppOnTop(true);
|
||||
|
||||
} else if (m_toolsClientConnected && client == m_toolsClient) {
|
||||
disconnect(client, SIGNAL(currentObjectsChanged(QList<int>)),
|
||||
this, SLOT(selectObjectsFromToolsClient(QList<int>)));
|
||||
disconnect(client, SIGNAL(logActivity(QString,QString)),
|
||||
m_debugAdapter, SLOT(logServiceActivity(QString,QString)));
|
||||
|
||||
Core::ActionManager::unregisterAction(m_selectAction,
|
||||
Core::Id(Constants::QML_SELECTTOOL));
|
||||
Core::ActionManager::unregisterAction(m_zoomAction,
|
||||
Core::Id(Constants::QML_ZOOMTOOL));
|
||||
Core::ActionManager::unregisterAction(m_selectAction, Core::Id(Constants::QML_SELECTTOOL));
|
||||
Core::ActionManager::unregisterAction(m_zoomAction, Core::Id(Constants::QML_ZOOMTOOL));
|
||||
Core::ActionManager::unregisterAction(m_showAppOnTopAction,
|
||||
Core::Id(Constants::QML_SHOW_APP_ON_TOP));
|
||||
Core::ActionManager::unregisterAction(m_updateOnSaveAction,
|
||||
Core::Id(Constants::QML_UPDATE_ON_SAVE));
|
||||
|
||||
m_selectAction->setChecked(false);
|
||||
m_zoomAction->setChecked(false);
|
||||
Core::ICore::updateAdditionalContexts(m_inspectorToolsContext,
|
||||
Core::Context());
|
||||
|
||||
Utils::SavedAction *action = debuggerCore()->action(QmlUpdateOnSave);
|
||||
disconnect(action, 0, this, 0);
|
||||
action = debuggerCore()->action(ShowAppOnTop);
|
||||
disconnect(action, 0, this, 0);
|
||||
Core::ICore::updateAdditionalContexts(m_inspectorToolsContext, Core::Context());
|
||||
|
||||
enableTools(false);
|
||||
m_toolsClientConnected = false;
|
||||
m_selectAction->setCheckable(false);
|
||||
m_zoomAction->setCheckable(false);
|
||||
m_showAppOnTopAction->setCheckable(false);
|
||||
m_updateOnSaveAction->setCheckable(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,7 +367,7 @@ void QmlInspectorAdapter::updatePendingPreviewDocuments(QmlJS::Document::Ptr doc
|
||||
preview->associateEditor(editor);
|
||||
}
|
||||
|
||||
void QmlInspectorAdapter::onSelectActionTriggered(bool checked)
|
||||
void QmlInspectorAdapter::onSelectActionTriggered(const bool checked)
|
||||
{
|
||||
QTC_ASSERT(toolsClient(), return);
|
||||
if (checked) {
|
||||
@@ -370,7 +379,7 @@ void QmlInspectorAdapter::onSelectActionTriggered(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void QmlInspectorAdapter::onZoomActionTriggered(bool checked)
|
||||
void QmlInspectorAdapter::onZoomActionTriggered(const bool checked)
|
||||
{
|
||||
QTC_ASSERT(toolsClient(), return);
|
||||
if (checked) {
|
||||
@@ -382,20 +391,19 @@ void QmlInspectorAdapter::onZoomActionTriggered(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void QmlInspectorAdapter::onShowAppOnTopChanged(const QVariant &value)
|
||||
void QmlInspectorAdapter::onShowAppOnTopChanged(const bool checked)
|
||||
{
|
||||
bool showAppOnTop = value.toBool();
|
||||
if (m_toolsClient && m_toolsClient->status() == QmlDebug::Enabled)
|
||||
m_toolsClient->showAppOnTop(showAppOnTop);
|
||||
QTC_ASSERT(toolsClient(), return);
|
||||
toolsClient()->showAppOnTop(checked);
|
||||
}
|
||||
|
||||
void QmlInspectorAdapter::onUpdateOnSaveChanged(const QVariant &value)
|
||||
void QmlInspectorAdapter::onUpdateOnSaveChanged(const bool checked)
|
||||
{
|
||||
bool updateOnSave = value.toBool();
|
||||
QTC_ASSERT(toolsClient(), return);
|
||||
for (QHash<QString, QmlLiveTextPreview *>::const_iterator it
|
||||
= m_textPreviews.constBegin();
|
||||
it != m_textPreviews.constEnd(); ++it) {
|
||||
it.value()->setApplyChangesToQmlInspector(updateOnSave);
|
||||
it.value()->setApplyChangesToQmlInspector(checked);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,6 +507,19 @@ void QmlInspectorAdapter::deletePreviews()
|
||||
delete m_textPreviews.take(key);
|
||||
}
|
||||
|
||||
void QmlInspectorAdapter::enableTools(const bool enable)
|
||||
{
|
||||
if (!m_toolsClientConnected)
|
||||
return;
|
||||
m_selectAction->setEnabled(enable);
|
||||
m_showAppOnTopAction->setEnabled(enable);
|
||||
m_updateOnSaveAction->setEnabled(enable);
|
||||
// only enable zoom action for Qt 4.x/old client
|
||||
// (zooming is integrated into selection tool in Qt 5).
|
||||
if (!qobject_cast<QmlToolsClient*>(m_toolsClient))
|
||||
m_zoomAction->setEnabled(enable);
|
||||
}
|
||||
|
||||
void QmlInspectorAdapter::onReload()
|
||||
{
|
||||
QHash<QString, QByteArray> changesHash;
|
||||
@@ -540,5 +561,10 @@ void QmlInspectorAdapter::onDestroyedObject(int objectDebugId)
|
||||
m_agent->fetchObject(m_agent->parentIdForObject(objectDebugId));
|
||||
}
|
||||
|
||||
void QmlInspectorAdapter::onEngineStateChanged(const DebuggerState state)
|
||||
{
|
||||
enableTools(state == InferiorRunOk);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Debugger
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef QMLINSPECTORADAPTER_H
|
||||
#define QMLINSPECTORADAPTER_H
|
||||
|
||||
#include "debuggerconstants.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QStringList>
|
||||
|
||||
@@ -49,11 +51,13 @@ class FileReference;
|
||||
}
|
||||
|
||||
namespace Debugger {
|
||||
|
||||
class DebuggerEngine;
|
||||
|
||||
namespace Internal {
|
||||
|
||||
class WatchTreeView;
|
||||
class QmlAdapter;
|
||||
class QmlEngine;
|
||||
class QmlInspectorAgent;
|
||||
class QmlLiveTextPreview;
|
||||
|
||||
@@ -62,7 +66,7 @@ class QmlInspectorAdapter : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QmlInspectorAdapter(QmlAdapter *debugAdapter, QmlEngine *engine,
|
||||
QmlInspectorAdapter(QmlAdapter *debugAdapter, DebuggerEngine *engine,
|
||||
QObject *parent = 0);
|
||||
~QmlInspectorAdapter();
|
||||
|
||||
@@ -78,6 +82,8 @@ signals:
|
||||
void selectionChanged();
|
||||
|
||||
private slots:
|
||||
void onEngineStateChanged(const Debugger::DebuggerState);
|
||||
|
||||
void clientStatusChanged(QmlDebug::ClientStatus status);
|
||||
void toolsClientStatusChanged(QmlDebug::ClientStatus status);
|
||||
void engineClientStatusChanged(QmlDebug::ClientStatus status);
|
||||
@@ -89,10 +95,10 @@ private slots:
|
||||
void removePreviewForEditor(Core::IEditor *editor);
|
||||
void updatePendingPreviewDocuments(QmlJS::Document::Ptr doc);
|
||||
|
||||
void onSelectActionTriggered(bool checked);
|
||||
void onZoomActionTriggered(bool checked);
|
||||
void onShowAppOnTopChanged(const QVariant &value);
|
||||
void onUpdateOnSaveChanged(const QVariant &value);
|
||||
void onSelectActionTriggered(const bool checked);
|
||||
void onZoomActionTriggered(const bool checked);
|
||||
void onShowAppOnTopChanged(const bool checked);
|
||||
void onUpdateOnSaveChanged(const bool checked);
|
||||
void onReload();
|
||||
void onReloaded();
|
||||
void onDestroyedObject(int);
|
||||
@@ -110,9 +116,10 @@ private:
|
||||
SelectionTarget target);
|
||||
void deletePreviews();
|
||||
|
||||
void enableTools(const bool enable);
|
||||
|
||||
QmlAdapter *m_debugAdapter;
|
||||
QmlEngine *m_engine;
|
||||
DebuggerEngine *m_engine; // Master Engine
|
||||
QmlDebug::BaseEngineDebugClient *m_engineClient;
|
||||
QHash<QString, QmlDebug::BaseEngineDebugClient*> m_engineClients;
|
||||
QmlDebug::BaseToolsClient *m_toolsClient;
|
||||
@@ -135,6 +142,8 @@ private:
|
||||
Core::Context m_inspectorToolsContext;
|
||||
QAction *m_selectAction;
|
||||
QAction *m_zoomAction;
|
||||
QAction *m_showAppOnTopAction;
|
||||
QAction *m_updateOnSaveAction;
|
||||
|
||||
bool m_engineClientConnected;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user