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

« back to all changes in this revision

Viewing changes to ubuntumenu.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 "ubuntumenu.h"
20
 
#include "ubuntushared.h"
21
 
#include "ubuntuconstants.h"
22
 
#include "ubuntudeviceswidget.h"
23
 
 
24
 
#include <coreplugin/icore.h>
25
 
#include <coreplugin/icontext.h>
26
 
#include <coreplugin/actionmanager/command.h>
27
 
#include <coreplugin/actionmanager/actioncontainer.h>
28
 
#include <coreplugin/coreconstants.h>
29
 
#include <coreplugin/messagemanager.h>
30
 
#include <qt4projectmanager/qt4projectmanagerconstants.h>
31
 
#include <projectexplorer/projectexplorer.h>
32
 
#include <projectexplorer/project.h>
33
 
#include <projectexplorer/buildmanager.h>
34
 
#include <projectexplorer/compileoutputwindow.h>
35
 
#include <projectexplorer/iprojectmanager.h>
36
 
#include <utils/qtcprocess.h>
37
 
 
38
 
#include <QProcessEnvironment>
39
 
#include <QAction>
40
 
#include <QMenu>
41
 
#include <QInputDialog>
42
 
#include <QDebug>
43
 
#include <QMessageBox>
44
 
 
45
 
#include <QJsonObject>
46
 
#include <QJsonArray>
47
 
 
48
 
using namespace Ubuntu;
49
 
using namespace Ubuntu::Internal;
50
 
 
51
 
UbuntuMenu::UbuntuMenu(QObject *parent) :
52
 
    QObject(parent)
53
 
{
54
 
    m_obj = getMenuJSON();
55
 
 
56
 
    connect(&m_ubuntuProcess,SIGNAL(message(QString)),this,SLOT(onMessage(QString)));
57
 
    connect(&m_ubuntuProcess,SIGNAL(finished(QString,int)),this,SLOT(onFinished(QString,int)));
58
 
    connect(&m_ubuntuProcess,SIGNAL(started(QString)),this,SLOT(onStarted(QString)));
59
 
    connect(&m_ubuntuProcess,SIGNAL(error(QString)),this,SLOT(onError(QString)));
60
 
 
61
 
    connect(ProjectExplorer::ProjectExplorerPlugin::instance(),SIGNAL(updateRunActions()),this,SLOT(slotUpdateActions()));
62
 
    connect(UbuntuDevicesWidget::instance(),SIGNAL(updateDeviceActions()),this,SLOT(slotUpdateActions()));
63
 
}
64
 
 
65
 
 
66
 
void UbuntuMenu::slotUpdateActions() {
67
 
    ProjectExplorer::ProjectExplorerPlugin* projectExplorerInstance = ProjectExplorer::ProjectExplorerPlugin::instance();
68
 
    ProjectExplorer::Project* startupProject = projectExplorerInstance->startupProject();
69
 
    bool isQmlProject = false;
70
 
    bool isQmakeProject = false;
71
 
    bool isUbuntuProject = false;
72
 
    bool isCordovaProject = false;
73
 
 
74
 
    if (startupProject) {
75
 
        isQmlProject = (startupProject->projectManager()->mimeType() == QLatin1String("application/x-qmlproject"));
76
 
        isQmakeProject = (startupProject->projectManager()->mimeType() == QLatin1String("application/vnd.nokia.qt.qmakeprofile"));
77
 
        isCordovaProject = (startupProject->projectManager()->mimeType() == QLatin1String("application/x-cordovaproject"));
78
 
        isUbuntuProject = (startupProject->projectManager()->mimeType() == QLatin1String(Constants::UBUNTUPROJECT_MIMETYPE));
79
 
    }
80
 
 
81
 
    //bool canRun = projectExplorerInstance->canRun(startupProject,ProjectExplorer::NormalRunMode);
82
 
    bool projectOpen = (startupProject!=NULL);
83
 
    bool deviceDetected = UbuntuDevicesWidget::instance()->deviceDetected();
84
 
 
85
 
    foreach(QAction* act, m_actions) {
86
 
        bool requiresDevice = act->property(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED).toBool();
87
 
        bool requiresProject = act->property(Constants::UBUNTU_MENUJSON_PROJECTREQUIRED).toBool();
88
 
        bool requiresQmlProject = act->property(Constants::UBUNTU_MENUJSON_QMLPROJECTREQUIRED).toBool();
89
 
        bool requiresCordovaProject = act->property(Constants::UBUNTU_MENUJSON_CORDOVAPROJECTREQUIRED).toBool();
90
 
        bool requiresQmakeProject = act->property(Constants::UBUNTU_MENUJSON_QMAKEPROJECTREQUIRED).toBool();
91
 
        bool requiresUbuntuProject = act->property(Constants::UBUNTU_MENUJSON_UBUNTUPROJECTREQUIRED).toBool();
92
 
        bool actionEnabled = ( (requiresQmakeProject ? isQmakeProject : true) && (requiresQmlProject ? isQmlProject : true) && (requiresDevice ? deviceDetected : true) && (requiresProject ? projectOpen : true) && (requiresUbuntuProject ? isUbuntuProject : true) && (requiresCordovaProject ? isCordovaProject : true));
93
 
 
94
 
        act->setEnabled( actionEnabled );
95
 
    }
96
 
}
97
 
 
98
 
