forked from qt-creator/qt-creator
QmlJS Live Preview: Implemented "Apply changes from Qml File" button
The button is checkable and pressing it will stop/propagate changes to the qml application being debugged.
This commit is contained in:
@@ -53,6 +53,9 @@ QmlInspectorToolbar::QmlInspectorToolbar(QObject *parent) :
|
||||
void QmlInspectorToolbar::setEnabled(bool value)
|
||||
{
|
||||
m_designmodeAction->setEnabled(value);
|
||||
//m_toQmlAction->setEnabled(value);
|
||||
m_fromQmlAction->setEnabled(value);
|
||||
|
||||
m_reloadAction->setEnabled(value);
|
||||
m_playAction->setEnabled(value);
|
||||
m_pauseAction->setEnabled(value);
|
||||
@@ -60,7 +63,7 @@ void QmlInspectorToolbar::setEnabled(bool value)
|
||||
m_selectMarqueeAction->setEnabled(value);
|
||||
m_zoomAction->setEnabled(value);
|
||||
m_colorPickerAction->setEnabled(value);
|
||||
m_toQmlAction->setEnabled(value);
|
||||
//m_toQmlAction->setEnabled(value);
|
||||
m_fromQmlAction->setEnabled(value);
|
||||
}
|
||||
|
||||
@@ -149,7 +152,9 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
|
||||
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
|
||||
Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>();
|
||||
|
||||
m_fromQmlAction = new QAction(QIcon(":/qml/images/from-qml-small.png"), tr("Apply Changes to Document"), this);
|
||||
m_designmodeAction = new QAction(QIcon(":/qml/images/designmode.png"), "Design Mode", this);
|
||||
|
||||
m_reloadAction = new QAction(QIcon(":/qml/images/reload.png"), "Reload", this);
|
||||
m_playAction = new QAction(QIcon(":/qml/images/play-small.png"), tr("Play animations"), this);
|
||||
m_pauseAction = new QAction(QIcon(":/qml/images/pause-small.png"), tr("Pause animations"), this);
|
||||
@@ -158,7 +163,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
|
||||
m_zoomAction = new QAction(QIcon(":/qml/images/zoom-small.png"), tr("Zoom"), this);
|
||||
m_colorPickerAction = new QAction(QIcon(":/qml/images/color-picker-small.png"), tr("Color Picker"), this);
|
||||
m_toQmlAction = new QAction(QIcon(":/qml/images/to-qml-small.png"), tr("Apply Changes to QML Viewer"), this);
|
||||
m_fromQmlAction = new QAction(QIcon(":/qml/images/from-qml-small.png"), tr("Apply Changes to Document"), this);
|
||||
|
||||
m_designmodeAction->setCheckable(true);
|
||||
m_designmodeAction->setChecked(false);
|
||||
m_playAction->setCheckable(true);
|
||||
@@ -169,6 +174,9 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
|
||||
m_zoomAction->setCheckable(true);
|
||||
m_colorPickerAction->setCheckable(true);
|
||||
|
||||
m_fromQmlAction->setCheckable(true);
|
||||
m_fromQmlAction->setChecked(true);
|
||||
|
||||
am->registerAction(m_designmodeAction, QmlJSInspector::Constants::DESIGNMODE_ACTION, context);
|
||||
am->registerAction(m_reloadAction, QmlJSInspector::Constants::RELOAD_ACTION, context);
|
||||
am->registerAction(m_playAction, QmlJSInspector::Constants::PLAY_ACTION, context);
|
||||
@@ -219,6 +227,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
|
||||
|
||||
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::DEBUG)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(ProjectExplorer::Constants::STOP)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::FROM_QML_ACTION)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::DESIGNMODE_ACTION)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::RELOAD_ACTION)->action()));
|
||||
|
||||
@@ -233,8 +242,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
|
||||
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::ZOOM_ACTION)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::COLOR_PICKER_ACTION)->action()));
|
||||
|
||||
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::TO_QML_ACTION)->action()));
|
||||
configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::FROM_QML_ACTION)->action()));
|
||||
//configBarLayout->addWidget(createToolButton(am->command(QmlJSInspector::Constants::TO_QML_ACTION)->action()));
|
||||
|
||||
configBarLayout->addStretch();
|
||||
|
||||
@@ -254,7 +262,7 @@ void QmlInspectorToolbar::createActions(const Core::Context &context)
|
||||
connect(m_selectAction, SIGNAL(triggered()), SLOT(activateSelectToolOnClick()));
|
||||
connect(m_selectMarqueeAction, SIGNAL(triggered()), SLOT(activateMarqueeSelectToolOnClick()));
|
||||
|
||||
connect(m_toQmlAction, SIGNAL(triggered()), SLOT(activateToQml()));
|
||||
//connect(m_toQmlAction, SIGNAL(triggered()), SLOT(activateToQml()));
|
||||
connect(m_fromQmlAction, SIGNAL(triggered()), SLOT(activateFromQml()));
|
||||
}
|
||||
|
||||
@@ -299,8 +307,6 @@ void QmlInspectorToolbar::activateDesignModeOnClick()
|
||||
m_selectMarqueeAction->setEnabled(checked);
|
||||
m_zoomAction->setEnabled(checked);
|
||||
m_colorPickerAction->setEnabled(checked);
|
||||
m_toQmlAction->setEnabled(checked);
|
||||
m_fromQmlAction->setEnabled(checked);
|
||||
|
||||
if (m_emitSignals)
|
||||
emit designModeSelected(checked);
|
||||
@@ -388,7 +394,7 @@ void QmlInspectorToolbar::activateZoomOnClick()
|
||||
void QmlInspectorToolbar::activateFromQml()
|
||||
{
|
||||
if (m_emitSignals)
|
||||
emit applyChangesFromQmlFileSelected();
|
||||
emit applyChangesFromQmlFileTriggered(m_fromQmlAction->isChecked());
|
||||
}
|
||||
|
||||
void QmlInspectorToolbar::activateToQml()
|
||||
|
||||
@@ -52,7 +52,7 @@ signals:
|
||||
void zoomToolSelected();
|
||||
|
||||
void applyChangesToQmlFileSelected();
|
||||
void applyChangesFromQmlFileSelected();
|
||||
void applyChangesFromQmlFileTriggered(bool isChecked);
|
||||
|
||||
private slots:
|
||||
void activateDesignModeOnClick();
|
||||
|
||||
@@ -636,3 +636,13 @@ bool Inspector::addQuotesForData(const QVariant &value) const
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Inspector::setApplyChangesToQmlObserver(bool applyChanges)
|
||||
{
|
||||
QHashIterator<QString, QmlJSLiveTextPreview *> iter(m_textPreviews);
|
||||
while(iter.hasNext()) {
|
||||
iter.next();
|
||||
iter.value()->setApplyChangesToQmlObserver(applyChanges);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ public:
|
||||
QDeclarativeDebugExpressionQuery *setBindingForObject(int objectDebugId, const QString &objectId,
|
||||
const QString &propertyName, const QVariant &value,
|
||||
bool isLiteralValue);
|
||||
|
||||
signals:
|
||||
void statusMessage(const QString &text);
|
||||
|
||||
@@ -100,6 +99,7 @@ public slots:
|
||||
void setSimpleDockWidgetArrangement();
|
||||
void reloadQmlViewer();
|
||||
void serverReloaded();
|
||||
void setApplyChangesToQmlObserver(bool applyChanges);
|
||||
|
||||
private slots:
|
||||
void gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj);
|
||||
|
||||
@@ -166,6 +166,7 @@ void InspectorPlugin::extensionsInitialized()
|
||||
connect(m_toolbar, SIGNAL(zoomToolSelected()), _clientProxy, SLOT(changeToZoomTool()));
|
||||
connect(m_toolbar, SIGNAL(selectToolSelected()), _clientProxy, SLOT(changeToSelectTool()));
|
||||
connect(m_toolbar, SIGNAL(marqueeSelectToolSelected()), _clientProxy, SLOT(changeToSelectMarqueeTool()));
|
||||
connect(m_toolbar, SIGNAL(applyChangesFromQmlFileTriggered(bool)), _inspector, SLOT(setApplyChangesToQmlObserver(bool)));
|
||||
|
||||
connect(_clientProxy, SIGNAL(colorPickerActivated()), m_toolbar, SLOT(activateColorPicker()));
|
||||
connect(_clientProxy, SIGNAL(selectToolActivated()), m_toolbar, SLOT(activateSelectTool()));
|
||||
|
||||
@@ -164,7 +164,7 @@ void QmlJSLiveTextPreview::unassociateEditor(Core::IEditor *oldEditor)
|
||||
}
|
||||
|
||||
QmlJSLiveTextPreview::QmlJSLiveTextPreview(const QmlJS::Document::Ptr &doc, const QmlJS::Document::Ptr &initDoc, QObject* parent) :
|
||||
QObject(parent), m_previousDoc(doc), m_initialDoc(initDoc)
|
||||
QObject(parent), m_previousDoc(doc), m_initialDoc(initDoc), m_applyChangesToQmlObserver(true)
|
||||
{
|
||||
Q_ASSERT(doc->fileName() == initDoc->fileName());
|
||||
ClientProxy *clientProxy = ClientProxy::instance();
|
||||
@@ -184,6 +184,7 @@ void QmlJSLiveTextPreview::resetInitialDoc(const QmlJS::Document::Ptr &doc)
|
||||
m_previousDoc = doc;
|
||||
m_createdObjects.clear();
|
||||
m_debugIds.clear();
|
||||
m_docWithUnappliedChanges.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -462,6 +463,9 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
||||
if (!core->hasContext(dbgcontext))
|
||||
return;
|
||||
|
||||
if (m_applyChangesToQmlObserver) {
|
||||
m_docWithUnappliedChanges.clear();
|
||||
|
||||
if (doc && m_previousDoc && doc->fileName() == m_previousDoc->fileName()
|
||||
&& doc->qmlProgram() && m_previousDoc->qmlProgram())
|
||||
{
|
||||
@@ -475,6 +479,21 @@ void QmlJSLiveTextPreview::documentChanged(QmlJS::Document::Ptr doc)
|
||||
if (!delta.newObjects.isEmpty())
|
||||
m_createdObjects[doc] += delta.newObjects;
|
||||
}
|
||||
} else {
|
||||
m_docWithUnappliedChanges = doc;
|
||||
}
|
||||
}
|
||||
|
||||
void QmlJSLiveTextPreview::setApplyChangesToQmlObserver(bool applyChanges)
|
||||
{
|
||||
if (applyChanges && !m_applyChangesToQmlObserver) {
|
||||
if (m_docWithUnappliedChanges) {
|
||||
m_applyChangesToQmlObserver = true;
|
||||
documentChanged(m_docWithUnappliedChanges);
|
||||
}
|
||||
}
|
||||
|
||||
m_applyChangesToQmlObserver = applyChanges;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -75,11 +75,14 @@ public:
|
||||
signals:
|
||||
void selectedItemsChanged(const QList<QDeclarativeDebugObjectReference> &objects);
|
||||
|
||||
public slots:
|
||||
void setApplyChangesToQmlObserver(bool applyChanges);
|
||||
void updateDebugIds(const QDeclarativeDebugObjectReference &rootReference);
|
||||
|
||||
private slots:
|
||||
void changeSelectedElements(QList<int> offsets, const QString &wordAtCursor);
|
||||
void documentChanged(QmlJS::Document::Ptr doc);
|
||||
public slots:
|
||||
void updateDebugIds(const QDeclarativeDebugObjectReference &rootReference);
|
||||
|
||||
|
||||
private:
|
||||
QList<int> objectReferencesForOffset(quint32 offset) const;
|
||||
@@ -95,6 +98,9 @@ private:
|
||||
|
||||
QList<QWeakPointer<QmlJSEditor::Internal::QmlJSTextEditor> > m_editors;
|
||||
|
||||
bool m_applyChangesToQmlObserver;
|
||||
QmlJS::Document::Ptr m_docWithUnappliedChanges;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user