projectexplorer.cpp 107 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
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

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

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

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

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

117
#include <QtCore/QtPlugin>
hjk's avatar
hjk committed
118
#include <QtCore/QDateTime>
con's avatar
con committed
119
120
#include <QtCore/QDebug>
#include <QtCore/QSettings>
121
#include <QtCore/QAbstractFileEngine>
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;
}

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

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
#endif
Tobias Hunger's avatar
Tobias Hunger committed
317
    addAutoReleasedObject(new Internal::ClangToolChainFactory);
318
319
320
321
322

    d->m_toolChainManager = new ToolChainManager(this);

    addAutoReleasedObject(new Internal::ToolChainOptionsPage);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

407
    addAutoReleasedObject(new LocalApplicationRunControlFactory);
con's avatar
con committed
408
409
    addAutoReleasedObject(new CustomExecutableRunConfigurationFactory);

410
    addAutoReleasedObject(new ProjectFileWizardExtension);
con's avatar
con committed
411

412
413
414
    // Settings page
    addAutoReleasedObject(new ProjectExplorerSettingsPage);

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

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

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

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

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

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

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

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

    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
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);
477
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
con's avatar
con committed
478

dt's avatar
dt committed
479
480
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
dt's avatar
dt committed
481
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
dt's avatar
dt committed
482
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
483
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
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
534
535
536
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_CONFIG);

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

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

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

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

    //
    // Actions
    //

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

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

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

581
    d->m_showInGraphicalShell = new QAction(FolderNavigationWidget::msgGraphicalShellAction(), this);
582
    cmd = am->registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
dt's avatar
dt committed
583
584
585
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
586

587
    d->m_openTerminalHere = new QAction(FolderNavigationWidget::msgTerminalAction(), this);
588
    cmd = am->registerAction(d->m_openTerminalHere, ProjectExplorer::Constants::OPENTERMIANLHERE,
dt's avatar
dt committed
589
590
591
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
592

con's avatar
con committed
593
    // Open With menu
dt's avatar
dt committed
594
    mfileContextMenu->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN);
con's avatar
con committed
595

mae's avatar
mae committed
596
    // recent projects menu
597
    Core::ActionContainer *mrecent =
mae's avatar
mae committed
598
        am->createMenu(Constants::M_RECENTPROJECTS);
599
    mrecent->menu()->setTitle(tr("Recent P&rojects"));
600
    mrecent->setOnAllDisabledBehavior(Core::ActionContainer::Show);
mae's avatar
mae committed
601
602
603
604
    mfile->addMenu(mrecent, Core::Constants::G_FILE_OPEN);
    connect(mfile->menu(), SIGNAL(aboutToShow()),
        this, SLOT(updateRecentProjectMenu()));

605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
    // 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
621
    // XXX same action?
con's avatar
con committed
622
    // unload action
623
624
    d->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""),
                                                      Utils::ParameterAction::EnabledWithParameter, this);
625
    cmd = am->registerAction(d->m_unloadAction, Constants::UNLOAD, globalcontext);
con's avatar
con committed
626
    cmd->setAttribute(Core::Command::CA_UpdateText);
627
    cmd->setDefaultText(d->m_unloadAction->text());
con's avatar
con committed
628
629
630
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    // unload session action
631
632
    d->m_clearSession = new QAction(tr("Close All Projects"), this);
    cmd = am->registerAction(d->m_clearSession, Constants::CLEARSESSION, globalcontext);
con's avatar
con committed
633
634
635
636
637
638
    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);
639
640
    d->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
    cmd = am->registerAction(d->m_buildSessionAction, Constants::BUILDSESSION, globalcontext);
con's avatar
con committed
641
642
643
644
645
646
647
    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);
648
649
    d->m_rebuildSessionAction = new QAction(rebuildIcon, tr("Rebuild All"), this);
    cmd = am->registerAction(d->m_rebuildSessionAction, Constants::REBUILDSESSION, globalcontext);
con's avatar
con committed
650
651
652
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

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

    // build action
668
    d->m_buildAction = new Utils::ParameterAction(tr("Build Project"), tr("Build Project \"%1\""),
669
                                                     Utils::ParameterAction::AlwaysEnabled, this);
dt's avatar
dt committed
670
    d->m_buildAction->setIcon(buildIcon);
671
    cmd = am->registerAction(d->m_buildAction, Constants::BUILD, globalcontext);
672
    cmd->setAttribute(Core::Command::CA_UpdateText);
673
    cmd->setDefaultText(d->m_buildAction->text());
con's avatar
con committed
674
675
676
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

677
678
679
    // Add to mode bar
    modeManager->addAction(cmd->action(), Constants::P_ACTION_BUILDPROJECT);

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

Tobias Hunger's avatar
Tobias Hunger committed
688
689
690
691
692
693
694
695
    // 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);

696
697
698
699
700
701
702
703
    // 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
704
    // clean action
705
    d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
706
                                                     Utils::ParameterAction::AlwaysEnabled, this);
707
    cmd = am->registerAction(d->m_cleanAction, Constants::CLEAN, globalcontext);
708
    cmd->setAttribute(Core::Command::CA_UpdateText);
709
    cmd->setDefaultText(d->m_cleanAction->text());
con's avatar
con committed
710
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
711
712
713
714

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

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

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

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

744
    // build without dependencies action
745
746
    d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this);
    cmd = am->registerAction(d->m_buildProjectOnlyAction, Constants::BUILDPROJECTONLY, globalcontext);
747

748
    // rebuild without dependencies action
749
750
    d->m_rebuildProjectOnlyAction = new QAction(tr("Rebuild Without Dependencies"), this);
    cmd = am->registerAction(d->m_rebuildProjectOnlyAction, Constants::REBUILDPROJECTONLY, globalcontext);
751

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

756
    // clean without dependencies action
757
758
    d->m_cleanProjectOnlyAction = new QAction(tr("Clean Without Dependencies"), this);
    cmd = am->registerAction(d->m_cleanProjectOnlyAction, Constants::CLEANPROJECTONLY, globalcontext);
759

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

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

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

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

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

    // add new file action
781
782
    d->m_addNewFileAction = new QAction(tr("Add New..."), this);
    cmd = am->registerAction(d->m_addNewFileAction, ProjectExplorer::Constants::ADDNEWFILE,
dt's avatar
dt committed
783
784
785
786
                       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
787
788

    // add existing file action
789
790
    d->m_addExistingFilesAction = new QAction(tr("Add Existing Files..."), this);
    cmd = am->registerAction(d->m_addExistingFilesAction, ProjectExplorer::Constants::ADDEXISTINGFILES,
dt's avatar
dt committed
791
792
793
794
                       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
795

796
797
798
    // 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
799
800
801
                       projecTreeContext);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
802
803

    // unload project again, in right position
804
    mprojectContextMenu->addAction(am->command(Constants::UNLOAD), Constants::G_PROJECT_LAST);
805

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

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

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

dt's avatar
dt committed
826
    // renamefile action
827
828
    d->m_renameFileAction = new QAction(tr("Rename"), this);
    cmd = am->registerAction(d->m_renameFileAction, ProjectExplorer::Constants::RENAMEFILE,
dt's avatar
dt committed
829
830
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OTHER);
dt's avatar
dt committed
831
832
833
834
    // 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
835

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

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

    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
856
857
                       globalcontext);
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+T")));
858
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
859
860
861

    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
            d->m_targetSelector, SLOT(addProject(ProjectExplorer::Project*)));