projectexplorer.cpp 114 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12
13
14
15
16
17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21
22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23
24
25
26
27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
29
** Nokia at qt-info@nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

33
#include "projectexplorer.h"
Tobias Hunger's avatar
Tobias Hunger committed
34

Tobias Hunger's avatar
Tobias Hunger committed
35
36
#include "buildsteplist.h"
#include "deployconfiguration.h"
37
#include "gcctoolchainfactories.h"
38
#include "project.h"
39
#include "projectexplorersettings.h"
Tobias Hunger's avatar
Tobias Hunger committed
40
41
#include "target.h"
#include "targetsettingspanel.h"
42
43
#include "toolchainmanager.h"
#include "toolchainoptionspage.h"
44
#include "copytaskhandler.h"
45
#include "showineditortaskhandler.h"
46
#include "vcsannotatetaskhandler.h"
47
#include "localapplicationruncontrol.h"
con's avatar
con committed
48
49
50
51
#include "allprojectsfilter.h"
#include "allprojectsfind.h"
#include "buildmanager.h"
#include "buildsettingspropertiespage.h"
52
#include "currentprojectfind.h"
con's avatar
con committed
53
54
#include "currentprojectfilter.h"
#include "customexecutablerunconfiguration.h"
55
#include "editorsettingspropertiespage.h"
56
#include "codestylesettingspropertiespage.h"
57
#include "dependenciespanel.h"
con's avatar
con committed
58
59
60
61
#include "foldernavigationwidget.h"
#include "iprojectmanager.h"
#include "metatypedeclarations.h"
#include "nodesvisitor.h"
62
#include "appoutputpane.h"
con's avatar
con committed
63
64
65
#include "pluginfilefactory.h"
#include "processstep.h"
#include "projectexplorerconstants.h"
66
#include "customwizard.h"
con's avatar
con committed
67
68
69
70
71
72
#include "projectfilewizardextension.h"
#include "projecttreewidget.h"
#include "projectwindow.h"
#include "removefiledialog.h"
#include "runsettingspropertiespage.h"
#include "session.h"
73
#include "projectnodes.h"
con's avatar
con committed
74
#include "sessiondialog.h"
Tobias Hunger's avatar
Tobias Hunger committed
75
#include "target.h"
76
#include "projectexplorersettingspage.h"
77
#include "projectwelcomepage.h"
78
#include "corelistenercheckingforrunningbuild.h"
79
#include "buildconfiguration.h"
80
#include "miniprojecttargetselector.h"
dt's avatar
dt committed
81
#include "taskhub.h"
82
83
#include "publishing/ipublishingwizardfactory.h"
#include "publishing/publishingwizardselectiondialog.h"
con's avatar
con committed
84

85
#ifdef Q_OS_WIN
86
#    include "windebuginterface.h"
87
#    include "msvctoolchain.h"
SteveKing's avatar
SteveKing committed
88
#    include "wincetoolchain.h"
89
90
#endif

91
#include <extensionsystem/pluginspec.h>
con's avatar
con committed
92
#include <coreplugin/coreconstants.h>
93
94
#include <coreplugin/filemanager.h>
#include <coreplugin/icore.h>
95
#include <coreplugin/imode.h>
con's avatar
con committed
96
97
#include <coreplugin/mimedatabase.h>
#include <coreplugin/modemanager.h>
98
#include <coreplugin/actionmanager/actionmanager.h>
99
100
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
101
#include <coreplugin/id.h>
con's avatar
con committed
102
103
104
105
106
107
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/basefilewizard.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/iversioncontrol.h>
108
#include <coreplugin/variablemanager.h>
Robert Loehning's avatar
Robert Loehning committed
109
#include <coreplugin/fileutils.h>
110
#include <extensionsystem/pluginmanager.h>
111
#include <find/searchresultwindow.h>
112
#include <utils/consoleprocess.h>
hjk's avatar
hjk committed
113
#include <utils/qtcassert.h>
114
#include <utils/parameteraction.h>
115
#include <utils/stringutils.h>
Jarek Kobus's avatar
Jarek Kobus committed
116
#include <utils/persistentsettings.h>
con's avatar
con committed
117

118
119
120
121
122
#include <QtPlugin>
#include <QDateTime>
#include <QDebug>
#include <QSettings>
#include <QAbstractFileEngine>
hjk's avatar
hjk committed
123

124
125
126
127
128
129
130
#include <QAction>
#include <QApplication>
#include <QFileDialog>
#include <QMenu>
#include <QMessageBox>
#include <QMainWindow>
#include <QWizard>
con's avatar
con committed
131

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*!
    \namespace ProjectExplorer
    ProjectExplorer plugin namespace
