2
* Copyright 2013 Canonical Ltd.
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License as published by
6
* the Free Software Foundation; version 2.1.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
19
#include "ubuntuwelcomemode.h"
20
#include "ubuntuconstants.h"
22
#include <coreplugin/modemanager.h>
23
#include <QDeclarativeEngine>
24
#include <QDeclarativeContext>
25
#include <coreplugin/editormanager/editormanager.h>
26
#include <coreplugin/dialogs/iwizard.h>
27
#include <coreplugin/coreconstants.h>
28
#include <projectexplorer/projectexplorer.h>
29
#include <extensionsystem/pluginmanager.h>
30
#include <coreplugin/icore.h>
31
#include <coreplugin/imode.h>
32
#include <utils/styledbar.h>
33
#include <utils/iwelcomepage.h>
34
#include <extensionsystem/pluginmanager.h>
35
#include <coreplugin/dialogs/iwizard.h>
37
#include <QVBoxLayout>
38
#include <QScrollArea>
42
#include <QCoreApplication>
44
using namespace Ubuntu;
45
using namespace Ubuntu::Internal;
48
UbuntuWelcomeMode::UbuntuWelcomeMode(QObject *parent) : Core::IMode(parent),
49
m_declarativeView(new QDeclarativeView) {
50
setDisplayName(tr(Ubuntu::Constants::UBUNTU_MODE_WELCOME_DISPLAYNAME));
51
setIcon(QIcon(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_WELCOME_ICON)));
52
setPriority(Core::Constants::P_MODE_WELCOME);
53
setId(Ubuntu::Constants::UBUNTU_MODE_WELCOME);
54
setObjectName(QLatin1String(Ubuntu::Constants::UBUNTU_MODE_WELCOME));
56
QDeclarativeContext *context = m_declarativeView->rootContext();
57
context->setContextProperty(QLatin1String("welcomeMode"), this);
59
m_declarativeView->setResizeMode(QDeclarativeView::SizeRootObjectToView);
60
m_declarativeView->setMinimumWidth(860);
61
m_declarativeView->setMinimumHeight(548);
63
m_modeWidget = new QWidget;
64
QVBoxLayout *layout = new QVBoxLayout;
66
layout->setSpacing(0);
67
m_modeWidget->setLayout(layout);
69
Utils::StyledBar* styledBar = new Utils::StyledBar(m_modeWidget);
70
layout->addWidget(styledBar);
71
QScrollArea *scrollArea = new QScrollArea(m_modeWidget);
72
scrollArea->setFrameShape(QFrame::NoFrame);
73
layout->addWidget(scrollArea);
74
scrollArea->setWidget(m_declarativeView);
75
scrollArea->setWidgetResizable(true);
76
m_declarativeView->setMinimumWidth(860);
77
m_declarativeView->setMinimumHeight(548);
78
connect(Core::ModeManager::instance(), SIGNAL(currentModeChanged(Core::IMode*)), SLOT(modeChanged(Core::IMode*)));
79
ExtensionSystem::PluginManager *pluginManager = ExtensionSystem::PluginManager::instance();
80
connect(pluginManager, SIGNAL(objectAdded(QObject*)), SLOT(objectAdded(QObject*)));
82
setWidget(m_modeWidget);
83
//qDebug() << __PRETTY_FUNCTION__;
86
void UbuntuWelcomeMode::modeChanged(Core::IMode *mode) {
90
void UbuntuWelcomeMode::initialize() {
92
//qDebug() << __PRETTY_FUNCTION__;
93
QDeclarativeContext *context = m_declarativeView->rootContext();
94
context->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_welcomeTabPluginList));
96
m_declarativeView->setSource(QUrl::fromLocalFile(Constants::UBUNTU_WELCOMESCREEN_QML));
97
m_declarativeView->show();
98
// Load existing welcome screen plugins - start
99
/* QList<Utils::IWelcomePage*> loadedWelcomeScreenPlugins = ExtensionSystem::PluginManager::getObjects<Utils::IWelcomePage>();
101
QDeclarativeEngine *engine = m_declarativeView->engine();
104
QStringList importPathList = engine->importPathList();
105
importPathList << Core::ICore::resourcePath() + QLatin1String("/welcomescreen")
106
<< QDir::cleanPath(QCoreApplication::applicationDirPath() + QLatin1String("/../" IDE_LIBRARY_BASENAME "/qtcreator"));
107
engine->setImportPathList(importPathList);
108
qDebug() << engine->importPathList();
109
qDebug() << "Checking for loaded plugins";
110
foreach (Utils::IWelcomePage *plugin, loadedWelcomeScreenPlugins) {
111
qDebug() << "Load welcomepage plugin: " << plugin->title();
112
plugin->facilitateQml(engine);
113
m_welcomeTabPluginList.append(plugin);
115
context->setContextProperty(QLatin1String("pagesModel"), QVariant::fromValue(m_welcomeTabPluginList));
116
qDebug() << "check complete";*/
121
void UbuntuWelcomeMode::objectAdded(QObject* obj) {
123
//qDebug() << __PRETTY_FUNCTION__;
127
void UbuntuWelcomeMode::newProject() {
128
Core::ICore::showNewItemDialog(tr("New Project"), Core::IWizard::wizardsOfKind(Core::IWizard::ProjectWizard));
131
void UbuntuWelcomeMode::openProject() {
132
ProjectExplorer::ProjectExplorerPlugin::instance()->openOpenProjectDialog();