ToolChains: Fix enabling the toolchain combobox in the Kits page

Change-Id: I96b44e2febf070f4eea4a5b5878382dd8b374564
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-03-16 15:40:49 +01:00
parent 972a306d56
commit 85f10dcaaa
2 changed files with 10 additions and 19 deletions

View File

@@ -127,10 +127,10 @@ void SysRootInformationConfigWidget::pathWasChanged()
ToolChainInformationConfigWidget::ToolChainInformationConfigWidget(Kit *k, const KitInformation *ki) :
KitConfigWidget(k, ki),
m_ignoreChanges(false)
m_ignoreChanges(false),
m_isReadOnly(false)
{
m_comboBox = new QComboBox;
m_comboBox->setEnabled(false);
m_comboBox->setToolTip(toolTip());
refresh();
@@ -166,7 +166,12 @@ void ToolChainInformationConfigWidget::refresh()
foreach (ToolChain *tc, ToolChainManager::toolChains())
m_comboBox->addItem(tc->displayName(), tc->id());
m_comboBox->setEnabled(m_comboBox->count() > 1);
if (m_comboBox->count() == 0) {
m_comboBox->addItem(tr("<No compiler available>"), QString());
m_comboBox->setEnabled(false);
} else {
m_comboBox->setEnabled(m_comboBox->count() > 1 && !m_isReadOnly);
}
m_comboBox->setCurrentIndex(indexOf(ToolChainKitInformation::toolChain(m_kit)));
m_ignoreChanges = false;
@@ -174,6 +179,7 @@ void ToolChainInformationConfigWidget::refresh()
void ToolChainInformationConfigWidget::makeReadOnly()
{
m_isReadOnly = true;
m_comboBox->setEnabled(false);
}
@@ -201,21 +207,6 @@ void ToolChainInformationConfigWidget::currentToolChainChanged(int idx)
ToolChainKitInformation::setToolChain(m_kit, ToolChainManager::findToolChain(id));
}
void ToolChainInformationConfigWidget::updateComboBox()
{
// remove unavailable tool chain:
int pos = indexOf(0);
if (pos >= 0)
m_comboBox->removeItem(pos);
if (m_comboBox->count() == 0) {
m_comboBox->addItem(tr("<No compiler available>"), QString());
m_comboBox->setEnabled(false);
} else {
m_comboBox->setEnabled(true);
}
}
int ToolChainInformationConfigWidget::indexOf(const ToolChain *tc)
{
const QString id = tc ? tc->id() : QString();

View File

@@ -104,12 +104,12 @@ private slots:
void currentToolChainChanged(int idx);
private:
void updateComboBox();
int indexOf(const ToolChain *tc);
QComboBox *m_comboBox;
QPushButton *m_manageButton;
bool m_ignoreChanges;
bool m_isReadOnly;
};
// --------------------------------------------------------------------------