diff options
4 files changed, 82 insertions, 3 deletions
diff --git a/src/plugins/qmldesigner/QmlDesigner.pluginspec.in b/src/plugins/qmldesigner/QmlDesigner.pluginspec.in index 7259c9f6f8..8c0f3c1d36 100644 --- a/src/plugins/qmldesigner/QmlDesigner.pluginspec.in +++ b/src/plugins/qmldesigner/QmlDesigner.pluginspec.in @@ -23,5 +23,8 @@ will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.</license> <dependency name=\"Core\" version=\"$$QTCREATOR_VERSION\"/> <dependency name=\"TextEditor\" version=\"$$QTCREATOR_VERSION\"/> <dependency name=\"QmlJSEditor\" version=\"$$QTCREATOR_VERSION\"/> + <dependency name=\"QmlProjectManager\" version=\"$$QTCREATOR_VERSION\"/> + <dependency name=\"Qt4ProjectManager\" version=\"$$QTCREATOR_VERSION\"/> + <dependency name=\"ProjectExplorer\" version=\"$$QTCREATOR_VERSION\"/> </dependencyList> </plugin> diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp index 11f4ddee1b..65f0a9a12f 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.cpp @@ -81,6 +81,13 @@ #include <QtGui/QPlainTextEdit> #include <QtGui/QApplication> +#include <projectexplorer/projectexplorer.h> +#include <qt4projectmanager/qt4project.h> +#include <qt4projectmanager/qt4target.h> +#include <qtsupport/qtversionmanager.h> +#include <qt4projectmanager/qt4projectmanagerconstants.h> +#include <qmlprojectmanager/qmlprojectrunconfiguration.h> + enum { debug = false }; @@ -113,7 +120,7 @@ public: QUrl searchPath; bool documentLoaded; bool syncBlocked; - + int qt_versionId; }; /** @@ -128,6 +135,10 @@ DesignDocumentController::DesignDocumentController(QObject *parent) : { m_d->documentLoaded = false; m_d->syncBlocked = false; + + ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); + connect(projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), this, SLOT(activeQtVersionChanged())); + activeQtVersionChanged(); } DesignDocumentController::~DesignDocumentController() @@ -162,9 +173,9 @@ void DesignDocumentController::detachNodeInstanceView() void DesignDocumentController::attachNodeInstanceView() { - if (m_d->nodeInstanceView) + if (m_d->nodeInstanceView) { model()->attachView(m_d->nodeInstanceView.data()); - + } } QWidget *DesignDocumentController::centralWidget() const @@ -172,6 +183,14 @@ QWidget *DesignDocumentController::centralWidget() const return qobject_cast<QWidget*>(parent()); } +QString DesignDocumentController::pathToQt() const +{ + QtSupport::BaseQtVersion *activeQtVersion = QtSupport::QtVersionManager::instance()->version(m_d->qt_versionId); + if (activeQtVersion && (activeQtVersion->qtVersion().majorVersion > 3) && (activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::QT_SIMULATOR_TARGET_ID) || activeQtVersion->supportsTargetId(Qt4ProjectManager::Constants::DESKTOP_TARGET_ID))) + return activeQtVersion->versionInfo().value("QT_INSTALL_DATA"); + return QString(); +} + /*! Returns whether the model is automatically updated if the text editor changes. */ @@ -199,6 +218,7 @@ void DesignDocumentController::blockModelSync(bool block) detachNodeInstanceView(); m_d->textModifier->deactivateChangeSignals(); } else { + activeQtVersionChanged(); QmlModelState state; //We go back to base state (and back again) to avoid side effects from text editing. if (m_d->statesEditorView && m_d->statesEditorView->model()) { @@ -756,6 +776,56 @@ void DesignDocumentController::redo() m_d->textEdit->redo(); } +static inline QtSupport::BaseQtVersion *getActiveQtVersion(DesignDocumentController *controller) +{ + ProjectExplorer::ProjectExplorerPlugin *projectExplorer = ProjectExplorer::ProjectExplorerPlugin::instance(); + ProjectExplorer::Project *currentProject = projectExplorer->currentProject(); + + if (!currentProject) + return 0; + + controller->disconnect(controller, SLOT(activeQtVersionChanged())); + controller->connect(projectExplorer, SIGNAL(currentProjectChanged(ProjectExplorer::Project*)), controller, SLOT(activeQtVersionChanged())); + + controller->connect(currentProject, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)), controller, SLOT(activeQtVersionChanged())); + + + ProjectExplorer::Target *target = currentProject->activeTarget(); + + if (!target) + return 0; + + ProjectExplorer::RunConfiguration *runConfiguration = target->activeRunConfiguration(); + QmlProjectManager::QmlProjectRunConfiguration *qmlRunConfiguration = qobject_cast<QmlProjectManager::QmlProjectRunConfiguration* >(runConfiguration); + + if (qmlRunConfiguration) { + controller->connect(target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)), controller, SLOT(activeQtVersionChanged())); + return qmlRunConfiguration->qtVersion(); + } + + Qt4ProjectManager::Qt4BuildConfiguration *activeBuildConfiguration = qobject_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(target->activeBuildConfiguration()); + + if (activeBuildConfiguration) { + controller->connect(target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)), controller, SLOT(activeQtVersionChanged())); + return activeBuildConfiguration->qtVersion(); + } + + return 0; +} + +void DesignDocumentController::activeQtVersionChanged() +{ + QtSupport::BaseQtVersion *newQtVersion = getActiveQtVersion(this); + + if (!newQtVersion ) { + m_d->qt_versionId = -1; + return; + } + + m_d->qt_versionId = newQtVersion->uniqueId(); + +} + #ifdef ENABLE_TEXT_VIEW void DesignDocumentController::showText() { diff --git a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h index 15601b56d7..616a9e351b 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h +++ b/src/plugins/qmldesigner/components/integration/designdocumentcontroller.h @@ -122,6 +122,7 @@ public slots: void selectAll(); void undo(); void redo(); + void activeQtVersionChanged(); #ifdef ENABLE_TEXT_VIEW void showText(); @@ -136,6 +137,8 @@ private: void detachNodeInstanceView(); void attachNodeInstanceView(); QWidget *centralWidget() const; + QString pathToQt() const; + class DesignDocumentControllerPrivate *m_d; }; diff --git a/src/plugins/qmldesigner/qmldesigner_dependencies.pri b/src/plugins/qmldesigner/qmldesigner_dependencies.pri index b7219a7d8e..52e2603a22 100644 --- a/src/plugins/qmldesigner/qmldesigner_dependencies.pri +++ b/src/plugins/qmldesigner/qmldesigner_dependencies.pri @@ -4,3 +4,6 @@ include(../../libs/qmleditorwidgets/qmleditorwidgets.pri) include(../coreplugin/coreplugin.pri) include(../texteditor/texteditor.pri) include(../qmljseditor/qmljseditor.pri) +include(../qt4projectmanager/qt4projectmanager.pri) +include(../qmlprojectmanager/qmlprojectmanager.pri) +include(../projectexplorer/projectexplorer.pri) |