Commit 83e2a378 authored by Kai Koehne's avatar Kai Koehne
Browse files

QmlObserver: Disable UI when no server plugin exists

Reviewed-by: Christiaan Janssen
parent 8a48ef78
......@@ -76,7 +76,6 @@ public:
void logServiceStatusChange(const QString &service, QDeclarativeDebugClient::Status newStatus);
signals:
void aboutToDisconnect();
void connected();
void disconnected();
void connectionStartupFailed();
......
......@@ -53,10 +53,10 @@ ClientProxy::ClientProxy(Debugger::QmlAdapter *adapter, QObject *parent)
, m_designClient(0)
, m_engineQuery(0)
, m_contextQuery(0)
, m_isConnected(false)
{
m_requestObjectsTimer.setSingleShot(true);
m_requestObjectsTimer.setInterval(3000);
connect(m_adapter, SIGNAL(aboutToDisconnect()), SLOT(disconnectFromServer()));
connect(m_client, SIGNAL(newObjects()), this, SLOT(newObjects()));
connect(&m_requestObjectsTimer, SIGNAL(timeout()), this, SLOT(refreshObjectTree()));
connectToServer();
......@@ -66,8 +66,6 @@ void ClientProxy::connectToServer()
{
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());
......@@ -93,7 +91,9 @@ void ClientProxy::connectToServer()
SIGNAL(selectedColorChanged(QColor)));
connect(m_designClient, SIGNAL(contextPathUpdated(QStringList)),
SIGNAL(contextPathUpdated(QStringList)));
reloadEngines();
updateConnected();
}
void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
......@@ -105,8 +105,7 @@ void ClientProxy::clientStatusChanged(QDeclarativeDebugClient::Status status)
m_adapter->logServiceStatusChange(serviceName, status);
if (status == QDeclarativeDebugClient::Enabled)
emit connected();
updateConnected();
}
void ClientProxy::disconnectFromServer()
......@@ -147,6 +146,8 @@ void ClientProxy::disconnectFromServer()
qDeleteAll(m_objectTreeQuery);
m_objectTreeQuery.clear();
updateConnected();
}
void ClientProxy::refreshObjectTree()
......@@ -494,6 +495,21 @@ void ClientProxy::setContextPathIndex(int 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()
{
if (m_engineQuery) {
......@@ -532,8 +548,7 @@ Debugger::QmlAdapter *ClientProxy::qmlAdapter() const
bool ClientProxy::isConnected() const
{
return m_designClient && m_designClient->status() == QDeclarativeDebugClient::Enabled
&& m_client && m_client->status() == QDeclarativeEngineDebug::Enabled;
return m_isConnected;
}
void ClientProxy::newObjects()
......
......@@ -92,7 +92,6 @@ signals:
void selectedItemsChanged(const QList<QDeclarativeDebugObjectReference> &selectedItems);
void connected();
void aboutToDisconnect();
void disconnected();
void colorPickerActivated();
......@@ -136,6 +135,7 @@ private slots:
void newObjects();
private:
void updateConnected();
void reloadEngines();
QList<QDeclarativeDebugObjectReference> objectReferences(const QDeclarativeDebugObjectReference &objectRef) const;
......@@ -157,6 +157,8 @@ private:
QList<QDeclarativeDebugEngineReference> m_engines;
QTimer m_requestObjectsTimer;
DebugIdHash m_debugIdHash;
bool m_isConnected;
};
} // namespace Internal
......
......@@ -501,6 +501,20 @@ void InspectorUi::setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjec
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)
{
Q_UNUSED(obj);
......@@ -686,8 +700,8 @@ void InspectorUi::disableLivePreview()
void InspectorUi::setupToolbar(bool doConnect)
{
if (doConnect) {
connect(m_clientProxy, SIGNAL(connected()), m_toolbar, SLOT(enable()));
connect(m_clientProxy, SIGNAL(disconnected()), m_toolbar, SLOT(disable()));
connect(m_clientProxy, SIGNAL(connected()), this, SLOT(enable()));
connect(m_clientProxy, SIGNAL(disconnected()), this, SLOT(disable()));
connect(m_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool)));
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(animationSpeedChanged(qreal)), m_toolbar, SLOT(setAnimationSpeed(qreal)));
m_toolbar->enable();
} else {
disconnect(m_clientProxy, SIGNAL(connected()), m_toolbar, SLOT(enable()));
disconnect(m_clientProxy, SIGNAL(disconnected()), m_toolbar, SLOT(disable()));
disconnect(m_clientProxy, SIGNAL(connected()), this, SLOT(enable()));
disconnect(m_clientProxy, SIGNAL(disconnected()), this, SLOT(disable()));
disconnect(m_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool)));
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(animationSpeedChanged(qreal)), m_toolbar, SLOT(setAnimationSpeed(qreal)));
m_toolbar->disable();
}
if (m_clientProxy && m_clientProxy->isConnected()) {
enable();
} else {
disable();
}
}
......@@ -119,6 +119,8 @@ public slots:
void setApplyChangesToQmlObserver(bool applyChanges);
private slots:
void enable();
void disable();
void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj);
void setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjectReference> objectReferences);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment