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
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
con's avatar
con committed
8
**
con's avatar
con committed
9
** No Commercial Usage
10
**
con's avatar
con committed
11
12
13
14
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
15
**
16
** GNU Lesser General Public License Usage
17
**
18
19
20
21
22
23
** 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.
24
**
con's avatar
con committed
25
26
27
28
29
30
** In addition, as a special exception, Nokia gives you certain additional
** rights.  These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
con's avatar
con committed
31
**
32
**************************************************************************/
hjk's avatar
hjk committed
33

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

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

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

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

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

129
130
Q_DECLARE_METATYPE(Core::IEditorFactory*)
Q_DECLARE_METATYPE(Core::IExternalEditor*)
con's avatar
con committed
131
132
133
134
135

namespace {
bool debug = false;
}

con's avatar
con committed
136
137
138
static const char * const kCurrentProjectPath = "CurrentProject:Path";
static const char * const kCurrentProjectFilePath = "CurrentProject:FilePath";

139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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;
156
    Utils::ParameterAction *m_unloadAction;
157
158
    QAction *m_clearSession;
    QAction *m_buildProjectOnlyAction;
159
    Utils::ParameterAction *m_buildAction;
160
    Utils::ParameterAction *m_buildActionContextMenu;
161
162
    QAction *m_buildSessionAction;
    QAction *m_rebuildProjectOnlyAction;
163
    Utils::ParameterAction *m_rebuildAction;
164
    Utils::ParameterAction *m_rebuildActionContextMenu;
165
166
    QAction *m_rebuildSessionAction;
    QAction *m_cleanProjectOnlyAction;
Tobias Hunger's avatar
Tobias Hunger committed
167
168
169
170
    QAction *m_deployProjectOnlyAction;
    Utils::ParameterAction *m_deployAction;
    Utils::ParameterAction *m_deployActionContextMenu;
    QAction *m_deploySessionAction;
171
    Utils::ParameterAction *m_publishAction;
172
    Utils::ParameterAction *m_cleanAction;
173
    Utils::ParameterAction *m_cleanActionContextMenu;
174
175
176
177
178
179
    QAction *m_cleanSessionAction;
    QAction *m_runAction;
    QAction *m_runActionContextMenu;
    QAction *m_cancelBuildAction;
    QAction *m_addNewFileAction;
    QAction *m_addExistingFilesAction;
180
    QAction *m_addNewSubprojectAction;
181
    QAction *m_removeFileAction;
182
    QAction *m_removeProjectAction;
183
    QAction *m_deleteFileAction;
184
    QAction *m_renameFileAction;
dt's avatar
dt committed
185
186
187
    QAction *m_openFileAction;
    QAction *m_showInGraphicalShell;
    QAction *m_openTerminalHere;
188
    QAction *m_setStartupProjectAction;
189
    QAction *m_projectSelectorAction;
190
    QAction *m_projectSelectorActionMenu;
dt's avatar
dt committed
191
    QAction *m_runSubProject;
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209

    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;
    Internal::OutputPane *m_outputPane;

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

    QString m_lastOpenDirectory;
210
    RunConfiguration *m_delayedRunConfiguration; // TODO this is not right
211
212
    QString m_runMode;
    QString m_projectFilterString;
213
    Internal::MiniProjectTargetSelector * m_targetSelector;
214
    Internal::ProjectExplorerSettings m_projectExplorerSettings;
215
    Internal::ProjectWelcomePage *m_welcomePage;
216

217
    Core::IMode *m_projectsMode;
218
219

    ToolChainManager *m_toolChainManager;
220
221
222
223
224
225
};

ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
    m_currentProject(0),
    m_currentNode(0),
    m_delayedRunConfiguration(0),
226
227
    m_projectsMode(0),
    m_toolChainManager(0)
228
229
230
{
}

231
232
233
234
235
class ProjectsMode : public Core::IMode
{
public:
    ProjectsMode(QWidget *proWindow) : m_widget(proWindow) {}

Friedemann Kleint's avatar
Friedemann Kleint committed
236
    QString displayName() const { return QCoreApplication::translate("ProjectExplorer::ProjectsMode", "Projects"); }
237
238
239
240
241
242
243
244
245
246
247
248
249
    QIcon icon() const { return QIcon(QLatin1String(":/fancyactionbar/images/mode_Project.png")); }
    int priority() const { return Constants::P_MODE_SESSION; }
    QWidget *widget() { return m_widget; }
    QString id() const { return QLatin1String(Constants::MODE_SESSION); }
    QString type() const { return QString(); }
    Core::Context context() const { return Core::Context(Constants::C_PROJECTEXPLORER); }
    QString contextHelpId() const { return QLatin1String("Managing Projects"); }

private:
    QWidget *m_widget;
    QIcon m_icon;
};

250
251
}  // namespace ProjectExplorer

con's avatar
con committed
252
253
254
255
256
257
258
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;


ProjectExplorerPlugin *ProjectExplorerPlugin::m_instance = 0;

ProjectExplorerPlugin::ProjectExplorerPlugin()
259
    : d(new ProjectExplorerPluginPrivate)
con's avatar
con committed
260
261
262
263
264
265
{
    m_instance = this;
}

ProjectExplorerPlugin::~ProjectExplorerPlugin()
{
266
267
    removeObject(d->m_welcomePage);
    delete d->m_welcomePage;
268
    delete d->m_toolChainManager;
con's avatar
con committed
269
    removeObject(this);
270
    delete d;
con's avatar
con committed
271
272
273
274
275
276
277
}

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

278
279
280
281
282
283
bool ProjectExplorerPlugin::parseArguments(const QStringList &arguments, QString * /* error */)
{
    CustomWizard::setVerbose(arguments.count(QLatin1String("-customwizard-verbose")));
    return true;
}

284
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
con's avatar
con committed
285
{
286
287
    if (!parseArguments(arguments, error))
        return false;
dt's avatar
dt committed
288
289
    addObject(this);

290
291
292
293
294
295
296
297
298
299
300
301
302
    // Add ToolChainFactories:
#ifndef Q_OS_WIN
    addAutoReleasedObject(new Internal::GccToolChainFactory);
    addAutoReleasedObject(new Internal::LinuxIccToolChainFactory);
#else
    addAutoReleasedObject(new Internal::MingwToolChainFactory);
    addAutoReleasedObject(new Internal::MsvcToolChainFactory);
#endif

    d->m_toolChainManager = new ToolChainManager(this);

    addAutoReleasedObject(new Internal::ToolChainOptionsPage);

dt's avatar
dt committed
303
    addAutoReleasedObject(new TaskHub);
304

305
306
    Core::ICore *core = Core::ICore::instance();
    Core::ActionManager *am = core->actionManager();
307
    connect(core, SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards()));
con's avatar
con committed
308

309
    d->m_welcomePage = new ProjectWelcomePage;
310
    connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
311
    addObject(d->m_welcomePage);
con's avatar
con committed
312

hjk's avatar
hjk committed
313
314
    connect(core->fileManager(), SIGNAL(currentFileChanged(QString)),
            this, SLOT(setCurrentFile(QString)));
con's avatar
con committed
315

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

318
    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project *)),
con's avatar
con committed
319
            this, SIGNAL(fileListChanged()));
320
    connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
con's avatar
con committed
321
            this, SLOT(invalidateProject(ProjectExplorer::Project *)));
322
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
con's avatar
con committed
323
            this, SIGNAL(fileListChanged()));
324
325
326
327
    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*)));
328
    connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project *)),
con's avatar
con committed
329
            this, SLOT(startupProjectChanged()));
330
331
    connect(d->m_session, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
            this, SLOT(updateActions()));
con's avatar
con committed
332

333
    d->m_proWindow = new ProjectWindow;
con's avatar
con committed
334

335
    Core::Context globalcontext(Core::Constants::C_GLOBAL);
dt's avatar
dt committed
336
    Core::Context projecTreeContext(Constants::C_PROJECT_TREE);
con's avatar
con committed
337

338
    d->m_projectsMode = new ProjectsMode(d->m_proWindow);
339
340
    d->m_projectsMode->setEnabled(session()->startupProject());
    addAutoReleasedObject(d->m_projectsMode);
341
    d->m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(d->m_proWindow));
con's avatar
con committed
342

343
    addAutoReleasedObject(new CopyTaskHandler);
344
    addAutoReleasedObject(new ShowInEditorTaskHandler);
345
    addAutoReleasedObject(new VcsAnnotateTaskHandler);
346

