forked from qt-creator/qt-creator
CMakePM: Make "Autorun CMake" a global setting
The "Autorun CMake" is only visible in the Tools settings page when the user clicks on CMake tool. This is not very visible and it doesn't have to be per CMake version. Change-Id: I57ded0b2e6a3ecb731bb8bc1495b6b61bc04c8b6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -832,8 +832,8 @@ void CMakeBuildSystem::wireUpConnections()
|
||||
|
||||
connect(project(), &Project::projectFileIsDirty, this, [this] {
|
||||
if (buildConfiguration()->isActive() && !isParsing()) {
|
||||
const auto cmake = CMakeKitAspect::cmakeTool(kit());
|
||||
if (cmake && cmake->isAutoRun()) {
|
||||
auto settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
if (settings->autorunCMake.value()) {
|
||||
qCDebug(cmakeBuildSystemLog) << "Requesting parse due to dirty project file";
|
||||
reparse(CMakeBuildSystem::REPARSE_FORCE_CMAKE_RUN);
|
||||
}
|
||||
|
@@ -58,8 +58,7 @@ public:
|
||||
void updateCMakeTool(const Utils::Id &id,
|
||||
const QString &displayName,
|
||||
const FilePath &executable,
|
||||
const FilePath &qchFile,
|
||||
bool autoRun);
|
||||
const FilePath &qchFile);
|
||||
void removeCMakeTool(const Utils::Id &id);
|
||||
void apply();
|
||||
|
||||
@@ -82,7 +81,6 @@ public:
|
||||
, m_qchFile(item->qchFilePath())
|
||||
, m_versionDisplay(item->versionDisplay())
|
||||
, m_detectionSource(item->detectionSource())
|
||||
, m_isAutoRun(item->isAutoRun())
|
||||
, m_autodetected(item->isAutoDetected())
|
||||
, m_isSupported(item->hasFileApi())
|
||||
, m_changed(changed)
|
||||
@@ -280,8 +278,7 @@ void CMakeToolItemModel::reevaluateChangedFlag(CMakeToolTreeItem *item) const
|
||||
void CMakeToolItemModel::updateCMakeTool(const Id &id,
|
||||
const QString &displayName,
|
||||
const FilePath &executable,
|
||||
const FilePath &qchFile,
|
||||
bool autoRun)
|
||||
const FilePath &qchFile)
|
||||
{
|
||||
CMakeToolTreeItem *treeItem = cmakeToolItem(id);
|
||||
QTC_ASSERT(treeItem, return );
|
||||
@@ -289,7 +286,6 @@ void CMakeToolItemModel::updateCMakeTool(const Id &id,
|
||||
treeItem->m_name = displayName;
|
||||
treeItem->m_executable = executable;
|
||||
treeItem->m_qchFile = qchFile;
|
||||
treeItem->m_isAutoRun = autoRun;
|
||||
|
||||
treeItem->updateErrorFlags();
|
||||
|
||||
@@ -331,7 +327,6 @@ void CMakeToolItemModel::apply()
|
||||
cmake->setFilePath(item->m_executable);
|
||||
cmake->setQchFilePath(item->m_qchFile);
|
||||
cmake->setDetectionSource(item->m_detectionSource);
|
||||
cmake->setAutorun(item->m_isAutoRun);
|
||||
} else {
|
||||
toRegister.append(item);
|
||||
}
|
||||
@@ -399,7 +394,6 @@ private:
|
||||
|
||||
CMakeToolItemModel *m_model;
|
||||
QLineEdit *m_displayNameLineEdit;
|
||||
QCheckBox *m_autoRunCheckBox;
|
||||
PathChooser *m_binaryChooser;
|
||||
PathChooser *m_qchFileChooser;
|
||||
QLabel *m_versionLabel;
|
||||
@@ -428,24 +422,17 @@ CMakeToolItemConfigWidget::CMakeToolItemConfigWidget(CMakeToolItemModel *model)
|
||||
|
||||
m_versionLabel = new QLabel(this);
|
||||
|
||||
m_autoRunCheckBox = new QCheckBox;
|
||||
m_autoRunCheckBox->setText(Tr::tr("Autorun CMake"));
|
||||
m_autoRunCheckBox->setToolTip(Tr::tr("Automatically run CMake after changes to CMake project files."));
|
||||
|
||||
auto formLayout = new QFormLayout(this);
|
||||
formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
||||
formLayout->addRow(new QLabel(Tr::tr("Name:")), m_displayNameLineEdit);
|
||||
formLayout->addRow(new QLabel(Tr::tr("Path:")), m_binaryChooser);
|
||||
formLayout->addRow(new QLabel(Tr::tr("Version:")), m_versionLabel);
|
||||
formLayout->addRow(new QLabel(Tr::tr("Help file:")), m_qchFileChooser);
|
||||
formLayout->addRow(m_autoRunCheckBox);
|
||||
|
||||
connect(m_binaryChooser, &PathChooser::browsingFinished, this, &CMakeToolItemConfigWidget::onBinaryPathEditingFinished);
|
||||
connect(m_binaryChooser, &PathChooser::editingFinished, this, &CMakeToolItemConfigWidget::onBinaryPathEditingFinished);
|
||||
connect(m_qchFileChooser, &PathChooser::rawPathChanged, this, &CMakeToolItemConfigWidget::store);
|
||||
connect(m_displayNameLineEdit, &QLineEdit::textChanged, this, &CMakeToolItemConfigWidget::store);
|
||||
connect(m_autoRunCheckBox, &QCheckBox::toggled,
|
||||
this, &CMakeToolItemConfigWidget::store);
|
||||
}
|
||||
|
||||
void CMakeToolItemConfigWidget::store() const
|
||||
@@ -454,8 +441,7 @@ void CMakeToolItemConfigWidget::store() const
|
||||
m_model->updateCMakeTool(m_id,
|
||||
m_displayNameLineEdit->text(),
|
||||
m_binaryChooser->filePath(),
|
||||
m_qchFileChooser->filePath(),
|
||||
m_autoRunCheckBox->checkState() == Qt::Checked);
|
||||
m_qchFileChooser->filePath());
|
||||
}
|
||||
|
||||
void CMakeToolItemConfigWidget::onBinaryPathEditingFinished()
|
||||
@@ -493,8 +479,6 @@ void CMakeToolItemConfigWidget::load(const CMakeToolTreeItem *item)
|
||||
|
||||
m_versionLabel->setText(item->m_versionDisplay);
|
||||
|
||||
m_autoRunCheckBox->setChecked(item->m_isAutoRun);
|
||||
|
||||
m_id = item->m_id;
|
||||
m_loadingItem = false;
|
||||
}
|
||||
|
@@ -23,6 +23,13 @@ CMakeSpecificSettings::CMakeSpecificSettings()
|
||||
setSettingsGroup("CMakeSpecificSettings");
|
||||
setAutoApply(false);
|
||||
|
||||
registerAspect(&autorunCMake);
|
||||
autorunCMake.setSettingsKey("AutorunCMake");
|
||||
autorunCMake.setDefaultValue(true);
|
||||
autorunCMake.setLabelText(::CMakeProjectManager::Tr::tr("Autorun CMake"));
|
||||
autorunCMake.setToolTip(::CMakeProjectManager::Tr::tr(
|
||||
"Automatically run CMake after changes to CMake project files."));
|
||||
|
||||
registerAspect(&afterAddFileSetting);
|
||||
afterAddFileSetting.setSettingsKey("ProjectPopupSetting");
|
||||
afterAddFileSetting.setDefaultValue(AfterAddFileAction::AskUser);
|
||||
@@ -85,6 +92,7 @@ CMakeSpecificSettingsPage::CMakeSpecificSettingsPage(CMakeSpecificSettings *sett
|
||||
title(::CMakeProjectManager::Tr::tr("Adding Files")),
|
||||
Column { s.afterAddFileSetting }
|
||||
},
|
||||
s.autorunCMake,
|
||||
s.packageManagerAutoSetup,
|
||||
s.askBeforeReConfigureInitialParams,
|
||||
s.showSourceSubFolders,
|
||||
|
@@ -20,6 +20,7 @@ class CMakeSpecificSettings final : public Utils::AspectContainer
|
||||
public:
|
||||
CMakeSpecificSettings();
|
||||
|
||||
Utils::BoolAspect autorunCMake;
|
||||
Utils::SelectionAspect afterAddFileSetting;
|
||||
Utils::StringAspect ninjaPath;
|
||||
Utils::BoolAspect packageManagerAutoSetup;
|
||||
|
@@ -151,15 +151,6 @@ FilePath CMakeTool::filePath() const
|
||||
return m_executable;
|
||||
}
|
||||
|
||||
void CMakeTool::setAutorun(bool autoRun)
|
||||
{
|
||||
if (m_isAutoRun == autoRun)
|
||||
return;
|
||||
|
||||
m_isAutoRun = autoRun;
|
||||
CMakeToolManager::notifyAboutUpdate(this);
|
||||
}
|
||||
|
||||
bool CMakeTool::isValid() const
|
||||
{
|
||||
if (!m_id.isValid() || !m_introspection)
|
||||
|
@@ -61,8 +61,6 @@ public:
|
||||
Utils::Id id() const { return m_id; }
|
||||
QVariantMap toMap () const;
|
||||
|
||||
void setAutorun(bool autoRun);
|
||||
|
||||
void setFilePath(const Utils::FilePath &executable);
|
||||
Utils::FilePath filePath() const;
|
||||
Utils::FilePath cmakeExecutable() const;
|
||||
|
@@ -4,6 +4,8 @@
|
||||
#include "cmaketoolmanager.h"
|
||||
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "cmaketoolsettingsaccessor.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
@@ -138,6 +140,14 @@ void CMakeToolManager::restoreCMakeTools()
|
||||
updateDocumentation();
|
||||
|
||||
emit m_instance->cmakeToolsLoaded();
|
||||
|
||||
// Store the default CMake tool "Autorun CMake" value globally
|
||||
auto settings = Internal::CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
if (settings->autorunCMake.value() == settings->autorunCMake.defaultValue()) {
|
||||
CMakeTool *cmake = defaultCMakeTool();
|
||||
settings->autorunCMake.setValue(cmake ? cmake->isAutoRun() : true);
|
||||
settings->writeSettings(Core::ICore::settings());
|
||||
}
|
||||
}
|
||||
|
||||
void CMakeToolManager::updateDocumentation()
|
||||
|
@@ -5,6 +5,8 @@
|
||||
|
||||
#include "cmakeprocess.h"
|
||||
#include "cmakeprojectmanagertr.h"
|
||||
#include "cmakeprojectplugin.h"
|
||||
#include "cmakespecificsettings.h"
|
||||
#include "fileapidataextractor.h"
|
||||
#include "fileapiparser.h"
|
||||
|
||||
@@ -106,7 +108,8 @@ 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 bool cmakeFilesChanged = m_parameters.cmakeTool() && m_parameters.cmakeTool()->isAutoRun()
|
||||
const auto settings = CMakeProjectPlugin::projectTypeSpecificSettings();
|
||||
const bool cmakeFilesChanged = m_parameters.cmakeTool() && settings->autorunCMake.value()
|
||||
&& anyOf(m_cmakeFiles, [&replyFile](const CMakeFileInfo &info) {
|
||||
return !info.isGenerated
|
||||
&& info.path.lastModified() > replyFile.lastModified();
|
||||
|
Reference in New Issue
Block a user