aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonkitaspect.cpp
diff options
context:
space:
mode:
authorDavid Schulz <david.schulz@qt.io>2023-12-12 14:40:37 +0100
committerDavid Schulz <david.schulz@qt.io>2024-01-10 05:32:23 +0000
commit76b61a799352e4c43863284f9faafcbbb23e0420 (patch)
tree4c5c161fd257696f342ca0d292a752970c2e377d /src/plugins/python/pythonkitaspect.cpp
parent8bfb6dbf35cee611dfddaa6cbdce899fdf1c7051 (diff)
Python: register python infos to the kits macro expander
... and use the name in the autogenerated kits display name Change-Id: I928533e6f8238189d64350463897a86ff5512ae7 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Diffstat (limited to 'src/plugins/python/pythonkitaspect.cpp')
-rw-r--r--src/plugins/python/pythonkitaspect.cpp24
1 files changed, 24 insertions, 0 deletions
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<Interpreter> &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<Interpreter> PythonKitAspect::python(const Kit *kit)