forked from qt-creator/qt-creator
CMake: Move settings storage closer to class implementation
Simpler in use. Change-Id: I8cc929001035974b9b73566b206410bfd77f73a6 Reviewed-by: Cristian Adam <cristian.adam@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
|
||||
#include "cmakebuildconfiguration.h"
|
||||
|
||||
#include "cmakebuildconfiguration.h"
|
||||
#include "cmakebuildstep.h"
|
||||
#include "cmakebuildsystem.h"
|
||||
#include "cmakeconfigitem.h"
|
||||
@@ -11,7 +10,6 @@
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "configmodel.h"
|
||||
#include "configmodelitemdelegate.h"
|
||||
@@ -300,7 +298,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
|
||||
|
||||
m_showAdvancedCheckBox = new QCheckBox(Tr::tr("Advanced"));
|
||||
|
||||
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
m_showAdvancedCheckBox->setChecked(settings->showAdvancedOptionsByDefault.value());
|
||||
|
||||
connect(m_configView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
@@ -608,10 +606,10 @@ void CMakeBuildSettingsWidget::batchEditConfiguration()
|
||||
|
||||
void CMakeBuildSettingsWidget::reconfigureWithInitialParameters()
|
||||
{
|
||||
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
bool doNotAsk = !settings->askBeforeReConfigureInitialParams.value();
|
||||
if (!doNotAsk) {
|
||||
QDialogButtonBox::StandardButton reply = Utils::CheckableMessageBox::question(
|
||||
QDialogButtonBox::StandardButton reply = CheckableMessageBox::question(
|
||||
Core::ICore::dialogParent(),
|
||||
Tr::tr("Re-configure with Initial Parameters"),
|
||||
Tr::tr("Clear CMake configuration and configure with initial parameters?"),
|
||||
@@ -1152,8 +1150,7 @@ static CommandLine defaultInitialCMakeCommand(const Kit *k, const QString buildT
|
||||
if (!buildType.isEmpty() && !CMakeGeneratorKitAspect::isMultiConfigGenerator(k))
|
||||
cmd.addArg("-DCMAKE_BUILD_TYPE:STRING=" + buildType);
|
||||
|
||||
Internal::CMakeSpecificSettings *settings
|
||||
= Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
auto settings = Internal::CMakeSpecificSettings::instance();
|
||||
|
||||
// Package manager auto setup. The file auto-setup.cmake resides on the host,
|
||||
// so it's not accessible for remotely running cmakes. We need to exclude that case.
|
||||
@@ -2122,7 +2119,7 @@ void CMakeBuildConfiguration::addToEnvironment(Utils::Environment &env) const
|
||||
if (tool && tool->cmakeExecutable().needsDevice())
|
||||
return;
|
||||
|
||||
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
if (!settings->ninjaPath.filePath().isEmpty()) {
|
||||
const Utils::FilePath ninja = settings->ninjaPath.filePath();
|
||||
env.appendOrSetPath(ninja.isFile() ? ninja.parentDir() : ninja);
|
||||
|
@@ -11,7 +11,6 @@
|
||||
#include "cmakeproject.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "projecttreehelper.h"
|
||||
|
||||
@@ -80,7 +79,7 @@ static void noAutoAdditionNotify(const FilePaths &filePaths, const ProjectNode *
|
||||
});
|
||||
|
||||
if (!srcPaths.empty()) {
|
||||
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
switch (settings->afterAddFileSetting.value()) {
|
||||
case AskUser: {
|
||||
bool checkValue{false};
|
||||
@@ -825,7 +824,7 @@ void CMakeBuildSystem::wireUpConnections()
|
||||
|
||||
connect(project(), &Project::projectFileIsDirty, this, [this] {
|
||||
if (buildConfiguration()->isActive() && !isParsing()) {
|
||||
auto settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
if (settings->autorunCMake.value()) {
|
||||
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file";
|
||||
reparse(CMakeBuildSystem::REPARSE_FORCE_CMAKE_RUN);
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "cmakeconfigitem.h"
|
||||
#include "cmakeprojectconstants.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "cmaketool.h"
|
||||
#include "cmaketoolmanager.h"
|
||||
@@ -680,9 +679,7 @@ QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const
|
||||
});
|
||||
if (it != known.constEnd()) {
|
||||
const bool hasNinja = [k, tool] {
|
||||
Internal::CMakeSpecificSettings *settings
|
||||
= Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
|
||||
auto settings = Internal::CMakeSpecificSettings::instance();
|
||||
if (settings->ninjaPath.filePath().isEmpty()) {
|
||||
auto findNinja = [](const Environment &env) -> bool {
|
||||
return !env.searchInPath("ninja").isEmpty();
|
||||
|
@@ -74,7 +74,7 @@ public:
|
||||
};
|
||||
|
||||
CMakeSettingsPage settingsPage;
|
||||
CMakeSpecificSettingsPage specificSettings{CMakeProjectPlugin::projectTypeSpecificSettings()};
|
||||
CMakeSpecificSettingsPage specificSettings;
|
||||
|
||||
CMakeManager manager;
|
||||
CMakeBuildStepFactory buildStepFactory;
|
||||
@@ -138,12 +138,6 @@ void CMakeProjectPluginPrivate::autoFormatOnSave(Core::IDocument *document)
|
||||
TextEditor::formatEditor(widget, command);
|
||||
}
|
||||
|
||||
CMakeSpecificSettings *CMakeProjectPlugin::projectTypeSpecificSettings()
|
||||
{
|
||||
static CMakeSpecificSettings theSettings;
|
||||
return &theSettings;
|
||||
}
|
||||
|
||||
CMakeProjectPlugin::~CMakeProjectPlugin()
|
||||
{
|
||||
delete d;
|
||||
@@ -152,7 +146,7 @@ CMakeProjectPlugin::~CMakeProjectPlugin()
|
||||
void CMakeProjectPlugin::initialize()
|
||||
{
|
||||
d = new CMakeProjectPluginPrivate;
|
||||
projectTypeSpecificSettings()->readSettings(ICore::settings());
|
||||
CMakeSpecificSettings::instance()->readSettings(ICore::settings());
|
||||
|
||||
const Context projectContext{CMakeProjectManager::Constants::CMAKE_PROJECT_ID};
|
||||
|
||||
|
@@ -9,15 +9,12 @@ namespace ProjectExplorer { class Node; }
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
class CMakeSpecificSettings;
|
||||
|
||||
class CMakeProjectPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "CMakeProjectManager.json")
|
||||
|
||||
public:
|
||||
static CMakeSpecificSettings *projectTypeSpecificSettings();
|
||||
~CMakeProjectPlugin();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
@@ -73,10 +73,17 @@ CMakeSpecificSettings::CMakeSpecificSettings()
|
||||
::CMakeProjectManager::Tr::tr("Show advanced options by default"));
|
||||
}
|
||||
|
||||
CMakeSpecificSettings *CMakeSpecificSettings::instance()
|
||||
{
|
||||
static CMakeSpecificSettings theSettings;
|
||||
return &theSettings;
|
||||
}
|
||||
|
||||
// CMakeSpecificSettingsPage
|
||||
|
||||
CMakeSpecificSettingsPage::CMakeSpecificSettingsPage(CMakeSpecificSettings *settings)
|
||||
CMakeSpecificSettingsPage::CMakeSpecificSettingsPage()
|
||||
{
|
||||
CMakeSpecificSettings *settings = CMakeSpecificSettings::instance();
|
||||
setId(Constants::Settings::GENERAL_ID);
|
||||
setDisplayName(::CMakeProjectManager::Tr::tr("General"));
|
||||
setDisplayCategory("CMake");
|
||||
|
@@ -20,6 +20,8 @@ class CMakeSpecificSettings final : public Utils::AspectContainer
|
||||
public:
|
||||
CMakeSpecificSettings();
|
||||
|
||||
static CMakeSpecificSettings *instance();
|
||||
|
||||
Utils::BoolAspect autorunCMake;
|
||||
Utils::SelectionAspect afterAddFileSetting;
|
||||
Utils::StringAspect ninjaPath;
|
||||
@@ -32,7 +34,7 @@ public:
|
||||
class CMakeSpecificSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
explicit CMakeSpecificSettingsPage(CMakeSpecificSettings *settings);
|
||||
CMakeSpecificSettingsPage();
|
||||
};
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#include "cmaketoolmanager.h"
|
||||
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "cmaketoolsettingsaccessor.h"
|
||||
|
||||
@@ -142,7 +141,7 @@ void CMakeToolManager::restoreCMakeTools()
|
||||
emit m_instance->cmakeToolsLoaded();
|
||||
|
||||
// Store the default CMake tool "Autorun CMake" value globally
|
||||
auto settings = Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
auto settings = Internal::CMakeSpecificSettings::instance();
|
||||
if (settings->autorunCMake.value() == settings->autorunCMake.defaultValue()) {
|
||||
CMakeTool *cmake = defaultCMakeTool();
|
||||
settings->autorunCMake.setValue(cmake ? cmake->isAutoRun() : true);
|
||||
|
@@ -525,9 +525,7 @@ void addCompileGroups(ProjectNode *targetRoot,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const TargetDetails &td)
|
||||
{
|
||||
CMakeSpecificSettings *settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
const bool showSourceFolders = settings->showSourceSubFolders.value();
|
||||
|
||||
const bool showSourceFolders = CMakeSpecificSettings::instance()->showSourceSubFolders.value();
|
||||
const bool inSourceBuild = (sourceDirectory == buildDirectory);
|
||||
|
||||
std::vector<std::unique_ptr<FileNode>> toList;
|
||||
|
@@ -108,7 +108,7 @@ void FileApiReader::parse(bool forceCMakeRun,
|
||||
// * A query file is newer than the reply file
|
||||
const bool hasArguments = !args.isEmpty();
|
||||
const bool replyFileMissing = !replyFile.exists();
|
||||
const auto settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
const auto settings = CMakeSpecificSettings::instance();
|
||||
const bool cmakeFilesChanged = m_parameters.cmakeTool() && settings->autorunCMake.value()
|
||||
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
||||
return !info.isGenerated
|
||||
|
Reference in New Issue
Block a user