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
**
Eike Ziller's avatar
Eike Ziller committed
7
** Contact: http://www.qt-project.org/
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
**
29
**************************************************************************/
hjk's avatar
hjk committed
30

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

Tobias Hunger's avatar
Tobias Hunger committed
33
#include "buildsteplist.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"
Tobias Hunger's avatar
Tobias Hunger committed
39
40
#include "kitmanager.h"
#include "kitoptionspage.h"
Tobias Hunger's avatar
Tobias Hunger committed
41
42
#include "target.h"
#include "targetsettingspanel.h"
43
44
#include "toolchainmanager.h"
#include "toolchainoptionspage.h"
45
#include "copytaskhandler.h"
46
#include "showineditortaskhandler.h"
47
#include "vcsannotatetaskhandler.h"
48
#include "localapplicationruncontrol.h"
con's avatar
con committed
49
50
51
52
#include "allprojectsfilter.h"
#include "allprojectsfind.h"
#include "buildmanager.h"
#include "buildsettingspropertiespage.h"
53
#include "currentprojectfind.h"
con's avatar
con committed
54
#include "currentprojectfilter.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"
Tobias Hunger's avatar
Tobias Hunger committed
67
#include "kitinformation.h"
con's avatar
con committed
68
69
70
71
72
#include "projectfilewizardextension.h"
#include "projecttreewidget.h"
#include "projectwindow.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"
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"
86
87
#include "publishing/ipublishingwizardfactory.h"
#include "publishing/publishingwizardselectiondialog.h"
con's avatar
con committed
88

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

95
#include <extensionsystem/pluginspec.h>
con's avatar
con committed
96
#include <coreplugin/coreconstants.h>
97
#include <coreplugin/documentmanager.h>
98
#include <coreplugin/icore.h>
99
#include <coreplugin/imode.h>
con's avatar
con committed
100
101
#include <coreplugin/mimedatabase.h>
#include <coreplugin/modemanager.h>
102
#include <coreplugin/actionmanager/actionmanager.h>
103
104
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
105
#include <coreplugin/id.h>
con's avatar
con committed
106
107
108
109
110
111
#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>
112
#include <coreplugin/variablemanager.h>
Robert Loehning's avatar
Robert Loehning committed
113
#include <coreplugin/fileutils.h>
114
#include <coreplugin/removefiledialog.h>
115
#include <extensionsystem/pluginmanager.h>
116
#include <find/searchresultwindow.h>
117
#include <utils/consoleprocess.h>
hjk's avatar
hjk committed
118
#include <utils/qtcassert.h>
119
#include <utils/parameteraction.h>
120
#include <utils/stringutils.h>
Jarek Kobus's avatar
Jarek Kobus committed
121
#include <utils/persistentsettings.h>
con's avatar
con committed
122

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

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

136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*!
    \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
154
155
156
157
namespace {
bool debug = false;
}

158
159
static const char kCurrentProjectPath[] = "CurrentProject:Path";
static const char kCurrentProjectFilePath[] = "CurrentProject:FilePath";
160
static const char kCurrentProjectBuildPath[] = "CurrentProject:BuildPath";
con's avatar
con committed
161

162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
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;
179
    Utils::ParameterAction *m_unloadAction;
180
    QAction *m_closeAllProjects;
181
    QAction *m_buildProjectOnlyAction;
182
    Utils::ParameterAction *m_buildAction;
183
    QAction *m_buildActionContextMenu;
184
185
    QAction *m_buildSessionAction;
    QAction *m_rebuildProjectOnlyAction;
186
    Utils::ParameterAction *m_rebuildAction;
187
    QAction *m_rebuildActionContextMenu;
188
189
    QAction *m_rebuildSessionAction;
    QAction *m_cleanProjectOnlyAction;
Tobias Hunger's avatar
Tobias Hunger committed
190
191
    QAction *m_deployProjectOnlyAction;
    Utils::ParameterAction *m_deployAction;
192
    QAction *m_deployActionContextMenu;
Tobias Hunger's avatar
Tobias Hunger committed
193
    QAction *m_deploySessionAction;
194
    Utils::ParameterAction *m_publishAction;
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_addNewSubprojectAction;
205
    QAction *m_removeFileAction;
206
    QAction *m_removeProjectAction;
207
    QAction *m_deleteFileAction;
208
    QAction *m_renameFileAction;
dt's avatar
dt committed
209
    QAction *m_openFileAction;
