QmlObserver: Disable UI when no server plugin exists

Reviewed-by: Christiaan Janssen
This commit is contained in:
Kai Koehne
2010-10-01 16:28:45 +02:00
parent 8a48ef7869
commit 83e2a37850
5 changed files with 51 additions and 15 deletions

View File

@@ -76,7 +76,6 @@ public:
void logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus); void logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus);
signals: signals:
void aboutToDisconnect();
void connected(); void connected();
void disconnected(); void disconnected();
void connectionStartupFailed(); void connectionStartupFailed();

View File

@@ -53,10 +53,10 @@ ClientProxy::ClientProxy(Debugger::QmlAdapter *adapter, QObject *parent)
, m_designClient(0) , m_designClient(0)
, m_engineQuery(0) , m_engineQuery(0)
, m_contextQuery(0) , m_contextQuery(0)
, m_isConnected(false)
{ {
m_requestObjectsTimer.setSingleShot(true); m_requestObjectsTimer.setSingleShot(true);
m_requestObjectsTimer.setInterval(3000); m_requestObjectsTimer.setInterval(3000);
connect(m_adapter, SIGNAL(aboutToDisconnect()), SLOT(disconnectFromServer()));
connect(m_client, SIGNAL(newObjects()), this, SLOT(newObjects())); connect(m_client, SIGNAL(newObjects()), this, SLOT(newObjects()));
connect(&m_requestObjectsTimer, SIGNAL(timeout()), this, SLOT(refreshObjectTree())); connect(&m_requestObjectsTimer, SIGNAL(timeout()), this, SLOT(refreshObjectTree()));
connectToServer(); connectToServer();
@@ -66,8 +66,6 @@ void ClientProxy::connectToServer()
{ {
m_designClient = new QmlJSObserverClient(m_adapter->connection(), this); m_designClient = new QmlJSObserverClient(m_adapter->connection(), this);
if (m_designClient->status() == QDeclarativeDebugClient::Enabled)
emit connected();
m_adapter->logServiceStatusChange(m_designClient->name(), m_designClient->status()); m_adapter->logServiceStatusChange(m_designClient->name(), m_designClient->status());
@@ -93,7 +91,9 @@ void ClientProxy::connectToServer()
SIGNAL(selectedColorChanged(QColor))); SIGNAL(selectedColorChanged(QColor)));
connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)), connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)),
SIGNAL(contextPathUpdated(QStringList))); SIGNAL(contextPathUpdated(QStringList)));
reloadEngines(); reloadEngines();
updateConnected();
} }
void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status) void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
@@ -105,8 +105,7 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
m_adapter->logServiceStatusChange(serviceName, status); m_adapter->logServiceStatusChange(serviceName, status);
if (status == QDeclarativeDebugClient::Enabled) updateConnected();
emit connected();
} }
void ClientProxy::disconnectFromServer() void ClientProxy::disconnectFromServer()
@@ -147,6 +146,8 @@ void ClientProxy::disconnectFromServer()
qDeleteAll(m_objectTreeQuery); qDeleteAll(m_objectTreeQuery);
m_objectTreeQuery.clear(); m_objectTreeQuery.clear();
updateConnected();
} }
void ClientProxy::refreshObjectTree() void ClientProxy::refreshObjectTree()
@@ -494,6 +495,21 @@ void ClientProxy::setContextPathIndex(int contextIndex)
m_designClient->setContextPathIndex(contextIndex); m_designClient->setContextPathIndex(contextIndex);
} }
void ClientProxy::updateConnected()
{
bool isConnected = m_designClient && m_designClient->status() == QDeclarativeDebugClient::Enabled
&& m_client && m_client->status() == QDeclarativeEngineDebug::Enabled;
if (isConnected != m_isConnected) {
m_isConnected = isConnected;
if (isConnected) {
emit connected();
} else {
emit disconnected();
}
}
}
void ClientProxy::reloadEngines() void ClientProxy::reloadEngines()
{ {
if (m_engineQuery) { if (m_engineQuery) {
@@ -532,8 +548,7 @@ Debugger::QmlAdapter *ClientProxy::qmlAdapter() const
bool ClientProxy::isConnected() const bool ClientProxy::isConnected() const
{ {
return m_designClient && m_designClient->status() == QDeclarativeDebugClient::Enabled return m_isConnected;
&& m_client && m_client->status() == QDeclarativeEngineDebug::Enabled;
} }
void ClientProxy::newObjects() void ClientProxy::newObjects()

View File

@@ -92,7 +92,6 @@ signals:
void selectedItemsChanged(const QList<QDeclarativeDebugObjectReference> &selectedItems); void selectedItemsChanged(const QList<QDeclarativeDebugObjectReference> &selectedItems);
void connected(); void connected();
void aboutToDisconnect();
void disconnected(); void disconnected();
void colorPickerActivated(); void colorPickerActivated();
@@ -136,6 +135,7 @@ private slots:
void newObjects(); void newObjects();
private: private:
void updateConnected();
void reloadEngines(); void reloadEngines();
QList<QDeclarativeDebugObjectReference> objectReferences(const QDeclarativeDebugObjectReference &objectRef) const; QList<QDeclarativeDebugObjectReference> objectReferences(const QDeclarativeDebugObjectReference &objectRef) const;
@@ -157,6 +157,8 @@ private:
QList<QDeclarativeDebugEngineReference> m_engines; QList<QDeclarativeDebugEngineReference> m_engines;
QTimer m_requestObjectsTimer; QTimer m_requestObjectsTimer;
DebugIdHash m_debugIdHash; DebugIdHash m_debugIdHash;
bool m_isConnected;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -501,6 +501,20 @@ void InspectorUi::setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjec
gotoObjectReferenceDefinition(objectReferences.first()); gotoObjectReferenceDefinition(objectReferences.first());
} }
void InspectorUi::enable()
{
m_toolbar->enable();
m_crumblePath->setEnabled(true);
m_objectTreeWidget->setEnabled(true);
}
void InspectorUi::disable()
{
m_toolbar->disable();
m_crumblePath->setEnabled(false);
m_objectTreeWidget->setEnabled(false);
}
void InspectorUi::gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj) void InspectorUi::gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj)
{ {
Q_UNUSED(obj); Q_UNUSED(obj);
@@ -686,8 +700,8 @@ void InspectorUi::disableLivePreview()
void InspectorUi::setupToolbar(bool doConnect) void InspectorUi::setupToolbar(bool doConnect)
{ {
if (doConnect) { if (doConnect) {
connect(m_clientProxy, SIGNAL(connected()), m_toolbar, SLOT(enable())); connect(m_clientProxy, SIGNAL(connected()), this, SLOT(enable()));
connect(m_clientProxy, SIGNAL(disconnected()), m_toolbar, SLOT(disable())); connect(m_clientProxy, SIGNAL(disconnected()), this, SLOT(disable()));
connect(m_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool))); connect(m_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool)));
connect(m_toolbar, SIGNAL(reloadSelected()), m_clientProxy, SLOT(reloadQmlViewer())); connect(m_toolbar, SIGNAL(reloadSelected()), m_clientProxy, SLOT(reloadQmlViewer()));
@@ -705,10 +719,9 @@ void InspectorUi::setupToolbar(bool doConnect)
connect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setSelectedColor(QColor))); connect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setSelectedColor(QColor)));
connect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(setAnimationSpeed(qreal))); connect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(setAnimationSpeed(qreal)));
m_toolbar->enable();
} else { } else {
disconnect(m_clientProxy, SIGNAL(connected()), m_toolbar, SLOT(enable())); disconnect(m_clientProxy, SIGNAL(connected()), this, SLOT(enable()));
disconnect(m_clientProxy, SIGNAL(disconnected()), m_toolbar, SLOT(disable())); disconnect(m_clientProxy, SIGNAL(disconnected()), this, SLOT(disable()));
disconnect(m_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool))); disconnect(m_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool)));
disconnect(m_toolbar, SIGNAL(reloadSelected()), m_clientProxy, SLOT(reloadQmlViewer())); disconnect(m_toolbar, SIGNAL(reloadSelected()), m_clientProxy, SLOT(reloadQmlViewer()));
@@ -726,6 +739,11 @@ void InspectorUi::setupToolbar(bool doConnect)
disconnect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setSelectedColor(QColor))); disconnect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setSelectedColor(QColor)));
disconnect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(setAnimationSpeed(qreal))); disconnect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(setAnimationSpeed(qreal)));
m_toolbar->disable(); }
if (m_clientProxy && m_clientProxy->isConnected()) {
enable();
} else {
disable();
} }
} }

View File

@@ -119,6 +119,8 @@ public slots:
void setApplyChangesToQmlObserver(bool applyChanges); void setApplyChangesToQmlObserver(bool applyChanges);
private slots: private slots:
void enable();
void disable();
void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj); void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj);
void setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjectReference> objectReferences); void setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjectReference> objectReferences);