*/

/*!
    \namespace ProjectExplorer::Internal
    Internal namespace of the ProjectExplorer plugin
    \internal
*/

/*!
    \class ProjectExplorer::ProjectExplorerPlugin

    \brief ProjectExplorerPlugin with static accessor and utility functions to obtain
    current project, open projects, etc.
*/

con's avatar
con committed
150
151
152
153
namespace {
bool debug = false;
}

154
155
static const char kCurrentProjectPath[] = "CurrentProject:Path";
static const char kCurrentProjectFilePath[] = "CurrentProject:FilePath";
con's avatar
con committed
156

157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
namespace ProjectExplorer {

struct ProjectExplorerPluginPrivate {
    ProjectExplorerPluginPrivate();

    QMenu *m_sessionContextMenu;
    QMenu *m_sessionMenu;
    QMenu *m_projectMenu;
    QMenu *m_subProjectMenu;
    QMenu *m_folderMenu;
    QMenu *m_fileMenu;
    QMenu *m_openWithMenu;

    QMultiMap<int, QObject*> m_actionMap;
    QAction *m_sessionManagerAction;
    QAction *m_newAction;
    QAction *m_loadAction;
174
    Utils::ParameterAction *m_unloadAction;
175
    QAction *m_closeAllProjects;
176
    QAction *m_buildProjectOnlyAction;
177
    Utils::ParameterAction *m_buildAction;
178
    Utils::ParameterAction *m_buildActionContextMenu;
179
180
    QAction *m_buildSessionAction;
    QAction *m_rebuildProjectOnlyAction;
181
    Utils::ParameterAction *m_rebuildAction;
182
    Utils::ParameterAction *m_rebuildActionContextMenu;
183
184
    QAction *m_rebuildSessionAction;
    QAction *m_cleanProjectOnlyAction;
Tobias Hunger's avatar
Tobias Hunger committed
185
186
187
188
    QAction *m_deployProjectOnlyAction;
    Utils::ParameterAction *m_deployAction;
    Utils::ParameterAction *m_deployActionContextMenu;
    QAction *m_deploySessionAction;
189
    Utils::ParameterAction *m_publishAction;
190
    Utils::ParameterAction *m_cleanAction;
191
    Utils::ParameterAction *m_cleanActionContextMenu;
192
193
194
    QAction *m_cleanSessionAction;
    QAction *m_runAction;
    QAction *m_runActionContextMenu;
195
    QAction *m_runWithoutDeployAction;
196
197
198
    QAction *m_cancelBuildAction;
    QAction *m_addNewFileAction;
    QAction *m_addExistingFilesAction;
199
    QAction *m_addNewSubprojectAction;
200
    QAction *m_removeFileAction;
201
    QAction *m_removeProjectAction;
202
    QAction *m_deleteFileAction;
203
    QAction *m_renameFileAction;
dt's avatar
dt committed
204
    QAction *m_openFileAction;
205
    QAction *m_projectTreeCollapseAllAction;
206
    QAction *m_searchOnFileSystem;
dt's avatar
dt committed
207
208
    QAction *m_showInGraphicalShell;
    QAction *m_openTerminalHere;
209
    QAction *m_setStartupProjectAction;
210
    QAction *m_projectSelectorAction;
211
    QAction *m_projectSelectorActionMenu;
Daniel Teske's avatar
Daniel Teske committed
212
    QAction *m_projectSelectorActionQuick;
dt's avatar
dt committed
213
    QAction *m_runSubProject;
214
215
216
217
218
219
220
221
222
223
224
225

    Internal::ProjectWindow *m_proWindow;
    SessionManager *m_session;
    QString m_sessionToRestoreAtStartup;

    Project *m_currentProject;
    Node *m_currentNode;

    BuildManager *m_buildManager;

    QList<Internal::ProjectFileFactory*> m_fileFactories;
    QStringList m_profileMimeTypes;
226
    Internal::AppOutputPane *m_outputPane;
227
228
229
230
231

    QList<QPair<QString, QString> > m_recentProjects; // pair of filename, displayname
    static const int m_maxRecentProjects = 7;

    QString m_lastOpenDirectory;
232
    RunConfiguration *m_delayedRunConfiguration; // TODO this is not right
233
    RunMode m_runMode;
234
    QString m_projectFilterString;
235
    Internal::MiniProjectTargetSelector * m_targetSelector;
236
    Internal::ProjectExplorerSettings m_projectExplorerSettings;
237
    Internal::ProjectWelcomePage *m_welcomePage;
238

239
    Core::IMode *m_projectsMode;
240
241