210
    QAction *m_projectTreeCollapseAllAction;
211
    QAction *m_searchOnFileSystem;
dt's avatar
dt committed
212
213
    QAction *m_showInGraphicalShell;
    QAction *m_openTerminalHere;
214
    Utils::ParameterAction *m_setStartupProjectAction;
215
    QAction *m_projectSelectorAction;
216
    QAction *m_projectSelectorActionMenu;
Daniel Teske's avatar
Daniel Teske committed
217
    QAction *m_projectSelectorActionQuick;
dt's avatar
dt committed
218
    QAction *m_runSubProject;
219
220
221
222
223
224
225
226
227
228
229
230

    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;
231
    Internal::AppOutputPane *m_outputPane;
232
233
234
235
236

    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
237
    RunConfiguration *m_delayedRunConfiguration;
238
    RunMode m_runMode;
239
    QString m_projectFilterString;
240
    Internal::MiniProjectTargetSelector * m_targetSelector;
241
    Internal::ProjectExplorerSettings m_projectExplorerSettings;
242
    Internal::ProjectWelcomePage *m_welcomePage;
243

244
    Core::IMode *m_projectsMode;
245

246
    TaskHub *m_taskHub;
Tobias Hunger's avatar
Tobias Hunger committed
247
    KitManager *m_kitManager;
Tobias Hunger's avatar
Tobias Hunger committed
248
    ToolChainManager *m_toolChainManager;
249
    bool m_shuttingDown;
250
251
252
253
254
255
};

ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
    m_currentProject(0),
    m_currentNode(0),
    m_delayedRunConfiguration(0),
256
    m_runMode(NoRunMode),
257
    m_projectsMode(0),
Tobias Hunger's avatar
Tobias Hunger committed
258
    m_kitManager(0),
Tobias Hunger's avatar
Tobias Hunger committed
259
    m_toolChainManager(0),
260
    m_shuttingDown(false)
261
262
263
{
}

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

280
281
}  // namespace ProjectExplorer

con's avatar
con committed
282
283
284
285
286
287
288
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;


ProjectExplorerPlugin *ProjectExplorerPlugin::m_instance = 0;

ProjectExplorerPlugin::ProjectExplorerPlugin()
289
    : d(new ProjectExplorerPluginPrivate)
con's avatar
con committed
290
291
292
293
294
295
{
    m_instance = this;
}

ProjectExplorerPlugin::~ProjectExplorerPlugin()
{
296
297
    removeObject(d->m_welcomePage);
    delete d->m_welcomePage;
con's avatar
con committed
298
    removeObject(this);
Tobias Hunger's avatar
Tobias Hunger committed
299
    // Force sequence of deletion:
Tobias Hunger's avatar
Tobias Hunger committed
300
    delete d->m_kitManager; // remove all the profile informations
Tobias Hunger's avatar
Tobias Hunger committed
301
302
    delete d->m_toolChainManager;

303
    delete d;
con's avatar
con committed
304
305
306
307
308
309
310
}

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

311
312
313
314
315
316
bool ProjectExplorerPlugin::parseArguments(const QStringList &arguments, QString * /* error */)
{
    CustomWizard::setVerbose(arguments.count(QLatin1String("-customwizard-verbose")));
    return true;
}

317
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
con's avatar
con committed
318
{
Friedemann Kleint's avatar
Friedemann Kleint committed
319
    qRegisterMetaType<ProjectExplorer::RunControl *>();
320
    qRegisterMetaType<ProjectExplorer::DeployableFile>("ProjectExplorer::DeployableFile");
Friedemann Kleint's avatar
Friedemann Kleint committed
321

322
323
    if (!parseArguments(arguments, error))
        return false;
dt's avatar
dt committed
324
325
    addObject(this);

326
    // Add ToolChainFactories:
327
#ifdef Q_OS_WIN
328
329
    addAutoReleasedObject(new WinDebugInterface);

330
    addAutoReleasedObject(new Internal::MsvcToolChainFactory);
SteveKing's avatar
SteveKing committed
331
    addAutoReleasedObject(new Internal::WinCEToolChainFactory);
332
333
#else
    addAutoReleasedObject(new Internal::LinuxIccToolChainFactory);
Tobias Hunger's avatar
Tobias Hunger committed
334
335
336
#endif
#ifndef Q_OS_MAC
    addAutoReleasedObject(new Internal::MingwToolChainFactory); // Mingw offers cross-compiling to windows
337
#endif
338
    addAutoReleasedObject(new Internal::GccToolChainFactory);
Tobias Hunger's avatar
Tobias Hunger committed
339
    addAutoReleasedObject(new Internal::ClangToolChainFactory);
340

Tobias Hunger's avatar
Tobias Hunger committed
341
342
    addAutoReleasedObject(new Internal::DesktopDeviceFactory);

Tobias Hunger's avatar
Tobias Hunger committed
343
    d->m_kitManager = new KitManager; // register before ToolChainManager
Tobias Hunger's avatar
Tobias Hunger committed
344
    d->m_toolChainManager = new ToolChainManager;
345
    addAutoReleasedObject(new Internal::ToolChainOptionsPage);
Tobias Hunger's avatar
Tobias Hunger committed
346
    addAutoReleasedObject(new KitOptionsPage);
347

348
349
    d->m_taskHub = new TaskHub;
    addAutoReleasedObject(d->m_taskHub);
350

hjk's avatar
hjk committed
351
    connect(Core::ICore::instance(), SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards()));
