projectexplorer.cpp 123 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, 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.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

30
#include "projectexplorer.h"
Tobias Hunger's avatar
Tobias Hunger committed
31

Tobias Hunger's avatar
Tobias Hunger committed
32
#include "buildsteplist.h"
33
#include "customwizard/customwizard.h"
34
#include "deployablefile.h"
Tobias Hunger's avatar
Tobias Hunger committed
35
#include "deployconfiguration.h"
36
#include "gcctoolchainfactories.h"
37
#include "project.h"
38
#include "projectexplorersettings.h"
39
#include "projectmacroexpander.h"
40
#include "removetaskhandler.h"
41
#include "unconfiguredprojectpanel.h"
Tobias Hunger's avatar
Tobias Hunger committed
42
43
#include "kitmanager.h"
#include "kitoptionspage.h"
Tobias Hunger's avatar
Tobias Hunger committed
44
#include "target.h"
45
46
#include "toolchainmanager.h"
#include "toolchainoptionspage.h"
47
#include "copytaskhandler.h"
48
#include "showineditortaskhandler.h"
49
#include "vcsannotatetaskhandler.h"
50
#include "localapplicationruncontrol.h"
con's avatar
con committed
51
52
53
54
#include "allprojectsfilter.h"
#include "allprojectsfind.h"
#include "buildmanager.h"
#include "buildsettingspropertiespage.h"
55
#include "currentprojectfind.h"
con's avatar
con committed
56
#include "currentprojectfilter.h"
57
#include "editorsettingspropertiespage.h"
58
#include "codestylesettingspropertiespage.h"
59
#include "dependenciespanel.h"
con's avatar
con committed
60
61
62
#include "foldernavigationwidget.h"
#include "iprojectmanager.h"
#include "nodesvisitor.h"
63
#include "appoutputpane.h"
con's avatar
con committed
64
65
#include "pluginfilefactory.h"
#include "processstep.h"
Tobias Hunger's avatar
Tobias Hunger committed
66
#include "kitinformation.h"
con's avatar
con committed
67
68
69
70
71
#include "projectfilewizardextension.h"
#include "projecttreewidget.h"
#include "projectwindow.h"
#include "runsettingspropertiespage.h"
#include "session.h"
72
#include "projectnodes.h"
con's avatar
con committed
73
#include "sessiondialog.h"
74
#include "projectexplorersettingspage.h"
75
#include "corelistenercheckingforrunningbuild.h"
76
#include "buildconfiguration.h"
77
#include "miniprojecttargetselector.h"
dt's avatar
dt committed
78
#include "taskhub.h"
79
#include "customtoolchain.h"
Christian Kandeler's avatar
Christian Kandeler committed
80
#include "selectablefilesmodel.h"
81
#include <projectexplorer/customwizard/customwizard.h>
Tobias Hunger's avatar
Tobias Hunger committed
82
83
84
#include "devicesupport/desktopdevice.h"
#include "devicesupport/desktopdevicefactory.h"
#include "devicesupport/devicemanager.h"
85
#include "devicesupport/devicesettingspage.h"
con's avatar
con committed
86

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

93
94
95
#define HAS_WELCOME_PAGE (QT_VERSION >= QT_VERSION_CHECK(5, 1, 0))

#if HAS_WELCOME_PAGE
96
97
98
#include "projectwelcomepage.h"
#endif

99
#include <extensionsystem/pluginspec.h>
100
#include <extensionsystem/pluginmanager.h>
101
#include <coreplugin/icore.h>
102
#include <coreplugin/editormanager/ieditor.h>
103
#include <coreplugin/id.h>
con's avatar
con committed
104
#include <coreplugin/coreconstants.h>
105
#include <coreplugin/documentmanager.h>
106
#include <coreplugin/imode.h>
con's avatar
con committed
107
108
#include <coreplugin/mimedatabase.h>
#include <coreplugin/modemanager.h>
109
#include <coreplugin/actionmanager/actionmanager.h>
110
#include <coreplugin/actionmanager/actioncontainer.h>
111
#include <coreplugin/infobar.h>
con's avatar
con committed
112
113
114
115
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/iversioncontrol.h>
116
#include <coreplugin/variablemanager.h>
Robert Loehning's avatar
Robert Loehning committed
117
#include <coreplugin/fileutils.h>
118
#include <coreplugin/removefiledialog.h>
119
#include <texteditor/findinfiles.h>
120
#include <utils/fileutils.h>
121
#include <utils/parameteraction.h>
122
#include <utils/qtcassert.h>
con's avatar
con committed
123

