projectexplorer.cpp 102 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2
3
4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.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
29
** If you have questions regarding the use of this file, please contact
** 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
56
#include "editorsettingspropertiespage.h"
#include "dependenciespanel.h"
con's avatar
con committed
57
58
59
60
#include "foldernavigationwidget.h"
#include "iprojectmanager.h"
#include "metatypedeclarations.h"
#include "nodesvisitor.h"
61
#include "appoutputpane.h"
con's avatar
con committed
62
63
64
65
#include "persistentsettings.h"
#include "pluginfilefactory.h"
#include "processstep.h"
#include "projectexplorerconstants.h"
66
#include "customwizard.h"
con's avatar
con committed
67
68
69
70
71
72
73
#include "projectfilewizardextension.h"
#include "projecttreewidget.h"
#include "projectwindow.h"
#include "removefiledialog.h"
#include "runsettingspropertiespage.h"
#include "scriptwrappers.h"
#include "session.h"
74
#include "projectnodes.h"
con's avatar
con committed
75
#include "sessiondialog.h"
Tobias Hunger's avatar
Tobias Hunger committed
76
#include "target.h"
77
#include "projectexplorersettingspage.h"
78
79
#include "projectwelcomepage.h"
#include "projectwelcomepagewidget.h"
80
#include "corelistenercheckingforrunningbuild.h"
81
#include "buildconfiguration.h"
82
#include "miniprojecttargetselector.h"
dt's avatar
dt committed
83
#include "taskhub.h"
84
85
#include "publishing/ipublishingwizardfactory.h"
#include "publishing/publishingwizardselectiondialog.h"
con's avatar
con committed
86

87
#ifdef Q_OS_WIN
88
#    include "windebuginterface.h"
89
90
91
#    include "msvctoolchain.h"
#endif

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/uniqueidmanager.h>
con's avatar
con committed
102
103
104
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/editormanager/ieditorfactory.h>
105
#include <coreplugin/editormanager/iexternaleditor.h>
con's avatar
con committed
106
107
108
109
#include <coreplugin/findplaceholder.h>
#include <coreplugin/basefilewizard.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/iversioncontrol.h>
110
#include <coreplugin/variablemanager.h>
111
#include <extensionsystem/pluginmanager.h>
112
#include <find/searchresultwindow.h>
113
#include <utils/consoleprocess.h>
hjk's avatar
hjk committed
114
#include <utils/qtcassert.h>
115
#include <utils/parameteraction.h>
116
#include <utils/stringutils.h>
con's avatar
con committed
117

118
#include <QtCore/QtPlugin>
hjk's avatar
hjk committed
119
#include <QtCore/QDateTime>
con's avatar
con committed
120
121
#include <QtCore/QDebug>
#include <QtCore/QSettings>
hjk's avatar
hjk committed
122

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

131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*!
    \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.
*/

149
150
Q_DECLARE_METATYPE(Core::IEditorFactory*)
Q_DECLARE_METATYPE(Core::IExternalEditor*)
con's avatar
con committed
151
152
153
154
155

namespace {
bool debug = false;
}

con's avatar
con committed
156
157
158
static const char * const kCurrentProjectPath = "CurrentProject:Path";
static const char * const kCurrentProjectFilePath = "CurrentProject:FilePath";

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

    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;
224
    Internal::AppOutputPane *m_outputPane;
225
226
227
228
229

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

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

237
    Core::IMode *m_projectsMode;
238
239

    ToolChainManager *m_toolChainManager;
240
241
242
243
244
245
};

ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
    m_currentProject(0),
    m_currentNode(0),
    m_delayedRunConfiguration(0),
246
247
    m_projectsMode(0),
    m_toolChainManager(0)
248
249
250
{
}

251
252
253
class ProjectsMode : public Core::IMode
{
public:
254
255
256
257
    ProjectsMode(QWidget *proWindow)
    {
        setWidget(proWindow);
        setContext(Core::Context(Constants::C_PROJECTEXPLORER));
258
259
260
261
262
263
        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"));
264
    }
265
266
};

267
268
}  // namespace ProjectExplorer

con's avatar
con committed
269
270
271
272
273
274
275
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;


ProjectExplorerPlugin *ProjectExplorerPlugin::m_instance = 0;

ProjectExplorerPlugin::ProjectExplorerPlugin()
276
    : d(new ProjectExplorerPluginPrivate)