con's avatar
con committed
352

353
    d->m_welcomePage = new ProjectWelcomePage;
354
    connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
355
    addObject(d->m_welcomePage);
con's avatar
con committed
356

357
    connect(Core::DocumentManager::instance(), SIGNAL(currentFileChanged(QString)),
hjk's avatar
hjk committed
358
            this, SLOT(setCurrentFile(QString)));
con's avatar
con committed
359

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

Robert Loehning's avatar
Robert Loehning committed
362
    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
con's avatar
con committed
363
            this, SIGNAL(fileListChanged()));
Robert Loehning's avatar
Robert Loehning committed
364
365
366
    connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
            this, SLOT(invalidateProject(ProjectExplorer::Project*)));
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
con's avatar
con committed
367
            this, SIGNAL(fileListChanged()));
368
369
370
371
    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*)));
Robert Loehning's avatar
Robert Loehning committed
372
    connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
con's avatar
con committed
373
            this, SLOT(startupProjectChanged()));
374
375
    connect(d->m_session, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
            this, SLOT(projectDisplayNameChanged(ProjectExplorer::Project*)));
376
377
    connect(d->m_session, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
            this, SLOT(updateActions()));
378
    connect(d->m_session, SIGNAL(sessionLoaded(QString)),
379
            this, SLOT(updateActions()));
380
    connect(d->m_session, SIGNAL(sessionLoaded(QString)),
381
            this, SLOT(updateWelcomePage()));
con's avatar
con committed
382

383
    d->m_proWindow = new ProjectWindow;
Orgad Shaneh's avatar
Orgad Shaneh committed
384
    addAutoReleasedObject(d->m_proWindow);
con's avatar
con committed
385

386
    Core::Context globalcontext(Core::Constants::C_GLOBAL);
dt's avatar
dt committed
387
    Core::Context projecTreeContext(Constants::C_PROJECT_TREE);
con's avatar
con committed
388

389
    d->m_projectsMode = new ProjectsMode(d->m_proWindow);
390
    d->m_projectsMode->setEnabled(false);
391
    addAutoReleasedObject(d->m_projectsMode);
392
    d->m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(d->m_proWindow));
con's avatar
con committed
393

394
    addAutoReleasedObject(new CopyTaskHandler);
395
    addAutoReleasedObject(new ShowInEditorTaskHandler);
396
    addAutoReleasedObject(new VcsAnnotateTaskHandler);
397
    addAutoReleasedObject(new CoreListener);
con's avatar
con committed
398

399
    d->m_outputPane = new AppOutputPane;
400
    addAutoReleasedObject(d->m_outputPane);
Robert Loehning's avatar
Robert Loehning committed
401
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
402
            d->m_outputPane, SLOT(projectRemoved()));
con's avatar
con committed
403

404
405
406
407
408
    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*)));

409
    AllProjectsFilter *allProjectsFilter = new AllProjectsFilter(this);
con's avatar
con committed
410
411
    addAutoReleasedObject(allProjectsFilter);

412
    CurrentProjectFilter *currentProjectFilter = new CurrentProjectFilter(this);
con's avatar
con committed
413
414
415
416
417
    addAutoReleasedObject(currentProjectFilter);

    addAutoReleasedObject(new BuildSettingsPanelFactory);
    addAutoReleasedObject(new RunSettingsPanelFactory);
    addAutoReleasedObject(new EditorSettingsPanelFactory);