void UbuntuMenu::onStarted(QString cmd) {
99
 
    printToOutputPane(QString::fromLatin1("Started %0").arg(cmd));
100
 
}
101
 
 
102
 
void UbuntuMenu::onMessage(QString msg) {
103
 
    printToOutputPane(msg);
104
 
}
105
 
 
106
 
void UbuntuMenu::onError(QString msg) {
107
 
    printToOutputPane(QString::fromLatin1("%0").arg(msg));
108
 
}
109
 
 
110
 
void UbuntuMenu::onFinished(QString cmd, int code) {
111
 
    printToOutputPane(QString::fromLatin1("%0 finished with code %1").arg(cmd).arg(code));
112
 
}
113
 
 
114
 
QString UbuntuMenu::menuPath(QString fileName) {
115
 
    return Constants::UBUNTU_MENUPATH + fileName;
116
 
}
117
 
 
118
 
QJsonDocument UbuntuMenu::getMenuJSON() {
119
 
    QByteArray contents;
120
 
    QString errorMsg;
121
 
    if (readFile(menuPath(QLatin1String(Constants::UBUNTU_MENUJSON)),&contents, &errorMsg) == false) {
122
 
        qDebug() << __PRETTY_FUNCTION__ << errorMsg;
123
 
    }
124
 
    QJsonParseError error;
125
 
    QJsonDocument retval = QJsonDocument::fromJson(contents,&error);
126
 
    if (error.error != QJsonParseError::NoError) {
127
 
        qDebug() << error.errorString();
128
 
    }
129
 
    return retval;
130
 
}
131
 
 
132
 
void UbuntuMenu::parseMenu(QJsonObject obj, Core::ActionContainer*& parent, const Core::Id &group) {
133
 
    if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_SUBMENU))) {
134
 
        QString menuName, menuId;
135
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_NAME))) {
136
 
            menuName = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_NAME)).toString();
137
 
        }
138
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_ID))) {
139
 
            menuId = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_ID)).toString();
140
 
        }
141
 
        Core::ActionContainer *actionContainer = Core::ActionManager::createMenu(Core::Id(menuId));
142
 
        actionContainer->menu()->setTitle(menuName);
143
 
        actionContainer->menu()->setObjectName(menuId);
144
 
 
145
 
        QJsonValue submenu = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_SUBMENU));
146
 
        if (submenu.isArray()) {
147
 
            QJsonArray submenuArray = submenu.toArray();
148
 
            for (int idx=0; idx<submenuArray.size(); idx++) {
149
 
                QJsonValue subMenuItem = submenuArray.at(idx);
150
 
                if (subMenuItem.isObject()) {
151
 
                    parseMenu(subMenuItem.toObject(),actionContainer);
152
 
                }
153
 
            }
154
 
        }
155
 
 
156
 
        if (parent == NULL) {
157
 
            parent = actionContainer;
158
 
        } else {
159
 
            parent->addMenu(actionContainer,group);
160
 
        }
161
 
    } else if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_ACTIONS))) {
162
 
        QString actionName;
163
 
        QString actionId;
164
 
        QString actionKeySequence;
165
 
        QString actionWorkingDirectory;
166
 
        bool actionProjectRequired = false;
167
 
        bool actionDeviceRequired = false;
168
 
        bool actionQmlProjectRequired = false;
169
 
        bool actionQmakeProjectRequired = false;
170
 
        bool actionUbuntuProjectRequired = false;
171
 
        bool actionSaveRequired = false;
172
 
 
173
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_NAME))) {
174
 
            actionName = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_NAME)).toString();
175
 
        }
176
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_ID))) {
177
 
            actionId = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_ID)).toString();
178
 
        }
179
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_KEYSEQUENCE))) {
180
 
            actionKeySequence = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_KEYSEQUENCE)).toString();
181
 
        }
