ClangFormat: Separate ClangFormat and Standard Indenter UI

The combined UI was a bit misleading for the user and cause
bunch of synchronization problems.

The synchronization between old CodeStyle settings and ClangFormat
settings was removed. Corresponding classes and functions
were also cleared.

The behavior now:
When "Indenting only" or "Full Formatting" modes are chosen then
The ClangFormat settings page is visible and the ClangFormat indenter
is used.
For "Disable" mode standard CodeStyle pages are shown and standard
indenter respectively.

Change-Id: Idb4974c68ceb16ef2e55b108043cc6f56f859840
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Artem Sokolovskii
2024-01-11 11:31:00 +01:00
parent 2ff533b499
commit bb88c8c9be
13 changed files with 45 additions and 184 deletions

View File

@@ -27,7 +27,7 @@ namespace ClangFormat {
ClangFormatGlobalConfigWidget::ClangFormatGlobalConfigWidget(
TextEditor::ICodeStylePreferences *codeStyle, ProjectExplorer::Project *project, QWidget *parent)
: CppCodeStyleWidget(parent)
: TextEditor::CodeStyleEditorWidget(parent)
, m_project(project)
, m_codeStyle(codeStyle)
{
@@ -122,7 +122,7 @@ void ClangFormatGlobalConfigWidget::initIndentationOrFormattingCombobox()
m_indentingOrFormatting->insertItem(static_cast<int>(ClangFormatSettings::Mode::Formatting),
Tr::tr("Full formatting"));
m_indentingOrFormatting->insertItem(static_cast<int>(ClangFormatSettings::Mode::Disable),
Tr::tr("Disable"));
Tr::tr("Use built-in indenter"));
m_indentingOrFormatting->setCurrentIndex(
static_cast<int>(getProjectIndentationOrFormattingSettings(m_project)));
@@ -226,8 +226,10 @@ void ClangFormatGlobalConfigWidget::initCustomSettingsCheckBox()
if (m_ignoreChanges.isLocked())
return;
Utils::GuardLocker locker(m_ignoreChanges);
m_codeStyle->currentPreferences()->setTemporarilyReadOnly(!m_useCustomSettingsCheckBox->isChecked());
m_codeStyle->currentPreferences()->setIsAdditionalTabDisabled(!m_useCustomSettingsCheckBox->isEnabled());
m_codeStyle->currentPreferences()->setTemporarilyReadOnly(
!m_useCustomSettingsCheckBox->isChecked());
m_codeStyle->currentPreferences()->setIsAdditionalTabVisible(
m_useCustomSettingsCheckBox->isEnabled());
ClangFormatSettings::instance().write();
emit m_codeStyle->currentPreferencesChanged(m_codeStyle->currentPreferences());
};