diff --git a/src/plugins/clangformat/clangformatglobalconfigwidget.cpp b/src/plugins/clangformat/clangformatglobalconfigwidget.cpp index f6e04576919..bdc64c13b16 100644 --- a/src/plugins/clangformat/clangformatglobalconfigwidget.cpp +++ b/src/plugins/clangformat/clangformatglobalconfigwidget.cpp @@ -11,6 +11,7 @@ #include "clangformatutils.h" #include +#include #include #include @@ -19,13 +20,13 @@ #include #include +#include #include #include #include #include #include -#include using namespace CppEditor; using namespace ProjectExplorer; @@ -34,8 +35,44 @@ using namespace Utils; namespace ClangFormat { -ClangFormatGlobalConfigWidget::ClangFormatGlobalConfigWidget( - TextEditor::ICodeStylePreferences *codeStyle, ProjectExplorer::Project *project, QWidget *parent) +class ClangFormatGlobalConfigWidget final : public CodeStyleEditorWidget +{ +public: + ClangFormatGlobalConfigWidget(ICodeStylePreferences *codeStyle, + Project *project, + QWidget *parent); + void apply() final; + void finish() final; + +private: + void initCheckBoxes(); + void initIndentationOrFormattingCombobox(); + void initCustomSettingsCheckBox(); + void initUseGlobalSettingsCheckBox(); + void initFileSizeThresholdSpinBox(); + void initCurrentProjectLabel(); + + bool projectClangFormatFileExists(); + + Project *m_project; + ICodeStylePreferences *m_codeStyle; + Guard m_ignoreChanges; + bool m_useCustomSettings; + + QLabel *m_projectHasClangFormat; + QLabel *m_formattingModeLabel; + QLabel *m_fileSizeThresholdLabel; + QSpinBox *m_fileSizeThresholdSpinBox; + QComboBox *m_indentingOrFormatting; + QCheckBox *m_formatWhileTyping; + QCheckBox *m_formatOnSave; + QCheckBox *m_useCustomSettingsCheckBox; + QCheckBox *m_useGlobalSettings; + QLabel *m_currentProjectLabel; +}; + +ClangFormatGlobalConfigWidget::ClangFormatGlobalConfigWidget(ICodeStylePreferences *codeStyle, + Project *project, QWidget *parent) : TextEditor::CodeStyleEditorWidget(parent) , m_project(project) , m_codeStyle(codeStyle) @@ -106,8 +143,6 @@ ClangFormatGlobalConfigWidget::ClangFormatGlobalConfigWidget( globalSettingsGroupBoxWidget->show(); } -ClangFormatGlobalConfigWidget::~ClangFormatGlobalConfigWidget() = default; - void ClangFormatGlobalConfigWidget::initCheckBoxes() { auto setEnableCheckBoxes = [this](int index) { diff --git a/src/plugins/clangformat/clangformatglobalconfigwidget.h b/src/plugins/clangformat/clangformatglobalconfigwidget.h index d262f27f950..1701d1a6f75 100644 --- a/src/plugins/clangformat/clangformatglobalconfigwidget.h +++ b/src/plugins/clangformat/clangformatglobalconfigwidget.h @@ -3,64 +3,10 @@ #pragma once -#include - -#include - -QT_BEGIN_NAMESPACE -class QCheckBox; -class QComboBox; -class QLabel; -class QSpinBox; -QT_END_NAMESPACE - -namespace ProjectExplorer { class Project; } -namespace TextEditor { -class ICodeStylePreferences; -class CodeStyleEditorWidget; -} // namespace TextEditor +#include namespace ClangFormat { -class ClangFormatGlobalConfigWidget : public TextEditor::CodeStyleEditorWidget -{ - Q_OBJECT - -public: - explicit ClangFormatGlobalConfigWidget(TextEditor::ICodeStylePreferences *codeStyle, - ProjectExplorer::Project *project = nullptr, - QWidget *parent = nullptr); - ~ClangFormatGlobalConfigWidget() override; - void apply() override; - void finish() override; - -private: - void initCheckBoxes(); - void initIndentationOrFormattingCombobox(); - void initCustomSettingsCheckBox(); - void initUseGlobalSettingsCheckBox(); - void initFileSizeThresholdSpinBox(); - void initCurrentProjectLabel(); - - bool projectClangFormatFileExists(); - - ProjectExplorer::Project *m_project; - TextEditor::ICodeStylePreferences *m_codeStyle; - Utils::Guard m_ignoreChanges; - bool m_useCustomSettings; - - QLabel *m_projectHasClangFormat; - QLabel *m_formattingModeLabel; - QLabel *m_fileSizeThresholdLabel; - QSpinBox *m_fileSizeThresholdSpinBox; - QComboBox *m_indentingOrFormatting; - QCheckBox *m_formatWhileTyping; - QCheckBox *m_formatOnSave; - QCheckBox *m_useCustomSettingsCheckBox; - QCheckBox *m_useGlobalSettings; - QLabel *m_currentProjectLabel; -}; - void setupClangFormatStyleFactory(QObject *guard); -} // namespace ClangFormat +} // ClangFormat