182
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_WORKINGDIRECTORY))) {
183
 
            actionWorkingDirectory = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_WORKINGDIRECTORY)).toString();
184
 
        }
185
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_PROJECTREQUIRED))) {
186
 
            actionProjectRequired = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_PROJECTREQUIRED)).toBool();
187
 
        }
188
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED))) {
189
 
            actionDeviceRequired = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED)).toBool();
190
 
        }
191
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_QMLPROJECTREQUIRED))) {
192
 
            actionQmlProjectRequired = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_QMLPROJECTREQUIRED)).toBool();
193
 
        }
194
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_QMAKEPROJECTREQUIRED))) {
195
 
            actionQmakeProjectRequired = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_QMAKEPROJECTREQUIRED)).toBool();
196
 
        }
197
 
 
198
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_UBUNTUPROJECTREQUIRED))) {
199
 
            actionUbuntuProjectRequired = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_UBUNTUPROJECTREQUIRED)).toBool();
200
 
        }
201
 
 
202
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_SAVEREQUIRED))) {
203
 
            actionSaveRequired = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_SAVEREQUIRED)).toBool();
204
 
        }
205
 
 
206
 
        if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_ACTIONS)) && obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_ACTIONS)).isArray()) {
207
 
 
208
 
            QJsonValue actions = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_ACTIONS));
209
 
            if (actions.isArray()) {
210
 
                QJsonArray actionsArray = actions.toArray();
211
 
                QJsonValueList actionsList;
212
 
                for (int idx=0; idx<actionsArray.size(); idx++) {
213
 
                    QJsonValue actionItem = actionsArray.at(idx);
214
 
                    actionsList.append(actionItem);
215
 
                }
216
 
                m_commandMap.insert(actionName,actionsList);
217
 
            }
218
 
        }
219
 
 
220
 
        QAction *act= new QAction(actionName, this);
221
 
        act->setObjectName(actionId);
222
 
 
223
 
        Core::Command *cmd = Core::ActionManager::registerAction(act, Core::Id(actionId), Core::Context(Core::Constants::C_GLOBAL));
224
 
        if (actionKeySequence.isEmpty() == false) {
225
 
            cmd->setDefaultKeySequence(QKeySequence(actionKeySequence));
226
 
        }
227
 
        if (actionWorkingDirectory.isEmpty() == false) {
228
 
            act->setProperty(Constants::UBUNTU_MENUJSON_WORKINGDIRECTORY,actionWorkingDirectory);
229
 
        }
230
 
 
231
 
        act->setProperty(Constants::UBUNTU_MENUJSON_PROJECTREQUIRED,actionProjectRequired);
232
 
        act->setProperty(Constants::UBUNTU_MENUJSON_DEVICEREQUIRED,actionDeviceRequired);
233
 
        act->setProperty(Constants::UBUNTU_MENUJSON_QMAKEPROJECTREQUIRED,actionQmakeProjectRequired);
234
 
        act->setProperty(Constants::UBUNTU_MENUJSON_QMLPROJECTREQUIRED,actionQmlProjectRequired);
235
 
        act->setProperty(Constants::UBUNTU_MENUJSON_UBUNTUPROJECTREQUIRED,actionUbuntuProjectRequired);
236
 
        act->setProperty(Constants::UBUNTU_MENUJSON_SAVEREQUIRED,actionSaveRequired);
237
 
 
238
 
        connect(act, SIGNAL(triggered()), this, SLOT(menuItemTriggered()));
239
 
        m_actions.append(act);
240
 
 
241
 
        if (parent == NULL) {
242
 
            qWarning() << "No menu defined";
243
 
        } else {
244
 
            parent->addAction(cmd,group);
245
 
        }
246
 
    }
247
 
 
248
 
}
249
 
 
250
 