418
    addAutoReleasedObject(new CodeStyleSettingsPanelFactory);
419
    addAutoReleasedObject(new DependenciesPanelFactory(d->m_session));
con's avatar
con committed
420
421
422
423

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

424
    AllProjectsFind *allProjectsFind = new AllProjectsFind(this);
con's avatar
con committed
425
426
    addAutoReleasedObject(allProjectsFind);

427
    CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this);
con's avatar
con committed
428
429
    addAutoReleasedObject(currentProjectFind);

430
    addAutoReleasedObject(new LocalApplicationRunControlFactory);
con's avatar
con committed
431

432
    addAutoReleasedObject(new ProjectFileWizardExtension);
con's avatar
con committed
433

434
    // Settings pages
435
    addAutoReleasedObject(new ProjectExplorerSettingsPage);
436
    addAutoReleasedObject(new DeviceSettingsPage);
437

con's avatar
con committed
438
    // context menus
439
    Core::ActionContainer *msessionContextMenu =
Eike Ziller's avatar
Eike Ziller committed
440
        Core::ActionManager::createMenu(Constants::M_SESSIONCONTEXT);
dt's avatar
dt committed
441
    Core::ActionContainer *mprojectContextMenu =
Eike Ziller's avatar
Eike Ziller committed
442
        Core::ActionManager::createMenu(Constants::M_PROJECTCONTEXT);
dt's avatar
dt committed
443
    Core::ActionContainer *msubProjectContextMenu =
Eike Ziller's avatar
Eike Ziller committed
444
        Core::ActionManager::createMenu(Constants::M_SUBPROJECTCONTEXT);
dt's avatar
dt committed
445
    Core::ActionContainer *mfolderContextMenu =
Eike Ziller's avatar
Eike Ziller committed
446
        Core::ActionManager::createMenu(Constants::M_FOLDERCONTEXT);
dt's avatar
dt committed
447
    Core::ActionContainer *mfileContextMenu =
Eike Ziller's avatar
Eike Ziller committed
448
        Core::ActionManager::createMenu(Constants::M_FILECONTEXT);
con's avatar
con committed
449

450
    d->m_sessionContextMenu = msessionContextMenu->menu();
dt's avatar
dt committed
451
452
453
454
    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
455

456
    Core::ActionContainer *mfile =
Eike Ziller's avatar
Eike Ziller committed
457
        Core::ActionManager::actionContainer(Core::Constants::M_FILE);
458
    Core::ActionContainer *menubar =
Eike Ziller's avatar
Eike Ziller committed
459
        Core::ActionManager::actionContainer(Core::Constants::MENU_BAR);
con's avatar
con committed
460
461

    // build menu
462
    Core::ActionContainer *mbuild =
Eike Ziller's avatar
Eike Ziller committed
463
        Core::ActionManager::createMenu(Constants::M_BUILDPROJECT);
464
    mbuild->menu()->setTitle(tr("&Build"));
con's avatar
con committed
465
466
467
    menubar->addMenu(mbuild, Core::Constants::G_VIEW);

    // debug menu
468
    Core::ActionContainer *mdebug =
Eike Ziller's avatar
Eike Ziller committed
469
        Core::ActionManager::createMenu(Constants::M_DEBUG);
470
    mdebug->menu()->setTitle(tr("&Debug"));
con's avatar
con committed
471
472
    menubar->addMenu(mdebug, Core::Constants::G_VIEW);

473
    Core::ActionContainer *mstartdebugging =
Eike Ziller's avatar
Eike Ziller committed
474
        Core::ActionManager::createMenu(Constants::M_DEBUG_STARTDEBUGGING);
475
476
    mstartdebugging->menu()->setTitle(tr("&Start Debugging"));
    mdebug->addMenu(mstartdebugging, Core::Constants::G_DEFAULT_ONE);
con's avatar
con committed
477
478
479
480
481

    //
    // Groups
    //

482
483
484
485
    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
486
    mbuild->appendGroup(Constants::G_BUILD_CANCEL);
dt's avatar
dt committed
487
    mbuild->appendGroup(Constants::G_BUILD_RUN);
con's avatar
con committed
488
489

    msessionContextMenu->appendGroup(Constants::G_SESSION_BUILD);
