diff options
author | Tobias Hunger <tobias.hunger@digia.com> | 2012-10-25 16:50:13 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@digia.com> | 2012-10-25 17:33:44 +0200 |
commit | 3c9874200ce67938a4b1621770bf444fd897a1f7 (patch) | |
tree | e33920ce80381b4167936f1e3df9edd1936c8b19 /src/plugins | |
parent | c2c58fecd7adf6bf42f73559ef20e5f500b982e1 (diff) | |
download | qt-creator-3c9874200ce67938a4b1621770bf444fd897a1f7.tar.gz |
Make Qt-related variables available to all projects
Now that we have kits all projects have access to the Qt version, so
those variables should be available in all those projects.
Change-Id: Ia1cf20816f6e66df46c77f5fc823c06053a54a1f
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/qt4projectmanager/qt4projectmanager.cpp | 34 | ||||
-rw-r--r-- | src/plugins/qt4projectmanager/qt4projectmanager.h | 1 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtsupportplugin.cpp | 37 | ||||
-rw-r--r-- | src/plugins/qtsupport/qtsupportplugin.h | 2 |
4 files changed, 39 insertions, 35 deletions
diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.cpp b/src/plugins/qt4projectmanager/qt4projectmanager.cpp index 3bb7066808..b217ac05e3 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.cpp +++ b/src/plugins/qt4projectmanager/qt4projectmanager.cpp @@ -45,7 +45,6 @@ #include <coreplugin/id.h> #include <coreplugin/editormanager/editormanager.h> #include <coreplugin/editormanager/ieditor.h> -#include <coreplugin/variablemanager.h> #include <projectexplorer/projectexplorer.h> #include <projectexplorer/buildmanager.h> #include <projectexplorer/session.h> @@ -76,9 +75,6 @@ using ProjectExplorer::FormType; using ProjectExplorer::ResourceType; using ProjectExplorer::UnknownFileType; -static const char kHostBins[] = "CurrentProject:QT_HOST_BINS"; -static const char kInstallBins[] = "CurrentProject:QT_INSTALL_BINS"; - // Known file types of a Qt 4 project static const char *qt4FileTypes[] = { "CppHeaderFiles", @@ -138,15 +134,6 @@ void Qt4Manager::init() connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)), this, SLOT(editorChanged(Core::IEditor*))); - - Core::VariableManager *vm = Core::VariableManager::instance(); - vm->registerVariable(kHostBins, - tr("Full path to the host bin directory of the current project's Qt version.")); - vm->registerVariable(kInstallBins, - tr("Full path to the target bin directory of the current project's Qt version." - " You probably want %1 instead.").arg(QString::fromLatin1(kHostBins))); - connect(vm, SIGNAL(variableUpdateRequested(QByteArray)), - this, SLOT(updateVariable(QByteArray))); } void Qt4Manager::editorChanged(Core::IEditor *editor) @@ -188,27 +175,6 @@ void Qt4Manager::editorAboutToClose(Core::IEditor *editor) } } -void Qt4Manager::updateVariable(const QByteArray &variable) -{ - if (variable == kHostBins || variable == kInstallBins) { - Qt4Project *qt4pro = qobject_cast<Qt4Project *>(ProjectExplorer::ProjectExplorerPlugin::currentProject()); - if (!qt4pro) { - Core::VariableManager::instance()->remove(variable); - return; - } - QString value; - const QtSupport::BaseQtVersion *qtv = 0; - if (ProjectExplorer::Target *t = qt4pro->activeTarget()) - qtv = QtSupport::QtKitInformation::qtVersion(t->kit()); - else - qtv = QtSupport::QtKitInformation::qtVersion(ProjectExplorer::KitManager::instance()->defaultKit()); - - if (qtv) - value = qtv->qmakeProperty(variable == kHostBins ? "QT_HOST_BINS" : "QT_INSTALL_BINS"); - Core::VariableManager::instance()->insert(variable, value); - } -} - void Qt4Manager::uiEditorContentsChanged() { // cast sender, get filename diff --git a/src/plugins/qt4projectmanager/qt4projectmanager.h b/src/plugins/qt4projectmanager/qt4projectmanager.h index 4c98027e28..63465d77a1 100644 --- a/src/plugins/qt4projectmanager/qt4projectmanager.h +++ b/src/plugins/qt4projectmanager/qt4projectmanager.h @@ -106,7 +106,6 @@ private slots: void editorAboutToClose(Core::IEditor *editor); void uiEditorContentsChanged(); void editorChanged(Core::IEditor*); - void updateVariable(const QByteArray &variable); private: QList<Qt4Project *> m_projects; diff --git a/src/plugins/qtsupport/qtsupportplugin.cpp b/src/plugins/qtsupport/qtsupportplugin.cpp index 1b773d1215..08007f9d45 100644 --- a/src/plugins/qtsupport/qtsupportplugin.cpp +++ b/src/plugins/qtsupport/qtsupportplugin.cpp @@ -38,12 +38,19 @@ #include "gettingstartedwelcomepage.h" +#include <coreplugin/variablemanager.h> #include <extensionsystem/pluginmanager.h> #include <projectexplorer/kitmanager.h> +#include <projectexplorer/project.h> +#include <projectexplorer/projectexplorer.h> +#include <projectexplorer/target.h> #include <QtPlugin> #include <QMenu> +static const char kHostBins[] = "CurrentProject:QT_HOST_BINS"; +static const char kInstallBins[] = "CurrentProject:QT_INSTALL_BINS"; + using namespace QtSupport; using namespace QtSupport::Internal; @@ -81,6 +88,15 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes void QtSupportPlugin::extensionsInitialized() { + Core::VariableManager *vm = Core::VariableManager::instance(); + vm->registerVariable(kHostBins, + tr("Full path to the host bin directory of the current project's Qt version.")); + vm->registerVariable(kInstallBins, + tr("Full path to the target bin directory of the current project's Qt version." + " You probably want %1 instead.").arg(QString::fromLatin1(kHostBins))); + connect(vm, SIGNAL(variableUpdateRequested(QByteArray)), + this, SLOT(updateVariable(QByteArray))); + QtVersionManager::instance()->extensionsInitialized(); ProjectExplorer::KitManager::instance()->registerKitInformation(new QtKitInformation); } @@ -90,4 +106,25 @@ bool QtSupportPlugin::delayedInitialize() return QtVersionManager::instance()->delayedInitialize(); } +void QtSupportPlugin::updateVariable(const QByteArray &variable) +{ + if (variable != kHostBins && variable != kInstallBins) + return; + + ProjectExplorer::Project *project = ProjectExplorer::ProjectExplorerPlugin::currentProject(); + if (!project || !project->activeTarget()) { + Core::VariableManager::instance()->remove(variable); + return; + } + + const BaseQtVersion *qtVersion = QtKitInformation::qtVersion(project->activeTarget()->kit()); + if (!qtVersion) { + Core::VariableManager::instance()->remove(variable); + return; + } + + QString value = qtVersion->qmakeProperty(variable == kHostBins ? "QT_HOST_BINS" : "QT_INSTALL_BINS"); + Core::VariableManager::instance()->insert(variable, value); +} + Q_EXPORT_PLUGIN(QtSupportPlugin) diff --git a/src/plugins/qtsupport/qtsupportplugin.h b/src/plugins/qtsupport/qtsupportplugin.h index b529c5335a..8a5a24eb79 100644 --- a/src/plugins/qtsupport/qtsupportplugin.h +++ b/src/plugins/qtsupport/qtsupportplugin.h @@ -49,6 +49,8 @@ public: bool delayedInitialize(); private slots: + void updateVariable(const QByteArray &variable); + #ifdef WITH_TESTS void testQtOutputParser_data(); void testQtOutputParser(); |