void UbuntuMenu::menuItemTriggered() {
251
 
    QAction* act = qobject_cast<QAction*>(sender());
252
 
    if (act) {
253
 
 
254
 
        // if we are executing something now, then kill it!
255
 
        if (m_ubuntuProcess.state() != QProcess::NotRunning) {
256
 
            m_ubuntuProcess.stop();
257
 
        }
258
 
 
259
 
        QVariant projectRequired = act->property(Constants::UBUNTU_MENUJSON_PROJECTREQUIRED);
260
 
        ProjectExplorer::Project* project = NULL;
261
 
 
262
 
        if (projectRequired.isValid() && projectRequired.toBool() == true) {
263
 
            project = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject();
264
 
 
265
 
            if (project == NULL) {
266
 
                QMessageBox::information(Core::ICore::mainWindow(),QLatin1String(Constants::UBUNTU_DIALOG_NO_PROJECTOPEN_TITLE),QLatin1String(Constants::UBUNTU_DIALOG_NO_PROJECTOPEN_TEXT));
267
 
                return;
268
 
            }
269
 
        }
270
 
 
271
 
        QVariant saveModifiedFilesRequired = act->property(Constants::UBUNTU_MENUJSON_SAVEREQUIRED);
272
 
        if (saveModifiedFilesRequired.isValid() && saveModifiedFilesRequired.toBool()==true) {
273
 
            ProjectExplorer::ProjectExplorerPlugin::instance()->saveModifiedFiles();
274
 
        }
275
 
 
276
 
        if (m_commandMap.contains(act->text())) {
277
 
            QJsonValueList actions = m_commandMap.value(act->text());
278
 
 
279
 
            QString queryData;
280
 
            bool bQueryOk = false;
281
 
            bool bQuery = false;
282
 
 
283
 
            for (int idx=0; idx < actions.size(); idx++) {
284
 
                QJsonValue value = actions.at(idx);
285
 
                if (value.isObject()) {
286
 
                    QJsonObject obj = value.toObject();
287
 
 
288
 
                    // check if the object is a querydialog
289
 
                    if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_QUERYDIALOG))) {
290
 
                        QJsonValue queryDialog = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_QUERYDIALOG));
291
 
                        if (queryDialog.isObject()) {
292
 
                            QJsonObject queryDialogObj = queryDialog.toObject();
293
 
                            QString queryDialogTitle;
294
 
                            QString queryDialogMessage;
295
 
                            QString queryDialogValue;
296
 
 
297
 
                            if (queryDialogObj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_TITLE))) {
298
 
                                queryDialogTitle = queryDialogObj.value(QLatin1String(Constants::UBUNTU_MENUJSON_TITLE)).toString();
299
 
                            }
300
 
 
301
 
                            if (queryDialogObj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_MESSAGE))) {
302
 
                                queryDialogMessage = queryDialogObj.value(QLatin1String(Constants::UBUNTU_MENUJSON_MESSAGE)).toString();
303
 
                            }
304
 
 
305
 
                            if (queryDialogObj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_VALUE))) {
306
 
                                queryDialogValue = queryDialogObj.value(QLatin1String(Constants::UBUNTU_MENUJSON_VALUE)).toString();
307
 
                            }
308
 
 
309
 
                            queryData = QInputDialog::getText(Core::ICore::mainWindow(), queryDialogTitle,
310
 
                                                                     queryDialogMessage, QLineEdit::Normal,
311
 
                                                                     queryDialogValue, &bQueryOk);
312
 
 
313
 
                            // raise a flag that there is query data available for future actions
314
 
                            bQuery = true;
315
 
 
316
 
                            // if user has cancelled
317
 
                            if (bQueryOk == false) {
318
 
                                // clear queue
319
 
                                m_ubuntuProcess.clear();
320
 
                                return;
321
 
                            }
322
 
                        }
323
 
                    // check if messageDialog
324
 
                    } else if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_MESSAGEDIALOG))) {
325
 
                        QJsonValue messageDialog = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_MESSAGEDIALOG));
326
 
                        if (messageDialog.isObject()) {
327
 
                            QJsonObject messageDialogObj = messageDialog.toObject();
328
 
                            QString messageDialogTitle;
329
 
                            QString messageDialogMessage;
330
 
 
331
 
                            if (messageDialogObj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_TITLE))) {
332
 
                                messageDialogTitle = messageDialogObj.value(QLatin1String(Constants::UBUNTU_MENUJSON_TITLE)).toString();
333
 
                            }
334
 
 
335
 
                            if (messageDialogObj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_MESSAGE))) {
336
 
                                messageDialogMessage = messageDialogObj.value(QLatin1String(Constants::UBUNTU_MENUJSON_MESSAGE)).toString();
337
 
                            }
338
 
 
339
 
                            QMessageBox::information(Core::ICore::mainWindow(), messageDialogTitle,
340
 
                                                                     messageDialogMessage);
341
 
                        }
342
 
                    }
343
 
                // check if command
344
 
                } else if (value.isString()) {
345
 
                    QString command = value.toString();
346
 
                    QString workingDirectory;
347
 
 
348
 
                    if (project) {
349
 
 
350
 
                        QString projectDirectory = project->projectDirectory();
351
 
                        QString displayName = project->displayName();
352
 
                        QString folderName = QFileInfo(projectDirectory).baseName();
353
 
                        QStringList projectFiles = project->files(ProjectExplorer::Project::AllFiles);
354
 
 
355
 
                        QString workingDirectoryData = act->property(Constants::UBUNTU_MENUJSON_WORKINGDIRECTORY).toString();
356
 
                        if (workingDirectoryData.isEmpty() == false) {
357
 
                            workingDirectory = workingDirectoryData.arg(projectDirectory);
358
 
                        } else {
359
 
                            workingDirectory = projectDirectory;
360
 
                        }
361
 
                        command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_PROJECTDIRECTORY),projectDirectory);