    ToolChainManager *m_toolChainManager;
242
    TaskHub *m_taskHub;
243
244
245
246
247
248
};

ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
    m_currentProject(0),
    m_currentNode(0),
    m_delayedRunConfiguration(0),
249
    m_runMode(NoRunMode),
250
251
    m_projectsMode(0),
    m_toolChainManager(0)
252
253
254
{
}

255
256
257
class ProjectsMode : public Core::IMode
{
public:
258
259
260
261
    ProjectsMode(QWidget *proWindow)
    {
        setWidget(proWindow);
        setContext(Core::Context(Constants::C_PROJECTEXPLORER));
262
263
264
265
266
267
        setDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectsMode", "Projects"));
        setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Project.png")));
        setPriority(Constants::P_MODE_SESSION);
        setId(QLatin1String(Constants::MODE_SESSION));
        setType(QString());
        setContextHelpId(QLatin1String("Managing Projects"));
268
    }
269
270
};

271
272
}  // namespace ProjectExplorer

con's avatar
con committed
273
274
275
276
277
278
279
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;


ProjectExplorerPlugin *ProjectExplorerPlugin::m_instance = 0;

ProjectExplorerPlugin::ProjectExplorerPlugin()
280
    : d(new ProjectExplorerPluginPrivate)
con's avatar
con committed
281
282
283
284
285
286
{
    m_instance = this;
}

ProjectExplorerPlugin::~ProjectExplorerPlugin()
{
287
288
    removeObject(d->m_welcomePage);
    delete d->m_welcomePage;
289
    delete d->m_toolChainManager;
con's avatar
con committed
290
    removeObject(this);
291
    delete d;
con's avatar
con committed
292
293
294
295
296
297
298
}

ProjectExplorerPlugin *ProjectExplorerPlugin::instance()
{
    return m_instance;
}

299
300
301
302
303
304
bool ProjectExplorerPlugin::parseArguments(const QStringList &arguments, QString * /* error */)
{
    CustomWizard::setVerbose(arguments.count(QLatin1String("-customwizard-verbose")));
    return true;
}

305
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
con's avatar
con committed
306
{
Friedemann Kleint's avatar
Friedemann Kleint committed
307
308
    qRegisterMetaType<ProjectExplorer::RunControl *>();

309
310
    if (!parseArguments(arguments, error))
        return false;
dt's avatar
dt committed
311
312
    addObject(this);

313
    // Add ToolChainFactories:
314
#ifdef Q_OS_WIN
315
316
    addAutoReleasedObject(new WinDebugInterface);

317
    addAutoReleasedObject(new Internal::MsvcToolChainFactory);
SteveKing's avatar
SteveKing committed
318
    addAutoReleasedObject(new Internal::WinCEToolChainFactory);
319
320
321
#else
    addAutoReleasedObject(new Internal::GccToolChainFactory);
    addAutoReleasedObject(new Internal::LinuxIccToolChainFactory);
Tobias Hunger's avatar
Tobias Hunger committed
322
323
324
#endif
#ifndef Q_OS_MAC
    addAutoReleasedObject(new Internal::MingwToolChainFactory); // Mingw offers cross-compiling to windows
325
#endif
Tobias Hunger's avatar
Tobias Hunger committed
326
    addAutoReleasedObject(new Internal::ClangToolChainFactory);
327
328
329
330
331

    d->m_toolChainManager = new ToolChainManager(this);

    addAutoReleasedObject(new Internal::ToolChainOptionsPage);

332
333
    d->m_taskHub = new TaskHub;
    addAutoReleasedObject(d->m_taskHub);
334

hjk's avatar
hjk committed
335
336
    Core::ActionManager *am = Core::ICore::actionManager();
    connect(Core::ICore::instance(), SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards()));
con's avatar
con committed
337

338
    d->m_welcomePage = new ProjectWelcomePage;
339
    connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
340
    addObject(d->m_welcomePage);
con's avatar
con committed
341

342
    connect(Core::FileManager::instance(), SIGNAL(currentFileChanged(QString)),
hjk's avatar
hjk committed
343
            this, SLOT(setCurrentFile(QString)));
con's avatar
con committed
344

345
    d->m_session = new SessionManager(this);
con's avatar
con committed
346

347
    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project *)),
con's avatar
con committed
348
            this, SIGNAL(fileListChanged()));
349
    connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
con's avatar
con committed
350
            this, SLOT(invalidateProject(ProjectExplorer::Project *)));
351
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
con's avatar
con committed
352
            this, SIGNAL(fileListChanged()));