347
348
    d->m_buildManager = new BuildManager(this);
    connect(d->m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
con's avatar
con committed
349
            this, SLOT(buildStateChanged(ProjectExplorer::Project *)));
350
    connect(d->m_buildManager, SIGNAL(buildQueueFinished(bool)),
con's avatar
con committed
351
352
            this, SLOT(buildQueueFinished(bool)));

353
    addAutoReleasedObject(new CoreListener);
con's avatar
con committed
354

355
356
357
358
    d->m_outputPane = new OutputPane;
    addAutoReleasedObject(d->m_outputPane);
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
            d->m_outputPane, SLOT(projectRemoved()));
con's avatar
con committed
359

360
    AllProjectsFilter *allProjectsFilter = new AllProjectsFilter(this);
con's avatar
con committed
361
362
    addAutoReleasedObject(allProjectsFilter);

363
    CurrentProjectFilter *currentProjectFilter = new CurrentProjectFilter(this);
con's avatar
con committed
364
365
366
367
368
    addAutoReleasedObject(currentProjectFilter);

    addAutoReleasedObject(new BuildSettingsPanelFactory);
    addAutoReleasedObject(new RunSettingsPanelFactory);
    addAutoReleasedObject(new EditorSettingsPanelFactory);
369
    addAutoReleasedObject(new DependenciesPanelFactory(d->m_session));
con's avatar
con committed
370
371
372
373

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

374
    AllProjectsFind *allProjectsFind = new AllProjectsFind(this,
375
        Find::SearchResultWindow::instance());
con's avatar
con committed
376
377
    addAutoReleasedObject(allProjectsFind);

378
    CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this,
379
        Find::SearchResultWindow::instance());
con's avatar
con committed
380
381
    addAutoReleasedObject(currentProjectFind);

382
    addAutoReleasedObject(new LocalApplicationRunControlFactory);
con's avatar
con committed
383
384
    addAutoReleasedObject(new CustomExecutableRunConfigurationFactory);

385
    addAutoReleasedObject(new ProjectFileWizardExtension);
con's avatar
con committed
386

387
388
389
    // Settings page
    addAutoReleasedObject(new ProjectExplorerSettingsPage);

con's avatar
con committed
390
    // context menus
391
    Core::ActionContainer *msessionContextMenu =
con's avatar
con committed
392
        am->createMenu(Constants::M_SESSIONCONTEXT);
dt's avatar
dt committed
393
    Core::ActionContainer *mprojectContextMenu =
con's avatar
con committed
394
        am->createMenu(Constants::M_PROJECTCONTEXT);
dt's avatar
dt committed
395
    Core::ActionContainer *msubProjectContextMenu =
con's avatar
con committed
396
        am->createMenu(Constants::M_SUBPROJECTCONTEXT);
dt's avatar
dt committed
397
    Core::ActionContainer *mfolderContextMenu =
con's avatar
con committed
398
        am->createMenu(Constants::M_FOLDERCONTEXT);
dt's avatar
dt committed
399
    Core::ActionContainer *mfileContextMenu =
con's avatar
con committed
400
401
        am->createMenu(Constants::M_FILECONTEXT);

402
    d->m_sessionContextMenu = msessionContextMenu->menu();
dt's avatar
dt committed
403
404
405
406
    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
407

408
    Core::ActionContainer *mfile =
con's avatar
con committed
409
        am->actionContainer(Core::Constants::M_FILE);
410
    Core::ActionContainer *menubar =
con's avatar
con committed
411
412
413
        am->actionContainer(Core::Constants::MENU_BAR);

    // mode manager (for fancy actions)
414
    Core::ModeManager *modeManager = core->modeManager();
con's avatar
con committed
415
416

    // build menu
417
    Core::ActionContainer *mbuild =
con's avatar
con committed
418
        am->createMenu(Constants::M_BUILDPROJECT);
419
    mbuild->menu()->setTitle(tr("&Build"));
con's avatar
con committed
420
421
422
    menubar->addMenu(mbuild, Core::Constants::G_VIEW);

    // debug menu
423
    Core::ActionContainer *mdebug =
con's avatar
con committed
424
        am->createMenu(Constants::M_DEBUG);
425
    mdebug->menu()->setTitle(tr("&Debug"));
con's avatar
con committed
426
427
    menubar->addMenu(mdebug, Core::Constants::G_VIEW);

428
429
430
431
    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