124
125
#include <QtPlugin>
#include <QDebug>
126
#include <QFileInfo>
127
#include <QSettings>
Morten Johan Sorvig's avatar
Morten Johan Sorvig committed
128

129
130
131
132
133
#include <QAction>
#include <QApplication>
#include <QFileDialog>
#include <QMenu>
#include <QMessageBox>
134
#include <QTimer>
135
#include <QWizard>
con's avatar
con committed
136

137
138
/*!
    \namespace ProjectExplorer
139
    The ProjectExplorer namespace contains the classes to explore projects.
140
141
142
143
*/

/*!
    \namespace ProjectExplorer::Internal
144
145
    The ProjectExplorer::Internal namespace is the internal namespace of the
    ProjectExplorer plugin.
146
147
148
149
150
151
    \internal
*/

/*!
    \class ProjectExplorer::ProjectExplorerPlugin

152
153
    \brief The ProjectExplorerPlugin class contains static accessor and utility
    functions to obtain the current project, open projects, and so on.
154
155
*/

con's avatar
con committed
156
157
namespace {
bool debug = false;
158
const char EXTERNAL_FILE_WARNING[] = "ExternalFile";
con's avatar
con committed
159
160
}

161
162
using namespace Core;

163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
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;
180
    Utils::ParameterAction *m_unloadAction;
181
    QAction *m_closeAllProjects;
182
    QAction *m_buildProjectOnlyAction;
183
    Utils::ParameterAction *m_buildAction;
184
    QAction *m_buildActionContextMenu;
185
186
    QAction *m_buildSessionAction;
    QAction *m_rebuildProjectOnlyAction;
187
    Utils::ParameterAction *m_rebuildAction;
188
    QAction *m_rebuildActionContextMenu;
189
190
    QAction *m_rebuildSessionAction;
    QAction *m_cleanProjectOnlyAction;
Tobias Hunger's avatar
Tobias Hunger committed
191
192
    QAction *m_deployProjectOnlyAction;
    Utils::ParameterAction *m_deployAction;
193
    QAction *m_deployActionContextMenu;
Tobias Hunger's avatar
Tobias Hunger committed
194
    QAction *m_deploySessionAction;
195
    Utils::ParameterAction *m_cleanAction;
196
    QAction *m_cleanActionContextMenu;
197
198
199
    QAction *m_cleanSessionAction;
    QAction *m_runAction;
    QAction *m_runActionContextMenu;
200
    QAction *m_runWithoutDeployAction;
201
202
203
    QAction *m_cancelBuildAction;
    QAction *m_addNewFileAction;
    QAction *m_addExistingFilesAction;
204
    QAction *m_addExistingDirectoryAction;
205
    QAction *m_addNewSubprojectAction;
206
    QAction *m_removeFileAction;
207
    QAction *m_removeProjectAction;
208
    QAction *m_deleteFileAction;
209
    QAction *m_renameFileAction;
dt's avatar
dt committed
210
    QAction *m_openFileAction;
211
    QAction *m_projectTreeCollapseAllAction;
212
    QAction *m_searchOnFileSystem;
dt's avatar
dt committed
213
214
    QAction *m_showInGraphicalShell;
    QAction *m_openTerminalHere;
215
    Utils::ParameterAction *m_setStartupProjectAction;
216
    QAction *m_projectSelectorAction;
217
    QAction *m_projectSelectorActionMenu;
Daniel Teske's avatar
Daniel Teske committed
218
    QAction *m_projectSelectorActionQuick;
dt's avatar
dt committed
219
    QAction *m_runSubProject;
