projectexplorer.cpp 114 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
7
** Contact: Nokia Corporation (qt-info@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
29
** Nokia at qt-info@nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

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

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

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

91
#include <extensionsystem/pluginspec.h>
con's avatar
con committed
92
#include <coreplugin/coreconstants.h>
93 94
#include <coreplugin/filemanager.h>
#include <coreplugin/icore.h>
95
#include <coreplugin/imode.h>
con's avatar
con committed
96 97
#include <coreplugin/mimedatabase.h>
#include <coreplugin/modemanager.h>
98
#include <coreplugin/actionmanager/actionmanager.h>
99 100
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/command.h>
101
#include <coreplugin/id.h>
con's avatar
con committed
102 103 104 105 106 107
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/editormanager/ieditor.h>
#include <coreplugin/findplaceholder.h>
#include <coreplugin/basefilewizard.h>
#include <coreplugin/vcsmanager.h>
#include <coreplugin/iversioncontrol.h>
108
#include <coreplugin/variablemanager.h>
Robert Loehning's avatar
Robert Loehning committed
109
#include <coreplugin/fileutils.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>
Jarek Kobus's avatar
Jarek Kobus committed
116
#include <utils/persistentsettings.h>
con's avatar
con committed
117

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

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

132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
/*!
    \namespace ProjectExplorer
    ProjectExplorer plugin namespace
*/

/*!
    \namespace ProjectExplorer::Internal
    Internal namespace of the ProjectExplorer plugin
    \internal
*/

/*!
    \class ProjectExplorer::ProjectExplorerPlugin

    \brief ProjectExplorerPlugin with static accessor and utility functions to obtain
    current project, open projects, etc.
*/

con's avatar
con committed
150 151 152 153
namespace {
bool debug = false;
}

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

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

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

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

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

239
    Core::IMode *m_projectsMode;
240 241

    ToolChainManager *m_toolChainManager;
242 243 244 245 246 247
};

ProjectExplorerPluginPrivate::ProjectExplorerPluginPrivate() :
    m_currentProject(0),
    m_currentNode(0),
    m_delayedRunConfiguration(0),
248
    m_runMode(NoRunMode),
249 250
    m_projectsMode(0),
    m_toolChainManager(0)
251 252 253
{
}

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

270 271
}  // namespace ProjectExplorer

con's avatar
con committed
272 273 274 275 276 277 278
using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;


ProjectExplorerPlugin *ProjectExplorerPlugin::m_instance = 0;

ProjectExplorerPlugin::ProjectExplorerPlugin()
279
    : d(new ProjectExplorerPluginPrivate)
con's avatar
con committed
280 281 282 283 284 285
{
    m_instance = this;
}

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

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

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

304
bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *error)
con's avatar
con committed
305
{
Friedemann Kleint's avatar
Friedemann Kleint committed
306 307
    qRegisterMetaType<ProjectExplorer::RunControl *>();

308 309
    if (!parseArguments(arguments, error))
        return false;
dt's avatar
dt committed
310 311
    addObject(this);

312
    // Add ToolChainFactories:
313
#ifdef Q_OS_WIN
314 315
    addAutoReleasedObject(new WinDebugInterface);

316
    addAutoReleasedObject(new Internal::MsvcToolChainFactory);
SteveKing's avatar
SteveKing committed
317
    addAutoReleasedObject(new Internal::WinCEToolChainFactory);
318 319 320
#else
    addAutoReleasedObject(new Internal::GccToolChainFactory);
    addAutoReleasedObject(new Internal::LinuxIccToolChainFactory);
Tobias Hunger's avatar
Tobias Hunger committed
321 322 323
#endif
#ifndef Q_OS_MAC
    addAutoReleasedObject(new Internal::MingwToolChainFactory); // Mingw offers cross-compiling to windows
324
#endif
Tobias Hunger's avatar
Tobias Hunger committed
325
    addAutoReleasedObject(new Internal::ClangToolChainFactory);
326 327 328 329 330

    d->m_toolChainManager = new ToolChainManager(this);

    addAutoReleasedObject(new Internal::ToolChainOptionsPage);

dt's avatar
dt committed
331
    addAutoReleasedObject(new TaskHub);
332

hjk's avatar
hjk committed
333 334
    Core::ActionManager *am = Core::ICore::actionManager();
    connect(Core::ICore::instance(), SIGNAL(newItemsDialogRequested()), this, SLOT(loadCustomWizards()));
con's avatar
con committed
335

336
    d->m_welcomePage = new ProjectWelcomePage;
337
    connect(d->m_welcomePage, SIGNAL(manageSessions()), this, SLOT(showSessionManager()));
338
    addObject(d->m_welcomePage);
con's avatar
con committed
339

340
    connect(Core::FileManager::instance(), SIGNAL(currentFileChanged(QString)),
hjk's avatar
hjk committed
341
            this, SLOT(setCurrentFile(QString)));
con's avatar
con committed
342

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

345
    connect(d->m_session, SIGNAL(projectAdded(ProjectExplorer::Project *)),
con's avatar
con committed
346
            this, SIGNAL(fileListChanged()));
347
    connect(d->m_session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project *)),
