2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2019-08-27 16:09:39 +02:00
|
|
|
#include "settingswidget.h"
|
|
|
|
|
|
2019-08-28 08:56:22 +02:00
|
|
|
#include "clangtoolsconstants.h"
|
2018-01-17 15:08:30 +01:00
|
|
|
#include "clangtoolsutils.h"
|
2022-09-26 16:08:37 +02:00
|
|
|
#include "runsettingswidget.h"
|
2015-03-03 11:08:26 +01:00
|
|
|
|
2021-08-30 10:58:08 +02:00
|
|
|
#include <cppeditor/clangdiagnosticconfigsmodel.h>
|
|
|
|
|
#include <cppeditor/clangdiagnosticconfigsselectionwidget.h>
|
2019-09-25 15:46:15 +02:00
|
|
|
|
2020-02-03 09:18:49 +01:00
|
|
|
#include <debugger/analyzer/analyzericons.h>
|
|
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
#include <utils/pathchooser.h>
|
|
|
|
|
|
|
|
|
|
#include <QCoreApplication>
|
2019-09-25 15:46:15 +02:00
|
|
|
|
2021-08-12 09:19:55 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
namespace ClangTools::Internal {
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2019-10-21 14:59:57 +02:00
|
|
|
static SettingsWidget *m_instance = nullptr;
|
|
|
|
|
|
|
|
|
|
SettingsWidget *SettingsWidget::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 17:45:16 +01:00
|
|
|
SettingsWidget::SettingsWidget()
|
2022-09-26 16:08:37 +02:00
|
|
|
: m_settings(ClangToolsSettings::instance())
|
2014-09-25 11:11:58 +02:00
|
|
|
{
|
2019-10-21 14:59:57 +02:00
|
|
|
m_instance = this;
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
resize(400, 300);
|
2019-08-28 08:56:22 +02:00
|
|
|
|
2021-08-12 09:19:55 +02:00
|
|
|
QString placeHolderText = shippedClangTidyExecutable().toUserOutput();
|
|
|
|
|
FilePath path = m_settings->clangTidyExecutable();
|
2019-08-28 08:56:22 +02:00
|
|
|
if (path.isEmpty() && placeHolderText.isEmpty())
|
|
|
|
|
path = Constants::CLANG_TIDY_EXECUTABLE_NAME;
|
2022-09-26 16:08:37 +02:00
|
|
|
m_clangTidyPathChooser = new PathChooser;
|
|
|
|
|
m_clangTidyPathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
m_clangTidyPathChooser->setPromptDialogTitle(tr("Clang-Tidy Executable"));
|
|
|
|
|
m_clangTidyPathChooser->setDefaultValue(placeHolderText);
|
|
|
|
|
m_clangTidyPathChooser->setFilePath(path);
|
|
|
|
|
m_clangTidyPathChooser->setHistoryCompleter("ClangTools.ClangTidyExecutable.History");
|
2019-08-28 08:56:22 +02:00
|
|
|
|
2021-08-12 09:19:55 +02:00
|
|
|
placeHolderText = shippedClazyStandaloneExecutable().toUserOutput();
|
2020-05-13 14:47:35 +02:00
|
|
|
path = m_settings->clazyStandaloneExecutable();
|
|
|
|
|
if (path.isEmpty() && placeHolderText.isEmpty())
|
|
|
|
|
path = Constants::CLAZY_STANDALONE_EXECUTABLE_NAME;
|
2022-09-26 16:08:37 +02:00
|
|
|
m_clazyStandalonePathChooser = new PathChooser;
|
|
|
|
|
m_clazyStandalonePathChooser->setExpectedKind(PathChooser::ExistingCommand);
|
|
|
|
|
m_clazyStandalonePathChooser->setPromptDialogTitle(tr("Clazy Executable"));
|
|
|
|
|
m_clazyStandalonePathChooser->setDefaultValue(placeHolderText);
|
|
|
|
|
m_clazyStandalonePathChooser->setFilePath(path);
|
|
|
|
|
m_clazyStandalonePathChooser->setHistoryCompleter("ClangTools.ClazyStandaloneExecutable.History");
|
|
|
|
|
|
|
|
|
|
m_runSettingsWidget = new RunSettingsWidget;
|
|
|
|
|
m_runSettingsWidget->fromSettings(m_settings->runSettings());
|
|
|
|
|
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
|
Group {
|
|
|
|
|
title(tr("Executables")),
|
|
|
|
|
Form {
|
|
|
|
|
tr("Clang-Tidy:"), m_clangTidyPathChooser, br,
|
|
|
|
|
tr("Clazy-Standalone:"), m_clazyStandalonePathChooser
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
m_runSettingsWidget,
|
|
|
|
|
st
|
|
|
|
|
}.attachTo(this);
|
2019-09-13 10:49:14 +02:00
|
|
|
}
|
2018-05-07 15:40:14 +02:00
|
|
|
|
2019-09-13 10:49:14 +02:00
|
|
|
void SettingsWidget::apply()
|
|
|
|
|
{
|
2019-10-01 16:53:01 +02:00
|
|
|
// Executables
|
2021-08-12 09:19:55 +02:00
|
|
|
m_settings->setClangTidyExecutable(clangTidyPath());
|
|
|
|
|
m_settings->setClazyStandaloneExecutable(clazyStandalonePath());
|
2019-10-01 16:53:01 +02:00
|
|
|
|
|
|
|
|
// Run options
|
2022-09-26 16:08:37 +02:00
|
|
|
m_settings->setRunSettings(m_runSettingsWidget->toSettings());
|
2018-05-07 15:40:14 +02:00
|
|
|
|
2019-10-01 16:53:01 +02:00
|
|
|
// Custom configs
|
2021-08-30 10:58:08 +02:00
|
|
|
const CppEditor::ClangDiagnosticConfigs customConfigs
|
2022-09-26 16:08:37 +02:00
|
|
|
= m_runSettingsWidget->diagnosticSelectionWidget()->customConfigs();
|
2019-10-01 16:53:01 +02:00
|
|
|
m_settings->setDiagnosticConfigs(customConfigs);
|
|
|
|
|
|
2019-09-13 10:49:14 +02:00
|
|
|
m_settings->writeSettings();
|
2014-09-25 11:11:58 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-21 14:59:57 +02:00
|
|
|
SettingsWidget::~SettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
m_instance = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-12 09:19:55 +02:00
|
|
|
FilePath SettingsWidget::clangTidyPath() const
|
2019-10-21 14:59:57 +02:00
|
|
|
{
|
2022-09-26 16:08:37 +02:00
|
|
|
return m_clangTidyPathChooser->rawFilePath();
|
2019-10-21 14:59:57 +02:00
|
|
|
}
|
|
|
|
|
|
2021-08-12 09:19:55 +02:00
|
|
|
FilePath SettingsWidget::clazyStandalonePath() const
|
2019-10-21 14:59:57 +02:00
|
|
|
{
|
2022-09-26 16:08:37 +02:00
|
|
|
return m_clazyStandalonePathChooser->rawFilePath();
|
2019-10-21 14:59:57 +02:00
|
|
|
}
|
2014-09-25 11:11:58 +02:00
|
|
|
|
2020-02-03 09:18:49 +01:00
|
|
|
// ClangToolsOptionsPage
|
|
|
|
|
|
|
|
|
|
ClangToolsOptionsPage::ClangToolsOptionsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(Constants::SETTINGS_PAGE_ID);
|
|
|
|
|
setDisplayName(QCoreApplication::translate(
|
|
|
|
|
"ClangTools::Internal::ClangToolsOptionsPage",
|
|
|
|
|
"Clang Tools"));
|
|
|
|
|
setCategory("T.Analyzer");
|
|
|
|
|
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
|
|
|
|
|
setCategoryIconPath(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
|
|
|
|
|
setWidgetCreator([] { return new SettingsWidget; });
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-26 16:08:37 +02:00
|
|
|
} // ClangTools::Internal
|