490
    msessionContextMenu->appendGroup(Constants::G_SESSION_REBUILD);
con's avatar
con committed
491
492
    msessionContextMenu->appendGroup(Constants::G_SESSION_FILES);
    msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER);
493
    msessionContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
494

dt's avatar
dt committed
495
496
497
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
498
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_REBUILD);
dt's avatar
dt committed
499
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
500
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
501
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
502

dt's avatar
dt committed
503
504
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
dt's avatar
dt committed
505
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
dt's avatar
dt committed
506
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
507
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
508
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
509

Eike Ziller's avatar
Eike Ziller committed
510
    Core::ActionContainer *runMenu = Core::ActionManager::createMenu(Constants::RUNMENUCONTEXTMENU);
dt's avatar
dt committed
511
    runMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
Friedemann Kleint's avatar
Friedemann Kleint committed
512
    QIcon runIcon = QIcon(QLatin1String(Constants::ICON_RUN));
513
    runIcon.addFile(QLatin1String(Constants::ICON_RUN_SMALL));
dt's avatar
dt committed
514
    runMenu->menu()->setIcon(runIcon);
515
    runMenu->menu()->setTitle(tr("Run"));
dt's avatar
dt committed
516
517
    msubProjectContextMenu->addMenu(runMenu, ProjectExplorer::Constants::G_PROJECT_RUN);

dt's avatar
dt committed
518
519
520
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
521
    mfolderContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
522

dt's avatar
dt committed
523
524
525
    mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
    mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
    mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
526
    mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
527
    // "open with" submenu
528
    Core::ActionContainer * const openWith =
Eike Ziller's avatar
Eike Ziller committed
529
            Core::ActionManager::createMenu(ProjectExplorer::Constants::M_OPENFILEWITHCONTEXT);
530
    openWith->setOnAllDisabledBehavior(Core::ActionContainer::Show);
531
532
    d->m_openWithMenu = openWith->menu();
    d->m_openWithMenu->setTitle(tr("Open With"));
con's avatar
con committed
533

Robert Loehning's avatar
Robert Loehning committed
534
    connect(d->m_openWithMenu, SIGNAL(triggered(QAction*)),
535
            Core::DocumentManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)));
con's avatar
con committed
536
537
538
539
540

    //
    // Separators
    //

con's avatar
con committed
541
    Core::Command *cmd;
con's avatar
con committed
542

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

545
546
547
548
549
550
551
552
553
    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
554
555
556
557
558
559

    //
    // Actions
    //

    // new action
560
    d->m_newAction = new QAction(tr("New Project..."), this);
Eike Ziller's avatar
Eike Ziller committed
561
    cmd = Core::ActionManager::registerAction(d->m_newAction, Constants::NEWPROJECT, globalcontext);
con's avatar
con committed
562
563
564
565
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+N")));
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // open action
566
    d->m_loadAction = new QAction(tr("Load Project..."), this);
Eike Ziller's avatar
Eike Ziller committed
567
    cmd = Core::ActionManager::registerAction(d->m_loadAction, Constants::LOAD, globalcontext);
568
#ifndef Q_OS_MAC
con's avatar
con committed
569
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+O")));
570
#endif
con's avatar
con committed
571
572
573
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // Default open action
574
    d->m_openFileAction = new QAction(tr("Open File"), this);
Eike Ziller's avatar
Eike Ziller committed
575
    cmd = Core::ActionManager::registerAction(d->m_openFileAction, ProjectExplorer::Constants::OPENFILE,
dt's avatar
dt committed
576
577
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
con's avatar
con committed
578

579
    d->m_searchOnFileSystem = new QAction(FolderNavigationWidget::msgFindOnFileSystem(), this);
Eike Ziller's avatar
Eike Ziller committed
580
    cmd = Core::ActionManager::registerAction(d->m_searchOnFileSystem, ProjectExplorer::Constants::SEARCHONFILESYSTEM, projecTreeContext);
581
582
583
584
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_CONFIG);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);

585
    d->m_showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), this);
Eike Ziller's avatar
Eike Ziller committed
586
    cmd = Core::ActionManager::registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
dt's avatar
dt committed
587
588
589
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
590

591
    d->m_openTerminalHere = new QAction(Core::FileUtils::msgTerminalAction(), this);
