~zeller-benjamin/qtcreator-plugin-ubuntu/qtc41-beta

« back to all changes in this revision

Viewing changes to src/ubuntu/ubuntuplugin.cpp

  • Committer: Juhapekka Piiroinen
  • Date: 2013-09-04 15:30:00 UTC
  • mto: (23.1.14 binary-plugin)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: juhapekka.piiroinen@canonical.com-20130904153000-r4lhfhrjlwmop277
Added cordova plugin from ubuntu-qtcreator-plugins.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Canonical Ltd.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 * Author: Juhapekka Piiroinen <juhapekka.piiroinen@canonical.com>
 
17
 */
 
18
 
 
19
#include "ubuntuplugin.h"
 
20
#include "ubuntuconstants.h"
 
21
#include "ubuntuprojectapplicationwizard.h"
 
22
 
 
23
#include <coreplugin/modemanager.h>
 
24
 
 
25
#include <QJsonDocument>
 
26
#include <QJsonArray>
 
27
#include <QJsonObject>
 
28
#include <QDebug>
 
29
#include <QFileInfo>
 
30
#include <QGuiApplication>
 
31
 
 
32
using namespace Ubuntu::Internal;
 
33
 
 
34
UbuntuPlugin::UbuntuPlugin()
 
35
{
 
36
 
 
37
}
 
38
 
 
39
UbuntuPlugin::~UbuntuPlugin()
 
40
{
 
41
 
 
42
}
 
43
 
 
44
bool UbuntuPlugin::initialize(const QStringList &arguments, QString *errorString)
 
45
{
 
46
    Q_UNUSED(arguments)
 
47
    Q_UNUSED(errorString)
 
48
 
 
49
    Core::MimeDatabase *mimeDB = Core::ICore::mimeDatabase();
 
50
 
 
51
    const QLatin1String mimetypesXml(":/ubuntu/UbuntuProject.mimetypes.xml");
 
52
 
 
53
    if (!mimeDB->addMimeTypes(mimetypesXml, errorString))
 
54
        return false;
 
55
 
 
56
    QJsonDocument jsonDoc = QJsonDocument::fromJson(Internal::UbuntuProjectApplicationWizard::getProjectTypesJSON());
 
57
    if (jsonDoc.isArray()) {
 
58
        QJsonArray array = jsonDoc.array();
 
59
        for (int idx = 0; idx < array.size(); idx++) {
 
60
            if (array.at(idx).isObject()) {
 
61
                QJsonObject obj = array.at(idx).toObject();
 
62
                QString folder;
 
63
                QJsonValue tmp_folder = obj.value(QLatin1String(Constants::UBUNTU_PROJECTJSON_FOLDER));
 
64
                if (tmp_folder.isUndefined() == false) {
 
65
                    folder = tmp_folder.toString();
 
66
                    if (QFileInfo(UbuntuProjectApplicationWizard::templatesPath(folder)).exists()) {
 
67
                        addAutoReleasedObject(new Internal::UbuntuProjectApplicationWizard(obj));
 
68
                    }
 
69
                }
 
70
            }
 
71
        }
 
72
    } else {
 
73
        qWarning() << __PRETTY_FUNCTION__ << "failed to read from JSON.";
 
74
    }
 
75
 
 
76
    m_ubuntuWelcomeMode = new UbuntuWelcomeMode;
 
77
    m_ubuntuDeviceMode = new UbuntuDeviceMode;
 
78
    m_ubuntuMenu = new UbuntuMenu;
 
79
    m_ubuntuIRCMode = new UbuntuIRCMode;
 
80
    m_ubuntuAPIMode = new UbuntuAPIMode;
 
81
    m_ubuntuCoreAppsMode = new UbuntuCoreAppsMode;
 
82
    m_ubuntuWikiMode = new UbuntuWikiMode;
 
83
    m_ubuntuPackagingMode = new UbuntuPackagingMode;
 
84
    m_ubuntuPastebinMode = new UbuntuPastebinMode;
 
85
 
 
86
    addAutoReleasedObject(m_ubuntuWelcomeMode);
 
87
    addAutoReleasedObject(m_ubuntuDeviceMode);
 
88
    addAutoReleasedObject(m_ubuntuMenu);
 
89
    addAutoReleasedObject(m_ubuntuIRCMode);
 
90
    addAutoReleasedObject(m_ubuntuAPIMode);
 
91
    addAutoReleasedObject(m_ubuntuCoreAppsMode);
 
92
    addAutoReleasedObject(m_ubuntuWikiMode);
 
93
    addAutoReleasedObject(m_ubuntuPackagingMode);
 
94
    addAutoReleasedObject(m_ubuntuPastebinMode);
 
95
 
 
96
    addAutoReleasedObject(new UbuntuVersionManager);
 
97
    addAutoReleasedObject(new UbuntuFeatureProvider);
 
98
 
 
99
    //addAutoReleasedObject(new UbuntuProjectManager);
 
100
    //addAutoReleasedObject(new UbuntuRunConfigurationFactory);
 
101
    //addAutoReleasedObject(new UbuntuRunControlFactory);
 
102
 
 
103
    return true;
 
104
}
 
105
 
 
106
void UbuntuPlugin::extensionsInitialized()
 
107
{
 
108
    m_ubuntuMenu->initialize();
 
109
    m_ubuntuWelcomeMode->initialize();
 
110
    m_ubuntuDeviceMode->initialize();
 
111
    m_ubuntuIRCMode->initialize();
 
112
    m_ubuntuAPIMode->initialize();
 
113
    m_ubuntuCoreAppsMode->initialize();
 
114
    m_ubuntuWikiMode->initialize();
 
115
    m_ubuntuPackagingMode->initialize();
 
116
    Core::ModeManager::activateMode(m_ubuntuWelcomeMode->id());
 
117
}
 
118
 
 
119
Q_EXPORT_PLUGIN2(Ubuntu, UbuntuPlugin)
 
120