forked from qt-creator/qt-creator
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:
@@ -45,7 +45,6 @@
|
|||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
#include <coreplugin/editormanager/editormanager.h>
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
#include <coreplugin/variablemanager.h>
|
|
||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/buildmanager.h>
|
#include <projectexplorer/buildmanager.h>
|
||||||
#include <projectexplorer/session.h>
|
#include <projectexplorer/session.h>
|
||||||
@@ -76,9 +75,6 @@ using ProjectExplorer::FormType;
|
|||||||
using ProjectExplorer::ResourceType;
|
using ProjectExplorer::ResourceType;
|
||||||
using ProjectExplorer::UnknownFileType;
|
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
|
// Known file types of a Qt 4 project
|
||||||
static const char *qt4FileTypes[] = {
|
static const char *qt4FileTypes[] = {
|
||||||
"CppHeaderFiles",
|
"CppHeaderFiles",
|
||||||
@@ -138,15 +134,6 @@ void Qt4Manager::init()
|
|||||||
|
|
||||||
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
connect(Core::EditorManager::instance(), SIGNAL(currentEditorChanged(Core::IEditor*)),
|
||||||
this, SLOT(editorChanged(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)
|
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()
|
void Qt4Manager::uiEditorContentsChanged()
|
||||||
{
|
{
|
||||||
// cast sender, get filename
|
// cast sender, get filename
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ private slots:
|
|||||||
void editorAboutToClose(Core::IEditor *editor);
|
void editorAboutToClose(Core::IEditor *editor);
|
||||||
void uiEditorContentsChanged();
|
void uiEditorContentsChanged();
|
||||||
void editorChanged(Core::IEditor*);
|
void editorChanged(Core::IEditor*);
|
||||||
void updateVariable(const QByteArray &variable);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<Qt4Project *> m_projects;
|
QList<Qt4Project *> m_projects;
|
||||||
|
|||||||
@@ -38,12 +38,19 @@
|
|||||||
|
|
||||||
#include "gettingstartedwelcomepage.h"
|
#include "gettingstartedwelcomepage.h"
|
||||||
|
|
||||||
|
#include <coreplugin/variablemanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <projectexplorer/kitmanager.h>
|
#include <projectexplorer/kitmanager.h>
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectexplorer.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
|
||||||
|
static const char kHostBins[] = "CurrentProject:QT_HOST_BINS";
|
||||||
|
static const char kInstallBins[] = "CurrentProject:QT_INSTALL_BINS";
|
||||||
|
|
||||||
using namespace QtSupport;
|
using namespace QtSupport;
|
||||||
using namespace QtSupport::Internal;
|
using namespace QtSupport::Internal;
|
||||||
|
|
||||||
@@ -81,6 +88,15 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes
|
|||||||
|
|
||||||
void QtSupportPlugin::extensionsInitialized()
|
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();
|
QtVersionManager::instance()->extensionsInitialized();
|
||||||
ProjectExplorer::KitManager::instance()->registerKitInformation(new QtKitInformation);
|
ProjectExplorer::KitManager::instance()->registerKitInformation(new QtKitInformation);
|
||||||
}
|
}
|
||||||
@@ -90,4 +106,25 @@ bool QtSupportPlugin::delayedInitialize()
|
|||||||
return QtVersionManager::instance()->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)
|
Q_EXPORT_PLUGIN(QtSupportPlugin)
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ public:
|
|||||||
bool delayedInitialize();
|
bool delayedInitialize();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
void updateVariable(const QByteArray &variable);
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
void testQtOutputParser_data();
|
void testQtOutputParser_data();
|
||||||
void testQtOutputParser();
|
void testQtOutputParser();
|
||||||
|
|||||||
Reference in New Issue
Block a user