220
221
222
223
224

    Internal::ProjectWindow *m_proWindow;
    QString m_sessionToRestoreAtStartup;

    Project *m_currentProject;
225
    Context m_lastProjectContext;
226
227
228
229
    Node *m_currentNode;

    QList<Internal::ProjectFileFactory*> m_fileFactories;
    QStringList m_profileMimeTypes;
230
    Internal::AppOutputPane *m_outputPane;
231
232
233
234
235

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

    QString m_lastOpenDirectory;
Daniel Teske's avatar
Daniel Teske committed
236
    RunConfiguration *m_delayedRunConfiguration;
237
    RunMode m_runMode;
238
    QString m_projectFilterString;
239
    Internal::MiniProjectTargetSelector * m_targetSelector;
240
    Internal::ProjectExplorerSettings m_projectExplorerSettings;
241

242

243
#if HAS_WELCOME_PAGE
244
245
    Internal::ProjectWelcomePage *m_welcomePage;
#endif
246
    IMode *m_projectsMode;
247

248
    TaskHub *m_taskHub;
Tobias Hunger's avatar
Tobias Hunger committed
249
    KitManager *m_kitManager;
Tobias Hunger's avatar
Tobias Hunger committed
250
    ToolChainManager *m_toolChainManager;
251
    bool m_shuttingDown;
252
    bool m_ignoreDocumentManagerChangedFile;
253
    QStringList m_arguments;
254
255
256
257
258
259
};

ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
    m_currentProject(0),
    m_currentNode(0),
    m_delayedRunConfiguration(0),
260
    m_runMode(NoRunMode),
261
    m_projectsMode(0),
Tobias Hunger's avatar
Tobias Hunger committed
262
    m_kitManager(0),
Tobias Hunger's avatar
Tobias Hunger committed
263
    m_toolChainManager(0),
264
265
    m_shuttingDown(false),
    m_ignoreDocumentManagerChangedFile(false)
266
267
268
{
}

269
class ProjectsMode : public IMode
270
271
{
public:
272
273
274
    ProjectsMode(QWidget *proWindow)
    {
        setWidget(proWindow);
275
        setContext(Context(Constants::C_PROJECTEXPLORER));
276
277
278
        setDisplayName(QCoreApplication::translate("ProjectExplorer::ProjectsMode", "Projects"));
        setIcon(QIcon(QLatin1String(":/fancyactionbar/images/mode_Project.png")));
        setPriority(Constants::P_MODE_SESSION);
279
        setId(Constants::MODE_SESSION);
280
        setContextHelpId(QLatin1String("Managing Projects"));
281
    }
282
283
};

284
285
}  // namespace ProjectExplorer

con's avatar
con committed
286
287
288
289
290
291
292
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;


ProjectExplorerPlugin *ProjectExplorerPlugin::m_instance = 0;

ProjectExplorerPlugin::ProjectExplorerPlugin()
293
    : d(new ProjectExplorerPluginPrivate)
con's avatar
con committed
294
295
296
297
298
299
{
    m_instance = this;
}

ProjectExplorerPlugin::~ProjectExplorerPlugin()
{
300
#if HAS_WELCOME_PAGE
301
302
    removeObject(d->m_welcomePage);
    delete d->m_welcomePage;
303
#endif
con's avatar
con committed
304
    removeObject(this);
Tobias Hunger's avatar
Tobias Hunger committed
305
    // Force sequence of deletion:
Tobias Hunger's avatar
Tobias Hunger committed
306
    delete d->m_kitManager; // remove all the profile informations
Tobias Hunger's avatar
Tobias Hunger committed
307
308
    delete d->m_toolChainManager;

309
    delete d;
con's avatar
con committed
310
311
312
313
314
315
316
}

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

317
318
319
320
321
322
bool ProjectExplorerPlugin::parseArguments(const QStringList &arguments, QString * /* error */)
{
    CustomWizard::setVerbose(arguments.count(QLatin1String("-customwizard-verbose")));
    return true;
}

