diff options
Diffstat (limited to 'src/plugins/cmakeprojectmanager')
8 files changed, 28 insertions, 33 deletions
diff --git a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp index b26c8acc7e..0f7665242f 100644 --- a/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp +++ b/src/plugins/cmakeprojectmanager/cmakebuildsystem.cpp @@ -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); } diff --git a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp index 4e9bb6a24a..317e4c10f3 100644 --- a/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp +++ b/src/plugins/cmakeprojectmanager/cmakesettingspage.cpp @@ -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; } diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp b/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp index 8f4cadb40c..071588ed4a 100644 --- a/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp +++ b/src/plugins/cmakeprojectmanager/cmakespecificsettings.cpp @@ -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, diff --git a/src/plugins/cmakeprojectmanager/cmakespecificsettings.h b/src/plugins/cmakeprojectmanager/cmakespecificsettings.h index 7b6b34e90f..f014a867ac 100644 --- a/src/plugins/cmakeprojectmanager/cmakespecificsettings.h +++ b/src/plugins/cmakeprojectmanager/cmakespecificsettings.h @@ -20,6 +20,7 @@ class CMakeSpecificSettings final : public Utils::AspectContainer public: CMakeSpecificSettings(); + Utils::BoolAspect autorunCMake; Utils::SelectionAspect afterAddFileSetting; Utils::StringAspect ninjaPath; Utils::BoolAspect packageManagerAutoSetup; diff --git a/src/plugins/cmakeprojectmanager/cmaketool.cpp b/src/plugins/cmakeprojectmanager/cmaketool.cpp index 0af885ac17..0f4d6f6f00 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketool.cpp @@ -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) diff --git a/src/plugins/cmakeprojectmanager/cmaketool.h b/src/plugins/cmakeprojectmanager/cmaketool.h index 94e122d204..75c1c05aa6 100644 --- a/src/plugins/cmakeprojectmanager/cmaketool.h +++ b/src/plugins/cmakeprojectmanager/cmaketool.h @@ -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; diff --git a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp index 301d20dea2..4d3fbeb2f6 100644 --- a/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp +++ b/src/plugins/cmakeprojectmanager/cmaketoolmanager.cpp @@ -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() diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index 9ddd15b5b8..38c7995134 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -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(); |