Commit a4a4f7a4 authored by Daniel Teske's avatar Daniel Teske

ProjectExplorer: Fix disabled "Close Project" after closing project

The close project action is special. If there are multiple projects open
we show a menu with individual actions per project. If only one project
is open, we show one the "m_unloadAction". Even with only one project
open, the current project might be null. So explicitly manage enabled
the same way as visible. And also us the displayName of the startup
project, since that is guranteed to be non-null if there's a project
open.

Task-number: QTCREATORBUG-13497
Change-Id: I9150568da162c58ee524c2b954e0b9a816f79d7c
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent 5449e0a7
......@@ -741,7 +741,7 @@ bool ProjectExplorerPlugin::initialize(const QStringList &arguments, QString *er
// unload action
dd->m_unloadAction = new Utils::ParameterAction(tr("Close Project"), tr("Close Project \"%1\""),
Utils::ParameterAction::EnabledWithParameter, this);
Utils::ParameterAction::AlwaysEnabled, this);
cmd = ActionManager::registerAction(dd->m_unloadAction, Constants::UNLOAD, globalcontext);
cmd->setAttribute(Command::CA_UpdateText);
cmd->setDescription(dd->m_unloadAction->text());
......@@ -2148,7 +2148,7 @@ void ProjectExplorerPluginPrivate::updateActions()
QString projectName = project ? project->displayName() : QString();
QString projectNameContextMenu = m_currentProject ? m_currentProject->displayName() : QString();
m_unloadAction->setParameter(projectNameContextMenu);
m_unloadAction->setParameter(projectName);
m_unloadActionContextMenu->setParameter(projectNameContextMenu);
// Normal actions
......@@ -2198,6 +2198,7 @@ void ProjectExplorerPluginPrivate::updateActions()
// Session actions
m_closeAllProjects->setEnabled(SessionManager::hasProjects());
m_unloadAction->setVisible(SessionManager::projects().size() <= 1);
m_unloadAction->setEnabled(SessionManager::projects().size() == 1);
m_unloadActionContextMenu->setEnabled(SessionManager::hasProjects());
ActionContainer *aci =
......
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