diff --git a/src/plugins/python/pythonkitaspect.cpp b/src/plugins/python/pythonkitaspect.cpp index 17e101b2cfd..4846f12c12d 100644 --- a/src/plugins/python/pythonkitaspect.cpp +++ b/src/plugins/python/pythonkitaspect.cpp @@ -42,6 +42,10 @@ public: PythonKitAspect::setPython(m_kit, m_comboBox->currentData().toString()); }); + connect(PythonSettings::instance(), + &PythonSettings::interpretersChanged, + this, + &PythonKitAspectImpl::refresh); } void makeReadOnly() override @@ -59,6 +63,7 @@ public: m_comboBox->addItem(interpreter.name, interpreter.id); updateComboBox(PythonKitAspect::python(m_kit)); + emit changed(); // we need to emit changed here to update changes in the macro expander } void updateComboBox(const std::optional &python) @@ -146,6 +151,25 @@ public: return {PythonKitAspect::id()}; return {}; } + + void addToMacroExpander(Kit *kit, MacroExpander *expander) const override + { + QTC_ASSERT(kit, return); + expander->registerVariable("Python:Name", + Tr::tr("Name of Python Interpreter"), + [kit]() -> QString { + if (auto python = PythonKitAspect::python(kit)) + return python->name; + return {}; + }); + expander->registerVariable("Python:Path", + Tr::tr("Path to Python Interpreter"), + [kit]() -> QString { + if (auto python = PythonKitAspect::python(kit)) + return python->command.toUserOutput(); + return {}; + }); + } }; std::optional PythonKitAspect::python(const Kit *kit) diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp index 26f6b8de4db..7d0acd72715 100644 --- a/src/plugins/python/pythonsettings.cpp +++ b/src/plugins/python/pythonsettings.cpp @@ -819,7 +819,7 @@ void PythonSettings::addKitsForInterpreter(const Interpreter &interpreter) [interpreter](Kit *k) { k->setAutoDetected(true); k->setAutoDetectionSource("Python"); - k->setUnexpandedDisplayName(interpreter.name); + k->setUnexpandedDisplayName("%{Python:Name}"); setRelevantAspectsToKit(k); PythonKitAspect::setPython(k, interpreter.id); k->setSticky(PythonKitAspect::id(), true);