Commit 4537e1b8 authored by Yuchen Deng's avatar Yuchen Deng Committed by Tobias Hunger

Add support to force skip deploy before running or debugging

When we enabled the option "Always deploy project before running it",
and try to running or debugging a big project, e.g. QtCreator.
We need waitting a long time for deploy it.
But in fact, we not need this in every time.
So we can add two menu items:
"Run Without Deployment" and "Debug Without Deployment".
We can running or debugging directly.

Change-Id: I6ba92aa0cfa792cef923012856b79c29a672252c
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent e453585d
......@@ -90,14 +90,15 @@
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/toolchainmanager.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/projectexplorersettings.h>
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <projectexplorer/abi.h>
#include <projectexplorer/toolchain.h>
#include <projectexplorer/toolchainmanager.h>
#include <qtsupport/qtsupportconstants.h>
......@@ -719,8 +720,10 @@ public slots:
void onModeChanged(Core::IMode *mode);
void onCoreAboutToOpen();
void showSettingsDialog();
void updateDebugWithoutDeployMenu();
void debugProject();
void debugProjectWithoutDeploy();
void debugProjectBreakMain();
void startExternalApplication();
void startRemoteCdbSession();
......@@ -1027,6 +1030,7 @@ public:
Utils::ProxyAction *m_visibleStartAction;
Utils::ProxyAction *m_hiddenStopAction;
QAction *m_startAction;
QAction *m_debugWithoutDeployAction;
QAction *m_startExternalAction;
QAction *m_startRemoteAction;
QAction *m_attachToQmlPortAction;
......@@ -1145,6 +1149,7 @@ DebuggerPluginPrivate::DebuggerPluginPrivate(DebuggerPlugin *plugin) :
m_reverseToolButton = 0;
m_startAction = 0;
m_debugWithoutDeployAction = 0;
m_startExternalAction = 0;
m_startRemoteAction = 0;
m_attachRemoteAction = 0;
......@@ -1395,6 +1400,7 @@ void DebuggerPluginPrivate::onCurrentProjectChanged(Project *project)
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false);
m_startAction->setEnabled(true);
m_debugWithoutDeployAction->setEnabled(true);
m_visibleStartAction->setAction(m_startAction);
}
......@@ -1409,6 +1415,13 @@ void DebuggerPluginPrivate::debugProject()
pe->runProject(pro, Constants::DEBUGMODE);
}
void DebuggerPluginPrivate::debugProjectWithoutDeploy()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
if (Project *pro = pe->startupProject())
pe->runProject(pro, Constants::DEBUGMODE, true);
}
void DebuggerPluginPrivate::debugProjectBreakMain()
{
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
......@@ -2158,6 +2171,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false);
m_startAction->setEnabled(true);
m_debugWithoutDeployAction->setEnabled(true);
m_visibleStartAction->setAction(m_startAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
} else if (state == InferiorStopOk) {
......@@ -2166,6 +2180,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_continueAction->setEnabled(true);
m_exitAction->setEnabled(true);
m_startAction->setEnabled(false);
m_debugWithoutDeployAction->setEnabled(false);
m_visibleStartAction->setAction(m_continueAction);
m_hiddenStopAction->setAction(m_exitAction);
} else if (state == InferiorRunOk) {
......@@ -2174,6 +2189,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(true);
m_startAction->setEnabled(false);
m_debugWithoutDeployAction->setEnabled(false);
m_visibleStartAction->setAction(m_interruptAction);
m_hiddenStopAction->setAction(m_interruptAction);
} else if (state == DebuggerFinished) {
......@@ -2182,6 +2198,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false);
m_startAction->setEnabled(true);
m_debugWithoutDeployAction->setEnabled(true);
m_visibleStartAction->setAction(m_startAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
m_codeModelSnapshot = CPlusPlus::Snapshot();
......@@ -2193,6 +2210,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(true);
m_startAction->setEnabled(false);
m_debugWithoutDeployAction->setEnabled(false);
m_visibleStartAction->setAction(m_startAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
} else {
......@@ -2201,6 +2219,7 @@ void DebuggerPluginPrivate::updateState(DebuggerEngine *engine)
m_continueAction->setEnabled(false);
m_exitAction->setEnabled(false);
m_startAction->setEnabled(false);
m_debugWithoutDeployAction->setEnabled(false);
m_visibleStartAction->setAction(m_undisturbableAction);
m_hiddenStopAction->setAction(m_undisturbableAction);
}
......@@ -2288,6 +2307,7 @@ void DebuggerPluginPrivate::updateDebugActions()
const bool canRun = pe->canRun(project, debugMode);
m_startAction->setEnabled(canRun);
m_startAction->setToolTip(canRun ? QString() : pe->cannotRunReason(project, debugMode));
m_debugWithoutDeployAction->setEnabled(canRun);
// Step into/next: Start and break at 'main' unless a debugger is running.
if (m_snapshotHandler->currentIndex() < 0) {
......@@ -2342,6 +2362,12 @@ void DebuggerPluginPrivate::showSettingsDialog()
_(DEBUGGER_COMMON_SETTINGS_ID));
}
void DebuggerPluginPrivate::updateDebugWithoutDeployMenu()
{
const bool state = ProjectExplorerPlugin::instance()->projectExplorerSettings().deployBeforeRun;
m_debugWithoutDeployAction->setVisible(state);
}
void DebuggerPluginPrivate::dumpLog()
{
QString fileName = QFileDialog::getSaveFileName(mainWindow(),
......@@ -2952,6 +2978,10 @@ void DebuggerPluginPrivate::extensionsInitialized()
act->setText(tr("Start Debugging"));
connect(act, SIGNAL(triggered()), this, SLOT(debugProject()));
act = m_debugWithoutDeployAction = new QAction(this);
act->setText(tr("Debug Without Deployment"));
connect(act, SIGNAL(triggered()), this, SLOT(debugProjectWithoutDeploy()));
// Handling of external applications.
act = m_startExternalAction = new QAction(this);
act->setText(tr("Start and Debug External Application..."));
......@@ -3018,6 +3048,11 @@ void DebuggerPluginPrivate::extensionsInitialized()
ModeManager *modeManager = ModeManager::instance();
modeManager->addAction(m_visibleStartAction, Constants::P_ACTION_DEBUG);
cmd = am->registerAction(m_debugWithoutDeployAction,
"Debugger.DebugWithoutDeploy", globalcontext);
cmd->setAttribute(Command::CA_Hide);
mstart->addAction(cmd, CC::G_DEFAULT_ONE);
cmd = am->registerAction(m_attachExternalAction,
"Debugger.AttachExternal", globalcontext);
cmd->setAttribute(Command::CA_Hide);
......@@ -3238,7 +3273,8 @@ void DebuggerPluginPrivate::extensionsInitialized()
SLOT(onModeChanged(Core::IMode*)));
connect(ICore::instance(), SIGNAL(coreAboutToOpen()),
SLOT(onCoreAboutToOpen()));
connect(ProjectExplorer::ProjectExplorerPlugin::instance(), SIGNAL(settingsChanged()),
this, SLOT(updateDebugWithoutDeployMenu()));
// Debug mode setup
DebugMode *debugMode = new DebugMode;
......
......@@ -196,6 +196,7 @@ struct ProjectExplorerPluginPrivate {
QAction *m_cleanSessionAction;
QAction *m_runAction;
QAction *m_runActionContextMenu;
QAction *m_runWithoutDeployAction;
QAction *m_cancelBuildAction;
QAction *m_addNewFileAction;
QAction *m_addExistingFilesAction;
......@@ -786,6 +787,11 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
mprojectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
msubProjectContextMenu->addAction(cmd, Constants::G_PROJECT_RUN);
// run without deployment action
d->m_runWithoutDeployAction = new QAction(tr("Run Without Deployment"), this);
cmd = am->registerAction(d->m_runWithoutDeployAction, Constants::RUNWITHOUTDEPLOY, globalcontext);
mbuild->addAction(cmd, Constants::G_BUILD_RUN);
// cancel build action
d->m_cancelBuildAction = new QAction(tr("Cancel Build"), this);
cmd = am->registerAction(d->m_cancelBuildAction, Constants::CANCELBUILD, globalcontext);
......@@ -958,6 +964,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(d->m_cleanSessionAction, SIGNAL(triggered()), this, SLOT(cleanSession()));
connect(d->m_runAction, SIGNAL(triggered()), this, SLOT(runProject()));
connect(d->m_runActionContextMenu, SIGNAL(triggered()), this, SLOT(runProjectContextMenu()));
connect(d->m_runWithoutDeployAction, SIGNAL(triggered()), this, SLOT(runProjectWithoutDeploy()));
connect(d->m_cancelBuildAction, SIGNAL(triggered()), this, SLOT(cancelBuild()));
connect(d->m_unloadAction, SIGNAL(triggered()), this, SLOT(unloadProject()));
connect(d->m_clearSession, SIGNAL(triggered()), this, SLOT(clearSession()));
......@@ -975,6 +982,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
connect(d->m_setStartupProjectAction, SIGNAL(triggered()), this, SLOT(setStartupProject()));
connect(this, SIGNAL(updateRunActions()), this, SLOT(slotUpdateRunActions()));
connect(this, SIGNAL(settingsChanged()), this, SLOT(updateRunWithoutDeployMenu()));
updateActions();
......@@ -1114,6 +1122,11 @@ void ProjectExplorerPlugin::updateVariable(const QString &variable)
}
}
void ProjectExplorerPlugin::updateRunWithoutDeployMenu()
{
d->m_runWithoutDeployAction->setVisible(d->m_projectExplorerSettings.deployBeforeRun);
}
ExtensionSystem::IPlugin::ShutdownFlag ProjectExplorerPlugin::aboutToShutdown()
{
d->m_proWindow->aboutToShutdown(); // disconnect from session
......@@ -1674,6 +1687,7 @@ void ProjectExplorerPlugin::updateActions()
d->m_projectSelectorActionMenu->setEnabled(!session()->projects().isEmpty());
updateDeployActions();
updateRunWithoutDeployMenu();
}
// NBS TODO check projectOrder()
......@@ -1870,6 +1884,11 @@ void ProjectExplorerPlugin::runProject()
runProject(startupProject(), ProjectExplorer::Constants::RUNMODE);
}
void ProjectExplorerPlugin::runProjectWithoutDeploy()
{
runProject(startupProject(), ProjectExplorer::Constants::RUNMODE, true);
}
void ProjectExplorerPlugin::runProjectContextMenu()
{
ProjectNode *projectNode = qobject_cast<ProjectNode*>(d->m_currentNode);
......@@ -1986,21 +2005,23 @@ bool ProjectExplorerPlugin::hasDeploySettings(Project *pro)
return false;
}
void ProjectExplorerPlugin::runProject(Project *pro, const QString &mode)
void ProjectExplorerPlugin::runProject(Project *pro, const QString &mode, const bool forceSkipDeploy)
{
if (!pro)
return;
runRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode);
runRunConfiguration(pro->activeTarget()->activeRunConfiguration(), mode, forceSkipDeploy);
}
void ProjectExplorerPlugin::runRunConfiguration(ProjectExplorer::RunConfiguration *rc, const QString &mode)
void ProjectExplorerPlugin::runRunConfiguration(ProjectExplorer::RunConfiguration *rc,
const QString &mode,
const bool forceSkipDeploy)
{
if (!rc->isEnabled())
return;
QStringList stepIds;
if (d->m_projectExplorerSettings.deployBeforeRun) {
if (!forceSkipDeploy && d->m_projectExplorerSettings.deployBeforeRun) {
if (d->m_projectExplorerSettings.buildBeforeDeploy)
stepIds << Constants::BUILDSTEPS_BUILD;
stepIds << Constants::BUILDSTEPS_DEPLOY;
......@@ -2226,8 +2247,10 @@ QString ProjectExplorerPlugin::cannotRunReason(Project *project, const QString &
void ProjectExplorerPlugin::slotUpdateRunActions()
{
Project *project = startupProject();
d->m_runAction->setEnabled(canRun(project, ProjectExplorer::Constants::RUNMODE));
const bool state = canRun(project, ProjectExplorer::Constants::RUNMODE);
d->m_runAction->setEnabled(state);
d->m_runAction->setToolTip(cannotRunReason(project, ProjectExplorer::Constants::RUNMODE));
d->m_runWithoutDeployAction->setEnabled(state);
}
void ProjectExplorerPlugin::cancelBuild()
......@@ -2797,7 +2820,6 @@ void ProjectExplorerPlugin::setSession(QAction *action)
d->m_session->loadSession(session);
}
void ProjectExplorerPlugin::setProjectExplorerSettings(const Internal::ProjectExplorerSettings &pes)
{
if (d->m_projectExplorerSettings == pes)
......
......@@ -117,8 +117,9 @@ public:
bool canRun(Project *pro, const QString &runMode);
QString cannotRunReason(Project *project, const QString &runMode);
void runProject(Project *pro, const QString &mode);
void runRunConfiguration(ProjectExplorer::RunConfiguration *rc, const QString &mode);
void runProject(Project *pro, const QString &mode, const bool forceSkipDeploy = false);
void runRunConfiguration(ProjectExplorer::RunConfiguration *rc, const QString &mode,
const bool forceSkipDeploy = false);
void addExistingFiles(ProjectExplorer::ProjectNode *projectNode, const QStringList &filePaths);
void addExistingFiles(const QStringList &filePaths);
......@@ -183,6 +184,7 @@ private slots:
void restoreSession();
void loadSession(const QString &session);
void runProject();
void runProjectWithoutDeploy();
void runProjectContextMenu();
void savePersistentSettings();
......@@ -223,6 +225,7 @@ private slots:
void updateActions();
void loadCustomWizards();
void updateVariable(const QString &variable);
void updateRunWithoutDeployMenu();
void publishProject();
void updateWelcomePage();
......
......@@ -67,6 +67,7 @@ const char CLEANCM[] = "ProjectExplorer.CleanCM";
const char CLEANSESSION[] = "ProjectExplorer.CleanSession";
const char CANCELBUILD[] = "ProjectExplorer.CancelBuild";
const char RUN[] = "ProjectExplorer.Run";
const char RUNWITHOUTDEPLOY[] = "ProjectExplorer.RunWithoutDeploy";
const char RUNCONTEXTMENU[] = "ProjectExplorer.RunContextMenu";
const char STOP[] = "ProjectExplorer.Stop";
const char ADDNEWFILE[] = "ProjectExplorer.AddNewFile";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment