From 151f9e7d04433263933ff8e1ceaf59ff535a8e99 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 12 Sep 2024 15:41:32 +0200 Subject: [PATCH] Python: Fix enabled state for generate kit button Ensure the generate kit button for a python interpreter is only enabled if we can add a kit for this python. Basically disallows (local) python with incorrect paths. Change-Id: I3ca7b1fefb453837894a7ad6f39a446394fe2c4b Reviewed-by: David Schulz --- src/plugins/python/pythonsettings.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp index bfc411c6c2f..ba74146053e 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(