CMakePM: Allow CMake peset kits refresh without configuring first

This allows the user to reload the presets kits after editing
CMakePresets.json without configuring the project first.

Fixes: QTCREATORBUG-30238
Change-Id: Id448dd8e821591f6357ec9618f114733c13a3121
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Cristian Adam
2024-02-05 12:16:55 +01:00
parent c06dfdb237
commit 86b6d852b4
4 changed files with 20 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
#include "cmakeprocess.h"
#include "cmakeproject.h"
#include "cmakeprojectconstants.h"
#include "cmakeprojectimporter.h"
#include "cmakeprojectmanagertr.h"
#include "cmakeprojectnodes.h"
#include "cmakespecificsettings.h"
@@ -362,6 +363,8 @@ void CMakeManager::reloadCMakePresets()
project->setOldPresetKits(oldKits);
emit project->projectImporter()->cmakePresetsUpdated();
Core::ModeManager::activateMode(ProjectExplorer::Constants::MODE_SESSION);
Core::ModeManager::setFocusToCurrentMode();
}

View File

@@ -47,6 +47,9 @@ public:
void addProject(Kit *k) const;
void removeProject(Kit *k) const;
signals:
void cmakePresetsUpdated();
protected:
class UpdateGuard
{

View File

@@ -12,6 +12,7 @@
#include "project.h"
#include "projectexplorericons.h"
#include "projectexplorertr.h"
#include "projectimporter.h"
#include "projectmanager.h"
#include "projectwindow.h"
#include "runsettingspropertiespage.h"

View File

@@ -368,9 +368,22 @@ void TargetSetupPage::setProjectImporter(ProjectImporter *importer)
if (d->m_widgetsWereSetUp)
d->reset(); // Reset before changing the importer!
if (d->m_importer) {
disconnect(d->m_importer, &ProjectImporter::cmakePresetsUpdated,
this, &TargetSetupPage::initializePage);
}
d->m_importer = importer;
d->m_importWidget->setVisible(d->m_importer);
if (d->m_importer) {
// FIXME: Needed for the refresh of CMake preset kits created by
// CMakeProjectImporter
connect(d->m_importer, &ProjectImporter::cmakePresetsUpdated,
this, &TargetSetupPage::initializePage);
}
if (d->m_widgetsWereSetUp)
initializePage();
}