432
433
434
435
436
437
438
439
440

    //
    // 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
441
    mbuild->appendGroup(Constants::G_BUILD_RUN);
con's avatar
con committed
442
443
444
445
446
447

    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
448
449
450
451
452
453
    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
454

dt's avatar
dt committed
455
456
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
dt's avatar
dt committed
457
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
dt's avatar
dt committed
458
459
460
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_OTHER);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_CONFIG);
con's avatar
con committed
461

dt's avatar
dt committed
462
463
464
465
466
467
468
469
    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
470
471
472
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
con's avatar
con committed
473

dt's avatar
dt committed
474
475
476
    mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
    mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
    mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
con's avatar
con committed
477
478

    // "open with" submenu
479
    Core::ActionContainer * const openWith =
con's avatar
con committed
480
            am->createMenu(ProjectExplorer::Constants::M_OPENFILEWITHCONTEXT);
481
    openWith->setOnAllDisabledBehavior(Core::ActionContainer::Show);
482
483
    d->m_openWithMenu = openWith->menu();
    d->m_openWithMenu->setTitle(tr("Open With"));
con's avatar
con committed
484

485
    connect(d->m_openWithMenu, SIGNAL(triggered(QAction *)),
con's avatar
con committed
486
487
488
489
490
491
            this, SLOT(openWithMenuTriggered(QAction *)));

    //
    // Separators
    //

con's avatar
con committed
492
    Core::Command *cmd;
con's avatar
con committed
493
494
495
496
    QAction *sep;

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
497
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Build.Sep"), globalcontext);
con's avatar
con committed
498
499
500
501
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
502
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Files.Sep"), projecTreeContext);
con's avatar
con committed
503
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);
dt's avatar
dt committed
504
505
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
con's avatar
con committed
506
507
508

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
509
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Config.Sep"), projecTreeContext);
con's avatar
con committed
510
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_CONFIG);
dt's avatar
dt committed
511
512
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_CONFIG);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_CONFIG);
con's avatar
con committed
513
514
515

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
516
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Projects.Sep"), globalcontext);
con's avatar
con committed
517
518
519
520
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
521
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Other.Sep"), globalcontext);
con's avatar
con committed
522
523
    mbuild->addAction(cmd, Constants::G_BUILD_OTHER);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_OTHER);
dt's avatar
dt committed
524
525
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_OTHER);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_OTHER);
con's avatar
con committed
526
527
528

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
529
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Run.Sep"), globalcontext);
con's avatar
con committed
530
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
dt's avatar
dt committed
531
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
con's avatar
con committed
532
533
534

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
535
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.CancelBuild.Sep"), globalcontext);
con's avatar
con committed
536
537
538
539
540
541
542
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    //
    // Actions
    //

    // new action
543
544
    d->m_newAction = new QAction(tr("New Project..."), this);
    cmd = am->registerAction(d->m_newAction, Constants::NEWPROJECT, globalcontext);
con's avatar
con committed
545
546
547
548
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+N")));
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // open action
549
550
    d->m_loadAction = new QAction(tr("Load Project..."), this);
    cmd = am->registerAction(d->m_loadAction, Constants::LOAD, globalcontext);
551
#ifndef Q_WS_MAC
con's avatar
con committed
552
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+O")));
553
#endif
con's avatar
con committed
554
555
556
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // Default open action
557
558
    d->m_openFileAction = new QAction(tr("Open File"), this);
    cmd = am->registerAction(d->m_openFileAction, ProjectExplorer::Constants::OPENFILE,
dt's avatar
dt committed
559
560
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
con's avatar
con committed
561

562
    d->m_showInGraphicalShell = new QAction(FolderNavigationWidget::msgGraphicalShellAction(), this);
563
    cmd = am->registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
dt's avatar
dt committed
564
565
566
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
567

568
    d->m_openTerminalHere = new QAction(FolderNavigationWidget::msgTerminalAction(), this);
569
    cmd = am->registerAction(d->m_openTerminalHere, ProjectExplorer::Constants::OPENTERMIANLHERE,
dt's avatar
dt committed
570
571
572
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
573

con's avatar
con committed
574
    // Open With menu
dt's avatar
dt committed
575
    mfileContextMenu->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN);
con's avatar
con committed
576

mae's avatar
mae committed
577
    // recent projects menu
578
    Core::ActionContainer *mrecent =
mae's avatar
mae committed
579
        am->createMenu(Constants::M_RECENTPROJECTS);
580
    mrecent->menu()->setTitle(tr("Recent P&rojects"));
581
    mrecent->setOnAllDisabledBehavior(Core::ActionContainer::Show);
mae's avatar
mae committed
582
583
584
585
    mfile->addMenu(mrecent, Core::Constants::G_FILE_OPEN);
    connect(mfile->menu(), SIGNAL(aboutToShow()),
        this, SLOT(updateRecentProjectMenu()));

586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
    // 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
602
    // XXX same action?
con's avatar
con committed
603
    // unload action
604
605
    d->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""),
                                                      Utils::ParameterAction::EnabledWithParameter, this);
