Do not add a menu if the examples cannot be found.

This is not only a waste of ressources, but breaks a check later on
which tries to load the QML examples from Creators ressource path
if no QML capable Qt version is found (included with Creator packages)

Reviewed-by: dt
This commit is contained in:
Daniel Molkentin
2010-05-31 11:04:00 +02:00
parent ec0d44fc3b
commit a41876cd41
3 changed files with 16 additions and 10 deletions

1
share/qtcreator/declarative Symbolic link
View File

@@ -0,0 +1 @@
examples/declarative/

1
share/qtcreator/examples Symbolic link
View File

@@ -0,0 +1 @@
/home/danimo/dev/qt-4.7/examples/

View File

@@ -175,8 +175,6 @@ void GettingStartedWelcomePageWidget::updateQmlExamples(const QString &examplePa
const QString &sourcePath) const QString &sourcePath)
{ {
ui->qmlExamplesButton->setText(tr("Choose an example...")); ui->qmlExamplesButton->setText(tr("Choose an example..."));
QMenu *menu = new QMenu(ui->qmlExamplesButton);
ui->qmlExamplesButton->setMenu(menu);
QStringList roots; QStringList roots;
roots << (examplePath + QLatin1String("/declarative")) roots << (examplePath + QLatin1String("/declarative"))
@@ -197,6 +195,11 @@ void GettingStartedWelcomePageWidget::updateQmlExamples(const QString &examplePa
exampleProjects.insert(fileName, exampleProject); exampleProjects.insert(fileName, exampleProject);
} }
} }
if (!exampleProjects.isEmpty()) {
QMenu *menu = new QMenu(ui->qmlExamplesButton);
ui->qmlExamplesButton->setMenu(menu);
QMapIterator<QString, QString> it(exampleProjects); QMapIterator<QString, QString> it(exampleProjects);
while (it.hasNext()) { while (it.hasNext()) {
it.next(); it.next();
@@ -206,6 +209,7 @@ void GettingStartedWelcomePageWidget::updateQmlExamples(const QString &examplePa
// FIXME once we have help for QML examples // FIXME once we have help for QML examples
// exampleAction->setProperty(HelpPathPropertyName, helpPath); // exampleAction->setProperty(HelpPathPropertyName, helpPath);
} }
}
ui->qmlExamplesButton->setEnabled(!exampleProjects.isEmpty()); ui->qmlExamplesButton->setEnabled(!exampleProjects.isEmpty());
} }