forked from qt-creator/qt-creator
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user