con's avatar
con committed
277
278
279
280
281
282
{
    m_instance = this;
}

ProjectExplorerPlugin::~ProjectExplorerPlugin()
{
283
284
    removeObject(d->m_welcomePage);
    delete d->m_welcomePage;
285
    delete d->m_toolChainManager;
con's avatar
con committed
286
    removeObject(this);
287
    delete d;
con's avatar
con committed
288
289
290
291
292
293
294
}

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

295
296
297
298
299
300
bool ProjectExplorerPlugin::parseArguments(const QStringList &arguments, QString * /* error */)
{
    CustomWizard::setVerbose(arguments.count(QLatin1String("-customwizard-verbose")));
    return true;
}

301
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
con's avatar
con committed
302
{
303
304
    if (!parseArguments(arguments, error))
        return false;
dt's avatar
dt committed
305
306
    addObject(this);

307
    // Add ToolChainFactories:
308
#ifdef Q_OS_WIN
309
310
    addAutoReleasedObject(new WinDebugInterface);

311
312
    addAutoReleasedObject(new Internal::MingwToolChainFactory);
    addAutoReleasedObject(new Internal::MsvcToolChainFactory);
313
314
315
#else
    addAutoReleasedObject(new Internal::GccToolChainFactory);
    addAutoReleasedObject(new Internal::LinuxIccToolChainFactory);
316
317
318
319
320
321
#endif

    d->m_toolChainManager = new ToolChainManager(this);

    addAutoReleasedObject(new Internal::ToolChainOptionsPage);

dt's avatar
dt committed
322
    addAutoReleasedObject(new TaskHub);
323

324
325
    Core::ICore *core = Core::ICore::instance();
    Core::ActionManager *am = core->actionManager();
326
    connect(core, SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards()));
con's avatar
con committed
327

328
    d->m_welcomePage = new ProjectWelcomePage;
329
    connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
330
    addObject(d->m_welcomePage);
con's avatar
con committed
331

hjk's avatar
hjk committed
332
333
    connect(core->fileManager(), SIGNAL(currentFileChanged(QString)),
            this, SLOT(setCurrentFile(QString)));
con's avatar
con committed
334

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

337
    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project *)),
con's avatar
con committed
338
            this, SIGNAL(fileListChanged()));
339
    connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
con's avatar
con committed
340
            this, SLOT(invalidateProject(ProjectExplorer::Project *)));
341
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
con's avatar
con committed
342
            this, SIGNAL(fileListChanged()));
343
344
345
346
    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*)));
347
    connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project *)),
con's avatar
con committed
348
            this, SLOT(startupProjectChanged()));
349
350
    connect(d->m_session, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
            this, SLOT(updateActions()));
351
352
    connect(d->m_session, SIGNAL(sessionLoaded()),
            this, SLOT(updateActions()));
353
354
    connect(d->m_session, SIGNAL(sessionLoaded()),
            this, SLOT(updateWelcomePage()));
con's avatar
con committed
355

356
    d->m_proWindow = new ProjectWindow;
con's avatar
con committed
357

358
    Core::Context globalcontext(Core::Constants::C_GLOBAL);
dt's avatar
dt committed
359
    Core::Context projecTreeContext(Constants::C_PROJECT_TREE);
con's avatar
con committed
360

361
    d->m_projectsMode = new ProjectsMode(d->m_proWindow);
362
363
    d->m_projectsMode->setEnabled(session()->startupProject());
    addAutoReleasedObject(d->m_projectsMode);
364
    d->m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(d->m_proWindow));
con's avatar
con committed
365

366
    addAutoReleasedObject(new CopyTaskHandler);
367
    addAutoReleasedObject(new ShowInEditorTaskHandler);
368
    addAutoReleasedObject(new VcsAnnotateTaskHandler);
369

370
371
    d->m_buildManager = new BuildManager(this);
    connect(d->m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
con's avatar
con committed
372
            this, SLOT(buildStateChanged(ProjectExplorer::Project *)));
373
    connect(d->m_buildManager, SIGNAL(buildQueueFinished(bool)),
con's avatar
con committed
374
375
            this, SLOT(buildQueueFinished(bool)));

376
    addAutoReleasedObject(new CoreListener);
con's avatar
con committed
377

378
    d->m_outputPane = new AppOutputPane;
