forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -42,6 +42,10 @@ public:
|
|||||||
|
|
||||||
PythonKitAspect::setPython(m_kit, m_comboBox->currentData().toString());
|
PythonKitAspect::setPython(m_kit, m_comboBox->currentData().toString());
|
||||||
});
|
});
|
||||||
|
connect(PythonSettings::instance(),
|
||||||
|
&PythonSettings::interpretersChanged,
|
||||||
|
this,
|
||||||
|
&PythonKitAspectImpl::refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
void makeReadOnly() override
|
void makeReadOnly() override
|
||||||
@@ -59,6 +63,7 @@ public:
|
|||||||
m_comboBox->addItem(interpreter.name, interpreter.id);
|
m_comboBox->addItem(interpreter.name, interpreter.id);
|
||||||
|
|
||||||
updateComboBox(PythonKitAspect::python(m_kit));
|
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)
|
void updateComboBox(const std::optional<Interpreter> &python)
|
||||||
@@ -146,6 +151,25 @@ public:
|
|||||||
return {PythonKitAspect::id()};
|
return {PythonKitAspect::id()};
|
||||||
return {};
|
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)
|
std::optional<Interpreter> PythonKitAspect::python(const Kit *kit)
|
||||||
|
@@ -819,7 +819,7 @@ void PythonSettings::addKitsForInterpreter(const Interpreter &interpreter)
|
|||||||
[interpreter](Kit *k) {
|
[interpreter](Kit *k) {
|
||||||
k->setAutoDetected(true);
|
k->setAutoDetected(true);
|
||||||
k->setAutoDetectionSource("Python");
|
k->setAutoDetectionSource("Python");
|
||||||
k->setUnexpandedDisplayName(interpreter.name);
|
k->setUnexpandedDisplayName("%{Python:Name}");
|
||||||
setRelevantAspectsToKit(k);
|
setRelevantAspectsToKit(k);
|
||||||
PythonKitAspect::setPython(k, interpreter.id);
|
PythonKitAspect::setPython(k, interpreter.id);
|
||||||
k->setSticky(PythonKitAspect::id(), true);
|
k->setSticky(PythonKitAspect::id(), true);
|
||||||
|
Reference in New Issue
Block a user