con's avatar
con committed
348
            this, SLOT(invalidateProject(ProjectExplorer::Project *)));
349
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
con's avatar
con committed
350
            this, SIGNAL(fileListChanged()));
351 352 353 354
    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*)));
355
    connect(d->m_session, SIGNAL(startupProjectChanged(ProjectExplorer::Project *)),
con's avatar
con committed
356
            this, SLOT(startupProjectChanged()));
357 358
    connect(d->m_session, SIGNAL(dependencyChanged(ProjectExplorer::Project*,ProjectExplorer::Project*)),
            this, SLOT(updateActions()));
359
    connect(d->m_session, SIGNAL(sessionLoaded(QString)),
360
            this, SLOT(updateActions()));
361
    connect(d->m_session, SIGNAL(sessionLoaded(QString)),
362
            this, SLOT(updateWelcomePage()));
con's avatar
con committed
363

364
    d->m_proWindow = new ProjectWindow;
con's avatar
con committed
365

366
    Core::Context globalcontext(Core::Constants::C_GLOBAL);
dt's avatar
dt committed
367
    Core::Context projecTreeContext(Constants::C_PROJECT_TREE);
con's avatar
con committed
368

369
    d->m_projectsMode = new ProjectsMode(d->m_proWindow);
370 371
    d->m_projectsMode->setEnabled(session()->startupProject());
    addAutoReleasedObject(d->m_projectsMode);
372
    d->m_proWindow->layout()->addWidget(new Core::FindToolBarPlaceHolder(d->m_proWindow));
con's avatar
con committed
373

374
    addAutoReleasedObject(new CopyTaskHandler);
375
    addAutoReleasedObject(new ShowInEditorTaskHandler);
376
    addAutoReleasedObject(new VcsAnnotateTaskHandler);
377

378 379
    d->m_buildManager = new BuildManager(this);
    connect(d->m_buildManager, SIGNAL(buildStateChanged(ProjectExplorer::Project *)),
con's avatar
con committed
380
            this, SLOT(buildStateChanged(ProjectExplorer::Project *)));
381
    connect(d->m_buildManager, SIGNAL(buildQueueFinished(bool)),
con's avatar
con committed
382 383
            this, SLOT(buildQueueFinished(bool)));

384
    addAutoReleasedObject(new CoreListener);
con's avatar
con committed
385

386
    d->m_outputPane = new AppOutputPane;
387 388 389
    addAutoReleasedObject(d->m_outputPane);
    connect(d->m_session, SIGNAL(projectRemoved(ProjectExplorer::Project *)),
            d->m_outputPane, SLOT(projectRemoved()));
con's avatar
con committed
390