379
380
381
    addAutoReleasedObject(d->m_outputPane);
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
            d->m_outputPane, SLOT(projectRemoved()));
con's avatar
con committed
382

383
    AllProjectsFilter *allProjectsFilter = new AllProjectsFilter(this);
con's avatar
con committed
384
385
    addAutoReleasedObject(allProjectsFilter);

386
    CurrentProjectFilter *currentProjectFilter = new CurrentProjectFilter(this);
con's avatar
con committed
387
388
389
390
391
    addAutoReleasedObject(currentProjectFilter);

    addAutoReleasedObject(new BuildSettingsPanelFactory);
    addAutoReleasedObject(new RunSettingsPanelFactory);
    addAutoReleasedObject(new EditorSettingsPanelFactory);
392
    addAutoReleasedObject(new DependenciesPanelFactory(d->m_session));
con's avatar
con committed
393
394
395
396

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

397
    AllProjectsFind *allProjectsFind = new AllProjectsFind(this,
398
        Find::SearchResultWindow::instance());
con's avatar
con committed
399
400
    addAutoReleasedObject(allProjectsFind);

401
    CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this,
402
        Find::SearchResultWindow::instance());
con's avatar
con committed
403
404
    addAutoReleasedObject(currentProjectFind);

405
    addAutoReleasedObject(new LocalApplicationRunControlFactory);
con's avatar
con committed
406
407
    addAutoReleasedObject(new CustomExecutableRunConfigurationFactory);

408
    addAutoReleasedObject(new ProjectFileWizardExtension);
con's avatar
con committed
409

410
411
412
    // Settings page
    addAutoReleasedObject(new ProjectExplorerSettingsPage);

con's avatar
con committed
413
    // context menus
414
    Core::ActionContainer *msessionContextMenu =
con's avatar
con committed
415
        am->createMenu(Constants::M_SESSIONCONTEXT);
dt's avatar
dt committed
416
    Core::ActionContainer *mprojectContextMenu =
con's avatar
con committed
417
        am->createMenu(Constants::M_PROJECTCONTEXT);
dt's avatar
dt committed
418
    Core::ActionContainer *msubProjectContextMenu =
con's avatar
con committed
419
        am->createMenu(Constants::M_SUBPROJECTCONTEXT);
dt's avatar
dt committed
420
    Core::ActionContainer *mfolderContextMenu =
con's avatar
con committed
421
        am->createMenu(Constants::M_FOLDERCONTEXT);
dt's avatar
dt committed
422
    Core::ActionContainer *mfileContextMenu =
con's avatar
con committed
423
424
        am->createMenu(Constants::M_FILECONTEXT);

425
    d->m_sessionContextMenu = msessionContextMenu->menu();
dt's avatar
dt committed
426
427
428
429
    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
430

431
    Core::ActionContainer *mfile =
con's avatar
con committed
432
        am->actionContainer(Core::Constants::M_FILE);
433
    Core::ActionContainer *menubar =
con's avatar
con committed
434
435
436
        am->actionContainer(Core::Constants::MENU_BAR);

    // mode manager (for fancy actions)
437
    Core::ModeManager *modeManager = core->modeManager();
con's avatar
con committed
438
439

    // build menu
440
    Core::ActionContainer *mbuild =
con's avatar
con committed
441
        am->createMenu(Constants::M_BUILDPROJECT);
442
    mbuild->menu()->setTitle(tr("&Build"));
con's avatar
con committed
443
444
445
    menubar->addMenu(mbuild, Core::Constants::G_VIEW);

    // debug menu
446
    Core::ActionContainer *mdebug =
con's avatar
con committed
447
        am->createMenu(Constants::M_DEBUG);
448
    mdebug->menu()->setTitle(tr("&Debug"));
con's avatar
con committed
449
450
    menubar->addMenu(mdebug, Core::Constants::G_VIEW);

451
452
453
454
    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
455
456
457
458
459
460
461
462
463

    //
    // 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
464
    mbuild->appendGroup(Constants::G_BUILD_RUN);
con's avatar
con committed
465
466
467
468
469
470

    msessionContextMenu->appendGroup(Constants::G_SESSION_BUILD);
    msessionContextMenu->appendGroup(Constants::G_SESSION_FILES);
    msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER);
    msessionContextMenu->appendGroup(Constants::G_SESSION_CONFIG);