323
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
con's avatar
con committed
324
{
Friedemann Kleint's avatar
Friedemann Kleint committed
325
    qRegisterMetaType<ProjectExplorer::RunControl *>();
326
    qRegisterMetaType<ProjectExplorer::DeployableFile>("ProjectExplorer::DeployableFile");
Friedemann Kleint's avatar
Friedemann Kleint committed
327

328
329
    if (!parseArguments(arguments, error))
        return false;
dt's avatar
dt committed
330
331
    addObject(this);

332
    // Add ToolChainFactories:
333
#ifdef Q_OS_WIN
334
335
    addAutoReleasedObject(new WinDebugInterface);

336
    addAutoReleasedObject(new Internal::MsvcToolChainFactory);
SteveKing's avatar
SteveKing committed
337
    addAutoReleasedObject(new Internal::WinCEToolChainFactory);
338
339
#else
    addAutoReleasedObject(new Internal::LinuxIccToolChainFactory);
Tobias Hunger's avatar
Tobias Hunger committed
340
341
342
#endif
#ifndef Q_OS_MAC
    addAutoReleasedObject(new Internal::MingwToolChainFactory); // Mingw offers cross-compiling to windows
343
#endif
344
    addAutoReleasedObject(new Internal::GccToolChainFactory);
Tobias Hunger's avatar
Tobias Hunger committed
345
    addAutoReleasedObject(new Internal::ClangToolChainFactory);
346
    addAutoReleasedObject(new Internal::CustomToolChainFactory);
347

Tobias Hunger's avatar
Tobias Hunger committed
348
349
    addAutoReleasedObject(new Internal::DesktopDeviceFactory);

Tobias Hunger's avatar
Tobias Hunger committed
350
    d->m_kitManager = new KitManager; // register before ToolChainManager
Tobias Hunger's avatar
Tobias Hunger committed
351
    d->m_toolChainManager = new ToolChainManager;
352
353

    // Register KitInformation:
354
355
356
357
    KitManager::registerKitInformation(new DeviceTypeKitInformation);
    KitManager::registerKitInformation(new DeviceKitInformation);
    KitManager::registerKitInformation(new ToolChainKitInformation);
    KitManager::registerKitInformation(new SysRootKitInformation);
358

359
    addAutoReleasedObject(new Internal::ToolChainOptionsPage);
Tobias Hunger's avatar
Tobias Hunger committed
360
    addAutoReleasedObject(new KitOptionsPage);
361

362
    addAutoReleasedObject(new TaskHub);
363

364
    connect(ICore::instance(), SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards()));
con's avatar
con committed
365

366
#if HAS_WELCOME_PAGE
367
    d->m_welcomePage = new ProjectWelcomePage;
368
    connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
369
    addObject(d->m_welcomePage);
370
#endif
con's avatar
con committed
371

372
    connect(DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
hjk's avatar
hjk committed
373
            this, SLOT(setCurrentFile(QString)));
con's avatar
con committed
374

375
    QObject *sessionManager = new SessionManager(this);
con's avatar
con committed
376

377
    connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
con's avatar
con committed
378
            this, SIGNAL(fileListChanged()));
379
    connect(sessionManager, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
Robert Loehning's avatar
Robert Loehning committed
380
            this, SLOT(invalidateProject(ProjectExplorer::Project*)));
381
    connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
con's avatar
con committed
382
            this, SIGNAL(fileListChanged()));
383
    connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
384
            this, SLOT(projectAdded(ProjectExplorer::Project*)));
385
    connect(sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
386
            this, SLOT(projectRemoved(ProjectExplorer::Project*)));
387
    connect(sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
con's avatar
con committed
388
            this, SLOT(startupProjectChanged()));
389
    connect(sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
390
            this, SLOT(projectDisplayNameChanged(ProjectExplorer::Project*)));
391
    connect(sessionManager, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
392
            this, SLOT(updateActions()));
393
    connect(sessionManager, SIGNAL(sessionLoaded(QString)),
394
            this, SLOT(updateActions()));
395
    connect(sessionManager, SIGNAL(sessionLoaded(QString)),
396
            this, SLOT(updateWelcomePage()));
con's avatar
con committed
397

