forked from qt-creator/qt-creator
CppEditor: Tell users about clangd configuration files
It's not feasible to map every possible setting into our UI, so instead teach people how to use the clangd configuration mechanism. Change-Id: Id11e81e25b687a4f49af4e090203faca3a75722d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -88,7 +88,6 @@
|
||||
#include <QPair>
|
||||
#include <QPointer>
|
||||
#include <QRegularExpression>
|
||||
#include <QStandardPaths>
|
||||
#include <QVBoxLayout>
|
||||
#include <QWidget>
|
||||
#include <QtConcurrent>
|
||||
@@ -603,10 +602,9 @@ public:
|
||||
|
||||
void setupClangdConfigFile()
|
||||
{
|
||||
const Utils::FilePath baseDir = Utils::FilePath::fromString(
|
||||
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)) / "clangd";
|
||||
const Utils::FilePath targetConfigFile = CppEditor::ClangdSettings::clangdUserConfigFilePath();
|
||||
const Utils::FilePath baseDir = targetConfigFile.parentDir();
|
||||
baseDir.ensureWritableDir();
|
||||
const Utils::FilePath targetConfigFile = baseDir / "config.yaml";
|
||||
Utils::FileReader configReader;
|
||||
const QByteArray firstLine = "# This file was generated by Qt Creator and will be overwritten "
|
||||
"unless you remove this line.";
|
||||
|
@@ -42,6 +42,7 @@
|
||||
#include <QHash>
|
||||
#include <QPair>
|
||||
#include <QSettings>
|
||||
#include <QStandardPaths>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
@@ -418,6 +419,13 @@ FilePath ClangdSettings::clangdIncludePath() const
|
||||
return includePath;
|
||||
}
|
||||
|
||||
FilePath ClangdSettings::clangdUserConfigFilePath()
|
||||
{
|
||||
return FilePath::fromString(
|
||||
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation))
|
||||
/ "clangd/config.yaml";
|
||||
}
|
||||
|
||||
void ClangdSettings::loadSettings()
|
||||
{
|
||||
Utils::fromSettings(clangdSettingsKey(), {}, Core::ICore::settings(), &m_data);
|
||||
|
@@ -156,6 +156,7 @@ public:
|
||||
static QVersionNumber clangdVersion(const Utils::FilePath &clangdFilePath);
|
||||
QVersionNumber clangdVersion() const { return clangdVersion(clangdFilePath()); }
|
||||
Utils::FilePath clangdIncludePath() const;
|
||||
static Utils::FilePath clangdUserConfigFilePath();
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
static void setUseClangd(bool use);
|
||||
|
@@ -39,6 +39,7 @@
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
@@ -341,6 +342,26 @@ ClangdSettingsWidget::ClangdSettingsWidget(const ClangdSettings::Data &settingsD
|
||||
// TODO: Remove once the concept is functional.
|
||||
d->sessionsGroupBox->hide();
|
||||
}
|
||||
|
||||
const auto configFilesHelpLabel = new QLabel;
|
||||
configFilesHelpLabel->setText(tr("Additional settings are available via "
|
||||
"<a href=\"https://clangd.llvm.org/config\"> clangd configuration files</a>.<br>"
|
||||
"General settings go <a href=\"%1\">here</a> "
|
||||
"and can be overridden per project by putting a .clangd file into "
|
||||
"the project source tree.")
|
||||
.arg(ClangdSettings::clangdUserConfigFilePath().toUserOutput()));
|
||||
connect(configFilesHelpLabel, &QLabel::linkHovered, configFilesHelpLabel, &QLabel::setToolTip);
|
||||
connect(configFilesHelpLabel, &QLabel::linkActivated, [](const QString &link) {
|
||||
if (link.startsWith("https"))
|
||||
QDesktopServices::openUrl(link);
|
||||
else
|
||||
Core::EditorManager::openEditor(Utils::FilePath::fromString(link));
|
||||
});
|
||||
const auto separator = new QFrame;
|
||||
separator->setFrameShape(QFrame::HLine);
|
||||
layout->addWidget(separator);
|
||||
layout->addWidget(configFilesHelpLabel);
|
||||
|
||||
layout->addStretch(1);
|
||||
|
||||
static const auto setWidgetsEnabled = [](QLayout *layout, bool enabled, const auto &f) -> void {
|
||||
|
Reference in New Issue
Block a user