dt's avatar
dt committed
471
472
473
474
475
476
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_OTHER);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_CONFIG);
con's avatar
con committed
477

dt's avatar
dt committed
478
479
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
dt's avatar
dt committed
480
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
dt's avatar
dt committed
481
482
483
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_OTHER);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_CONFIG);
con's avatar
con committed
484

dt's avatar
dt committed
485
486
487
488
489
490
491
492
    Core::ActionContainer *runMenu = Core::ICore::instance()->actionManager()->createMenu(Constants::RUNMENUCONTEXTMENU);
    runMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
    QIcon runIcon(Constants::ICON_RUN);
    runIcon.addFile(Constants::ICON_RUN_SMALL);
    runMenu->menu()->setIcon(runIcon);
    runMenu->menu()->setTitle("Run");
    msubProjectContextMenu->addMenu(runMenu, ProjectExplorer::Constants::G_PROJECT_RUN);

dt's avatar
dt committed
493
494
495
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
con's avatar
con committed
496

dt's avatar
dt committed
497
498
499
    mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
    mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
    mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
con's avatar
con committed
500
501

    // "open with" submenu
502
    Core::ActionContainer * const openWith =
con's avatar
con committed
503
            am->createMenu(ProjectExplorer::Constants::M_OPENFILEWITHCONTEXT);
504
    openWith->setOnAllDisabledBehavior(Core::ActionContainer::Show);
505
506
    d->m_openWithMenu = openWith->menu();
    d->m_openWithMenu->setTitle(tr("Open With"));
con's avatar
con committed
507

508
    connect(d->m_openWithMenu, SIGNAL(triggered(QAction *)),
con's avatar
con committed
509
510
511
512
513
514
            this, SLOT(openWithMenuTriggered(QAction *)));

    //
    // Separators
    //

con's avatar
con committed
515
    Core::Command *cmd;
con's avatar
con committed
516
517
518
519
    QAction *sep;

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
520
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Build.Sep"), globalcontext);
con's avatar
con committed
521
522
523
524
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
525
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Files.Sep"), projecTreeContext);
con's avatar
con committed
526
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);
dt's avatar
dt committed
527
528
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
con's avatar
con committed
529
530
531

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
532
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Config.Sep"), projecTreeContext);
con's avatar
con committed
533
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_CONFIG);
dt's avatar
dt committed
534
535
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_CONFIG);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_CONFIG);
con's avatar
con committed
536
537
538

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
539
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Projects.Sep"), globalcontext);
con's avatar
con committed
540
541
542
543
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
544
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Other.Sep"), globalcontext);
con's avatar
con committed
545
546
    mbuild->addAction(cmd, Constants::G_BUILD_OTHER);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_OTHER);
dt's avatar
dt committed
547
548
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_OTHER);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_OTHER);
con's avatar
con committed
549
550
551

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
552
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Run.Sep"), globalcontext);
con's avatar
con committed
553
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
dt's avatar
dt committed
554
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
con's avatar
con committed
555
556
557

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
558
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.CancelBuild.Sep"), globalcontext);
con's avatar
con committed
559
560
561
562
563
564
565
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    //
    // Actions
    //

    // new action
566
567
    d->m_newAction = new QAction(tr("New Project..."), this);
    cmd = am->registerAction(d->m_newAction, Constants::NEWPROJECT, globalcontext);
con's avatar
con committed
568
569
570
571
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+N")));
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // open action
572
573
    d->m_loadAction = new QAction(tr("Load Project..."), this);
    cmd = am->registerAction(d->m_loadAction, Constants::LOAD, globalcontext);
574
#ifndef Q_WS_MAC
con's avatar
con committed
575
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+O")));
576
#endif
con's avatar
con committed
577
578
579
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // Default open action
580
581
    d->m_openFileAction = new QAction(tr("Open File"), this);
    cmd = am->registerAction(d->m_openFileAction, ProjectExplorer::Constants::OPENFILE,
dt's avatar
dt committed
582
583
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
con's avatar
con committed
584

585
    d->m_showInGraphicalShell = new QAction(FolderNavigationWidget::msgGraphicalShellAction(), this);
586
    cmd = am->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(FolderNavigationWidget::msgTerminalAction(), this);
592
    cmd = am->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 =
mae's avatar
mae committed
602
        am->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
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
    // 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
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);
629
    cmd = am->registerAction(d->m_unloadAction, Constants::UNLOAD, globalcontext);
