forked from qt-creator/qt-creator
Welcome: beautify code
Change-Id: I1dff086e7fb7839aa44383f80214a4543de916d1 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -160,7 +160,7 @@ private:
|
|||||||
void welcomePluginAdded(QObject*);
|
void welcomePluginAdded(QObject*);
|
||||||
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
|
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
|
||||||
void facilitateQml(QQmlEngine *engine);
|
void facilitateQml(QQmlEngine *engine);
|
||||||
void addPages(const QList<IWelcomePage *> &pages);
|
void addPages(QQmlEngine *engine, const QList<IWelcomePage *> &pages);
|
||||||
void addKeyboardShortcuts();
|
void addKeyboardShortcuts();
|
||||||
|
|
||||||
QWidget *m_modeWidget;
|
QWidget *m_modeWidget;
|
||||||
@@ -296,13 +296,16 @@ void WelcomeMode::initPlugins()
|
|||||||
QSettings *settings = ICore::settings();
|
QSettings *settings = ICore::settings();
|
||||||
setActivePlugin(settings->value(QLatin1String(currentPageSettingsKeyC)).toInt());
|
setActivePlugin(settings->value(QLatin1String(currentPageSettingsKeyC)).toInt());
|
||||||
|
|
||||||
facilitateQml(m_welcomePage->engine());
|
QQmlEngine *engine = m_welcomePage->engine();
|
||||||
|
facilitateQml(engine);
|
||||||
|
|
||||||
QList<IWelcomePage *> availablePages = PluginManager::getObjects<IWelcomePage>();
|
QList<IWelcomePage *> availablePages = PluginManager::getObjects<IWelcomePage>();
|
||||||
addPages(availablePages);
|
addPages(engine, availablePages);
|
||||||
// make sure later added pages are made available too:
|
// make sure later added pages are made available too:
|
||||||
connect(PluginManager::instance(), &PluginManager::objectAdded,
|
connect(PluginManager::instance(), &PluginManager::objectAdded, engine, [this, engine](QObject *obj) {
|
||||||
this, &WelcomeMode::welcomePluginAdded);
|
if (IWelcomePage *page = qobject_cast<IWelcomePage*>(obj))
|
||||||
|
addPages(engine, QList<IWelcomePage *>() << page);
|
||||||
|
});
|
||||||
|
|
||||||
QString path = resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
|
QString path = resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
|
||||||
|
|
||||||
@@ -322,23 +325,14 @@ bool WelcomeMode::openDroppedFiles(const QList<QUrl> &urls)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WelcomeMode::welcomePluginAdded(QObject *obj)
|
void WelcomeMode::addPages(QQmlEngine *engine, const QList<IWelcomePage *> &pages)
|
||||||
{
|
|
||||||
IWelcomePage *page = qobject_cast<IWelcomePage*>(obj);
|
|
||||||
if (!page)
|
|
||||||
return;
|
|
||||||
addPages(QList<IWelcomePage *>() << page);
|
|
||||||
}
|
|
||||||
|
|
||||||
void WelcomeMode::addPages(const QList<IWelcomePage *> &pages)
|
|
||||||
{
|
{
|
||||||
QList<IWelcomePage *> addedPages = pages;
|
QList<IWelcomePage *> addedPages = pages;
|
||||||
Utils::sort(addedPages, &IWelcomePage::priority);
|
Utils::sort(addedPages, &IWelcomePage::priority);
|
||||||
// insert into m_pluginList, keeping m_pluginList sorted by priority
|
// insert into m_pluginList, keeping m_pluginList sorted by priority
|
||||||
QQmlEngine *engine = m_welcomePage->engine();
|
auto addIt = addedPages.cbegin();
|
||||||
auto addIt = addedPages.begin();
|
|
||||||
auto currentIt = m_pluginList.begin();
|
auto currentIt = m_pluginList.begin();
|
||||||
while (addIt != addedPages.end()) {
|
while (addIt != addedPages.cend()) {
|
||||||
IWelcomePage *page = *addIt;
|
IWelcomePage *page = *addIt;
|
||||||
QTC_ASSERT(!m_idPageMap.contains(page->id()), ++addIt; continue);
|
QTC_ASSERT(!m_idPageMap.contains(page->id()), ++addIt; continue);
|
||||||
while (currentIt != m_pluginList.end() && (*currentIt)->priority() <= page->priority())
|
while (currentIt != m_pluginList.end() && (*currentIt)->priority() <= page->priority())
|
||||||
|
|||||||
Reference in New Issue
Block a user