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 <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2024-09-12 15:41:32 +02:00
parent e986dc8938
commit 151f9e7d04

View File

@@ -155,6 +155,7 @@ private:
void currentChanged(const QModelIndex &index, const QModelIndex &previous); void currentChanged(const QModelIndex &index, const QModelIndex &previous);
void detailsChanged(); void detailsChanged();
void updateCleanButton(); void updateCleanButton();
void updateGenerateKitButton(const Interpreter &interpreter);
void addItem(); void addItem();
void deleteItem(); void deleteItem();
void makeDefault(); void makeDefault();
@@ -283,10 +284,10 @@ void InterpreterOptionsWidget::currentChanged(const QModelIndex &index, const QM
emit m_model.dataChanged(previous, previous); emit m_model.dataChanged(previous, previous);
} }
if (index.isValid()) { 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_detailsWidget->show();
m_generateKitButton->setEnabled( updateGenerateKitButton(interpreter);
!KitManager::kit(Id::fromString(m_model.itemAt(index.row())->itemData.id)));
} else { } else {
m_detailsWidget->hide(); m_detailsWidget->hide();
m_generateKitButton->setEnabled(false); m_generateKitButton->setEnabled(false);
@@ -299,8 +300,10 @@ void InterpreterOptionsWidget::detailsChanged()
{ {
const QModelIndex &index = m_view->currentIndex(); const QModelIndex &index = m_view->currentIndex();
if (index.isValid()) { 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); emit m_model.dataChanged(index, index);
updateGenerateKitButton(interpreter);
} }
updateCleanButton(); 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() void InterpreterOptionsWidget::addItem()
{ {
const QModelIndex &index = m_model.indexForItem( const QModelIndex &index = m_model.indexForItem(