398
399
400
401
    addAutoReleasedObject(new CustomWizardFactory<CustomProjectWizard>(Core::IWizard::ProjectWizard));
    addAutoReleasedObject(new CustomWizardFactory<CustomWizard>(Core::IWizard::FileWizard));
    addAutoReleasedObject(new CustomWizardFactory<CustomWizard>(Core::IWizard::ClassWizard));

402
    d->m_proWindow = new ProjectWindow;
Orgad Shaneh's avatar
Orgad Shaneh committed
403
    addAutoReleasedObject(d->m_proWindow);
con's avatar
con committed
404

405
406
    Context globalcontext(Core::Constants::C_GLOBAL);
    Context projecTreeContext(Constants::C_PROJECT_TREE);
con's avatar
con committed
407

408
    d->m_projectsMode = new ProjectsMode(d->m_proWindow);
409
    d->m_projectsMode->setEnabled(false);
410
    addAutoReleasedObject(d->m_projectsMode);
411
    d->m_proWindow->layout()->addWidget(new FindToolBarPlaceHolder(d->m_proWindow));
con's avatar
con committed
412

413
    addAutoReleasedObject(new CopyTaskHandler);
414
    addAutoReleasedObject(new ShowInEditorTaskHandler);
415
    addAutoReleasedObject(new VcsAnnotateTaskHandler);
416
    addAutoReleasedObject(new RemoveTaskHandler);
417
    addAutoReleasedObject(new CoreListener);
con's avatar
con committed
418

419
    d->m_outputPane = new AppOutputPane;
420
    addAutoReleasedObject(d->m_outputPane);
421
    connect(SessionManager::instance(), SIGNAL(projectRemoved(ProjectExplorer::Project*)),
422
            d->m_outputPane, SLOT(projectRemoved()));
con's avatar
con committed
423

424
425
426
427
428
    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*)));

hjk's avatar
hjk committed
429
430
    addAutoReleasedObject(new AllProjectsFilter);
    addAutoReleasedObject(new CurrentProjectFilter);
con's avatar
con committed
431
432
433
434

    addAutoReleasedObject(new BuildSettingsPanelFactory);
    addAutoReleasedObject(new RunSettingsPanelFactory);
    addAutoReleasedObject(new EditorSettingsPanelFactory);
435
    addAutoReleasedObject(new CodeStyleSettingsPanelFactory);
436
    addAutoReleasedObject(new DependenciesPanelFactory);
con's avatar
con committed
437

hjk's avatar
hjk committed
438
    addAutoReleasedObject(new ProcessStepFactory);
439
    addAutoReleasedObject(new UnconfiguredProjectPanel);
con's avatar
con committed
440

hjk's avatar
hjk committed
441
442
    addAutoReleasedObject(new AllProjectsFind);
    addAutoReleasedObject(new CurrentProjectFind);
con's avatar
con committed
443

444
    addAutoReleasedObject(new LocalApplicationRunControlFactory);
con's avatar
con committed
445

446
    addAutoReleasedObject(new ProjectFileWizardExtension);
con's avatar
con committed
447

448
    // Settings pages
449
    addAutoReleasedObject(new ProjectExplorerSettingsPage);
450
    addAutoReleasedObject(new DeviceSettingsPage);
451

con's avatar
con committed
452
    // context menus
453
454
455
456
457
458
459
460
461
462
    ActionContainer *msessionContextMenu =
        ActionManager::createMenu(Constants::M_SESSIONCONTEXT);
    ActionContainer *mprojectContextMenu =
        ActionManager::createMenu(Constants::M_PROJECTCONTEXT);
    ActionContainer *msubProjectContextMenu =
        ActionManager::createMenu(Constants::M_SUBPROJECTCONTEXT);
    ActionContainer *mfolderContextMenu =
        ActionManager::createMenu(Constants::M_FOLDERCONTEXT);
    ActionContainer *mfileContextMenu =
        ActionManager::createMenu(Constants::M_FILECONTEXT);
con's avatar
con committed
463

464
    d->m_sessionContextMenu = msessionContextMenu->menu();
dt's avatar
dt committed
465
466
467
468
    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
469