Eike Ziller's avatar
Eike Ziller committed
592
    cmd = Core::ActionManager::registerAction(d->m_openTerminalHere, ProjectExplorer::Constants::OPENTERMIANLHERE,
dt's avatar
dt committed
593
594
595
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
596

con's avatar
con committed
597
    // Open With menu
dt's avatar
dt committed
598
    mfileContextMenu->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN);
con's avatar
con committed
599

mae's avatar
mae committed
600
    // recent projects menu
601
    Core::ActionContainer *mrecent =
Eike Ziller's avatar
Eike Ziller committed
602
        Core::ActionManager::createMenu(Constants::M_RECENTPROJECTS);
603
    mrecent->menu()->setTitle(tr("Recent P&rojects"));
604
    mrecent->setOnAllDisabledBehavior(Core::ActionContainer::Show);
mae's avatar
mae committed
605
606
607
608
    mfile->addMenu(mrecent, Core::Constants::G_FILE_OPEN);
    connect(mfile->menu(), SIGNAL(aboutToShow()),
        this, SLOT(updateRecentProjectMenu()));

609
    // session menu
Eike Ziller's avatar
Eike Ziller committed
610
    Core::ActionContainer *msession = Core::ActionManager::createMenu(Constants::M_SESSION);
611
    msession->menu()->setTitle(tr("Sessions"));
612
613
614
615
616
617
618
619
    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);
Eike Ziller's avatar
Eike Ziller committed
620
    cmd = Core::ActionManager::registerAction(d->m_sessionManagerAction, Constants::NEWSESSION, globalcontext);
621
622
623
624
    mfile->addAction(cmd, Core::Constants::G_FILE_OPEN);
    cmd->setDefaultKeySequence(QKeySequence());


dt's avatar
dt committed
625
    // XXX same action?
con's avatar
con committed
626
    // unload action
627
628
    d->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""),
                                                      Utils::ParameterAction::EnabledWithParameter, this);
Eike Ziller's avatar
Eike Ziller committed
629
    cmd = Core::ActionManager::registerAction(d->m_unloadAction, Constants::UNLOAD, globalcontext);
con's avatar
con committed
630
    cmd->setAttribute(Core::Command::CA_UpdateText);
631
    cmd->setDescription(d->m_unloadAction->text());
con's avatar
con committed
632
633
634
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    // unload session action
635
    d->m_closeAllProjects = new QAction(tr("Close All Projects and Editors"), this);
Eike Ziller's avatar
Eike Ziller committed
636
    cmd = Core::ActionManager::registerAction(d->m_closeAllProjects, Constants::CLEARSESSION, globalcontext);
con's avatar
con committed
637
638
639
640
    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
641
    QIcon buildIcon = QIcon(QLatin1String(Constants::ICON_BUILD));
642
    buildIcon.addFile(QLatin1String(Constants::ICON_BUILD_SMALL));
643
    d->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
Eike Ziller's avatar
Eike Ziller committed
644
    cmd = Core::ActionManager::registerAction(d->m_buildSessionAction, Constants::BUILDSESSION, globalcontext);
con's avatar
con committed
645
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B")));
646
647
648
649
650
    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);
Eike Ziller's avatar
Eike Ziller committed
651
    cmd = Core::ActionManager::registerAction(d->m_deploySessionAction, Constants::DEPLOYSESSION, globalcontext);
652
    mbuild->addAction(cmd, Constants::G_BUILD_DEPLOY);
con's avatar
con committed
653
654
655
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // rebuild session action
Friedemann Kleint's avatar
Friedemann Kleint committed
656
    QIcon rebuildIcon = QIcon(QLatin1String(Constants::ICON_REBUILD));
657
    rebuildIcon.addFile(QLatin1String(Constants::ICON_REBUILD_SMALL));
658
    d->m_rebuildSessionAction = new QAction(rebuildIcon, tr("Rebuild All"), this);
Eike Ziller's avatar
Eike Ziller committed
659
    cmd = Core::ActionManager::registerAction(d->m_rebuildSessionAction, Constants::REBUILDSESSION, globalcontext);
660
661
    mbuild->addAction(cmd, Constants::G_BUILD_REBUILD);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_REBUILD);
Tobias Hunger's avatar
Tobias Hunger committed
662

con's avatar
con committed
663
    // clean session
Friedemann Kleint's avatar
Friedemann Kleint committed
664
    QIcon cleanIcon = QIcon(QLatin1String(Constants::ICON_CLEAN));
665
    cleanIcon.addFile(QLatin1String(Constants::ICON_CLEAN_SMALL));