606
    cmd = am->registerAction(d->m_unloadAction, Constants::UNLOAD, globalcontext);
con's avatar
con committed
607
    cmd->setAttribute(Core::Command::CA_UpdateText);
608
    cmd->setDefaultText(d->m_unloadAction->text());
con's avatar
con committed
609
610
611
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    // unload session action
612
613
    d->m_clearSession = new QAction(tr("Close All Projects"), this);
    cmd = am->registerAction(d->m_clearSession, Constants::CLEARSESSION, globalcontext);
con's avatar
con committed
614
615
616
617
618
619
    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);
620
621
    d->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
    cmd = am->registerAction(d->m_buildSessionAction, Constants::BUILDSESSION, globalcontext);
con's avatar
con committed
622
623
624
625
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);
    // Add to mode bar
626
    modeManager->addAction(cmd->action(), Constants::P_ACTION_BUILDSESSION);
con's avatar
con committed
627
628
629
630

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

Tobias Hunger's avatar
Tobias Hunger committed
636
637
638
639
640
641
    // 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
642
643
644
    // clean session
    QIcon cleanIcon(Constants::ICON_CLEAN);
    cleanIcon.addFile(Constants::ICON_CLEAN_SMALL);
645
646
    d->m_cleanSessionAction = new QAction(cleanIcon, tr("Clean All"), this);
    cmd = am->registerAction(d->m_cleanSessionAction, Constants::CLEANSESSION, globalcontext);
con's avatar
con committed
647
648
649
650
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // build action
651
    d->m_buildAction = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""),
652
                                                     Utils::ParameterAction::AlwaysEnabled, this);
653
    cmd = am->registerAction(d->m_buildAction, Constants::BUILD, globalcontext);
654
    cmd->setAttribute(Core::Command::CA_UpdateText);
655
    cmd->setDefaultText(d->m_buildAction->text());
con's avatar
con committed
656
657
658
659
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

    // rebuild action
660
    d->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
661
                                                       Utils::ParameterAction::AlwaysEnabled, this);
662
    cmd = am->registerAction(d->m_rebuildAction, Constants::REBUILD, globalcontext);
663
    cmd->setAttribute(Core::Command::CA_UpdateText);
664
    cmd->setDefaultText(d->m_rebuildAction->text());
con's avatar
con committed
665
666
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

Tobias Hunger's avatar
Tobias Hunger committed
667
668
669
670
671
672
673
674
    // 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);

675
676
677
678
679
680
681
682
    // 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
683
    // clean action
684
    d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
685
                                                     Utils::ParameterAction::AlwaysEnabled, this);
686
    cmd = am->registerAction(d->m_cleanAction, Constants::CLEAN, globalcontext);
687
    cmd->setAttribute(Core::Command::CA_UpdateText);
688
    cmd->setDefaultText(d->m_cleanAction->text());
con's avatar
con committed
689
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
690
691
692
693

    // 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
694
    cmd = am->registerAction(d->m_buildActionContextMenu, Constants::BUILDCM, projecTreeContext);
695
696
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_buildActionContextMenu->text());
dt's avatar
dt committed
697
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
698
699
700
701

    // 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
702
    cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::REBUILDCM, projecTreeContext);
703
704
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_rebuildActionContextMenu->text());
dt's avatar
dt committed
705
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
706

Tobias Hunger's avatar
Tobias Hunger committed
707
708
709
    // 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
710
    cmd = am->registerAction(d->m_deployActionContextMenu, Constants::DEPLOYCM, projecTreeContext);