391 392 393 394 395
    connect(d->m_outputPane, SIGNAL(runControlStarted(ProjectExplorer::RunControl*)),
            this, SIGNAL(runControlStarted(ProjectExplorer::RunControl*)));
    connect(d->m_outputPane, SIGNAL(runControlFinished(ProjectExplorer::RunControl*)),
            this, SIGNAL(runControlFinished(ProjectExplorer::RunControl*)));

396
    AllProjectsFilter *allProjectsFilter = new AllProjectsFilter(this);
con's avatar
con committed
397 398
    addAutoReleasedObject(allProjectsFilter);

399
    CurrentProjectFilter *currentProjectFilter = new CurrentProjectFilter(this);
con's avatar
con committed
400 401 402 403 404
    addAutoReleasedObject(currentProjectFilter);

    addAutoReleasedObject(new BuildSettingsPanelFactory);
    addAutoReleasedObject(new RunSettingsPanelFactory);
    addAutoReleasedObject(new EditorSettingsPanelFactory);
405
    addAutoReleasedObject(new CodeStyleSettingsPanelFactory);
406
    addAutoReleasedObject(new DependenciesPanelFactory(d->m_session));
con's avatar
con committed
407 408 409 410

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

411
    AllProjectsFind *allProjectsFind = new AllProjectsFind(this);
con's avatar
con committed
412 413
    addAutoReleasedObject(allProjectsFind);

414
    CurrentProjectFind *currentProjectFind = new CurrentProjectFind(this);
con's avatar
con committed
415 416
    addAutoReleasedObject(currentProjectFind);

417
    addAutoReleasedObject(new LocalApplicationRunControlFactory);
con's avatar
con committed
418 419
    addAutoReleasedObject(new CustomExecutableRunConfigurationFactory);

420
    addAutoReleasedObject(new ProjectFileWizardExtension);
con's avatar
con committed
421

422 423 424
    // Settings page
    addAutoReleasedObject(new ProjectExplorerSettingsPage);

con's avatar
con committed
425
    // context menus
426
    Core::ActionContainer *msessionContextMenu =
con's avatar
con committed
427
        am->createMenu(Constants::M_SESSIONCONTEXT);
dt's avatar
dt committed
428
    Core::ActionContainer *mprojectContextMenu =
con's avatar
con committed
429
        am->createMenu(Constants::M_PROJECTCONTEXT);
dt's avatar
dt committed
430
    Core::ActionContainer *msubProjectContextMenu =
con's avatar
con committed
431
        am->createMenu(Constants::M_SUBPROJECTCONTEXT);
dt's avatar
dt committed
432
    Core::ActionContainer *mfolderContextMenu =
con's avatar
con committed
433
        am->createMenu(Constants::M_FOLDERCONTEXT);
dt's avatar
dt committed
434
    Core::ActionContainer *mfileContextMenu =
con's avatar
con committed
435 436
        am->createMenu(Constants::M_FILECONTEXT);

437
    d->m_sessionContextMenu = msessionContextMenu->menu();
dt's avatar
dt committed
438 439 440 441
    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
442

443
    Core::ActionContainer *mfile =
con's avatar
con committed
444
        am->actionContainer(Core::Constants::M_FILE);
445
    Core::ActionContainer *menubar =
con's avatar
con committed
446 447 448
        am->actionContainer(Core::Constants::MENU_BAR);

    // build menu
449
    Core::ActionContainer *mbuild =
con's avatar
con committed
450
        am->createMenu(Constants::M_BUILDPROJECT);
451
    mbuild->menu()->setTitle(tr("&Build"));
con's avatar
con committed
452 453 454
    menubar->addMenu(mbuild, Core::Constants::G_VIEW);

    // debug menu
455
    Core::ActionContainer *mdebug =
con's avatar
con committed
456
        am->createMenu(Constants::M_DEBUG);
457
    mdebug->menu()->setTitle(tr("&Debug"));
con's avatar
con committed
458 459
    menubar->addMenu(mdebug, Core::Constants::G_VIEW);

460 461 462 463
    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
464 465 466 467 468 469 470 471 472

    //
    // 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