353
354
355
356
    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
            this, SLOT(projectAdded(ProjectExplorer::Project*)));
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
            this, SLOT(projectRemoved(ProjectExplorer::Project*)));
357
    connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project *)),
con's avatar
con committed
358
            this, SLOT(startupProjectChanged()));
359
360
    connect(d->m_session, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
            this, SLOT(updateActions()));
361
    connect(d->m_session, SIGNAL(sessionLoaded(QString)),
362
            this, SLOT(updateActions()));
363
    connect(d->m_session, SIGNAL(sessionLoaded(QString)),
364
            this, SLOT(updateWelcomePage()));
con's avatar
con committed
365

366
    d->m_proWindow = new ProjectWindow;
con's avatar
con committed
367

368
    Core::Context globalcontext(Core::Constants::C_GLOBAL);
dt's avatar
dt committed
369
    Core::Context projecTreeContext(Constants::C_PROJECT_TREE);
con's avatar
con committed
370

371
    d->m_projectsMode = new ProjectsMode(d->m_proWindow);
372
373
    d->m_projectsMode->setEnabled(session()->startupProject());
    addAutoReleasedObject(d->m_projectsMode);
374
    d->m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(d->m_proWindow));
con's avatar
con committed
375

376
    addAutoReleasedObject(new CopyTaskHandler);
377
    addAutoReleasedObject(new ShowInEditorTaskHandler);
378
    addAutoReleasedObject(new VcsAnnotateTaskHandler);
379

380
381
    d->m_buildManager = new BuildManager(this);
    connect(d->m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
con's avatar
con committed
382
            this, SLOT(buildStateChanged(ProjectExplorer::Project *)));
383
    connect(d->m_buildManager, SIGNAL(buildQueueFinished(bool)),
con's avatar
con committed
384
385
            this, SLOT(buildQueueFinished(bool)));

386
    addAutoReleasedObject(new CoreListener);
con's avatar
con committed
387

388
    d->m_outputPane = new AppOutputPane;
389
390
391
    addAutoReleasedObject(d->m_outputPane);
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
            d->m_outputPane, SLOT(projectRemoved()));
con's avatar
con committed
392

393
394
395
396
397
    connect(d->m_outputPane, SIGNAL(runControlStarted(ProjectExplorer::RunControl*)),
            this, SIGNAL(runControlStarted(ProjectExplorer::RunControl*)));
    connect(d->m_outputPane, SIGNAL(runControlFinished(ProjectExplorer::RunControl*)),
            this, SIGNAL(runControlFinished(ProjectExplorer::RunControl*)));

398
    AllProjectsFilter *allProjectsFilter = new AllProjectsFilter(this);
con's avatar
con committed
399
400
    addAutoReleasedObject(allProjectsFilter);

401
    CurrentProjectFilter *currentProjectFilter = new CurrentProjectFilter(this);
con's avatar
con committed
402
403
404
405
406
    addAutoReleasedObject(currentProjectFilter);

    addAutoReleasedObject(new BuildSettingsPanelFactory);
    addAutoReleasedObject(new RunSettingsPanelFactory);
    addAutoReleasedObject(new EditorSettingsPanelFactory);
407
    addAutoReleasedObject(new CodeStyleSettingsPanelFactory);
408
    addAutoReleasedObject(new DependenciesPanelFactory(d->m_session));
con's avatar
con committed
409
410
411
412

    ProcessStepFactory *processStepFactory = new ProcessStepFactory;
    addAutoReleasedObject(processStepFactory);

413
    AllProjectsFind *allProjectsFind = new AllProjectsFind(this);
con's avatar
con committed
414
415
    addAutoReleasedObject(allProjectsFind);

416
    CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this);
con's avatar
con committed
417
418
    addAutoReleasedObject(currentProjectFind);

419
    addAutoReleasedObject(new LocalApplicationRunControlFactory);
con's avatar
con committed
420
421
    addAutoReleasedObject(new CustomExecutableRunConfigurationFactory);

422
    addAutoReleasedObject(new ProjectFileWizardExtension);
con's avatar
con committed
423

424
425
426
    // Settings page
    addAutoReleasedObject(new ProjectExplorerSettingsPage);

con's avatar
con committed
427
    // context menus
428
    Core::ActionContainer *msessionContextMenu =
con's avatar
con committed
429
        am->createMenu(Constants::M_SESSIONCONTEXT);
dt's avatar
dt committed
430
    Core::ActionContainer *mprojectContextMenu =
con's avatar
con committed
431
        am->createMenu(Constants::M_PROJECTCONTEXT);
dt's avatar
dt committed
432
    Core::ActionContainer *msubProjectContextMenu =
