From af3f10dfdd91b070512bdc8abda954bbb29396dc Mon Sep 17 00:00:00 2001 From: Lasse Holmstedt <lasse.holmstedt@nokia.com> Date: Tue, 13 Apr 2010 15:15:02 +0200 Subject: [PATCH] Fixed auto-switching issues with QML inspector and c++ debugger Reviewed-by: hjk --- src/plugins/debugger/debuggerplugin.cpp | 14 ++++++++++- src/plugins/qmlinspector/qmlinspector.cpp | 4 +++- .../qmlinspector/qmlinspectorplugin.cpp | 24 +++++++------------ src/plugins/qmlinspector/qmlinspectorplugin.h | 1 - 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp index 13c2add30da..7f93ba2f3e3 100644 --- a/src/plugins/debugger/debuggerplugin.cpp +++ b/src/plugins/debugger/debuggerplugin.cpp @@ -1340,6 +1340,16 @@ void DebuggerPlugin::readSettings() DebuggerSettings::instance()->readSettings(s); } +static bool isCurrentProjectCppBased() +{ + ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); + Project *startupProject = projectExplorer->startupProject(); + const QStringList cppProjectIds = QStringList() << QLatin1String("GenericProjectManager.GenericProject") + << QLatin1String("CMakeProjectManager.CMakeProject") + << QLatin1String("Qt4ProjectManager.Qt4Project"); + return (startupProject && cppProjectIds.contains(startupProject->id())); +} + void DebuggerPlugin::onModeChanged(IMode *mode) { // FIXME: This one gets always called, even if switching between modes @@ -1353,12 +1363,14 @@ void DebuggerPlugin::onModeChanged(IMode *mode) if (editorManager->currentEditor()) { editorManager->currentEditor()->widget()->setFocus(); - if (editorManager->currentEditor()->id() == CppEditor::Constants::C_CPPEDITOR) + if (isCurrentProjectCppBased()) m_uiSwitcher->setActiveLanguage(LANG_CPP); } } + + void DebuggerPlugin::showSettingsDialog() { Core::ICore::instance()->showOptionsDialog( diff --git a/src/plugins/qmlinspector/qmlinspector.cpp b/src/plugins/qmlinspector/qmlinspector.cpp index 95299a3d5ec..9a22e7c31f6 100644 --- a/src/plugins/qmlinspector/qmlinspector.cpp +++ b/src/plugins/qmlinspector/qmlinspector.cpp @@ -193,12 +193,14 @@ bool QmlInspector::connectToViewer() m_conn = 0; } - ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::instance()->currentProject(); + ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); if (!project) { emit statusMessage(tr("No active project, debugging canceled.")); return false; } + // FIXME if we have c++ project with qml files in it, it would make sense to be able to start + // the qml inspector simultaneously for that project. however, now it's not possible. QmlProjectManager::QmlProjectRunConfiguration* config = qobject_cast<QmlProjectManager::QmlProjectRunConfiguration*>(project->activeTarget()->activeRunConfiguration()); if (!config) { diff --git a/src/plugins/qmlinspector/qmlinspectorplugin.cpp b/src/plugins/qmlinspector/qmlinspectorplugin.cpp index 1d8c8414c75..8eb3b18a497 100644 --- a/src/plugins/qmlinspector/qmlinspectorplugin.cpp +++ b/src/plugins/qmlinspector/qmlinspectorplugin.cpp @@ -37,8 +37,7 @@ #include <qmljseditor/qmljseditorconstants.h> #include <coreplugin/modemanager.h> -#include <coreplugin/editormanager/ieditor.h> -#include <coreplugin/editormanager/editormanager.h> +#include <projectexplorer/projectexplorer.h> #include <extensionsystem/pluginmanager.h> #include <coreplugin/icore.h> @@ -117,7 +116,7 @@ void QmlInspectorPlugin::extensionsInitialized() { ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>(); - //connect(uiSwitcher, SIGNAL(languageChanged(QString)), SLOT(activateDebugger(QString))); + connect(uiSwitcher, SIGNAL(dockArranged(QString)), SLOT(setDockWidgetArrangement(QString))); ProjectExplorer::ProjectExplorerPlugin *pex = ProjectExplorer::ProjectExplorerPlugin::instance(); @@ -143,18 +142,13 @@ void QmlInspectorPlugin::extensionsInitialized() uiSwitcher->setToolbar(Qml::Constants::LANG_QML, configBar); } -void QmlInspectorPlugin::activateDebugger(const QString &langName) -{ - if (langName == Qml::Constants::LANG_QML) { - m_inspector->connectToViewer(); - } -} - void QmlInspectorPlugin::activateDebuggerForProject(ProjectExplorer::Project *project, const QString &runMode) { if (runMode == ProjectExplorer::Constants::DEBUGMODE) { - QmlProjectManager::QmlProject *qmlproj = qobject_cast<QmlProjectManager::QmlProject*>(project); - if (qmlproj) + // FIXME we probably want to activate the debugger for other projects than QmlProjects, + // if they contain Qml files. Some kind of options should exist for this behavior. + //QmlProjectManager::QmlProject *qmlproj = qobject_cast<QmlProjectManager::QmlProject*>(project); + //if (qmlproj) m_connectionTimer->start(); } @@ -180,10 +174,10 @@ void QmlInspectorPlugin::prepareDebugger(Core::IMode *mode) if (mode->id() != Debugger::Constants::MODE_DEBUG) return; - Core::EditorManager *editorManager = Core::EditorManager::instance(); + ProjectExplorer::ProjectExplorerPlugin *pex = ProjectExplorer::ProjectExplorerPlugin::instance(); - if (editorManager->currentEditor() && - editorManager->currentEditor()->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) { + if (pex->startupProject() && pex->startupProject()->id() == "QmlProjectManager.QmlProject") + { ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance(); Debugger::DebuggerUISwitcher *uiSwitcher = pluginManager->getObject<Debugger::DebuggerUISwitcher>(); uiSwitcher->setActiveLanguage(Qml::Constants::LANG_QML); diff --git a/src/plugins/qmlinspector/qmlinspectorplugin.h b/src/plugins/qmlinspector/qmlinspectorplugin.h index 9a592156f50..3db22835ae7 100644 --- a/src/plugins/qmlinspector/qmlinspectorplugin.h +++ b/src/plugins/qmlinspector/qmlinspectorplugin.h @@ -63,7 +63,6 @@ public: virtual void shutdown(); public slots: - void activateDebugger(const QString &langName); void activateDebuggerForProject(ProjectExplorer::Project *project, const QString &runMode); void setDockWidgetArrangement(const QString &activeLanguage); -- GitLab