2011-02-05 23:35:18 +01:00
|
|
|
/**
|
|
|
|
******************************************************************************
|
|
|
|
*
|
|
|
|
* @file welcomemode.cpp
|
|
|
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
|
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
|
|
|
* @addtogroup GCSPlugins GCS Plugins
|
|
|
|
* @{
|
|
|
|
* @addtogroup WelcomePlugin Welcome Plugin
|
|
|
|
* @{
|
|
|
|
* @brief The GCS Welcome plugin
|
|
|
|
*****************************************************************************/
|
|
|
|
/*
|
2013-05-19 16:37:30 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2011-02-05 23:35:18 +01:00
|
|
|
* (at your option) any later version.
|
2013-05-19 16:37:30 +02:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
2011-02-05 23:35:18 +01:00
|
|
|
* for more details.
|
2013-05-19 16:37:30 +02:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
2011-02-05 23:35:18 +01:00
|
|
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "welcomemode.h"
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
#include <coreplugin/uniqueidmanager.h>
|
|
|
|
#include <coreplugin/modemanager.h>
|
|
|
|
|
|
|
|
#include <utils/styledbar.h>
|
|
|
|
#include <utils/welcomemodetreewidget.h>
|
|
|
|
#include <utils/iwelcomepage.h>
|
|
|
|
|
|
|
|
#include <QtGui/QDesktopServices>
|
|
|
|
|
|
|
|
#include <QtCore/QSettings>
|
|
|
|
#include <QtCore/QUrl>
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
2012-02-11 00:58:30 +01:00
|
|
|
#include <QtDeclarative/qdeclarative.h>
|
|
|
|
#include <QtDeclarative/qdeclarativeview.h>
|
|
|
|
#include <QtDeclarative/qdeclarativeengine.h>
|
|
|
|
#include <QtDeclarative/qdeclarativecontext.h>
|
2011-02-05 23:35:18 +01:00
|
|
|
|
2012-02-11 00:58:30 +01:00
|
|
|
#include <cstdlib>
|
2011-02-05 23:35:18 +01:00
|
|
|
|
|
|
|
using namespace ExtensionSystem;
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
namespace Welcome {
|
2013-05-19 16:37:30 +02:00
|
|
|
struct WelcomeModePrivate {
|
2011-02-05 23:35:18 +01:00
|
|
|
WelcomeModePrivate();
|
|
|
|
|
2012-02-11 00:58:30 +01:00
|
|
|
QDeclarativeView *declarativeView;
|
2011-02-05 23:35:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
WelcomeModePrivate::WelcomeModePrivate()
|
2013-05-19 16:37:30 +02:00
|
|
|
{}
|
2011-02-05 23:35:18 +01:00
|
|
|
|
|
|
|
// --- WelcomeMode
|
|
|
|
WelcomeMode::WelcomeMode() :
|
2011-08-03 12:58:39 +02:00
|
|
|
m_d(new WelcomeModePrivate),
|
|
|
|
m_priority(Core::Constants::P_MODE_WELCOME)
|
2011-02-05 23:35:18 +01:00
|
|
|
{
|
2012-02-11 00:58:30 +01:00
|
|
|
m_d->declarativeView = new QDeclarativeView;
|
|
|
|
m_d->declarativeView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
|
|
|
|
m_d->declarativeView->engine()->rootContext()->setContextProperty("welcomePlugin", this);
|
|
|
|
m_d->declarativeView->setSource(QUrl("qrc:/welcome/qml/main.qml"));
|
2011-02-05 23:35:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
WelcomeMode::~WelcomeMode()
|
|
|
|
{
|
2012-02-11 00:58:30 +01:00
|
|
|
delete m_d->declarativeView;
|
2011-02-05 23:35:18 +01:00
|
|
|
delete m_d;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString WelcomeMode::name() const
|
|
|
|
{
|
|
|
|
return tr("Welcome");
|
|
|
|
}
|
|
|
|
|
|
|
|
QIcon WelcomeMode::icon() const
|
|
|
|
{
|
2012-10-05 02:18:29 +02:00
|
|
|
return QIcon(QLatin1String(":/core/images/openpiloticon.png"));
|
2011-02-05 23:35:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int WelcomeMode::priority() const
|
|
|
|
{
|
2011-08-03 12:58:39 +02:00
|
|
|
return m_priority;
|
2011-02-05 23:35:18 +01:00
|
|
|
}
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
QWidget *WelcomeMode::widget()
|
2011-02-05 23:35:18 +01:00
|
|
|
{
|
2012-02-11 00:58:30 +01:00
|
|
|
return m_d->declarativeView;
|
2011-02-05 23:35:18 +01:00
|
|
|
}
|
|
|
|
|
2013-05-19 16:37:30 +02:00
|
|
|
const char *WelcomeMode::uniqueModeName() const
|
2011-02-05 23:35:18 +01:00
|
|
|
{
|
|
|
|
return Core::Constants::MODE_WELCOME;
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<int> WelcomeMode::context() const
|
|
|
|
{
|
|
|
|
static QList<int> contexts = QList<int>()
|
|
|
|
<< Core::UniqueIDManager::instance()->uniqueIdentifier(Core::Constants::C_WELCOME_MODE);
|
2013-05-19 16:37:30 +02:00
|
|
|
|
2011-02-05 23:35:18 +01:00
|
|
|
return contexts;
|
|
|
|
}
|
|
|
|
|
2012-02-11 00:58:30 +01:00
|
|
|
void WelcomeMode::openUrl(const QString &url)
|
2011-02-05 23:35:18 +01:00
|
|
|
{
|
2012-02-11 00:58:30 +01:00
|
|
|
QDesktopServices::openUrl(QUrl(url));
|
2011-02-05 23:35:18 +01:00
|
|
|
}
|
|
|
|
|
2012-02-11 00:58:30 +01:00
|
|
|
void WelcomeMode::openPage(const QString &page)
|
2011-02-05 23:35:18 +01:00
|
|
|
{
|
2012-05-30 17:46:45 +02:00
|
|
|
Core::ModeManager::instance()->activateModeByWorkspaceName(page);
|
2011-02-05 23:35:18 +01:00
|
|
|
}
|
|
|
|
|
2012-09-16 23:03:15 +02:00
|
|
|
void WelcomeMode::triggerAction(const QString &actionId)
|
|
|
|
{
|
|
|
|
Core::ModeManager::instance()->triggerAction(actionId);
|
|
|
|
}
|
2011-02-05 23:35:18 +01:00
|
|
|
} // namespace Welcome
|