con's avatar
con committed
630
    cmd->setAttribute(Core::Command::CA_UpdateText);
631
    cmd->setDefaultText(d->m_unloadAction->text());
con's avatar
con committed
632
633
634
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    // unload session action
635
636
    d->m_clearSession = new QAction(tr("Close All Projects"), this);
    cmd = am->registerAction(d->m_clearSession, Constants::CLEARSESSION, globalcontext);
con's avatar
con committed
637
638
639
640
641
642
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // build session action
    QIcon buildIcon(Constants::ICON_BUILD);
    buildIcon.addFile(Constants::ICON_BUILD_SMALL);
643
644
    d->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
    cmd = am->registerAction(d->m_buildSessionAction, Constants::BUILDSESSION, globalcontext);
con's avatar
con committed
645
646
647
648
649
650
651
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // rebuild session action
    QIcon rebuildIcon(Constants::ICON_REBUILD);
    rebuildIcon.addFile(Constants::ICON_REBUILD_SMALL);
652
653
    d->m_rebuildSessionAction = new QAction(rebuildIcon, tr("Rebuild All"), this);
    cmd = am->registerAction(d->m_rebuildSessionAction, Constants::REBUILDSESSION, globalcontext);
con's avatar
con committed
654
655
656
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

Tobias Hunger's avatar
Tobias Hunger committed
657
658
659
660
661
662
    // 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
663
664
665
    // clean session
    QIcon cleanIcon(Constants::ICON_CLEAN);
    cleanIcon.addFile(Constants::ICON_CLEAN_SMALL);
666
667
    d->m_cleanSessionAction = new QAction(cleanIcon, tr("Clean All"), this);
    cmd = am->registerAction(d->m_cleanSessionAction, Constants::CLEANSESSION, globalcontext);
con's avatar
con committed
668
669
670
671
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // 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);
675
    cmd = am->registerAction(d->m_buildAction, Constants::BUILD, globalcontext);
676
    cmd->setAttribute(Core::Command::CA_UpdateText);
677
    cmd->setDefaultText(d->m_buildAction->text());
con's avatar
con committed
678
679
680
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

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

con's avatar
con committed
684
    // rebuild action
685
    d->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
686
                                                       Utils::ParameterAction::AlwaysEnabled, this);
687
    cmd = am->registerAction(d->m_rebuildAction, Constants::REBUILD, globalcontext);
688
    cmd->setAttribute(Core::Command::CA_UpdateText);
689
    cmd->setDefaultText(d->m_rebuildAction->text());
con's avatar
con committed
690
691
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

Tobias Hunger's avatar
Tobias Hunger committed
692
693
694
695
696
697
698
699
    // 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);
    cmd->setDefaultText(d->m_deployAction->text());
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

700
701
702
703
704
705
706
707
    // 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);
    cmd->setDefaultText(d->m_publishAction->text());
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

con's avatar
con committed
708
    // clean action
709
    d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
710
                                                     Utils::ParameterAction::AlwaysEnabled, this);
711
    cmd = am->registerAction(d->m_cleanAction, Constants::CLEAN, globalcontext);
712
    cmd->setAttribute(Core::Command::CA_UpdateText);
713
    cmd->setDefaultText(d->m_cleanAction->text());
con's avatar
con committed
714
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
715
716
717
718

    // 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
719
    cmd = am->registerAction(d->m_buildActionContextMenu, Constants::BUILDCM, projecTreeContext);
720
721
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_buildActionContextMenu->text());
dt's avatar
dt committed
722
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
723
724
725
726

    // 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
727
    cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::REBUILDCM, projecTreeContext);
728
729
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_rebuildActionContextMenu->text());
dt's avatar
dt committed
730
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
731

Tobias Hunger's avatar
Tobias Hunger committed
732
733
734
    // 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
735
    cmd = am->registerAction(d->m_deployActionContextMenu, Constants::DEPLOYCM, projecTreeContext);
Tobias Hunger's avatar
Tobias Hunger committed
736
737
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_deployActionContextMenu->text());
dt's avatar
dt committed
738
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
Tobias Hunger's avatar
Tobias Hunger committed
739

740
741
742
    // 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
