From 83f6c82752668d60f169b395acbf9d1ae959a33a Mon Sep 17 00:00:00 2001 From: Christian Kandeler Date: Mon, 28 Mar 2022 11:59:52 +0200 Subject: [PATCH] CppEditor: Show project-specific clangd settings conditionally That is, only if the ClangCodeModel is enabled, as it was already done for the global clangd settings. The current mix is an excellent way to confuse users. Change-Id: I1d3e7a366172ed972ac1ed04c4b332686a2ffb10 Reviewed-by: David Schulz Reviewed-by: Reviewed-by: Qt CI Bot --- src/plugins/cppeditor/cppeditorplugin.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/cppeditor/cppeditorplugin.cpp b/src/plugins/cppeditor/cppeditorplugin.cpp index 0bc90d1f1f1..8b144601e24 100644 --- a/src/plugins/cppeditor/cppeditorplugin.cpp +++ b/src/plugins/cppeditor/cppeditorplugin.cpp @@ -294,14 +294,6 @@ bool CppEditorPlugin::initialize(const QStringList & /*arguments*/, QString *err tr("Insert \"#pragma once\" instead of \"#ifndef\" include guards into header file"), [] { return usePragmaOnce() ? QString("true") : QString(); }); - const auto clangdPanelFactory = new ProjectPanelFactory; - clangdPanelFactory->setPriority(100); - clangdPanelFactory->setDisplayName(tr("Clangd")); - clangdPanelFactory->setCreateWidgetFunction([](Project *project) { - return new ClangdProjectSettingsWidget(project); - }); - ProjectPanelFactory::registerFactory(clangdPanelFactory); - const auto quickFixSettingsPanelFactory = new ProjectPanelFactory; quickFixSettingsPanelFactory->setPriority(100); quickFixSettingsPanelFactory->setId(Constants::QUICK_FIX_PROJECT_PANEL_ID); @@ -441,8 +433,17 @@ void CppEditorPlugin::extensionsInitialized() d->m_fileSettings.fromSettings(ICore::settings()); if (!d->m_fileSettings.applySuffixesToMimeDB()) qWarning("Unable to apply cpp suffixes to mime database (cpp mime types not found).\n"); - if (CppModelManager::instance()->isClangCodeModelActive()) + + if (CppModelManager::instance()->isClangCodeModelActive()) { d->m_clangdSettingsPage = new ClangdSettingsPage; + const auto clangdPanelFactory = new ProjectPanelFactory; + clangdPanelFactory->setPriority(100); + clangdPanelFactory->setDisplayName(tr("Clangd")); + clangdPanelFactory->setCreateWidgetFunction([](Project *project) { + return new ClangdProjectSettingsWidget(project); + }); + ProjectPanelFactory::registerFactory(clangdPanelFactory); + } // Add the hover handler factories here instead of in initialize() // so that the Clang Code Model has a chance to hook in.