forked from qt-creator/qt-creator
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:
@@ -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(
|
||||
|
Reference in New Issue
Block a user