diff --git a/src/libs/utils/iwelcomepage.h b/src/libs/utils/iwelcomepage.h index 38a973bb7cbef128bb594736c103899d0b972485..67b2de93b5b1bb3dc3c3515f8a6b7259003a197d 100644 --- a/src/libs/utils/iwelcomepage.h +++ b/src/libs/utils/iwelcomepage.h @@ -54,6 +54,14 @@ class QTCREATOR_UTILS_EXPORT IWelcomePage : public QObject Q_PROPERTY(bool hasSearchBar READ hasSearchBar CONSTANT) public: + enum Id { + GettingStarted = 0, + Develop = 1, + Examples = 2, + Tutorials = 3, + UserDefined = 32 + }; + IWelcomePage(); virtual ~IWelcomePage(); @@ -62,6 +70,7 @@ public: virtual int priority() const { return 0; } virtual void facilitateQml(QDeclarativeEngine *) {} virtual bool hasSearchBar() const { return false; } + virtual Id id() const = 0; private: // not used atm diff --git a/src/plugins/projectexplorer/projectwelcomepage.cpp b/src/plugins/projectexplorer/projectwelcomepage.cpp index ee4c436d5a71091c4f7f8c6efb5a677a92bbce41..f26e4d2e458f82f5998bc1c8e7d181693c2c2e4c 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.cpp +++ b/src/plugins/projectexplorer/projectwelcomepage.cpp @@ -32,6 +32,8 @@ #include "projectwelcomepage.h" +#include "projectexplorerconstants.h" + #include <utils/stringutils.h> #include <QDeclarativeEngine> @@ -216,6 +218,11 @@ void ProjectWelcomePage::facilitateQml(QDeclarativeEngine *engine) ctx->setContextProperty(QLatin1String("projectWelcomePage"), this); } +ProjectWelcomePage::Id ProjectWelcomePage::id() const +{ + return Develop; +} + void ProjectWelcomePage::reloadWelcomeScreenData() { if (m_sessionModel) diff --git a/src/plugins/projectexplorer/projectwelcomepage.h b/src/plugins/projectexplorer/projectwelcomepage.h index 2e85551b2efce3ac70df7c9a309f4b7b376d0854..5c0d963a3b5aea929105528dddc056d072087d53 100644 --- a/src/plugins/projectexplorer/projectwelcomepage.h +++ b/src/plugins/projectexplorer/projectwelcomepage.h @@ -101,6 +101,7 @@ public: QWidget *page() { return 0; } QString title() const { return tr("Develop"); } int priority() const { return 20; } + Id id() const; void reloadWelcomeScreenData(); diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp index 5b112daa2c01f6ce8e2bc567489cf3d2d95ea13a..496094ee9237552fc3c075f187a8ce22165b18a1 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.cpp +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.cpp @@ -35,6 +35,8 @@ #include "exampleslistmodel.h" #include "screenshotcropper.h" +#include "qtsupportconstants.h" + #include <utils/pathchooser.h> #include <utils/fileutils.h> @@ -210,7 +212,7 @@ QString GettingStartedWelcomePage::title() const int GettingStartedWelcomePage::priority() const { - return 0; + return 4; } void GettingStartedWelcomePage::facilitateQml(QDeclarativeEngine *engine) @@ -218,6 +220,11 @@ void GettingStartedWelcomePage::facilitateQml(QDeclarativeEngine *engine) m_engine = engine; } +GettingStartedWelcomePage::Id GettingStartedWelcomePage::id() const +{ + return GettingStarted; +} + ExamplesWelcomePage::ExamplesWelcomePage() : m_engine(0), m_showExamples(false) { @@ -281,6 +288,11 @@ void ExamplesWelcomePage::facilitateQml(QDeclarativeEngine *engine) rootContenxt->setContextProperty(QLatin1String("gettingStarted"), this); } +ExamplesWelcomePage::Id ExamplesWelcomePage::id() const +{ + return m_showExamples ? Examples : Tutorials; +} + void ExamplesWelcomePage::openSplitHelp(const QUrl &help) { Core::ICore::helpManager()->handleHelpRequest(help.toString()+QLatin1String("?view=split")); diff --git a/src/plugins/qtsupport/gettingstartedwelcomepage.h b/src/plugins/qtsupport/gettingstartedwelcomepage.h index aefa4fdeeeae5c4475a9c2ce524635247e5b08c2..678b9bea02de874d75b01c5632a1574e3a5a1f7e 100644 --- a/src/plugins/qtsupport/gettingstartedwelcomepage.h +++ b/src/plugins/qtsupport/gettingstartedwelcomepage.h @@ -58,6 +58,7 @@ public: QString title() const; int priority() const; void facilitateQml(QDeclarativeEngine *); + Id id() const; private: QDeclarativeEngine *m_engine; @@ -76,6 +77,7 @@ public: int priority() const; bool hasSearchBar() const; void facilitateQml(QDeclarativeEngine *); + Id id() const; Q_INVOKABLE QStringList tagList() const; Q_INVOKABLE void openUrl(const QUrl &url); diff --git a/src/plugins/welcome/welcomeplugin.cpp b/src/plugins/welcome/welcomeplugin.cpp index b34e36deee957ff204f2140b4d8ae7221bcb1f9c..37e23f270928ac97947bfdc188c9c6d1a9626117 100644 --- a/src/plugins/welcome/welcomeplugin.cpp +++ b/src/plugins/welcome/welcomeplugin.cpp @@ -208,8 +208,30 @@ void WelcomeMode::initPlugins() QDeclarativeContext *ctx = m_welcomePage->rootContext(); ctx->setContextProperty(QLatin1String("welcomeMode"), this); - QList<Utils::IWelcomePage*> plugins = PluginManager::instance()->getObjects<Utils::IWelcomePage>(); - qSort(plugins.begin(), plugins.end(), &sortFunction); + QList<Utils::IWelcomePage*> duplicatePlugins = PluginManager::instance()->getObjects<Utils::IWelcomePage>(); + qSort(duplicatePlugins.begin(), duplicatePlugins.end(), &sortFunction); + + QList<Utils::IWelcomePage*> plugins; + QHash<Utils::IWelcomePage::Id, Utils::IWelcomePage*> pluginHash; + + //avoid duplicate ids - choose by priority + foreach (Utils::IWelcomePage* plugin, duplicatePlugins) { + if (pluginHash.contains(plugin->id())) { + Utils::IWelcomePage* pluginOther = pluginHash.value(plugin->id()); + + if (pluginOther->priority() > plugin->priority()) { + plugins.removeAll(pluginOther); + pluginHash.remove(pluginOther->id()); + plugins << plugin; + pluginHash.insert(plugin->id(), plugin); + } + + } else { + plugins << plugin; + pluginHash.insert(plugin->id(), plugin); + } + } + QDeclarativeEngine *engine = m_welcomePage->engine(); if (!debug) @@ -252,7 +274,24 @@ QString WelcomeMode::platform() const void WelcomeMode::welcomePluginAdded(QObject *obj) { + QHash<Utils::IWelcomePage::Id, Utils::IWelcomePage*> pluginHash; + + foreach (QObject *obj, m_pluginList) { + Utils::IWelcomePage *plugin = qobject_cast<Utils::IWelcomePage*>(obj); + pluginHash.insert(plugin->id(), plugin); + } if (Utils::IWelcomePage *plugin = qobject_cast<Utils::IWelcomePage*>(obj)) { + //check for duplicated id + if (pluginHash.contains(plugin->id())) { + Utils::IWelcomePage* pluginOther = pluginHash.value(plugin->id()); + + if (pluginOther->priority() > plugin->priority()) { + m_pluginList.removeAll(pluginOther); + } else { + return; + } + } + int insertPos = 0; foreach (Utils::IWelcomePage* p, PluginManager::instance()->getObjects<Utils::IWelcomePage>()) { if (plugin->priority() < p->priority())