2010-06-29 12:41:26 +02:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
|
|
|
**
|
|
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
|
|
|
**
|
|
|
|
|
** Commercial Usage
|
|
|
|
|
**
|
|
|
|
|
** Licensees holding valid Qt Commercial licenses may use this file in
|
|
|
|
|
** accordance with the Qt Commercial License Agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Nokia.
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** If you are unsure which license is appropriate for your use, please
|
|
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
|
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
#include "qmljsinspectorconstants.h"
|
2010-06-29 13:51:50 +02:00
|
|
|
#include "qmljsinspector.h"
|
2010-08-13 14:18:10 +02:00
|
|
|
#include "qmlinspectortoolbar.h"
|
2010-06-29 13:51:50 +02:00
|
|
|
#include "qmljsclientproxy.h"
|
2010-07-08 11:34:51 +02:00
|
|
|
#include "qmljslivetextpreview.h"
|
|
|
|
|
#include "qmljsprivateapi.h"
|
2010-08-02 17:25:29 +02:00
|
|
|
#include "qmljscontextcrumblepath.h"
|
2010-08-09 10:07:03 +02:00
|
|
|
#include "qmljsinspectorsettings.h"
|
2010-06-29 16:15:49 +02:00
|
|
|
|
2010-07-16 15:59:08 +02:00
|
|
|
#include <qmljseditor/qmljseditorconstants.h>
|
|
|
|
|
|
2010-06-29 16:15:49 +02:00
|
|
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
|
|
|
|
#include <qmljs/qmljsdocument.h>
|
2010-07-21 14:26:25 +02:00
|
|
|
#include <qmljs/qmljsdelta.h>
|
2010-06-29 13:51:50 +02:00
|
|
|
|
|
|
|
|
#include <debugger/debuggerrunner.h>
|
|
|
|
|
#include <debugger/debuggerconstants.h>
|
|
|
|
|
#include <debugger/debuggerengine.h>
|
|
|
|
|
#include <debugger/debuggermainwindow.h>
|
|
|
|
|
#include <debugger/debuggerplugin.h>
|
|
|
|
|
#include <debugger/debuggerrunner.h>
|
|
|
|
|
#include <debugger/debuggeruiswitcher.h>
|
|
|
|
|
#include <debugger/debuggerconstants.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
#include <utils/fancymainwindow.h>
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icontext.h>
|
|
|
|
|
#include <coreplugin/basemode.h>
|
|
|
|
|
#include <coreplugin/findplaceholder.h>
|
|
|
|
|
#include <coreplugin/minisplitter.h>
|
|
|
|
|
#include <coreplugin/outputpane.h>
|
|
|
|
|
#include <coreplugin/rightpane.h>
|
|
|
|
|
#include <coreplugin/navigationwidget.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/actionmanager/command.h>
|
|
|
|
|
#include <coreplugin/editormanager/editormanager.h>
|
|
|
|
|
|
|
|
|
|
#include <texteditor/itexteditor.h>
|
|
|
|
|
#include <texteditor/basetexteditor.h>
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/runconfiguration.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
#include <projectexplorer/applicationrunconfiguration.h>
|
|
|
|
|
#include <qmlprojectmanager/qmlprojectconstants.h>
|
|
|
|
|
#include <qmlprojectmanager/qmlprojectrunconfiguration.h>
|
|
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
#include <QtCore/QStringList>
|
|
|
|
|
#include <QtCore/QTimer>
|
|
|
|
|
#include <QtCore/QtPlugin>
|
|
|
|
|
#include <QtCore/QDateTime>
|
|
|
|
|
|
|
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QDockWidget>
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QLineEdit>
|
|
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QSpinBox>
|
|
|
|
|
#include <QtGui/QMessageBox>
|
|
|
|
|
#include <QtGui/QTextBlock>
|
|
|
|
|
|
|
|
|
|
#include <QtNetwork/QHostAddress>
|
|
|
|
|
|
2010-06-29 16:15:49 +02:00
|
|
|
using namespace QmlJS;
|
2010-06-29 13:51:50 +02:00
|
|
|
using namespace QmlJS::AST;
|
2010-06-29 12:41:26 +02:00
|
|
|
using namespace QmlJSInspector::Internal;
|
2010-06-29 13:51:50 +02:00
|
|
|
using namespace Debugger::Internal;
|
2010-06-29 12:41:26 +02:00
|
|
|
|
2010-06-29 14:12:39 +02:00
|
|
|
enum {
|
|
|
|
|
MaxConnectionAttempts = 50,
|
|
|
|
|
ConnectionAttemptDefaultInterval = 75,
|
|
|
|
|
|
|
|
|
|
// used when debugging with c++ - connection can take a lot of time
|
|
|
|
|
ConnectionAttemptSimultaneousInterval = 500
|
|
|
|
|
};
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
InspectorUi *InspectorUi::m_instance = 0;
|
2010-07-30 15:28:05 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
QmlJS::ModelManagerInterface *modelManager()
|
2010-06-29 12:41:26 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
return ExtensionSystem::PluginManager::instance()->getObject<QmlJS::ModelManagerInterface>();
|
2010-06-29 12:41:26 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
InspectorUi::InspectorUi(QObject *parent)
|
|
|
|
|
: QObject(parent)
|
|
|
|
|
, m_listeningToEditorManager(false)
|
|
|
|
|
, m_settings(new InspectorSettings(this))
|
|
|
|
|
, m_clientProxy(0)
|
|
|
|
|
, m_debugProject(0)
|
|
|
|
|
{
|
|
|
|
|
m_instance = this;
|
|
|
|
|
m_toolbar = new QmlInspectorToolbar(this);
|
|
|
|
|
}
|
2010-07-09 17:02:36 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
InspectorUi::~InspectorUi()
|
2010-06-29 12:41:26 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
}
|
2010-08-09 10:07:03 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::setupUi()
|
|
|
|
|
{
|
|
|
|
|
setupDockWidgets();
|
|
|
|
|
m_toolbar->createActions(Core::Context(Constants::C_INSPECTOR));
|
|
|
|
|
restoreSettings();
|
2010-08-09 10:07:03 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::saveSettings() const
|
2010-08-09 10:07:03 +02:00
|
|
|
{
|
|
|
|
|
m_settings->saveSettings(Core::ICore::instance()->settings());
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::restoreSettings()
|
2010-08-09 10:07:03 +02:00
|
|
|
{
|
|
|
|
|
m_settings->restoreSettings(Core::ICore::instance()->settings());
|
2010-06-29 12:41:26 +02:00
|
|
|
}
|
2010-06-29 13:51:50 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::connected(ClientProxy *clientProxy)
|
|
|
|
|
{
|
|
|
|
|
m_clientProxy = clientProxy;
|
|
|
|
|
|
|
|
|
|
connect(m_clientProxy, SIGNAL(selectedItemsChanged(QList<QDeclarativeDebugObjectReference>)),
|
|
|
|
|
SLOT(setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjectReference>)));
|
|
|
|
|
|
|
|
|
|
connect(m_clientProxy, SIGNAL(enginesChanged()), SLOT(updateEngineList()));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(serverReloaded()), this, SLOT(serverReloaded()));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(contextPathUpdated(QStringList)),
|
|
|
|
|
m_crumblePath, SLOT(updateContextPath(QStringList)));
|
|
|
|
|
|
|
|
|
|
m_debugProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject();
|
|
|
|
|
connect(m_debugProject, SIGNAL(destroyed()), SLOT(currentDebugProjectRemoved()));
|
|
|
|
|
|
|
|
|
|
setupToolbar(true);
|
|
|
|
|
resetViews();
|
|
|
|
|
|
|
|
|
|
initializeDocuments();
|
|
|
|
|
|
|
|
|
|
QHashIterator<QString, QmlJSLiveTextPreview *> iter(m_textPreviews);
|
|
|
|
|
while(iter.hasNext()) {
|
|
|
|
|
iter.next();
|
|
|
|
|
iter.value()->setClientProxy(m_clientProxy);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void InspectorUi::disconnected()
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
disconnect(m_clientProxy, SIGNAL(selectedItemsChanged(QList<QDeclarativeDebugObjectReference>)),
|
|
|
|
|
this, SLOT(setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjectReference>)));
|
|
|
|
|
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(enginesChanged()), this, SLOT(updateEngineList()));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(serverReloaded()), this, SLOT(serverReloaded()));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(contextPathUpdated(QStringList)),
|
|
|
|
|
m_crumblePath, SLOT(updateContextPath(QStringList)));
|
|
|
|
|
|
2010-08-06 14:03:13 +02:00
|
|
|
m_debugProject = 0;
|
2010-06-29 13:51:50 +02:00
|
|
|
resetViews();
|
2010-08-13 14:18:10 +02:00
|
|
|
|
|
|
|
|
setupToolbar(false);
|
2010-08-02 11:56:10 +02:00
|
|
|
applyChangesToQmlObserverHelper(false);
|
2010-08-13 14:18:10 +02:00
|
|
|
|
|
|
|
|
QHashIterator<QString, QmlJSLiveTextPreview *> iter(m_textPreviews);
|
|
|
|
|
while(iter.hasNext()) {
|
|
|
|
|
iter.next();
|
|
|
|
|
iter.value()->setClientProxy(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_clientProxy = 0;
|
2010-06-29 13:51:50 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::updateEngineList()
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
2010-08-18 11:40:03 +02:00
|
|
|
m_engines = m_clientProxy->engines();
|
2010-06-29 14:24:12 +02:00
|
|
|
|
2010-07-09 14:01:03 +02:00
|
|
|
//#warning update the QML engines combo
|
2010-06-29 13:51:50 +02:00
|
|
|
|
2010-08-18 11:40:03 +02:00
|
|
|
if (m_engines.isEmpty())
|
2010-06-29 13:51:50 +02:00
|
|
|
qWarning("qmldebugger: no engines found!");
|
2010-06-29 14:24:12 +02:00
|
|
|
else {
|
2010-08-18 11:40:03 +02:00
|
|
|
const QDeclarativeDebugEngineReference engine = m_engines.first();
|
2010-06-29 14:24:12 +02:00
|
|
|
m_clientProxy->queryEngineContext(engine.debugId());
|
2010-06-29 13:51:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::changeSelectedItems(const QList<QDeclarativeDebugObjectReference> &objects)
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
2010-07-08 11:34:51 +02:00
|
|
|
m_clientProxy->setSelectedItemsByObjectId(objects);
|
2010-06-29 13:51:50 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::initializeDocuments()
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
if (!modelManager() || !m_clientProxy)
|
2010-07-16 15:59:08 +02:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Core::EditorManager *em = Core::EditorManager::instance();
|
2010-08-02 11:56:10 +02:00
|
|
|
m_loadedSnapshot = modelManager()->snapshot();
|
|
|
|
|
|
|
|
|
|
if (!m_listeningToEditorManager) {
|
|
|
|
|
m_listeningToEditorManager = true;
|
|
|
|
|
connect(em, SIGNAL(editorAboutToClose(Core::IEditor*)), SLOT(removePreviewForEditor(Core::IEditor*)));
|
|
|
|
|
connect(em, SIGNAL(editorOpened(Core::IEditor*)), SLOT(createPreviewForEditor(Core::IEditor*)));
|
|
|
|
|
}
|
2010-07-16 15:59:08 +02:00
|
|
|
|
|
|
|
|
// initial update
|
2010-07-20 12:35:36 +02:00
|
|
|
foreach (Core::IEditor *editor, em->openedEditors()) {
|
|
|
|
|
createPreviewForEditor(editor);
|
|
|
|
|
}
|
2010-08-02 11:56:10 +02:00
|
|
|
|
|
|
|
|
applyChangesToQmlObserverHelper(true);
|
2010-07-16 15:59:08 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::serverReloaded()
|
2010-07-20 12:35:36 +02:00
|
|
|
{
|
|
|
|
|
QmlJS::Snapshot snapshot = modelManager()->snapshot();
|
|
|
|
|
m_loadedSnapshot = snapshot;
|
|
|
|
|
for (QHash<QString, QmlJSLiveTextPreview *>::const_iterator it = m_textPreviews.constBegin();
|
|
|
|
|
it != m_textPreviews.constEnd(); ++it) {
|
|
|
|
|
Document::Ptr doc = snapshot.document(it.key());
|
|
|
|
|
it.value()->resetInitialDoc(doc);
|
|
|
|
|
}
|
2010-08-18 11:40:03 +02:00
|
|
|
m_clientProxy->queryEngineContext(m_engines.value(0).debugId());
|
2010-07-20 12:35:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::removePreviewForEditor(Core::IEditor *oldEditor)
|
2010-07-16 15:59:08 +02:00
|
|
|
{
|
|
|
|
|
if (QmlJSLiveTextPreview *preview = m_textPreviews.value(oldEditor->file()->fileName())) {
|
|
|
|
|
preview->unassociateEditor(oldEditor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::createPreviewForEditor(Core::IEditor *newEditor)
|
2010-07-16 15:59:08 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
if (m_clientProxy
|
|
|
|
|
&& m_clientProxy->isConnected()
|
|
|
|
|
&& newEditor
|
|
|
|
|
&& newEditor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID
|
|
|
|
|
)
|
2010-08-02 11:56:10 +02:00
|
|
|
{
|
2010-07-16 15:59:08 +02:00
|
|
|
QString filename = newEditor->file()->fileName();
|
|
|
|
|
QmlJS::Document::Ptr doc = modelManager()->snapshot().document(filename);
|
2010-07-19 15:10:36 +02:00
|
|
|
if (!doc || !doc->qmlProgram())
|
|
|
|
|
return;
|
2010-07-20 12:35:36 +02:00
|
|
|
QmlJS::Document::Ptr initdoc = m_loadedSnapshot.document(filename);
|
|
|
|
|
if (!initdoc)
|
|
|
|
|
initdoc = doc;
|
2010-07-16 15:59:08 +02:00
|
|
|
|
|
|
|
|
if (m_textPreviews.contains(filename)) {
|
|
|
|
|
m_textPreviews.value(filename)->associateEditor(newEditor);
|
|
|
|
|
} else {
|
2010-08-13 14:18:10 +02:00
|
|
|
QmlJSLiveTextPreview *preview = new QmlJSLiveTextPreview(doc, initdoc, m_clientProxy, this);
|
2010-07-16 15:59:08 +02:00
|
|
|
connect(preview,
|
|
|
|
|
SIGNAL(selectedItemsChanged(QList<QDeclarativeDebugObjectReference>)),
|
|
|
|
|
SLOT(changeSelectedItems(QList<QDeclarativeDebugObjectReference>)));
|
2010-07-30 15:28:05 +02:00
|
|
|
connect(preview, SIGNAL(reloadQmlViewerRequested()), m_clientProxy, SLOT(reloadQmlViewer()));
|
|
|
|
|
connect(preview, SIGNAL(disableLivePreviewRequested()), SLOT(disableLivePreview()));
|
|
|
|
|
|
2010-07-16 15:59:08 +02:00
|
|
|
m_textPreviews.insert(newEditor->file()->fileName(), preview);
|
2010-07-27 11:57:06 +02:00
|
|
|
preview->associateEditor(newEditor);
|
2010-07-20 12:50:14 +02:00
|
|
|
preview->updateDebugIds(m_clientProxy->rootObjectReference());
|
2010-07-16 15:59:08 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::currentDebugProjectRemoved()
|
2010-08-06 14:03:13 +02:00
|
|
|
{
|
|
|
|
|
m_debugProject = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::resetViews()
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
2010-08-02 18:03:27 +02:00
|
|
|
m_crumblePath->updateContextPath(QStringList());
|
2010-06-29 13:51:50 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::reloadQmlViewer()
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
if (m_clientProxy)
|
|
|
|
|
m_clientProxy->reloadQmlViewer();
|
2010-06-29 13:51:50 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::setSimpleDockWidgetArrangement()
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
|
|
|
|
Utils::FancyMainWindow *mainWindow = Debugger::DebuggerUISwitcher::instance()->mainWindow();
|
|
|
|
|
|
|
|
|
|
mainWindow->setTrackingEnabled(false);
|
2010-08-02 17:25:29 +02:00
|
|
|
mainWindow->removeDockWidget(m_crumblePathDock);
|
|
|
|
|
mainWindow->addDockWidget(Qt::BottomDockWidgetArea, m_crumblePathDock);
|
|
|
|
|
mainWindow->splitDockWidget(mainWindow->toolBarDockWidget(), m_crumblePathDock, Qt::Vertical);
|
2010-08-03 13:48:13 +02:00
|
|
|
m_crumblePathDock->setVisible(true);
|
2010-06-29 13:51:50 +02:00
|
|
|
mainWindow->setTrackingEnabled(true);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::setSelectedItemsByObjectReference(QList<QDeclarativeDebugObjectReference> objectReferences)
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
|
|
|
|
if (objectReferences.length())
|
|
|
|
|
gotoObjectReferenceDefinition(objectReferences.first());
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::gotoObjectReferenceDefinition(const QDeclarativeDebugObjectReference &obj)
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
|
|
|
|
Q_UNUSED(obj);
|
|
|
|
|
|
|
|
|
|
QDeclarativeDebugFileReference source = obj.source();
|
|
|
|
|
const QString fileName = source.url().toLocalFile();
|
|
|
|
|
|
|
|
|
|
if (source.lineNumber() < 0 || !QFile::exists(fileName))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Core::EditorManager *editorManager = Core::EditorManager::instance();
|
|
|
|
|
Core::IEditor *editor = editorManager->openEditor(fileName, QString(), Core::EditorManager::NoModeSwitch);
|
|
|
|
|
TextEditor::ITextEditor *textEditor = qobject_cast<TextEditor::ITextEditor*>(editor);
|
|
|
|
|
|
|
|
|
|
if (textEditor) {
|
|
|
|
|
editorManager->addCurrentPositionToNavigationHistory();
|
|
|
|
|
textEditor->gotoLine(source.lineNumber());
|
|
|
|
|
textEditor->widget()->setFocus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
bool InspectorUi::addQuotesForData(const QVariant &value) const
|
2010-06-29 13:51:50 +02:00
|
|
|
{
|
|
|
|
|
switch (value.type()) {
|
|
|
|
|
case QVariant::String:
|
|
|
|
|
case QVariant::Color:
|
|
|
|
|
case QVariant::Date:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-07-26 11:59:59 +02:00
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::setupDockWidgets()
|
2010-08-02 17:25:29 +02:00
|
|
|
{
|
|
|
|
|
m_crumblePath = new ContextCrumblePath;
|
2010-08-11 10:00:59 +02:00
|
|
|
m_crumblePath->setObjectName("QmlContextPath");
|
2010-08-02 17:25:29 +02:00
|
|
|
m_crumblePath->setWindowTitle("Context Path");
|
2010-08-03 10:17:09 +02:00
|
|
|
connect(m_crumblePath, SIGNAL(elementClicked(int)), SLOT(crumblePathElementClicked(int)));
|
2010-08-02 17:25:29 +02:00
|
|
|
Debugger::DebuggerUISwitcher *uiSwitcher = Debugger::DebuggerUISwitcher::instance();
|
|
|
|
|
m_crumblePathDock = uiSwitcher->createDockWidget(QmlJSInspector::Constants::LANG_QML,
|
|
|
|
|
m_crumblePath, Qt::BottomDockWidgetArea);
|
|
|
|
|
m_crumblePathDock->setAllowedAreas(Qt::TopDockWidgetArea | Qt::BottomDockWidgetArea);
|
|
|
|
|
m_crumblePathDock->setTitleBarWidget(new QWidget(m_crumblePathDock));
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::crumblePathElementClicked(int pathIndex)
|
2010-08-03 10:17:09 +02:00
|
|
|
{
|
2010-08-13 14:18:10 +02:00
|
|
|
if (m_clientProxy && m_clientProxy->isConnected() && !m_crumblePath->isEmpty()) {
|
2010-08-03 10:17:09 +02:00
|
|
|
m_clientProxy->setContextPathIndex(pathIndex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
bool InspectorUi::showExperimentalWarning()
|
2010-07-30 15:28:05 +02:00
|
|
|
{
|
2010-08-09 10:07:03 +02:00
|
|
|
return m_settings->showLivePreviewWarning();
|
2010-07-30 15:28:05 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::setShowExperimentalWarning(bool value)
|
2010-07-30 15:28:05 +02:00
|
|
|
{
|
2010-08-09 10:07:03 +02:00
|
|
|
m_settings->setShowLivePreviewWarning(value);
|
2010-07-30 15:28:05 +02:00
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
InspectorUi *InspectorUi::instance()
|
2010-08-06 14:03:13 +02:00
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
ProjectExplorer::Project *InspectorUi::debugProject() const
|
2010-08-06 14:03:13 +02:00
|
|
|
{
|
|
|
|
|
return m_debugProject;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::setApplyChangesToQmlObserver(bool applyChanges)
|
2010-08-02 11:56:10 +02:00
|
|
|
{
|
|
|
|
|
emit livePreviewActivated(applyChanges);
|
|
|
|
|
applyChangesToQmlObserverHelper(applyChanges);
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::applyChangesToQmlObserverHelper(bool applyChanges)
|
2010-08-02 11:56:10 +02:00
|
|
|
{
|
|
|
|
|
QHashIterator<QString, QmlJSLiveTextPreview *> iter(m_textPreviews);
|
|
|
|
|
while(iter.hasNext()) {
|
|
|
|
|
iter.next();
|
|
|
|
|
iter.value()->setApplyChangesToQmlObserver(applyChanges);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-13 14:18:10 +02:00
|
|
|
void InspectorUi::disableLivePreview()
|
2010-07-30 15:28:05 +02:00
|
|
|
{
|
|
|
|
|
setApplyChangesToQmlObserver(false);
|
|
|
|
|
}
|
2010-08-13 14:18:10 +02:00
|
|
|
|
|
|
|
|
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_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool)));
|
|
|
|
|
connect(m_toolbar, SIGNAL(reloadSelected()), m_clientProxy, SLOT(reloadQmlViewer()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(animationSpeedChanged(qreal)), m_clientProxy, SLOT(setAnimationSpeed(qreal)));
|
|
|
|
|
connect(m_toolbar, SIGNAL(colorPickerSelected()), m_clientProxy, SLOT(changeToColorPickerTool()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(zoomToolSelected()), m_clientProxy, SLOT(changeToZoomTool()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(selectToolSelected()), m_clientProxy, SLOT(changeToSelectTool()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(marqueeSelectToolSelected()), m_clientProxy, SLOT(changeToSelectMarqueeTool()));
|
|
|
|
|
connect(m_toolbar, SIGNAL(applyChangesFromQmlFileTriggered(bool)), this, SLOT(setApplyChangesToQmlObserver(bool)));
|
|
|
|
|
|
|
|
|
|
connect(this, SIGNAL(livePreviewActivated(bool)), m_toolbar, SLOT(setLivePreviewChecked(bool)));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(colorPickerActivated()), m_toolbar, SLOT(activateColorPicker()));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(selectToolActivated()), m_toolbar, SLOT(activateSelectTool()));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(selectMarqueeToolActivated()), m_toolbar, SLOT(activateMarqueeSelectTool()));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(zoomToolActivated()), m_toolbar, SLOT(activateZoomTool()));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(designModeBehaviorChanged(bool)), m_toolbar, SLOT(setDesignModeBehavior(bool)));
|
|
|
|
|
connect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setSelectedColor(QColor)));
|
|
|
|
|
|
|
|
|
|
connect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(changeAnimationSpeed(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_toolbar, SIGNAL(designModeSelected(bool)), m_clientProxy, SLOT(setDesignModeBehavior(bool)));
|
|
|
|
|
disconnect(m_toolbar, SIGNAL(reloadSelected()), m_clientProxy, SLOT(reloadQmlViewer()));
|
|
|
|
|
disconnect(m_toolbar, SIGNAL(animationSpeedChanged(qreal)), m_clientProxy, SLOT(setAnimationSpeed(qreal)));
|
|
|
|
|
disconnect(m_toolbar, SIGNAL(colorPickerSelected()), m_clientProxy, SLOT(changeToColorPickerTool()));
|
|
|
|
|
disconnect(m_toolbar, SIGNAL(zoomToolSelected()), m_clientProxy, SLOT(changeToZoomTool()));
|
|
|
|
|
disconnect(m_toolbar, SIGNAL(selectToolSelected()), m_clientProxy, SLOT(changeToSelectTool()));
|
|
|
|
|
disconnect(m_toolbar, SIGNAL(marqueeSelectToolSelected()), m_clientProxy, SLOT(changeToSelectMarqueeTool()));
|
|
|
|
|
disconnect(m_toolbar, SIGNAL(applyChangesFromQmlFileTriggered(bool)), this, SLOT(setApplyChangesToQmlObserver(bool)));
|
|
|
|
|
|
|
|
|
|
disconnect(this, SIGNAL(livePreviewActivated(bool)), m_toolbar, SLOT(setLivePreviewChecked(bool)));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(colorPickerActivated()), m_toolbar, SLOT(activateColorPicker()));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(selectToolActivated()), m_toolbar, SLOT(activateSelectTool()));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(selectMarqueeToolActivated()), m_toolbar, SLOT(activateMarqueeSelectTool()));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(zoomToolActivated()), m_toolbar, SLOT(activateZoomTool()));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(designModeBehaviorChanged(bool)), m_toolbar, SLOT(setDesignModeBehavior(bool)));
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(selectedColorChanged(QColor)), m_toolbar, SLOT(setSelectedColor(QColor)));
|
|
|
|
|
|
|
|
|
|
disconnect(m_clientProxy, SIGNAL(animationSpeedChanged(qreal)), m_toolbar, SLOT(changeAnimationSpeed(qreal)));
|
|
|
|
|
m_toolbar->disable();
|
|
|
|
|
}
|
|
|
|
|
}
|