743
    cmd = am->registerAction(d->m_cleanActionContextMenu, Constants::CLEANCM, projecTreeContext);
744
745
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_cleanActionContextMenu->text());
dt's avatar
dt committed
746
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
con's avatar
con committed
747

748
    // build without dependencies action
749
750
    d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this);
    cmd = am->registerAction(d->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext);
751

752
    // rebuild without dependencies action
753
754
    d->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this);
    cmd = am->registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext);
755

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

760
    // clean without dependencies action
761
762
    d->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this);
    cmd = am->registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext);
763

con's avatar
con committed
764
    // run action
765
766
    d->m_runAction = new QAction(runIcon, tr("Run"), this);
    cmd = am->registerAction(d->m_runAction, Constants::RUN, globalcontext);
767
768
    cmd->setAttribute(Core::Command::CA_UpdateText);

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

772
    modeManager->addAction(cmd->action(), Constants::P_ACTION_RUN);
con's avatar
con committed
773

774
    d->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this);
dt's avatar
dt committed
775
776
    cmd = am->registerAction(d->m_runActionContextMenu, Constants::RUNCONTEXTMENU, projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
dt's avatar
dt committed
777
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
778

con's avatar
con committed
779
    // cancel build action
780
781
    d->m_cancelBuildAction = new QAction(tr("Cancel Build"), this);
    cmd = am->registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
con's avatar
con committed
782
783
784
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    // add new file action
785
786
    d->m_addNewFileAction = new QAction(tr("Add New..."), this);
    cmd = am->registerAction(d->m_addNewFileAction, ProjectExplorer::Constants::ADDNEWFILE,
dt's avatar
dt committed
787
788
789
790
                       projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
791
792

    // add existing file action
793
794
    d->m_addExistingFilesAction = new QAction(tr("Add Existing Files..."), this);
    cmd = am->registerAction(d->m_addExistingFilesAction, ProjectExplorer::Constants::ADDEXISTINGFILES,
dt's avatar
dt committed
795
796
797
798
                       projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
799

800
801
802
    // new subproject action
    d->m_addNewSubprojectAction = new QAction(tr("New Subproject..."), this);
    cmd = am->registerAction(d->m_addNewSubprojectAction, ProjectExplorer::Constants::ADDNEWSUBPROJECT,
dt's avatar
dt committed
803
804
805
                       projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
806
807

    // unload project again, in right position
dt's avatar
dt committed
808
    mprojectContextMenu->addAction(am->command(Constants::UNLOAD), Constants::G_PROJECT_FILES);
809

con's avatar
con committed
810
    // remove file action
811
812
    d->m_removeFileAction = new QAction(tr("Remove File..."), this);
    cmd = am->registerAction(d->m_removeFileAction, ProjectExplorer::Constants::REMOVEFILE,
dt's avatar
dt committed
813
                       projecTreeContext);
814
    cmd->setDefaultKeySequence(QKeySequence::Delete);
dt's avatar
dt committed
815
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
con's avatar
con committed
816

Friedemann Kleint's avatar
Friedemann Kleint committed
817
818
    //: Remove project from parent profile (Project explorer view); will not physically delete any files.
    d->m_removeProjectAction = new QAction(tr("Remove Project..."), this);
819
    cmd = am->registerAction(d->m_removeProjectAction, ProjectExplorer::Constants::REMOVEPROJECT,
dt's avatar
dt committed
820
821
                       projecTreeContext);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
822

dt's avatar
dt committed
823
    // delete file action
824
825
    d->m_deleteFileAction = new QAction(tr("Delete File..."), this);
    cmd = am->registerAction(d->m_deleteFileAction, ProjectExplorer::Constants::DELETEFILE,
dt's avatar
dt committed
826
                             projecTreeContext);
827
    cmd->setDefaultKeySequence(QKeySequence::Delete);
dt's avatar
dt committed
828
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
829

dt's avatar
dt committed
830
    // renamefile action
831
832
    d->m_renameFileAction = new QAction(tr("Rename"), this);
    cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE,
dt's avatar
dt committed
833
834
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
dt's avatar
dt committed
835
836
837
838
    // Not yet used by anyone, so hide for now
//    mfolder->addAction(cmd, Constants::G_FOLDER_FILES);
//    msubProject->addAction(cmd, Constants::G_FOLDER_FILES);
//    mproject->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
839

840
841
842
    // set startup project action
    d->m_setStartupProjectAction = new QAction(tr("Set as Startup Project"), this);
    cmd = am->registerAction(d->m_setStartupProjectAction, ProjectExplorer::Constants::SETSTARTUP,
dt's avatar
dt committed
843
844
                             projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FIRST);
845

846
847
    // target selector
    d->m_projectSelectorAction = new QAction(this);
848
    d->m_projectSelectorAction->setCheckable(true);
849
850
851
    d->m_projectSelectorAction->setEnabled(false);
    QWidget *mainWindow = Core::ICore::instance()->mainWindow();
    d->m_targetSelector = new Internal::MiniProjectTargetSelector(d->m_projectSelectorAction, mainWindow);
852
    connect(d->m_projectSelectorAction, SIGNAL(triggered()), d->m_targetSelector, SLOT(show()));
853
    modeManager->addProjectSelector(d->m_projectSelectorAction);
854
855
856
857
858
859

    d->m_projectSelectorActionMenu = new QAction(this);
    d->m_projectSelectorActionMenu->setEnabled(false);
    d->m_projectSelectorActionMenu->setText(tr("Open Build/Run Target Selector..."));
    connect(d->m_projectSelectorActionMenu, SIGNAL(triggered()), d->m_targetSelector, SLOT(show()));
    cmd = am->registerAction(d->m_projectSelectorActionMenu, ProjectExplorer::Constants::SELECTTARGET,
Tobias Hunger's avatar
Tobias Hunger committed
860
861
                       globalcontext);
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T")));
862
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
863
864
865

    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
            d->m_targetSelector, SLOT(addProject(ProjectExplorer::Project*)));
866
    connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
867
868
869
870
871
872
            d->m_targetSelector, SLOT(removeProject(ProjectExplorer::Project*)));
    connect(d->m_targetSelector, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
            this, SLOT(setStartupProject(ProjectExplorer::Project*)));
    connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
            d->m_targetSelector, SLOT(changeStartupProject(ProjectExplorer::Project*)));

873
    connect(core, SIGNAL(saveSettingsRequested()),
con's avatar
con committed
874
875
        this, SLOT(savePersistentSettings()));

hjk's avatar
hjk committed
876
877
    addAutoReleasedObject(new ProjectTreeWidgetFactory);
    addAutoReleasedObject(new FolderNavigationWidgetFactory);
878
    addAutoReleasedObject(new DeployConfigurationFactory);
con's avatar
con committed
879

880
881
882
883
884
    if (QSettings *s = core->settings()) {
        const QStringList fileNames = s->value("ProjectExplorer/RecentProjects/FileNames").toStringList();
        const QStringList displayNames = s->value("ProjectExplorer/RecentProjects/DisplayNames").toStringList();
        if (fileNames.size() == displayNames.size()) {
            for (int i = 0; i < fileNames.size(); ++i) {
885
                if (QFileInfo(fileNames.at(i)).isFile())
886
                    d->m_recentProjects.append(qMakePair(fileNames.at(i), displayNames.at(i)));
887
888
889
890
            }
        }
    }

891
    if (QSettings *s = core->settings()) {
Tobias Hunger's avatar
Tobias Hunger committed
892
893
        d->m_projectExplorerSettings.buildBeforeDeploy = s->value("ProjectExplorer/Settings/BuildBeforeDeploy", true).toBool();
        d->m_projectExplorerSettings.deployBeforeRun = s->value("ProjectExplorer/Settings/DeployBeforeRun", true).toBool();
894
895
        d->m_projectExplorerSettings.saveBeforeBuild = s->value("ProjectExplorer/Settings/SaveBeforeBuild", false).toBool();
        d->m_projectExplorerSettings.showCompilerOutput = s->value("ProjectExplorer/Settings/ShowCompilerOutput", false).toBool();
896
        d->m_projectExplorerSettings.showRunOutput = s->value("ProjectExplorer/Settings/ShowRunOutput", true).toBool();
897
        d->m_projectExplorerSettings.cleanOldAppOutput = s->value("ProjectExplorer/Settings/CleanOldAppOutput", false).toBool();
898
        d->m_projectExplorerSettings.wrapAppOutput = s->value("ProjectExplorer/Settings/WrapAppOutput", true).toBool();