From 5cf11e2bbdf02ac25338efc028bfd1f3700d0f8a Mon Sep 17 00:00:00 2001 From: Aurindam Jana <aurindam.jana@digia.com> Date: Wed, 21 Nov 2012 16:18:53 +0100 Subject: [PATCH] Qml Debugging: Default option for Qt Quick application Qt Quick applications should have Qml Debugging enabled by default. Task-number: QTCREATORBUG-8208 Change-Id: I794249567b15071098f0ac8ba5f2a8e5f2be4ffb Reviewed-by: hjk <hjk121@nokiamail.com> --- .../autotoolsproject.cpp | 2 +- .../cmakeprojectmanager/cmakeproject.cpp | 2 +- .../genericprojectmanager/genericproject.cpp | 2 +- src/plugins/projectexplorer/project.cpp | 10 +++++----- src/plugins/projectexplorer/project.h | 4 ++-- .../projectexplorer/projectexplorer.cpp | 4 ++-- .../projectexplorer/runconfiguration.cpp | 16 ++-------------- src/plugins/qmlprojectmanager/qmlproject.cpp | 2 +- src/plugins/qt4projectmanager/qt4project.cpp | 19 ++++++++++++++++++- 9 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp index a9f7332107e..8d938a4ab22 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp @@ -76,7 +76,7 @@ AutotoolsProject::AutotoolsProject(AutotoolsManager *manager, const QString &fil m_makefileParserThread(0) { setProjectContext(Core::Context(Constants::PROJECT_CONTEXT)); - setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX)); + setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); const QFileInfo fileInfo(m_fileName); m_projectName = fileInfo.absoluteDir().dirName(); diff --git a/src/plugins/cmakeprojectmanager/cmakeproject.cpp b/src/plugins/cmakeprojectmanager/cmakeproject.cpp index 13085b37ce3..da8094327f0 100644 --- a/src/plugins/cmakeprojectmanager/cmakeproject.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeproject.cpp @@ -110,7 +110,7 @@ CMakeProject::CMakeProject(CMakeManager *manager, const QString &fileName) m_lastEditor(0) { setProjectContext(Core::Context(CMakeProjectManager::Constants::PROJECTCONTEXT)); - setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX)); + setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); m_file = new CMakeFile(this, fileName); diff --git a/src/plugins/genericprojectmanager/genericproject.cpp b/src/plugins/genericprojectmanager/genericproject.cpp index a1853024de9..6b77b46d573 100644 --- a/src/plugins/genericprojectmanager/genericproject.cpp +++ b/src/plugins/genericprojectmanager/genericproject.cpp @@ -70,7 +70,7 @@ GenericProject::GenericProject(Manager *manager, const QString &fileName) m_fileName(fileName) { setProjectContext(Context(GenericProjectManager::Constants::PROJECTCONTEXT)); - setProjectLanguage(Context(ProjectExplorer::Constants::LANG_CXX)); + setProjectLanguages(Context(ProjectExplorer::Constants::LANG_CXX)); QFileInfo fileInfo(m_fileName); QDir dir = fileInfo.dir(); diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp index faefbc44a7b..d3ca4925dce 100644 --- a/src/plugins/projectexplorer/project.cpp +++ b/src/plugins/projectexplorer/project.cpp @@ -92,7 +92,7 @@ public: Target *m_activeTarget; EditorConfiguration *m_editorConfiguration; Core::Context m_projectContext; - Core::Context m_projectLanguage; + Core::Context m_projectLanguages; QVariantMap m_pluginSettings; SettingsAccessor *m_accessor; }; @@ -400,9 +400,9 @@ void Project::setProjectContext(Core::Context context) d->m_projectContext = context; } -void Project::setProjectLanguage(Core::Context language) +void Project::setProjectLanguages(Core::Context language) { - d->m_projectLanguage = language; + d->m_projectLanguages = language; } Core::Context Project::projectContext() const @@ -410,9 +410,9 @@ Core::Context Project::projectContext() const return d->m_projectContext; } -Core::Context Project::projectLanguage() const +Core::Context Project::projectLanguages() const { - return d->m_projectLanguage; + return d->m_projectLanguages; } QVariant Project::namedSettings(const QString &name) const diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index a1cb6419f51..2795b62d68a 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -114,7 +114,7 @@ public: static QString projectDirectory(const QString &top); virtual Core::Context projectContext() const; - virtual Core::Context projectLanguage() const; + virtual Core::Context projectLanguages() const; QVariant namedSettings(const QString &name) const; void setNamedSettings(const QString &name, const QVariant &value); @@ -148,7 +148,7 @@ protected: virtual bool setupTarget(Target *t); virtual void setProjectContext(Core::Context context); - virtual void setProjectLanguage(Core::Context language); + virtual void setProjectLanguages(Core::Context language); private slots: void changeEnvironment(); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 47f28445879..105e806996c 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -1809,11 +1809,11 @@ void ProjectExplorerPlugin::setCurrent(Project *project, QString filePath, Node if (d->m_currentProject) { oldContext.add(d->m_currentProject->projectContext()); - oldContext.add(d->m_currentProject->projectLanguage()); + oldContext.add(d->m_currentProject->projectLanguages()); } if (project) { newContext.add(project->projectContext()); - newContext.add(project->projectLanguage()); + newContext.add(project->projectLanguages()); } Core::ICore::updateAdditionalContexts(oldContext, newContext); diff --git a/src/plugins/projectexplorer/runconfiguration.cpp b/src/plugins/projectexplorer/runconfiguration.cpp index aaf3d08e482..99ea22ef1fe 100644 --- a/src/plugins/projectexplorer/runconfiguration.cpp +++ b/src/plugins/projectexplorer/runconfiguration.cpp @@ -157,23 +157,11 @@ bool DebuggerRunConfigurationAspect::useCppDebugger() const return m_useCppDebugger; } -static bool isQtQuickAppProject(Project *project) -{ - const QString projectDirectory = project->projectDirectory(); - // Qt Quick 1 wizard generated file - const QString qq1FilePath = projectDirectory - + QLatin1String("/qmlapplicationviewer/qmlapplicationviewer.pri"); - // Qt Quick 2 wizard generated file - const QString qq2FilePath = projectDirectory - + QLatin1String("/qtquick2applicationviewer/qtquick2applicationviewer.pri"); - const QStringList projectFiles = project->files(Project::ExcludeGeneratedFiles); - return projectFiles.contains(qq1FilePath) || projectFiles.contains(qq2FilePath); -} - bool DebuggerRunConfigurationAspect::useQmlDebugger() const { if (m_useQmlDebugger == DebuggerRunConfigurationAspect::AutoEnableQmlDebugger) - return isQtQuickAppProject(m_runConfiguration->target()->project()); + return m_runConfiguration->target()->project()->projectLanguages().contains( + ProjectExplorer::Constants::LANG_QMLJS); return m_useQmlDebugger == DebuggerRunConfigurationAspect::EnableQmlDebugger; } diff --git a/src/plugins/qmlprojectmanager/qmlproject.cpp b/src/plugins/qmlprojectmanager/qmlproject.cpp index fdaabe37d4c..7b0377d21af 100644 --- a/src/plugins/qmlprojectmanager/qmlproject.cpp +++ b/src/plugins/qmlprojectmanager/qmlproject.cpp @@ -64,7 +64,7 @@ QmlProject::QmlProject(Internal::Manager *manager, const QString &fileName) m_modelManager(QmlJS::ModelManagerInterface::instance()) { setProjectContext(Core::Context(QmlProjectManager::Constants::PROJECTCONTEXT)); - setProjectLanguage(Core::Context(QmlProjectManager::Constants::LANG_QML)); + setProjectLanguages(Core::Context(QmlProjectManager::Constants::LANG_QML)); QFileInfo fileInfo(m_fileName); m_projectName = fileInfo.completeBaseName(); diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 1945f54ebc5..2a630f96769 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -348,7 +348,7 @@ Qt4Project::Qt4Project(Qt4Manager *manager, const QString& fileName) : m_activeTarget(0) { setProjectContext(Core::Context(Qt4ProjectManager::Constants::PROJECT_ID)); - setProjectLanguage(Core::Context(ProjectExplorer::Constants::LANG_CXX)); + setProjectLanguages(Core::Context(ProjectExplorer::Constants::LANG_CXX)); m_asyncUpdateTimer.setSingleShot(true); m_asyncUpdateTimer.setInterval(3000); @@ -599,10 +599,27 @@ void Qt4Project::updateQmlJSCodeModel() QList<Qt4ProFileNode *> proFiles = findQt4ProFiles(rootProjectNode()); projectInfo.importPaths.clear(); + + bool hasQmlLib = false; foreach (Qt4ProFileNode *node, proFiles) { projectInfo.importPaths.append(node->variableValue(QmlImportPathVar)); + if (!hasQmlLib) { + QStringList qtLibs = node->variableValue(QtVar); + hasQmlLib = qtLibs.contains(QLatin1String("declarative")) || + qtLibs.contains(QLatin1String("qml")) || + qtLibs.contains(QLatin1String("quick")); + } } + // If the project directory has a pro/pri file that includes a qml or quick or declarative + // library then chances of the project being a QML project is quite high. + // This assumption fails when there are no QDeclarativeEngine/QDeclarativeView (QtQuick 1) + // or QQmlEngine/QQuickView (QtQuick 2) instances. + Core::Context pl(ProjectExplorer::Constants::LANG_CXX); + if (projectInfo.sourceFiles.count() && hasQmlLib) + pl.add(ProjectExplorer::Constants::LANG_QMLJS); + setProjectLanguages(pl); + bool preferDebugDump = false; projectInfo.tryQmlDump = false; -- GitLab