From 4231a88b67abe9ce2bfcffedc589a262c230d642 Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Wed, 6 Jan 2021 16:12:01 +0100 Subject: [PATCH] ProjectExplorer: Add more variables for active project Fixes: QTCREATORBUG-25206 Change-Id: I3826824de73ef15138e037a7134592e4aa13130f Reviewed-by: Eike Ziller --- .../projectexplorer/projectexplorer.cpp | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 16970638495..10e18d89e0c 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -328,10 +328,15 @@ static BuildConfiguration *currentBuildConfiguration() return target ? target->activeBuildConfiguration() : nullptr; } -static BuildConfiguration *activeBuildConfiguration() +static Target *activeTarget() { const Project * const project = SessionManager::startupProject(); - const Target * const target = project ? project->activeTarget() : nullptr; + return project ? project->activeTarget() : nullptr; +} + +static BuildConfiguration *activeBuildConfiguration() +{ + const Target * const target = activeTarget(); return target ? target->activeBuildConfiguration() : nullptr; } @@ -1823,6 +1828,20 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er return project->projectFilePath().toString(); return {}; }); + expander->registerVariable("ActiveProject:Kit:Name", + "The name of the active project's active kit.", // TODO: tr() + []() -> QString { + if (const Target * const target = activeTarget()) + return target->kit()->displayName(); + return {}; + }); + expander->registerVariable("ActiveProject:BuildConfig:Name", + "The name of the active project's active build configuration.", // TODO: tr() + []() -> QString { + if (const BuildConfiguration * const bc = activeBuildConfiguration()) + return bc->displayName(); + return {}; + }); expander->registerVariable("ActiveProject:BuildConfig:Type", tr("The type of the active project's active build configuration."), []() -> QString {