470
471
472
473
    ActionContainer *mfile =
        ActionManager::actionContainer(Core::Constants::M_FILE);
    ActionContainer *menubar =
        ActionManager::actionContainer(Core::Constants::MENU_BAR);
con's avatar
con committed
474
475

    // build menu
476
477
    ActionContainer *mbuild =
        ActionManager::createMenu(Constants::M_BUILDPROJECT);
478
    mbuild->menu()->setTitle(tr("&Build"));
con's avatar
con committed
479
480
481
    menubar->addMenu(mbuild, Core::Constants::G_VIEW);

    // debug menu
482
483
    ActionContainer *mdebug =
        ActionManager::createMenu(Constants::M_DEBUG);
484
    mdebug->menu()->setTitle(tr("&Debug"));
con's avatar
con committed
485
486
    menubar->addMenu(mdebug, Core::Constants::G_VIEW);

487
488
    ActionContainer *mstartdebugging =
        ActionManager::createMenu(Constants::M_DEBUG_STARTDEBUGGING);
489
490
    mstartdebugging->menu()->setTitle(tr("&Start Debugging"));
    mdebug->addMenu(mstartdebugging, Core::Constants::G_DEFAULT_ONE);
con's avatar
con committed
491
492
493
494
495

    //
    // Groups
    //

496
497
498
499
    mbuild->appendGroup(Constants::G_BUILD_BUILD);
    mbuild->appendGroup(Constants::G_BUILD_DEPLOY);
    mbuild->appendGroup(Constants::G_BUILD_REBUILD);
    mbuild->appendGroup(Constants::G_BUILD_CLEAN);
con's avatar
con committed
500
    mbuild->appendGroup(Constants::G_BUILD_CANCEL);
dt's avatar
dt committed
501
    mbuild->appendGroup(Constants::G_BUILD_RUN);
con's avatar
con committed
502
503

    msessionContextMenu->appendGroup(Constants::G_SESSION_BUILD);
504
    msessionContextMenu->appendGroup(Constants::G_SESSION_REBUILD);
con's avatar
con committed
505
506
    msessionContextMenu->appendGroup(Constants::G_SESSION_FILES);
    msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER);
507
    msessionContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
508

dt's avatar
dt committed
509
510
511
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
512
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_REBUILD);
dt's avatar
dt committed
513
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
514
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
515
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
516

dt's avatar
dt committed
517
518
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
dt's avatar
dt committed
519
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
dt's avatar
dt committed
520
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
521
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
522
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
523

524
525
    ActionContainer *runMenu = ActionManager::createMenu(Constants::RUNMENUCONTEXTMENU);
    runMenu->setOnAllDisabledBehavior(ActionContainer::Hide);
Friedemann Kleint's avatar
Friedemann Kleint committed
526
    QIcon runIcon = QIcon(QLatin1String(Constants::ICON_RUN));
527
    runIcon.addFile(QLatin1String(Constants::ICON_RUN_SMALL));
dt's avatar
dt committed
528
    runMenu->menu()->setIcon(runIcon);
529
    runMenu->menu()->setTitle(tr("Run"));
dt's avatar
dt committed
530
531
    msubProjectContextMenu->addMenu(runMenu, ProjectExplorer::Constants::G_PROJECT_RUN);

dt's avatar
dt committed
532
533
534
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
535
    mfolderContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
536

dt's avatar
dt committed
537
538
539
    mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
    mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
    mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
540
    mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
541
    // "open with" submenu
542
543
544
    ActionContainer * const openWith =
            ActionManager::createMenu(ProjectExplorer::Constants::M_OPENFILEWITHCONTEXT);
    openWith->setOnAllDisabledBehavior(ActionContainer::Show);
545
546
    d->m_openWithMenu = openWith->menu();
    d->m_openWithMenu->setTitle(tr("Open With"));
con's avatar
con committed
547

Robert Loehning's avatar
Robert Loehning committed
548
    connect(d->m_openWithMenu, SIGNAL(triggered(QAction*)),
549
            DocumentManager::instance(), SLOT(executeOpenWithMenuAction(QAction*)));
