ClangFormat: Synchronize with C++ code style settings

And remove UI for default code style settings because
it does not affect anything when ClangFormat plugin is
enabled.

Change-Id: Ie348b7d2691b09ea2b4868da987f2a27347ea0f3
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
Ivan Donchevskii
2018-11-08 10:35:23 +01:00
parent 3de607f4e0
commit 0e5c7f51fa
9 changed files with 253 additions and 69 deletions

View File

@@ -45,8 +45,12 @@
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/target.h>
#include <texteditor/texteditorsettings.h>
#include <clang/Format/Format.h>
#include <utils/algorithm.h>
#include <QAction>
#include <QDebug>
#include <QMainWindow>
@@ -95,6 +99,24 @@ private:
ClangFormatPlugin::ClangFormatPlugin() = default;
ClangFormatPlugin::~ClangFormatPlugin() = default;
static void disableCppCodeStyle()
{
using namespace TextEditor;
TextEditorSettings::unregisterCodeStyleFactory(CppTools::Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStylePool(CppTools::Constants::CPP_SETTINGS_ID);
TextEditorSettings::unregisterCodeStyle(CppTools::Constants::CPP_SETTINGS_ID);
QList<Core::IOptionsPage *> pages = Core::IOptionsPage::allOptionsPages();
int codeStylePageIndex = Utils::indexOf(pages, [](Core::IOptionsPage *page) {
return page->id() == CppTools::Constants::CPP_CODE_STYLE_SETTINGS_ID;
});
if (codeStylePageIndex >= 0) {
auto *page = pages[codeStylePageIndex];
page->finish();
page->deleteLater();
}
}
bool ClangFormatPlugin::initialize(const QStringList &arguments, QString *errorString)
{
Q_UNUSED(arguments);
@@ -113,6 +135,8 @@ bool ClangFormatPlugin::initialize(const QStringList &arguments, QString *errorS
CppTools::CppModelManager::instance()->setCppIndenterCreator([]() {
return new ClangFormatIndenter();
});
disableCppCodeStyle();
#endif
return true;
}