con's avatar
con committed
433
        am->createMenu(Constants::M_SUBPROJECTCONTEXT);
dt's avatar
dt committed
434
    Core::ActionContainer *mfolderContextMenu =
con's avatar
con committed
435
        am->createMenu(Constants::M_FOLDERCONTEXT);
dt's avatar
dt committed
436
    Core::ActionContainer *mfileContextMenu =
con's avatar
con committed
437
438
        am->createMenu(Constants::M_FILECONTEXT);

439
    d->m_sessionContextMenu = msessionContextMenu->menu();
dt's avatar
dt committed
440
441
442
443
    d->m_projectMenu = mprojectContextMenu->menu();
    d->m_subProjectMenu = msubProjectContextMenu->menu();
    d->m_folderMenu = mfolderContextMenu->menu();
    d->m_fileMenu = mfileContextMenu->menu();
con's avatar
con committed
444

445
    Core::ActionContainer *mfile =
con's avatar
con committed
446
        am->actionContainer(Core::Constants::M_FILE);
447
    Core::ActionContainer *menubar =
con's avatar
con committed
448
449
450
        am->actionContainer(Core::Constants::MENU_BAR);

    // build menu
451
    Core::ActionContainer *mbuild =
con's avatar
con committed
452
        am->createMenu(Constants::M_BUILDPROJECT);
453
    mbuild->menu()->setTitle(tr("&Build"));
con's avatar
con committed
454
455
456
    menubar->addMenu(mbuild, Core::Constants::G_VIEW);

    // debug menu
457
    Core::ActionContainer *mdebug =
con's avatar
con committed
458
        am->createMenu(Constants::M_DEBUG);
459
    mdebug->menu()->setTitle(tr("&Debug"));
con's avatar
con committed
460
461
    menubar->addMenu(mdebug, Core::Constants::G_VIEW);

462
463
464
465
    Core::ActionContainer *mstartdebugging =
        am->createMenu(Constants::M_DEBUG_STARTDEBUGGING);
    mstartdebugging->menu()->setTitle(tr("&Start Debugging"));
    mdebug->addMenu(mstartdebugging, Core::Constants::G_DEFAULT_ONE);
con's avatar
con committed
466
467
468
469
470
471
472
473
474

    //
    // Groups
    //

    mbuild->appendGroup(Constants::G_BUILD_SESSION);
    mbuild->appendGroup(Constants::G_BUILD_PROJECT);
    mbuild->appendGroup(Constants::G_BUILD_OTHER);
    mbuild->appendGroup(Constants::G_BUILD_CANCEL);
dt's avatar
dt committed
475
    mbuild->appendGroup(Constants::G_BUILD_RUN);
con's avatar
con committed
476
477
478
479
480

    msessionContextMenu->appendGroup(Constants::G_SESSION_BUILD);
    msessionContextMenu->appendGroup(Constants::G_SESSION_FILES);
    msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER);
    msessionContextMenu->appendGroup(Constants::G_SESSION_CONFIG);
481
    msessionContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
482

dt's avatar
dt committed
483
484
485
486
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
487
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
488
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
489

dt's avatar
dt committed
490
491
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
dt's avatar
dt committed
492
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
dt's avatar
dt committed
493
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
494
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
495
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
496

hjk's avatar
hjk committed
497
    Core::ActionContainer *runMenu = Core::ICore::actionManager()->createMenu(Constants::RUNMENUCONTEXTMENU);
dt's avatar
dt committed
498
    runMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
Friedemann Kleint's avatar
Friedemann Kleint committed
499
    QIcon runIcon = QIcon(QLatin1String(Constants::ICON_RUN));
500
    runIcon.addFile(QLatin1String(Constants::ICON_RUN_SMALL));
dt's avatar
dt committed
501
    runMenu->menu()->setIcon(runIcon);
502
    runMenu->menu()->setTitle(tr("Run"));
dt's avatar
dt committed
503
504
    msubProjectContextMenu->addMenu(runMenu, ProjectExplorer::Constants::G_PROJECT_RUN);

dt's avatar
dt committed
505
506
507
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
508
    mfolderContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
509

dt's avatar
dt committed
510
511
512
    mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
    mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
    mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
513
    mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
514
    // "open with" submenu
515
    Core::ActionContainer * const openWith =
con's avatar
con committed
516
            am->createMenu(ProjectExplorer::Constants::M_OPENFILEWITHCONTEXT);
517
    openWith->setOnAllDisabledBehavior(Core::ActionContainer::Show);
518
519
    d->m_openWithMenu = openWith->menu();
    d->m_openWithMenu->setTitle(tr("Open With"));
con's avatar
con committed
520

521
    connect(d->m_openWithMenu, SIGNAL(triggered(QAction *)),
522
            Core::FileManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)));
con's avatar
con committed
523
524
525
526
527

    //
    // Separators
    //

con's avatar
con committed
528
    Core::Command *cmd;
con's avatar
con committed
529
530
531
532
    QAction *sep;

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
533
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Build.Sep"), globalcontext);
con's avatar
con committed
534
535
536
537
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
538
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Files.Sep"), projecTreeContext);
con's avatar
con committed
539
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);
dt's avatar
dt committed
540
541
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
con's avatar
con committed
542
543
544

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
545
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Config.Sep"), projecTreeContext);
con's avatar
con committed
546
547
548
549
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_CONFIG);

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
550
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Projects.Sep"), globalcontext);
con's avatar
con committed
551
552
553
554
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
555
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Other.Sep"), globalcontext);
con's avatar
con committed
556
557
558
559
560
    mbuild->addAction(cmd, Constants::G_BUILD_OTHER);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_OTHER);

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
561
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Run.Sep"), globalcontext);
con's avatar
con committed
562
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
dt's avatar
dt committed
563
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
con's avatar
con committed
564
565
566

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
567
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.CancelBuild.Sep"), globalcontext);
con's avatar
con committed
568
569
570
571
572
573
574
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    //
    // Actions
    //

    // new action
575
576
    d->m_newAction = new QAction(tr("New Project..."), this);
    cmd = am->registerAction(d->m_newAction, Constants::NEWPROJECT, globalcontext);
con's avatar
con committed
577
578
579
580
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+N")));
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // open action
581
582
    d->m_loadAction = new QAction(tr("Load Project..."), this);
    cmd = am->registerAction(d->m_loadAction, Constants::LOAD, globalcontext);
583
#ifndef Q_OS_MAC
con's avatar
con committed
584
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+O")));
585
#endif
con's avatar
con committed
586
587
588
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // Default open action
589
590
    d->m_openFileAction = new QAction(tr("Open File"), this);
    cmd = am->registerAction(d->m_openFileAction, ProjectExplorer::Constants::OPENFILE,
dt's avatar
dt committed
591
592
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
con's avatar
con committed
593

594
595
596
597
598
599
    d->m_searchOnFileSystem = new QAction(FolderNavigationWidget::msgFindOnFileSystem(), this);
    cmd = am->registerAction(d->m_searchOnFileSystem, ProjectExplorer::Constants::SEARCHONFILESYSTEM, projecTreeContext);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_CONFIG);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);

600
    d->m_showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), this);
601
    cmd = am->registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
dt's avatar
dt committed
602
603
604
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
605

606
    d->m_openTerminalHere = new QAction(Core::FileUtils::msgTerminalAction(), this);
607
    cmd = am->registerAction(d->m_openTerminalHere, ProjectExplorer::Constants::OPENTERMIANLHERE,
dt's avatar
dt committed
608
609
610
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
611

con's avatar
con committed
612
    // Open With menu
dt's avatar
dt committed
613
    mfileContextMenu->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN);
con's avatar
con committed
614

mae's avatar
mae committed
615
    // recent projects menu
616
    Core::ActionContainer *mrecent =
mae's avatar
mae committed
617
        am->createMenu(Constants::M_RECENTPROJECTS);
618
    mrecent->menu()->setTitle(tr("Recent P&rojects"));
619
    mrecent->setOnAllDisabledBehavior(Core::ActionContainer::Show);
mae's avatar
mae committed
620
621
622
623
    mfile->addMenu(mrecent, Core::Constants::G_FILE_OPEN);
    connect(mfile->menu(), SIGNAL(aboutToShow()),
        this, SLOT(updateRecentProjectMenu()));

624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
    // recent session menu
    Core::ActionContainer *msession = am->createMenu(Constants::M_SESSION);
    msession->menu()->setTitle(tr("Recent Sessions"));
    msession->setOnAllDisabledBehavior(Core::ActionContainer::Show);
    mfile->addMenu(msession, Core::Constants::G_FILE_OPEN);
    d->m_sessionMenu = msession->menu();
    connect(mfile->menu(), SIGNAL(aboutToShow()),
            this, SLOT(updateSessionMenu()));

    // session manager action
    d->m_sessionManagerAction = new QAction(tr("Session Manager..."), this);
    cmd = am->registerAction(d->m_sessionManagerAction, Constants::NEWSESSION, globalcontext);
    mfile->addAction(cmd, Core::Constants::G_FILE_OPEN);
    cmd->setDefaultKeySequence(QKeySequence());