con's avatar
con committed
550
551
552
553
554

    //
    // Separators
    //

555
    Command *cmd;
con's avatar
con committed
556

557
    msessionContextMenu->addSeparator(projecTreeContext, Constants::G_SESSION_REBUILD);
con's avatar
con committed
558

559
560
561
562
563
564
565
566
567
    msessionContextMenu->addSeparator(projecTreeContext, Constants::G_SESSION_FILES);
    mprojectContextMenu->addSeparator(projecTreeContext, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addSeparator(projecTreeContext, Constants::G_PROJECT_FILES);
    mfile->addSeparator(globalcontext, Core::Constants::G_FILE_PROJECT);
    mbuild->addSeparator(globalcontext, Constants::G_BUILD_REBUILD);
    msessionContextMenu->addSeparator(globalcontext, Constants::G_SESSION_OTHER);
    mbuild->addSeparator(globalcontext, Constants::G_BUILD_CANCEL);
    mbuild->addSeparator(globalcontext, Constants::G_BUILD_RUN);
    mprojectContextMenu->addSeparator(globalcontext, Constants::G_PROJECT_REBUILD);
con's avatar
con committed
568
569
570
571
572
573

    //
    // Actions
    //

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

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

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

593
    d->m_searchOnFileSystem = new QAction(FileUtils::msgFindInDirectory(), this);
594
    cmd = ActionManager::registerAction(d->m_searchOnFileSystem, ProjectExplorer::Constants::SEARCHONFILESYSTEM, projecTreeContext);
595
596

    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
597
598
599
600
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_CONFIG);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);

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

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

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

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

625
    // session menu
626
    ActionContainer *msession = ActionManager::createMenu(Constants::M_SESSION);
627
    msession->menu()->setTitle(tr("Sessions"));
628
    msession->setOnAllDisabledBehavior(ActionContainer::Show);
629
630
631
632
633
634
635
    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);
636
    cmd = ActionManager::registerAction(d->m_sessionManagerAction, Constants::NEWSESSION, globalcontext);
637
638
639
640
    mfile->addAction(cmd, Core::Constants::G_FILE_OPEN);
    cmd->setDefaultKeySequence(QKeySequence());


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

    // unload session action
651
    d->m_closeAllProjects = new QAction(tr("Close All Projects and Editors"), this);
652
    cmd = ActionManager::registerAction(d->m_closeAllProjects, Constants::CLEARSESSION, globalcontext);
con's avatar
con committed
653
654
655
656
    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
657
    QIcon buildIcon = QIcon(QLatin1String(Constants::ICON_BUILD));
658
    buildIcon.addFile(QLatin1String(Constants::ICON_BUILD_SMALL));
659
    d->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
660
    cmd = ActionManager::registerAction(d->m_buildSessionAction, Constants::BUILDSESSION, globalcontext);
con's avatar
con committed
661
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B")));
662
663
664
665
666
    mbuild->addAction(cmd, Constants::G_BUILD_BUILD);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // deploy session
    d->m_deploySessionAction = new QAction(tr("Deploy All"), this);
667
    cmd = ActionManager::registerAction(d->m_deploySessionAction, Constants::DEPLOYSESSION, globalcontext);
668
    mbuild->addAction(cmd, Constants::G_BUILD_DEPLOY);
con's avatar
con committed
669
670
671
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // rebuild session action
Friedemann Kleint's avatar
Friedemann Kleint committed
672
    QIcon rebuildIcon = QIcon(QLatin1String(Constants::ICON_REBUILD));
673
    rebuildIcon.addFile(QLatin1String(Constants::ICON_REBUILD_SMALL));
674
    d->m_rebuildSessionAction = new QAction(rebuildIcon, tr("Rebuild All"), this);
675
    cmd = ActionManager::registerAction(d->m_rebuildSessionAction, Constants::REBUILDSESSION, globalcontext);
676
677
    mbuild->addAction(cmd, Constants::G_BUILD_REBUILD);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_REBUILD);
Tobias Hunger's avatar
Tobias Hunger committed
678

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

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

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