Tobias Hunger's avatar
Tobias Hunger committed
711
712
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_deployActionContextMenu->text());
dt's avatar
dt committed
713
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
Tobias Hunger's avatar
Tobias Hunger committed
714

715
716
717
    // 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
718
    cmd = am->registerAction(d->m_cleanActionContextMenu, Constants::CLEANCM, projecTreeContext);
719
720
    cmd->setAttribute(Core::Command::CA_UpdateText);
    cmd->setDefaultText(d->m_cleanActionContextMenu->text());
dt's avatar
dt committed
721
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
con's avatar
con committed
722

723
    // build without dependencies action
724
725
    d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this);
    cmd = am->registerAction(d->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext);
726

727
    // rebuild without dependencies action
728
729
    d->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this);
    cmd = am->registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext);
730

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

735
    // clean without dependencies action
736
737
    d->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this);
    cmd = am->registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext);
738

con's avatar
con committed
739
    // run action
740
741
    d->m_runAction = new QAction(runIcon, tr("Run"), this);
    cmd = am->registerAction(d->m_runAction, Constants::RUN, globalcontext);
742
743
    cmd->setAttribute(Core::Command::CA_UpdateText);

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

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

749
    d->m_runActionContextMenu = new QAction(runIcon, tr("Run"), this);
dt's avatar
dt committed
750
751
    cmd = am->registerAction(d->m_runActionContextMenu, Constants::RUNCONTEXTMENU, projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
dt's avatar
dt committed
752
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
753

con's avatar
con committed
754
    // cancel build action
755
756
    d->m_cancelBuildAction = new QAction(tr("Cancel Build"), this);
    cmd = am->registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
con's avatar
con committed
757
758
759
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    // add new file action
760
761
    d->m_addNewFileAction = new QAction(tr("Add New..."), this);
    cmd = am->registerAction(d->m_addNewFileAction, ProjectExplorer::Constants::ADDNEWFILE,
dt's avatar
dt committed
762
763
764
765
                       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
766
767

    // add existing file action
768
769
    d->m_addExistingFilesAction = new QAction(tr("Add Existing Files..."), this);
    cmd = am->registerAction(d->m_addExistingFilesAction, ProjectExplorer::Constants::ADDEXISTINGFILES,
dt's avatar
dt committed
770
771
772
773
                       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
774

775
776
777
    // 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
778
779
780
                       projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
781
782

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

con's avatar
con committed
785
    // remove file action
786
787
    d->m_removeFileAction = new QAction(tr("Remove File..."), this);
    cmd = am->registerAction(d->m_removeFileAction, ProjectExplorer::Constants::REMOVEFILE,
dt's avatar
dt committed
788
                       projecTreeContext);
789
    cmd->setDefaultKeySequence(QKeySequence::Delete);
dt's avatar
dt committed
790
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
con's avatar
con committed
791

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

dt's avatar
dt committed
798
    // delete file action
799
800
    d->m_deleteFileAction = new QAction(tr("Delete File..."), this);
    cmd = am->registerAction(d->m_deleteFileAction, ProjectExplorer::Constants::DELETEFILE,
dt's avatar
dt committed
801
                             projecTreeContext);
802
    cmd->setDefaultKeySequence(QKeySequence::Delete);
dt's avatar
dt committed
803
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
804

dt's avatar
dt committed
805
    // renamefile action
806
807
    d->m_renameFileAction = new QAction(tr("Rename"), this);
    cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE,
dt's avatar
dt committed
808
809
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
dt's avatar
dt committed
810
811
812
813
    // 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
814

815
816
817
    // 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
818
819
                             projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FIRST);
820

821
822
    // target selector
    d->m_projectSelectorAction = new QAction(this);
823
    d->m_projectSelectorAction->setCheckable(true);
824
825
826
    d->m_projectSelectorAction->setEnabled(false);
    QWidget *mainWindow = Core::ICore::instance()->mainWindow();
    d->m_targetSelector = new Internal::MiniProjectTargetSelector(d->m_projectSelectorAction, mainWindow);
827
    connect(d->m_projectSelectorAction, SIGNAL(triggered()), d->m_targetSelector, SLOT(show()));
828
    modeManager->addProjectSelector(d->m_projectSelectorAction);
829
830
831
832
833
834

    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
835
836
                       globalcontext);
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T")));
837
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
838
839
840
841
842
843
844
845
846
847

    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
            d->m_targetSelector, SLOT(addProject(ProjectExplorer::Project*)));
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
            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*)));