473
    mbuild->appendGroup(Constants::G_BUILD_RUN);
con's avatar
con committed
474 475 476 477 478

    msessionContextMenu->appendGroup(Constants::G_SESSION_BUILD);
    msessionContextMenu->appendGroup(Constants::G_SESSION_FILES);
    msessionContextMenu->appendGroup(Constants::G_SESSION_OTHER);
    msessionContextMenu->appendGroup(Constants::G_SESSION_CONFIG);
479
    msessionContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
480

dt's avatar
dt committed
481 482 483 484
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
485
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
486
    mprojectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
487

dt's avatar
dt committed
488 489
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FIRST);
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_BUILD);
dt's avatar
dt committed
490
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_RUN);
dt's avatar
dt committed
491
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_FILES);
492
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_LAST);
493
    msubProjectContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
494

hjk's avatar
hjk committed
495
    Core::ActionContainer *runMenu = Core::ICore::actionManager()->createMenu(Constants::RUNMENUCONTEXTMENU);
dt's avatar
dt committed
496
    runMenu->setOnAllDisabledBehavior(Core::ActionContainer::Hide);
Friedemann Kleint's avatar
Friedemann Kleint committed
497
    QIcon runIcon = QIcon(QLatin1String(Constants::ICON_RUN));
498
    runIcon.addFile(QLatin1String(Constants::ICON_RUN_SMALL));
dt's avatar
dt committed
499
    runMenu->menu()->setIcon(runIcon);
500
    runMenu->menu()->setTitle(tr("Run"));
dt's avatar
dt committed
501 502
    msubProjectContextMenu->addMenu(runMenu, ProjectExplorer::Constants::G_PROJECT_RUN);

dt's avatar
dt committed
503 504 505
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_FILES);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_OTHER);
    mfolderContextMenu->appendGroup(Constants::G_FOLDER_CONFIG);
506
    mfolderContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
507

dt's avatar
dt committed
508 509 510
    mfileContextMenu->appendGroup(Constants::G_FILE_OPEN);
    mfileContextMenu->appendGroup(Constants::G_FILE_OTHER);
    mfileContextMenu->appendGroup(Constants::G_FILE_CONFIG);
511
    mfileContextMenu->appendGroup(Constants::G_PROJECT_TREE);
con's avatar
con committed
512
    // "open with" submenu
513
    Core::ActionContainer * const openWith =
con's avatar
con committed
514
            am->createMenu(ProjectExplorer::Constants::M_OPENFILEWITHCONTEXT);
515
    openWith->setOnAllDisabledBehavior(Core::ActionContainer::Show);
516 517
    d->m_openWithMenu = openWith->menu();
    d->m_openWithMenu->setTitle(tr("Open With"));
con's avatar
con committed
518

519
    connect(d->m_openWithMenu, SIGNAL(triggered(QAction *)),
520
            Core::FileManager::instance(), SLOT(slotExecuteOpenWithMenuAction(QAction*)));
con's avatar
con committed
521 522 523 524 525

    //
    // Separators
    //

con's avatar
con committed
526
    Core::Command *cmd;
con's avatar
con committed
527 528 529 530
    QAction *sep;

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
531
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Build.Sep"), globalcontext);
con's avatar
con committed
532 533 534 535
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
536
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Files.Sep"), projecTreeContext);
con's avatar
con committed
537
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);
dt's avatar
dt committed
538 539
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_FILES);
con's avatar
con committed
540 541 542

    sep = new QAction(this);
    sep->setSeparator(true);
dt's avatar
dt committed
543
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Config.Sep"), projecTreeContext);
con's avatar
con committed
544 545 546 547
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_CONFIG);

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
548
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Projects.Sep"), globalcontext);
con's avatar
con committed
549 550 551 552
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
553
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Other.Sep"), globalcontext);
con's avatar
con committed
554 555 556 557 558
    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
559
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.Run.Sep"), globalcontext);
con's avatar
con committed
560
    mbuild->addAction(cmd, Constants::G_BUILD_RUN);
