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>
This commit is contained in:
Tobias Hunger
2012-10-25 16:50:13 +02:00
parent c2c58fecd7
commit 3c9874200c
4 changed files with 39 additions and 35 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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)

View File

@@ -49,6 +49,8 @@ public:
bool delayedInitialize();
private slots:
void updateVariable(const QByteArray &variable);
#ifdef WITH_TESTS
void testQtOutputParser_data();
void testQtOutputParser();