848
    connect(core, SIGNAL(saveSettingsRequested()),
con's avatar
con committed
849
850
        this, SLOT(savePersistentSettings()));

hjk's avatar
hjk committed
851
852
    addAutoReleasedObject(new ProjectTreeWidgetFactory);
    addAutoReleasedObject(new FolderNavigationWidgetFactory);
con's avatar
con committed
853

854
855
856
857
858
    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) {
859
                if (QFileInfo(fileNames.at(i)).isFile())
860
                    d->m_recentProjects.append(qMakePair(fileNames.at(i), displayNames.at(i)));
861
862
863
864
            }
        }
    }

865
    if (QSettings *s = core->settings()) {
Tobias Hunger's avatar
Tobias Hunger committed
866
867
        d->m_projectExplorerSettings.buildBeforeDeploy = s->value("ProjectExplorer/Settings/BuildBeforeDeploy", true).toBool();
        d->m_projectExplorerSettings.deployBeforeRun = s->value("ProjectExplorer/Settings/DeployBeforeRun", true).toBool();
868
869
        d->m_projectExplorerSettings.saveBeforeBuild = s->value("ProjectExplorer/Settings/SaveBeforeBuild", false).toBool();
        d->m_projectExplorerSettings.showCompilerOutput = s->value("ProjectExplorer/Settings/ShowCompilerOutput", false).toBool();
870
        d->m_projectExplorerSettings.showRunOutput = s->value("ProjectExplorer/Settings/ShowRunOutput", true).toBool();
871
        d->m_projectExplorerSettings.cleanOldAppOutput = s->value("ProjectExplorer/Settings/CleanOldAppOutput", false).toBool();
872
        d->m_projectExplorerSettings.wrapAppOutput = s->value("ProjectExplorer/Settings/WrapAppOutput", true).toBool();
873
        d->m_projectExplorerSettings.useJom = s->value("ProjectExplorer/Settings/UseJom", true).toBool();
874
        d->m_projectExplorerSettings.autorestoreLastSession = s->value("ProjectExplorer/Settings/AutoRestoreLastSession", false).toBool();
875
        d->m_projectExplorerSettings.prompToStopRunControl = s->value("ProjectExplorer/Settings/PromptToStopRunControl", false).toBool();
876
877
878
        d->m_projectExplorerSettings.environmentId = QUuid(s->value("ProjectExplorer/Settings/EnvironmentId").toString());
        if (d->m_projectExplorerSettings.environmentId.isNull())
            d->m_projectExplorerSettings.environmentId = QUuid::createUuid();
879
    }
880

881
882
883
884
885
    connect(d->m_sessionManagerAction, SIGNAL(triggered()), this, SLOT(showSessionManager()));
    connect(d->m_newAction, SIGNAL(triggered()), this, SLOT(newProject()));
    connect(d->m_loadAction, SIGNAL(triggered()), this, SLOT(loadAction()));
    connect(d->m_buildProjectOnlyAction, SIGNAL(triggered()), this, SLOT(buildProjectOnly()));
    connect(d->m_buildAction, SIGNAL(triggered()), this, SLOT(buildProject()));
886
    connect(d->m_buildActionContextMenu, SIGNAL(triggered()), this, SLOT(buildProjectContextMenu()));
887
888
889
    connect(d->m_buildSessionAction, SIGNAL(triggered()), this, SLOT(buildSession()));
    connect(d->m_rebuildProjectOnlyAction, SIGNAL(triggered()), this, SLOT(rebuildProjectOnly()));
    connect(d->m_rebuildAction, SIGNAL(triggered()), this, SLOT(rebuildProject()));
890
    connect(d->m_rebuildActionContextMenu, SIGNAL(triggered()), this, SLOT(rebuildProjectContextMenu()));
891
    connect(d->m_rebuildSessionAction, SIGNAL(triggered()), this, SLOT(rebuildSession()));
Tobias Hunger's avatar
Tobias Hunger committed
892
893
894
895
    connect(d->m_deployProjectOnlyAction, SIGNAL(triggered()), this, SLOT(deployProjectOnly()));
    connect(d->m_deployAction, SIGNAL(triggered()), this, SLOT(deployProject()));
    connect(d->m_deployActionContextMenu, SIGNAL(triggered()), this