aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonsettings.cpp
diff options
context:
space:
mode:
authorEike Ziller <[email protected]>2024-09-25 09:50:57 +0200
committerEike Ziller <[email protected]>2024-09-25 09:50:57 +0200
commitad7ea80c0799953a58a92e64453082cff6387a85 (patch)
tree696acc799f39d137bbd6f6a550b45f8c0789b007 /src/plugins/python/pythonsettings.cpp
parent469124a89a6b7dd890faf69cd56d385225d53223 (diff)
parent852470cfbb947433a3fc3d0ad3cc5d2765637ee4 (diff)
Merge remote-tracking branch 'origin/14.0'
Conflicts: coin/instructions/build.yaml src/plugins/cppeditor/cpptoolsreuse.cpp src/plugins/projectexplorer/projectexplorer.cpp Change-Id: I26748c67ed58114b392704bbf4eba978b1048c80
Diffstat (limited to 'src/plugins/python/pythonsettings.cpp')
-rw-r--r--src/plugins/python/pythonsettings.cpp37
1 files changed, 24 insertions, 13 deletions
diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp
index 9e0fd837d9c..6c8fff0e615 100644
--- a/src/plugins/python/pythonsettings.cpp
+++ b/src/plugins/python/pythonsettings.cpp
@@ -155,6 +155,7 @@ private:
void currentChanged(const QModelIndex &index, const QModelIndex &previous);
void detailsChanged();
void updateCleanButton();
+ void updateGenerateKitButton(const Interpreter &interpreter);
void addItem();
void deleteItem();
void makeDefault();
@@ -283,10 +284,10 @@ void InterpreterOptionsWidget::currentChanged(const QModelIndex &index, const QM
emit m_model.dataChanged(previous, previous);
}
if (index.isValid()) {
- m_detailsWidget->updateInterpreter(m_model.itemAt(index.row())->itemData);
+ const Interpreter interpreter = m_model.itemAt(index.row())->itemData;
+ m_detailsWidget->updateInterpreter(interpreter);
m_detailsWidget->show();
- m_generateKitButton->setEnabled(
- !KitManager::kit(Id::fromString(m_model.itemAt(index.row())->itemData.id)));
+ updateGenerateKitButton(interpreter);
} else {
m_detailsWidget->hide();
m_generateKitButton->setEnabled(false);
@@ -299,8 +300,10 @@ void InterpreterOptionsWidget::detailsChanged()
{
const QModelIndex &index = m_view->currentIndex();
if (index.isValid()) {
- m_model.itemAt(index.row())->itemData = m_detailsWidget->toInterpreter();
+ const Interpreter interpreter = m_detailsWidget->toInterpreter();
+ m_model.itemAt(index.row())->itemData = interpreter;
emit m_model.dataChanged(index, index);
+ updateGenerateKitButton(interpreter);
}
updateCleanButton();
}
@@ -312,6 +315,13 @@ void InterpreterOptionsWidget::updateCleanButton()
}));
}
+void InterpreterOptionsWidget::updateGenerateKitButton(const Interpreter &interpreter)
+{
+ bool enabled = !KitManager::kit(Id::fromString(interpreter.id))
+ && (interpreter.command.needsDevice() || interpreter.command.isExecutableFile());
+ m_generateKitButton->setEnabled(enabled);
+}
+
void InterpreterOptionsWidget::addItem()
{
const QModelIndex &index = m_model.indexForItem(
@@ -568,7 +578,7 @@ void InterpreterOptionsWidget::generateKit()
{
const QModelIndex &index = m_view->currentIndex();
if (index.isValid())
- PythonSettings::addKitsForInterpreter(m_model.itemAt(index.row())->itemData);
+ PythonSettings::addKitsForInterpreter(m_model.itemAt(index.row())->itemData, true);
m_generateKitButton->setEnabled(false);
}
@@ -796,19 +806,20 @@ static void setRelevantAspectsToKit(Kit *k)
k->setRelevantAspects(relevantAspects);
}
-void PythonSettings::addKitsForInterpreter(const Interpreter &interpreter)
+void PythonSettings::addKitsForInterpreter(const Interpreter &interpreter, bool force)
{
if (!KitManager::isLoaded()) {
- connect(KitManager::instance(), &KitManager::kitsLoaded, settingsInstance, [interpreter]() {
- addKitsForInterpreter(interpreter);
- });
+ connect(KitManager::instance(),
+ &KitManager::kitsLoaded,
+ settingsInstance,
+ [interpreter, force]() { addKitsForInterpreter(interpreter, force); });
return;
}
const Id kitId = Id::fromString(interpreter.id);
if (Kit *k = KitManager::kit(kitId)) {
setRelevantAspectsToKit(k);
- } else if (!isVenvPython(interpreter.command)) {
+ } else if (force || !isVenvPython(interpreter.command)) {
KitManager::registerKit(
[interpreter](Kit *k) {
k->setAutoDetected(true);
@@ -844,7 +855,7 @@ void PythonSettings::setInterpreter(const QList<Interpreter> &interpreters, cons
QList<Interpreter> toRemove = settingsInstance->m_interpreters;
for (const Interpreter &interpreter : interpreters) {
if (!Utils::eraseOne(toRemove, Utils::equal(&Interpreter::id, interpreter.id)))
- addKitsForInterpreter(interpreter);
+ addKitsForInterpreter(interpreter, false);
}
for (const Interpreter &interpreter : toRemove)
removeKitsForInterpreter(interpreter);
@@ -889,7 +900,7 @@ void PythonSettings::addInterpreter(const Interpreter &interpreter, bool isDefau
if (isDefault)
settingsInstance->m_defaultInterpreterId = interpreter.id;
saveSettings();
- addKitsForInterpreter(interpreter);
+ addKitsForInterpreter(interpreter, false);
}
Interpreter PythonSettings::addInterpreter(const FilePath &interpreterPath,
@@ -1059,7 +1070,7 @@ void PythonSettings::initFromSettings(QtcSettings *settings)
if (cmd.needsDevice() || cmd.parentDir().pathAppended("activate").exists())
continue;
}
- addKitsForInterpreter(interpreter);
+ addKitsForInterpreter(interpreter, false);
}
} else {
fixupPythonKits();