Make it possible to select default session from menu

when we are in the limbo state where no session has been loaded, and the
default session has not been explicitly created or loaded yet.

Fixes: QTCREATORBUG-28393
Change-Id: I66d69561e18b5073a477d90c1926074e3cd97cee
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Eike Ziller
2022-11-25 10:52:24 +01:00
parent 3cd3bba720
commit cb8742ccab

View File

@@ -4173,6 +4173,7 @@ void ProjectExplorerPluginPrivate::updateSessionMenu()
auto *ag = new QActionGroup(m_sessionMenu);
connect(ag, &QActionGroup::triggered, this, &ProjectExplorerPluginPrivate::setSession);
const QString activeSession = SessionManager::activeSession();
const bool isDefaultVirgin = SessionManager::isDefaultVirgin();
const QStringList sessions = SessionManager::sessions();
for (int i = 0; i < sessions.size(); ++i) {
@@ -4184,7 +4185,7 @@ void ProjectExplorerPluginPrivate::updateSessionMenu()
QAction *act = ag->addAction(actionText);
act->setData(session);
act->setCheckable(true);
if (session == activeSession)
if (session == activeSession && !isDefaultVirgin)
act->setChecked(true);
}
m_sessionMenu->addActions(ag->actions());
@@ -4193,9 +4194,7 @@ void ProjectExplorerPluginPrivate::updateSessionMenu()
void ProjectExplorerPluginPrivate::setSession(QAction *action)
{
QString session = action->data().toString();
if (session != SessionManager::activeSession())
SessionManager::loadSession(session);
SessionManager::loadSession(action->data().toString());
}
void ProjectExplorerPlugin::setProjectExplorerSettings(const ProjectExplorerSettings &pes)