dt's avatar
dt committed
640
    // XXX same action?
con's avatar
con committed
641
    // unload action
642
643
    d->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""),
                                                      Utils::ParameterAction::EnabledWithParameter, this);
644
    cmd = am->registerAction(d->m_unloadAction, Constants::UNLOAD, globalcontext);
con's avatar
con committed
645
    cmd->setAttribute(Core::Command::CA_UpdateText);
646
    cmd->setDescription(d->m_unloadAction->text());
con's avatar
con committed
647
648
649
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    // unload session action
650
651
    d->m_closeAllProjects = new QAction(tr("Close All Projects"), this);
    cmd = am->registerAction(d->m_closeAllProjects, Constants::CLEARSESSION, globalcontext);
con's avatar
con committed
652
653
654
655
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // build session action
Friedemann Kleint's avatar
Friedemann Kleint committed
656
    QIcon buildIcon = QIcon(QLatin1String(Constants::ICON_BUILD));
657
    buildIcon.addFile(QLatin1String(Constants::ICON_BUILD_SMALL));
658
659
    d->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
    cmd = am->registerAction(d->m_buildSessionAction, Constants::BUILDSESSION, globalcontext);
con's avatar
con committed
660
661
662
663
664
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // rebuild session action
Friedemann Kleint's avatar
Friedemann Kleint committed
665
    QIcon rebuildIcon = QIcon(QLatin1String(Constants::ICON_REBUILD));
666
    rebuildIcon.addFile(QLatin1String(Constants::ICON_REBUILD_SMALL));
667
668
    d->m_rebuildSessionAction = new QAction(rebuildIcon, tr("Rebuild All"), this);
    cmd = am->registerAction(d->m_rebuildSessionAction, Constants::REBUILDSESSION, globalcontext);
con's avatar
con committed
669
670
671
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

Tobias Hunger's avatar
Tobias Hunger committed
672
673
674
675
676
677
    // deploy session
    d->m_deploySessionAction = new QAction(tr("Deploy All"), this);
    cmd = am->registerAction(d->m_deploySessionAction, Constants::DEPLOYSESSION, globalcontext);
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

con's avatar
con committed
678
    // clean session
Friedemann Kleint's avatar
Friedemann Kleint committed
679
    QIcon cleanIcon = QIcon(QLatin1String(Constants::ICON_CLEAN));
680
    cleanIcon.addFile(QLatin1String(Constants::ICON_CLEAN_SMALL));
681
682
    d->m_cleanSessionAction = new QAction(cleanIcon, tr("Clean All"), this);
    cmd = am->registerAction(d->m_cleanSessionAction, Constants::CLEANSESSION, globalcontext);
con's avatar
con committed
683
684
685
686
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // build action
687
    d->m_buildAction = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""),
688
                                                     Utils::ParameterAction::AlwaysEnabled, this);
dt's avatar
dt committed
689
    d->m_buildAction->setIcon(buildIcon);
690
    cmd = am->registerAction(d->m_buildAction, Constants::BUILD, globalcontext);
691
    cmd->setAttribute(Core::Command::CA_UpdateText);
692
    cmd->setDescription(d->m_buildAction->text());
con's avatar
con committed
693
694
695
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

696
    // Add to mode bar
697
    Core::ModeManager::addAction(cmd->action(), Constants::P_ACTION_BUILDPROJECT);
698

con's avatar
con committed
699
    // rebuild action
700
    d->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
701
                                                       Utils::ParameterAction::AlwaysEnabled, this);
702
    cmd = am->registerAction(d->m_rebuildAction, Constants::REBUILD, globalcontext);
703
    cmd->setAttribute(Core::Command::CA_UpdateText);
704
    cmd->setDescription(d->m_rebuildAction->text());
con's avatar
con committed
705
706
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

Tobias Hunger's avatar
Tobias Hunger committed
707
708
709
710
711
    // deploy action
    d->m_deployAction = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""),
                                                     Utils::ParameterAction::AlwaysEnabled, this);
    cmd = am->registerAction(d->m_deployAction, Constants::DEPLOY, globalcontext);
    cmd->setAttribute(Core::Command::CA_UpdateText);
712
    cmd->setDescription(d->m_deployAction->text());
Tobias Hunger's avatar
Tobias Hunger committed
713
714
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

715
716
717
718
719
    // Publish action
    d->m_publishAction = new Utils::ParameterAction(tr("Publish Project..."), tr("Publish Project \"%1\"..."),
                                                    Utils::ParameterAction::AlwaysEnabled, this);
    cmd = am->registerAction(d->m_publishAction, Constants::PUBLISH, globalcontext);
    cmd->setAttribute(Core::Command::CA_UpdateText);
