Merge remote-tracking branch 'origin/10.0'

Change-Id: I98e5e1ad43103984b490c65cdeed84b7414303b3
This commit is contained in:
Eike Ziller
2023-05-11 10:33:18 +02:00
19 changed files with 185 additions and 75 deletions

View File

@@ -88,8 +88,8 @@ ClangFormatConfigWidget::ClangFormatConfigWidget(TextEditor::ICodeStylePreferenc
d->checksScrollArea->setWidget(d->checksWidget);
d->checksScrollArea->setWidgetResizable(true);
d->checksWidget->setEnabled(!codeStyle->isReadOnly()
&& !codeStyle->isTemporarilyReadOnly());
d->checksWidget->setEnabled(!codeStyle->isReadOnly() && !codeStyle->isTemporarilyReadOnly()
&& !codeStyle->isAdditionalTabDisabled());
FilePath fileName;
if (d->project)
@@ -140,8 +140,8 @@ void ClangFormatConfigWidget::slotCodeStyleChanged(
d->config->setIsReadOnly(codeStyle->isReadOnly());
d->style = d->config->style();
d->checksWidget->setEnabled(!codeStyle->isReadOnly()
&& !codeStyle->isTemporarilyReadOnly());
d->checksWidget->setEnabled(!codeStyle->isReadOnly() && !codeStyle->isTemporarilyReadOnly()
&& !codeStyle->isAdditionalTabDisabled());
fillTable();
updatePreview();

View File

@@ -156,9 +156,20 @@ void ClangFormatGlobalConfigWidget::initOverrideCheckBox()
"can be overridden by the settings below."));
}
auto setEnableOverrideCheckBox = [this](int index) {
auto setTemporarilyReadOnly = [this]() {
if (m_ignoreChanges.isLocked())
return;
Utils::GuardLocker locker(m_ignoreChanges);
m_codeStyle->currentPreferences()->setTemporarilyReadOnly(!m_overrideDefault->isChecked());
m_codeStyle->currentPreferences()->setIsAdditionalTabDisabled(!m_overrideDefault->isEnabled());
ClangFormatSettings::instance().write();
emit m_codeStyle->currentPreferencesChanged(m_codeStyle->currentPreferences());
};
auto setEnableOverrideCheckBox = [this, setTemporarilyReadOnly](int index) {
bool isDisable = index == static_cast<int>(ClangFormatSettings::Mode::Disable);
m_overrideDefault->setDisabled(isDisable);
setTemporarilyReadOnly();
};
setEnableOverrideCheckBox(m_indentingOrFormatting->currentIndex());
@@ -176,20 +187,19 @@ void ClangFormatGlobalConfigWidget::initOverrideCheckBox()
".clang-format file."));
m_overrideDefault->setChecked(getProjectOverriddenSettings(m_project));
m_codeStyle->currentPreferences()->setTemporarilyReadOnly(!m_overrideDefault->isChecked());
setTemporarilyReadOnly();
connect(m_overrideDefault, &QCheckBox::toggled, this, [this](bool checked) {
connect(m_overrideDefault, &QCheckBox::toggled, this, [this, setTemporarilyReadOnly](bool checked) {
if (m_project)
m_project->setNamedSettings(Constants::OVERRIDE_FILE_ID, checked);
else {
m_codeStyle->currentPreferences()->setTemporarilyReadOnly(!checked);
emit m_codeStyle->currentPreferencesChanged(m_codeStyle->currentPreferences());
}
else
setTemporarilyReadOnly();
});
connect(m_codeStyle, &TextEditor::ICodeStylePreferences::currentPreferencesChanged, this, [this] {
m_codeStyle->currentPreferences()->setTemporarilyReadOnly(!m_overrideDefault->isChecked());
});
connect(m_codeStyle,
&TextEditor::ICodeStylePreferences::currentPreferencesChanged,
this,
setTemporarilyReadOnly);
}

View File

@@ -5,6 +5,8 @@
#include <cppeditor/cppcodestylesettingspage.h>
#include <utils/guard.h>
#include <memory>
QT_BEGIN_NAMESPACE
@@ -40,6 +42,7 @@ private:
ProjectExplorer::Project *m_project;
TextEditor::ICodeStylePreferences *m_codeStyle;
Utils::Guard m_ignoreChanges;
QLabel *m_projectHasClangFormat;
QLabel *m_formattingModeLabel;

View File

@@ -213,10 +213,14 @@ bool getCurrentOverriddenSettings(const Utils::FilePath &filePath)
const ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::projectForFile(
filePath);
return getProjectUseGlobalSettings(project) ? !TextEditor::TextEditorSettings::codeStyle("Cpp")
->currentPreferences()
->isTemporarilyReadOnly()
: getProjectOverriddenSettings(project);
return getProjectUseGlobalSettings(project)
? !TextEditor::TextEditorSettings::codeStyle("Cpp")
->currentPreferences()
->isTemporarilyReadOnly()
&& !TextEditor::TextEditorSettings::codeStyle("Cpp")
->currentPreferences()
->isAdditionalTabDisabled()
: getProjectOverriddenSettings(project);
}
ClangFormatSettings::Mode getProjectIndentationOrFormattingSettings(