Show tooltip on disabled run actions

Change-Id: I9b5eaa49e14b71b9d1f8ac84aa7cb7bb4d014cac
Reviewed-on: http://codereview.qt.nokia.com/192
Reviewed-by: hjk <qthjk@ovi.com>
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
This commit is contained in:
dt_
2011-05-26 19:57:07 +02:00
committed by Daniel Teske
parent fb9fb87037
commit 42e5e5f00a
4 changed files with 55 additions and 2 deletions

View File

@@ -845,9 +845,21 @@ void AnalyzerManager::updateRunActions()
ProjectExplorer::Project *project = pe->startupProject(); ProjectExplorer::Project *project = pe->startupProject();
bool startEnabled = !d->m_currentRunControl && pe->canRun(project, Constants::MODE_ANALYZE) bool startEnabled = !d->m_currentRunControl && pe->canRun(project, Constants::MODE_ANALYZE)
&& currentTool(); && currentTool();
QString disabledReason;
if (d->m_currentRunControl)
disabledReason = tr("An analysis is still in progress.");
else if (!currentTool())
disabledReason = tr("No analyzer tool selected.");
else
disabledReason = pe->cannotRunReason(project, Constants::MODE_ANALYZE);
d->m_startAction->setEnabled(startEnabled); d->m_startAction->setEnabled(startEnabled);
d->m_startAction->setToolTip(disabledReason);
if (currentTool() && !currentTool()->canRunRemotely())
disabledReason = tr("Current analyzer tool can not be run remotely.");
d->m_startRemoteAction->setEnabled(!d->m_currentRunControl && currentTool() d->m_startRemoteAction->setEnabled(!d->m_currentRunControl && currentTool()
&& currentTool()->canRunRemotely()); && currentTool()->canRunRemotely());
d->m_startRemoteAction->setToolTip(disabledReason);
d->m_toolBox->setEnabled(!d->m_currentRunControl); d->m_toolBox->setEnabled(!d->m_currentRunControl);
d->m_toolGroup->setEnabled(!d->m_currentRunControl); d->m_toolGroup->setEnabled(!d->m_currentRunControl);

View File

@@ -2094,9 +2094,13 @@ void DebuggerPluginPrivate::updateDebugActions()
ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance(); ProjectExplorerPlugin *pe = ProjectExplorerPlugin::instance();
Project *project = pe->startupProject(); Project *project = pe->startupProject();
m_debugAction->setEnabled(pe->canRun(project, _(Constants::DEBUGMODE))); m_debugAction->setEnabled(pe->canRun(project, _(Constants::DEBUGMODE)));
m_debugAction->setToolTip(pe->cannotRunReason(project, _(Constants::DEBUGMODE)));
const bool canStepInto = pe->canRun(project, _(Constants::DEBUGMODE2)); const bool canStepInto = pe->canRun(project, _(Constants::DEBUGMODE2));
const QString cannotStepIntoReason = pe->cannotRunReason(project, _(Constants::DEBUGMODE2));
m_stepAction->setEnabled(canStepInto); m_stepAction->setEnabled(canStepInto);
m_nextAction->setEnabled(canStepInto); m_nextAction->setEnabled(canStepInto);
m_stepAction->setToolTip(cannotStepIntoReason);
m_nextAction->setToolTip(cannotStepIntoReason);
} }
void DebuggerPluginPrivate::onCoreAboutToOpen() void DebuggerPluginPrivate::onCoreAboutToOpen()
@@ -2773,6 +2777,7 @@ void DebuggerPluginPrivate::extensionsInitialized()
cmd = am->registerAction(m_debugAction, Constants::DEBUG, globalcontext); cmd = am->registerAction(m_debugAction, Constants::DEBUG, globalcontext);
cmd->setDefaultText(tr("Start Debugging")); cmd->setDefaultText(tr("Start Debugging"));
cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY)); cmd->setDefaultKeySequence(QKeySequence(Constants::DEBUG_KEY));
cmd->setAttribute(Command::CA_UpdateText);
mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE); mstart->addAction(cmd, Core::Constants::G_DEFAULT_ONE);
m_visibleDebugAction = new Utils::ProxyAction(this); m_visibleDebugAction = new Utils::ProxyAction(this);

View File

@@ -1908,8 +1908,6 @@ QPair<bool, QString> ProjectExplorerPlugin::buildSettingsEnabledForSession()
return result; return result;
} }
bool ProjectExplorerPlugin::coreAboutToClose() bool ProjectExplorerPlugin::coreAboutToClose()
{ {
if (d->m_buildManager->isBuilding()) { if (d->m_buildManager->isBuilding()) {
@@ -2135,10 +2133,47 @@ bool ProjectExplorerPlugin::canRun(Project *project, const QString &runMode)
return (canRun && !building); return (canRun && !building);
} }
QString ProjectExplorerPlugin::cannotRunReason(Project *project, const QString &runMode)
{
if (!project)
return tr("No active project");
if (!project->activeTarget())
return tr("The project '%1' has no active target").arg(project->displayName());
if (!project->activeTarget()->activeRunConfiguration())
return tr("The target '%1' for project '%2' has no active run configuration")
.arg(project->activeTarget()->displayName(), project->displayName());
if (d->m_projectExplorerSettings.buildBeforeDeploy
&& d->m_projectExplorerSettings.deployBeforeRun
&& hasBuildSettings(project)) {
QPair<bool, QString> buildState = buildSettingsEnabled(project);
if (!buildState.first)
return buildState.second;
}
RunConfiguration *activeRC = project->activeTarget()->activeRunConfiguration();
// shouldn't actually be shown to the user...
if (!findRunControlFactory(activeRC, runMode))
return tr("Cannot run '%1' in mode '%2'.")
.arg(activeRC->displayName(), runMode);
if (!activeRC->isEnabled())
return activeRC->disabledReason();
if (d->m_buildManager->isBuilding())
return tr("A build is still in progress.");
return QString();
}
void ProjectExplorerPlugin::slotUpdateRunActions() void ProjectExplorerPlugin::slotUpdateRunActions()
{ {
Project *project = startupProject(); Project *project = startupProject();
d->m_runAction->setEnabled(canRun(project, ProjectExplorer::Constants::RUNMODE)); d->m_runAction->setEnabled(canRun(project, ProjectExplorer::Constants::RUNMODE));
d->m_runAction->setToolTip(cannotRunReason(project, ProjectExplorer::Constants::RUNMODE));
} }
void ProjectExplorerPlugin::cancelBuild() void ProjectExplorerPlugin::cancelBuild()

View File

@@ -118,6 +118,7 @@ public:
bool coreAboutToClose(); bool coreAboutToClose();
bool canRun(Project *pro, const QString &runMode); bool canRun(Project *pro, const QString &runMode);
QString cannotRunReason(Project *project, const QString &runMode);
void runProject(Project *pro, const QString &mode); void runProject(Project *pro, const QString &mode);
void runRunConfiguration(ProjectExplorer::RunConfiguration *rc, const QString &mode); void runRunConfiguration(ProjectExplorer::RunConfiguration *rc, const QString &mode);