720
    cmd->setDescription(d->m_publishAction->text());
721
722
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

con's avatar
con committed
723
    // clean action
724
    d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
725
                                                     Utils::ParameterAction::AlwaysEnabled, this);
726
    cmd = am->registerAction(d->m_cleanAction, Constants::CLEAN, globalcontext);
727
    cmd->setAttribute(Core::Command::CA_UpdateText);
728
    cmd->setDescription(d->m_cleanAction->text());
con's avatar
con committed
729
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
730
731
732
733

    // build action (context menu)
    d->m_buildActionContextMenu = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""),
                                                             Utils::ParameterAction::AlwaysEnabled, this);
dt's avatar
dt committed
734
    cmd = am->registerAction(d->m_buildActionContextMenu, Constants::BUILDCM, projecTreeContext);
735
    cmd->setAttribute(Core::Command::CA_UpdateText);
736
    cmd->setDescription(d->m_buildActionContextMenu->text());
dt's avatar
dt committed
737
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
738
739
740
741

    // rebuild action (context menu)
    d->m_rebuildActionContextMenu = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
                                                               Utils::ParameterAction::AlwaysEnabled, this);
dt's avatar
dt committed
742
    cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::REBUILDCM, projecTreeContext);
743
    cmd->setAttribute(Core::Command::CA_UpdateText);
744
    cmd->setDescription(d->m_rebuildActionContextMenu->text());
dt's avatar
dt committed
745
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
746

Tobias Hunger's avatar
Tobias Hunger committed
747
748
749
    // deploy action (context menu)
    d->m_deployActionContextMenu = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""),
                                                              Utils::ParameterAction::AlwaysEnabled, this);
dt's avatar
dt committed
750
    cmd = am->registerAction(d->m_deployActionContextMenu, Constants::DEPLOYCM, projecTreeContext);
Tobias Hunger's avatar
Tobias Hunger committed
751
    cmd->setAttribute(Core::Command::CA_UpdateText);
752
    cmd->setDescription(d->m_deployActionContextMenu->text());
dt's avatar
dt committed
753
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
Tobias Hunger's avatar
Tobias Hunger committed
754

755
756
757
    // clean action (context menu)
    d->m_cleanActionContextMenu = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
                                                             Utils::ParameterAction::AlwaysEnabled, this);
dt's avatar
dt committed
758
    cmd = am->registerAction(d->m_cleanActionContextMenu, Constants::CLEANCM, projecTreeContext);
759
    cmd->setAttribute(Core::Command::CA_UpdateText);
760
    cmd->setDescription(d->m_cleanActionContextMenu->text());
dt's avatar
dt committed
761
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
con's avatar
con committed
762

763
    // build without dependencies action
764
765
    d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this);
    cmd = am->registerAction(d->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext);
766

767
    // rebuild without dependencies action
768
769
    d->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this);
    cmd = am->registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext);
770

Tobias Hunger's avatar
Tobias Hunger committed
771
772
773
774
    // deploy without dependencies action
    d->m_deployProjectOnlyAction = new QAction(tr("Deploy Without Dependencies"), this);
    cmd = am->registerAction(d->m_deployProjectOnlyAction, Constants::DEPLOYPROJECTONLY, globalcontext);

775
    // clean without dependencies action
776
777
    d->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this);
    cmd = am->registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext);
778

con's avatar
con committed
779
    // run action
780
781
    d->m_runAction = new QAction(runIcon, tr("Run"), this);
    cmd = am->registerAction(d->m_runAction, Constants::RUN, globalcontext);
782
783
    cmd->setAttribute(Core::Command::CA_UpdateText);

con's avatar
con committed
784
785
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+R")));
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
786

787
    Core::ModeManager::addAction(cmd->action(), Constants::P_ACTION_RUN);
con's avatar
con committed
788

789
    d->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this);
dt's avatar
dt committed
790
791
    cmd = am->registerAction(d->m_runActionContextMenu, Constants::RUNCONTEXTMENU, projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
dt's avatar
dt committed
792
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
793

794
795
796
797
798
    // run without deployment action
    d->m_runWithoutDeployAction = new QAction(tr("Run Without Deployment"), this);
    cmd = am->registerAction(d->m_runWithoutDeployAction, Constants::RUNWITHOUTDEPLOY, globalcontext);
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);

con's avatar
con committed
799
    // cancel build action
800
801
    d->m_cancelBuildAction = new QAction(tr("Cancel Build"), this);
    cmd = am->registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
con's avatar
con committed
802
803
804
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    // add new file action
</