666
    d->m_cleanSessionAction = new QAction(cleanIcon, tr("Clean All"), this);
Eike Ziller's avatar
Eike Ziller committed
667
    cmd = Core::ActionManager::registerAction(d->m_cleanSessionAction, Constants::CLEANSESSION, globalcontext);
668
669
    mbuild->addAction(cmd, Constants::G_BUILD_CLEAN);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_REBUILD);
con's avatar
con committed
670
671

    // build action
672
    d->m_buildAction = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""),
673
                                                     Utils::ParameterAction::AlwaysEnabled, this);
dt's avatar
dt committed
674
    d->m_buildAction->setIcon(buildIcon);
Eike Ziller's avatar
Eike Ziller committed
675
    cmd = Core::ActionManager::registerAction(d->m_buildAction, Constants::BUILD, globalcontext);
676
    cmd->setAttribute(Core::Command::CA_UpdateText);
677
    cmd->setDescription(d->m_buildAction->text());
con's avatar
con committed
678
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B")));
679
    mbuild->addAction(cmd, Constants::G_BUILD_BUILD);
con's avatar
con committed
680

681
    // Add to mode bar
682
    Core::ModeManager::addAction(cmd->action(), Constants::P_ACTION_BUILDPROJECT);
683

684
685
686
    // deploy action
    d->m_deployAction = new Utils::ParameterAction(tr("Deploy Project"), tr("Deploy Project \"%1\""),
                                                     Utils::ParameterAction::AlwaysEnabled, this);
Eike Ziller's avatar
Eike Ziller committed
687
    cmd = Core::ActionManager::registerAction(d->m_deployAction, Constants::DEPLOY, globalcontext);
688
689
690
691
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDescription(d->m_deployAction->text());
    mbuild->addAction(cmd, Constants::G_BUILD_DEPLOY);

con's avatar
con committed
692
    // rebuild action
693
    d->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
694
                                                       Utils::ParameterAction::AlwaysEnabled, this);
Eike Ziller's avatar
Eike Ziller committed
695
    cmd = Core::ActionManager::registerAction(d->m_rebuildAction, Constants::REBUILD, globalcontext);
696
    cmd->setAttribute(Core::Command::CA_UpdateText);
697
    cmd->setDescription(d->m_rebuildAction->text());
698
    mbuild->addAction(cmd, Constants::G_BUILD_REBUILD);
con's avatar
con committed
699

700
701
    // clean action
    d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
Tobias Hunger's avatar
Tobias Hunger committed
702
                                                     Utils::ParameterAction::AlwaysEnabled, this);
Eike Ziller's avatar
Eike Ziller committed
703
    cmd = Core::ActionManager::registerAction(d->m_cleanAction, Constants::CLEAN, globalcontext);
Tobias Hunger's avatar
Tobias Hunger committed
704
    cmd->setAttribute(Core::Command::CA_UpdateText);
705
706
707
708
709
710
711
    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);
Eike Ziller's avatar
Eike Ziller committed
712
    cmd = Core::ActionManager::registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
713
714
715
716
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    // run action
    d->m_runAction = new QAction(runIcon, tr("Run"), this);
Eike Ziller's avatar
Eike Ziller committed
717
    cmd = Core::ActionManager::registerAction(d->m_runAction, Constants::RUN, globalcontext);
718
719
720
721
722
723
724
725
726
    cmd->setAttribute(Core::Command::CA_UpdateText);

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

    Core::ModeManager::addAction(cmd->action(), Constants::P_ACTION_RUN);

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

730
731
732
    // Publish action
    d->m_publishAction = new Utils::ParameterAction(tr("Publish Project..."), tr("Publish Project \"%1\"..."),
                                                    Utils::ParameterAction::AlwaysEnabled, this);
Eike Ziller's avatar
Eike Ziller committed
733
    cmd = Core::ActionManager::registerAction(d->m_publishAction, Constants::PUBLISH, globalcontext);
734
    cmd->setAttribute(Core::Command::CA_UpdateText);
735
    cmd->setDescription(d->m_publishAction->text());
736
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
737
738

    // build action (context menu)
739
    d->m_buildActionContextMenu = new QAction(tr("Build"), this);
Eike Ziller's avatar
Eike Ziller committed
740
    cmd = Core::ActionManager::registerAction(d->m_buildActionContextMenu, Constants::BUILDCM, projecTreeContext