dt's avatar
dt committed
561
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
con's avatar
con committed
562 563 564

    sep = new QAction(this);
    sep->setSeparator(true);
hjk's avatar
hjk committed
565
    cmd = am->registerAction(sep, Core::Id("ProjectExplorer.CancelBuild.Sep"), globalcontext);
con's avatar
con committed
566 567 568 569 570 571 572
    mbuild->addAction(cmd, Constants::G_BUILD_CANCEL);

    //
    // Actions
    //

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

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

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

592 593 594 595 596 597
    d->m_searchOnFileSystem = new QAction(FolderNavigationWidget::msgFindOnFileSystem(), this);
    cmd = am->registerAction(d->m_searchOnFileSystem, ProjectExplorer::Constants::SEARCHONFILESYSTEM, projecTreeContext);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_CONFIG);
    msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_LAST);

598
    d->m_showInGraphicalShell = new QAction(Core::FileUtils::msgGraphicalShellAction(), this);
599
    cmd = am->registerAction(d->m_showInGraphicalShell, ProjectExplorer::Constants::SHOWINGRAPHICALSHELL,
dt's avatar
dt committed
600 601 602
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
con's avatar
con committed
603

604
    d->m_openTerminalHere = new QAction(Core::FileUtils::msgTerminalAction(), this);
605
    cmd = am->registerAction(d->m_openTerminalHere, ProjectExplorer::Constants::OPENTERMIANLHERE,
dt's avatar
dt committed
606 607 608
                       projecTreeContext);
    mfileContextMenu->addAction(cmd, Constants::G_FILE_OPEN);
    mfolderContextMenu->addAction(cmd, Constants::G_FOLDER_FILES);
609

con's avatar
con committed
610
    // Open With menu
dt's avatar
dt committed
611
    mfileContextMenu->addMenu(openWith, ProjectExplorer::Constants::G_FILE_OPEN);
con's avatar
con committed
612

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

622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637
    // 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
638
    // XXX same action?
con's avatar
con committed
639
    // unload action
640 641
    d->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""),
                                                      Utils::ParameterAction::EnabledWithParameter, this);
642
    cmd = am->registerAction(d->m_unloadAction, Constants::UNLOAD, globalcontext);
con's avatar
con committed
643
    cmd->setAttribute(Core::Command::CA_UpdateText);
644
    cmd->setDescription(d->m_unloadAction->text());
con's avatar
con committed
645 646 647
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);

    // unload session action
648 649
    d->m_clearSession = new QAction(tr("Close All Projects"), this);
    cmd = am->registerAction(d->m_clearSession, Constants::CLEARSESSION, globalcontext);
con's avatar
con committed
650 651 652 653
    mfile->addAction(cmd, Core::Constants::G_FILE_PROJECT);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_FILES);

    // build session action
Friedemann Kleint's avatar
Friedemann Kleint committed
654
    QIcon buildIcon = QIcon(QLatin1String(Constants::ICON_BUILD));
655
    buildIcon.addFile(QLatin1String(Constants::ICON_BUILD_SMALL));
656 657
    d->m_buildSessionAction = new QAction(buildIcon, tr("Build All"), this);
    cmd = am->registerAction(d->m_buildSessionAction, Constants::BUILDSESSION, globalcontext);
con's avatar
con committed
658 659 660 661 662
    cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+B")));
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

    // rebuild session action
Friedemann Kleint's avatar
Friedemann Kleint committed
663
    QIcon rebuildIcon = QIcon(QLatin1String(Constants::ICON_REBUILD));
664
    rebuildIcon.addFile(QLatin1String(Constants::ICON_REBUILD_SMALL));
665 666
    d->m_rebuildSessionAction = new QAction(rebuildIcon, tr("Rebuild All"), this);
    cmd = am->registerAction(d->m_rebuildSessionAction, Constants::REBUILDSESSION, globalcontext);
con's avatar
con committed
667 668 669
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