362
 
                        command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_FOLDERNAME),folderName);
363
 
                        command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_DISPLAYNAME),displayName);
364
 
                        command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_PROJECTFILES),projectFiles.join(QLatin1String(" ")));
365
 
                    }
366
 
 
367
 
                    command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_SHAREDIRECTORY),Constants::UBUNTU_SHAREPATH);
368
 
                    command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_SCRIPTDIRECTORY),Constants::UBUNTU_SCRIPTPATH);
369
 
                    command = command.replace(QLatin1String(Constants::UBUNTU_ACTION_SERIALNUMBER),UbuntuDevicesWidget::instance()->serialNumber());
370
 
 
371
 
                    if (bQuery && bQueryOk) {
372
 
                        command = QString(command).arg(queryData);
373
 
                    }
374
 
 
375
 
                    QStringList cmdList;
376
 
                    cmdList << command << workingDirectory;
377
 
                    m_ubuntuProcess.append(cmdList);
378
 
                }
379
 
            }
380
 
            m_ubuntuProcess.start(act->text());
381
 
        } else {
382
 
            qWarning() << __PRETTY_FUNCTION__  << "No actions defined in map";
383
 
        }
384
 
    } else {
385
 
        qWarning() << __PRETTY_FUNCTION__  << "Could not cast to action";
386
 
    }
387
 
}
388
 
 
389
 
void UbuntuMenu::initialize() {
390
 
    if (m_obj.isObject()) {
391
 
        QJsonObject tmp = m_obj.object();
392
 
 
393
 
        foreach (QString key, tmp.keys()) {
394
 
            if (tmp.contains(key)) {
395
 
                QJsonObject obj = tmp.value(key).toObject();
396
 
 
397
 
                Core::ActionContainer *actionContainer = NULL;
398
 
 
399
 
                if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_PARENT))) {
400
 
                    QString parentValue = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_PARENT)).toString();
401
 
                    if (parentValue == QLatin1String(Constants::UBUNTU_MENUJSON_PARENT_TOOLS)) actionContainer = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
402
 
                    else if (parentValue == QLatin1String(Constants::UBUNTU_MENUJSON_PARENT_EDIT)) actionContainer = Core::ActionManager::actionContainer(Core::Constants::M_EDIT);
403
 
                    else if (parentValue == QLatin1String(Constants::UBUNTU_MENUJSON_PARENT_HELP)) actionContainer = Core::ActionManager::actionContainer(Core::Constants::M_HELP);
404
 
                    else if (parentValue == QLatin1String(Constants::UBUNTU_MENUJSON_PARENT_WINDOW)) actionContainer = Core::ActionManager::actionContainer(Core::Constants::M_WINDOW);
405
 
                    else if (parentValue == QLatin1String(Constants::UBUNTU_MENUJSON_PARENT_FILE)) actionContainer = Core::ActionManager::actionContainer(Core::Constants::M_FILE);
406
 
                    else if (parentValue == QLatin1String(Constants::UBUNTU_MENUJSON_PARENT_BUILD)) actionContainer = Core::ActionManager::actionContainer(ProjectExplorer::Constants::M_BUILDPROJECT);
407
 
                    else if (parentValue == QLatin1String(Constants::UBUNTU_MENUJSON_PARENT_TOP)) actionContainer = Core::ActionManager::actionContainer(Core::Constants::MENU_BAR);
408
 
                    else actionContainer = Core::ActionManager::actionContainer(Core::Id(parentValue));
409
 
                } else {
410
 
                    actionContainer = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
411
 
                }
412
 
 
413
 
                QString group;
414
 
                if (obj.contains(QLatin1String(Constants::UBUNTU_MENUJSON_GROUP))) {
415
 
                    group = obj.value(QLatin1String(Constants::UBUNTU_MENUJSON_GROUP)).toString();
416
 
                }
417
 
 
418
 
                Core::Id groupId;
419
 
                if (!group.isEmpty()) {
420
 
                    groupId = Core::Id(group);
421
 
                }
422
 
                parseMenu(obj,actionContainer,groupId);
423
 
            }
424
 
        }
425
 
    } else {
426
 
        qDebug() << "json is not valid";
427
 
    }
428
 
}