From a41876cd4105869e3a830523d7172f1804f285c9 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin <daniel.molkentin@nokia.com> Date: Mon, 31 May 2010 11:04:00 +0200 Subject: [PATCH] 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 --- share/qtcreator/declarative | 1 + share/qtcreator/examples | 1 + .../gettingstartedwelcomepagewidget.cpp | 24 +++++++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) create mode 120000 share/qtcreator/declarative create mode 120000 share/qtcreator/examples diff --git a/share/qtcreator/declarative b/share/qtcreator/declarative new file mode 120000 index 00000000000..286404c10df --- /dev/null +++ b/share/qtcreator/declarative @@ -0,0 +1 @@ +examples/declarative/ \ No newline at end of file diff --git a/share/qtcreator/examples b/share/qtcreator/examples new file mode 120000 index 00000000000..d5679a7d341 --- /dev/null +++ b/share/qtcreator/examples @@ -0,0 +1 @@ +/home/danimo/dev/qt-4.7/examples/ \ No newline at end of file diff --git a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp index 58a25be5238..a8a74ddff98 100644 --- a/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp +++ b/src/plugins/qt4projectmanager/gettingstartedwelcomepagewidget.cpp @@ -175,8 +175,6 @@ void GettingStartedWelcomePageWidget::updateQmlExamples(const QString &examplePa const QString &sourcePath) { ui->qmlExamplesButton->setText(tr("Choose an example...")); - QMenu *menu = new QMenu(ui->qmlExamplesButton); - ui->qmlExamplesButton->setMenu(menu); QStringList roots; roots << (examplePath + QLatin1String("/declarative")) @@ -197,14 +195,20 @@ void GettingStartedWelcomePageWidget::updateQmlExamples(const QString &examplePa exampleProjects.insert(fileName, exampleProject); } } - QMapIterator<QString, QString> it(exampleProjects); - while (it.hasNext()) { - it.next(); - QAction *exampleAction = menu->addAction(it.key()); - connect(exampleAction, SIGNAL(triggered()), SLOT(slotOpenExample())); - exampleAction->setProperty(ExamplePathPropertyName, it.value()); - // FIXME once we have help for QML examples - // exampleAction->setProperty(HelpPathPropertyName, helpPath); + + if (!exampleProjects.isEmpty()) { + QMenu *menu = new QMenu(ui->qmlExamplesButton); + ui->qmlExamplesButton->setMenu(menu); + + QMapIterator<QString, QString> it(exampleProjects); + while (it.hasNext()) { + it.next(); + QAction *exampleAction = menu->addAction(it.key()); + connect(exampleAction, SIGNAL(triggered()), SLOT(slotOpenExample())); + exampleAction->setProperty(ExamplePathPropertyName, it.value()); + // FIXME once we have help for QML examples + // exampleAction->setProperty(HelpPathPropertyName, helpPath); + } } ui->qmlExamplesButton->setEnabled(!exampleProjects.isEmpty()); -- GitLab