Tobias Hunger's avatar
Tobias Hunger committed
670 671 672 673 674 675
    // 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
676
    // clean session
Friedemann Kleint's avatar
Friedemann Kleint committed
677
    QIcon cleanIcon = QIcon(QLatin1String(Constants::ICON_CLEAN));
678
    cleanIcon.addFile(QLatin1String(Constants::ICON_CLEAN_SMALL));
679 680
    d->m_cleanSessionAction = new QAction(cleanIcon, tr("Clean All"), this);
    cmd = am->registerAction(d->m_cleanSessionAction, Constants::CLEANSESSION, globalcontext);
con's avatar
con committed
681 682 683 684
    mbuild->addAction(cmd, Constants::G_BUILD_SESSION);
    msessionContextMenu->addAction(cmd, Constants::G_SESSION_BUILD);

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

694
    // Add to mode bar
695
    Core::ModeManager::addAction(cmd->action(), Constants::P_ACTION_BUILDPROJECT);
696

con's avatar
con committed
697
    // rebuild action
698
    d->m_rebuildAction = new Utils::ParameterAction(tr("Rebuild Project"), tr("Rebuild Project \"%1\""),
699
                                                       Utils::ParameterAction::AlwaysEnabled, this);
700
    cmd = am->registerAction(d->m_rebuildAction, Constants::REBUILD, globalcontext);
701
    cmd->setAttribute(Core::Command::CA_UpdateText);
702
    cmd->setDescription(d->m_rebuildAction->text());
con's avatar
con committed
703 704
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

Tobias Hunger's avatar
Tobias Hunger committed
705 706 707 708 709
    // 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);
710
    cmd->setDescription(d->m_deployAction->text());
Tobias Hunger's avatar
Tobias Hunger committed
711 712
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

713 714 715 716 717
    // 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);
718
    cmd->setDescription(d->m_publishAction->text());
719 720
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);

con's avatar
con committed
721
    // clean action
722
    d->m_cleanAction = new Utils::ParameterAction(tr("Clean Project"), tr("Clean Project \"%1\""),
723
                                                     Utils::ParameterAction::AlwaysEnabled, this);
724
    cmd = am->registerAction(d->m_cleanAction, Constants::CLEAN, globalcontext);
725
    cmd->setAttribute(Core::Command::CA_UpdateText);
726
    cmd->setDescription(d->m_cleanAction->text());
con's avatar
con committed
727
    mbuild->addAction(cmd, Constants::G_BUILD_PROJECT);
728 729 730 731

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

    // 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
740
    cmd = am->registerAction(d->m_rebuildActionContextMenu, Constants::REBUILDCM, projecTreeContext);
741
    cmd->setAttribute(Core::Command::CA_UpdateText);
742
    cmd->setDescription(d->m_rebuildActionContextMenu->text());
dt's avatar
dt committed
743
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
744

Tobias Hunger's avatar
Tobias Hunger committed
745 746 747
    // 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
748
    cmd = am->registerAction(d->m_deployActionContextMenu, Constants::DEPLOYCM, projecTreeContext);
Tobias Hunger's avatar
Tobias Hunger committed
749
    cmd->setAttribute(Core::Command::CA_UpdateText);
750
    cmd->setDescription(d->m_deployActionContextMenu->text());
dt's avatar
dt committed
751
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
Tobias Hunger's avatar
Tobias Hunger committed
752

753 754 755
    // 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
756
    cmd = am->registerAction(d->m_cleanActionContextMenu, Constants::CLEANCM, projecTreeContext);
757
    cmd->setAttribute(Core::Command::CA_UpdateText);
758
    cmd->setDescription(d->m_cleanActionContextMenu->text());
dt's avatar
dt committed
759
    mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_BUILD);
con's avatar
con committed
760

761
    // build without dependencies action
762 763
    d->m_buildProjectOnlyAction = new QAction(tr("Build Without Dependencies"), this);
    cmd = am->registerAction(d->m_buildProjectOnlyAction, Constants