Clangd: use special value text for automatic worker count

Change-Id: Iddb75b6716724b5994d8093a8e389f5cb8e2d044
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
David Schulz
2021-06-28 12:21:30 +02:00
parent 2d08b296b7
commit 44f0f9ae18

View File

@@ -211,10 +211,8 @@ public:
"If background indexing is enabled, global symbol searches will yield\n" "If background indexing is enabled, global symbol searches will yield\n"
"more accurate results, at the cost of additional CPU load when\n" "more accurate results, at the cost of additional CPU load when\n"
"the project is first opened.")); "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()); m_threadLimitSpinBox.setValue(ClangdSettings::workerThreadLimit());
m_threadLimitSpinBox.setSpecialValueText("Automatic");
const auto layout = new QVBoxLayout(this); const auto layout = new QVBoxLayout(this);
layout->addWidget(&m_useClangdCheckBox); layout->addWidget(&m_useClangdCheckBox);
@@ -226,7 +224,8 @@ public:
const auto threadLimitLayout = new QHBoxLayout; const auto threadLimitLayout = new QHBoxLayout;
threadLimitLayout->addWidget(&m_threadLimitSpinBox); threadLimitLayout->addWidget(&m_threadLimitSpinBox);
threadLimitLayout->addStretch(1); threadLimitLayout->addStretch(1);
formLayout->addRow(&m_threadLimitCheckBox, threadLimitLayout); const auto threadLimitLabel = new QLabel(tr("Set worker thread count:"));
formLayout->addRow(threadLimitLabel, threadLimitLayout);
layout->addLayout(formLayout); layout->addLayout(formLayout);
layout->addStretch(1); layout->addStretch(1);
@@ -235,15 +234,11 @@ public:
m_clangdChooser.setEnabled(checked); m_clangdChooser.setEnabled(checked);
indexingLabel->setEnabled(checked); indexingLabel->setEnabled(checked);
m_indexingCheckBox.setEnabled(checked); m_indexingCheckBox.setEnabled(checked);
m_threadLimitCheckBox.setEnabled(checked); m_threadLimitSpinBox.setEnabled(checked);
m_threadLimitSpinBox.setEnabled(checked && m_threadLimitCheckBox.isChecked());
}; };
connect(&m_useClangdCheckBox, &QCheckBox::toggled, toggleEnabled); connect(&m_useClangdCheckBox, &QCheckBox::toggled, toggleEnabled);
connect(&m_threadLimitCheckBox, &QCheckBox::toggled,
&m_threadLimitSpinBox, &QSpinBox::setEnabled);
toggleEnabled(m_useClangdCheckBox.isChecked()); toggleEnabled(m_useClangdCheckBox.isChecked());
m_threadLimitSpinBox.setEnabled(m_useClangdCheckBox.isChecked() m_threadLimitSpinBox.setEnabled(m_useClangdCheckBox.isChecked());
&& m_threadLimitCheckBox.isChecked());
} }
private: private:
@@ -253,14 +248,12 @@ private:
data.useClangd = m_useClangdCheckBox.isChecked(); data.useClangd = m_useClangdCheckBox.isChecked();
data.executableFilePath = m_clangdChooser.filePath(); data.executableFilePath = m_clangdChooser.filePath();
data.enableIndexing = m_indexingCheckBox.isChecked(); data.enableIndexing = m_indexingCheckBox.isChecked();
data.workerThreadLimit = m_threadLimitCheckBox.isChecked() data.workerThreadLimit = m_threadLimitSpinBox.value();
? m_threadLimitSpinBox.value() : 0;
ClangdSettings::setData(data); ClangdSettings::setData(data);
} }
QCheckBox m_useClangdCheckBox; QCheckBox m_useClangdCheckBox;
QCheckBox m_indexingCheckBox; QCheckBox m_indexingCheckBox;
QCheckBox m_threadLimitCheckBox;
QSpinBox m_threadLimitSpinBox; QSpinBox m_threadLimitSpinBox;
Utils::PathChooser m_clangdChooser; Utils::PathChooser m_clangdChooser;
}; };