diff options
author | Lasse Holmstedt <lasse.holmstedt@nokia.com> | 2010-09-27 17:22:57 +0200 |
---|---|---|
committer | Lasse Holmstedt <lasse.holmstedt@nokia.com> | 2010-09-29 09:39:30 +0200 |
commit | 96d991bbdc34b00b4ba1c3b4f5690f04edfb4cf0 (patch) | |
tree | ba09125bc414c558ad54f1bc2ad391bb0d88779e /src/plugins | |
parent | 5d9858129aa9c11a9b708c3fb1701c3ed9ac9843 (diff) | |
download | qt-creator-96d991bbdc34b00b4ba1c3b4f5690f04edfb4cf0.tar.gz |
QML Observer: Build together on runtime with debugging tools
Moved qmljsdebugger to a dir under qml/, made qmlobserver compile
without creator dependencies and made it compile with debugging
helpers.
Reviewed-by: hjk
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/debugger/debuggerrunner.cpp | 8 | ||||
-rw-r--r-- | src/plugins/projectexplorer/debugginghelper.cpp | 3 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsmodelmanager.cpp | 27 | ||||
-rw-r--r-- | src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp | 50 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qmldumptool.cpp | 14 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qmldumptool.h | 4 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qmlobservertool.cpp | 219 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qmlobservertool.h | 69 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qt4project.cpp | 32 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qt4projectmanager.pro | 6 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qtoptionspage.cpp | 76 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qtoptionspage.h | 4 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qtversionmanager.cpp | 62 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qtversionmanager.h | 7 |
14 files changed, 480 insertions, 101 deletions
diff --git a/src/plugins/debugger/debuggerrunner.cpp b/src/plugins/debugger/debuggerrunner.cpp index 69f739b850..3260775ddc 100644 --- a/src/plugins/debugger/debuggerrunner.cpp +++ b/src/plugins/debugger/debuggerrunner.cpp @@ -380,13 +380,7 @@ void DebuggerRunControl::createEngine(const DebuggerStartParameters &startParams // Figure out engine according to toolchain, executable, attach or default. DebuggerEngineType engineType = NoEngineType; DebuggerLanguages activeLangs = DebuggerPlugin::instance()->activeLanguages(); - /*bool isQmlExecutable = sp.executable.endsWith(_("qmlviewer")) || sp.executable.endsWith(_("qmlobserver")); -#ifdef Q_OS_MAC - isQmlExecutable = sp.executable.endsWith(_("QMLViewer.app")) || sp.executable.endsWith(_("QMLObserver.app")); -#endif - if (isQmlExecutable && sp.startMode != AttachCore) - engineType = QmlEngineType; - else */if (sp.executable.endsWith(_(".js"))) + if (sp.executable.endsWith(_(".js"))) engineType = ScriptEngineType; else if (sp.executable.endsWith(_(".py"))) engineType = PdbEngineType; diff --git a/src/plugins/projectexplorer/debugginghelper.cpp b/src/plugins/projectexplorer/debugginghelper.cpp index 5d65d17707..b006691cae 100644 --- a/src/plugins/projectexplorer/debugginghelper.cpp +++ b/src/plugins/projectexplorer/debugginghelper.cpp @@ -110,7 +110,8 @@ QString DebuggingHelperLibrary::copy(const QString &qtInstallData, errorMessage->clear(); return directory; } - *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2") + *errorMessage = QCoreApplication::translate("ProjectExplorer::DebuggingHelperLibrary", + "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); } diff --git a/src/plugins/qmljseditor/qmljsmodelmanager.cpp b/src/plugins/qmljseditor/qmljsmodelmanager.cpp index 2f3d14387b..f30357ff64 100644 --- a/src/plugins/qmljseditor/qmljsmodelmanager.cpp +++ b/src/plugins/qmljseditor/qmljsmodelmanager.cpp @@ -42,7 +42,6 @@ #include <texteditor/itexteditor.h> #include <projectexplorer/project.h> #include <projectexplorer/projectexplorer.h> -#include <qt4projectmanager/qmldumptool.h> #include <QDir> #include <QFile> @@ -474,25 +473,13 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString & if (m_runningQmldumps.values().contains(canonicalLibraryPath)) return; - // TODO shouldn't be static - instead, if project changes, qmldump should probably change too. - static QString qmldumpPath; - if (qmldumpPath.isNull()) { - - ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); - qmldumpPath = Qt4ProjectManager::QmlDumpTool::qmlDumpToolForProject(activeProject); - // ### no support for .qmlproject projects or cmake projects. - - QFileInfo qmldumpFileInfo(qmldumpPath); - if (!qmldumpFileInfo.exists()) { - qWarning() << "ModelManager::loadQmlPluginTypes: qmldump executable does not exist at" << qmldumpPath; - qmldumpPath.clear(); - } else if (!qmldumpFileInfo.isFile()) { - qWarning() << "ModelManager::loadQmlPluginTypes: " << qmldumpPath << " is not a file"; - qmldumpPath.clear(); - } + ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); + if (!activeProject) + return; - } - if (qmldumpPath.isEmpty()) + ProjectInfo info = projectInfo(activeProject); + + if (info.qmlDumpPath.isEmpty()) return; QProcess *process = new QProcess(this); @@ -501,7 +488,7 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString & QStringList args; args << importPath; args << importUri; - process->start(qmldumpPath, args); + process->start(info.qmlDumpPath, args); m_runningQmldumps.insert(process, canonicalLibraryPath); } diff --git a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp index 3cd103a42d..34c86df699 100644 --- a/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp +++ b/src/plugins/qmlprojectmanager/qmlprojectrunconfiguration.cpp @@ -32,7 +32,6 @@ #include "qmlprojectmanagerconstants.h" #include "qmlprojecttarget.h" #include "projectexplorer/projectexplorer.h" - #include <coreplugin/mimedatabase.h> #include <projectexplorer/buildconfiguration.h> #include <coreplugin/editormanager/editormanager.h> @@ -45,6 +44,7 @@ #include <utils/detailswidget.h> #include <qt4projectmanager/qtversionmanager.h> #include <qt4projectmanager/qt4projectmanagerconstants.h> +#include <qt4projectmanager/qmlobservertool.h> #include <QFormLayout> #include <QComboBox> @@ -371,47 +371,19 @@ QString QmlProjectRunConfiguration::viewerDefaultPath() const { QString path; - // Search for QmlObserver -#ifdef Q_OS_MAC - const QString qmlObserverName = QLatin1String("QMLObserver.app"); -#else - const QString qmlObserverName = QLatin1String("qmlobserver"); -#endif - - QDir appDir(QCoreApplication::applicationDirPath()); - QString qmlObserverPath; -#ifdef Q_OS_WIN - qmlObserverPath = appDir.absoluteFilePath(qmlObserverName + QLatin1String(".exe")); -#else - qmlObserverPath = appDir.absoluteFilePath(qmlObserverName); -#endif - if (QFileInfo(qmlObserverPath).exists()) { - return qmlObserverPath; - } - - // Search for QmlViewer - - // prepend creator/bin dir to search path (only useful for special creator-qml package) - const QString searchPath = QCoreApplication::applicationDirPath() - + Utils::SynchronousProcess::pathSeparator() - + QString::fromLocal8Bit(qgetenv("PATH")); - -#ifdef Q_OS_MAC - const QString qmlViewerName = QLatin1String("QMLViewer"); -#else - const QString qmlViewerName = QLatin1String("qmlviewer"); -#endif - - path = Utils::SynchronousProcess::locateBinary(searchPath, qmlViewerName); - if (!path.isEmpty()) - return path; - // Try to locate default path in Qt Versions Qt4ProjectManager::QtVersionManager *qtVersions = Qt4ProjectManager::QtVersionManager::instance(); foreach (Qt4ProjectManager::QtVersion *version, qtVersions->validVersions()) { - if (!version->qmlviewerCommand().isEmpty() - && version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)) { - return version->qmlviewerCommand(); + if (version->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID)) { + // Search for QmlObserver + + const QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); + path = Qt4ProjectManager::QmlObserverTool::toolByInstallData(qtInstallData); + + if (path.isEmpty() && !version->qmlviewerCommand().isEmpty()) { + path = version->qmlviewerCommand(); + break; + } } } diff --git a/src/plugins/qt4projectmanager/qmldumptool.cpp b/src/plugins/qt4projectmanager/qmldumptool.cpp index 51d340282e..cf60f055f0 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.cpp +++ b/src/plugins/qt4projectmanager/qmldumptool.cpp @@ -55,9 +55,8 @@ bool QmlDumpTool::canBuild(const QString &installHeadersDir) return QFile::exists(qDeclHeader); } -QString QmlDumpTool::qmlDumpToolForProject(ProjectExplorer::Project *project) +QString QmlDumpTool::toolForProject(ProjectExplorer::Project *project) { - qDebug() << "current project:" << project; if (project->id() == Qt4ProjectManager::Constants::QT4PROJECT_ID) { Qt4Project *qt4Project = static_cast<Qt4Project*>(project); if (qt4Project && qt4Project->activeTarget() @@ -65,16 +64,15 @@ QString QmlDumpTool::qmlDumpToolForProject(ProjectExplorer::Project *project) QtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); if (version->isValid()) { QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); - QString toolByInstallData = qmlDumpToolByInstallData(qtInstallData); - qDebug () << toolByInstallData; - return toolByInstallData; + QString toolPath = toolByInstallData(qtInstallData); + return toolPath; } } } return QString(); } -QString QmlDumpTool::qmlDumpToolByInstallData(const QString &qtInstallData) +QString QmlDumpTool::toolByInstallData(const QString &qtInstallData) { if (!Core::ICore::instance()) return QString(); @@ -123,8 +121,8 @@ QString QmlDumpTool::copy(const QString &qtInstallData, QString *errorMessage) errorMessage->clear(); return directory; } - *errorMessage = QCoreApplication::tr("ProjectExplorer::QmlDumpTool", - "The debugger helpers could not be built in any of the directories:\n- %1\n\nReason: %2") + *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlDumpTool", + "qmldump could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); } diff --git a/src/plugins/qt4projectmanager/qmldumptool.h b/src/plugins/qt4projectmanager/qmldumptool.h index d8804c8b4b..5ec3355659 100644 --- a/src/plugins/qt4projectmanager/qmldumptool.h +++ b/src/plugins/qt4projectmanager/qmldumptool.h @@ -47,8 +47,8 @@ class QT4PROJECTMANAGER_EXPORT QmlDumpTool : public Utils::BuildableHelperLibrar { public: static bool canBuild(const QString &installHeadersDir); - static QString qmlDumpToolForProject(ProjectExplorer::Project *project); - static QString qmlDumpToolByInstallData(const QString &qtInstallData); + static QString toolForProject(ProjectExplorer::Project *project); + static QString toolByInstallData(const QString &qtInstallData); static QStringList locationsByInstallData(const QString &qtInstallData); // Build the helpers and return the output log/errormessage. diff --git a/src/plugins/qt4projectmanager/qmlobservertool.cpp b/src/plugins/qt4projectmanager/qmlobservertool.cpp new file mode 100644 index 0000000000..3a64da2ed7 --- /dev/null +++ b/src/plugins/qt4projectmanager/qmlobservertool.cpp @@ -0,0 +1,219 @@ +/************************************************************************** +** +** 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 "qmlobservertool.h" + +#include "qt4project.h" +#include "qt4projectmanagerconstants.h" +#include <coreplugin/icore.h> + +#include <projectexplorer/project.h> +#include <QDesktopServices> +#include <QCoreApplication> +#include <QDir> +#include <QDebug> + +namespace Qt4ProjectManager { + +static inline QStringList validBinaryFilenames() +{ + return QStringList() + << QLatin1String("debug/qmlobserver.exe") + << QLatin1String("qmlobserver.exe") + << QLatin1String("qmlobserver") + << QLatin1String("QMLObserver.app/Contents/MacOS/QMLObserver"); +} + +bool QmlObserverTool::canBuild(const QString &installHeadersDir) +{ + QString qDeclHeader = installHeadersDir + QLatin1String("/QtDeclarative/private/qdeclarativemetatype_p.h"); + return QFile::exists(qDeclHeader); +} + +QString QmlObserverTool::toolForProject(ProjectExplorer::Project *project) +{ + if (project->id() == Qt4ProjectManager::Constants::QT4PROJECT_ID) { + Qt4Project *qt4Project = static_cast<Qt4Project*>(project); + if (qt4Project && qt4Project->activeTarget() + && qt4Project->activeTarget()->activeBuildConfiguration()) { + QtVersion *version = qt4Project->activeTarget()->activeBuildConfiguration()->qtVersion(); + if (version->isValid()) { + QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); + QString toolPath = toolByInstallData(qtInstallData); + return toolPath; + } + } + } + return QString(); +} + +QString QmlObserverTool::toolByInstallData(const QString &qtInstallData) +{ + if (!Core::ICore::instance()) + return QString(); + + const QString mainFilename = Core::ICore::instance()->resourcePath() + + QLatin1String("/qml/qmlobserver/main.cpp"); + const QStringList directories = installDirectories(qtInstallData); + const QStringList binFilenames = validBinaryFilenames(); + + return byInstallDataHelper(mainFilename, directories, binFilenames); +} + +QStringList QmlObserverTool::locationsByInstallData(const QString &qtInstallData) +{ + QStringList result; + QFileInfo fileInfo; + const QStringList binFilenames = validBinaryFilenames(); + foreach(const QString &directory, installDirectories(qtInstallData)) { + if (getHelperFileInfoFor(binFilenames, directory, &fileInfo)) + result << fileInfo.filePath(); + } + return result; +} + +QString QmlObserverTool::build(const QString &directory, const QString &makeCommand, + const QString &qmakeCommand, const QString &mkspec, + const Utils::Environment &env, const QString &targetMode) +{ + return buildHelper(QCoreApplication::tr("QMLObserver"), QLatin1String("qmlobserver.pro"), + directory, makeCommand, qmakeCommand, mkspec, env, targetMode); +} + +static inline bool mkpath(const QString &targetDirectory, QString *errorMessage) +{ + if (!QDir().mkpath(targetDirectory)) { + *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlObserverTool", "The target directory %1 could not be created.").arg(targetDirectory); + return false; + } + return true; +} + +QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessage) +{ + const QStringList directories = QmlObserverTool::installDirectories(qtInstallData); + + QStringList files; + files << QLatin1String("main.cpp") << QLatin1String("qmlobserver.pro") + << QLatin1String("crumblepath.cpp") << QLatin1String("crumblepath.h") + << QLatin1String("deviceorientation.cpp") << QLatin1String("deviceorientation.h") + << QLatin1String("deviceorientation_maemo5.cpp") << QLatin1String("Info_mac.plist") + << QLatin1String("loggerwidget.cpp") << QLatin1String("loggerwidget.h") + << QLatin1String("proxysettings.cpp") << QLatin1String("proxysettings.h") + << QLatin1String("proxysettings.ui") << QLatin1String("proxysettings_maemo5.ui") + << QLatin1String("qdeclarativetester.cpp") << QLatin1String("qdeclarativetester.h") + << QLatin1String("qml.icns") << QLatin1String("qml.pri") + << QLatin1String("qmlruntime.cpp") << QLatin1String("qmlruntime.h") + << QLatin1String("qmlruntime.qrc") << QLatin1String("recopts.ui") + << QLatin1String("recopts_maemo5.ui") + << QLatin1String("texteditautoresizer_maemo5.h") + << QLatin1String("content/Browser.qml") << QLatin1String("content/images/folder.png") + << QLatin1String("content/images/titlebar.png") << QLatin1String("content/images/titlebar.sci") + << QLatin1String("content/images/up.png") + << QLatin1String("LICENSE.LGPL") << QLatin1String("LGPL_EXCEPTION.TXT"); + + QStringList debuggerLibFiles; + debuggerLibFiles << QLatin1String("jsdebuggeragent.cpp") << QLatin1String("private_headers.pri") + << QLatin1String("qdeclarativeobserverservice.cpp") << QLatin1String("qdeclarativeviewobserver.cpp") + << QLatin1String("qdeclarativeviewobserver_p.h") << QLatin1String("qmljsdebugger.pri") + << QLatin1String("qmljsdebugger.pro") << QLatin1String("qmljsdebugger-lib.pri") + << QLatin1String("include/jsdebuggeragent.h") << QLatin1String("include/qdeclarativeobserverservice.h") + << QLatin1String("include/qdeclarativeviewobserver.h") << QLatin1String("include/qmljsdebugger_global.h") + << QLatin1String("include/qmlobserverconstants.h"); + + QStringList debuggerLibEditorFiles; + debuggerLibEditorFiles << QLatin1String("abstractformeditortool.cpp") << QLatin1String("abstractformeditortool.h") + << QLatin1String("boundingrecthighlighter.cpp") << QLatin1String("boundingrecthighlighter.h") + << QLatin1String("colorpickertool.cpp") << QLatin1String("colorpickertool.h") + << QLatin1String("editor.pri") << QLatin1String("editor.qrc") + << QLatin1String("layeritem.cpp") << QLatin1String("layeritem.h") + << QLatin1String("qmltoolbar.cpp") << QLatin1String("qmltoolbar.h") + << QLatin1String("rubberbandselectionmanipulator.cpp") + << QLatin1String("rubberbandselectionmanipulator.h") << QLatin1String("selectionindicator.cpp") + << QLatin1String("selectionindicator.h") << QLatin1String("selectionrectangle.cpp") + << QLatin1String("selectionrectangle.h") << QLatin1String("selectiontool.cpp") + << QLatin1String("selectiontool.h") << QLatin1String("singleselectionmanipulator.cpp") + << QLatin1String("singleselectionmanipulator.h") << QLatin1String("subcomponenteditortool.cpp") + << QLatin1String("subcomponenteditortool.h") << QLatin1String("subcomponentmasklayeritem.cpp") + << QLatin1String("subcomponentmasklayeritem.h") << QLatin1String("toolbarcolorbox.cpp") + << QLatin1String("toolbarcolorbox.h") << QLatin1String("zoomtool.cpp") + << QLatin1String("zoomtool.h") << QLatin1String("images/color-picker.png") + << QLatin1String("images/color-picker-24.png") << QLatin1String("images/color-picker-hicontrast.png") + << QLatin1String("images/from-qml.png") << QLatin1String("images/from-qml-24.png") + << QLatin1String("images/observermode.png") << QLatin1String("images/observermode-24.png") + << QLatin1String("images/pause.png") << QLatin1String("images/pause-24.png") + << QLatin1String("images/play.png") << QLatin1String("images/play-24.png") + << QLatin1String("images/reload.png") << QLatin1String("images/resize_handle.png") + << QLatin1String("images/select.png") << QLatin1String("images/select-24.png") + << QLatin1String("images/select-marquee.png") << QLatin1String("images/select-marquee-24.png") + << QLatin1String("images/to-qml.png") << QLatin1String("images/to-qml-24.png") + << QLatin1String("images/zoom.png") << QLatin1String("images/zoom-24.png"); + + QString sourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmlobserver/"); + QString libSourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmljsdebugger/"); + QString libEditorSourcePath = Core::ICore::instance()->resourcePath() + QLatin1String("/qml/qmljsdebugger/editor/"); + + // Try to find a writeable directory. + foreach(const QString &directory, directories) { + if (!mkpath(directory + QLatin1String("/content/images"), errorMessage) + || !mkpath(directory + QLatin1String("/qmljsdebugger/editor/images"), errorMessage) + || !mkpath(directory + QLatin1String("/qmljsdebugger/include"), errorMessage)) + { + continue; + } else { + errorMessage->clear(); + } + + if (copyFiles(sourcePath, files, directory, errorMessage) + && copyFiles(libSourcePath, debuggerLibFiles, directory + QLatin1String("/qmljsdebugger/"), errorMessage) + && copyFiles(libEditorSourcePath, debuggerLibEditorFiles, directory + QLatin1String("/qmljsdebugger/editor/"), errorMessage)) + { + errorMessage->clear(); + return directory; + } + } + *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlObserverTool", + "QMLObserver could not be built in any of the directories:\n- %1\n\nReason: %2") + .arg(directories.join(QLatin1String("\n- ")), *errorMessage); + return QString(); +} + +QStringList QmlObserverTool::installDirectories(const QString &qtInstallData) +{ + const QChar slash = QLatin1Char('/'); + const uint hash = qHash(qtInstallData); + QStringList directories; + directories + << (qtInstallData + QLatin1String("/qtc-qmlobserver/")) + << QDir::cleanPath((QCoreApplication::applicationDirPath() + QLatin1String("/../qtc-qmlobserver/") + QString::number(hash))) + slash + << (QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/qtc-qmlobserver/") + QString::number(hash)) + slash; + return directories; +} + +} // namespace diff --git a/src/plugins/qt4projectmanager/qmlobservertool.h b/src/plugins/qt4projectmanager/qmlobservertool.h new file mode 100644 index 0000000000..625e625c76 --- /dev/null +++ b/src/plugins/qt4projectmanager/qmlobservertool.h @@ -0,0 +1,69 @@ +/************************************************************************** +** +** 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. +** +**************************************************************************/ + +#ifndef QMLOBSERVERTOOL_H +#define QMLOBSERVERTOOL_H + +#include <utils/buildablehelperlibrary.h> +#include "qt4projectmanager_global.h" + +namespace Utils { + class Environment; +} + +namespace ProjectExplorer { + class Project; +} + +namespace Qt4ProjectManager { + +class QT4PROJECTMANAGER_EXPORT QmlObserverTool : public Utils::BuildableHelperLibrary +{ +public: + static bool canBuild(const QString &installHeadersDir); + static QString toolForProject(ProjectExplorer::Project *project); + static QString toolByInstallData(const QString &qtInstallData); + static QStringList locationsByInstallData(const QString &qtInstallData); + + // Build the helpers and return the output log/errormessage. + static QString build(const QString &directory, const QString &makeCommand, + const QString &qmakeCommand, const QString &mkspec, + const Utils::Environment &env, const QString &targetMode); + + // Copy the source files to a target location and return the chosen target location. + static QString copy(const QString &qtInstallData, QString *errorMessage); + +private: + static QStringList installDirectories(const QString &qtInstallData); + +}; + +} // namespace + +#endif // QMLOBSERVERTOOL_H diff --git a/src/plugins/qt4projectmanager/qt4project.cpp b/src/plugins/qt4projectmanager/qt4project.cpp index 1385f63406..20808d95ab 100644 --- a/src/plugins/qt4projectmanager/qt4project.cpp +++ b/src/plugins/qt4projectmanager/qt4project.cpp @@ -40,6 +40,7 @@ #include "projectloadwizard.h" #include "qt4buildconfiguration.h" #include "findqt4profiles.h" +#include "qmldumptool.h" #include <coreplugin/icore.h> #include <coreplugin/messagemanager.h> @@ -50,6 +51,7 @@ #include <qmljs/qmljsmodelmanagerinterface.h> #include <projectexplorer/buildenvironmentwidget.h> #include <projectexplorer/customexecutablerunconfiguration.h> +#include <projectexplorer/projectexplorer.h> #include <utils/qtcassert.h> #include <QtCore/QDebug> @@ -584,6 +586,36 @@ void Qt4Project::updateQmlJSCodeModel() } projectInfo.importPaths.removeDuplicates(); + + if (projectInfo.qmlDumpPath.isNull()) { + ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject(); + projectInfo.qmlDumpPath = Qt4ProjectManager::QmlDumpTool::toolForProject(activeProject); + + // ### this is needed for qmlproject and cmake project support, but may not work in all cases. + if (projectInfo.qmlDumpPath.isEmpty()) { + // Try to locate default path in Qt Versions + QtVersionManager *qtVersions = QtVersionManager::instance(); + foreach (QtVersion *version, qtVersions->validVersions()) { + if (version->supportsTargetId(Constants::DESKTOP_TARGET_ID)) { + const QString qtInstallData = version->versionInfo().value("QT_INSTALL_DATA"); + projectInfo.qmlDumpPath = QmlDumpTool::toolByInstallData(qtInstallData); + + if (!projectInfo.qmlDumpPath.isEmpty()) { + break; + } + } + } + } + QFileInfo qmldumpFileInfo(projectInfo.qmlDumpPath); + if (!qmldumpFileInfo.exists()) { + qWarning() << "Qt4Project::loadQmlPluginTypes: qmldump executable does not exist at" << projectInfo.qmlDumpPath; + projectInfo.qmlDumpPath.clear(); + } else if (!qmldumpFileInfo.isFile()) { + qWarning() << "Qt4Project::loadQmlPluginTypes: " << projectInfo.qmlDumpPath << " is not a file"; + projectInfo.qmlDumpPath.clear(); + } + } + modelManager->updateProjectInfo(projectInfo); } diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.pro b/src/plugins/qt4projectmanager/qt4projectmanager.pro index 3b84f9653e..e456017ebe 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.pro +++ b/src/plugins/qt4projectmanager/qt4projectmanager.pro @@ -62,7 +62,8 @@ HEADERS += qt4deployconfiguration.h \ librarydetailscontroller.h \ findqt4profiles.h \ qt4projectmanager_global.h \ - qmldumptool.h + qmldumptool.h \ + qmlobservertool.h SOURCES += qt4projectmanagerplugin.cpp \ qt4deployconfiguration.cpp \ qtparser.cpp \ @@ -119,7 +120,8 @@ SOURCES += qt4projectmanagerplugin.cpp \ addlibrarywizard.cpp \ librarydetailscontroller.cpp \ findqt4profiles.cpp \ - qmldumptool.cpp + qmldumptool.cpp \ + qmlobservertool.cpp FORMS += makestep.ui \ qmakestep.ui \ qt4projectconfigwidget.ui \ diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp index d0e0b7d59f..0179867751 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.cpp +++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp @@ -70,10 +70,9 @@ DebuggingHelperBuildTask::~DebuggingHelperBuildTask() void DebuggingHelperBuildTask::run(QFutureInterface<void> &future) { - future.setProgressRange(0, 4); - future.setProgressValue(1); - const QString output = m_version->buildDebuggingHelperLibrary(); + future.setProgressRange(0, 5); future.setProgressValue(1); + const QString output = m_version->buildDebuggingHelperLibrary(future); emit finished(m_version->displayName(), output); deleteLater(); } @@ -145,8 +144,10 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver : QWidget(parent) , m_debuggingHelperOkPixmap(QLatin1String(":/extensionsystem/images/ok.png")) , m_debuggingHelperErrorPixmap(QLatin1String(":/extensionsystem/images/error.png")) + , m_debuggingHelperIntermediatePixmap(QLatin1String(":/extensionsystem/images/notloaded.png")) , m_debuggingHelperOkIcon(m_debuggingHelperOkPixmap) , m_debuggingHelperErrorIcon(m_debuggingHelperErrorPixmap) + , m_debuggingHelperIntermediateIcon(m_debuggingHelperIntermediatePixmap) , m_specifyNameString(tr("<specify a name>")) , m_specifyPathString(tr("<specify a qmake location>")) , m_ui(new Internal::Ui::QtVersionManager()) @@ -190,7 +191,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver item->setData(0, Qt::UserRole, version->uniqueId()); if (version->isValid() && version->supportsBinaryDebuggingHelper()) - item->setData(2, Qt::DecorationRole, version->hasDebuggingHelper() ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon); + item->setData(2, Qt::DecorationRole, debuggerHelperIconForQtVersion(version)); else item->setData(2, Qt::DecorationRole, QIcon()); } @@ -235,6 +236,26 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver updateState(); } +QIcon QtOptionsPageWidget::debuggerHelperIconForQtVersion(const QtVersion *version) +{ + if (version->hasDebuggingHelper() && version->hasQmlDump() && version->hasQmlObserver()) { + return m_debuggingHelperOkIcon; + } else if (!version->hasDebuggingHelper() && !version->hasQmlDump() && !version->hasQmlObserver()) { + return m_debuggingHelperErrorIcon; + } + return m_debuggingHelperIntermediateIcon; +} + +QPixmap QtOptionsPageWidget::debuggerHelperPixmapForQtVersion(const QtVersion *version) +{ + if (version->hasDebuggingHelper() && version->hasQmlDump() && version->hasQmlObserver()) { + return m_debuggingHelperOkPixmap; + } else if (!version->hasDebuggingHelper() && !version->hasQmlDump() && !version->hasQmlObserver()) { + return m_debuggingHelperErrorPixmap; + } + return m_debuggingHelperIntermediatePixmap; +} + bool QtOptionsPageWidget::eventFilter(QObject *o, QEvent *e) { // Set the items tooltip, which may cause costly initialization @@ -289,8 +310,9 @@ void QtOptionsPageWidget::debuggingHelperBuildFinished(const QString &name, cons QTreeWidgetItem *item = treeItemForIndex(index); QTC_ASSERT(item, return) item->setData(2, Qt::UserRole, output); - const bool success = m_versions.at(index)->hasDebuggingHelper(); - item->setData(2, Qt::DecorationRole, success ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon); + QSharedPointerQtVersion qtVersion = m_versions.at(index); + const bool success = qtVersion->hasDebuggingHelper() && qtVersion->hasQmlDump() && qtVersion->hasQmlObserver(); + item->setData(2, Qt::DecorationRole, debuggerHelperIconForQtVersion(qtVersion.data())); // Update bottom control if the selection is still the same if (index == currentIndex()) { @@ -373,15 +395,35 @@ void QtOptionsPageWidget::removeQtDir() } // Format html table tooltip about helpers -static inline QString msgHtmlHelperToolTip(const QFileInfo &fi) +static inline QString msgHtmlHelperToolTip(const QString &gdbHelperPath, const QString &qmlDumpPath, const QString &qmlObserverPath) { + QFileInfo gdbHelperFI(gdbHelperPath); + QFileInfo qmlDumpFI(qmlDumpPath); + QFileInfo qmlObserverFI(qmlObserverPath); + + QString notFound = QtOptionsPageWidget::tr("Binary not found"); + //: Tooltip showing the debugging helper library file. return QtOptionsPageWidget::tr("<html><body><table><tr><td>File:</td><td><pre>%1</pre></td></tr>" "<tr><td>Last modified:</td><td>%2</td></tr>" - "<tr><td>Size:</td><td>%3 Bytes</td></tr></table></body></html>"). - arg(QDir::toNativeSeparators(fi.absoluteFilePath())). - arg(fi.lastModified().toString(Qt::SystemLocaleLongDate)). - arg(fi.size()); + "<tr><td>Size:</td><td>%3 Bytes</td></tr>" + "<tr><td>File:</td><td><pre>%4</pre></td></tr>" + "<tr><td>Last modified:</td><td>%5</td></tr>" + "<tr><td>Size:</td><td>%6 Bytes</td></tr>" + "<tr><td>File:</td><td><pre>%7</pre></td></tr>" + "<tr><td>Last modified:</td><td>%8</td></tr>" + "<tr><td>Size:</td><td>%9 Bytes</td></tr>" + "</table></body></html>" + ). + arg(gdbHelperPath.isEmpty() ? notFound : QDir::toNativeSeparators(gdbHelperFI.absoluteFilePath())). + arg(gdbHelperFI.lastModified().toString(Qt::SystemLocaleLongDate)). + arg(gdbHelperFI.size()). + arg(qmlDumpPath.isEmpty() ? notFound : QDir::toNativeSeparators(qmlDumpFI.absoluteFilePath())). + arg(qmlDumpFI.lastModified().toString(Qt::SystemLocaleLongDate)). + arg(qmlDumpFI.size()). + arg(qmlObserverPath.isEmpty() ? notFound : QDir::toNativeSeparators(qmlObserverFI.absoluteFilePath())). + arg(qmlObserverFI.lastModified().toString(Qt::SystemLocaleLongDate)). + arg(qmlObserverFI.size()); } // Update the state label with a pixmap and set a tooltip describing @@ -390,10 +432,12 @@ void QtOptionsPageWidget::updateDebuggingHelperStateLabel(const QtVersion *versi { QString tooltip; if (version && version->isValid()) { - const bool hasHelper = version->hasDebuggingHelper(); - m_ui->debuggingHelperStateLabel->setPixmap(hasHelper ? m_debuggingHelperOkPixmap : m_debuggingHelperErrorPixmap); - if (hasHelper) - tooltip = msgHtmlHelperToolTip(QFileInfo(version->debuggingHelperLibrary())); + const bool hasHelpers = version->hasDebuggingHelper() && version->hasQmlDump() && version->hasQmlObserver(); + m_ui->debuggingHelperStateLabel->setPixmap(debuggerHelperPixmapForQtVersion(version)); + if (hasHelpers) + tooltip = msgHtmlHelperToolTip(version->debuggingHelperLibrary(), + version->qmlDumpTool(), + version->qmlObserverTool()); } else { m_ui->debuggingHelperStateLabel->setPixmap(QPixmap()); } @@ -679,7 +723,7 @@ void QtOptionsPageWidget::updateCurrentQMakeLocation() if (version->isValid() && version->supportsBinaryDebuggingHelper()) { const bool hasLog = !currentItem->data(2, Qt::UserRole).toString().isEmpty(); - currentItem->setData(2, Qt::DecorationRole, version->hasDebuggingHelper() ? m_debuggingHelperOkIcon : m_debuggingHelperErrorIcon); + currentItem->setData(2, Qt::DecorationRole, debuggerHelperIconForQtVersion(version)); m_ui->showLogButton->setEnabled(hasLog); m_ui->rebuildButton->setEnabled(true); } else { diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h index 65a3956a3a..293dd32306 100644 --- a/src/plugins/qt4projectmanager/qtoptionspage.h +++ b/src/plugins/qt4projectmanager/qtoptionspage.h @@ -90,11 +90,15 @@ private: QtVersion *currentVersion() const; int currentIndex() const; void updateDebuggingHelperStateLabel(const QtVersion *version = 0); + QIcon debuggerHelperIconForQtVersion(const QtVersion *version); + QPixmap debuggerHelperPixmapForQtVersion(const QtVersion *version); const QPixmap m_debuggingHelperOkPixmap; const QPixmap m_debuggingHelperErrorPixmap; + const QPixmap m_debuggingHelperIntermediatePixmap; const QIcon m_debuggingHelperOkIcon; const QIcon m_debuggingHelperErrorIcon; + const QIcon m_debuggingHelperIntermediateIcon; const QString m_specifyNameString; const QString m_specifyPathString; diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp index e6b8aa93a3..12aeebb035 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.cpp +++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp @@ -37,6 +37,7 @@ #include "qt-s60/s60manager.h" #include "qt-s60/s60projectchecker.h" +#include "qmlobservertool.h" #include "qmldumptool.h" #include <projectexplorer/debugginghelper.h> #include <projectexplorer/projectexplorer.h> @@ -516,6 +517,8 @@ QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, int id, m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -538,6 +541,8 @@ QtVersion::QtVersion(const QString &name, const QString &qmakeCommand, m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -556,6 +561,8 @@ QtVersion::QtVersion(const QString &qmakeCommand, bool isAutodetected, const QSt : m_isAutodetected(isAutodetected), m_autodetectionSource(autodetectionSource), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -574,6 +581,8 @@ QtVersion::QtVersion() : m_id(-1), m_isAutodetected(false), m_hasDebuggingHelper(false), + m_hasQmlDump(false), + m_hasQmlObserver(false), m_toolChainUpToDate(false), m_versionInfoUpToDate(false), m_notInstalled(false), @@ -1126,6 +1135,8 @@ void QtVersion::updateVersionInfo() const m_hasExamples = false; m_hasDocumentation = false; m_hasDebuggingHelper = false; + m_hasQmlDump = false; + m_hasQmlObserver = false; if (!queryQMakeVariables(qmakeCommand(), &m_versionInfo)) return; @@ -1136,7 +1147,8 @@ void QtVersion::updateVersionInfo() const if (!qtInstallData.isEmpty()) { m_hasDebuggingHelper = !DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData).isEmpty(); - m_hasQmlDump = !QmlDumpTool::qmlDumpToolByInstallData(qtInstallData).isEmpty(); + m_hasQmlDump = !QmlDumpTool::toolByInstallData(qtInstallData).isEmpty(); + m_hasQmlObserver = !QmlObserverTool::toolByInstallData(qtInstallData).isEmpty(); } } @@ -1237,6 +1249,7 @@ QString QtVersion::qmlviewerCommand() const { if (!isValid()) return QString(); + if (m_qmlviewerCommand.isNull()) { #ifdef Q_OS_MAC const QString qmlViewerName = QLatin1String("QMLViewer"); @@ -1618,6 +1631,12 @@ bool QtVersion::hasQmlDump() const return m_hasQmlDump; } +bool QtVersion::hasQmlObserver() const +{ + updateVersionInfo(); + return m_hasQmlObserver; +} + QString QtVersion::debuggingHelperLibrary() const { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); @@ -1626,6 +1645,22 @@ QString QtVersion::debuggingHelperLibrary() const return DebuggingHelperLibrary::debuggingHelperLibraryByInstallData(qtInstallData); } +QString QtVersion::qmlDumpTool() const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QString(); + return QmlDumpTool::toolByInstallData(qtInstallData); +} + +QString QtVersion::qmlObserverTool() const +{ + QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); + if (qtInstallData.isEmpty()) + return QString(); + return QmlObserverTool::toolByInstallData(qtInstallData); +} + QStringList QtVersion::debuggingHelperLibraryLocations() const { QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); @@ -1711,7 +1746,7 @@ bool QtVersion::isQt64Bit() const #endif } -QString QtVersion::buildDebuggingHelperLibrary() +QString QtVersion::buildDebuggingHelperLibrary(QFutureInterface<void> &future) { QString qtInstallHeaders = versionInfo().value("QT_INSTALL_HEADERS"); QString qtInstallData = versionInfo().value("QT_INSTALL_DATA"); @@ -1733,18 +1768,35 @@ QString QtVersion::buildDebuggingHelperLibrary() qmakeCommand(), mkspec(), env, (tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String(""))); } + future.setProgressValue(2); + if (QmlDumpTool::canBuild(qtInstallHeaders)) { - QString qmlDumpDirectory = QmlDumpTool::copy(qtInstallData, &output); - if (!qmlDumpDirectory.isEmpty()) { - output += QmlDumpTool::build(qmlDumpDirectory, tc->makeCommand(), + QString toolDirectory = QmlDumpTool::copy(qtInstallData, &output); + if (!toolDirectory.isEmpty()) { + output += QmlDumpTool::build(toolDirectory, tc->makeCommand(), qmakeCommand(), mkspec(), env, (tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String(""))); } } else { output += QCoreApplication::tr("Cannot build qmldump; Qt version must be 4.7.1 or higher."); } + future.setProgressValue(3); + + if (QmlObserverTool::canBuild(qtInstallHeaders)) { + QString toolDirectory = QmlObserverTool::copy(qtInstallData, &output); + if (!toolDirectory.isEmpty()) { + output += QmlObserverTool::build(toolDirectory, tc->makeCommand(), + qmakeCommand(), mkspec(), env, + (tc->type() == ToolChain::GCC_MAEMO ? QLatin1String("-unix") : QLatin1String(""))); + } + } else { + output += QCoreApplication::tr("Cannot build QMLObserver; Qt version must be 4.7.1 or higher."); + } + future.setProgressValue(4); m_hasDebuggingHelper = !debuggingHelperLibrary().isEmpty(); + m_hasQmlDump = !qmlDumpTool().isEmpty(); + m_hasQmlObserver = !qmlObserverTool().isEmpty(); return output; } diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h index c9bbe9d91c..4e9f0ac156 100644 --- a/src/plugins/qt4projectmanager/qtversionmanager.h +++ b/src/plugins/qt4projectmanager/qtversionmanager.h @@ -38,6 +38,7 @@ #include <QtCore/QHash> #include <QtCore/QSet> #include <QtCore/QSharedPointer> +#include <QtCore/QFutureInterface> namespace Qt4ProjectManager { @@ -111,14 +112,17 @@ public: bool hasDebuggingHelper() const; QString debuggingHelperLibrary() const; + QString qmlDumpTool() const; + QString qmlObserverTool() const; QStringList debuggingHelperLibraryLocations() const; bool supportsBinaryDebuggingHelper() const; bool hasQmlDump() const; + bool hasQmlObserver() const; // Builds a debugging library // returns the output of the commands - QString buildDebuggingHelperLibrary(); + QString buildDebuggingHelperLibrary(QFutureInterface<void> &future); bool hasExamples() const; QString examplesPath() const; @@ -172,6 +176,7 @@ private: QString m_autodetectionSource; mutable bool m_hasDebuggingHelper; // controlled by m_versionInfoUpToDate mutable bool m_hasQmlDump; // controlled by m_versionInfoUpToDate + mutable bool m_hasQmlObserver; // controlled by m_versionInfoUpToDate QString m_mwcDirectory; QString m_s60SDKDirectory; |