forked from qt-creator/qt-creator
CMake: Use current pattern to access main settings page
Change-Id: I95c556bebe1d583879b6702f727d9a859b9a4bcb Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -299,9 +299,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildSystem *bs) :
|
||||
m_batchEditButton->setToolTip(Tr::tr("Set or reset multiple values in the CMake configuration."));
|
||||
|
||||
m_showAdvancedCheckBox = new QCheckBox(Tr::tr("Advanced"));
|
||||
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
m_showAdvancedCheckBox->setChecked(settings->showAdvancedOptionsByDefault.value());
|
||||
m_showAdvancedCheckBox->setChecked(settings().showAdvancedOptionsByDefault());
|
||||
|
||||
connect(m_configView->selectionModel(), &QItemSelectionModel::selectionChanged,
|
||||
this, [this](const QItemSelection &, const QItemSelection &) {
|
||||
@@ -589,20 +587,18 @@ void CMakeBuildSettingsWidget::batchEditConfiguration()
|
||||
|
||||
void CMakeBuildSettingsWidget::reconfigureWithInitialParameters()
|
||||
{
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
QMessageBox::StandardButton reply = CheckableMessageBox::question(
|
||||
Core::ICore::dialogParent(),
|
||||
Tr::tr("Re-configure with Initial Parameters"),
|
||||
Tr::tr("Clear CMake configuration and configure with initial parameters?"),
|
||||
settings->askBeforeReConfigureInitialParams.askAgainCheckableDecider(),
|
||||
settings().askBeforeReConfigureInitialParams.askAgainCheckableDecider(),
|
||||
QMessageBox::Yes | QMessageBox::No,
|
||||
QMessageBox::Yes);
|
||||
|
||||
settings->writeSettings();
|
||||
settings().writeSettings();
|
||||
|
||||
if (reply != QMessageBox::Yes) {
|
||||
if (reply != QMessageBox::Yes)
|
||||
return;
|
||||
}
|
||||
|
||||
m_buildSystem->clearCMakeCache();
|
||||
|
||||
@@ -1135,7 +1131,7 @@ static CommandLine defaultInitialCMakeCommand(const Kit *k, const QString buildT
|
||||
cmd.addArg("-DCMAKE_BUILD_TYPE:STRING=" + buildType);
|
||||
|
||||
// Package manager auto setup
|
||||
if (Internal::CMakeSpecificSettings::instance()->packageManagerAutoSetup.value()) {
|
||||
if (settings().packageManagerAutoSetup()) {
|
||||
cmd.addArg(QString("-DCMAKE_PROJECT_INCLUDE_BEFORE:FILEPATH="
|
||||
"%{BuildConfig:BuildDirectory:NativeFilePath}/%1/auto-setup.cmake")
|
||||
.arg(Constants::PACKAGE_MANAGER_DIR));
|
||||
@@ -2059,11 +2055,9 @@ void CMakeBuildConfiguration::addToEnvironment(Utils::Environment &env) const
|
||||
if (tool && tool->cmakeExecutable().needsDevice())
|
||||
return;
|
||||
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
if (!settings->ninjaPath().isEmpty()) {
|
||||
const Utils::FilePath ninja = settings->ninjaPath();
|
||||
const FilePath ninja = settings().ninjaPath();
|
||||
if (!ninja.isEmpty())
|
||||
env.appendOrSetPath(ninja.isFile() ? ninja.parentDir() : ninja);
|
||||
}
|
||||
}
|
||||
|
||||
Environment CMakeBuildConfiguration::configureEnvironment() const
|
||||
|
||||
@@ -1190,8 +1190,7 @@ void CMakeBuildSystem::wireUpConnections()
|
||||
|
||||
connect(project(), &Project::projectFileIsDirty, this, [this] {
|
||||
if (buildConfiguration()->isActive() && !isParsing()) {
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
if (settings->autorunCMake.value()) {
|
||||
if (settings().autorunCMake()) {
|
||||
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file";
|
||||
reparse(CMakeBuildSystem::REPARSE_FORCE_CMAKE_RUN);
|
||||
}
|
||||
|
||||
@@ -648,8 +648,7 @@ QVariant CMakeGeneratorKitAspect::defaultValue(const Kit *k) const
|
||||
});
|
||||
if (it != known.constEnd()) {
|
||||
const bool hasNinja = [k, tool] {
|
||||
auto settings = Internal::CMakeSpecificSettings::instance();
|
||||
if (settings->ninjaPath().isEmpty()) {
|
||||
if (Internal::settings().ninjaPath().isEmpty()) {
|
||||
auto findNinja = [](const Environment &env) -> bool {
|
||||
return !env.searchInPath("ninja").isEmpty();
|
||||
};
|
||||
|
||||
@@ -101,7 +101,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, const QStringList &
|
||||
}
|
||||
|
||||
// Copy the "package-manager" CMake code from the ${IDE:ResourcePath} to the build directory
|
||||
if (Internal::CMakeSpecificSettings::instance()->packageManagerAutoSetup.value()) {
|
||||
if (settings().packageManagerAutoSetup()) {
|
||||
const FilePath localPackageManagerDir = buildDirectory.pathAppended(Constants::PACKAGE_MANAGER_DIR);
|
||||
const FilePath idePackageManagerDir = FilePath::fromString(
|
||||
parameters.expander->expand(QStringLiteral("%{IDE:ResourcePath}/package-manager")));
|
||||
|
||||
@@ -231,14 +231,12 @@ void CMakeManager::enableBuildFileMenus(Node *node)
|
||||
|
||||
void CMakeManager::reloadCMakePresets()
|
||||
{
|
||||
auto settings = CMakeSpecificSettings::instance();
|
||||
|
||||
QMessageBox::StandardButton clickedButton = CheckableMessageBox::question(
|
||||
Core::ICore::dialogParent(),
|
||||
Tr::tr("Reload CMake Presets"),
|
||||
Tr::tr("Re-generates the kits that were created for CMake presets. All manual "
|
||||
"modifications to the CMake project settings will be lost."),
|
||||
settings->askBeforePresetsReload.askAgainCheckableDecider(),
|
||||
settings().askBeforePresetsReload.askAgainCheckableDecider(),
|
||||
QMessageBox::Yes | QMessageBox::Cancel,
|
||||
QMessageBox::Yes,
|
||||
QMessageBox::Yes,
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectnodes.h"
|
||||
#include "cmakesettingspage.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "cmaketoolmanager.h"
|
||||
|
||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||
@@ -54,7 +53,6 @@ public:
|
||||
};
|
||||
|
||||
CMakeSettingsPage settingsPage;
|
||||
CMakeSpecificSettings specificSettings;
|
||||
|
||||
CMakeManager manager;
|
||||
CMakeBuildStepFactory buildStepFactory;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
|
||||
#include <utils/layoutbuilder.h>
|
||||
@@ -15,23 +17,14 @@ using namespace Utils;
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
static CMakeSpecificSettings *theSettings;
|
||||
|
||||
CMakeSpecificSettings *CMakeSpecificSettings::instance()
|
||||
CMakeSpecificSettings &settings()
|
||||
{
|
||||
static CMakeSpecificSettings theSettings;
|
||||
return theSettings;
|
||||
}
|
||||
|
||||
CMakeSpecificSettings::CMakeSpecificSettings()
|
||||
{
|
||||
theSettings = this;
|
||||
|
||||
setId(Constants::Settings::GENERAL_ID);
|
||||
setDisplayName(::CMakeProjectManager::Tr::tr("General"));
|
||||
setDisplayCategory("CMake");
|
||||
setCategory(Constants::Settings::CATEGORY);
|
||||
setCategoryIconPath(Constants::Icons::SETTINGS_CATEGORY);
|
||||
|
||||
setLayouter([this] {
|
||||
using namespace Layouting;
|
||||
return Column {
|
||||
@@ -91,4 +84,20 @@ CMakeSpecificSettings::CMakeSpecificSettings()
|
||||
readSettings();
|
||||
}
|
||||
|
||||
class CMakeSpecificSettingsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
CMakeSpecificSettingsPage()
|
||||
{
|
||||
setId(Constants::Settings::GENERAL_ID);
|
||||
setDisplayName(::CMakeProjectManager::Tr::tr("General"));
|
||||
setDisplayCategory("CMake");
|
||||
setCategory(Constants::Settings::CATEGORY);
|
||||
setCategoryIconPath(Constants::Icons::SETTINGS_CATEGORY);
|
||||
setSettingsProvider([] { return &settings(); });
|
||||
}
|
||||
};
|
||||
|
||||
const CMakeSpecificSettingsPage settingsPage;
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -3,17 +3,15 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
#include <utils/aspects.h>
|
||||
|
||||
namespace CMakeProjectManager::Internal {
|
||||
|
||||
class CMakeSpecificSettings final : public Core::PagedSettings
|
||||
class CMakeSpecificSettings final : public Utils::AspectContainer
|
||||
{
|
||||
public:
|
||||
CMakeSpecificSettings();
|
||||
|
||||
static CMakeSpecificSettings *instance();
|
||||
|
||||
Utils::BoolAspect autorunCMake{this};
|
||||
Utils::FilePathAspect ninjaPath{this};
|
||||
Utils::BoolAspect packageManagerAutoSetup{this};
|
||||
@@ -23,4 +21,6 @@ public:
|
||||
Utils::BoolAspect showAdvancedOptionsByDefault{this};
|
||||
};
|
||||
|
||||
CMakeSpecificSettings &settings();
|
||||
|
||||
} // CMakeProjectManager::Internal
|
||||
|
||||
@@ -142,11 +142,11 @@ void CMakeToolManager::restoreCMakeTools()
|
||||
|
||||
// Store the default CMake tool "Autorun CMake" value globally
|
||||
// TODO: Remove in Qt Creator 13
|
||||
auto settings = Internal::CMakeSpecificSettings::instance();
|
||||
if (settings->autorunCMake.value() == settings->autorunCMake.defaultValue()) {
|
||||
Internal::CMakeSpecificSettings &s = Internal::settings();
|
||||
if (s.autorunCMake() == s.autorunCMake.defaultValue()) {
|
||||
CMakeTool *cmake = defaultCMakeTool();
|
||||
settings->autorunCMake.setValue(cmake ? cmake->isAutoRun() : true);
|
||||
settings->writeSettings();
|
||||
s.autorunCMake.setValue(cmake ? cmake->isAutoRun() : true);
|
||||
s.writeSettings();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,13 +174,13 @@ void CMakeToolSettingsAccessor::saveCMakeTools(const QList<CMakeTool *> &cmakeTo
|
||||
data.insert(QLatin1String(CMAKE_TOOL_DEFAULT_KEY), defaultId.toSetting());
|
||||
|
||||
int count = 0;
|
||||
const bool autoRun = settings().autorunCMake();
|
||||
for (CMakeTool *item : cmakeTools) {
|
||||
Utils::FilePath fi = item->cmakeExecutable();
|
||||
|
||||
// Gobal Autorun value will be set for all tools
|
||||
// TODO: Remove in Qt Creator 13
|
||||
const auto settings = CMakeSpecificSettings::instance();
|
||||
item->setAutorun(settings->autorunCMake.value());
|
||||
item->setAutorun(autoRun);
|
||||
|
||||
if (fi.needsDevice() || fi.isExecutableFile()) { // be graceful for device related stuff
|
||||
QVariantMap tmp = item->toMap();
|
||||
|
||||
@@ -540,10 +540,9 @@ void addCompileGroups(ProjectNode *targetRoot,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const TargetDetails &td)
|
||||
{
|
||||
const bool showSourceFolders = CMakeSpecificSettings::instance()->showSourceSubFolders.value();
|
||||
const bool showSourceFolders = settings().showSourceSubFolders();
|
||||
const bool inSourceBuild = (sourceDirectory == buildDirectory);
|
||||
|
||||
std::vector<std::unique_ptr<FileNode>> toList;
|
||||
QSet<Utils::FilePath> alreadyListed;
|
||||
|
||||
// Files already added by other configurations:
|
||||
|
||||
@@ -107,8 +107,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 = CMakeSpecificSettings::instance();
|
||||
const bool cmakeFilesChanged = m_parameters.cmakeTool() && settings->autorunCMake.value()
|
||||
const bool cmakeFilesChanged = m_parameters.cmakeTool() && settings().autorunCMake()
|
||||
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
||||
return !info.isGenerated
|
||||
&& info.path.lastModified() > replyFile.lastModified();
|
||||
|
||||
Reference in New Issue
Block a user