2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-07-20 19:08:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2009-07-20 19:08:09 +02:00
|
|
|
|
|
|
|
|
#include "welcomeplugin.h"
|
2011-04-13 17:09:44 +02:00
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-07-27 13:55:30 +02:00
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <coreplugin/imode.h>
|
2009-07-20 19:08:09 +02:00
|
|
|
#include <coreplugin/modemanager.h>
|
2014-05-02 17:38:42 +02:00
|
|
|
#include <coreplugin/iwizardfactory.h>
|
2009-07-20 19:08:09 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2013-10-23 22:07:46 +03:00
|
|
|
#include <utils/fileutils.h>
|
2012-08-23 15:53:58 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2011-04-13 17:09:44 +02:00
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
#include <utils/iwelcomepage.h>
|
|
|
|
|
|
2013-01-16 10:26:26 +01:00
|
|
|
#include <QVBoxLayout>
|
2014-03-05 11:52:24 +01:00
|
|
|
#include <QMessageBox>
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDir>
|
2009-07-20 19:08:09 +02:00
|
|
|
|
2014-06-16 14:55:37 +02:00
|
|
|
#ifdef USE_QUICK_WIDGET
|
|
|
|
|
#include <QtQuickWidgets/QQuickWidget>
|
|
|
|
|
typedef QQuickWidget QuickContainer;
|
|
|
|
|
#else
|
|
|
|
|
#include <QtQuick/QQuickView>
|
|
|
|
|
typedef QQuickView QuickContainer;
|
|
|
|
|
#endif
|
2013-09-02 17:29:30 +02:00
|
|
|
#include <QtQml/QQmlContext>
|
|
|
|
|
#include <QtQml/QQmlEngine>
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2011-07-22 16:45:41 +02:00
|
|
|
enum { debug = 0 };
|
2009-07-20 19:08:09 +02:00
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
using namespace ExtensionSystem;
|
2012-08-23 15:53:58 +02:00
|
|
|
using namespace Utils;
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
static const char currentPageSettingsKeyC[] = "WelcomeTab";
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
namespace Welcome {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
struct WelcomeModePrivate
|
|
|
|
|
{
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class WelcomeMode : public Core::IMode
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2010-11-11 16:49:17 +01:00
|
|
|
Q_PROPERTY(int activePlugin READ activePlugin WRITE setActivePlugin NOTIFY activePluginChanged)
|
2011-04-13 17:09:44 +02:00
|
|
|
public:
|
|
|
|
|
WelcomeMode();
|
|
|
|
|
~WelcomeMode();
|
|
|
|
|
|
|
|
|
|
void activated();
|
|
|
|
|
void initPlugins();
|
2010-11-11 16:49:17 +01:00
|
|
|
int activePlugin() const { return m_activePlugin; }
|
|
|
|
|
|
2011-07-01 16:08:21 +02:00
|
|
|
Q_SCRIPTABLE QString platform() const;
|
|
|
|
|
|
2013-09-02 17:29:30 +02:00
|
|
|
// bool eventFilter(QObject *, QEvent *);
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2013-03-25 11:24:00 +01:00
|
|
|
public slots:
|
2010-11-11 16:49:17 +01:00
|
|
|
void setActivePlugin(int pos)
|
|
|
|
|
{
|
|
|
|
|
if (m_activePlugin != pos) {
|
|
|
|
|
m_activePlugin = pos;
|
|
|
|
|
emit activePluginChanged(pos);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void activePluginChanged(int pos);
|
2011-04-13 17:09:44 +02:00
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
|
void welcomePluginAdded(QObject*);
|
2014-03-05 11:52:24 +01:00
|
|
|
#if QT_VERSION >= 0x050300
|
|
|
|
|
void sceneGraphError(QQuickWindow::SceneGraphError, const QString &message);
|
|
|
|
|
#endif
|
2011-04-13 17:09:44 +02:00
|
|
|
|
|
|
|
|
private:
|
2013-09-02 17:29:30 +02:00
|
|
|
void facilitateQml(QQmlEngine *engine);
|
2011-07-15 15:24:43 +02:00
|
|
|
|
2011-06-29 12:17:52 +02:00
|
|
|
QWidget *m_modeWidget;
|
2014-06-16 14:55:37 +02:00
|
|
|
QuickContainer *m_welcomePage;
|
2010-11-11 16:49:17 +01:00
|
|
|
QList<QObject*> m_pluginList;
|
|
|
|
|
int m_activePlugin;
|
2011-04-13 17:09:44 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// --- WelcomeMode
|
2010-11-11 16:49:17 +01:00
|
|
|
WelcomeMode::WelcomeMode() :
|
|
|
|
|
m_activePlugin(0)
|
2011-04-13 17:09:44 +02:00
|
|
|
{
|
|
|
|
|
setDisplayName(tr("Welcome"));
|
2013-01-16 22:06:59 +01:00
|
|
|
QIcon qtLogo;
|
|
|
|
|
qtLogo.addFile(QLatin1String(Core::Constants::ICON_QTLOGO_32));
|
|
|
|
|
qtLogo.addFile(QLatin1String(Core::Constants::ICON_QTLOGO_64));
|
|
|
|
|
qtLogo.addFile(QLatin1String(Core::Constants::ICON_QTLOGO_128));
|
|
|
|
|
setIcon(qtLogo);
|
2011-04-13 17:09:44 +02:00
|
|
|
setPriority(Core::Constants::P_MODE_WELCOME);
|
2012-05-07 18:28:03 +02:00
|
|
|
setId(Core::Constants::MODE_WELCOME);
|
2011-04-13 17:09:44 +02:00
|
|
|
setContextHelpId(QLatin1String("Qt Creator Manual"));
|
2011-04-13 17:19:55 +02:00
|
|
|
setContext(Core::Context(Core::Constants::C_WELCOME_MODE));
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2011-06-29 12:17:52 +02:00
|
|
|
m_modeWidget = new QWidget;
|
2013-09-27 10:47:34 +03:00
|
|
|
m_modeWidget->setObjectName(QLatin1String("WelcomePageModeWidget"));
|
2014-06-16 14:55:37 +02:00
|
|
|
QVBoxLayout *layout = new QVBoxLayout(m_modeWidget);
|
2011-06-29 12:17:52 +02:00
|
|
|
layout->setMargin(0);
|
|
|
|
|
layout->setSpacing(0);
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2014-06-16 14:55:37 +02:00
|
|
|
m_welcomePage = new QuickContainer();
|
|
|
|
|
m_welcomePage->setResizeMode(QuickContainer::SizeRootObjectToView);
|
|
|
|
|
|
|
|
|
|
m_welcomePage->setObjectName(QLatin1String("WelcomePage"));
|
|
|
|
|
|
|
|
|
|
#if QT_VERSION >= 0x050300
|
|
|
|
|
connect(m_welcomePage, SIGNAL(sceneGraphError(QQuickWindow::SceneGraphError,QString)),
|
|
|
|
|
this, SLOT(sceneGraphError(QQuickWindow::SceneGraphError,QString)));
|
|
|
|
|
#endif // Qt 5.3
|
|
|
|
|
|
2012-02-08 13:02:40 +01:00
|
|
|
Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget);
|
2013-09-27 10:47:34 +03:00
|
|
|
styledBar->setObjectName(QLatin1String("WelcomePageStyledBar"));
|
2012-02-08 13:02:40 +01:00
|
|
|
layout->addWidget(styledBar);
|
2013-09-02 17:29:30 +02:00
|
|
|
|
2014-06-16 14:55:37 +02:00
|
|
|
#ifdef USE_QUICK_WIDGET
|
|
|
|
|
m_welcomePage->setParent(m_modeWidget);
|
|
|
|
|
layout->addWidget(m_welcomePage);
|
|
|
|
|
#else
|
2013-11-19 11:04:26 +01:00
|
|
|
QWidget *container = QWidget::createWindowContainer(m_welcomePage, m_modeWidget);
|
2013-09-02 17:29:30 +02:00
|
|
|
m_modeWidget->setLayout(layout);
|
2013-11-19 11:04:26 +01:00
|
|
|
layout->addWidget(container);
|
2014-06-16 14:55:37 +02:00
|
|
|
#endif // USE_QUICK_WIDGET
|
2013-09-02 17:29:30 +02:00
|
|
|
|
2013-08-02 11:47:17 +02:00
|
|
|
connect(PluginManager::instance(), SIGNAL(objectAdded(QObject*)), SLOT(welcomePluginAdded(QObject*)));
|
2011-04-13 17:09:44 +02:00
|
|
|
|
2011-06-29 12:17:52 +02:00
|
|
|
setWidget(m_modeWidget);
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WelcomeMode::~WelcomeMode()
|
2009-07-20 19:08:09 +02:00
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *settings = Core::ICore::settings();
|
2010-11-11 16:49:17 +01:00
|
|
|
settings->setValue(QLatin1String(currentPageSettingsKeyC), activePlugin());
|
2011-06-29 12:17:52 +02:00
|
|
|
delete m_modeWidget;
|
2009-07-20 19:08:09 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-05 11:52:24 +01:00
|
|
|
#if QT_VERSION >= 0x050300
|
|
|
|
|
void WelcomeMode::sceneGraphError(QQuickWindow::SceneGraphError, const QString &message)
|
|
|
|
|
{
|
|
|
|
|
QMessageBox *messageBox =
|
|
|
|
|
new QMessageBox(QMessageBox::Warning,
|
|
|
|
|
tr("Welcome Mode Load Error"), message,
|
|
|
|
|
QMessageBox::Close, m_modeWidget);
|
|
|
|
|
messageBox->setModal(false);
|
|
|
|
|
messageBox->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
|
messageBox->show();
|
|
|
|
|
}
|
|
|
|
|
#endif // Qt 5.3
|
|
|
|
|
|
2013-09-02 17:29:30 +02:00
|
|
|
void WelcomeMode::facilitateQml(QQmlEngine * /*engine*/)
|
2011-07-15 15:24:43 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2012-11-28 14:25:18 +01:00
|
|
|
static QString applicationDirPath()
|
|
|
|
|
{
|
|
|
|
|
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
|
2013-10-23 22:07:46 +03:00
|
|
|
return Utils::FileUtils::normalizePathName(QCoreApplication::applicationDirPath());
|
2012-11-28 14:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static QString resourcePath()
|
|
|
|
|
{
|
|
|
|
|
// normalize paths so QML doesn't freak out if it's wrongly capitalized on Windows
|
2013-10-23 22:07:46 +03:00
|
|
|
return Utils::FileUtils::normalizePathName(Core::ICore::resourcePath());
|
2012-11-28 14:25:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
void WelcomeMode::initPlugins()
|
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
QSettings *settings = Core::ICore::settings();
|
2010-11-11 16:49:17 +01:00
|
|
|
setActivePlugin(settings->value(QLatin1String(currentPageSettingsKeyC)).toInt());
|
|
|
|
|
|
2013-09-02 17:29:30 +02:00
|
|
|
QQmlContext *ctx = m_welcomePage->rootContext();
|
2012-01-12 10:15:08 +01:00
|
|
|
ctx->setContextProperty(QLatin1String("welcomeMode"), this);
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2012-06-18 11:34:15 +02:00
|
|
|
QList<Utils::IWelcomePage*> duplicatePlugins = PluginManager::getObjects<Utils::IWelcomePage>();
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(duplicatePlugins, [](const Utils::IWelcomePage *l, const Utils::IWelcomePage *r) {
|
|
|
|
|
return l->priority() < r->priority();
|
|
|
|
|
});
|
2012-03-06 12:26:18 +01:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2013-09-02 17:29:30 +02:00
|
|
|
QQmlEngine *engine = m_welcomePage->engine();
|
2012-03-15 11:45:05 +01:00
|
|
|
QStringList importPathList = engine->importPathList();
|
2012-11-28 14:25:18 +01:00
|
|
|
importPathList << resourcePath() + QLatin1String("/welcomescreen");
|
2012-03-15 11:45:05 +01:00
|
|
|
engine->setImportPathList(importPathList);
|
2011-07-20 14:33:44 +02:00
|
|
|
if (!debug)
|
|
|
|
|
engine->setOutputWarningsToStandardError(false);
|
2012-11-28 14:25:18 +01:00
|
|
|
QString pluginPath = applicationDirPath();
|
2012-08-23 15:53:58 +02:00
|
|
|
if (HostOsInfo::isMacHost())
|
|
|
|
|
pluginPath += QLatin1String("/../PlugIns");
|
|
|
|
|
else
|
|
|
|
|
pluginPath += QLatin1String("/../" IDE_LIBRARY_BASENAME "/qtcreator");
|
2011-08-02 17:11:29 +02:00
|
|
|
engine->addImportPath(QDir::cleanPath(pluginPath));
|
2011-07-15 15:24:43 +02:00
|
|
|
facilitateQml(engine);
|
2011-04-13 17:09:44 +02:00
|
|
|
foreach (Utils::IWelcomePage *plugin, plugins) {
|
2010-11-11 16:49:17 +01:00
|
|
|
plugin->facilitateQml(engine);
|
|
|
|
|
m_pluginList.append(plugin);
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
2012-01-12 10:15:08 +01:00
|
|
|
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_pluginList));
|
2010-11-11 16:49:17 +01:00
|
|
|
|
2012-11-28 14:25:18 +01:00
|
|
|
QString path = resourcePath() + QLatin1String("/welcomescreen/welcomescreen.qml");
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
// finally, load the root page
|
|
|
|
|
m_welcomePage->setSource(
|
2012-11-28 14:25:18 +01:00
|
|
|
QUrl::fromLocalFile(path));
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-01 16:08:21 +02:00
|
|
|
QString WelcomeMode::platform() const
|
|
|
|
|
{
|
2012-08-23 15:53:58 +02:00
|
|
|
switch (HostOsInfo::hostOs()) {
|
2013-08-15 16:08:16 +02:00
|
|
|
case OsTypeWindows: return QLatin1String("windows");
|
|
|
|
|
case OsTypeMac: return QLatin1String("mac");
|
|
|
|
|
case OsTypeLinux: return QLatin1String("linux");
|
|
|
|
|
case OsTypeOtherUnix: return QLatin1String("unix");
|
2012-08-23 15:53:58 +02:00
|
|
|
default: return QLatin1String("other");
|
|
|
|
|
}
|
2011-07-01 16:08:21 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
void WelcomeMode::welcomePluginAdded(QObject *obj)
|
|
|
|
|
{
|
2012-03-06 12:26:18 +01:00
|
|
|
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);
|
|
|
|
|
}
|
2010-11-11 16:49:17 +01:00
|
|
|
if (Utils::IWelcomePage *plugin = qobject_cast<Utils::IWelcomePage*>(obj)) {
|
2012-03-06 12:26:18 +01:00
|
|
|
//check for duplicated id
|
|
|
|
|
if (pluginHash.contains(plugin->id())) {
|
|
|
|
|
Utils::IWelcomePage* pluginOther = pluginHash.value(plugin->id());
|
|
|
|
|
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
if (pluginOther->priority() > plugin->priority())
|
2012-03-06 12:26:18 +01:00
|
|
|
m_pluginList.removeAll(pluginOther);
|
Remove braces for single lines of conditions
#!/usr/bin/env ruby
Dir.glob('**/*.cpp') { |file|
# skip ast (excluding paste, astpath, and canv'ast'imer)
next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i
s = File.read(file)
next if s.include?('qlalr')
orig = s.dup
s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m|
res = $&
if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces
res
else
res.gsub!('} else', 'else')
res.gsub!(/\n +} *\n/m, "\n")
res.gsub(/ *{$/, '')
end
}
s.gsub!(/ *$/, '')
File.open(file, 'wb').write(s) if s != orig
}
Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc
Reviewed-by: hjk <qthjk@ovi.com>
2013-01-08 03:32:53 +02:00
|
|
|
else
|
2012-03-06 12:26:18 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-11 16:49:17 +01:00
|
|
|
int insertPos = 0;
|
2012-06-18 11:34:15 +02:00
|
|
|
foreach (Utils::IWelcomePage* p, PluginManager::getObjects<Utils::IWelcomePage>()) {
|
2010-11-11 16:49:17 +01:00
|
|
|
if (plugin->priority() < p->priority())
|
|
|
|
|
insertPos++;
|
|
|
|
|
else
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
m_pluginList.insert(insertPos, plugin);
|
|
|
|
|
// update model through reset
|
2013-09-02 17:29:30 +02:00
|
|
|
QQmlContext *ctx = m_welcomePage->rootContext();
|
2012-01-12 10:15:08 +01:00
|
|
|
ctx->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_pluginList));
|
2011-04-13 17:09:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
WelcomePlugin::WelcomePlugin()
|
|
|
|
|
: m_welcomeMode(0)
|
2009-07-20 19:08:09 +02:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Initializes the plugin. Returns true on success.
|
|
|
|
|
Plugins want to register objects with the plugin manager here.
|
|
|
|
|
|
2011-09-21 13:05:15 +02:00
|
|
|
\a errorMessage can be used to pass an error message to the plugin system,
|
2009-07-20 19:08:09 +02:00
|
|
|
if there was any.
|
|
|
|
|
*/
|
2011-09-21 13:05:15 +02:00
|
|
|
bool WelcomePlugin::initialize(const QStringList & /* arguments */, QString * /* errorMessage */)
|
2009-07-20 19:08:09 +02:00
|
|
|
{
|
|
|
|
|
m_welcomeMode = new WelcomeMode;
|
2010-03-31 11:49:06 +02:00
|
|
|
addAutoReleasedObject(m_welcomeMode);
|
2009-07-20 19:08:09 +02:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! Notification that all extensions that this plugin depends on have been
|
|
|
|
|
initialized. The dependencies are defined in the plugins .qwp file.
|
|
|
|
|
|
2013-10-07 13:34:40 +02:00
|
|
|
Normally this function is used for things that rely on other plugins to have
|
2009-07-20 19:08:09 +02:00
|
|
|
added objects to the plugin manager, that implement interfaces that we're
|
|
|
|
|
interested in. These objects can now be requested through the
|
|
|
|
|
PluginManagerInterface.
|
|
|
|
|
|
|
|
|
|
The WelcomePlugin doesn't need things from other plugins, so it does
|
|
|
|
|
nothing here.
|
|
|
|
|
*/
|
|
|
|
|
void WelcomePlugin::extensionsInitialized()
|
|
|
|
|
{
|
2009-07-27 13:55:30 +02:00
|
|
|
m_welcomeMode->initPlugins();
|
2012-01-26 01:18:02 +01:00
|
|
|
Core::ModeManager::activateMode(m_welcomeMode->id());
|
2009-07-20 19:08:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-13 17:09:44 +02:00
|
|
|
} // namespace Internal
|
2010-11-11 16:49:17 +01:00
|
|
|
} // namespace Welcome
|
2011-04-13 17:09:44 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Q_EXPORT_PLUGIN(Welcome::Internal::WelcomePlugin)
|
|
|
|
|
|
|
|
|
|
#include "welcomeplugin.moc"
|