summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cppcodemodelsettingspage.cpp
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2021-06-25 18:16:08 +0200
committerChristian Kandeler <christian.kandeler@qt.io>2021-06-28 10:35:33 +0000
commit56cddf38b37c5b36424121d67592a9ce7b6ac10c (patch)
treed2a73a09483146081e7a83170614ac6780a047ad /src/plugins/cpptools/cppcodemodelsettingspage.cpp
parent876cd8e9755aff5bb69264f9aa0c5210b23b3920 (diff)
downloadqt-creator-56cddf38b37c5b36424121d67592a9ce7b6ac10c.tar.gz
Clangd: Let users limit the worker thread count
This is particularly interesting for indexing, where users might prefer a slower-building index with less CPU load. Change-Id: Id44c58e9041df2857cd0772e71345673b14623f3 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cppcodemodelsettingspage.cpp')
-rw-r--r--src/plugins/cpptools/cppcodemodelsettingspage.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.cpp b/src/plugins/cpptools/cppcodemodelsettingspage.cpp
index d3a75af0cb..f48f639d16 100644
--- a/src/plugins/cpptools/cppcodemodelsettingspage.cpp
+++ b/src/plugins/cpptools/cppcodemodelsettingspage.cpp
@@ -36,6 +36,7 @@
#include <utils/pathchooser.h>
#include <QFormLayout>
+#include <QSpinBox>
#include <QTextStream>
namespace CppTools {
@@ -210,6 +211,10 @@ public:
"If background indexing is enabled, global symbol searches will yield\n"
"more accurate results, at the cost of additional CPU load when\n"
"the project is first opened."));
+ m_threadLimitCheckBox.setText(tr("Set worker thread count limit"));
+ m_threadLimitCheckBox.setChecked(ClangdSettings::workerThreadLimit() != 0);
+ m_threadLimitSpinBox.setMinimum(1);
+ m_threadLimitSpinBox.setValue(ClangdSettings::workerThreadLimit());
const auto layout = new QVBoxLayout(this);
layout->addWidget(&m_useClangdCheckBox);
@@ -218,6 +223,10 @@ public:
formLayout->addRow(chooserLabel, &m_clangdChooser);
const auto indexingLabel = new QLabel(tr("Enable background indexing:"));
formLayout->addRow(indexingLabel, &m_indexingCheckBox);
+ const auto threadLimitLayout = new QHBoxLayout;
+ threadLimitLayout->addWidget(&m_threadLimitSpinBox);
+ threadLimitLayout->addStretch(1);
+ formLayout->addRow(&m_threadLimitCheckBox, threadLimitLayout);
layout->addLayout(formLayout);
layout->addStretch(1);
@@ -226,9 +235,15 @@ public:
m_clangdChooser.setEnabled(checked);
indexingLabel->setEnabled(checked);
m_indexingCheckBox.setEnabled(checked);
+ m_threadLimitCheckBox.setEnabled(checked);
+ m_threadLimitSpinBox.setEnabled(checked && m_threadLimitCheckBox.isChecked());
};
connect(&m_useClangdCheckBox, &QCheckBox::toggled, toggleEnabled);
+ connect(&m_threadLimitCheckBox, &QCheckBox::toggled,
+ &m_threadLimitSpinBox, &QSpinBox::setEnabled);
toggleEnabled(m_useClangdCheckBox.isChecked());
+ m_threadLimitSpinBox.setEnabled(m_useClangdCheckBox.isChecked()
+ && m_threadLimitCheckBox.isChecked());
}
private:
@@ -238,11 +253,15 @@ private:
data.useClangd = m_useClangdCheckBox.isChecked();
data.executableFilePath = m_clangdChooser.filePath();
data.enableIndexing = m_indexingCheckBox.isChecked();
+ data.workerThreadLimit = m_threadLimitCheckBox.isChecked()
+ ? m_threadLimitSpinBox.value() : 0;
ClangdSettings::setData(data);
}
QCheckBox m_useClangdCheckBox;
QCheckBox m_indexingCheckBox;
+ QCheckBox m_threadLimitCheckBox;
+ QSpinBox m_threadLimitSpinBox;
Utils::PathChooser m_clangdChooser;
};
@@ -254,7 +273,5 @@ ClangdSettingsPage::ClangdSettingsPage()
setWidgetCreator([] { return new ClangdSettingsWidget; });
}
-
-
} // Internal
} // CppTools