700
701
702
    // deploy action
    d->m_deployAction = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""),
                                                     Utils::ParameterAction::AlwaysEnabled, this);
703
704
    cmd = ActionManager::registerAction(d->m_deployAction, Constants::DEPLOY, globalcontext);
    cmd->setAttribute(Command::CA_UpdateText);
705
706
707
    cmd->setDescription(d->m_deployAction->text());
    mbuild->addAction(cmd, Constants::G_BUILD_DEPLOY);

con's avatar
con committed
708
    // rebuild action
709
    d->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
710
                                                       Utils::ParameterAction::AlwaysEnabled, this);
711
712
    cmd = ActionManager::registerAction(d->m_rebuildAction, Constants::REBUILD, globalcontext);
    cmd->setAttribute(Command::CA_UpdateText);
713
    cmd->setDescription(d->m_rebuildAction->text());
714
    mbuild->addAction(cmd, Constants::G_BUILD_REBUILD);
con's avatar
con committed
715

716
717
    // clean action
    d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
Tobias Hunger's avatar
Tobias Hunger committed
718
                                                     Utils::ParameterAction::AlwaysEnabled, this);
719
720
    cmd = ActionManager::registerAction(d->m_cleanAction, Constants::CLEAN, globalcontext);
    cmd->setAttribute(Command::CA_UpdateText);
721
722
723
724
725
726
727
    cmd->setDescription(d->m_cleanAction->text());
    mbuild->addAction(cmd, Constants::G_BUILD_CLEAN);

    // cancel build action
    QIcon stopIcon = QIcon(QLatin1String(Constants::ICON_STOP));
    stopIcon.addFile(QLatin1String(Constants::ICON_STOP_SMALL));
    d->m_cancelBuildAction = new QAction(stopIcon, tr("Cancel Build"), this);
728
    cmd = ActionManager::registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
729
730
731
732
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    // run action
    d->m_runAction = new QAction(runIcon, tr("Run"), this);
733
734
    cmd = ActionManager::registerAction(d->m_runAction, Constants::RUN, globalcontext);
    cmd->setAttribute(Command::CA_UpdateText);
735
736
737
738

    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+R")));
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);

739
    ModeManager::addAction(cmd->action(), Constants::P_ACTION_RUN);
740
741
742

    // Run without deployment action
    d->m_runWithoutDeployAction = new QAction(tr("Run Without Deployment"), this);
743
    cmd = ActionManager::registerAction(d->m_runWithoutDeployAction, Constants::RUNWITHOUTDEPLOY, globalcontext);
744
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
Tobias Hunger's avatar
Tobias Hunger committed
745

746
    // build action (context menu)
747
    d->m_buildActionContextMenu = new QAction(tr("Build"), this);
748
749
    cmd = ActionManager::registerAction(d->m_buildActionContextMenu, Constants::BUILDCM, projecTreeContext);
    cmd->setAttribute(Command::CA_UpdateText);
dt's avatar
dt committed
750
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
751
752

    // rebuild action (context menu)
753
    d->m_rebuildActionContextMenu = new QAction(tr("Rebuild"), this);
754
755
    cmd = ActionManager::registerAction(d->m_rebuildActionContextMenu, Constants::REBUILDCM, projecTreeContext);
    cmd->setAttribute(Command::CA_UpdateText);
756
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_REBUILD);
Tobias Hunger's avatar
Tobias Hunger committed
757

758
    // clean action (context menu)
759
    d->m_cleanActionContextMenu = new QAction(tr("Clean"), this);
760
761
    cmd = ActionManager::registerAction(d->m_cleanActionContextMenu, Constants::CLEANCM, projecTreeContext);
    cmd->setAttribute(Command::CA_UpdateText);
762
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_REBUILD);
con's avatar
con committed
763

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

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

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

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

780
781
    // deploy action (context menu)
    d->m_deployActionContextMenu = new QAction(tr("Deploy"), this);
782
    cmd = ActionManager::registerAction(d->m_deployActionContextMenu, Constants::DEPLOYCM, projecTreeContext);
783
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
con's avatar
con committed
784

785
    d->m_runActionContextMenu = new QAction(runIcon, tr