Alert the user that he might be missing a toolchain

Change-Id: I2c9e3f9eab962b8310f21f9fe5fc392d88089c7f
Task-Nr: QTCREATORBUG-5248
Reviewed-on: http://codereview.qt.nokia.com/886
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
Tobias Hunger
2011-06-30 10:50:39 +02:00
committed by Daniel Teske
parent 9e5bcf2f4b
commit b90be2b5bf
2 changed files with 78 additions and 12 deletions

View File

@@ -48,6 +48,7 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/buildablehelperlibrary.h> #include <utils/buildablehelperlibrary.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
#include <projectexplorer/toolchainmanager.h>
#include <qtconcurrent/runextensions.h> #include <qtconcurrent/runextensions.h>
#include <QtCore/QDir> #include <QtCore/QDir>
@@ -129,6 +130,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *>
, m_versionUi(new Internal::Ui::QtVersionInfo()) , m_versionUi(new Internal::Ui::QtVersionInfo())
, m_debuggingHelperUi(new Internal::Ui::DebuggingHelper()) , m_debuggingHelperUi(new Internal::Ui::DebuggingHelper())
, m_invalidVersionIcon(":/projectexplorer/images/compile_error.png") , m_invalidVersionIcon(":/projectexplorer/images/compile_error.png")
, m_warningVersionIcon(":/projectexplorer/images/compile_warning.png")
, m_configurationWidget(0) , m_configurationWidget(0)
{ {
// Initialize m_versions // Initialize m_versions
@@ -169,7 +171,8 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *>
item->setText(0, version->displayName()); item->setText(0, version->displayName());
item->setText(1, QDir::toNativeSeparators(version->qmakeCommand())); item->setText(1, QDir::toNativeSeparators(version->qmakeCommand()));
item->setData(0, VersionIdRole, version->uniqueId()); item->setData(0, VersionIdRole, version->uniqueId());
item->setIcon(0, version->isValid()? m_validVersionIcon : m_invalidVersionIcon); const ValidityInfo info = validInformation(version);
item->setIcon(0, info.icon);
} }
m_ui->qtdirList->expandAll(); m_ui->qtdirList->expandAll();
@@ -207,6 +210,9 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *>
connect(QtVersionManager::instance(), SIGNAL(dumpUpdatedFor(QString)), connect(QtVersionManager::instance(), SIGNAL(dumpUpdatedFor(QString)),
this, SLOT(qtVersionsDumpUpdated(QString))); this, SLOT(qtVersionsDumpUpdated(QString)));
connect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainsChanged()),
this, SLOT(toolChainsUpdated()));
} }
bool QtOptionsPageWidget::eventFilter(QObject *o, QEvent *e) bool QtOptionsPageWidget::eventFilter(QObject *o, QEvent *e)
@@ -320,6 +326,19 @@ void QtOptionsPageWidget::cleanUpQtVersions()
updateCleanUpButton(); updateCleanUpButton();
} }
void QtOptionsPageWidget::toolChainsUpdated()
{
for (int i = 0; i < m_versions.count(); ++i) {
QTreeWidgetItem *item = treeItemForIndex(i);
if (item == m_ui->qtdirList->currentItem())
updateDescriptionLabel();
else {
const ValidityInfo info = validInformation(m_versions.at(i));
item->setIcon(0, info.icon);
}
}
}
void QtOptionsPageWidget::qtVersionsDumpUpdated(const QString &qmakeCommand) void QtOptionsPageWidget::qtVersionsDumpUpdated(const QString &qmakeCommand)
{ {
foreach (BaseQtVersion *version, m_versions) { foreach (BaseQtVersion *version, m_versions) {
@@ -334,6 +353,49 @@ void QtOptionsPageWidget::qtVersionsDumpUpdated(const QString &qmakeCommand)
} }
} }
QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const BaseQtVersion *version)
{
ValidityInfo info;
info.icon = m_validVersionIcon;
if (!version)
return info;
if (!version->isValid()) {
info.icon = m_invalidVersionIcon;
info.message = version->invalidReason();
return info;
}
// Do we have tool chain issues?
QStringList missingToolChains;
int abiCount = 0;
foreach (const ProjectExplorer::Abi &a, version->qtAbis()) {
// Ignore symbian emulator since we do not support it.
if (a.osFlavor() == ProjectExplorer::Abi::SymbianEmulatorFlavor)
continue;
if (ProjectExplorer::ToolChainManager::instance()->findToolChains(a).isEmpty())
missingToolChains.append(a.toString());
++abiCount;
}
if (missingToolChains.isEmpty()) {
// No:
info.message = tr("Qt version %1 for %2").arg(version->qtVersionString(), version->description());
} else if (missingToolChains.count() == abiCount) {
// Yes, this Qt version can't be used at all!
info.message = tr("No tool chain can produce code for this Qt version. Please define one or more tool chains.");
info.icon = m_invalidVersionIcon;
} else {
// Yes, some ABIs are unsupported
info.message = tr("Not all possible target environments can be supported due to missing tool chains.");
info.toolTip = tr("The following ABIs are currently not supported:<ul><li>%1</ul>")
.arg(missingToolChains.join(QLatin1String("</li><li>")));
info.icon = m_warningVersionIcon;
}
return info;
}
void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools) void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools)
{ {
const int index = currentIndex(); const int index = currentIndex();
@@ -725,17 +787,11 @@ void QtOptionsPageWidget::qtVersionChanged()
void QtOptionsPageWidget::updateDescriptionLabel() void QtOptionsPageWidget::updateDescriptionLabel()
{ {
QTreeWidgetItem *item = m_ui->qtdirList->currentItem(); QTreeWidgetItem *item = m_ui->qtdirList->currentItem();
const BaseQtVersion *version = currentVersion(); const ValidityInfo info = validInformation(currentVersion());
if (!version) { m_versionUi->errorLabel->setText(info.message);
m_versionUi->errorLabel->setText(QString()); m_versionUi->errorLabel->setToolTip(info.toolTip);
} else if (version->isValid()) { if (item)
m_versionUi->errorLabel->setText( tr("Qt version %1 for %2").arg(version->qtVersionString(), item->setIcon(0, info.icon);
version->description()));
item->setIcon(0, m_validVersionIcon);
} else {
m_versionUi->errorLabel->setText(version->invalidReason());
item->setIcon(0, m_invalidVersionIcon);
}
} }
int QtOptionsPageWidget::indexForTreeItem(const QTreeWidgetItem *item) const int QtOptionsPageWidget::indexForTreeItem(const QTreeWidgetItem *item) const

View File

@@ -88,6 +88,7 @@ private:
QList<BaseQtVersion *> m_versions; QList<BaseQtVersion *> m_versions;
int m_defaultVersion; int m_defaultVersion;
QIcon m_invalidVersionIcon; QIcon m_invalidVersionIcon;
QIcon m_warningVersionIcon;
QIcon m_validVersionIcon; QIcon m_validVersionIcon;
QtConfigWidget *m_configurationWidget; QtConfigWidget *m_configurationWidget;
@@ -108,8 +109,17 @@ private slots:
void slotShowDebuggingBuildLog(); void slotShowDebuggingBuildLog();
void debuggingHelperBuildFinished(int qtVersionId, const QString &output, DebuggingHelperBuildTask::Tools tools); void debuggingHelperBuildFinished(int qtVersionId, const QString &output, DebuggingHelperBuildTask::Tools tools);
void cleanUpQtVersions(); void cleanUpQtVersions();
void toolChainsUpdated();
void qtVersionsDumpUpdated(const QString &qmakeCommand); void qtVersionsDumpUpdated(const QString &qmakeCommand);
private:
struct ValidityInfo {
QString message;
QString toolTip;
QIcon icon;
};
ValidityInfo validInformation(const BaseQtVersion *version);
}; };
class QtOptionsPage : public Core::IOptionsPage class QtOptionsPage : public Core::IOptionsPage